feat: type the plugin host record, move plugin strings out of core and add lint checks

This commit is contained in:
LukeGus committed 2026-09-29 13:08:39 -05:00
1 parent bba06f7ff6
commit b8bbcd2196
626 files changed
+23884 -4590

No files matched your search

+2 -4
View File
@@ -2,7 +2,7 @@ import { ConnectionScreen, FullScreenAppWrapper } from "@termix/plugin-sdk/ui";
import React from "react";
import { useTranslation } from "@termix/plugin-sdk/frontend";
import { DockerManager } from "./DockerManager.tsx";
import { toDockerHost } from "./types";
import { toDockerHost, type DockerHostSource } from "./types";
interface DockerAppProps {
hostId?: string;
@@ -37,9 +37,7 @@ const DockerApp: React.FC<DockerAppProps> = ({ hostId }) => {
return (
<DockerManager
host={toDockerHost(
hostConfig as unknown as Record<string, unknown>,
)}
host={toDockerHost(hostConfig as unknown as DockerHostSource)}
title={hostConfig.name || `${hostConfig.username}@${hostConfig.ip}`}
isVisible={true}
isTopbarOpen={false}
@@ -90,10 +90,7 @@ function DockerManagerInner({
// standalone window has no shell, so it keeps the host it was given.
const liveRecord = useHost(host?.id);
const currentHost = React.useMemo(
() =>
liveRecord
? toDockerHost(liveRecord as unknown as Record<string, unknown>)
: host,
() => (liveRecord ? toDockerHost(liveRecord) : host),
[liveRecord, host],
);
const enabled = dockerEnabled(currentHost);
+1 -1
View File
@@ -27,7 +27,7 @@ function DockerWidget({
);
}
const host = toDockerHost(record as unknown as Record<string, unknown>);
const host = toDockerHost(record);
return (
<div className="flex flex-col w-full h-full overflow-hidden">
<WidgetTitle title={widget.title} icon={<Box size={11} />} />
+2 -2
View File
@@ -9,10 +9,10 @@ import type {
import { DockerManager } from "./DockerManager";
import DockerApp from "./DockerApp";
import { dockerWidget } from "./DockerWidget";
import { dockerEnabled, toDockerHost } from "./types";
import { dockerEnabled, toDockerHost, type DockerHostSource } from "./types";
function DockerTab({ host, sshHost, label, isVisible }: TabProps) {
const record = (host ?? sshHost) as Record<string, unknown> | undefined;
const record = host ?? (sshHost as DockerHostSource | undefined);
return (
<DockerManager
host={record ? toDockerHost(record) : undefined}
+14 -2
View File
@@ -59,11 +59,23 @@ export interface DockerHost {
pluginSettings?: Record<string, Record<string, unknown> | undefined>;
}
/** The fields toDockerHost reads from a shell or API host. */
export type DockerHostSource = Omit<DockerHost, "id" | "name"> & {
id: string | number;
name?: string | null;
};
/** Any host record the shell or an API hands over, as a DockerHost. */
export function toDockerHost(record: Record<string, unknown>): DockerHost {
export function toDockerHost(record: DockerHostSource): DockerHost {
return {
...(record as unknown as DockerHost),
id: Number(record.id),
name: record.name ?? undefined,
ip: record.ip,
port: record.port,
username: record.username,
syncId: record.syncId ?? null,
connectionOrigin: record.connectionOrigin ?? null,
pluginSettings: record.pluginSettings,
};
}