Files
DataStack/prisma/schema.prisma
T
Team Dark Devil 177ed4a844 refactor(auth): standardize session management and security
- Centralize secret retrieval using `getAdminSessionSecret`
- Replace manual session parsing with `verifyRequestAdminSession` utility
- Tighten API validation and improve security headers handling
- Enforce environment variable security for production deployments
2026-11-18 05:18:55 +06:00

75 lines
2.8 KiB
Plaintext

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
// CRITICAL: PostgreSQL is ONLY for Admin / Config / SDK Registration — NOT for collected data.
// All collected data is strictly written to CSV files in /storage/data/{clientId}/{YYYY-MM-DD}.csv
model ClientSDK {
clientId String @id @map("client_id")
name String
secret String
token String
rateLimit Int @default(100) @map("rate_limit") // Max events per second
status String @default("active") // active | revoked
totalEvents BigInt @default(0) @map("total_events")
lastActive DateTime? @map("last_active") @db.Timestamptz(6)
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
@@map("client_sdks")
}
model DeletedClient {
clientId String @id @map("client_id")
deletedAt DateTime @default(now()) @map("deleted_at") @db.Timestamptz(6)
@@map("deleted_clients")
}
model AdminUser {
id Int @id @default(1) @db.SmallInt
email String @unique
passwordSalt Bytes @map("password_salt")
passwordHash Bytes @map("password_hash")
tokenVersion Int @default(1) @map("token_version")
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
@@map("admin_users")
}
model AdminLoginAttempt {
keyHash String @id @map("key_hash")
windowStartedAt DateTime @map("window_started_at") @db.Timestamptz(6)
failedAttempts Int @map("failed_attempts")
blockedUntil DateTime? @map("blocked_until") @db.Timestamptz(6)
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
@@map("admin_login_attempts")
}
model AdminSettings {
id String @id @default("default")
serverPort Int @default(4000) @map("server_port")
webPort Int @default(3000) @map("web_port")
maxEventsPerSec Int @default(100) @map("max_events_per_sec")
maxPayloadSizeKb Int @default(100) @map("max_payload_size_kb")
batchFlushThreshold Int @default(500) @map("batch_flush_threshold")
batchFlushIntervalMs Int @default(2000) @map("batch_flush_interval_ms")
fileRotationMb Int @default(100) @map("file_rotation_mb")
jwtSecret String @map("jwt_secret")
enableIdempotency Boolean @default(true) @map("enable_idempotency")
autoPruneDays Int @default(30) @map("auto_prune_days")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6)
@@map("admin_settings")
}