diff --git a/web/src/services/nodes.ts b/web/src/services/nodes.ts index 018b16c..aa7f53b 100644 --- a/web/src/services/nodes.ts +++ b/web/src/services/nodes.ts @@ -1,5 +1,5 @@ import { http, type ApiEnvelope, unwrapApiEnvelope } from './http' -import type { NodeSummary, DirEntry } from '../types/nodes' +import type { NodeSummary, DirEntry, BatchCreateResult, InstallTokenInput, InstallTokenResult } from '../types/nodes' export async function listNodes() { const response = await http.get>('/nodes') @@ -30,3 +30,33 @@ export async function listNodeDirectory(nodeId: number, path: string) { const response = await http.get>(`/nodes/${nodeId}/fs/list`, { params: { path } }) return unwrapApiEnvelope(response.data) } + +export async function batchCreateNodes(names: string[]) { + const response = await http.post>('/nodes/batch', { names }) + return unwrapApiEnvelope(response.data) +} + +export async function createInstallToken(nodeId: number, input: InstallTokenInput) { + const response = await http.post>( + `/nodes/${nodeId}/install-tokens`, input, + ) + return unwrapApiEnvelope(response.data) +} + +export async function rotateNodeToken(nodeId: number) { + const response = await http.post>( + `/nodes/${nodeId}/rotate-token`, + ) + return unwrapApiEnvelope(response.data) +} + +export async function fetchScriptPreview( + nodeId: number, + params: { mode: string; arch: string; agentVersion: string; downloadSrc: string }, +) { + const response = await http.get(`/nodes/${nodeId}/install-script-preview`, { + params, + responseType: 'text', + }) + return response.data +} diff --git a/web/src/types/nodes.ts b/web/src/types/nodes.ts index c894b4c..3a51138 100644 --- a/web/src/types/nodes.ts +++ b/web/src/types/nodes.ts @@ -18,3 +18,27 @@ export interface DirEntry { isDir: boolean size: number } + +export type InstallMode = 'systemd' | 'docker' | 'foreground' +export type InstallArch = 'amd64' | 'arm64' | 'auto' +export type InstallSource = 'github' | 'ghproxy' + +export interface BatchCreateResult { + id: number + name: string +} + +export interface InstallTokenInput { + mode: InstallMode + arch: InstallArch + agentVersion: string + downloadSrc: InstallSource + ttlSeconds: number +} + +export interface InstallTokenResult { + installToken: string + expiresAt: string + url: string + composeUrl: string +}