mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 22:55:24 +00:00
feat: turn session recording into a plugin (B13)
This commit is contained in:
1 parent
a276f6898c
commit
0af2c94983
147 files changed
+25915
-2074
No files matched your search
@@ -74,6 +74,19 @@ export interface PluginKeyValue {
|
||||
list: () => Promise<string[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A folder on disk this plugin owns, for state too large for ctx.kv (session
|
||||
* recordings, uploaded files). Requires files:own.
|
||||
*/
|
||||
export interface PluginFiles {
|
||||
/**
|
||||
* The plugin's own folder under DATA_DIR, created if it does not exist yet.
|
||||
* Always the same path for this plugin; a plugin lays out its own
|
||||
* subdirectories underneath it.
|
||||
*/
|
||||
dataDir: () => Promise<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* The plugin's own tables.
|
||||
*
|
||||
@@ -1147,6 +1160,7 @@ export interface PluginContext {
|
||||
readonly log: PluginLogger;
|
||||
readonly events: PluginEvents;
|
||||
readonly kv: PluginKeyValue;
|
||||
readonly files: PluginFiles;
|
||||
readonly db: PluginDatabase;
|
||||
readonly sync: PluginSync;
|
||||
readonly registry: PluginRegistry;
|
||||
|
||||
@@ -60,6 +60,7 @@ export const CAPABILITY_CATALOG: readonly CapabilityInfo[] = [
|
||||
entry("hosts:read", "low"),
|
||||
entry("db:own", "low"),
|
||||
entry("kv:own", "low"),
|
||||
entry("files:own", "low"),
|
||||
entry("secrets:own", "low"),
|
||||
entry("settings:read-core", "low"),
|
||||
entry("ui:surface", "low"),
|
||||
|
||||
@@ -300,6 +300,12 @@ export function createFakeContext(
|
||||
list: async () => [...kv.keys()],
|
||||
},
|
||||
|
||||
files: {
|
||||
// A fake path; a test that needs a real folder uses the OS temp dir
|
||||
// itself, not this double.
|
||||
dataDir: async () => `/tmp/${pluginId}`,
|
||||
},
|
||||
|
||||
db: options.db
|
||||
? {
|
||||
...options.db,
|
||||
@@ -798,6 +804,13 @@ export function createMockCtx(
|
||||
},
|
||||
},
|
||||
|
||||
files: {
|
||||
dataDir: async () => {
|
||||
require("files:own");
|
||||
return ctx.files.dataDir();
|
||||
},
|
||||
},
|
||||
|
||||
events: {
|
||||
emit: (topic, payload) => {
|
||||
if (
|
||||
|
||||
Reference in new issue
Block a user