mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 06:35:24 +00:00
feat: add plugin worker protocol, bootstrap and plugin_storage table
Worker-side ctx proxy plus the message envelope it talks over, and the per-plugin key/value table behind ctx.storage with migrations for all three dialects. Rows cascade with the plugin so uninstalling leaves nothing behind.
This commit is contained in:
1 parent
a1805cb7ae
commit
248698f62d
19 files changed
+30035
No files matched your search
@@ -728,6 +728,16 @@ async function initializeCompleteDatabase(): Promise<void> {
|
||||
UNIQUE (plugin_id, registry_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS plugin_storage (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
plugin_id TEXT NOT NULL,
|
||||
key TEXT NOT NULL,
|
||||
value TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
UNIQUE (plugin_id, key),
|
||||
FOREIGN KEY (plugin_id) REFERENCES plugins (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS api_keys (
|
||||
id TEXT PRIMARY KEY,
|
||||
user_id TEXT NOT NULL,
|
||||
|
||||
@@ -2279,4 +2279,27 @@ export const pluginInstallCounts = mysqlTable(
|
||||
],
|
||||
);
|
||||
|
||||
/**
|
||||
* Per-plugin key/value state, written through ctx.storage. Rows are always
|
||||
* scoped to the calling plugin by the broker, so a plugin cannot name another
|
||||
* plugin's scope. Cascades with the plugin so uninstalling leaves nothing.
|
||||
*/
|
||||
export const pluginStorage = mysqlTable(
|
||||
"plugin_storage",
|
||||
{
|
||||
id: int("id").autoincrement().primaryKey(),
|
||||
pluginId: varchar("plugin_id", { length: 255 })
|
||||
.notNull()
|
||||
.references(() => plugins.id, { onDelete: "cascade" }),
|
||||
key: varchar("key", { length: 255 }).notNull(),
|
||||
value: text("value").notNull(),
|
||||
updatedAt: varchar("updated_at", { length: 255 })
|
||||
.notNull()
|
||||
.default(sql`(CURRENT_TIMESTAMP)`),
|
||||
},
|
||||
(table) => [
|
||||
uniqueIndex("idx_plugin_storage_plugin_key").on(table.pluginId, table.key),
|
||||
],
|
||||
);
|
||||
|
||||
// --- plugins end ---
|
||||
@@ -2280,4 +2280,27 @@ export const pluginInstallCounts = pgTable(
|
||||
],
|
||||
);
|
||||
|
||||
/**
|
||||
* Per-plugin key/value state, written through ctx.storage. Rows are always
|
||||
* scoped to the calling plugin by the broker, so a plugin cannot name another
|
||||
* plugin's scope. Cascades with the plugin so uninstalling leaves nothing.
|
||||
*/
|
||||
export const pluginStorage = pgTable(
|
||||
"plugin_storage",
|
||||
{
|
||||
id: serial("id").primaryKey(),
|
||||
pluginId: varchar("plugin_id", { length: 255 })
|
||||
.notNull()
|
||||
.references(() => plugins.id, { onDelete: "cascade" }),
|
||||
key: varchar("key", { length: 255 }).notNull(),
|
||||
value: text("value").notNull(),
|
||||
updatedAt: varchar("updated_at", { length: 255 })
|
||||
.notNull()
|
||||
.default(sql`CURRENT_TIMESTAMP`),
|
||||
},
|
||||
(table) => [
|
||||
uniqueIndex("idx_plugin_storage_plugin_key").on(table.pluginId, table.key),
|
||||
],
|
||||
);
|
||||
|
||||
// --- plugins end ---
|
||||
@@ -2278,4 +2278,27 @@ export const pluginInstallCounts = sqliteTable(
|
||||
],
|
||||
);
|
||||
|
||||
/**
|
||||
* Per-plugin key/value state, written through ctx.storage. Rows are always
|
||||
* scoped to the calling plugin by the broker, so a plugin cannot name another
|
||||
* plugin's scope. Cascades with the plugin so uninstalling leaves nothing.
|
||||
*/
|
||||
export const pluginStorage = sqliteTable(
|
||||
"plugin_storage",
|
||||
{
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
pluginId: text("plugin_id")
|
||||
.notNull()
|
||||
.references(() => plugins.id, { onDelete: "cascade" }),
|
||||
key: text("key").notNull(),
|
||||
value: text("value").notNull(),
|
||||
updatedAt: text("updated_at")
|
||||
.notNull()
|
||||
.default(sql`CURRENT_TIMESTAMP`),
|
||||
},
|
||||
(table) => [
|
||||
uniqueIndex("idx_plugin_storage_plugin_key").on(table.pluginId, table.key),
|
||||
],
|
||||
);
|
||||
|
||||
// --- plugins end ---
|
||||
Reference in new issue
Block a user