Files
remotelink-docker/lib/db/schema.ts
monoadmin 61edbf59bf Add ScreenConnect-parity features (high + medium)
Viewer:
- Toolbar: Ctrl+Alt+Del, clipboard paste, monitor picker, file transfer, chat, WoL buttons
- Multi-monitor: agent sends monitor_list on connect, viewer can switch via dropdown
- Clipboard sync: agent polls local clipboard → sends to viewer; viewer paste → agent sets remote clipboard
- File transfer panel: drag-drop upload to agent, directory browser, download files from remote
- Chat panel: bidirectional text chat forwarded through relay

Agent:
- Multi-monitor capture with set_monitor/set_quality message handlers
- exec_key_combo for Ctrl+Alt+Del and arbitrary combos
- Clipboard polling via pyperclip (both directions)
- File upload/download/list_files with base64 chunked protocol
- Attended mode (--attended): zenity/kdialog/PowerShell consent dialog before accepting stream
- Auto-update: heartbeat checks version, downloads new binary and exec-replaces self (Linux)
- Reports MAC address on registration (for WoL)

Relay:
- Forwards monitor_list, clipboard_content, file_chunk, file_list, chat_message agent→viewer
- Session recording: when RECORDING_DIR env set, saves JPEG frames as .remrec files
- ALLOWED_ORIGINS CORS now set from NEXT_PUBLIC_APP_URL in docker-compose

Database:
- groups table (id, name, description, created_by)
- machines: group_id, mac_address, notes, tags text[]
- Migration 0003 applied

Dashboard:
- Machines page: search, tag filter, group filter, inline notes/tags/rename editing
- MachineCard: inline tag management, group picker, notes textarea
- Admin page: new Groups tab (create/list/delete groups)
- API: PATCH /api/machines/[id] (name, notes, tags, groupId)
- API: GET/POST/DELETE /api/groups
- API: POST /api/machines/wol (broadcast magic packet)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-10 23:57:47 -07:00

110 lines
4.7 KiB
TypeScript

import {
pgTable,
uuid,
text,
boolean,
timestamp,
integer,
} from 'drizzle-orm/pg-core'
import { sql } from 'drizzle-orm'
// Re-export for convenience
export { sql }
export const users = pgTable('users', {
id: uuid('id').primaryKey().default(sql`gen_random_uuid()`),
email: text('email').unique().notNull(),
passwordHash: text('password_hash').notNull(),
fullName: text('full_name'),
company: text('company'),
role: text('role').default('user').notNull(),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
})
export const groups = pgTable('groups', {
id: uuid('id').primaryKey().default(sql`gen_random_uuid()`),
name: text('name').notNull(),
description: text('description'),
createdBy: uuid('created_by').references(() => users.id, { onDelete: 'set null' }),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
})
export const machines = pgTable('machines', {
id: uuid('id').primaryKey().default(sql`gen_random_uuid()`),
userId: uuid('user_id').references(() => users.id, { onDelete: 'cascade' }).notNull(),
groupId: uuid('group_id').references(() => groups.id, { onDelete: 'set null' }),
name: text('name').notNull(),
hostname: text('hostname'),
os: text('os'),
osVersion: text('os_version'),
agentVersion: text('agent_version'),
ipAddress: text('ip_address'),
macAddress: text('mac_address'),
accessKey: text('access_key').unique().notNull(),
isOnline: boolean('is_online').default(false).notNull(),
lastSeen: timestamp('last_seen', { withTimezone: true }),
notes: text('notes'),
tags: text('tags').array().default(sql`'{}'::text[]`),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
})
export const sessionCodes = pgTable('session_codes', {
id: uuid('id').primaryKey().default(sql`gen_random_uuid()`),
code: text('code').notNull(),
machineId: uuid('machine_id').references(() => machines.id, { onDelete: 'cascade' }).notNull(),
createdBy: uuid('created_by').references(() => users.id, { onDelete: 'set null' }),
expiresAt: timestamp('expires_at', { withTimezone: true }).notNull(),
isActive: boolean('is_active').default(true).notNull(),
usedAt: timestamp('used_at', { withTimezone: true }),
usedBy: uuid('used_by').references(() => users.id, { onDelete: 'set null' }),
})
export const sessions = pgTable('sessions', {
id: uuid('id').primaryKey().default(sql`gen_random_uuid()`),
machineId: uuid('machine_id').references(() => machines.id, { onDelete: 'set null' }),
machineName: text('machine_name'),
viewerUserId: uuid('viewer_user_id').references(() => users.id, { onDelete: 'set null' }),
connectionType: text('connection_type'),
sessionCode: text('session_code'),
viewerToken: uuid('viewer_token').default(sql`gen_random_uuid()`),
startedAt: timestamp('started_at', { withTimezone: true }).defaultNow().notNull(),
endedAt: timestamp('ended_at', { withTimezone: true }),
durationSeconds: integer('duration_seconds'),
notes: text('notes'),
})
export const enrollmentTokens = pgTable('enrollment_tokens', {
id: uuid('id').primaryKey().default(sql`gen_random_uuid()`),
token: uuid('token').unique().notNull().default(sql`gen_random_uuid()`),
label: text('label'),
createdBy: uuid('created_by').references(() => users.id, { onDelete: 'set null' }),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
expiresAt: timestamp('expires_at', { withTimezone: true }),
usedCount: integer('used_count').default(0).notNull(),
maxUses: integer('max_uses'),
revokedAt: timestamp('revoked_at', { withTimezone: true }),
})
export const invites = pgTable('invites', {
id: uuid('id').primaryKey().default(sql`gen_random_uuid()`),
token: uuid('token').unique().notNull().default(sql`gen_random_uuid()`),
email: text('email').notNull(),
createdBy: uuid('created_by').references(() => users.id, { onDelete: 'set null' }),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
expiresAt: timestamp('expires_at', { withTimezone: true })
.notNull()
.default(sql`now() + interval '7 days'`),
usedAt: timestamp('used_at', { withTimezone: true }),
usedBy: uuid('used_by').references(() => users.id, { onDelete: 'set null' }),
})
export type User = typeof users.$inferSelect
export type Group = typeof groups.$inferSelect
export type Machine = typeof machines.$inferSelect
export type SessionCode = typeof sessionCodes.$inferSelect
export type Session = typeof sessions.$inferSelect
export type Invite = typeof invites.$inferSelect
export type EnrollmentToken = typeof enrollmentTokens.$inferSelect