feat(mcp): подготовить сервер и доступ к приёмке

This commit is contained in:
Denozordec committed 2026-11-03 03:12:03 +07:00
commit bf3d50e1ff
3835 files changed
+537122

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
import { containersStateSchema, containerMutationAckSchema } from "@mmapp/contracts/containers"
import { requestJson } from "./http-client"
export async function readContainersState(baseUrl: string, options?: RequestInit) {
return containersStateSchema.parse(await requestJson<unknown>(baseUrl, "/api/containers/state", options))
}
export type ContainerAction = "start" | "stop" | "restart" | "remove"
export async function mutateContainer(baseUrl: string, serverId: string, rosId: string, action: ContainerAction, options?: RequestInit) {
if (!/^[1-9]\d*$/.test(serverId) || !Number.isSafeInteger(Number(serverId)) || !rosId.trim()) throw new Error("Неверный контекст контейнера")
return containerMutationAckSchema.parse(await requestJson<unknown>(baseUrl, `/api/servers/${encodeURIComponent(serverId)}/containers/${action}`, { ...options, method: "POST", body: JSON.stringify({ rosId }) }))
}