Compare commits

..

11 Commits

Author SHA1 Message Date
ca8728c90c модалочки оп-оп 2026-06-01 05:07:42 +06:00
0dd9efb9fb обновОЧКИ 2026-05-29 04:28:09 +06:00
3c885edc46 brutalism design 2026-05-24 16:26:52 +06:00
12ae0ae839 brutalism design 2026-05-23 22:49:52 +06:00
d06892e990 brutalism design 2026-05-22 06:01:27 +06:00
5d45c9674f brutalism design 2026-05-22 05:27:41 +06:00
1ca73e786c brutalism design 2026-05-22 05:08:41 +06:00
e4ed785911 brutalism design 2026-05-22 05:08:02 +06:00
abf4d41c23 chat wip 2026-05-14 07:09:52 +06:00
edef0a70d2 brutalism design 2026-05-14 01:05:01 +06:00
6a2111092b working hard 2026-05-09 17:39:42 +06:00
107 changed files with 4462 additions and 1457 deletions

View File

@@ -1,7 +1,7 @@
{
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "Chad",
"version": "0.3.0-rc.3",
"version": "0.3.0-rc.4",
"identifier": "xyz.koptilnya.chad",
"build": {
"frontendDist": "../.output/public",

View File

@@ -0,0 +1,7 @@
{
"permissions": {
"allow": [
"Bash(python -c \"import sys,json; p=json.load\\(sys.stdin\\); deps={**p.get\\('dependencies',{}\\), **p.get\\('devDependencies',{}\\)}; [print\\(k,v\\) for k in sorted\\(deps\\) if any\\(x in k for x in ['mediasoup','socket','vueuse','vue']\\)]\")"
]
}
}

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

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

View File

@@ -8,7 +8,7 @@
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Manrope:wght@200..800&family=Unbounded:wght@200..900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/src/shared/styles/reset.css" />
<link rel="stylesheet" href="/src/shared/styles/sanitize.css" />

View File

@@ -6,17 +6,31 @@
"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",
"@tauri-apps/plugin-global-shortcut": "^2.3.1",
"@tauri-apps/plugin-opener": "~2",
"@tauri-apps/plugin-process": "^2.3.1",
"@tauri-apps/plugin-updater": "^2.10.1",
"@vueuse/core": "^14.3.0",
"@zag-js/avatar": "^1.40.0",
"@zag-js/collapsible": "^1.40.0",
"@zag-js/dialog": "^1.41.1",
"@zag-js/file-upload": "^1.41.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",
"vue": "^3.5.32",
"vue-router": "^5.0.6"
},

View File

@@ -0,0 +1 @@
{"rustc_fingerprint":1074701663444030447,"outputs":{"17747080675513052775":{"success":true,"status":"","code":0,"stdout":"rustc 1.95.0 (59807616e 2026-04-14)\nbinary: rustc\ncommit-hash: 59807616e1fa2540724bfbac14d7976d7e4a3860\ncommit-date: 2026-04-14\nhost: x86_64-pc-windows-msvc\nrelease: 1.95.0\nLLVM version: 22.1.2\n","stderr":""},"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___.exe\nlib___.rlib\n___.dll\n___.dll\n___.lib\n___.dll\nC:\\Users\\opti\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\npacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"msvc\"\ntarget_family=\"windows\"\ntarget_feature=\"cmpxchg16b\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"windows\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"pc\"\nwindows\n","stderr":""}},"successes":{}}

View File

@@ -0,0 +1 @@
{"rustc":8891013984288978370,"features":"[]","declared_features":"[]","target":12687594469746301899,"profile":8731458305071235362,"path":4942398508502643691,"deps":[[1322478694103194923,"app_lib",false,8070585750093435046],[1322478694103194923,"build_script_build",false,16691984141835454783],[2700615264719386388,"tauri_plugin_opener",false,7350390124577390804],[4736393929136623228,"tauri_plugin_global_shortcut",false,15267933955632970549],[5673630358394410545,"tauri_plugin_updater",false,14019643380268120922],[8695090098768911186,"windows",false,17298248671909505349],[10630857666389190470,"log",false,5016507518680283320],[12653526805862679340,"tauri_plugin_log",false,15855325777720298125],[13548984313718623784,"serde",false,7298479236282139191],[13795362694956882968,"serde_json",false,4974751760879812175],[13905323280135927163,"tauri_plugin_single_instance",false,10523578089830730283],[14261240476176424521,"tauri",false,8738078672178348289],[18393575805749125025,"tauri_plugin_process",false,17190748950968290852]],"local":[{"CheckDepInfo":{"dep_info":"debug\\.fingerprint\\app-4e7dc2d6835c5d74\\dep-bin-app","checksum":false}}],"rustflags":[],"config":8247474407144887393,"compile_kind":0}

Binary file not shown.

View File

@@ -2,9 +2,12 @@
<Component :is="layoutComponent">
<RouterView />
</Component>
<ChadDialogContainer />
</template>
<script setup lang="ts">
import ChadDialogContainer from '@shared/components/ui/DialogContainer.vue'
import DefaultLayout from '@shared/layouts/Default.vue'
import { computed } from 'vue'
import { useRoute } from 'vue-router'

View File

@@ -24,12 +24,19 @@ defineProps<{
&__image {
width: 120px;
margin-bottom: 32px;
margin-bottom: var(--space-6);
user-select: none;
opacity: 0.9;
}
&__message {
color: var(--text-muted);
@include font-body-bold;
padding: var(--space-2) var(--space-3);
background-color: var(--paper);
outline: var(--border-w) solid var(--ink);
outline-offset: calc(var(--border-w) * -1);
box-shadow: var(--shadow);
}
}
</style>

View File

@@ -16,10 +16,14 @@
height: 100%;
> p {
@include font-body-bold;
margin: auto;
padding: 8px 16px;
border-radius: 16px;
background-color: var(--bg-light);
padding: var(--space-2) var(--space-3);
background-color: var(--paper);
outline: var(--border-w) solid var(--ink);
outline-offset: calc(var(--border-w) * -1);
box-shadow: var(--shadow);
}
}
</style>

View File

@@ -21,10 +21,14 @@ const { checking, lastUpdate } = useUpdater()
height: 100%;
> p {
@include font-body-bold;
margin: auto;
padding: 8px 16px;
border-radius: 16px;
background-color: var(--bg-light);
padding: var(--space-2) var(--space-3);
background-color: var(--paper);
outline: var(--border-w) solid var(--ink);
outline-offset: calc(var(--border-w) * -1);
box-shadow: var(--shadow);
}
}
</style>

View File

@@ -2,6 +2,7 @@ import { useAuth } from '@shared/composables/use-auth'
import { createApp } from 'vue'
import App from '../App.vue'
import routerPlugin, { router } from '../plugins/router'
import tanstackQueryPlugin from '../plugins/tanstack-query'
const mountPoint = '#app'
@@ -14,8 +15,14 @@ export default async function () {
await router.isReady()
if (!authorized.value && router.currentRoute.value.meta.auth === undefined) {
router.push('/auth/login')
await router.push({ name: '/auth/login', replace: true })
}
if (authorized.value && router.currentRoute.value.meta.auth === 'guest') {
await router.push({ name: '/', replace: true })
}
app.use(tanstackQueryPlugin)
app.mount(mountPoint)
}

View File

@@ -0,0 +1,138 @@
import { useMediasoup } from '@shared/composables/use-mediasoup'
import { useSignaling } from '@shared/composables/use-signaling'
import { Device } from 'mediasoup-client'
import { markRaw, watch } from 'vue'
const ICE_SERVERS: RTCIceServer[] = [
{ urls: 'stun:stunserver2025.stunprotocol.org:3478' },
{ urls: 'stun:stun.l.google.com:19302' },
{ urls: 'stun:stun.l.google.com:5349' },
{ urls: 'stun:stun1.l.google.com:3478' },
{ urls: 'stun:stun1.l.google.com:5349' },
{ urls: 'stun:stun2.l.google.com:19302' },
{ urls: 'stun:stun2.l.google.com:5349' },
{ urls: 'stun:stun3.l.google.com:3478' },
{ urls: 'stun:stun3.l.google.com:5349' },
{ urls: 'stun:stun4.l.google.com:19302' },
{ urls: 'stun:stun4.l.google.com:5349' },
]
export default function () {
const { socket } = useSignaling()
const ms = useMediasoup()
watch(socket, (socket) => {
if (!socket)
return
socket.on('initialized', async (initData) => {
ms.device.value = new Device()
await ms.device.value.load({ routerRtpCapabilities: initData.rtpCapabilities })
const sendInfo = await socket.emitWithAck('create-transport', { producing: true, consuming: false })
const sendTransport = ms.device.value.createSendTransport({
...sendInfo,
iceServers: [...ICE_SERVERS, ...(sendInfo.iceServers ?? [])],
})
ms.sendTransport.value = sendTransport
await ms.transports.add({
id: sendTransport.id,
ref: markRaw(sendTransport),
})
sendTransport.on('connect', async ({ dtlsParameters }, callback, errback) => {
try {
await socket.emitWithAck('connect-transport', { transportId: sendTransport.id, dtlsParameters })
callback()
}
catch (error) {
if (error instanceof Error)
errback(error)
}
})
sendTransport.on('produce', async ({ kind, rtpParameters, appData }, callback, errback) => {
try {
const { id } = await socket.emitWithAck('produce', {
transportId: sendTransport.id,
kind,
rtpParameters,
appData,
})
callback({ id })
}
catch (error) {
if (error instanceof Error)
errback(error)
}
})
const recvInfo = await socket.emitWithAck('create-transport', { producing: false, consuming: true })
const recvTransport = ms.device.value.createRecvTransport({
...recvInfo,
iceServers: [...ICE_SERVERS, ...(recvInfo.iceServers ?? [])],
})
ms.recvTransport.value = recvTransport
await ms.transports.add({
id: recvTransport.id,
ref: markRaw(recvTransport),
})
recvTransport.on('connect', async ({ dtlsParameters }, callback, errback) => {
try {
await socket.emitWithAck('connect-transport', { transportId: recvTransport.id, dtlsParameters })
callback()
}
catch (error) {
if (error instanceof Error)
errback(error)
}
})
})
socket.on('new-consumer', async ({ id, producerId, kind, rtpParameters, socketId, appData, producerPaused }, cb) => {
const rt = ms.recvTransport.value
if (!rt)
return
const consumer = await rt.consume({
id,
producerId,
kind,
rtpParameters,
streamId: `${socketId}-${appData.source ?? 'stream'}`,
appData: { ...appData, socketId },
})
if (producerPaused)
consumer.pause()
await ms.consumers.add({
id: consumer.id,
paused: consumer.paused,
kind: consumer.kind,
appData: consumer.appData as Record<string, unknown>,
track: consumer.track,
ref: markRaw(consumer),
})
cb()
})
socket.on('consumer-closed', ({ consumerId }) => {
ms.consumers.get(consumerId)?.ref.close()
})
socket.on('consumer-paused', ({ consumerId }) => {
ms.consumers.get(consumerId)?.ref.pause()
})
socket.on('consumer-resumed', ({ consumerId }) => {
ms.consumers.get(consumerId)?.ref.resume()
})
socket.on('disconnect', () => {
ms.clearAll()
})
}, { immediate: true })
}

View File

@@ -0,0 +1,52 @@
import type { ChatMessage } from '@shared/api/generated-chad-api.ts'
import { useAuth } from '@shared/composables/use-auth.ts'
import { useClients } from '@shared/composables/use-clients'
import { useEventBus } from '@shared/composables/use-event-bus.ts'
import { useSignaling } from '@shared/composables/use-signaling'
import { watch, watchEffect } from 'vue'
import { queryClient } from '../plugins/tanstack-query'
export default function () {
const { authorized } = useAuth()
const signaling = useSignaling()
const { addClient, updateClient, removeClient, clear: clearClients } = useClients()
const eventBus = useEventBus()
watch(signaling.connected, (connected) => {
if (!connected)
return
const socket = signaling.socket.value!
socket.on('initialized', async ({ clients }) => {
addClient(...clients)
})
socket.on('new-client', (client) => {
addClient(client)
})
socket.on('client-switched-channel', (client) => {
updateClient(client.socketId, client)
})
socket.on('client-disconnected', (socketId) => {
removeClient(socketId)
})
socket.on('disconnect', async () => {
clearClients()
await queryClient.resetQueries()
})
socket.on('chat:new-message', (message: ChatMessage) => {
eventBus.emit('chat:new-message', message)
})
})
watchEffect(() => {
if (authorized.value) {
signaling.connect()
}
})
}

View File

@@ -1,27 +1,33 @@
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 () => {
try {
await checkUpdates()
if (!import.meta.env.DEV)
await checkUpdates()
preloader.show()
await authorize()
initializeApp()
connectSignaling()
setupMediasoup()
await initializeApp()
}
catch (error) {
console.error(error)
if (error instanceof Error && error.message) {
showError(error.message)
await showError(error.message)
}
else {
showError('Something went wrong')
await showError('Something went wrong')
}
}
finally {

View File

@@ -1,4 +1,5 @@
import type { Component, FunctionPlugin } from 'vue'
import { useAuth } from '@shared/composables/use-auth'
import { createRouter, createWebHistory } from 'vue-router'
import { routes } from 'vue-router/auto-routes'
@@ -13,6 +14,23 @@ export const router = createRouter({
history: createWebHistory(),
routes,
})
router.onError((e) => {
console.log('wtf', e)
})
router.isReady().then(() => {
router.beforeEach((to) => {
const { authorized } = useAuth()
if (authorized.value && to.meta.auth === 'guest') {
return { name: '/', replace: true }
}
if (!authorized.value && to.meta.auth === undefined) {
return { name: '/auth/login', replace: true }
}
})
})
export default {
install(app) {

View File

@@ -0,0 +1,18 @@
import type { FunctionPlugin } from 'vue'
import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query'
export const queryClient = new QueryClient({
defaultOptions: {
queries: {
retry: false,
},
},
})
export default {
install(app) {
app.use(VueQueryPlugin, {
queryClient,
})
},
} as FunctionPlugin

View File

@@ -0,0 +1,19 @@
import type { Channel, CreateChannelPayload, ResponseError } from '@shared/api/generated-chad-api'
import api from '@shared/api/client'
import { useMutation, useQueryClient } from '@tanstack/vue-query'
export function mCreateChannel() {
const queryClient = useQueryClient()
return useMutation<Channel, ResponseError, CreateChannelPayload, Channel>({
mutationFn: async (payload) => {
const response = await api.chad.channelCreate(payload)
return response.data
},
onSuccess: async () => {
await queryClient.invalidateQueries({ queryKey: ['channel-list'] })
},
})
}

View File

@@ -0,0 +1,44 @@
<template>
<ChadDialog :id="DIALOG_ID" title="Create channel">
<ChadInput v-model="name" label="Name" />
<template #actions>
<ChadButton style="grid-column: 2" :disabled="!valid" :loading="submitting" @click="submit()">
Create
</ChadButton>
</template>
</ChadDialog>
</template>
<script setup lang="ts">
import ChadButton from '@shared/components/ui/Button.vue'
import ChadDialog from '@shared/components/ui/Dialog.vue'
import ChadInput from '@shared/components/ui/Input.vue'
import { useDialogManager } from '@shared/composables/use-dialog.ts'
import { computed, ref } from 'vue'
import { mCreateChannel } from '@/entities/channel/api/mCreateChannel.ts'
const DIALOG_ID = 'create-channel'
const dialogManager = useDialogManager()
const { mutateAsync: createChannel, isPending: submitting } = mCreateChannel()
const name = ref('')
const valid = computed(() => {
return name.value.trim().length > 0
})
async function submit() {
if (!valid.value)
return
await createChannel({
name: name.value,
persistent: false,
})
dialogManager.close(DIALOG_ID)
}
</script>

View File

@@ -10,5 +10,6 @@ definePage({
auth: 'guest',
layout: AuthLayout,
},
// redirect: '/auth/login',
})
</script>

View File

@@ -1,35 +1,71 @@
<template>
<div class="login-page">
<form class="login-page__form" @submit.prevent="">
<div class="login-page__fields">
<ChadInput placeholder="Login" error="Jopa" />
<ChadInput placeholder="Password" />
<ChadPasswordInput placeholder="Password" label="Test" />
</div>
<ChadCard class="login-page" as="form" title="Sign In" @submit.prevent="submit">
<div class="login-page__fields">
<ChadInput v-model="formData.username" label="Username" />
<ChadPasswordInput v-model="formData.password" label="Password" />
</div>
<ChadButton class="login-page__submit" full type="submit">
<template #actions>
<ChadButton full native-type="submit" :disabled="!valid" :loading="submitting">
Let's go
</ChadButton>
</form>
</div>
</template>
<template #bottom>
Don't have an account?
<RouterLink :to="{ name: '/auth/register' }">
Register
</RouterLink>
</template>
</ChadCard>
</template>
<script setup lang="ts">
import ChadButton from '@shared/components/ui/Button.vue'
import ChadCard from '@shared/components/ui/Card.vue'
import ChadInput from '@shared/components/ui/Input.vue'
import ChadPasswordInput from '@shared/components/ui/PasswordInput.vue'
import { useAuth } from '@shared/composables/use-auth.ts'
import { computed, reactive, ref } from 'vue'
const { login } = useAuth()
const submitting = ref(false)
const formData = reactive({
username: '',
password: '',
})
const valid = computed(() => {
if (!formData.username)
return false
if (!formData.password)
return false
return true
})
async function submit() {
if (!valid.value || submitting.value)
return
submitting.value = true
await login(formData.username, formData.password)
submitting.value = false
}
</script>
<style lang="scss">
.login-page {
&__fields {
> *:not(:last-child) {
margin-bottom: 16px;
margin-bottom: var(--space-4);
}
}
&__submit {
margin-top: 24px;
}
}
</style>

View File

@@ -1,6 +1,76 @@
<template>
Register page
<ChadCard class="register-page" as="form" title="Register" @submit.prevent="submit">
<div class="register-page__fields">
<ChadInput v-model="formData.username" label="Username" />
<ChadPasswordInput v-model="formData.password" label="Password" />
<ChadPasswordInput v-model="formData.repeatPassword" label="Repeat password" />
</div>
<template #actions>
<ChadButton full native-type="submit" :disabled="!valid" :loading="submitting">
Create an account
</ChadButton>
</template>
<template #bottom>
Already have an account?
<RouterLink :to="{ name: '/auth/login' }">
Sign In
</RouterLink>
</template>
</ChadCard>
</template>
<script setup lang="ts">
import ChadButton from '@shared/components/ui/Button.vue'
import ChadCard from '@shared/components/ui/Card.vue'
import ChadInput from '@shared/components/ui/Input.vue'
import ChadPasswordInput from '@shared/components/ui/PasswordInput.vue'
import { useAuth } from '@shared/composables/use-auth.ts'
import { computed, reactive, ref } from 'vue'
const { login } = useAuth()
const submitting = ref(false)
const formData = reactive({
username: '',
password: '',
repeatPassword: '',
})
const valid = computed(() => {
if (!formData.username)
return false
if (!formData.password)
return false
if (formData.password !== formData.repeatPassword)
return false
return true
})
async function submit() {
if (!valid.value || submitting.value)
return
submitting.value = true
await login(formData.username, formData.password)
submitting.value = false
}
</script>
<style lang="scss">
.register-page {
&__fields {
> *:not(:last-child) {
margin-bottom: var(--space-4);
}
}
}
</style>

View File

@@ -1,5 +1,7 @@
<template>
Index page
<Chat />
</template>
<script setup lang="ts"></script>
<script setup lang="ts">
import Chat from '@widgets/chat/ui/Chat.vue'
</script>

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 */
@@ -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

@@ -0,0 +1,22 @@
import type { ResponseError, User } from '@shared/api/generated-chad-api.ts'
import type { MaybeRefOrGetter } from 'vue'
import api from '@shared/api/client.ts'
import { useQuery } from '@tanstack/vue-query'
import { toValue } from 'vue'
export function qUser(username: MaybeRefOrGetter<string>) {
return useQuery<User, ResponseError>({
queryKey: ['user', username],
queryFn: async () => {
const response = await api.chad.userGet({ username: toValue(username) })
return response.data
},
staleTime: Infinity,
// persister: experimental_createQueryPersister({
// storage: localStorage,
// maxAge: 1000 * 60 * 60 * 24,
// prefix: 'CHAD_USER_',
// }),
})
}

View File

@@ -17,15 +17,21 @@ const { version } = useApp()
<style lang="scss">
.app-logo {
background-color: var(--ink);
padding: var(--space-2);
text-align: center;
&__title {
color: var(--primary);
font-weight: 700;
line-height: 20px;
@include font-display-22;
color: var(--yellow);
}
&__version {
font-size: 0.75rem;
color: var(--text-muted);
@include font-micro;
color: var(--grey-3);
margin-top: var(--space-1);
}
}
</style>

View File

@@ -0,0 +1,66 @@
<template>
<div class="chad-avatar" :class="{ highlighted }" v-bind="api.getRootProps()">
<span class="chad-avatar__fallback" v-bind="api.getFallbackProps()">{{ fallback }}</span>
<img class="chad-avatar__image" :alt="fallback" :src="src" v-bind="api.getImageProps()">
</div>
</template>
<script setup lang="ts">
import * as avatar from '@zag-js/avatar'
import { normalizeProps, useMachine } from '@zag-js/vue'
import { computed, useId } from 'vue'
defineOptions({
name: 'ChadAvatar',
})
defineProps<{
src: string
fallback: string
size?: 'sm'
highlighted?: boolean
}>()
const service = useMachine(avatar.machine, { id: useId() })
const api = computed(() => avatar.connect(service, normalizeProps))
</script>
<style lang="scss">
.chad-avatar {
$self: &;
outline: var(--border-w) solid var(--ink);
outline-offset: calc(var(--border-w) * -1);
width: 32px;
aspect-ratio: 1;
&__fallback {
@include font-label;
display: block;
text-align: center;
line-height: 32px;
background-color: var(--grey-2);
#{$self}.highlighted & {
background-color: var(--yellow);
}
&[data-state='hidden'] {
display: none;
}
}
&__image {
width: 100%;
height: 100%;
object-fit: cover;
object-position: center;
&[data-state='hidden'] {
display: none;
}
}
}
</style>

View File

@@ -1,59 +1,126 @@
<template>
<button
class="chad-button"
:data-loading="loading || undefined"
:class="[
bem.b(),
bem.exp(!!type, bem.m(type!)),
bem.is('icon-only', iconOnly),
bem.is('loading', loading),
bem.is('disabled', disabled),
bem.is('full', full),
]"
:disabled="disabled"
:type="type"
:data-full="full || undefined"
:type="nativeType"
>
<slot />
<ChadSpinner v-if="loading" class="chad-button__spinner" />
<template v-else>
<Component :is="icon" v-if="icon" class="chad-button__icon" />
<span v-if="$slots.default">
<slot />
</span>
</template>
</button>
</template>
<script setup lang="ts">
import type { Component } from 'vue'
import ChadSpinner from '@shared/components/ui/Spinner.vue'
import useBem from '@shared/composables/use-bem.ts'
import { computed, useSlots } from 'vue'
defineOptions({
name: 'ChadButton',
})
withDefaults(
defineProps<Props>(),
const props = withDefaults(
defineProps<ChadButtonProps>(),
{
type: 'button',
nativeType: 'button',
},
)
interface Props {
export interface ChadButtonProps {
loading?: boolean
disabled?: boolean
type?: 'button' | 'submit'
type?: 'secondary'
nativeType?: 'button' | 'submit'
icon?: Component
full?: boolean
}
const slots = useSlots()
const bem = useBem('chad-button')
const iconOnly = computed(() => {
return !slots.default && props.icon
})
</script>
<style lang="scss">
.chad-button {
@include font-display-14;
flex-shrink: 0;
border: none;
color: var(--bg-dark);
border-radius: 12px;
padding-inline: 12px;
color: var(--ink);
padding: 0 var(--space-3);
height: 44px;
background-color: var(--primary);
background-color: var(--yellow);
font-weight: 700;
text-align: center;
cursor: pointer;
transition-property: color, background-color;
transition-duration: 150ms;
transition-timing-function: ease-out;
outline: none;
outline: var(--border-w) solid var(--ink);
outline-offset: calc(var(--border-w) * -1);
&[data-full] {
&.is-full:not(.is-icon-only) {
width: 100%;
}
&.is-icon-only {
padding: 0;
aspect-ratio: 1;
}
&:hover,
&:focus,
&:focus {
background-color: var(--yellow-deep);
}
&:active {
background-color: var(--secondary);
background-color: var(--ink);
color: var(--yellow);
}
&--secondary {
background-color: var(--grey-1);
&:hover,
&:focus {
background-color: var(--grey-2);
}
&:active {
background-color: var(--grey-3);
color: var(--ink);
}
}
&:disabled {
cursor: not-allowed;
background-color: var(--grey-1);
color: var(--grey-3);
}
&.is-loading {
background-color: var(--grey-1);
cursor: wait;
}
&__icon {
&:not(:last-child) {
margin-right: var(--space-1);
}
}
}
</style>

View File

@@ -0,0 +1,85 @@
<template>
<Component :is="as" class="chad-card">
<div v-if="title || description" class="chad-card__header">
<p v-if="title" class="chad-card__title">
{{ title }}
</p>
<p v-if="description" class="chad-card__description">
{{ description }}
</p>
</div>
<div class="chad-card__content">
<slot />
</div>
<div v-if="!!slots.actions" class="chad-card__actions">
<slot name="actions" />
</div>
<div v-if="!!slots.bottom" class="chad-card__bottom">
<slot name="bottom" />
</div>
</Component>
</template>
<script setup lang="ts">
defineOptions({
name: 'ChadCard',
})
withDefaults(
defineProps<Props>(),
{
as: 'div',
},
)
const slots = defineSlots<{
default: []
actions: []
bottom: []
}>()
interface Props {
as?: string
title?: string
description?: string
}
</script>
<style lang="scss">
.chad-card {
display: block;
background-color: var(--paper);
padding: var(--space-6);
outline: var(--border-w) solid var(--ink);
outline-offset: calc(var(--border-w) * -1);
box-shadow: var(--shadow);
&__header {
margin-bottom: var(--space-6);
}
&__title {
@include font-display-22;
}
&__description {
margin-top: var(--space-2);
color: var(--grey-3);
}
&__actions {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: var(--space-3);
margin-top: var(--space-6);
}
&__bottom {
margin-top: var(--space-4);
}
}
</style>

View File

@@ -0,0 +1,169 @@
<template>
<Teleport to="body">
<div :class="[bem.b()]">
<Transition name="chad-dialog-overlay" appear>
<div v-if="api.open" :class="bem.e('overlay')" v-bind="api.getBackdropProps()" />
</Transition>
<Transition
name="chad-dialog-content"
appear
@after-enter="emit('opened')"
@before-leave="emit('beforeClose')"
@after-leave="emit('closed')"
>
<div v-if="api.open" :class="bem.e('positioner')" v-bind="api.getPositionerProps()">
<ChadCard
:class="bem.e('content')"
v-bind="api.getContentProps()"
:title="title"
:description="description"
>
<slot v-bind="{ close }" />
<template v-if="$slots.actions" #actions>
<slot name="actions" v-bind="{ close }" />
</template>
<template v-if="$slots.bottom" #bottom>
<slot name="bottom" v-bind="{ close }" />
</template>
<ChadButton v-bind="api.getCloseTriggerProps()" :icon="XIcon" :class="bem.e('close')" type="secondary" />
</ChadCard>
</div>
</Transition>
</div>
</Teleport>
</template>
<script setup lang="ts">
import type { Props as DialogProps } from '@zag-js/dialog'
import { XIcon } from '@lucide/vue'
import ChadButton from '@shared/components/ui/Button.vue'
import ChadCard from '@shared/components/ui/Card.vue'
import useBem from '@shared/composables/use-bem.ts'
import { useDialogManager } from '@shared/composables/use-dialog.ts'
import { connect, machine } from '@zag-js/dialog'
import { normalizeProps, useMachine } from '@zag-js/vue'
import { computed, getCurrentInstance, onBeforeUnmount, onMounted } from 'vue'
export interface ChadDialogProps {
id: string
title: string
description?: string
closeOnEscape?: boolean
closeOnInteractOutside?: boolean
}
defineOptions({
name: 'ChadDialog',
})
const props = withDefaults(
defineProps<ChadDialogProps>(),
{
closeOnEscape: true,
closeOnInteractOutside: true,
},
)
const emit = defineEmits<{
opened: []
beforeClose: []
closed: []
}>()
const bem = useBem('chad-dialog')
const service = useMachine(machine, computed(() => {
return {
id: props.id,
defaultOpen: true,
closeOnEscape: props.closeOnEscape,
closeOnInteractOutside: props.closeOnInteractOutside,
} as DialogProps
}))
const api = computed(() => connect(service, normalizeProps))
const instance = getCurrentInstance()
const manager = useDialogManager()
function close() {
api.value.setOpen(false)
}
onMounted(() => {
if (!instance)
return
manager.instances.push(instance)
})
onBeforeUnmount(() => {
const index = manager.instances.findIndex(_instance => _instance === instance)
if (index === -1)
return
manager.instances.splice(index, 1)
})
defineExpose({
close,
})
</script>
<style lang="scss">
.chad-dialog {
&__overlay {
position: fixed;
inset: 0;
background-color: color-mix(in srgb, var(--ink) 60%, transparent);
backdrop-filter: blur(4px);
}
&__positioner {
position: fixed;
inset: 0;
display: flex;
padding: var(--space-4);
}
&__content {
position: relative;
margin: auto;
width: 560px;
}
&__close {
position: absolute;
bottom: calc(100% + var(--space-2));
right: 0;
//right: var(--space-6);
//top: var(--space-6);
}
&-overlay-enter-active,
&-overlay-leave-active {
transition: opacity 0.15s ease-out;
}
&-overlay-enter-from,
&-overlay-leave-to {
opacity: 0;
}
&-content-enter-active,
&-content-leave-active {
transition: 0.15s ease-out;
transition-property: opacity, translate, scale;
}
&-content-enter-from,
&-content-leave-to {
opacity: 0;
scale: 0.99;
}
}
</style>

View File

@@ -0,0 +1,17 @@
<template>
<Component :is="dialog.component" v-for="dialog in dialogs" v-bind="dialog.attrs" :id="dialog.id" :key="dialog.id">
<template v-for="(slot, key) in dialog.slots" #[key] :key="key">
<Component :is="slot" />
</template>
</Component>
</template>
<script setup lang="ts">
import { useDialogManager } from '@shared/composables/use-dialog.ts'
defineOptions({
name: 'ChadDialogContainer',
})
const { dialogs } = useDialogManager()
</script>

View File

@@ -1,40 +1,47 @@
<template>
<FieldRoot class="chad-input" :invalid="!!error">
<FieldLabel v-if="label" class="chad-input__label">
<div
class="chad-input"
:class="{
'is-invalid': !!error,
}"
>
<label v-if="label" :for="inputId" class="chad-input__label">
{{ label }}
</FieldLabel>
</label>
<div class="chad-input__control">
<FieldInput v-model="modelValue" class="chad-input__input" :placeholder="placeholder" type="text" />
</div>
<input :id="inputId" v-model="modelValue" class="chad-input__input" :placeholder="placeholder" type="text" autocomplete="off">
<FieldHelperText v-if="helper" class="chad-input__helper">
<p v-if="helper" class="chad-input__helper">
{{ helper }}
</FieldHelperText>
<FieldErrorText v-if="error" class="chad-input__error">
</p>
<p v-if="error" class="chad-input__error">
{{ error }}
</FieldErrorText>
</FieldRoot>
</p>
</div>
</template>
<script setup lang="ts">
import type { FieldInputProps, FieldRootProps } from '@ark-ui/vue/field'
import { FieldErrorText, FieldHelperText, FieldInput, FieldLabel, FieldRoot } from '@ark-ui/vue/field'
import { computed, useId } from 'vue'
defineOptions({
name: 'ChadInput',
})
defineProps<Props>()
const modelValue = defineModel<FieldInputProps['modelValue']>('modelValue')
interface Props extends Omit<FieldRootProps, 'ids' | 'invalid'> {
interface Props {
id?: string
label?: string
placeholder?: string
helper?: string
error?: string
}
defineOptions({
name: 'ChadInput',
})
const props = defineProps<Props>()
const modelValue = defineModel<string>('modelValue')
const inputId = computed(() => {
return props.id ?? `input-${useId()}`
})
</script>
<style lang="scss">
@@ -42,44 +49,30 @@ interface Props extends Omit<FieldRootProps, 'ids' | 'invalid'> {
$self: &;
&__label {
@include font-label;
display: block;
color: var(--text-muted);
margin-bottom: 6px;
font-size: 0.75rem;
}
&__control {
border-radius: 12px;
padding-inline: 12px;
height: 44px;
background-color: var(--bg-light);
border: none;
outline: 1px solid var(--border);
outline-offset: -1px;
font-size: 1rem;
&:hover,
&:focus-within {
outline-color: var(--primary);
}
#{$self}[data-invalid] & {
outline-color: var(--danger);
}
color: var(--grey-3);
margin-bottom: var(--space-2);
}
&__input {
padding-inline: var(--space-3);
height: 44px;
background-color: var(--paper);
outline: var(--border-w) solid var(--ink);
outline-offset: calc(var(--border-w) * -1);
width: 100%;
height: 100%;
background: none;
border: none;
outline: none;
color: var(--text);
caret-color: var(--secondary);
color: var(--ink);
caret-color: var(--yellow);
caret-shape: block;
&::placeholder {
color: var(--text-muted);
font: inherit;
color: var(--grey-3);
opacity: 0.4;
font-style: italic;
}
&:-webkit-autofill,
@@ -91,21 +84,26 @@ interface Props extends Omit<FieldRootProps, 'ids' | 'invalid'> {
box-shadow: 0 0 0px 1000px var(--bg) inset;
background-color: var(--bg);
}
#{$self}.is-invalid & {
outline-color: var(--red);
}
}
&__helper,
&__error {
@include font-micro;
display: block;
font-size: 0.75rem;
margin-top: 6px;
margin-top: var(--space-1);
}
&__helper {
color: var(--text-muted);
color: var(--grey-3);
}
&__error {
color: var(--danger);
color: var(--red);
}
}
</style>

View File

@@ -0,0 +1,25 @@
<template>
<div class="chad-notification-badge">
<slot />
</div>
</template>
<script setup lang="ts">
</script>
<style lang="scss">
.chad-notification-badge {
position: relative;
&::after {
content: '';
position: absolute;
top: 0;
right: 0;
width: 12px;
aspect-ratio: 1;
background-color: var(--yellow);
}
}
</style>

View File

@@ -1,126 +1,131 @@
<template>
<FieldRoot class="chad-password-input" :invalid="!!error">
<FieldLabel v-if="label" class="chad-password-input__label">
<div class="chad-password-input" v-bind="api.getRootProps()">
<label v-if="label" class="chad-password-input__label" v-bind="api.getLabelProps()">
{{ label }}
</FieldLabel>
</label>
<PasswordInputRoot>
<PasswordInputControl class="chad-password-input__control">
<PasswordInputInput v-model="modelValue" class="chad-password-input__input" :placeholder="placeholder" />
<PasswordInputVisibilityTrigger class="chad-password-input__visibility-trigger">
<PasswordInputIndicator>
Z
<template #fallback>
X
</template>
</PasswordInputIndicator>
</PasswordInputVisibilityTrigger>
</PasswordInputControl>
</PasswordInputRoot>
<div class="chad-password-input__control" v-bind="api.getControlProps()">
<input v-bind="api.getInputProps()" v-model="modelValue" class="chad-password-input__input">
<FieldHelperText v-if="helper" class="chad-password-input__helper">
{{ helper }}
</FieldHelperText>
<FieldErrorText v-if="error" class="chad-password-input__error">
{{ error }}
</FieldErrorText>
</FieldRoot>
<button class="chad-password-input__visibility-trigger" v-bind="api.getVisibilityTriggerProps()">
<Component :is="api.visible ? EyeIcon : EyeOffIcon " v-bind="api.getIndicatorProps()" />
</button>
</div>
</div>
</template>
<script setup lang="ts">
import type { FieldInputProps, FieldRootProps } from '@ark-ui/vue/field'
import { FieldErrorText, FieldHelperText, FieldLabel, FieldRoot } from '@ark-ui/vue/field'
import { PasswordInputControl, PasswordInputIndicator, PasswordInputInput, PasswordInputRoot, PasswordInputVisibilityTrigger } from '@ark-ui/vue/password-input'
import { EyeIcon, EyeOffIcon } from '@lucide/vue'
import * as passwordInput from '@zag-js/password-input'
import { normalizeProps, useMachine } from '@zag-js/vue'
import { computed, useId } from 'vue'
defineOptions({
name: 'ChadPasswordInput',
})
defineProps<Props>()
const modelValue = defineModel<FieldInputProps['modelValue']>('modelValue')
interface Props extends Omit<FieldRootProps, 'ids' | 'invalid'> {
interface Props {
id?: string
label?: string
placeholder?: string
helper?: string
error?: string
}
defineOptions({
name: 'ChadPasswordInput',
})
const props = defineProps<Props>()
const modelValue = defineModel<string>('modelValue')
const inputId = computed(() => {
return props.id ?? `input-${useId()}`
})
const service = useMachine(passwordInput.machine, computed(() => {
return {
id: inputId.value,
ignorePasswordManagers: true,
autoComplete: undefined,
}
}))
const api = computed(() => passwordInput.connect(service, normalizeProps))
</script>
<style lang="scss">
.chad-password-input {
$self: &;
&__label {
@include font-label;
display: block;
color: var(--text-muted);
margin-bottom: 6px;
font-size: 0.75rem;
color: var(--grey-3);
margin-bottom: var(--space-2);
}
&__control {
position: relative;
border-radius: 12px;
padding-inline: 12px;
display: flex;
align-items: center;
height: 44px;
width: 100%;
background-color: var(--bg-light);
border: none;
outline: 1px solid var(--border);
outline-offset: -1px;
color: var(--text);
caret-color: var(--secondary);
font-size: 1rem;
&:hover,
&:focus {
outline-color: var(--primary);
}
&::placeholder {
color: var(--text-muted);
opacity: 0.4;
}
&[data-invalid] {
outline-color: var(--danger);
}
&:-webkit-autofill,
&:-webkit-autofill:enabled,
&:-webkit-autofill:hover,
&:-webkit-autofill:focus {
-webkit-text-fill-color: var(--text);
-webkit-box-shadow: 0 0 0px 1000px var(--bg) inset;
box-shadow: 0 0 0px 1000px var(--bg) inset;
background-color: var(--bg);
}
}
&__input {
flex: 1;
padding-inline: var(--space-3);
background-color: var(--paper);
outline: var(--border-w) solid var(--ink);
outline-offset: calc(var(--border-w) * -1);
width: 100%;
height: 100%;
background: none;
border: none;
outline: none;
color: var(--ink);
caret-color: var(--yellow);
caret-shape: block;
&::placeholder {
font: inherit;
color: var(--grey-3);
opacity: 0.4;
font-style: italic;
}
&[data-state='invalid'] {
outline-color: var(--red);
}
}
&__visibility-trigger {
position: absolute;
flex-shrink: 0;
background-color: var(--grey-1);
border: var(--border-w) solid var(--ink);
aspect-ratio: 1;
border-left: 0;
height: 100%;
&:hover,
&:focus {
background-color: var(--grey-2);
}
&:active {
background-color: var(--grey-3);
}
}
&__helper,
&__error {
@include font-micro;
display: block;
font-size: 0.75rem;
margin-top: 6px;
margin-top: var(--space-1);
}
&__helper {
color: var(--text-muted);
color: var(--grey-3);
}
&__error {
color: var(--danger);
color: var(--red);
}
}
</style>

View File

@@ -0,0 +1,43 @@
<template>
<div class="chad-spinner" />
</template>
<script setup lang="ts">
defineOptions({
name: 'ChadSpinner',
})
</script>
<style lang="scss">
.chad-spinner {
--color1: var(--yellow);
--color2: var(--ink);
display: inline-block;
position: relative;
width: 36px;
height: 12px;
background-image: linear-gradient(
to right,
var(--color1) 0%,
var(--color1) 33.333%,
transparent 33.333%,
transparent 66.666%,
var(--color2) 66.666%,
var(--color2) 100%
);
background-repeat: no-repeat;
animation: chad-spinner 400ms infinite;
}
@keyframes chad-spinner {
from {
--color1: var(--yellow);
--color2: var(--ink);
}
50% {
--color1: var(--ink);
--color2: var(--yellow);
}
}
</style>

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,38 @@
<template>
<button class="chad-to-bottom">
<ArrowDown />
</button>
</template>
<script setup lang="ts">
import { ArrowDown } from '@lucide/vue'
defineOptions({
name: 'ChadToBottom',
})
</script>
<style lang="scss">
.chad-to-bottom {
cursor: pointer;
width: 40px;
aspect-ratio: 1;
text-align: center;
line-height: 40px;
outline: var(--border-w) solid var(--ink);
outline-offset: calc(var(--border-w) * -1);
border: none;
background-color: var(--grey-1);
padding: 0;
box-shadow: var(--shadow-sm);
&:hover,
&:focus {
background-color: var(--grey-2);
}
&:active {
background-color: var(--grey-3);
}
}
</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

@@ -1,4 +1,5 @@
import type { User } from '../api/generated-chad-api'
import { router } from '@app/plugins/router'
import { createGlobalState } from '@vueuse/core'
import { computed, readonly, shallowRef } from 'vue'
import api from '../api/client'
@@ -20,6 +21,8 @@ export const useAuth = createGlobalState(() => {
})
setMe(response.data)
await router.push({ name: '/', replace: true })
}
catch {
setMe(undefined)
@@ -34,6 +37,8 @@ export const useAuth = createGlobalState(() => {
})
setMe(response.data)
await router.push({ name: '/', replace: true })
}
catch {}
}
@@ -43,6 +48,8 @@ export const useAuth = createGlobalState(() => {
await api.chad.authLogout()
setMe(undefined)
await router.push({ name: '/auth/login' })
}
catch {}
}

View File

@@ -0,0 +1,68 @@
interface Options {
block: string
blockSuffix?: string
element?: string
modifier?: string
}
function _bem(options: Options) {
const { block, blockSuffix, element, modifier } = options
let cls = block
if (blockSuffix)
cls += `-${blockSuffix}`
if (element)
cls += `__${element}`
if (modifier)
cls += `--${modifier}`
return cls
}
function isTruthy(value: unknown): boolean {
if (Array.isArray(value)) {
return value.length > 0
}
else if (typeof value === 'object' && value !== null) {
return Object.keys(value).length > 0
}
return !!value
}
export default (block: string) => {
const b = (blockSuffix?: string) => _bem({ block, blockSuffix })
const e = (element: string) => _bem({ block, element })
const m = (modifier: string) => _bem({ block, modifier })
const be = (blockSuffix: string, element: string) => _bem({ block, blockSuffix, element })
const em = (element: string, modifier: string) => _bem({ block, element, modifier })
const bm = (blockSuffix: string, modifier: string) => _bem({ block, blockSuffix, modifier })
const bem = (blockSuffix: string, element: string, modifier: string) => _bem({ block, blockSuffix, element, modifier })
const is = (name: string, state: unknown) => isTruthy(state) ? `is-${name}` : ''
const has = (name: string, state: unknown) => isTruthy(state) ? `has-${name}` : ''
const exp = (condition: boolean, trueState: string, falseState: string = '') => condition ? trueState : falseState
return {
b,
e,
m,
be,
em,
bm,
bem,
is,
has,
exp,
}
}

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

@@ -0,0 +1,69 @@
import type { Component, ComponentInternalInstance } from 'vue'
import { createGlobalState } from '@vueuse/core'
import { mergeProps, shallowReactive } from 'vue'
type ComponentAttrs = Record<string, any>
export interface UseDialogOptions {
id: string
component: Component
attrs?: ComponentAttrs
slots?: Record<string, Component>
}
export const useDialogManager = createGlobalState(() => {
const dialogs = shallowReactive<UseDialogOptions[]>([])
const instances = shallowReactive<ComponentInternalInstance[]>([])
function close(id: UseDialogOptions['id']) {
const instance = instances.find(instance => instance.props.id === id)
if (!instance?.exposed?.close || typeof instance.exposed.close !== 'function')
return
instance.exposed.close()
}
function closeAll() {
for (const dialog of dialogs) {
close(dialog.id)
}
}
return {
dialogs,
instances,
close,
closeAll,
}
})
export function useDialog(options: UseDialogOptions) {
const manager = useDialogManager()
const initialAttrs = mergeProps(options.attrs ?? {}, {
onClosed: () => {
const index = manager.dialogs.findIndex(dialog => options.id === dialog.id)
if (index === -1)
return
manager.dialogs.splice(index, 1)
},
})
function open(openAttrs?: ComponentAttrs) {
const attrs = mergeProps(initialAttrs, openAttrs ?? {})
manager.dialogs.push({ ...options, attrs })
}
function close() {
manager.close(options.id)
}
return {
open,
close,
}
}

View File

@@ -0,0 +1,44 @@
import type { ChatMessage } from '@shared/api/generated-chad-api.ts'
import type { EventType } from 'mitt'
import mitt from 'mitt'
export interface AppEvents extends Record<EventType, unknown> {
// 'socket:connected': void
// 'socket:disconnected': void
// 'socket:authenticated': { socketId: string }
//
// 'client:added': ChadClient
// 'client:removed': ChadClient
// 'client:updated': { socketId: string, oldClient: ChadClient, updatedClient: Partial<ChadClient> }
//
// 'consumer:added': Consumer
// 'consumer:removed': Consumer
// 'consumer:paused': Consumer
// 'consumer:resumed': Consumer
//
// 'producer:added': Producer
// 'producer:removed': Producer
// 'producer:paused': Producer
// 'producer:resumed': Producer
'audio:muted': void
'audio:unmuted': void
'output:muted': void
'output:unmuted': void
'video:enabled': void
'video:disabled': void
'share:enabled': void
'share:disabled': void
'chat:new-message': ChatMessage
}
const emitter = mitt<AppEvents>()
export function useEventBus() {
return {
emit: emitter.emit,
on: emitter.on,
off: emitter.off,
}
}

View File

@@ -0,0 +1,74 @@
import { createGlobalState } from '@vueuse/core'
import { computed, ref, watch } from 'vue'
import { useMediasoup } from './use-mediasoup'
import { useProducers } from './use-producers'
export const useMediaControls = createGlobalState(() => {
const { producers } = useMediasoup()
const { enableMic, enableVideo, disableVideo, enableShare, disableShare, pauseProducer, resumeProducer } = useProducers()
const micProducer = computed(() => producers.values.value.find(p => p.appData.source === 'mic'))
const cameraProducer = computed(() => producers.values.value.find(p => p.appData.source === 'camera'))
const shareProducer = computed(() => producers.values.value.find(p => p.appData.source === 'share'))
const isSoundEnabled = ref(true)
const isMicEnabled = computed(() => isSoundEnabled.value && !!micProducer.value && !micProducer.value.paused)
const isCameraEnabled = computed(() => !!cameraProducer.value && !cameraProducer.value.paused)
const isShareEnabled = computed(() => !!shareProducer.value)
watch(isSoundEnabled, async (enabled) => {
if (!enabled) {
if (micProducer.value && !micProducer.value.paused)
await pauseProducer(micProducer.value.id)
}
else {
if (micProducer.value?.paused)
await resumeProducer(micProducer.value.id)
}
})
async function toggleMic() {
if (!isSoundEnabled.value)
return
if (isMicEnabled.value) {
await pauseProducer(micProducer.value!.id)
}
else if (micProducer.value?.paused) {
await resumeProducer(micProducer.value.id)
}
else {
await enableMic()
}
}
function toggleSound() {
isSoundEnabled.value = !isSoundEnabled.value
}
async function toggleCamera() {
if (isCameraEnabled.value)
await disableVideo()
else
await enableVideo()
}
async function toggleShare() {
if (isShareEnabled.value)
await disableShare()
else
await enableShare()
}
return {
isMicEnabled,
isSoundEnabled,
isCameraEnabled,
isShareEnabled,
toggleMic,
toggleSound,
toggleCamera,
toggleShare,
}
})

View File

@@ -0,0 +1,119 @@
import type { Consumer, Device, Producer, Transport } from 'mediasoup-client/types'
import type { Ref } from 'vue'
import { createEventHook, createGlobalState } from '@vueuse/core'
import { computed, ref, shallowRef } from 'vue'
interface Snapshot<T> {
id: string
ref: T
[key: string]: any
}
export interface ProducerSnapshot extends Snapshot<Producer> {
paused: boolean
kind: string
appData: Record<string, unknown>
}
export interface ConsumerSnapshot extends Snapshot<Consumer> {
paused: boolean
kind: string
appData: Record<string, unknown>
track: MediaStreamTrack
}
export interface TransportSnapshot extends Snapshot<Transport> {
}
function createEntityStore<T extends { id: string }>() {
const store = ref(new Map<string, T>()) as unknown as Ref<Map<string, T>>
const onAddEvent = createEventHook<T>()
const onRemoveEvent = createEventHook<string>()
const values = computed(() => Array.from(store.value.values()))
async function add(entity: T) {
store.value.set(entity.id, entity)
// eslint-disable-next-line ts/ban-ts-comment
// @ts-expect-error
await onAddEvent.trigger(entity)
}
async function remove(id: string) {
store.value.delete(id)
await onRemoveEvent.trigger(id)
}
function get(id: string) {
return store.value.get(id)
}
function clear() {
store.value.clear()
}
return {
store,
values,
onAdd: onAddEvent.on,
onRemove: onRemoveEvent.on,
add,
remove,
get,
clear,
}
}
export const useMediasoup = createGlobalState(() => {
const device = shallowRef<Device>()
const sendTransport = shallowRef<Transport>()
const recvTransport = shallowRef<Transport>()
const producers = createEntityStore<ProducerSnapshot>()
producers.onAdd((producer) => {
producer.ref.observer.on('pause', () => {
producers.store.value.set(producer.id, { ...producer, paused: true })
})
producer.ref.observer.on('resume', () => {
producers.store.value.set(producer.id, { ...producer, paused: false })
})
producer.ref.observer.on('close', () => producers.remove(producer.id))
})
const consumers = createEntityStore<ConsumerSnapshot>()
consumers.onAdd((consumer) => {
consumer.ref.on('trackended', () => consumer.ref.close())
consumer.ref.observer.on('pause', () => {
consumers.store.value.set(consumer.id, { ...consumer, paused: true })
})
consumer.ref.observer.on('resume', () => {
consumers.store.value.set(consumer.id, { ...consumer, paused: false })
})
consumer.ref.observer.on('close', () => consumers.remove(consumer.id))
})
const transports = createEntityStore<TransportSnapshot>()
transports.onAdd((transport) => {
transport.ref.observer.on('close', () => transports.remove(transport.id))
})
function clearAll() {
device.value = undefined
sendTransport.value = undefined
recvTransport.value = undefined
producers.clear()
consumers.clear()
transports.clear()
}
return {
device,
sendTransport,
recvTransport,
producers,
consumers,
transports,
clearAll,
}
})

View File

@@ -0,0 +1,164 @@
import type { MediaKind, ProducerOptions } from 'mediasoup-client/types'
import { createGlobalState } from '@vueuse/core'
import { markRaw } from 'vue'
import { useMediasoup } from './use-mediasoup'
import { useSignaling } from './use-signaling'
export const useProducers = createGlobalState(() => {
const { socket } = useSignaling()
const { device, sendTransport, producers } = useMediasoup()
async function createProducer(options: ProducerOptions) {
if (!sendTransport.value || !device.value || !options.track)
return
if (!device.value.canProduce(options.track.kind as MediaKind))
return
const producer = await sendTransport.value.produce({ disableTrackOnPause: true, ...options })
producer.observer.on('trackended', () => disableProducer(producer.id))
await producers.add({
id: producer.id,
paused: producer.paused,
kind: producer.kind,
appData: producer.appData as Record<string, unknown>,
ref: markRaw(producer),
})
}
async function disableProducer(producerId: string) {
const snap = producers.get(producerId)
if (!snap)
return
try {
snap.ref.close()
await socket.value?.emitWithAck('close-producer', { producerId })
}
catch {}
}
async function pauseProducer(producerId: string) {
const snap = producers.get(producerId)
if (!snap || snap.paused)
return
try {
snap.ref.pause()
await socket.value?.emitWithAck('pause-producer', { producerId })
}
catch {
snap.ref.resume()
}
}
async function resumeProducer(producerId: string) {
const snap = producers.get(producerId)
if (!snap || !snap.paused)
return
try {
snap.ref.resume()
await socket.value?.emitWithAck('resume-producer', { producerId })
}
catch {
snap.ref.pause()
}
}
async function enableMic() {
for (const snap of producers.store.value.values()) {
if (snap.kind === 'audio')
return
}
const stream = await navigator.mediaDevices.getUserMedia({ audio: true })
const track = stream.getAudioTracks()[0]
if (!track)
return
await createProducer({
track,
streamId: 'mic-video',
codecOptions: { opusStereo: true, opusDtx: true },
appData: { source: 'mic' },
})
}
async function disableMic() {
for (const snap of producers.store.value.values()) {
if (snap.kind === 'audio')
await disableProducer(snap.id)
}
}
async function enableVideo() {
for (const snap of producers.store.value.values()) {
if (snap.kind === 'video' && snap.appData.source !== 'share')
return
}
const stream = await navigator.mediaDevices.getUserMedia({
video: { width: { ideal: 1920 }, height: { ideal: 1080 }, frameRate: { ideal: 60 } },
})
const track = stream.getVideoTracks()[0]
if (!track)
return
await createProducer({
track,
streamId: 'mic-video',
appData: { source: 'camera' },
})
}
async function disableVideo() {
for (const snap of producers.store.value.values()) {
if (snap.kind === 'video' && snap.appData.source !== 'share')
await disableProducer(snap.id)
}
}
async function enableShare() {
for (const snap of producers.store.value.values()) {
if (snap.appData.source === 'share')
return
}
const stream = await navigator.mediaDevices.getDisplayMedia({
audio: false,
video: { displaySurface: 'monitor' },
})
const track = stream.getVideoTracks()[0]
if (!track)
return
await createProducer({
track,
streamId: 'share',
zeroRtpOnPause: true,
appData: { source: 'share' },
})
}
async function disableShare() {
for (const snap of producers.store.value.values()) {
if (snap.appData.source === 'share')
await disableProducer(snap.id)
}
}
return {
enableMic,
disableMic,
enableVideo,
disableVideo,
enableShare,
disableShare,
pauseProducer,
resumeProducer,
disableProducer,
}
})

View File

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

View File

@@ -0,0 +1,87 @@
import type { Socket } from 'socket.io-client'
import { createSharedComposable } from '@vueuse/core'
import { io } from 'socket.io-client'
import { parseURL } from 'ufo'
import { onScopeDispose, ref, shallowRef, watch } from 'vue'
import { useAuth } from './use-auth'
import { useEventBus } from './use-event-bus'
export const useSignaling = createSharedComposable(() => {
const eventBus = useEventBus()
const { me } = useAuth()
const socket = shallowRef<Socket>()
const connected = ref(false)
watch(socket, (socket, prevSocket) => {
if (prevSocket) {
prevSocket.close()
}
if (!socket) {
return
}
if (import.meta.dev) {
socket.onAny((event, ...args) => {
console.info('[onAny]', event, args)
})
socket.onAnyOutgoing((event, ...args) => {
console.info('[onAnyOutgoing]', event, args)
})
}
socket.on('connect', async () => {
connected.value = true
})
socket.on('disconnect', async () => {
connected.value = false
})
}, { immediate: true, flush: 'sync' })
watch(connected, (connected) => {
if (connected)
eventBus.emit('socket:connected')
else
eventBus.emit('socket:disconnected')
}, { immediate: true })
watch(me, (me) => {
if (!me) {
socket.value?.close()
socket.value = undefined
}
})
onScopeDispose(disconnect)
function connect() {
if (socket.value || !me.value)
return
const { protocol, host, pathname } = parseURL(__API_BASE_URL__)
const uri = host ? `${protocol}//${host}` : ``
socket.value = io(uri, {
path: `${pathname}/ws`,
transports: ['websocket'],
withCredentials: true,
})
}
function disconnect() {
socket.value?.disconnect()
socket.value = undefined
}
return {
socket,
connected,
connect,
disconnect,
}
})

View File

@@ -0,0 +1,12 @@
import type { MaybeRefOrGetter } from 'vue'
import { qUser } from '@shared/api/qUser.ts'
import { readonly } from 'vue'
export function useUserDetails(username: MaybeRefOrGetter<string>) {
const { data: user, isFetching } = qUser(username)
return {
user: readonly(user),
isFetching,
}
}

View File

@@ -27,18 +27,12 @@ defineOptions({
&__container {
margin: auto;
width: 100%;
max-width: 380px;
max-width: 440px;
}
&__logo {
text-align: center;
margin-bottom: 24px;
}
&__content {
padding: 24px;
background-color: var(--bg);
border-radius: 36px;
justify-self: center;
margin-bottom: var(--space-6);
}
}
</style>

View File

@@ -1,30 +1,85 @@
<template>
<div class="default-layout">
<header class="app-header">
<div class="app-header__sidebar">
<AppLogo />
<header class="header">
<div class="header__left">
<p class="header__app-title">
Chad
</p>
<p class="header__version">
{{ version }}
</p>
</div>
<div class="app-header__content">
Header
<div class="header__right">
<p class="header__title">
Messages
</p>
</div>
</header>
<aside class="app-sidebar">
Sidebar
<aside class="sidebar">
<ChannelList class="sidebar__channel-list" />
<!-- <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> -->
<ChadButton style="margin: var(--space-2)" type="secondary" @click="createChannelDialog.open()">
Create channel
</ChadButton>
<ControlPanel />
</aside>
<div class="default-layout__content">
<div class="content">
<slot />
</div>
</div>
</template>
<script setup lang="ts">
import AppLogo from '@shared/components/AppLogo.vue'
import ChadButton from '@shared/components/ui/Button.vue'
import { useApp } from '@shared/composables/use-app.js'
import { useDialog } from '@shared/composables/use-dialog.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'
import CreateChannelDialog from '@/entities/channel/ui/CreateChannelDialog.vue'
defineOptions({
name: 'DefaultLayout',
})
const { version } = useApp()
const { sendTransport } = useMediasoup()
const { enableMic } = useProducers()
const createChannelDialog = useDialog({
id: 'create-channel',
component: CreateChannelDialog,
})
watchEffect(() => {
if (!sendTransport.value)
return
enableMic()
})
</script>
<style lang="scss">
@@ -37,46 +92,62 @@ defineOptions({
grid-template-rows: auto 1fr;
grid-template-areas: 'header header' 'sidebar content';
&__content {
grid-area: content;
}
.app-header {
.header {
grid-area: header;
display: grid;
grid-template-columns: var(--sidebar-width) 1fr;
align-items: stretch;
background-color: var(--bg);
border-bottom: 1px solid var(--border-muted);
height: 52px;
height: 56px;
border-bottom: var(--border-w) solid var(--ink);
&__sidebar {
border-right: 1px solid var(--border-muted);
}
&__sidebar,
&__content {
&__left {
display: flex;
align-items: center;
padding: 8px;
justify-content: space-between;
background-color: var(--ink);
padding-inline: var(--space-4);
}
&__title {
font-weight: 700;
&__app-title {
@include font-display-14;
color: var(--white);
}
&__version {
margin-left: 4px;
color: var(--text-muted);
font-size: 0.75rem;
@include font-micro;
color: var(--grey-3);
}
&__right {
display: flex;
align-items: center;
padding-inline: var(--space-4);
}
&__title {
@include font-display-14;
}
}
.app-sidebar {
.sidebar {
grid-area: sidebar;
background-color: var(--bg);
border-right: 1px solid var(--border-muted);
padding: 8px;
display: flex;
flex-direction: column;
border-right: var(--border-w) solid var(--ink);
overflow-y: auto;
&__channel-list {
flex: 1;
}
}
.content {
grid-area: content;
overflow-y: auto;
}
}
</style>

View File

@@ -3,27 +3,50 @@
html,
body,
[data-mount-point]:not(:empty) {
height: 100%;
height: 100%;
}
[data-mount-point]:empty {
display: none;
display: none;
}
body {
background-color: var(--bg-dark);
color: var(--text);
height: 100%;
@include font-body;
background-color: var(--paper);
color: var(--ink);
height: 100%;
}
*,
*::before,
*::after {
font-family: 'Inter', sans-serif;
font-optical-sizing: auto;
font-weight: 400;
font-style: normal;
font-variation-settings:
'wdth' 100,
'YTLC' 500;
a {
background-color: var(--yellow);
text-decoration: none;
color: var(--ink);
padding-inline: var(--space-1);
outline: none;
&:focus,
&:hover {
background-color: var(--yellow-deep);
}
&:active {
background-color: var(--ink);
color: var(--yellow);
}
}
::-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

@@ -0,0 +1 @@
@forward 'mixins/typography';

View File

@@ -0,0 +1,54 @@
$display-font-family: 'Unbounded', 'Manrope', system-ui, sans-serif;
$regular-font-family: 'Manrope', system-ui, sans-serif;
@mixin font-display-36 {
font-family: $display-font-family;
font-size: 36px;
letter-spacing: 0.01em;
text-transform: uppercase;
font-weight: 900;
}
@mixin font-display-22 {
font-family: $display-font-family;
font-size: 22px;
letter-spacing: 0.02em;
text-transform: uppercase;
font-weight: 900;
}
@mixin font-display-14 {
font-family: $display-font-family;
font-size: 14px;
letter-spacing: 0.02em;
text-transform: uppercase;
font-weight: 900;
}
@mixin font-body {
font-family: $regular-font-family;
font-size: 14px;
font-weight: 400;
}
@mixin font-body-bold {
font-family: $regular-font-family;
font-size: 14px;
font-weight: 700;
}
@mixin font-label {
font-family: $regular-font-family;
font-size: 12px;
letter-spacing: 0.12em;
text-transform: uppercase;
font-weight: 700;
}
@mixin font-micro {
font-family: $regular-font-family;
font-size: 10px;
letter-spacing: 0.1em;
text-transform: uppercase;
font-weight: 500;
}

View File

@@ -1,64 +1,26 @@
:root {
/* hsl (fallback color) */
--bg-dark: hsl(208 100% 2%);
--bg: hsl(201 86% 4%);
--bg-light: hsl(198 56% 8%);
--text: hsl(199 100% 93%);
--text-muted: hsl(199 36% 68%);
--highlight: hsl(199 28% 37%);
--border: hsl(198 40% 26%);
--border-muted: hsl(197 70% 15%);
--primary: hsl(198 69% 65%);
--secondary: hsl(20 68% 69%);
--danger: hsl(9 26% 64%);
--warning: hsl(52 19% 57%);
--success: hsl(146 17% 59%);
--info: hsl(217 28% 65%);
/* oklch */
--bg-dark: oklch(0.1 0.025 228);
--bg: oklch(0.15 0.025 228);
--bg-light: oklch(0.2 0.025 228);
--text: oklch(0.96 0.05 228);
--text-muted: oklch(0.76 0.05 228);
--highlight: oklch(0.5 0.05 228);
--border: oklch(0.4 0.05 228);
--border-muted: oklch(0.3 0.05 228);
--primary: oklch(0.76 0.1 228);
--secondary: oklch(0.76 0.1 48);
--danger: oklch(0.7 0.05 30);
--warning: oklch(0.7 0.05 100);
--success: oklch(0.7 0.05 160);
--info: oklch(0.7 0.05 260);
}
[data-theme="light"] {
/* hsl (fallback color) */
--bg-dark: hsl(199 53% 89%);
--bg: hsl(199 100% 94%);
--bg-light: hsl(199 100% 99%);
--text: hsl(204 100% 4%);
--text-muted: hsl(198 40% 26%);
--highlight: hsl(199 100% 99%);
--border: hsl(199 22% 49%);
--border-muted: hsl(199 28% 61%);
--primary: hsl(193 100% 16%);
--secondary: hsl(23 81% 25%);
--danger: hsl(9 21% 41%);
--warning: hsl(52 23% 34%);
--success: hsl(147 19% 36%);
--info: hsl(217 22% 41%);
/* oklch */
--bg-dark: oklch(0.92 0.025 228);
--bg: oklch(0.96 0.025 228);
--bg-light: oklch(1 0.025 228);
--text: oklch(0.15 0.05 228);
--text-muted: oklch(0.4 0.05 228);
--highlight: oklch(1 0.05 228);
--border: oklch(0.6 0.05 228);
--border-muted: oklch(0.7 0.05 228);
--primary: oklch(0.4 0.1 228);
--secondary: oklch(0.4 0.1 48);
--danger: oklch(0.5 0.05 30);
--warning: oklch(0.5 0.05 100);
--success: oklch(0.5 0.05 160);
--info: oklch(0.5 0.05 260);
--white: #fff;
--paper: #f4f1e8;
--ink: #0d0d0d;
--yellow: #ffd400;
--yellow-deep: #f5c400;
--red: #ff3b30;
--green: #1f9d55;
--grey-1: #ededed;
--grey-2: #c9c6bd;
--grey-3: #8a8a82;
--shadow-sm: 3px 3px 0 0 var(--ink);
--shadow: 6px 6px 0 0 var(--ink);
--border-w: 2px;
--space-1: 4px;
--space-2: 8px;
--space-3: 12px;
--space-4: 16px;
--space-5: 20px;
--space-6: 24px;
--space-7: 28px;
--space-8: 32px;
}

View File

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

View File

@@ -0,0 +1,16 @@
import type { Channel, ResponseError } from '@shared/api/generated-chad-api.ts'
import api from '@shared/api/client.ts'
import { useQuery } from '@tanstack/vue-query'
export function qChannelList() {
return useQuery<Channel[], ResponseError>({
queryKey: ['channel-list'],
queryFn: async () => {
const response = await api.chad.channelList()
return response.data
},
placeholderData: () => [],
staleTime: Infinity,
})
}

View File

@@ -0,0 +1,53 @@
<template>
<li v-bind="api.getRootProps()" class="channel">
<div class="channel__header" v-bind="api.getTriggerProps()">
{{ channel.name }}
</div>
<div v-bind="api.getContentProps()" class="channel__content">
<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 { 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
}>()
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">
.channel {
padding-inline: var(--space-3);
&__header {
@include font-micro;
padding-block: var(--space-2);
color: var(--grey-3);
}
}
</style>

View File

@@ -0,0 +1,22 @@
<template>
<div class="channel-list">
<ul class="channel-list__list">
<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 Channel from './Channel.vue'
const { data: channels } = qChannelList()
</script>
<style lang="scss">
.channel-list {
> *:not(:last-child) {
margin-bottom: var(--space-6);
}
}
</style>

View File

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

View File

@@ -0,0 +1,16 @@
import type { ResponseError } from '@shared/api/generated-chad-api.ts'
import type { MaybeRefOrGetter } from 'vue'
import api from '@shared/api/client.ts'
import { useQuery } from '@tanstack/vue-query'
import { toValue } from 'vue'
export function qMessageAttachment(attachmentId: MaybeRefOrGetter<string>) {
return useQuery<Blob, ResponseError>({
queryKey: ['message-attachment', attachmentId],
queryFn: async () => {
const response = await api.chad.attachmentGet(toValue(attachmentId), { format: 'blob' })
return response.data
},
})
}

View File

@@ -0,0 +1,42 @@
import type { ChatMessage } from '@shared/api/generated-chad-api.ts'
import { useEventBus } from '@shared/composables/use-event-bus.ts'
import { createGlobalState } from '@vueuse/core'
import { computed, shallowRef, triggerRef } from 'vue'
import { qChatMessages } from '../api/qChatMessages.ts'
export interface MessageGroup {
senderUsername: string
messages: ChatMessage[]
}
export const useChatHistory = createGlobalState(() => {
const eventBus = useEventBus()
const { data: messages, hasNextPage: hasMoreMessages, fetchNextPage: loadMoreMessages, isFetching } = qChatMessages()
const feedItems = shallowRef<ChatMessage[]>([])
eventBus.on('chat:new-message', (message: ChatMessage) => {
feedItems.value.push(message)
triggerRef(feedItems)
})
const messageGroups = computed<MessageGroup[]>(() => {
const all = [...(messages.value ?? []), ...feedItems.value]
return all.reduce((groups, msg) => {
const last = groups.at(-1)
if (last?.senderUsername === msg.senderUsername)
last.messages.push(msg)
else
groups.push({ senderUsername: msg.senderUsername, messages: [msg] })
return groups
}, [] as MessageGroup[])
})
return {
messageGroups,
hasMoreMessages,
loadMoreMessages,
isFetching,
}
})

View File

@@ -0,0 +1,110 @@
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,
})
let lastScrollHeight = 0
let lastScrollTop = 0
watch(el, (el) => {
if (!el)
return
scrollToStart(true)
getArrivedState()
}, { flush: 'post' })
useMutationObserver(el, (mutations) => {
if (arrivedState.start) {
scrollToStart(true)
}
else {
// const prepended = mutations.some(mutation => Array.from(mutation.addedNodes.values()).some(node => !!node.nextEle))
// console.log('prepended', prepended)
// for (const mutation of mutations) {
// for (const node of mutation.addedNodes) {
// console.log('added node', node, !!node.nextSibling)
// if (node.nextSibling) {
// // добавлено сверху/в середину
// // el.value!.scrollTop += (node as HTMLElement).offsetHeight
// }
// }
//
// // for (const node of mutation.removedNodes) {
// // // previousSibling/nextSibling здесь — это соседи на момент удаления
// // if (mutation.previousSibling || mutation.nextSibling) {
// // // удалено сверху/в середину — уменьшаем scrollTop
// // el.value!.scrollTop -= (node as HTMLElement).offsetHeight
// // }
// // }
// }
const heightDiff = el.value!.scrollHeight - lastScrollHeight
// const scrollDiff = el.value!.scrollTop - lastScrollTop
//
// console.log('height', 'old', lastScrollHeight, 'new', el.value!.scrollHeight, 'diff', heightDiff)
// console.log('scroll', 'old', lastScrollTop, 'new', el.value!.scrollTop, 'diff', scrollDiff)
//
el.value!.scrollTop += heightDiff
}
getArrivedState()
}, {
childList: true,
subtree: true,
})
useEventListener(el, 'scroll', () => {
getArrivedState()
lastScrollTop = el.value!.scrollTop
}, { 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
lastScrollHeight = el.value!.scrollHeight
}
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

@@ -0,0 +1,18 @@
import type { NewChatMessagePayload } from '@shared/api/generated-chad-api.ts'
import api from '@shared/api/client.ts'
export function useChat() {
async function sendMessage(newMessage: NewChatMessagePayload) {
newMessage.text = newMessage.text.trim()
if (newMessage.attachments?.length === 0 && newMessage.text.length === 0) {
return
}
await api.chad.chatSend(newMessage)
}
return {
sendMessage,
}
}

View File

@@ -0,0 +1,34 @@
<template>
<div class="chat">
<ChatMessages class="chat__messages" />
<!-- <ChadButton @click="loadMoreMessages()"> -->
<!-- PENIS -->
<!-- </ChadButton> -->
<ChatInput class="chat__input" />
</div>
</template>
<script setup lang="ts">
import { useChatHistory } from '@widgets/chat/composables/use-chat-history.ts'
import ChatInput from '@widgets/chat/ui/ChatInput.vue'
import ChatMessages from '@widgets/chat/ui/ChatMessages.vue'
const { loadMoreMessages } = useChatHistory()
</script>
<style lang="scss">
.chat {
display: grid;
grid-template-rows: 1fr auto;
height: 100%;
overflow: hidden;
&__messages {
flex: 1;
}
&__input {
flex: 0 0 auto;
}
}
</style>

View File

@@ -0,0 +1,62 @@
<template>
<div
:class="[
bem.b(),
bem.is('loading', loading),
bem.is('error', error),
]"
>
{{ name }}
</div>
</template>
<script setup lang="ts">
import useBem from '@shared/composables/use-bem.ts'
const props = defineProps<{
name: string
loading?: boolean
error?: boolean
}>()
const bem = useBem('chat-attachment')
</script>
<style lang="scss">
.chat-attachment {
--stripe-width: 20px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding: var(--space-1) var(--space-2);
background-color: var(--grey-1);
outline: 1px solid var(--ink);
outline-offset: -1px;
cursor: pointer;
background-repeat: repeat;
color: var(--grey-3);
&.is-loading {
background-image: repeating-linear-gradient(
-45deg,
transparent 25%,
transparent 50%,
var(--grey-2) 50%,
var(--grey-2) 75%
);
background-size: var(--stripe-width) var(--stripe-width);
animation: loading 500ms infinite linear;
}
}
@keyframes loading {
from {
background-position-x: 0;
}
to {
background-position-x: var(--stripe-width);
}
}
</style>

View File

@@ -0,0 +1,181 @@
<template>
<div class="chat-input" v-bind="fileUploadApi.getRootProps()">
<div class="chat-input__input-row">
<ChadButton
class="chat-input__add-attachment"
type="secondary"
:icon="Plus"
@click="fileUploadApi.openFilePicker()"
/>
<ChadInput
v-model="message.text"
class="chat-input__input"
placeholder="Write a message..."
@keydown.enter="sendMessage()"
/>
<ChadButton
class="chat-input__send"
:loading="isUploading"
@click="sendMessage()"
>
Send
</ChadButton>
</div>
<div v-if="fileUploadApi.acceptedFiles.length > 0" class="chat-input__attachments" v-bind="fileUploadApi.getItemGroupProps()">
<ChatAttachment
v-for="file in fileUploadApi.acceptedFiles"
:key="file.name"
:loading="uploadStates.get(file)?.status === 'loading'"
:error="uploadStates.get(file)?.status === 'error'"
class="chat-input__attachment"
v-bind="fileUploadApi.getItemProps({ file })"
:name="file.name"
@click="removeFile(file)"
/>
</div>
<input v-bind="fileUploadApi.getHiddenInputProps()">
</div>
</template>
<script setup lang="ts">
import type { FullRequestParams, NewChatMessagePayload } from '@shared/api/generated-chad-api.ts'
import { Plus } from '@lucide/vue'
import api from '@shared/api/client.ts'
import { ContentType } from '@shared/api/generated-chad-api.ts'
import ChadButton from '@shared/components/ui/Button.vue'
import ChadInput from '@shared/components/ui/Input.vue'
import { useEventListener } from '@vueuse/core'
import { useChat } from '@widgets/chat/composables/use-chat.ts'
import ChatAttachment from '@widgets/chat/ui/ChatAttachment.vue'
import * as fileUpload from '@zag-js/file-upload'
import { normalizeProps, useMachine } from '@zag-js/vue'
import { computed, reactive, useId } from 'vue'
interface UploadStatus {
status: 'loading' | 'done' | 'error'
uuid?: string
abortController: AbortController
}
const id = useId()
const chat = useChat()
const message: NewChatMessagePayload = reactive({
text: '',
attachments: [],
})
const uploadStates = reactive(new Map<File, UploadStatus>())
const isUploading = computed(() => {
return Array.from(uploadStates.values()).some(s => s.status === 'loading')
})
const service = useMachine(fileUpload.machine, {
id,
maxFiles: 10,
maxFileSize: 1000 * 1024 * 1024,
name: 'chat-input',
capture: 'environment',
allowDrop: false,
onFileAccept: (details) => {
for (const file of details.files) {
if (uploadStates.has(file))
continue
const state: UploadStatus = { status: 'loading', abortController: new AbortController() }
uploadStates.set(file, state)
const formData = new FormData()
formData.append('file', file)
try {
api.chad.attachmentUpload({
body: formData,
format: 'text',
type: ContentType.FormData,
signal: state.abortController.signal,
} as FullRequestParams).then((response) => {
uploadStates.set(file, { ...state, status: 'done', uuid: response.data })
message.attachments!.push(response.data)
})
}
catch {
uploadStates.set(file, { ...state, status: 'error' })
}
}
},
})
const fileUploadApi = computed(() => fileUpload.connect(service, normalizeProps))
useEventListener(document, 'paste', (event) => {
fileUploadApi.value.setClipboardFiles(event.clipboardData)
})
function removeFile(file: File) {
uploadStates.get(file)?.abortController.abort('Attachment removed')
uploadStates.delete(file)
fileUploadApi.value.deleteFile(file)
}
function sendMessage() {
if (isUploading.value)
return
chat.sendMessage(message)
reset()
}
function reset() {
message.text = ''
message.attachments = []
uploadStates.clear()
fileUploadApi.value.clearFiles()
}
</script>
<style lang="scss">
.chat-input {
padding: var(--space-3) var(--space-6);
border-top: var(--border-w) solid var(--ink);
&__input-row {
display: flex;
}
&__add-attachment {
flex-shrink: 0;
margin-right: calc(var(--border-w) * -1);
}
&__input {
flex: 1;
}
&__send {
flex-shrink: 0;
margin-left: calc(var(--border-w) * -1);
}
&__attachments {
display: flex;
flex-wrap: wrap;
gap: var(--space-2);
padding: var(--space-2);
margin-top: var(--space-2);
outline: var(--border-w) dashed var(--ink);
outline-offset: calc(var(--border-w) * -1);
overflow: hidden;
> * {
max-width: 300px;
}
}
}
</style>

View File

@@ -0,0 +1,87 @@
<template>
<div class="chat-message">
<div class="chat-message__top">
<p class="chat-message__sender">
{{ !sender ? message.senderUsername : sender.displayName }}
</p>
<p class="chat-message__datetime">
{{ datetime }}
</p>
</div>
<p class="chat-message__body">
{{ message.text }}
</p>
<ChatMessageAttachments v-if="message.attachments.length > 0" :attachments="message.attachments" class="chat-message__attachments" />
</div>
</template>
<script setup lang="ts">
import type { ChatMessage } from '@shared/api/generated-chad-api.ts'
import { useUserDetails } from '@shared/composables/use-user-details.ts'
import ChatMessageAttachments from '@widgets/chat/ui/ChatMessageAttachments.vue'
import { format, isThisYear, isToday } from 'date-fns'
import { computed, toRef } from 'vue'
const props = defineProps<{
message: ChatMessage
}>()
const { user: sender } = useUserDetails(toRef(() => props.message.senderUsername))
const datetime = computed(() => {
let formatStr = 'd MMMM yyyy, HH:mm'
if (isToday(props.message.createdAt)) {
formatStr = 'HH:mm'
}
else if (isThisYear(props.message.createdAt)) {
formatStr = 'd MMMM, HH:mm'
}
return format(props.message.createdAt, formatStr)
})
</script>
<style lang="scss">
.chat-message {
$self: &;
&:not(:last-child) {
margin-bottom: var(--space-3);
}
&__top {
display: flex;
gap: var(--space-2);
align-items: center;
//margin-top: var(--space-1);
}
&__sender {
@include font-body-bold;
#{$self}:not(:first-child) & {
display: none;
}
}
&__datetime {
@include font-micro;
flex-shrink: 0;
color: var(--grey-3);
}
&__body {
margin-top: var(--space-1);
}
&__attachments {
//overflow-x: auto;
margin-top: var(--space-2);
}
}
</style>

View File

@@ -0,0 +1,108 @@
<template>
<div class="chat-message-attachment" :title="attachment.name" @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">
{{ size }}
</p>
</div>
</div>
</template>
<script setup lang="ts">
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 { formatBytes } from '@zag-js/i18n-utils'
import { computed } from 'vue'
const props = defineProps<{
attachment: Attachment
}>()
const extension = computed(() => props.attachment.name.split('.').at(-1))
const url = computed(() => {
return `${__API_BASE_URL__}/attachment/${props.attachment.id}`
})
const size = computed(() => {
return formatBytes(props.attachment.size, 'en-US', { unitSystem: 'binary' })
})
async function download() {
const response = await api.chad.attachmentGet(props.attachment.id, { format: 'blob' })
downloadFile({ name: props.attachment.name, type: props.attachment.mimetype, file: response.data })
}
</script>
<style lang="scss">
.chat-message-attachment {
$self: &;
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: 300px;
height: 52px;
cursor: pointer;
&:focus,
&:hover {
background-color: var(--grey-2);
}
&:active {
background-color: var(--grey-3);
}
&__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;
overflow: hidden;
}
&__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;
#{$self}:active & {
color: var(--grey-1);
}
}
}
</style>

View File

@@ -0,0 +1,47 @@
<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 {
overflow-x: auto;
&__images,
&__list {
display: flex;
gap: var(--space-2);
flex-wrap: nowrap;
}
&__list {
margin-top: var(--space-3);
}
}
</style>

View File

@@ -0,0 +1,48 @@
<template>
<div class="chat-message-group">
<ChadAvatar class="chat-message-group__avatar" src="" :fallback="initials" :highlighted="isMyMessage" />
<div class="chat-message-group__messages">
<ChatMessage
v-for="message in group.messages"
:key="message.id"
:message="message"
/>
</div>
</div>
</template>
<script setup lang="ts">
import type { MessageGroup } from '@widgets/chat/composables/use-chat-history.js'
import ChadAvatar from '@shared/components/ui/Avatar.vue'
import { useAuth } from '@shared/composables/use-auth.ts'
import ChatMessage from '@widgets/chat/ui/ChatMessage.vue'
import { computed } from 'vue'
const props = defineProps<{
group: MessageGroup
}>()
const { me } = useAuth()
const initials = computed(() => props.group.senderUsername.slice(props.group.senderUsername.length - 2))
const isMyMessage = computed(() => {
return props.group.senderUsername === me.value?.username
})
</script>
<style lang="scss">
.chat-message-group {
display: grid;
grid-template-columns: auto 1fr;
column-gap: var(--space-3);
padding-block: var(--space-3);
padding-inline: var(--space-6);
&__avatar {
position: sticky;
top: var(--space-3);
}
}
</style>

View File

@@ -0,0 +1,35 @@
<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 {
object-fit: contain;
object-position: center;
max-width: 260px;
height: 100%;
}
}
</style>

View File

@@ -0,0 +1,119 @@
<template>
<div class="chat-messages">
<div v-if="messageGroups.length" ref="scroll" class="chat-messages__list">
<ChatMessageGroup
v-for="group in messageGroups"
:key="`group-${group.messages[0].id}`"
:group="group"
/>
</div>
<ChadSpinner v-if="isFetching" class="chat-messages__spinner" />
<div v-if="!arrivedState.start" class="chat-messages__floating-actions">
<div v-if="hasUnreadMessages" class="chat-messages__has-unread-messages">
New messages
</div>
<ChadToBottom
class="chat-messages__scroll-to-bottom"
@click="scrollToStart()"
/>
</div>
</div>
</template>
<script setup lang="ts">
import ChadSpinner from '@shared/components/ui/Spinner.vue'
import ChadToBottom from '@shared/components/ui/ToBottom.vue'
import { useEventBus } from '@shared/composables/use-event-bus.ts'
import { useChatScroll } from '@widgets/chat/composables/use-chat-scroll.ts'
import ChatMessageGroup from '@widgets/chat/ui/ChatMessageGroup.vue'
import { onUnmounted, ref, useTemplateRef, watch } from 'vue'
import { useChatHistory } from '../composables/use-chat-history'
const eventBus = useEventBus()
const scrollRef = useTemplateRef('scroll')
const { messageGroups, hasMoreMessages, loadMoreMessages, isFetching } = useChatHistory()
const hasUnreadMessages = ref(false)
const { arrivedState, scrollToStart } = useChatScroll(scrollRef, {
startOffset: 100,
endOffset: 100,
})
watch(() => arrivedState.end, (arrived) => {
if (!arrived)
return
if (hasMoreMessages.value) {
loadMoreMessages()
}
})
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">
.chat-messages {
position: relative;
overflow: hidden;
&__spinner {
position: absolute;
top: var(--space-4);
left: 50%;
translate: -50% 0;
z-index: 1;
}
&__list {
overflow-x: hidden;
overflow-y: auto;
overflow-y: overlay;
overflow-anchor: none;
position: relative;
max-height: 100%;
}
&__floating-actions {
position: absolute;
display: inline-flex;
align-items: flex-end;
gap: var(--space-2);
bottom: var(--space-4);
right: var(--space-4);
pointer-events: none;
}
&__has-unread-messages {
@include font-micro;
background-color: var(--yellow);
padding: var(--space-1) var(--space-2);
box-shadow: var(--shadow-sm);
}
&__scroll-to-bottom {
pointer-events: auto;
}
}
</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/*"],

View File

@@ -3,7 +3,6 @@ import VuePlugin from '@vitejs/plugin-vue'
import { defineConfig } from 'vite'
import VueRouterPlugin from 'vue-router/vite'
// https://vite.dev/config/
export default defineConfig({
plugins: [
VueRouterPlugin(),
@@ -20,15 +19,15 @@ export default defineConfig({
{ find: '@', replacement: path.resolve(__dirname, './src') },
],
},
// css: {
// preprocessorOptions: {
// scss: {
// additionalData: `
// @use '${path.resolve(__dirname, './shared/styles/tokens.scss')}'' as *;
// `,
// },
// },
// },
css: {
preprocessorOptions: {
scss: {
additionalData: `
@use "@shared/styles/mixins.scss" as *;
`,
},
},
},
server: {
port: 3000,
strictPort: true,

File diff suppressed because it is too large Load Diff

2
server/.gitignore vendored
View File

@@ -18,3 +18,5 @@ node_modules
.env*
*.db
uploads

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,23 +1,24 @@
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({
text: Type.String({ minLength: 1 }),
text: Type.String(),
attachments: Type.Optional(Type.Array(Type.String({ format: 'uuid' }))),
// replyTo: Type.Object({
// messageId: Type.String({ format: 'uuid' }),

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
@@ -995,6 +995,7 @@ export type UserPreferencesScalarFieldEnum = (typeof UserPreferencesScalarFieldE
export const AttachmentScalarFieldEnum = {
id: 'id',
username: 'username',
name: 'name',
mimetype: 'mimetype',
size: 'size',
@@ -1007,7 +1008,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 +1026,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
@@ -105,6 +104,7 @@ export type UserPreferencesScalarFieldEnum = (typeof UserPreferencesScalarFieldE
export const AttachmentScalarFieldEnum = {
id: 'id',
username: 'username',
name: 'name',
mimetype: 'mimetype',
size: 'size',
@@ -117,7 +117,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 +135,7 @@ export type MessageAttachmentScalarFieldEnum = (typeof MessageAttachmentScalarFi
export const ChannelScalarFieldEnum = {
id: 'id',
ownerId: 'ownerId',
ownerUsername: 'ownerUsername',
name: 'name',
persistent: 'persistent'
} as const

View File

@@ -36,6 +36,7 @@ export type AttachmentSumAggregateOutputType = {
export type AttachmentMinAggregateOutputType = {
id: string | null
username: string | null
name: string | null
mimetype: string | null
size: number | null
@@ -44,6 +45,7 @@ export type AttachmentMinAggregateOutputType = {
export type AttachmentMaxAggregateOutputType = {
id: string | null
username: string | null
name: string | null
mimetype: string | null
size: number | null
@@ -52,6 +54,7 @@ export type AttachmentMaxAggregateOutputType = {
export type AttachmentCountAggregateOutputType = {
id: number
username: number
name: number
mimetype: number
size: number
@@ -70,6 +73,7 @@ export type AttachmentSumAggregateInputType = {
export type AttachmentMinAggregateInputType = {
id?: true
username?: true
name?: true
mimetype?: true
size?: true
@@ -78,6 +82,7 @@ export type AttachmentMinAggregateInputType = {
export type AttachmentMaxAggregateInputType = {
id?: true
username?: true
name?: true
mimetype?: true
size?: true
@@ -86,6 +91,7 @@ export type AttachmentMaxAggregateInputType = {
export type AttachmentCountAggregateInputType = {
id?: true
username?: true
name?: true
mimetype?: true
size?: true
@@ -181,6 +187,7 @@ export type AttachmentGroupByArgs<ExtArgs extends runtime.Types.Extensions.Inter
export type AttachmentGroupByOutputType = {
id: string
username: string | null
name: string
mimetype: string
size: number
@@ -212,19 +219,23 @@ export type AttachmentWhereInput = {
OR?: Prisma.AttachmentWhereInput[]
NOT?: Prisma.AttachmentWhereInput | Prisma.AttachmentWhereInput[]
id?: Prisma.StringFilter<"Attachment"> | string
username?: Prisma.StringNullableFilter<"Attachment"> | string | null
name?: Prisma.StringFilter<"Attachment"> | string
mimetype?: Prisma.StringFilter<"Attachment"> | string
size?: Prisma.IntFilter<"Attachment"> | number
createdAt?: Prisma.DateTimeFilter<"Attachment"> | Date | string
user?: Prisma.XOR<Prisma.UserNullableScalarRelationFilter, Prisma.UserWhereInput> | null
message?: Prisma.MessageAttachmentListRelationFilter
}
export type AttachmentOrderByWithRelationInput = {
id?: Prisma.SortOrder
username?: Prisma.SortOrderInput | Prisma.SortOrder
name?: Prisma.SortOrder
mimetype?: Prisma.SortOrder
size?: Prisma.SortOrder
createdAt?: Prisma.SortOrder
user?: Prisma.UserOrderByWithRelationInput
message?: Prisma.MessageAttachmentOrderByRelationAggregateInput
}
@@ -233,15 +244,18 @@ export type AttachmentWhereUniqueInput = Prisma.AtLeast<{
AND?: Prisma.AttachmentWhereInput | Prisma.AttachmentWhereInput[]
OR?: Prisma.AttachmentWhereInput[]
NOT?: Prisma.AttachmentWhereInput | Prisma.AttachmentWhereInput[]
username?: Prisma.StringNullableFilter<"Attachment"> | string | null
name?: Prisma.StringFilter<"Attachment"> | string
mimetype?: Prisma.StringFilter<"Attachment"> | string
size?: Prisma.IntFilter<"Attachment"> | number
createdAt?: Prisma.DateTimeFilter<"Attachment"> | Date | string
user?: Prisma.XOR<Prisma.UserNullableScalarRelationFilter, Prisma.UserWhereInput> | null
message?: Prisma.MessageAttachmentListRelationFilter
}, "id">
export type AttachmentOrderByWithAggregationInput = {
id?: Prisma.SortOrder
username?: Prisma.SortOrderInput | Prisma.SortOrder
name?: Prisma.SortOrder
mimetype?: Prisma.SortOrder
size?: Prisma.SortOrder
@@ -258,6 +272,7 @@ export type AttachmentScalarWhereWithAggregatesInput = {
OR?: Prisma.AttachmentScalarWhereWithAggregatesInput[]
NOT?: Prisma.AttachmentScalarWhereWithAggregatesInput | Prisma.AttachmentScalarWhereWithAggregatesInput[]
id?: Prisma.StringWithAggregatesFilter<"Attachment"> | string
username?: Prisma.StringNullableWithAggregatesFilter<"Attachment"> | string | null
name?: Prisma.StringWithAggregatesFilter<"Attachment"> | string
mimetype?: Prisma.StringWithAggregatesFilter<"Attachment"> | string
size?: Prisma.IntWithAggregatesFilter<"Attachment"> | number
@@ -270,11 +285,13 @@ export type AttachmentCreateInput = {
mimetype: string
size: number
createdAt?: Date | string
user?: Prisma.UserCreateNestedOneWithoutAttachmentsInput
message?: Prisma.MessageAttachmentCreateNestedManyWithoutAttachmentInput
}
export type AttachmentUncheckedCreateInput = {
id?: string
username?: string | null
name: string
mimetype: string
size: number
@@ -288,11 +305,13 @@ export type AttachmentUpdateInput = {
mimetype?: Prisma.StringFieldUpdateOperationsInput | string
size?: Prisma.IntFieldUpdateOperationsInput | number
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
user?: Prisma.UserUpdateOneWithoutAttachmentsNestedInput
message?: Prisma.MessageAttachmentUpdateManyWithoutAttachmentNestedInput
}
export type AttachmentUncheckedUpdateInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
name?: Prisma.StringFieldUpdateOperationsInput | string
mimetype?: Prisma.StringFieldUpdateOperationsInput | string
size?: Prisma.IntFieldUpdateOperationsInput | number
@@ -302,6 +321,7 @@ export type AttachmentUncheckedUpdateInput = {
export type AttachmentCreateManyInput = {
id?: string
username?: string | null
name: string
mimetype: string
size: number
@@ -318,14 +338,26 @@ export type AttachmentUpdateManyMutationInput = {
export type AttachmentUncheckedUpdateManyInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
name?: Prisma.StringFieldUpdateOperationsInput | string
mimetype?: Prisma.StringFieldUpdateOperationsInput | string
size?: Prisma.IntFieldUpdateOperationsInput | number
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
}
export type AttachmentListRelationFilter = {
every?: Prisma.AttachmentWhereInput
some?: Prisma.AttachmentWhereInput
none?: Prisma.AttachmentWhereInput
}
export type AttachmentOrderByRelationAggregateInput = {
_count?: Prisma.SortOrder
}
export type AttachmentCountOrderByAggregateInput = {
id?: Prisma.SortOrder
username?: Prisma.SortOrder
name?: Prisma.SortOrder
mimetype?: Prisma.SortOrder
size?: Prisma.SortOrder
@@ -338,6 +370,7 @@ export type AttachmentAvgOrderByAggregateInput = {
export type AttachmentMaxOrderByAggregateInput = {
id?: Prisma.SortOrder
username?: Prisma.SortOrder
name?: Prisma.SortOrder
mimetype?: Prisma.SortOrder
size?: Prisma.SortOrder
@@ -346,6 +379,7 @@ export type AttachmentMaxOrderByAggregateInput = {
export type AttachmentMinOrderByAggregateInput = {
id?: Prisma.SortOrder
username?: Prisma.SortOrder
name?: Prisma.SortOrder
mimetype?: Prisma.SortOrder
size?: Prisma.SortOrder
@@ -361,6 +395,48 @@ export type AttachmentScalarRelationFilter = {
isNot?: Prisma.AttachmentWhereInput
}
export type AttachmentCreateNestedManyWithoutUserInput = {
create?: Prisma.XOR<Prisma.AttachmentCreateWithoutUserInput, Prisma.AttachmentUncheckedCreateWithoutUserInput> | Prisma.AttachmentCreateWithoutUserInput[] | Prisma.AttachmentUncheckedCreateWithoutUserInput[]
connectOrCreate?: Prisma.AttachmentCreateOrConnectWithoutUserInput | Prisma.AttachmentCreateOrConnectWithoutUserInput[]
createMany?: Prisma.AttachmentCreateManyUserInputEnvelope
connect?: Prisma.AttachmentWhereUniqueInput | Prisma.AttachmentWhereUniqueInput[]
}
export type AttachmentUncheckedCreateNestedManyWithoutUserInput = {
create?: Prisma.XOR<Prisma.AttachmentCreateWithoutUserInput, Prisma.AttachmentUncheckedCreateWithoutUserInput> | Prisma.AttachmentCreateWithoutUserInput[] | Prisma.AttachmentUncheckedCreateWithoutUserInput[]
connectOrCreate?: Prisma.AttachmentCreateOrConnectWithoutUserInput | Prisma.AttachmentCreateOrConnectWithoutUserInput[]
createMany?: Prisma.AttachmentCreateManyUserInputEnvelope
connect?: Prisma.AttachmentWhereUniqueInput | Prisma.AttachmentWhereUniqueInput[]
}
export type AttachmentUpdateManyWithoutUserNestedInput = {
create?: Prisma.XOR<Prisma.AttachmentCreateWithoutUserInput, Prisma.AttachmentUncheckedCreateWithoutUserInput> | Prisma.AttachmentCreateWithoutUserInput[] | Prisma.AttachmentUncheckedCreateWithoutUserInput[]
connectOrCreate?: Prisma.AttachmentCreateOrConnectWithoutUserInput | Prisma.AttachmentCreateOrConnectWithoutUserInput[]
upsert?: Prisma.AttachmentUpsertWithWhereUniqueWithoutUserInput | Prisma.AttachmentUpsertWithWhereUniqueWithoutUserInput[]
createMany?: Prisma.AttachmentCreateManyUserInputEnvelope
set?: Prisma.AttachmentWhereUniqueInput | Prisma.AttachmentWhereUniqueInput[]
disconnect?: Prisma.AttachmentWhereUniqueInput | Prisma.AttachmentWhereUniqueInput[]
delete?: Prisma.AttachmentWhereUniqueInput | Prisma.AttachmentWhereUniqueInput[]
connect?: Prisma.AttachmentWhereUniqueInput | Prisma.AttachmentWhereUniqueInput[]
update?: Prisma.AttachmentUpdateWithWhereUniqueWithoutUserInput | Prisma.AttachmentUpdateWithWhereUniqueWithoutUserInput[]
updateMany?: Prisma.AttachmentUpdateManyWithWhereWithoutUserInput | Prisma.AttachmentUpdateManyWithWhereWithoutUserInput[]
deleteMany?: Prisma.AttachmentScalarWhereInput | Prisma.AttachmentScalarWhereInput[]
}
export type AttachmentUncheckedUpdateManyWithoutUserNestedInput = {
create?: Prisma.XOR<Prisma.AttachmentCreateWithoutUserInput, Prisma.AttachmentUncheckedCreateWithoutUserInput> | Prisma.AttachmentCreateWithoutUserInput[] | Prisma.AttachmentUncheckedCreateWithoutUserInput[]
connectOrCreate?: Prisma.AttachmentCreateOrConnectWithoutUserInput | Prisma.AttachmentCreateOrConnectWithoutUserInput[]
upsert?: Prisma.AttachmentUpsertWithWhereUniqueWithoutUserInput | Prisma.AttachmentUpsertWithWhereUniqueWithoutUserInput[]
createMany?: Prisma.AttachmentCreateManyUserInputEnvelope
set?: Prisma.AttachmentWhereUniqueInput | Prisma.AttachmentWhereUniqueInput[]
disconnect?: Prisma.AttachmentWhereUniqueInput | Prisma.AttachmentWhereUniqueInput[]
delete?: Prisma.AttachmentWhereUniqueInput | Prisma.AttachmentWhereUniqueInput[]
connect?: Prisma.AttachmentWhereUniqueInput | Prisma.AttachmentWhereUniqueInput[]
update?: Prisma.AttachmentUpdateWithWhereUniqueWithoutUserInput | Prisma.AttachmentUpdateWithWhereUniqueWithoutUserInput[]
updateMany?: Prisma.AttachmentUpdateManyWithWhereWithoutUserInput | Prisma.AttachmentUpdateManyWithWhereWithoutUserInput[]
deleteMany?: Prisma.AttachmentScalarWhereInput | Prisma.AttachmentScalarWhereInput[]
}
export type IntFieldUpdateOperationsInput = {
set?: number
increment?: number
@@ -383,16 +459,73 @@ export type AttachmentUpdateOneRequiredWithoutMessageNestedInput = {
update?: Prisma.XOR<Prisma.XOR<Prisma.AttachmentUpdateToOneWithWhereWithoutMessageInput, Prisma.AttachmentUpdateWithoutMessageInput>, Prisma.AttachmentUncheckedUpdateWithoutMessageInput>
}
export type AttachmentCreateWithoutUserInput = {
id?: string
name: string
mimetype: string
size: number
createdAt?: Date | string
message?: Prisma.MessageAttachmentCreateNestedManyWithoutAttachmentInput
}
export type AttachmentUncheckedCreateWithoutUserInput = {
id?: string
name: string
mimetype: string
size: number
createdAt?: Date | string
message?: Prisma.MessageAttachmentUncheckedCreateNestedManyWithoutAttachmentInput
}
export type AttachmentCreateOrConnectWithoutUserInput = {
where: Prisma.AttachmentWhereUniqueInput
create: Prisma.XOR<Prisma.AttachmentCreateWithoutUserInput, Prisma.AttachmentUncheckedCreateWithoutUserInput>
}
export type AttachmentCreateManyUserInputEnvelope = {
data: Prisma.AttachmentCreateManyUserInput | Prisma.AttachmentCreateManyUserInput[]
}
export type AttachmentUpsertWithWhereUniqueWithoutUserInput = {
where: Prisma.AttachmentWhereUniqueInput
update: Prisma.XOR<Prisma.AttachmentUpdateWithoutUserInput, Prisma.AttachmentUncheckedUpdateWithoutUserInput>
create: Prisma.XOR<Prisma.AttachmentCreateWithoutUserInput, Prisma.AttachmentUncheckedCreateWithoutUserInput>
}
export type AttachmentUpdateWithWhereUniqueWithoutUserInput = {
where: Prisma.AttachmentWhereUniqueInput
data: Prisma.XOR<Prisma.AttachmentUpdateWithoutUserInput, Prisma.AttachmentUncheckedUpdateWithoutUserInput>
}
export type AttachmentUpdateManyWithWhereWithoutUserInput = {
where: Prisma.AttachmentScalarWhereInput
data: Prisma.XOR<Prisma.AttachmentUpdateManyMutationInput, Prisma.AttachmentUncheckedUpdateManyWithoutUserInput>
}
export type AttachmentScalarWhereInput = {
AND?: Prisma.AttachmentScalarWhereInput | Prisma.AttachmentScalarWhereInput[]
OR?: Prisma.AttachmentScalarWhereInput[]
NOT?: Prisma.AttachmentScalarWhereInput | Prisma.AttachmentScalarWhereInput[]
id?: Prisma.StringFilter<"Attachment"> | string
username?: Prisma.StringNullableFilter<"Attachment"> | string | null
name?: Prisma.StringFilter<"Attachment"> | string
mimetype?: Prisma.StringFilter<"Attachment"> | string
size?: Prisma.IntFilter<"Attachment"> | number
createdAt?: Prisma.DateTimeFilter<"Attachment"> | Date | string
}
export type AttachmentCreateWithoutMessageInput = {
id?: string
name: string
mimetype: string
size: number
createdAt?: Date | string
user?: Prisma.UserCreateNestedOneWithoutAttachmentsInput
}
export type AttachmentUncheckedCreateWithoutMessageInput = {
id?: string
username?: string | null
name: string
mimetype: string
size: number
@@ -421,9 +554,45 @@ export type AttachmentUpdateWithoutMessageInput = {
mimetype?: Prisma.StringFieldUpdateOperationsInput | string
size?: Prisma.IntFieldUpdateOperationsInput | number
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
user?: Prisma.UserUpdateOneWithoutAttachmentsNestedInput
}
export type AttachmentUncheckedUpdateWithoutMessageInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
name?: Prisma.StringFieldUpdateOperationsInput | string
mimetype?: Prisma.StringFieldUpdateOperationsInput | string
size?: Prisma.IntFieldUpdateOperationsInput | number
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
}
export type AttachmentCreateManyUserInput = {
id?: string
name: string
mimetype: string
size: number
createdAt?: Date | string
}
export type AttachmentUpdateWithoutUserInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
name?: Prisma.StringFieldUpdateOperationsInput | string
mimetype?: Prisma.StringFieldUpdateOperationsInput | string
size?: Prisma.IntFieldUpdateOperationsInput | number
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
message?: Prisma.MessageAttachmentUpdateManyWithoutAttachmentNestedInput
}
export type AttachmentUncheckedUpdateWithoutUserInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
name?: Prisma.StringFieldUpdateOperationsInput | string
mimetype?: Prisma.StringFieldUpdateOperationsInput | string
size?: Prisma.IntFieldUpdateOperationsInput | number
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
message?: Prisma.MessageAttachmentUncheckedUpdateManyWithoutAttachmentNestedInput
}
export type AttachmentUncheckedUpdateManyWithoutUserInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
name?: Prisma.StringFieldUpdateOperationsInput | string
mimetype?: Prisma.StringFieldUpdateOperationsInput | string
@@ -464,53 +633,67 @@ export type AttachmentCountOutputTypeCountMessageArgs<ExtArgs extends runtime.Ty
export type AttachmentSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean
username?: boolean
name?: boolean
mimetype?: boolean
size?: boolean
createdAt?: boolean
user?: boolean | Prisma.Attachment$userArgs<ExtArgs>
message?: boolean | Prisma.Attachment$messageArgs<ExtArgs>
_count?: boolean | Prisma.AttachmentCountOutputTypeDefaultArgs<ExtArgs>
}, ExtArgs["result"]["attachment"]>
export type AttachmentSelectCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean
username?: boolean
name?: boolean
mimetype?: boolean
size?: boolean
createdAt?: boolean
user?: boolean | Prisma.Attachment$userArgs<ExtArgs>
}, ExtArgs["result"]["attachment"]>
export type AttachmentSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean
username?: boolean
name?: boolean
mimetype?: boolean
size?: boolean
createdAt?: boolean
user?: boolean | Prisma.Attachment$userArgs<ExtArgs>
}, ExtArgs["result"]["attachment"]>
export type AttachmentSelectScalar = {
id?: boolean
username?: boolean
name?: boolean
mimetype?: boolean
size?: boolean
createdAt?: boolean
}
export type AttachmentOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "name" | "mimetype" | "size" | "createdAt", ExtArgs["result"]["attachment"]>
export type AttachmentOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "username" | "name" | "mimetype" | "size" | "createdAt", ExtArgs["result"]["attachment"]>
export type AttachmentInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
user?: boolean | Prisma.Attachment$userArgs<ExtArgs>
message?: boolean | Prisma.Attachment$messageArgs<ExtArgs>
_count?: boolean | Prisma.AttachmentCountOutputTypeDefaultArgs<ExtArgs>
}
export type AttachmentIncludeCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {}
export type AttachmentIncludeUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {}
export type AttachmentIncludeCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
user?: boolean | Prisma.Attachment$userArgs<ExtArgs>
}
export type AttachmentIncludeUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
user?: boolean | Prisma.Attachment$userArgs<ExtArgs>
}
export type $AttachmentPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
name: "Attachment"
objects: {
user: Prisma.$UserPayload<ExtArgs> | null
message: Prisma.$MessageAttachmentPayload<ExtArgs>[]
}
scalars: runtime.Types.Extensions.GetPayloadResult<{
id: string
username: string | null
name: string
mimetype: string
size: number
@@ -909,6 +1092,7 @@ readonly fields: AttachmentFieldRefs;
*/
export interface Prisma__AttachmentClient<T, Null = never, ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs, GlobalOmitOptions = {}> extends Prisma.PrismaPromise<T> {
readonly [Symbol.toStringTag]: "PrismaPromise"
user<T extends Prisma.Attachment$userArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Attachment$userArgs<ExtArgs>>): Prisma.Prisma__UserClient<runtime.Types.Result.GetResult<Prisma.$UserPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
message<T extends Prisma.Attachment$messageArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Attachment$messageArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$MessageAttachmentPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
@@ -940,6 +1124,7 @@ export interface Prisma__AttachmentClient<T, Null = never, ExtArgs extends runti
*/
export interface AttachmentFieldRefs {
readonly id: Prisma.FieldRef<"Attachment", 'String'>
readonly username: Prisma.FieldRef<"Attachment", 'String'>
readonly name: Prisma.FieldRef<"Attachment", 'String'>
readonly mimetype: Prisma.FieldRef<"Attachment", 'String'>
readonly size: Prisma.FieldRef<"Attachment", 'Int'>
@@ -1196,6 +1381,10 @@ export type AttachmentCreateManyAndReturnArgs<ExtArgs extends runtime.Types.Exte
* The data used to create many Attachments.
*/
data: Prisma.AttachmentCreateManyInput | Prisma.AttachmentCreateManyInput[]
/**
* Choose, which related nodes to fetch as well
*/
include?: Prisma.AttachmentIncludeCreateManyAndReturn<ExtArgs> | null
}
/**
@@ -1266,6 +1455,10 @@ export type AttachmentUpdateManyAndReturnArgs<ExtArgs extends runtime.Types.Exte
* Limit how many Attachments to update.
*/
limit?: number
/**
* Choose, which related nodes to fetch as well
*/
include?: Prisma.AttachmentIncludeUpdateManyAndReturn<ExtArgs> | null
}
/**
@@ -1334,6 +1527,25 @@ export type AttachmentDeleteManyArgs<ExtArgs extends runtime.Types.Extensions.In
limit?: number
}
/**
* Attachment.user
*/
export type Attachment$userArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
/**
* Select specific fields to fetch from the User
*/
select?: Prisma.UserSelect<ExtArgs> | null
/**
* Omit specific fields from the User
*/
omit?: Prisma.UserOmit<ExtArgs> | null
/**
* Choose, which related nodes to fetch as well
*/
include?: Prisma.UserInclude<ExtArgs> | null
where?: Prisma.UserWhereInput
}
/**
* Attachment.message
*/

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,12 +177,12 @@ 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
createdAt?: Prisma.DateTimeFilter<"User"> | Date | string
updatedAt?: Prisma.DateTimeFilter<"User"> | Date | string
Attachments?: Prisma.AttachmentListRelationFilter
Session?: Prisma.SessionListRelationFilter
UserPreferences?: Prisma.XOR<Prisma.UserPreferencesNullableScalarRelationFilter, Prisma.UserPreferencesWhereInput> | null
Messages?: Prisma.MessageListRelationFilter
@@ -197,12 +190,12 @@ export type UserWhereInput = {
}
export type UserOrderByWithRelationInput = {
id?: Prisma.SortOrder
username?: Prisma.SortOrder
password?: Prisma.SortOrder
displayName?: Prisma.SortOrder
createdAt?: Prisma.SortOrder
updatedAt?: Prisma.SortOrder
Attachments?: Prisma.AttachmentOrderByRelationAggregateInput
Session?: Prisma.SessionOrderByRelationAggregateInput
UserPreferences?: Prisma.UserPreferencesOrderByWithRelationInput
Messages?: Prisma.MessageOrderByRelationAggregateInput
@@ -210,7 +203,6 @@ export type UserOrderByWithRelationInput = {
}
export type UserWhereUniqueInput = Prisma.AtLeast<{
id?: string
username?: string
AND?: Prisma.UserWhereInput | Prisma.UserWhereInput[]
OR?: Prisma.UserWhereInput[]
@@ -219,14 +211,14 @@ export type UserWhereUniqueInput = Prisma.AtLeast<{
displayName?: Prisma.StringFilter<"User"> | string
createdAt?: Prisma.DateTimeFilter<"User"> | Date | string
updatedAt?: Prisma.DateTimeFilter<"User"> | Date | string
Attachments?: Prisma.AttachmentListRelationFilter
Session?: Prisma.SessionListRelationFilter
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 +233,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,12 +241,12 @@ export type UserScalarWhereWithAggregatesInput = {
}
export type UserCreateInput = {
id?: string
username: string
password: string
displayName: string
createdAt?: Date | string
updatedAt?: Date | string
Attachments?: Prisma.AttachmentCreateNestedManyWithoutUserInput
Session?: Prisma.SessionCreateNestedManyWithoutUserInput
UserPreferences?: Prisma.UserPreferencesCreateNestedOneWithoutUserInput
Messages?: Prisma.MessageCreateNestedManyWithoutSenderInput
@@ -263,12 +254,12 @@ export type UserCreateInput = {
}
export type UserUncheckedCreateInput = {
id?: string
username: string
password: string
displayName: string
createdAt?: Date | string
updatedAt?: Date | string
Attachments?: Prisma.AttachmentUncheckedCreateNestedManyWithoutUserInput
Session?: Prisma.SessionUncheckedCreateNestedManyWithoutUserInput
UserPreferences?: Prisma.UserPreferencesUncheckedCreateNestedOneWithoutUserInput
Messages?: Prisma.MessageUncheckedCreateNestedManyWithoutSenderInput
@@ -276,12 +267,12 @@ export type UserUncheckedCreateInput = {
}
export type UserUpdateInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
Attachments?: Prisma.AttachmentUpdateManyWithoutUserNestedInput
Session?: Prisma.SessionUpdateManyWithoutUserNestedInput
UserPreferences?: Prisma.UserPreferencesUpdateOneWithoutUserNestedInput
Messages?: Prisma.MessageUpdateManyWithoutSenderNestedInput
@@ -289,12 +280,12 @@ export type UserUpdateInput = {
}
export type UserUncheckedUpdateInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
Attachments?: Prisma.AttachmentUncheckedUpdateManyWithoutUserNestedInput
Session?: Prisma.SessionUncheckedUpdateManyWithoutUserNestedInput
UserPreferences?: Prisma.UserPreferencesUncheckedUpdateOneWithoutUserNestedInput
Messages?: Prisma.MessageUncheckedUpdateManyWithoutSenderNestedInput
@@ -302,7 +293,6 @@ export type UserUncheckedUpdateInput = {
}
export type UserCreateManyInput = {
id?: string
username: string
password: string
displayName: string
@@ -311,7 +301,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 +309,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 +317,6 @@ export type UserUncheckedUpdateManyInput = {
}
export type UserCountOrderByAggregateInput = {
id?: Prisma.SortOrder
username?: Prisma.SortOrder
password?: Prisma.SortOrder
displayName?: Prisma.SortOrder
@@ -338,7 +325,6 @@ export type UserCountOrderByAggregateInput = {
}
export type UserMaxOrderByAggregateInput = {
id?: Prisma.SortOrder
username?: Prisma.SortOrder
password?: Prisma.SortOrder
displayName?: Prisma.SortOrder
@@ -347,7 +333,6 @@ export type UserMaxOrderByAggregateInput = {
}
export type UserMinOrderByAggregateInput = {
id?: Prisma.SortOrder
username?: Prisma.SortOrder
password?: Prisma.SortOrder
displayName?: Prisma.SortOrder
@@ -401,6 +386,22 @@ export type UserUpdateOneRequiredWithoutUserPreferencesNestedInput = {
update?: Prisma.XOR<Prisma.XOR<Prisma.UserUpdateToOneWithWhereWithoutUserPreferencesInput, Prisma.UserUpdateWithoutUserPreferencesInput>, Prisma.UserUncheckedUpdateWithoutUserPreferencesInput>
}
export type UserCreateNestedOneWithoutAttachmentsInput = {
create?: Prisma.XOR<Prisma.UserCreateWithoutAttachmentsInput, Prisma.UserUncheckedCreateWithoutAttachmentsInput>
connectOrCreate?: Prisma.UserCreateOrConnectWithoutAttachmentsInput
connect?: Prisma.UserWhereUniqueInput
}
export type UserUpdateOneWithoutAttachmentsNestedInput = {
create?: Prisma.XOR<Prisma.UserCreateWithoutAttachmentsInput, Prisma.UserUncheckedCreateWithoutAttachmentsInput>
connectOrCreate?: Prisma.UserCreateOrConnectWithoutAttachmentsInput
upsert?: Prisma.UserUpsertWithoutAttachmentsInput
disconnect?: Prisma.UserWhereInput | boolean
delete?: Prisma.UserWhereInput | boolean
connect?: Prisma.UserWhereUniqueInput
update?: Prisma.XOR<Prisma.XOR<Prisma.UserUpdateToOneWithWhereWithoutAttachmentsInput, Prisma.UserUpdateWithoutAttachmentsInput>, Prisma.UserUncheckedUpdateWithoutAttachmentsInput>
}
export type UserCreateNestedOneWithoutMessagesInput = {
create?: Prisma.XOR<Prisma.UserCreateWithoutMessagesInput, Prisma.UserUncheckedCreateWithoutMessagesInput>
connectOrCreate?: Prisma.UserCreateOrConnectWithoutMessagesInput
@@ -434,24 +435,24 @@ export type UserUpdateOneWithoutChannelsNestedInput = {
}
export type UserCreateWithoutSessionInput = {
id?: string
username: string
password: string
displayName: string
createdAt?: Date | string
updatedAt?: Date | string
Attachments?: Prisma.AttachmentCreateNestedManyWithoutUserInput
UserPreferences?: Prisma.UserPreferencesCreateNestedOneWithoutUserInput
Messages?: Prisma.MessageCreateNestedManyWithoutSenderInput
Channels?: Prisma.ChannelCreateNestedManyWithoutOwnerInput
}
export type UserUncheckedCreateWithoutSessionInput = {
id?: string
username: string
password: string
displayName: string
createdAt?: Date | string
updatedAt?: Date | string
Attachments?: Prisma.AttachmentUncheckedCreateNestedManyWithoutUserInput
UserPreferences?: Prisma.UserPreferencesUncheckedCreateNestedOneWithoutUserInput
Messages?: Prisma.MessageUncheckedCreateNestedManyWithoutSenderInput
Channels?: Prisma.ChannelUncheckedCreateNestedManyWithoutOwnerInput
@@ -474,48 +475,48 @@ export type UserUpdateToOneWithWhereWithoutSessionInput = {
}
export type UserUpdateWithoutSessionInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
Attachments?: Prisma.AttachmentUpdateManyWithoutUserNestedInput
UserPreferences?: Prisma.UserPreferencesUpdateOneWithoutUserNestedInput
Messages?: Prisma.MessageUpdateManyWithoutSenderNestedInput
Channels?: Prisma.ChannelUpdateManyWithoutOwnerNestedInput
}
export type UserUncheckedUpdateWithoutSessionInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
Attachments?: Prisma.AttachmentUncheckedUpdateManyWithoutUserNestedInput
UserPreferences?: Prisma.UserPreferencesUncheckedUpdateOneWithoutUserNestedInput
Messages?: Prisma.MessageUncheckedUpdateManyWithoutSenderNestedInput
Channels?: Prisma.ChannelUncheckedUpdateManyWithoutOwnerNestedInput
}
export type UserCreateWithoutUserPreferencesInput = {
id?: string
username: string
password: string
displayName: string
createdAt?: Date | string
updatedAt?: Date | string
Attachments?: Prisma.AttachmentCreateNestedManyWithoutUserInput
Session?: Prisma.SessionCreateNestedManyWithoutUserInput
Messages?: Prisma.MessageCreateNestedManyWithoutSenderInput
Channels?: Prisma.ChannelCreateNestedManyWithoutOwnerInput
}
export type UserUncheckedCreateWithoutUserPreferencesInput = {
id?: string
username: string
password: string
displayName: string
createdAt?: Date | string
updatedAt?: Date | string
Attachments?: Prisma.AttachmentUncheckedCreateNestedManyWithoutUserInput
Session?: Prisma.SessionUncheckedCreateNestedManyWithoutUserInput
Messages?: Prisma.MessageUncheckedCreateNestedManyWithoutSenderInput
Channels?: Prisma.ChannelUncheckedCreateNestedManyWithoutOwnerInput
@@ -538,31 +539,30 @@ export type UserUpdateToOneWithWhereWithoutUserPreferencesInput = {
}
export type UserUpdateWithoutUserPreferencesInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
Attachments?: Prisma.AttachmentUpdateManyWithoutUserNestedInput
Session?: Prisma.SessionUpdateManyWithoutUserNestedInput
Messages?: Prisma.MessageUpdateManyWithoutSenderNestedInput
Channels?: Prisma.ChannelUpdateManyWithoutOwnerNestedInput
}
export type UserUncheckedUpdateWithoutUserPreferencesInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
Attachments?: Prisma.AttachmentUncheckedUpdateManyWithoutUserNestedInput
Session?: Prisma.SessionUncheckedUpdateManyWithoutUserNestedInput
Messages?: Prisma.MessageUncheckedUpdateManyWithoutSenderNestedInput
Channels?: Prisma.ChannelUncheckedUpdateManyWithoutOwnerNestedInput
}
export type UserCreateWithoutMessagesInput = {
id?: string
export type UserCreateWithoutAttachmentsInput = {
username: string
password: string
displayName: string
@@ -570,11 +570,11 @@ export type UserCreateWithoutMessagesInput = {
updatedAt?: Date | string
Session?: Prisma.SessionCreateNestedManyWithoutUserInput
UserPreferences?: Prisma.UserPreferencesCreateNestedOneWithoutUserInput
Messages?: Prisma.MessageCreateNestedManyWithoutSenderInput
Channels?: Prisma.ChannelCreateNestedManyWithoutOwnerInput
}
export type UserUncheckedCreateWithoutMessagesInput = {
id?: string
export type UserUncheckedCreateWithoutAttachmentsInput = {
username: string
password: string
displayName: string
@@ -582,6 +582,71 @@ export type UserUncheckedCreateWithoutMessagesInput = {
updatedAt?: Date | string
Session?: Prisma.SessionUncheckedCreateNestedManyWithoutUserInput
UserPreferences?: Prisma.UserPreferencesUncheckedCreateNestedOneWithoutUserInput
Messages?: Prisma.MessageUncheckedCreateNestedManyWithoutSenderInput
Channels?: Prisma.ChannelUncheckedCreateNestedManyWithoutOwnerInput
}
export type UserCreateOrConnectWithoutAttachmentsInput = {
where: Prisma.UserWhereUniqueInput
create: Prisma.XOR<Prisma.UserCreateWithoutAttachmentsInput, Prisma.UserUncheckedCreateWithoutAttachmentsInput>
}
export type UserUpsertWithoutAttachmentsInput = {
update: Prisma.XOR<Prisma.UserUpdateWithoutAttachmentsInput, Prisma.UserUncheckedUpdateWithoutAttachmentsInput>
create: Prisma.XOR<Prisma.UserCreateWithoutAttachmentsInput, Prisma.UserUncheckedCreateWithoutAttachmentsInput>
where?: Prisma.UserWhereInput
}
export type UserUpdateToOneWithWhereWithoutAttachmentsInput = {
where?: Prisma.UserWhereInput
data: Prisma.XOR<Prisma.UserUpdateWithoutAttachmentsInput, Prisma.UserUncheckedUpdateWithoutAttachmentsInput>
}
export type UserUpdateWithoutAttachmentsInput = {
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
Session?: Prisma.SessionUpdateManyWithoutUserNestedInput
UserPreferences?: Prisma.UserPreferencesUpdateOneWithoutUserNestedInput
Messages?: Prisma.MessageUpdateManyWithoutSenderNestedInput
Channels?: Prisma.ChannelUpdateManyWithoutOwnerNestedInput
}
export type UserUncheckedUpdateWithoutAttachmentsInput = {
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
Session?: Prisma.SessionUncheckedUpdateManyWithoutUserNestedInput
UserPreferences?: Prisma.UserPreferencesUncheckedUpdateOneWithoutUserNestedInput
Messages?: Prisma.MessageUncheckedUpdateManyWithoutSenderNestedInput
Channels?: Prisma.ChannelUncheckedUpdateManyWithoutOwnerNestedInput
}
export type UserCreateWithoutMessagesInput = {
username: string
password: string
displayName: string
createdAt?: Date | string
updatedAt?: Date | string
Attachments?: Prisma.AttachmentCreateNestedManyWithoutUserInput
Session?: Prisma.SessionCreateNestedManyWithoutUserInput
UserPreferences?: Prisma.UserPreferencesCreateNestedOneWithoutUserInput
Channels?: Prisma.ChannelCreateNestedManyWithoutOwnerInput
}
export type UserUncheckedCreateWithoutMessagesInput = {
username: string
password: string
displayName: string
createdAt?: Date | string
updatedAt?: Date | string
Attachments?: Prisma.AttachmentUncheckedCreateNestedManyWithoutUserInput
Session?: Prisma.SessionUncheckedCreateNestedManyWithoutUserInput
UserPreferences?: Prisma.UserPreferencesUncheckedCreateNestedOneWithoutUserInput
Channels?: Prisma.ChannelUncheckedCreateNestedManyWithoutOwnerInput
}
@@ -602,48 +667,48 @@ export type UserUpdateToOneWithWhereWithoutMessagesInput = {
}
export type UserUpdateWithoutMessagesInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
Attachments?: Prisma.AttachmentUpdateManyWithoutUserNestedInput
Session?: Prisma.SessionUpdateManyWithoutUserNestedInput
UserPreferences?: Prisma.UserPreferencesUpdateOneWithoutUserNestedInput
Channels?: Prisma.ChannelUpdateManyWithoutOwnerNestedInput
}
export type UserUncheckedUpdateWithoutMessagesInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
Attachments?: Prisma.AttachmentUncheckedUpdateManyWithoutUserNestedInput
Session?: Prisma.SessionUncheckedUpdateManyWithoutUserNestedInput
UserPreferences?: Prisma.UserPreferencesUncheckedUpdateOneWithoutUserNestedInput
Channels?: Prisma.ChannelUncheckedUpdateManyWithoutOwnerNestedInput
}
export type UserCreateWithoutChannelsInput = {
id?: string
username: string
password: string
displayName: string
createdAt?: Date | string
updatedAt?: Date | string
Attachments?: Prisma.AttachmentCreateNestedManyWithoutUserInput
Session?: Prisma.SessionCreateNestedManyWithoutUserInput
UserPreferences?: Prisma.UserPreferencesCreateNestedOneWithoutUserInput
Messages?: Prisma.MessageCreateNestedManyWithoutSenderInput
}
export type UserUncheckedCreateWithoutChannelsInput = {
id?: string
username: string
password: string
displayName: string
createdAt?: Date | string
updatedAt?: Date | string
Attachments?: Prisma.AttachmentUncheckedCreateNestedManyWithoutUserInput
Session?: Prisma.SessionUncheckedCreateNestedManyWithoutUserInput
UserPreferences?: Prisma.UserPreferencesUncheckedCreateNestedOneWithoutUserInput
Messages?: Prisma.MessageUncheckedCreateNestedManyWithoutSenderInput
@@ -666,24 +731,24 @@ export type UserUpdateToOneWithWhereWithoutChannelsInput = {
}
export type UserUpdateWithoutChannelsInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
Attachments?: Prisma.AttachmentUpdateManyWithoutUserNestedInput
Session?: Prisma.SessionUpdateManyWithoutUserNestedInput
UserPreferences?: Prisma.UserPreferencesUpdateOneWithoutUserNestedInput
Messages?: Prisma.MessageUpdateManyWithoutSenderNestedInput
}
export type UserUncheckedUpdateWithoutChannelsInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
username?: Prisma.StringFieldUpdateOperationsInput | string
password?: Prisma.StringFieldUpdateOperationsInput | string
displayName?: Prisma.StringFieldUpdateOperationsInput | string
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
Attachments?: Prisma.AttachmentUncheckedUpdateManyWithoutUserNestedInput
Session?: Prisma.SessionUncheckedUpdateManyWithoutUserNestedInput
UserPreferences?: Prisma.UserPreferencesUncheckedUpdateOneWithoutUserNestedInput
Messages?: Prisma.MessageUncheckedUpdateManyWithoutSenderNestedInput
@@ -695,12 +760,14 @@ export type UserUncheckedUpdateWithoutChannelsInput = {
*/
export type UserCountOutputType = {
Attachments: number
Session: number
Messages: number
Channels: number
}
export type UserCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
Attachments?: boolean | UserCountOutputTypeCountAttachmentsArgs
Session?: boolean | UserCountOutputTypeCountSessionArgs
Messages?: boolean | UserCountOutputTypeCountMessagesArgs
Channels?: boolean | UserCountOutputTypeCountChannelsArgs
@@ -716,6 +783,13 @@ export type UserCountOutputTypeDefaultArgs<ExtArgs extends runtime.Types.Extensi
select?: Prisma.UserCountOutputTypeSelect<ExtArgs> | null
}
/**
* UserCountOutputType without action
*/
export type UserCountOutputTypeCountAttachmentsArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
where?: Prisma.AttachmentWhereInput
}
/**
* UserCountOutputType without action
*/
@@ -739,12 +813,12 @@ 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
createdAt?: boolean
updatedAt?: boolean
Attachments?: boolean | Prisma.User$AttachmentsArgs<ExtArgs>
Session?: boolean | Prisma.User$SessionArgs<ExtArgs>
UserPreferences?: boolean | Prisma.User$UserPreferencesArgs<ExtArgs>
Messages?: boolean | Prisma.User$MessagesArgs<ExtArgs>
@@ -753,7 +827,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 +835,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 +843,6 @@ export type UserSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensio
}, ExtArgs["result"]["user"]>
export type UserSelectScalar = {
id?: boolean
username?: boolean
password?: boolean
displayName?: boolean
@@ -779,8 +850,9 @@ 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> = {
Attachments?: boolean | Prisma.User$AttachmentsArgs<ExtArgs>
Session?: boolean | Prisma.User$SessionArgs<ExtArgs>
UserPreferences?: boolean | Prisma.User$UserPreferencesArgs<ExtArgs>
Messages?: boolean | Prisma.User$MessagesArgs<ExtArgs>
@@ -793,13 +865,13 @@ export type UserIncludeUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensi
export type $UserPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
name: "User"
objects: {
Attachments: Prisma.$AttachmentPayload<ExtArgs>[]
Session: Prisma.$SessionPayload<ExtArgs>[]
UserPreferences: Prisma.$UserPreferencesPayload<ExtArgs> | null
Messages: Prisma.$MessagePayload<ExtArgs>[]
Channels: Prisma.$ChannelPayload<ExtArgs>[]
}
scalars: runtime.Types.Extensions.GetPayloadResult<{
id: string
username: string
password: string
displayName: string
@@ -888,8 +960,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 +1005,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 +1096,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
* },
@@ -1199,6 +1271,7 @@ readonly fields: UserFieldRefs;
*/
export interface Prisma__UserClient<T, Null = never, ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs, GlobalOmitOptions = {}> extends Prisma.PrismaPromise<T> {
readonly [Symbol.toStringTag]: "PrismaPromise"
Attachments<T extends Prisma.User$AttachmentsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.User$AttachmentsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$AttachmentPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
Session<T extends Prisma.User$SessionArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.User$SessionArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$SessionPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
UserPreferences<T extends Prisma.User$UserPreferencesArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.User$UserPreferencesArgs<ExtArgs>>): Prisma.Prisma__UserPreferencesClient<runtime.Types.Result.GetResult<Prisma.$UserPreferencesPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
Messages<T extends Prisma.User$MessagesArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.User$MessagesArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$MessagePayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
@@ -1232,7 +1305,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'>
@@ -1628,6 +1700,30 @@ export type UserDeleteManyArgs<ExtArgs extends runtime.Types.Extensions.Internal
limit?: number
}
/**
* User.Attachments
*/
export type User$AttachmentsArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
/**
* Select specific fields to fetch from the Attachment
*/
select?: Prisma.AttachmentSelect<ExtArgs> | null
/**
* Omit specific fields from the Attachment
*/
omit?: Prisma.AttachmentOmit<ExtArgs> | null
/**
* Choose, which related nodes to fetch as well
*/
include?: Prisma.AttachmentInclude<ExtArgs> | null
where?: Prisma.AttachmentWhereInput
orderBy?: Prisma.AttachmentOrderByWithRelationInput | Prisma.AttachmentOrderByWithRelationInput[]
cursor?: Prisma.AttachmentWhereUniqueInput
take?: number
skip?: number
distinct?: Prisma.AttachmentScalarFieldEnum | Prisma.AttachmentScalarFieldEnum[]
}
/**
* User.Session
*/

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

@@ -0,0 +1,101 @@
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
-- =====================
-- Channel
-- =====================
CREATE TABLE "new_Channel" (
"id" TEXT NOT NULL PRIMARY KEY,
"ownerId" TEXT,
"ownerUsername" TEXT,
"name" TEXT NOT NULL,
"persistent" BOOLEAN NOT NULL,
CONSTRAINT "Channel_ownerUsername_fkey" FOREIGN KEY ("ownerUsername") REFERENCES "User" ("username") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "new_Channel" ("id", "name", "ownerId", "ownerUsername", "persistent")
SELECT c."id", c."name", c."ownerId",
(SELECT u."username" FROM "User" u WHERE u."id" = c."ownerId"),
c."persistent"
FROM "Channel" c;
DROP TABLE "Channel";
ALTER TABLE "new_Channel" RENAME TO "Channel";
-- =====================
-- Message
-- =====================
CREATE TABLE "new_Message" (
"id" TEXT NOT NULL PRIMARY KEY,
"text" TEXT NOT NULL,
"senderId" TEXT,
"senderUsername" TEXT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
CONSTRAINT "Message_senderUsername_fkey" FOREIGN KEY ("senderUsername") REFERENCES "User" ("username") ON DELETE SET NULL ON UPDATE CASCADE
);
INSERT INTO "new_Message" ("id", "text", "senderId", "senderUsername", "createdAt", "updatedAt")
SELECT m."id", m."text", m."senderId",
(SELECT u."username" FROM "User" u WHERE u."id" = m."senderId"),
m."createdAt", m."updatedAt"
FROM "Message" m;
DROP TABLE "Message";
ALTER TABLE "new_Message" RENAME TO "Message";
-- =====================
-- Session
-- =====================
CREATE TABLE "new_Session" (
"id" TEXT NOT NULL PRIMARY KEY,
"userId" TEXT NOT NULL,
"username" TEXT NOT NULL,
"expiresAt" DATETIME NOT NULL,
CONSTRAINT "Session_username_fkey" FOREIGN KEY ("username") REFERENCES "User" ("username") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "new_Session" ("id", "userId", "username", "expiresAt")
SELECT s."id", s."userId",
(SELECT u."username" FROM "User" u WHERE u."id" = s."userId"),
s."expiresAt"
FROM "Session" s;
DROP TABLE "Session";
ALTER TABLE "new_Session" RENAME TO "Session";
CREATE INDEX "Session_userId_idx" ON "Session"("userId");
-- =====================
-- User
-- =====================
CREATE TABLE "new_User" (
"id" TEXT NOT NULL,
"username" TEXT NOT NULL PRIMARY KEY,
"password" TEXT NOT NULL,
"displayName" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);
INSERT INTO "new_User" ("createdAt", "displayName", "id", "password", "updatedAt", "username")
SELECT "createdAt", "displayName", "id", "password", "updatedAt", "username"
FROM "User";
DROP TABLE "User";
ALTER TABLE "new_User" RENAME TO "User";
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
-- =====================
-- UserPreferences
-- =====================
CREATE TABLE "new_UserPreferences" (
"userId" TEXT NOT NULL,
"username" TEXT NOT NULL PRIMARY KEY,
"toggleInputHotkey" TEXT DEFAULT '',
"toggleOutputHotkey" TEXT DEFAULT '',
CONSTRAINT "UserPreferences_username_fkey" FOREIGN KEY ("username") REFERENCES "User" ("username") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "new_UserPreferences" ("userId", "username", "toggleInputHotkey", "toggleOutputHotkey")
SELECT up."userId",
(SELECT u."username" FROM "User" u WHERE u."id" = up."userId"),
up."toggleInputHotkey", up."toggleOutputHotkey"
FROM "UserPreferences" up;
DROP TABLE "UserPreferences";
ALTER TABLE "new_UserPreferences" RENAME TO "UserPreferences";
CREATE UNIQUE INDEX "UserPreferences_userId_key" ON "UserPreferences"("userId");
CREATE UNIQUE INDEX "UserPreferences_username_key" ON "UserPreferences"("username");
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;

View File

@@ -0,0 +1,67 @@
/*
Warnings:
- You are about to drop the column `ownerId` on the `Channel` table. All the data in the column will be lost.
- You are about to drop the column `senderId` on the `Message` table. All the data in the column will be lost.
- You are about to drop the column `userId` on the `Session` table. All the data in the column will be lost.
- You are about to drop the column `id` on the `User` table. All the data in the column will be lost.
- You are about to drop the column `userId` on the `UserPreferences` table. All the data in the column will be lost.
*/
-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Channel" (
"id" TEXT NOT NULL PRIMARY KEY,
"ownerUsername" TEXT,
"name" TEXT NOT NULL,
"persistent" BOOLEAN NOT NULL,
CONSTRAINT "Channel_ownerUsername_fkey" FOREIGN KEY ("ownerUsername") REFERENCES "User" ("username") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "new_Channel" ("id", "name", "ownerUsername", "persistent") SELECT "id", "name", "ownerUsername", "persistent" FROM "Channel";
DROP TABLE "Channel";
ALTER TABLE "new_Channel" RENAME TO "Channel";
CREATE TABLE "new_Message" (
"id" TEXT NOT NULL PRIMARY KEY,
"text" TEXT NOT NULL,
"senderUsername" TEXT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
CONSTRAINT "Message_senderUsername_fkey" FOREIGN KEY ("senderUsername") REFERENCES "User" ("username") ON DELETE SET NULL ON UPDATE CASCADE
);
INSERT INTO "new_Message" ("createdAt", "id", "senderUsername", "text", "updatedAt") SELECT "createdAt", "id", "senderUsername", "text", "updatedAt" FROM "Message";
DROP TABLE "Message";
ALTER TABLE "new_Message" RENAME TO "Message";
CREATE TABLE "new_Session" (
"id" TEXT NOT NULL PRIMARY KEY,
"username" TEXT NOT NULL,
"expiresAt" DATETIME NOT NULL,
CONSTRAINT "Session_username_fkey" FOREIGN KEY ("username") REFERENCES "User" ("username") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "new_Session" ("expiresAt", "id", "username") SELECT "expiresAt", "id", "username" FROM "Session";
DROP TABLE "Session";
ALTER TABLE "new_Session" RENAME TO "Session";
CREATE INDEX "Session_username_idx" ON "Session"("username");
CREATE TABLE "new_User" (
"username" TEXT NOT NULL PRIMARY KEY,
"password" TEXT NOT NULL,
"displayName" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);
INSERT INTO "new_User" ("createdAt", "displayName", "password", "updatedAt", "username") SELECT "createdAt", "displayName", "password", "updatedAt", "username" FROM "User";
DROP TABLE "User";
ALTER TABLE "new_User" RENAME TO "User";
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
CREATE TABLE "new_UserPreferences" (
"username" TEXT NOT NULL PRIMARY KEY,
"toggleInputHotkey" TEXT DEFAULT '',
"toggleOutputHotkey" TEXT DEFAULT '',
CONSTRAINT "UserPreferences_username_fkey" FOREIGN KEY ("username") REFERENCES "User" ("username") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "new_UserPreferences" ("toggleInputHotkey", "toggleOutputHotkey", "username") SELECT "toggleInputHotkey", "toggleOutputHotkey", "username" FROM "UserPreferences";
DROP TABLE "UserPreferences";
ALTER TABLE "new_UserPreferences" RENAME TO "UserPreferences";
CREATE UNIQUE INDEX "UserPreferences_username_key" ON "UserPreferences"("username");
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;

View File

@@ -0,0 +1,21 @@
/*
Warnings:
- You are about to drop the column `username` on the `Session` table. All the data in the column will be lost.
- Added the required column `userId` to the `Session` table without a default value. This is not possible if the table is not empty.
*/
-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Session" (
"id" TEXT NOT NULL PRIMARY KEY,
"userId" TEXT NOT NULL,
"expiresAt" DATETIME NOT NULL,
CONSTRAINT "Session_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("username") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "new_Session" ("expiresAt", "id") SELECT "expiresAt", "id" FROM "Session";
DROP TABLE "Session";
ALTER TABLE "new_Session" RENAME TO "Session";
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;

View File

@@ -0,0 +1,17 @@
-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Attachment" (
"id" TEXT NOT NULL PRIMARY KEY,
"username" TEXT,
"name" TEXT NOT NULL,
"mimetype" TEXT NOT NULL,
"size" INTEGER NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Attachment_username_fkey" FOREIGN KEY ("username") REFERENCES "User" ("username") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "new_Attachment" ("createdAt", "id", "mimetype", "name", "size") SELECT "createdAt", "id", "mimetype", "name", "size" FROM "Attachment";
DROP TABLE "Attachment";
ALTER TABLE "new_Attachment" RENAME TO "Attachment";
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;

Some files were not shown because too many files have changed in this diff Show More