refactor(plugins): install-time gates, the capability-audit hash chain and the registry through repositories

This commit is contained in:
jubnl
2026-09-24 03:24:23 +02:00
parent f29216c5af
commit d522882590
30 changed files with 834 additions and 313 deletions
+3 -7
View File
@@ -1,4 +1,4 @@
import type BetterSqlite3 from 'better-sqlite3';
import type { PluginSettingsFieldsRepository } from '../../db/repositories/PluginSettingsFields.repository';
/** What a settings-field `default` may be — the JSON scalars the manifest accepts. */
export type SettingDefault = string | number | boolean;
@@ -32,15 +32,11 @@ export function parseDefaultValue(raw: unknown): SettingDefault | undefined {
/** The declared defaults for one plugin and scope, keyed by field. Null-prototype so a
* field key can never resolve off Object.prototype (see plugin-config-parse.ts). */
export async function settingDefaults(
db: BetterSqlite3.Database,
settingsFields: PluginSettingsFieldsRepository,
pluginId: string,
scope: 'instance' | 'user',
): Promise<Record<string, SettingDefault>> {
const rows = db
.prepare(
'SELECT field_key, default_value FROM plugin_settings_fields WHERE plugin_id = ? AND scope = ? AND secret = 0 AND default_value IS NOT NULL',
)
.all(pluginId, scope) as Array<{ field_key: string; default_value: string }>;
const rows = await settingsFields.listDefaults(pluginId, scope);
const out: Record<string, SettingDefault> = Object.create(null);
for (const r of rows) {
const v = parseDefaultValue(r.default_value);