From 50b0164c9b0753abb50ab6cbd180c6c33b6abf47 Mon Sep 17 00:00:00 2001 From: Kevin Puig <119972216+k-puig@users.noreply.github.com> Date: Sat, 27 Sep 2025 02:44:50 -0400 Subject: [PATCH] First schema iteration --- concord-server/package-lock.json | 390 +++++++++++++++++++++++++++++++ concord-server/package.json | 3 +- concord-server/schema.prisma | 113 +++++++++ 3 files changed, 505 insertions(+), 1 deletion(-) create mode 100644 concord-server/package-lock.json create mode 100644 concord-server/schema.prisma diff --git a/concord-server/package-lock.json b/concord-server/package-lock.json new file mode 100644 index 0000000..cef0762 --- /dev/null +++ b/concord-server/package-lock.json @@ -0,0 +1,390 @@ +{ + "name": "concord-server", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "concord-server", + "dependencies": { + "@prisma/client": "^6.16.2", + "hono": "^4.9.9", + "prisma": "^6.16.2" + }, + "devDependencies": { + "@types/bun": "latest" + } + }, + "node_modules/@prisma/client": { + "version": "6.16.2", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-6.16.2.tgz", + "integrity": "sha512-E00PxBcalMfYO/TWnXobBVUai6eW/g5OsifWQsQDzJYm7yaY+IRLo7ZLsaefi0QkTpxfuhFcQ/w180i6kX3iJw==", + "hasInstallScript": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "peerDependencies": { + "prisma": "*", + "typescript": ">=5.1.0" + }, + "peerDependenciesMeta": { + "prisma": { + "optional": true + }, + "typescript": { + "optional": true + } + } + }, + "node_modules/@prisma/config": { + "version": "6.16.2", + "license": "Apache-2.0", + "dependencies": { + "c12": "3.1.0", + "deepmerge-ts": "7.1.5", + "effect": "3.16.12", + "empathic": "2.0.0" + } + }, + "node_modules/@prisma/debug": { + "version": "6.16.2", + "license": "Apache-2.0" + }, + "node_modules/@prisma/engines": { + "version": "6.16.2", + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "@prisma/debug": "6.16.2", + "@prisma/engines-version": "6.16.0-7.1c57fdcd7e44b29b9313256c76699e91c3ac3c43", + "@prisma/fetch-engine": "6.16.2", + "@prisma/get-platform": "6.16.2" + } + }, + "node_modules/@prisma/engines-version": { + "version": "6.16.0-7.1c57fdcd7e44b29b9313256c76699e91c3ac3c43", + "license": "Apache-2.0" + }, + "node_modules/@prisma/fetch-engine": { + "version": "6.16.2", + "license": "Apache-2.0", + "dependencies": { + "@prisma/debug": "6.16.2", + "@prisma/engines-version": "6.16.0-7.1c57fdcd7e44b29b9313256c76699e91c3ac3c43", + "@prisma/get-platform": "6.16.2" + } + }, + "node_modules/@prisma/get-platform": { + "version": "6.16.2", + "license": "Apache-2.0", + "dependencies": { + "@prisma/debug": "6.16.2" + } + }, + "node_modules/@standard-schema/spec": { + "version": "1.0.0", + "license": "MIT" + }, + "node_modules/@types/bun": { + "version": "1.2.22", + "resolved": "https://registry.npmjs.org/@types/bun/-/bun-1.2.22.tgz", + "integrity": "sha512-5A/KrKos2ZcN0c6ljRSOa1fYIyCKhZfIVYeuyb4snnvomnpFqC0tTsEkdqNxbAgExV384OETQ//WAjl3XbYqQA==", + "dev": true, + "license": "MIT", + "dependencies": { + "bun-types": "1.2.22" + } + }, + "node_modules/@types/node": { + "version": "24.5.2", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~7.12.0" + } + }, + "node_modules/@types/react": { + "version": "19.1.14", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "csstype": "^3.0.2" + } + }, + "node_modules/bun-types": { + "version": "1.2.22", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + }, + "peerDependencies": { + "@types/react": "^19" + } + }, + "node_modules/c12": { + "version": "3.1.0", + "license": "MIT", + "dependencies": { + "chokidar": "^4.0.3", + "confbox": "^0.2.2", + "defu": "^6.1.4", + "dotenv": "^16.6.1", + "exsolve": "^1.0.7", + "giget": "^2.0.0", + "jiti": "^2.4.2", + "ohash": "^2.0.11", + "pathe": "^2.0.3", + "perfect-debounce": "^1.0.0", + "pkg-types": "^2.2.0", + "rc9": "^2.1.2" + }, + "peerDependencies": { + "magicast": "^0.3.5" + }, + "peerDependenciesMeta": { + "magicast": { + "optional": true + } + } + }, + "node_modules/chokidar": { + "version": "4.0.3", + "license": "MIT", + "dependencies": { + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/citty": { + "version": "0.1.6", + "license": "MIT", + "dependencies": { + "consola": "^3.2.3" + } + }, + "node_modules/confbox": { + "version": "0.2.2", + "license": "MIT" + }, + "node_modules/consola": { + "version": "3.4.2", + "license": "MIT", + "engines": { + "node": "^14.18.0 || >=16.10.0" + } + }, + "node_modules/csstype": { + "version": "3.1.3", + "dev": true, + "license": "MIT" + }, + "node_modules/deepmerge-ts": { + "version": "7.1.5", + "license": "BSD-3-Clause", + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/defu": { + "version": "6.1.4", + "license": "MIT" + }, + "node_modules/destr": { + "version": "2.0.5", + "license": "MIT" + }, + "node_modules/dotenv": { + "version": "16.6.1", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/effect": { + "version": "3.16.12", + "license": "MIT", + "dependencies": { + "@standard-schema/spec": "^1.0.0", + "fast-check": "^3.23.1" + } + }, + "node_modules/empathic": { + "version": "2.0.0", + "license": "MIT", + "engines": { + "node": ">=14" + } + }, + "node_modules/exsolve": { + "version": "1.0.7", + "license": "MIT" + }, + "node_modules/fast-check": { + "version": "3.23.2", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/dubzzz" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fast-check" + } + ], + "license": "MIT", + "dependencies": { + "pure-rand": "^6.1.0" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/giget": { + "version": "2.0.0", + "license": "MIT", + "dependencies": { + "citty": "^0.1.6", + "consola": "^3.4.0", + "defu": "^6.1.4", + "node-fetch-native": "^1.6.6", + "nypm": "^0.6.0", + "pathe": "^2.0.3" + }, + "bin": { + "giget": "dist/cli.mjs" + } + }, + "node_modules/hono": { + "version": "4.9.9", + "license": "MIT", + "engines": { + "node": ">=16.9.0" + } + }, + "node_modules/jiti": { + "version": "2.6.0", + "license": "MIT", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, + "node_modules/node-fetch-native": { + "version": "1.6.7", + "license": "MIT" + }, + "node_modules/nypm": { + "version": "0.6.2", + "license": "MIT", + "dependencies": { + "citty": "^0.1.6", + "consola": "^3.4.2", + "pathe": "^2.0.3", + "pkg-types": "^2.3.0", + "tinyexec": "^1.0.1" + }, + "bin": { + "nypm": "dist/cli.mjs" + }, + "engines": { + "node": "^14.16.0 || >=16.10.0" + } + }, + "node_modules/ohash": { + "version": "2.0.11", + "license": "MIT" + }, + "node_modules/pathe": { + "version": "2.0.3", + "license": "MIT" + }, + "node_modules/perfect-debounce": { + "version": "1.0.0", + "license": "MIT" + }, + "node_modules/pkg-types": { + "version": "2.3.0", + "license": "MIT", + "dependencies": { + "confbox": "^0.2.2", + "exsolve": "^1.0.7", + "pathe": "^2.0.3" + } + }, + "node_modules/prisma": { + "version": "6.16.2", + "hasInstallScript": true, + "license": "Apache-2.0", + "peer": true, + "dependencies": { + "@prisma/config": "6.16.2", + "@prisma/engines": "6.16.2" + }, + "bin": { + "prisma": "build/index.js" + }, + "engines": { + "node": ">=18.18" + }, + "peerDependencies": { + "typescript": ">=5.1.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/pure-rand": { + "version": "6.1.0", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/dubzzz" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fast-check" + } + ], + "license": "MIT" + }, + "node_modules/rc9": { + "version": "2.1.2", + "license": "MIT", + "dependencies": { + "defu": "^6.1.4", + "destr": "^2.0.3" + } + }, + "node_modules/readdirp": { + "version": "4.1.2", + "license": "MIT", + "engines": { + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/tinyexec": { + "version": "1.0.1", + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "7.12.0", + "dev": true, + "license": "MIT" + } + } +} diff --git a/concord-server/package.json b/concord-server/package.json index 77eee4a..42fc858 100644 --- a/concord-server/package.json +++ b/concord-server/package.json @@ -4,10 +4,11 @@ "dev": "bun run --hot src/index.ts" }, "dependencies": { + "@prisma/client": "^6.16.2", "hono": "^4.9.9", "prisma": "^6.16.2" }, "devDependencies": { "@types/bun": "latest" } -} \ No newline at end of file +} diff --git a/concord-server/schema.prisma b/concord-server/schema.prisma new file mode 100644 index 0000000..dc00572 --- /dev/null +++ b/concord-server/schema.prisma @@ -0,0 +1,113 @@ +generator client { + provider = "prisma-client-js" +} + +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} + +model Hello { + id String @id @default(uuid(7)) + names Thing[] +} + +model Thing { + id BigInt @id @default(autoincrement()) + txt String + Hello Hello? @relation(fields: [helloId], references: [id]) + helloId String? +} + +model Instance { + id String @id @default(uuid(7)) + name String + icon String? + Role Role[] + Category Category[] +} + +model User { + id String @id @default(uuid(7)) + username String + nickname String? + bio String? + picture String? + banner String? + admin Boolean + status String // online/offline/dnd/idle/invis + Role Role[] + UserAuth UserAuth? + Message Message[] + MessagePing MessagePing[] +} + +model Role { + User User @relation(fields: [userId], references: [id]) + userId String + Instance Instance @relation(fields: [instanceId], references: [id]) + instanceId String + + @@unique([userId, instanceId]) +} + +model UserAuth { + User User @relation(fields: [userId], references: [id]) + userId String + password String // HASHED PASSWORD AS STRING USING SHA-256 + token String? // current user token + + @@unique([userId]) +} + +model Category { + id String @id @default(uuid(7)) + Instance Instance? @relation(fields: [instanceId], references: [id]) + instanceId String? + name String + position Int + Channel Channel[] + Message Message[] +} + +model Channel { + id String @id @default(uuid(7)) + type String + Category Category? @relation(fields: [categoryId], references: [id]) + categoryId String? + name String + description String + Message Message[] +} + +model Message { + id String @id @default(uuid(7)) + Channel Channel? @relation(fields: [channelId], references: [id]) + channelId String? + Category Category? @relation(fields: [categoryId], references: [id]) + categoryId String? + User User? @relation(fields: [userId], references: [id]) + userId String? + text String + replies Reply[] @relation("MessageToReply") + repliedTo Reply[] @relation("ReplyToMessage") + MessagePing MessagePing[] +} + +model Reply { + message Message @relation("MessageToReply", fields: [messageId], references: [id]) + messageId String + repliesTo Message @relation("ReplyToMessage", fields: [repliesToId], references: [id]) + repliesToId String + + @@unique([messageId, repliesToId]) +} + +model MessagePing { + Message Message @relation(fields: [messageId], references: [id]) + messageId String + PingsUser User @relation(fields: [pingsUserId], references: [id]) + pingsUserId String + + @@unique([messageId, pingsUserId]) +}