feat(mvp): phase 2 - database schema & services layer

Define full Prisma schema (10 models), run initial migration, build core
services (auth, user, group, app, board, permission), Zod validators,
type definitions, API response envelope, constants, and seed script.
This commit is contained in:
2026-03-24 20:00:21 +03:00
parent cf6bde238c
commit f1b1aa5975
28 changed files with 2936 additions and 28 deletions
+98
View File
@@ -0,0 +1,98 @@
// User roles
export const UserRole = {
ADMIN: 'admin',
USER: 'user'
} as const;
export type UserRole = (typeof UserRole)[keyof typeof UserRole];
// Authentication modes
export const AuthMode = {
LOCAL: 'local',
OAUTH: 'oauth',
BOTH: 'both'
} as const;
export type AuthMode = (typeof AuthMode)[keyof typeof AuthMode];
// Auth providers
export const AuthProvider = {
LOCAL: 'local',
OAUTH: 'oauth'
} as const;
export type AuthProvider = (typeof AuthProvider)[keyof typeof AuthProvider];
// App status values
export const AppStatusValue = {
ONLINE: 'online',
OFFLINE: 'offline',
DEGRADED: 'degraded',
UNKNOWN: 'unknown'
} as const;
export type AppStatusValue = (typeof AppStatusValue)[keyof typeof AppStatusValue];
// Widget types
export const WidgetType = {
APP: 'app',
BOOKMARK: 'bookmark',
NOTE: 'note',
EMBED: 'embed',
STATUS: 'status'
} as const;
export type WidgetType = (typeof WidgetType)[keyof typeof WidgetType];
// Icon types
export const IconType = {
LUCIDE: 'lucide',
SIMPLE: 'simple',
URL: 'url',
EMOJI: 'emoji'
} as const;
export type IconType = (typeof IconType)[keyof typeof IconType];
// Permission levels (ordered by privilege)
export const PermissionLevel = {
VIEW: 'view',
EDIT: 'edit',
ADMIN: 'admin'
} as const;
export type PermissionLevel = (typeof PermissionLevel)[keyof typeof PermissionLevel];
// Permission hierarchy for comparison
export const PERMISSION_HIERARCHY: Record<string, number> = {
[PermissionLevel.VIEW]: 1,
[PermissionLevel.EDIT]: 2,
[PermissionLevel.ADMIN]: 3
};
// Entity types for permissions
export const EntityType = {
BOARD: 'board',
APP: 'app'
} as const;
export type EntityType = (typeof EntityType)[keyof typeof EntityType];
// Target types for permissions
export const TargetType = {
USER: 'user',
GROUP: 'group'
} as const;
export type TargetType = (typeof TargetType)[keyof typeof TargetType];
// Healthcheck method
export const HealthcheckMethod = {
GET: 'GET',
HEAD: 'HEAD'
} as const;
export type HealthcheckMethod = (typeof HealthcheckMethod)[keyof typeof HealthcheckMethod];
// Defaults
export const DEFAULTS = {
HEALTHCHECK_INTERVAL: 300,
HEALTHCHECK_TIMEOUT: 5000,
HEALTHCHECK_EXPECTED_STATUS: 200,
HEALTHCHECK_METHOD: 'GET',
JWT_EXPIRY: '15m',
REFRESH_TOKEN_EXPIRY_DAYS: 7,
DEFAULT_THEME: 'dark',
DEFAULT_PRIMARY_COLOR: '#6366f1',
SYSTEM_SETTINGS_ID: 'singleton'
} as const;