mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 08:53:13 +00:00
feat(plugins): plugin system scaffold — registry tables + admin panel
First slice of the plugin system. Lays down the data model and a read-only admin surface; nothing executes yet. - Migration 155: plugins, plugin_meta_migrations, plugin_error_log and plugin_settings_fields tables. Plugin data will live in a per-plugin sqlite file under /plugins-data, never in these tables. - New Nest module server/src/nest/plugins with GET /api/admin/plugins (admin-gated, returns the installed list + the runtime-enabled flag). - TREK_PLUGINS_ENABLED kill switch (config.pluginsEnabled), off by default. - Admin → Plugins tab with a read-only panel: installed list, status badges, and a clear banner when the runtime is disabled by server config. - i18n keys for the tab and panel across all locales. Install, activation, the isolated runtime and the registry browser follow in later slices.
This commit is contained in:
@@ -3289,6 +3289,69 @@ function runMigrations(db: Database.Database): void {
|
||||
() => {
|
||||
try { db.exec('ALTER TABLE invite_tokens ADD COLUMN trip_id INTEGER REFERENCES trips(id) ON DELETE SET NULL'); } catch (err) { console.warn('[migrations] Non-fatal migration step failed:', err); }
|
||||
},
|
||||
// Migration 155: plugin system scaffold (#plugins). A plugin is a row here;
|
||||
// its code lives on the /plugins volume and (once the runtime lands) runs in
|
||||
// an isolated child process. This migration only lays down the registry
|
||||
// tables — nothing executes yet. Own data lives in a per-plugin sqlite file
|
||||
// under /plugins-data, never in these tables.
|
||||
() => {
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS plugins (
|
||||
id TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
type TEXT NOT NULL DEFAULT 'integration',
|
||||
icon TEXT DEFAULT 'Blocks',
|
||||
version TEXT,
|
||||
api_version INTEGER DEFAULT 1,
|
||||
min_trek_version TEXT,
|
||||
permissions TEXT DEFAULT '[]',
|
||||
granted_permissions TEXT DEFAULT '[]',
|
||||
status TEXT NOT NULL DEFAULT 'inactive',
|
||||
config TEXT DEFAULT '{}',
|
||||
source_repo TEXT,
|
||||
source_commit TEXT,
|
||||
sha256 TEXT,
|
||||
crash_count INTEGER NOT NULL DEFAULT 0,
|
||||
last_error TEXT,
|
||||
reviewed_at TEXT,
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
installed_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS plugin_meta_migrations (
|
||||
plugin_id TEXT NOT NULL,
|
||||
migration_id TEXT NOT NULL,
|
||||
applied_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (plugin_id, migration_id)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS plugin_error_log (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
plugin_id TEXT NOT NULL,
|
||||
ts DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
level TEXT NOT NULL DEFAULT 'error',
|
||||
message TEXT,
|
||||
stack TEXT
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_plugin_error_log_plugin ON plugin_error_log(plugin_id, ts);
|
||||
CREATE TABLE IF NOT EXISTS plugin_settings_fields (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
plugin_id TEXT NOT NULL,
|
||||
field_key TEXT NOT NULL,
|
||||
label TEXT,
|
||||
input_type TEXT NOT NULL DEFAULT 'text',
|
||||
placeholder TEXT,
|
||||
hint TEXT,
|
||||
required INTEGER NOT NULL DEFAULT 0,
|
||||
secret INTEGER NOT NULL DEFAULT 0,
|
||||
scope TEXT NOT NULL DEFAULT 'instance',
|
||||
options TEXT,
|
||||
oauth_config TEXT,
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
UNIQUE (plugin_id, field_key)
|
||||
);
|
||||
`);
|
||||
},
|
||||
];
|
||||
|
||||
if (currentVersion < migrations.length) {
|
||||
|
||||
Reference in New Issue
Block a user