import type { ConfigUpdateResponse } from "modules/server/SystemController"; import { ModuleApi } from "./ModuleApi"; import type { ModuleConfigs, ModuleKey, ModuleSchemas } from "./ModuleManager"; export type ApiSchemaResponse = { version: number; schema: ModuleSchemas; config: ModuleConfigs; permissions: string[]; }; export class SystemApi extends ModuleApi { protected override getDefaultOptions(): Partial { return { basepath: "/api/system" }; } readSchema(options?: { config?: boolean; secrets?: boolean }) { return this.get("schema", { config: options?.config ? 1 : 0, secrets: options?.secrets ? 1 : 0 }); } setConfig( module: Module, value: ModuleConfigs[Module], force?: boolean ) { return this.post( ["config", "set", module].join("/") + `?force=${force ? 1 : 0}`, value ); } addConfig(module: Module, path: string, value: any) { return this.post(["config", "add", module, path], value); } patchConfig(module: Module, path: string, value: any) { return this.patch(["config", "patch", module, path], value); } overwriteConfig(module: Module, path: string, value: any) { return this.put(["config", "overwrite", module, path], value); } removeConfig(module: Module, path: string) { return this.delete(["config", "remove", module, path]); } }