Merge pull request #762 from Cooldude2606/feature/remote-update

Add core package updates + plugin listing, updating, and remote install
This commit is contained in:
Daniel authored and GitHub committed 2025-05-17 23:26:19 +02:00
commit 78d4217a2a
22 files changed
+1155 -2

No files matched your search

+1
View File
@@ -21,4 +21,5 @@ export * from "./messages_host";
export * from "./messages_instance";
export * from "./messages_mod";
export * from "./messages_user";
export * from "./messages_plugin";
export * from "./version";
@@ -19,6 +19,14 @@ export class ControllerRestartRequest {
static permission = "core.controller.restart" as const;
}
export class ControllerUpdateRequest {
declare ["constructor"]: typeof ControllerUpdateRequest;
static type = "request" as const;
static src = "control" as const;
static dst = "controller" as const;
static permission = "core.controller.update" as const;
}
export class ControllerConfigGetRequest {
declare ["constructor"]: typeof ControllerConfigGetRequest;
static type = "request" as const;
+8
View File
@@ -19,6 +19,14 @@ export class HostRestartRequest {
static permission = "core.host.restart" as const;
}
export class HostUpdateRequest {
declare ["constructor"]: typeof HostUpdateRequest;
static type = "request" as const;
static src = ["control", "controller"] as const;
static dst = "host" as const;
static permission = "core.host.update" as const;
}
export class HostConfigGetRequest {
declare ["constructor"]: typeof HostConfigGetRequest;
static type = "request" as const;
+93
View File
@@ -0,0 +1,93 @@
import { Type, Static } from "@sinclair/typebox";
import { jsonArray } from "./composites";
import { PluginNodeEnvInfo } from "../plugin";
/* This is similar to other plugin definitions but with lots removed */
export class PluginDetails {
constructor(
public name: string,
public title: string,
public version: string,
public loaded: boolean,
public enabled: boolean,
public description?: string,
public npmPackage?: string,
) {}
static jsonSchema = Type.Object({
name: Type.String(),
title: Type.String(),
version: Type.String(),
loaded: Type.Boolean(),
enabled: Type.Boolean(),
description: Type.Optional(Type.String()),
npmPackage: Type.Optional(Type.String()),
});
static fromJSON(json: Static<typeof this.jsonSchema>) {
return new this(
json.name, json.title, json.version, json.loaded, json.enabled,
json.description, json.npmPackage
);
}
static fromNodeEnvInfo(pluginInfo: PluginNodeEnvInfo, loaded: boolean, enabled: boolean) {
return new this(
pluginInfo.name, pluginInfo.title, pluginInfo.version, loaded, enabled,
pluginInfo.description, pluginInfo.npmPackage,
);
}
}
export class PluginListRequest {
declare ["constructor"]: typeof PluginListRequest;
static type = "request" as const;
static src = "control" as const;
static dst = ["controller", "host"] as const;
static permission = "core.plugin.list";
static Response = jsonArray(PluginDetails);
}
export class PluginUpdateRequest {
declare ["constructor"]: typeof PluginUpdateRequest;
static type = "request" as const;
static src = "control" as const;
static dst = ["controller", "host"] as const;
static permission = "core.plugin.update";
constructor(
public pluginPackage: string,
) {}
static jsonSchema = Type.String();
static fromJSON(json: Static<typeof this.jsonSchema>) {
return new this(json);
}
toJSON() {
return this.pluginPackage;
}
}
export class PluginInstallRequest {
declare ["constructor"]: typeof PluginInstallRequest;
static type = "request" as const;
static src = "control" as const;
static dst = ["controller", "host"] as const;
static permission = "core.plugin.install";
constructor(
public pluginPackage: string,
) {}
static jsonSchema = Type.String();
static fromJSON(json: Static<typeof this.jsonSchema>) {
return new this(json);
}
toJSON() {
return this.pluginPackage;
}
}