New integration kinds adguard (status, statistics, filter lists and a real DNS question over UDP; alerts for DNS down/not running, protection left off, stale lists) and grafana (alert rules firing or failing, data-source health). Optional warning for running Docker images built more than N days ago (off by default). A server's overview cards can be folded and arranged, kept per user. Migrations 0075-0077; docs, metrics and tests included. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
3972 lines
151 KiB
TypeScript
3972 lines
151 KiB
TypeScript
export type UserRole = "admin" | "operator" | "viewer";
|
||
|
||
export interface CurrentUser {
|
||
id: number;
|
||
sub: string;
|
||
email?: string;
|
||
name?: string;
|
||
role: UserRole;
|
||
/** Where this person's picture is, on this app (the server fetches it); null when no picture source is switched on for them. */
|
||
avatarUrl?: string | null;
|
||
/** Pages this person pinned to the top of their menu, by path — a page alone, or with filters ("/servers?status=offline"). */
|
||
favorites?: string[];
|
||
/** How this person arranged the dashboard cards. */
|
||
dashboard?: DashboardLayout;
|
||
/** How this person arranged a server's overview page. */
|
||
serverPage?: PageLayout;
|
||
}
|
||
|
||
export type ShareLinkDetail = "summary" | "names";
|
||
|
||
export type ShareLinkKind = "wall" | "status" | "calendar";
|
||
export type StatusItemKind = "server" | "integration" | "monitor";
|
||
|
||
/** One thing on a status page, as the editor sees it. */
|
||
export interface StatusPageItem {
|
||
id: number;
|
||
label: string;
|
||
kind: StatusItemKind;
|
||
targetId: number;
|
||
monitorId: string | null;
|
||
/** What it points at (the server's, integration's or monitor's own name). */
|
||
targetName: string | null;
|
||
}
|
||
|
||
/** What somebody who opens a status page's address is given: names and states, nothing else. */
|
||
export interface PublicStatusItem {
|
||
id: number;
|
||
label: string;
|
||
state: "up" | "trouble" | "down" | "maintenance" | "unknown";
|
||
uptime30d: number | null;
|
||
}
|
||
export interface PublicStatus {
|
||
title: string;
|
||
message: string | null;
|
||
level: "ok" | "trouble" | "issue" | "maintenance" | "unknown";
|
||
counts: Record<PublicStatusItem["state"], number>;
|
||
items: PublicStatusItem[];
|
||
generatedAt: string;
|
||
display: { dateFormat: string; timeFormat: string };
|
||
}
|
||
|
||
/** A link that opens the wall display, or a status page, without signing in, as the settings list shows it (never the secret). */
|
||
export interface ShareLink {
|
||
id: number;
|
||
label: string;
|
||
tokenPrefix: string;
|
||
kind: ShareLinkKind;
|
||
/** A status page's own heading and message. */
|
||
title: string | null;
|
||
message: string | null;
|
||
/** How many things a status page shows. */
|
||
itemCount: number;
|
||
detail: ShareLinkDetail;
|
||
createdBy: string | null;
|
||
createdAt: string;
|
||
expiresAt: string | null;
|
||
lastUsedAt: string | null;
|
||
expired: boolean;
|
||
}
|
||
|
||
/** What a share link may show: numbers, and with "names" also the names of what is wrong. Built on the server. */
|
||
/** An extra tile on the wall display (Hetzner servers running, critical vulnerabilities …). */
|
||
export interface WallTile {
|
||
id: string;
|
||
label: string;
|
||
figure: string;
|
||
state: "ok" | "warn" | "bad" | "info";
|
||
}
|
||
|
||
/** A summary of one group of integrations (the menu's Infrastructure, Apps …) for the wall display: how many are connected, failing, and how many alerts they have. */
|
||
export interface WallGroup {
|
||
id: string;
|
||
label: string;
|
||
integrations: number;
|
||
failing: number;
|
||
alerts: { critical: number; warning: number };
|
||
}
|
||
|
||
export interface PublicWall {
|
||
detail: ShareLinkDetail;
|
||
level: "ok" | "warning" | "critical" | "unsure";
|
||
environment: string | null;
|
||
servers: { online: number; offline: number };
|
||
alerts: { critical: number; warning: number };
|
||
maintenance: number;
|
||
integrationsFailing: number;
|
||
tiles?: WallTile[];
|
||
groups?: WallGroup[];
|
||
problems?: { id: string; severity: "critical" | "warning"; message: string }[];
|
||
maintenanceWindows?: { id: number; name: string; endsAt: string }[];
|
||
integrations?: { id: number; name: string; type: string; status: "ok" | "failing" | "unknown" }[];
|
||
generatedAt: string;
|
||
display: { dateFormat: string; timeFormat: string };
|
||
}
|
||
|
||
/** How a person arranged a page of blocks: the ones they folded, and the order they put them in (a lower number comes first). */
|
||
export interface PageLayout {
|
||
folded: string[];
|
||
order: Record<string, number>;
|
||
}
|
||
|
||
/** The dashboard cards a person hid, and the order they put the rest in (a lower number comes first). */
|
||
export interface DashboardLayout {
|
||
hidden: string[];
|
||
order: Record<string, number>;
|
||
}
|
||
|
||
/** One thing worth a line in "Since you last looked". */
|
||
export interface ChangeEvent {
|
||
at: string;
|
||
tone: "good" | "bad" | "info" | "neutral";
|
||
kind: "server" | "integration" | "maintenance";
|
||
title: string;
|
||
detail: string | null;
|
||
link: string | null;
|
||
}
|
||
|
||
export interface ChangesSummary {
|
||
since: string;
|
||
/** True the first time: the summary then covers the last day. */
|
||
firstTime: boolean;
|
||
events: ChangeEvent[];
|
||
moreEvents: number;
|
||
/** Entries other people wrote in the audit log in that time; null if this person can't see the audit log. */
|
||
changesByOthers: number | null;
|
||
}
|
||
|
||
/** Minutes known / minutes down in one 24-hour stretch. */
|
||
export interface UptimeBucket {
|
||
k: number;
|
||
d: number;
|
||
}
|
||
|
||
export interface UptimeSeries {
|
||
buckets: UptimeBucket[];
|
||
percent: number;
|
||
}
|
||
|
||
export interface UptimeReport {
|
||
days: number;
|
||
endsAt: string;
|
||
servers: Record<number, UptimeSeries>;
|
||
integrations: Record<number, UptimeSeries>;
|
||
}
|
||
|
||
export interface UserRecord {
|
||
id: number;
|
||
oidcSub: string;
|
||
email: string | null;
|
||
name: string | null;
|
||
role: UserRole;
|
||
createdAt: string;
|
||
lastLoginAt: string | null;
|
||
/** The groups the identity provider reported at their last sign-in; null until they have signed in with groups available. */
|
||
groups: string[] | null;
|
||
avatarUrl: string | null;
|
||
}
|
||
|
||
/** Where profile pictures may come from. Both off until an administrator allows them. */
|
||
export interface ProfilePictureSettings {
|
||
gravatar: boolean;
|
||
identityProvider: boolean;
|
||
}
|
||
|
||
/** How roles are decided at sign-in: by hand on the Users page, or from the groups the identity provider reports. */
|
||
export interface SignInSettings {
|
||
roleFromGroups: boolean;
|
||
groupsClaim: string;
|
||
adminGroups: string[];
|
||
operatorGroups: string[];
|
||
otherwise: "viewer" | "keep";
|
||
}
|
||
|
||
/** What each person would be under a draft of the group rules. */
|
||
export interface GroupRolePreview {
|
||
people: { id: number; name: string; role: UserRole; groups: string[] | null; wouldBe: UserRole | null }[];
|
||
/** How many administrators there would be; 0 means the rules would lock everyone out of administration. */
|
||
adminsAfter: number;
|
||
}
|
||
|
||
export interface SessionSummary {
|
||
id: string;
|
||
sub: string;
|
||
email: string | null;
|
||
name: string | null;
|
||
role: UserRole | null;
|
||
ip: string | null;
|
||
userAgent: string | null;
|
||
lastAccess: string;
|
||
expiresAt: string | null;
|
||
}
|
||
|
||
export type MaintenanceTargetType = "server" | "integration" | "dns_provider" | "device";
|
||
|
||
/** A whole group at once: every server, every enabled integration, every enabled DNS provider, or all of those. */
|
||
export type MaintenanceBulkScope = "everything" | "servers" | "integrations" | "dns_providers" | "devices";
|
||
|
||
export interface MaintenanceWindow {
|
||
id: number;
|
||
targetType: MaintenanceTargetType;
|
||
targetId: number;
|
||
targetName: string;
|
||
targetKind: string;
|
||
reason: string | null;
|
||
startedAt: string;
|
||
endsAt: string;
|
||
createdBy: string | null;
|
||
/** Set on windows mirrored from Uptime Kuma's schedule ("kuma:<integration>:<maintenance>"); null for ones started by hand. */
|
||
source: string | null;
|
||
}
|
||
|
||
export interface MaintenanceAlias {
|
||
id: number;
|
||
/** A bare host: a name or an IP. */
|
||
address: string;
|
||
targetType: MaintenanceTargetType;
|
||
targetId: number;
|
||
targetName: string;
|
||
targetKind: string;
|
||
}
|
||
|
||
export interface MaintenanceTargets {
|
||
servers: { id: number; name: string }[];
|
||
integrations: { id: number; name: string; type: string }[];
|
||
dnsProviders: { id: number; name: string; providerType: string }[];
|
||
/** Network devices read from a UniFi controller. */
|
||
devices: { id: number; name: string; kind: string }[];
|
||
}
|
||
|
||
export interface AuditLogEntry {
|
||
id: number;
|
||
actorUserId: number | null;
|
||
actorLabel: string | null;
|
||
category: string;
|
||
action: string;
|
||
targetType: string | null;
|
||
targetId: string | null;
|
||
detail: string | null;
|
||
createdAt: string;
|
||
}
|
||
|
||
export interface DiagLogEntry {
|
||
id: number;
|
||
source: string;
|
||
operation: string;
|
||
ok: boolean;
|
||
latencyMs: number;
|
||
error: string | null;
|
||
createdAt: string;
|
||
}
|
||
|
||
export interface DiagLogResponse {
|
||
total: number;
|
||
entries: DiagLogEntry[];
|
||
}
|
||
|
||
export type SecretType = "api_token" | "ssl_certificate" | "password" | "generic";
|
||
export type SecretStatus = "ok" | "expiring" | "expired" | "never";
|
||
|
||
export interface SecretRecord {
|
||
id: number;
|
||
name: string;
|
||
type: SecretType;
|
||
description: string | null;
|
||
/** null = never expires. */
|
||
expiryDate: string | null;
|
||
warnDays: number;
|
||
notes: string | null;
|
||
createdAt: string;
|
||
updatedAt: string;
|
||
status: SecretStatus;
|
||
/** null when the secret never expires. */
|
||
daysLeft: number | null;
|
||
/** ssl_certificate only — when set, expiryDate is read from the live certificate here rather than typed in. */
|
||
checkHost: string | null;
|
||
checkPort: number | null;
|
||
lastCheckedAt: string | null;
|
||
lastCheckError: string | null;
|
||
}
|
||
|
||
export interface SecretInput {
|
||
name: string;
|
||
type: SecretType;
|
||
description?: string;
|
||
/** Omitted when a host to check is given — the date then comes from the live certificate. */
|
||
/** null = never expires. */
|
||
expiryDate?: string | null;
|
||
warnDays: number;
|
||
notes?: string;
|
||
checkHost?: string | null;
|
||
checkPort?: number | null;
|
||
}
|
||
|
||
export interface MapNode {
|
||
id: string;
|
||
kind: "host" | "server" | "dns" | "monitor" | "device";
|
||
label: string;
|
||
sub: string | null;
|
||
status: "ok" | "bad" | "warn" | "unknown";
|
||
href: string | null;
|
||
}
|
||
|
||
export interface MapData {
|
||
nodes: MapNode[];
|
||
edges: { from: string; to: string }[];
|
||
/** Things that couldn't be read, so the picture is incomplete. */
|
||
notes: string[];
|
||
}
|
||
|
||
export interface ServerActivityEvent {
|
||
/** ISO. */
|
||
at: string;
|
||
kind: "change" | "health" | "maintenance";
|
||
tone: "good" | "bad" | "neutral" | "info";
|
||
title: string;
|
||
detail: string | null;
|
||
/** Who did it; "system" for the app's own checks. */
|
||
actor: string | null;
|
||
}
|
||
|
||
/** What is normal for one hour of the week: the median of that hour's averages over past weeks, a robust spread, and how many weeks it stands on. */
|
||
export interface BaselineSlot {
|
||
dow: number;
|
||
hour: number;
|
||
median: number;
|
||
spread: number;
|
||
weeks: number;
|
||
}
|
||
|
||
/** What is normal for a server at each hour of the week (Sunday 00:00 first), in the notification time zone; null where there are not enough weeks yet. */
|
||
export interface BaselineView {
|
||
timezone: string;
|
||
now: { dow: number; hour: number };
|
||
slots: { cpu: (BaselineSlot | null)[]; mem: (BaselineSlot | null)[] };
|
||
}
|
||
|
||
export interface ServerMetricSeries {
|
||
metric: string;
|
||
kind: "cpu" | "mem" | "disk";
|
||
label: string;
|
||
/** `lo` and `hi` are there when a point stands for an hour or a day: the lowest and highest figure in it. */
|
||
points: { t: string; v: number; lo?: number; hi?: number }[];
|
||
latest: number | null;
|
||
/** Disks only: the rate of change in points a day, and the days until full when it is rising. */
|
||
trend: { perDay: number; fit: number; spanDays: number; daysToFull: number | null } | null;
|
||
}
|
||
|
||
export interface IpamEntry {
|
||
id: number;
|
||
ipAddress: string;
|
||
label: string | null;
|
||
vendor: string | null;
|
||
location: string | null;
|
||
notes: string | null;
|
||
source: string | null;
|
||
createdAt: string;
|
||
updatedAt: string;
|
||
matchingDnsRecords: string[];
|
||
/** Falls within one of the Consistency page's excluded ranges — e.g. Docker's bridge network, repeated on every host. */
|
||
excluded: boolean;
|
||
}
|
||
|
||
export interface IpamSyncResult {
|
||
added: number;
|
||
updated: number;
|
||
skipped: number;
|
||
skippedIps: string[];
|
||
errors: string[];
|
||
}
|
||
|
||
export interface IpamInput {
|
||
ipAddress: string;
|
||
label?: string;
|
||
vendor?: string;
|
||
location?: string;
|
||
notes?: string;
|
||
}
|
||
|
||
export interface AgentPortRow {
|
||
serverId: number;
|
||
serverName: string;
|
||
serverHostname: string | null;
|
||
protocol: "tcp" | "udp";
|
||
port: number;
|
||
addresses: string[];
|
||
process: string | null;
|
||
localOnly: boolean;
|
||
lastSeenAt: string | null;
|
||
}
|
||
|
||
export interface AgentPortsResponse {
|
||
ports: AgentPortRow[];
|
||
reportingServers: number;
|
||
totalServers: number;
|
||
}
|
||
|
||
export interface PortForward {
|
||
id: number;
|
||
label: string;
|
||
externalPort: number;
|
||
protocol: "tcp" | "udp";
|
||
serverId: number | null;
|
||
serverName: string | null;
|
||
destination: string | null;
|
||
internalPort: number | null;
|
||
source: string | null;
|
||
comment: string | null;
|
||
createdAt: string;
|
||
updatedAt: string;
|
||
}
|
||
|
||
export interface PortForwardInput {
|
||
label: string;
|
||
externalPort: number;
|
||
protocol: "tcp" | "udp";
|
||
serverId?: number | null;
|
||
destination?: string | null;
|
||
internalPort?: number | null;
|
||
source?: string | null;
|
||
comment?: string | null;
|
||
}
|
||
|
||
export type DnsProviderType = "cloudflare" | "loopia" | "pihole" | "azure" | "cpanel" | "technitium";
|
||
|
||
export interface GotifySettings {
|
||
enabled: boolean;
|
||
url: string;
|
||
token: string;
|
||
priority: number;
|
||
}
|
||
|
||
export interface NtfySettings {
|
||
enabled: boolean;
|
||
url: string;
|
||
topic: string;
|
||
token: string;
|
||
priority: number;
|
||
}
|
||
|
||
export interface SmtpSettings {
|
||
enabled: boolean;
|
||
host: string;
|
||
port: number;
|
||
secure: boolean;
|
||
username: string;
|
||
password: string;
|
||
from: string;
|
||
to: string;
|
||
}
|
||
|
||
export interface WebhookSettings {
|
||
enabled: boolean;
|
||
url: string;
|
||
secret: string;
|
||
}
|
||
|
||
export type NotifyChannelId = "gotify" | "ntfy" | "smtp" | "webhook" | "webPush";
|
||
|
||
export interface RoutingRule {
|
||
id: string;
|
||
name: string;
|
||
enabled: boolean;
|
||
categories: AlertCategory[];
|
||
minSeverity: "warning" | "critical" | null;
|
||
tags: string[];
|
||
channels: NotifyChannelId[];
|
||
}
|
||
export interface RoutingSettings {
|
||
rules: RoutingRule[];
|
||
}
|
||
export interface EscalationStep {
|
||
afterMinutes: number;
|
||
minSeverity: "warning" | "critical";
|
||
channels: NotifyChannelId[];
|
||
extraEmail: string;
|
||
evenInQuietHours: boolean;
|
||
}
|
||
export interface EscalationSettings {
|
||
enabled: boolean;
|
||
steps: EscalationStep[];
|
||
}
|
||
|
||
export interface WebPushSettings {
|
||
enabled: boolean;
|
||
/** An email address or https address a push service can reach whoever runs this on. Blank is fine. */
|
||
contact: string;
|
||
}
|
||
|
||
/** A browser or phone that has asked for push notifications. */
|
||
export interface PushDevice {
|
||
id: number;
|
||
label: string | null;
|
||
host: string;
|
||
endpoint: string;
|
||
createdAt: string;
|
||
lastSuccessAt: string | null;
|
||
/** This browser only wants alerts at least this bad; null = every severity. */
|
||
minSeverity: "warning" | "critical" | null;
|
||
/** Only these kinds of alert; null = every kind. */
|
||
categories: AlertCategory[] | null;
|
||
}
|
||
|
||
export interface NotificationEvents {
|
||
dnsAdd: boolean;
|
||
dnsUpdate: boolean;
|
||
dnsDelete: boolean;
|
||
secretCheck: boolean;
|
||
tailscaleKeyCheck: boolean;
|
||
dockerUpdateCheck: boolean;
|
||
proxmoxBackupCheck: boolean;
|
||
pbsVerificationCheck: boolean;
|
||
healthAlerts: boolean;
|
||
automationAlerts: boolean;
|
||
updateRunResults: boolean;
|
||
domainExpiryCheck: boolean;
|
||
secretCheckTime: string;
|
||
timezone: string;
|
||
integrationFailureAlerts: boolean;
|
||
integrationFailureThreshold: number;
|
||
}
|
||
|
||
export type DateFormat = "ymd" | "dmy" | "mdy";
|
||
export type TimeFormat = "24h" | "12h";
|
||
|
||
export interface DisplaySettings {
|
||
dateFormat: DateFormat;
|
||
timeFormat: TimeFormat;
|
||
pageSize: number;
|
||
}
|
||
|
||
export interface LogRetentionSettings {
|
||
enabled: boolean;
|
||
retentionDays: number;
|
||
intervalHours: number;
|
||
}
|
||
|
||
export interface HealthCheckSettings {
|
||
serverOfflineMinutes: number;
|
||
diskUsagePercent: number;
|
||
domainWarnDays: number;
|
||
/** A disk on course to be full within this many days is flagged on the Alerts page; 0 is off. */
|
||
diskForecastDays: number;
|
||
/** A Proxmox guest whose newest backup is older than this many hours is raised as stale; 0 is off. */
|
||
backupStaleHours: number;
|
||
/** A restore test older than this many days is a problem; 0 = off (a failed test always is). */
|
||
restoreTestDays: number;
|
||
/** A server that starts listening on a TCP port it did not at first, and that is not noted on its Ports card, is a warning. */
|
||
newPortAlerts: boolean;
|
||
/** An alert raised this many times within an hour is "flapping": one message says so and its further messages are held until it has been quiet for an hour. 0 is off. */
|
||
flapRaises: number;
|
||
/** Minutes a UniFi device may be offline before it is raised. */
|
||
deviceOfflineMinutes: number;
|
||
/** Days before an operating system's support ends that a server is flagged (0 = off). */
|
||
osSupportWarnDays: number;
|
||
/** A server whose CPU or memory over the last hour is clearly higher than is normal for this hour of the week is a warning. */
|
||
baselineAlerts: boolean;
|
||
/** A container that keeps restarting, is unhealthy, stopped unexpectedly or never started, and a Docker host that cannot be reached, is an alert. */
|
||
containerAlerts: boolean;
|
||
vulnerabilityAlerts: boolean;
|
||
/** A Docker host with at least this many high findings is a warning too; 0 = off. */
|
||
vulnerabilityHighThreshold: number;
|
||
/** A Docker host with running images built more than this many days ago is a warning; 0 = off. */
|
||
imageAgeDays: number;
|
||
/** Containers to leave alone: a name, or "host/name"; * stands for anything. */
|
||
containerIgnore: string[];
|
||
}
|
||
|
||
/** The monthly report: last month's availability, incidents, updates and renewals, in one message on a day of the month. */
|
||
export interface MonthlyReportSettings {
|
||
enabled: boolean;
|
||
/** Also send the quarter's report after the month that ends it. */
|
||
quarterly: boolean;
|
||
/** Also send the year's report after December. */
|
||
annual: boolean;
|
||
/** Day of the month, 1–28, in the notification time zone. */
|
||
day: number;
|
||
/** "HH:MM", in the notification time zone. */
|
||
time: string;
|
||
}
|
||
|
||
export interface QuietHoursSettings {
|
||
enabled: boolean;
|
||
start: string;
|
||
end: string;
|
||
/** A critical alert is sent at once even inside the window. */
|
||
criticalThrough: boolean;
|
||
}
|
||
|
||
/** Whether somebody is away (notifications held until they are back), and how many are being held. */
|
||
export interface AwayView {
|
||
away: { from: string | null; until: string | null; criticalThrough: boolean; note: string; state: "none" | "planned" | "active" };
|
||
held: number;
|
||
timezone: string;
|
||
}
|
||
|
||
/** The weekly digest: one message a week through the notification channels. */
|
||
export interface DigestSettings {
|
||
enabled: boolean;
|
||
/** 0 = Sunday … 6 = Saturday, in the notification time zone. */
|
||
day: number;
|
||
/** "HH:MM", in the notification time zone. */
|
||
time: string;
|
||
}
|
||
|
||
export interface AppSettings {
|
||
gotify: GotifySettings;
|
||
ntfy: NtfySettings;
|
||
smtp: SmtpSettings;
|
||
webhook: WebhookSettings;
|
||
webPush: WebPushSettings;
|
||
routing: RoutingSettings;
|
||
escalation: EscalationSettings;
|
||
notifications: NotificationEvents;
|
||
providerColors: Record<string, string>;
|
||
integrationColors: Record<string, string>;
|
||
display: DisplaySettings;
|
||
logRetention: LogRetentionSettings;
|
||
quietHours: QuietHoursSettings;
|
||
healthChecks: HealthCheckSettings;
|
||
digest: DigestSettings;
|
||
signIn: SignInSettings;
|
||
alertActions: { enabled: boolean };
|
||
profilePictures: ProfilePictureSettings;
|
||
monthlyReport: MonthlyReportSettings;
|
||
}
|
||
|
||
export type AppSettingsPatch = { [K in keyof AppSettings]?: Partial<AppSettings[K]> };
|
||
|
||
export interface EncryptedExportFile {
|
||
app: "homelab-manager-backup";
|
||
version: 1;
|
||
salt: string;
|
||
iv: string;
|
||
authTag: string;
|
||
ciphertext: string;
|
||
}
|
||
|
||
export interface ImportResult {
|
||
integrationsCreated: number;
|
||
integrationsSkipped: string[];
|
||
dnsProvidersCreated: number;
|
||
dnsProvidersSkipped: string[];
|
||
}
|
||
|
||
export interface DnsProviderField {
|
||
key: string;
|
||
label: string;
|
||
secret: boolean;
|
||
type?: "text" | "password" | "checkbox";
|
||
placeholder?: string;
|
||
}
|
||
|
||
export interface DnsProviderSummary {
|
||
id: number;
|
||
providerType: DnsProviderType;
|
||
name: string;
|
||
enabled: boolean;
|
||
createdAt: string;
|
||
}
|
||
|
||
export interface DnsZone {
|
||
id: string;
|
||
name: string;
|
||
syncedAt: string | null;
|
||
recordCount: number;
|
||
}
|
||
|
||
export interface DnsRecord {
|
||
id: string;
|
||
type: string;
|
||
name: string;
|
||
content: string;
|
||
ttl: number | null;
|
||
priority: number | null;
|
||
proxied?: boolean | null;
|
||
}
|
||
|
||
export interface DnsRecordInput {
|
||
type: string;
|
||
name: string;
|
||
content: string;
|
||
ttl?: number;
|
||
priority?: number;
|
||
proxied?: boolean;
|
||
}
|
||
|
||
export interface ServerRecord {
|
||
id: number;
|
||
name: string;
|
||
hostname: string | null;
|
||
osType: string;
|
||
description: string | null;
|
||
apiTokenPrefix: string;
|
||
createdAt: string;
|
||
lastSeenAt: string | null;
|
||
proxmoxIntegrationId: number | null;
|
||
proxmoxNode: string | null;
|
||
proxmoxGuestType: "qemu" | "lxc" | null;
|
||
proxmoxVmid: number | null;
|
||
hideProxmoxLink: boolean;
|
||
/** An admin said it runs on nothing, so nothing is worked out for it. */
|
||
noParent: boolean;
|
||
tags: string[];
|
||
/** The server this one runs on, when an admin said so; null means it is worked out from the Proxmox node. */
|
||
parentServerId: number | null;
|
||
/** What the agent says is waiting to be installed; null until it has said. */
|
||
pendingUpdates: PendingUpdates | null;
|
||
/** When updates were first seen waiting (and none were before); null when none are. */
|
||
updatesPendingSince: string | null;
|
||
/** Which version of the agent script it runs, as the agent says; null from one that predates the number (version 1). */
|
||
agentVersion: number | null;
|
||
/** Failed services, disk health and ZFS pools, as the agent says; null until it says anything. */
|
||
hostHealth: HostHealth | null;
|
||
/** This server's own alert limits; null when it follows Settings entirely. */
|
||
thresholds: ServerThresholds | null;
|
||
}
|
||
|
||
/** The agent version a new install would be, per system; null when this app can't tell. */
|
||
export interface AgentLatest {
|
||
linux: number | null;
|
||
windows: number | null;
|
||
}
|
||
|
||
/** What a Linux agent says about the machine itself. Each part is there only if the agent could find it out. */
|
||
export interface HostHealth {
|
||
failedUnits?: { unit: string; description: string; /** This server is told to ignore it: it doesn't count as failed. */ ignored?: boolean }[];
|
||
smart?: { device: string; model: string; healthy: boolean | null; temperatureC: number | null; wearPercent: number | null }[];
|
||
zfs?: { name: string; health: string; capacityPercent: number | null }[];
|
||
reportedAt: string;
|
||
}
|
||
|
||
export interface PendingUpdates {
|
||
manager: string;
|
||
count: number;
|
||
/** Null when the package manager can't say which are security fixes. */
|
||
security: number | null;
|
||
rebootRequired: boolean;
|
||
reportedAt: string;
|
||
}
|
||
|
||
/** One server on the Updates page. */
|
||
/** A server's own alert limits; whatever is left out follows Settings. */
|
||
export interface ServerThresholds {
|
||
serverOfflineMinutes?: number;
|
||
diskUsagePercent?: number;
|
||
diskForecastDays?: number;
|
||
backupStaleHours?: number;
|
||
mounts?: Record<string, { percent?: number; ignore?: boolean }>;
|
||
/** Services never to count as failed here: names or patterns like "gupdate*". */
|
||
ignoreServices?: string[];
|
||
}
|
||
|
||
/** One thing worth telling a person about a server's agent: what it couldn't collect (and what to do), or that it is behind. */
|
||
export interface AgentDiagnosticNote {
|
||
check: string;
|
||
level: "warning" | "info";
|
||
title: string;
|
||
fix: string | null;
|
||
detail: string | null;
|
||
}
|
||
|
||
export interface UpdateRun {
|
||
id: number;
|
||
serverId: number;
|
||
serverName: string | null;
|
||
integrationId: number;
|
||
template: string;
|
||
limit: string;
|
||
taskId: number | null;
|
||
/** Semaphore's own word for the run. */
|
||
taskStatus: string | null;
|
||
status: "running" | "waiting_for_host" | "done" | "failed" | "cancelled";
|
||
active: boolean;
|
||
message: string | null;
|
||
startedBy: string | null;
|
||
startedAt: string;
|
||
taskEndedAt: string | null;
|
||
finishedAt: string | null;
|
||
updatesBefore: number | null;
|
||
updatesAfter: number | null;
|
||
rebootRequired: boolean;
|
||
}
|
||
|
||
export interface UpdateRunInput {
|
||
serverId: number;
|
||
integrationId: number;
|
||
projectId: number;
|
||
templateId: number;
|
||
limit: string;
|
||
windowMinutes: number;
|
||
/** Somebody is streaming from the machine and the person has seen the warning. */
|
||
startAnyway?: boolean;
|
||
}
|
||
|
||
export interface UpdatesServer {
|
||
id: number;
|
||
name: string;
|
||
osType: string;
|
||
lastSeenAt: string | null;
|
||
updates: PendingUpdates | null;
|
||
pendingSince: string | null;
|
||
agentVersion: number | null;
|
||
}
|
||
|
||
/** What a server runs on, and what runs on it. `auto`: worked out from the Proxmox node rather than set by hand. */
|
||
export interface ServerRelation {
|
||
id: number;
|
||
name: string;
|
||
auto: boolean;
|
||
}
|
||
|
||
export interface ServerHardware {
|
||
source: "proxmox" | "agent" | "none";
|
||
error?: string;
|
||
integrationId?: number;
|
||
integrationName?: string;
|
||
status?: string;
|
||
cpuModel?: string;
|
||
cpuCores?: number | null;
|
||
cpuUsagePercent?: number | null;
|
||
cpuLoadPercent?: number | null;
|
||
memTotalBytes?: number | null;
|
||
memUsedBytes?: number | null;
|
||
diskBytes?: number | null;
|
||
disks?: { mount: string; sizeBytes: number; usedBytes: number }[];
|
||
uptime?: number | null;
|
||
guestAgentAvailable?: boolean;
|
||
}
|
||
|
||
export interface DnsMatch {
|
||
recordName: string;
|
||
recordType: string;
|
||
ip: string;
|
||
zoneName: string | null;
|
||
providerName: string;
|
||
providerType: string;
|
||
}
|
||
|
||
export interface ServerLink {
|
||
id: number;
|
||
label: string;
|
||
url: string;
|
||
}
|
||
|
||
/** What a server runs and when that release stops being supported (from what its agent says). */
|
||
export interface ServerOs {
|
||
id: string;
|
||
name: string | null;
|
||
version: string | null;
|
||
product: string;
|
||
endsOn: string | null;
|
||
state: "ended" | "soon" | "ok" | "unknown";
|
||
daysLeft: number | null;
|
||
}
|
||
|
||
export interface ServerDetail {
|
||
os: ServerOs | null;
|
||
server: ServerRecord;
|
||
ipAddresses: string[];
|
||
hardware: ServerHardware;
|
||
dnsMatches: DnsMatch[];
|
||
links: ServerLink[];
|
||
relations: { parent: ServerRelation | null; children: ServerRelation[] };
|
||
agentLatest: AgentLatest;
|
||
/** What its agent couldn't collect, with what to do about it. */
|
||
diagnostics: AgentDiagnosticNote[];
|
||
/** The limits in Settings, which this server follows wherever it has none of its own. */
|
||
thresholdDefaults: HealthCheckSettings;
|
||
}
|
||
|
||
/** A token that opens /metrics for Prometheus, as the list shows it (never the secret). */
|
||
export interface MetricsToken {
|
||
id: number;
|
||
label: string;
|
||
tokenPrefix: string;
|
||
createdBy: string | null;
|
||
createdAt: string;
|
||
lastUsedAt: string | null;
|
||
}
|
||
|
||
export type WebhookEventName = "alert.opened" | "alert.resolved" | "maintenance.started" | "maintenance.ended";
|
||
|
||
/** A URL sent a signed JSON message when something happens. */
|
||
export interface EventWebhook {
|
||
id: number;
|
||
label: string;
|
||
url: string;
|
||
hasSecret: boolean;
|
||
events: WebhookEventName[];
|
||
enabled: boolean;
|
||
createdBy: string | null;
|
||
createdAt: string;
|
||
lastAttemptAt: string | null;
|
||
/** "200", or what went wrong. */
|
||
lastResult: string | null;
|
||
}
|
||
|
||
/** One message sent to an event webhook, and how it went. */
|
||
export interface WebhookDelivery {
|
||
id: number;
|
||
event: string;
|
||
deliveryId: string;
|
||
/** 1, or 2 when the first try failed. */
|
||
attempts: number;
|
||
ok: boolean;
|
||
/** "200", or what went wrong. */
|
||
result: string;
|
||
/** The JSON that was sent; null when it was too large to keep. */
|
||
body: string | null;
|
||
retryable: boolean;
|
||
/** The delivery this one sent again, if it was a retry by hand. */
|
||
retryOf: number | null;
|
||
createdAt: string;
|
||
}
|
||
|
||
export type UsageState = "limit" | "filling" | "not_trimmed" | "unlimited" | "plain";
|
||
|
||
export interface TableUsage {
|
||
name: string;
|
||
rows: number;
|
||
bytes: number | null;
|
||
keepDays: number | null;
|
||
note: string | null;
|
||
oldest: string | null;
|
||
newest: string | null;
|
||
perDay: number | null;
|
||
spanDays: number | null;
|
||
state: UsageState;
|
||
stateText: string;
|
||
}
|
||
|
||
/** How big the app's own data is, and whether its histories are trimmed as they should be. */
|
||
export interface DataUsage {
|
||
generatedAt: string;
|
||
database: { file: string; bytes: number; walBytes: number; pages: number; pageSize: number; freePages: number; freeBytes: number; tables: number };
|
||
backups: { files: number; bytes: number };
|
||
sessions: { files: number; bytes: number };
|
||
totalBytes: number;
|
||
tables: TableUsage[];
|
||
attention: { table: string; text: string }[];
|
||
}
|
||
|
||
export type CoverageStatus = "ok" | "stale" | "failed" | "none" | "unknown";
|
||
|
||
/** One Proxmox guest and how well it is backed up. */
|
||
export interface CoverageGuest {
|
||
/** How old its newest backup may be before it counts as stale, in hours — the limit that applied to it (0 = never). */
|
||
staleAfterHours: number;
|
||
integrationId: number;
|
||
integrationName: string;
|
||
node: string;
|
||
vmid: number;
|
||
name: string;
|
||
type: "qemu" | "lxc";
|
||
power: string;
|
||
/** A backup job covers it. */
|
||
inJob: boolean;
|
||
lastBackupAt: string | null;
|
||
lastSource: "pbs" | "task" | null;
|
||
status: CoverageStatus;
|
||
failure: string | null;
|
||
server: { id: number; name: string } | null;
|
||
/** The key a restore test of this guest is recorded under. */
|
||
restoreKey?: string;
|
||
/** How the newest restore test of it went. */
|
||
restoreTest?: RestoreInfo;
|
||
}
|
||
|
||
export type RestoreResult = "ok" | "partial" | "failed" | "not_needed";
|
||
export type RestoreStatus = RestoreResult | "never" | "stale";
|
||
export interface RestoreInfo {
|
||
status: RestoreStatus;
|
||
testedAt: string | null;
|
||
ageDays: number | null;
|
||
note: string | null;
|
||
testedBy: string | null;
|
||
}
|
||
export interface RestoreTestEntry {
|
||
id: number;
|
||
subjectKey: string;
|
||
label: string;
|
||
testedAt: string;
|
||
result: RestoreResult;
|
||
note: string | null;
|
||
testedBy: string | null;
|
||
createdAt: string;
|
||
}
|
||
|
||
export interface BackupCoverage {
|
||
restoreTestDays?: number;
|
||
guests: CoverageGuest[];
|
||
counts: Record<CoverageStatus, number> & { total: number };
|
||
sources: { kind: "proxmox" | "pbs"; name: string; ok: boolean; error?: string }[];
|
||
staleHours: number;
|
||
generatedAt: string;
|
||
}
|
||
|
||
export type EndpointKind = "http" | "tcp" | "tls";
|
||
export interface EndpointStats {
|
||
uptime24h: number | null;
|
||
uptime7d: number | null;
|
||
avgMs24h: number | null;
|
||
recent: { at: string; ok: boolean; ms: number | null }[];
|
||
}
|
||
export type EndpointValueOp = "<" | "<=" | ">" | ">=" | "=" | "!=" | "contains" | "exists";
|
||
|
||
export interface EndpointCheck {
|
||
id: number;
|
||
name: string;
|
||
kind: EndpointKind;
|
||
target: string;
|
||
port: number | null;
|
||
expectStatus: string | null;
|
||
keyword: string | null;
|
||
/** A web check can judge a value in a JSON answer: where it is, how it must compare, and what to. */
|
||
valuePath: string | null;
|
||
valueOp: EndpointValueOp | null;
|
||
valueExpected: string | null;
|
||
valueUnit: string | null;
|
||
/** A header sent with the request (its value is never sent back, only that there is one). */
|
||
headerName: string | null;
|
||
hasHeader: boolean;
|
||
/** What was read the last time, as text. */
|
||
lastValue: string | null;
|
||
insecure: boolean;
|
||
intervalMinutes: number;
|
||
timeoutSeconds: number;
|
||
failuresBeforeAlert: number;
|
||
warnDays: number;
|
||
serverId: number | null;
|
||
enabled: boolean;
|
||
lastCheckedAt: string | null;
|
||
lastOk: boolean | null;
|
||
lastMessage: string | null;
|
||
lastResponseMs: number | null;
|
||
certExpiresAt: string | null;
|
||
consecutiveFailures: number;
|
||
lastChangeAt: string | null;
|
||
server: { id: number; name: string } | null;
|
||
stats?: EndpointStats;
|
||
}
|
||
/** How one check has done over a stretch (GET /api/endpoints/:id/history). */
|
||
export interface EndpointHistory {
|
||
check: { id: number; name: string };
|
||
days: number;
|
||
/** The numbers a value check read, as far back as the results are kept; null for a check that reads none. */
|
||
values: { unit: string | null; days: number; points: { t: string; v: number; lo: number; hi: number }[]; latest: number | null; lowest: number | null; highest: number | null } | null;
|
||
/** Which figures it is drawn from: each answer (a day or two), the hourly figures, or the daily ones. */
|
||
source: "results" | "hourly" | "daily";
|
||
points: { t: string; availability: number | null; avgMs: number | null; maxMs: number | null; checks: number }[];
|
||
availability: number | null;
|
||
avgMs: number | null;
|
||
checks: number;
|
||
}
|
||
|
||
/** One of a person's own read-only API tokens; the secret is only ever shown when it is made. */
|
||
export interface ApiToken {
|
||
id: number;
|
||
label: string;
|
||
tokenPrefix: string;
|
||
createdAt: string;
|
||
lastUsedAt: string | null;
|
||
expiresAt: string | null;
|
||
expired: boolean;
|
||
}
|
||
|
||
export interface EndpointInput {
|
||
name: string;
|
||
kind: EndpointKind;
|
||
target: string;
|
||
port?: number | null;
|
||
expectStatus?: string | null;
|
||
keyword?: string | null;
|
||
valuePath?: string | null;
|
||
valueOp?: EndpointValueOp | null;
|
||
valueExpected?: string | null;
|
||
valueUnit?: string | null;
|
||
headerName?: string | null;
|
||
/** Left out, an edit keeps the value already saved. */
|
||
headerValue?: string | null;
|
||
insecure?: boolean;
|
||
intervalMinutes?: number;
|
||
timeoutSeconds?: number;
|
||
failuresBeforeAlert?: number;
|
||
warnDays?: number;
|
||
serverId?: number | null;
|
||
enabled?: boolean;
|
||
}
|
||
|
||
export type PatchPlanItemStatus = "pending" | "running" | "done" | "failed" | "skipped";
|
||
export interface PatchPlanItem {
|
||
serverId: number;
|
||
name: string;
|
||
status: PatchPlanItemStatus;
|
||
updateRunId: number | null;
|
||
message: string | null;
|
||
}
|
||
export interface PatchPlanRun {
|
||
id: number;
|
||
planId: number;
|
||
planName: string;
|
||
trigger: "schedule" | "manual";
|
||
startedBy: string | null;
|
||
status: "running" | "done" | "failed" | "cancelled";
|
||
message: string | null;
|
||
startedAt: string;
|
||
finishedAt: string | null;
|
||
items: PatchPlanItem[];
|
||
}
|
||
/** Updates on a schedule, one server at a time. */
|
||
export interface PatchPlan {
|
||
id: number;
|
||
name: string;
|
||
enabled: boolean;
|
||
/** 0 = Sunday … 6 = Saturday. */
|
||
days: number[];
|
||
startTime: string;
|
||
timezone: string;
|
||
tags: string[];
|
||
serverIds: number[];
|
||
integrationId: number;
|
||
projectId: number;
|
||
templateId: number;
|
||
templateName: string;
|
||
limitFrom: "name" | "hostname";
|
||
stopOnFailure: boolean;
|
||
onlyWithUpdates: boolean;
|
||
silenceDependents: boolean;
|
||
windowMinutes: number;
|
||
createdBy: string | null;
|
||
/** The servers it covers right now. */
|
||
servers: { id: number; name: string }[];
|
||
/** ISO — its next times. */
|
||
next: string[];
|
||
running: boolean;
|
||
}
|
||
export type PatchPlanInput = Omit<PatchPlan, "id" | "createdBy" | "servers" | "next" | "running">;
|
||
|
||
export interface AvailabilityRow {
|
||
id: number;
|
||
name: string;
|
||
percent: number | null;
|
||
downMinutes: number;
|
||
}
|
||
export type ServiceLevelSubject = "endpoint" | "server" | "integration";
|
||
|
||
/** How one service-level target did over a stretch (a month, quarter or year) in a report. */
|
||
export interface ServiceLevelResult {
|
||
id: number;
|
||
name: string;
|
||
subjectType: ServiceLevelSubject;
|
||
target: number;
|
||
percent: number | null;
|
||
downMinutes: number;
|
||
allowedMinutes: number;
|
||
usedPercent: number | null;
|
||
met: boolean | null;
|
||
}
|
||
|
||
/** A service-level target, where this month's error budget stands, and how the months before it went. */
|
||
export interface ServiceLevel {
|
||
id: number;
|
||
name: string;
|
||
subjectType: ServiceLevelSubject;
|
||
subjectId: number;
|
||
/** The thing measured; null when it has been removed. */
|
||
subjectName: string | null;
|
||
target: number;
|
||
alert: boolean;
|
||
createdBy: string | null;
|
||
period: { id: string; label: string; from: string; to: string; totalMinutes: number; elapsedMinutes: number };
|
||
measure: { percent: number | null; downMinutes: number; knownMinutes: number };
|
||
budget: { allowedMinutes: number; usedPercent: number | null; remainingMinutes: number; state: "ok" | "at_risk" | "breached" | "no_data"; projectedPercent: number | null };
|
||
history: { id: string; label: string; percent: number | null; downMinutes: number; allowedMinutes: number; met: boolean | null }[];
|
||
}
|
||
|
||
export interface ServiceLevelInput {
|
||
name: string;
|
||
subjectType: ServiceLevelSubject;
|
||
subjectId: number;
|
||
target: number;
|
||
alert: boolean;
|
||
}
|
||
|
||
export interface MonthlyReport {
|
||
/** A month ("2026-09"), a quarter ("2026-Q3") or a year ("2026"). */
|
||
period: "month" | "quarter" | "year";
|
||
month: string;
|
||
label: string;
|
||
serviceLevels: ServiceLevelResult[];
|
||
from: string;
|
||
to: string;
|
||
partial: boolean;
|
||
timezone: string;
|
||
servers: AvailabilityRow[];
|
||
integrations: AvailabilityRow[];
|
||
endpoints: { id: number; name: string; percent: number | null; avgMs: number | null; checks: number }[];
|
||
incidents: {
|
||
began: number;
|
||
resolved: number;
|
||
stillOpen: number;
|
||
totalMinutes: number;
|
||
averageMinutes: number | null;
|
||
longest: { id: number; message: string; minutes: number } | null;
|
||
byCategory: { category: string; count: number }[];
|
||
list: { id: number; message: string; where: string; severity: string; openedAt: string; resolvedAt: string | null; minutes: number }[];
|
||
};
|
||
updates: {
|
||
runs: number;
|
||
done: number;
|
||
failed: number;
|
||
installed: number;
|
||
byServer: { name: string; runs: number; failed: number; installed: number }[];
|
||
planRuns: { runs: number; done: number; failed: number };
|
||
};
|
||
restoreTests: { label: string; testedAt: string; result: string; note: string | null }[];
|
||
backups: { ok: number; stale: number; failed: number; none: number; unknown: number; total: number; asOf: string } | null;
|
||
renewals: { kind: string; subject: string; at: string; fromDate: string; toDate: string }[];
|
||
}
|
||
|
||
/** One Jellyfin, as its page shows it. */
|
||
export interface JellyfinStream {
|
||
user: string;
|
||
client: string | null;
|
||
device: string | null;
|
||
title: string;
|
||
transcoding: boolean;
|
||
paused: boolean;
|
||
}
|
||
|
||
export interface JellyfinInfo {
|
||
id: number;
|
||
name: string;
|
||
enabled: boolean;
|
||
runsOn: { id: number; name: string } | null;
|
||
status: { at: string; ok: boolean; error: string | null } | null;
|
||
fresh: boolean;
|
||
state: {
|
||
serverName: string | null;
|
||
version: string | null;
|
||
os: string | null;
|
||
pendingRestart: boolean;
|
||
updateAvailable: boolean;
|
||
streams: JellyfinStream[];
|
||
tasks: { name: string; category: string | null; state: string; lastStatus: string | null; lastEndedAt: string | null; error: string | null }[];
|
||
counts: { movies: number | null; series: number | null; episodes: number | null; songs: number | null };
|
||
failedLogins24h: number | null;
|
||
updatedAt: string;
|
||
} | null;
|
||
problems: { key: string; message: string; severity: "warning" | "critical" }[];
|
||
}
|
||
|
||
/** One Nextcloud, as its page shows it. */
|
||
export interface NextcloudInfo {
|
||
id: number;
|
||
name: string;
|
||
enabled: boolean;
|
||
status: { at: string; ok: boolean; error: string | null } | null;
|
||
fresh: boolean;
|
||
state: {
|
||
version: string | null;
|
||
maintenance: boolean;
|
||
needsUpgrade: boolean;
|
||
/** Whether the monitoring app answered (an administrator's app password is needed). */
|
||
detail: boolean;
|
||
freeBytes: number | null;
|
||
users: number | null;
|
||
files: number | null;
|
||
active24h: number | null;
|
||
appUpdates: number | null;
|
||
/** The version Nextcloud says is available ("newer" when it does not say which); null when none is. */
|
||
coreUpdate: string | null;
|
||
/** Nextcloud's own "Cron last run" check; null when not known (no login, or before Nextcloud 28). */
|
||
cron: { state: "success" | "info" | "warning" | "error"; text: string | null } | null;
|
||
/** Its other checks that report an error or a warning; null when they could not be asked. */
|
||
setupIssues: { name: string; severity: "warning" | "error"; text: string | null }[] | null;
|
||
updatedAt: string;
|
||
} | null;
|
||
problems: { key: string; message: string; severity: "warning" | "critical" }[];
|
||
}
|
||
|
||
export interface HetznerServerInfo {
|
||
id: number;
|
||
name: string;
|
||
status: string;
|
||
created: string | null;
|
||
type: string | null;
|
||
cores: number | null;
|
||
memoryGb: number | null;
|
||
diskGb: number | null;
|
||
location: string | null;
|
||
city: string | null;
|
||
os: string | null;
|
||
ipv4: string | null;
|
||
ipv6: string | null;
|
||
privateIps: string[];
|
||
locked: boolean;
|
||
rescueEnabled: boolean;
|
||
/** The hour backups are taken in; null when they are not enabled. */
|
||
backupWindow: string | null;
|
||
/** This month's traffic, in bytes. */
|
||
includedTraffic: number | null;
|
||
outgoingTraffic: number | null;
|
||
ingoingTraffic: number | null;
|
||
monthlyPrice: number | null;
|
||
lastRunningAt: string | null;
|
||
statusSince: string;
|
||
rescueSince: string | null;
|
||
/** How the month's traffic is forecast to end; null when there is too little to say. */
|
||
forecast?: HetznerTrafficForecast | null;
|
||
}
|
||
|
||
export interface HetznerTrafficForecast {
|
||
/** Bytes a day, the way it has been going. */
|
||
perDay: number;
|
||
/** What the month will have come to by its end at that rate. */
|
||
projectedMonth: number;
|
||
/** When the quota is passed, if that is before the month ends. */
|
||
exhaustedAt: string | null;
|
||
basis: "recent" | "month";
|
||
}
|
||
|
||
export interface HetznerLoadBalancerInfo {
|
||
id: number;
|
||
name: string;
|
||
type: string | null;
|
||
location: string | null;
|
||
ipv4: string | null;
|
||
algorithm: string | null;
|
||
services: number;
|
||
targets: { kind: "server" | "label_selector" | "ip"; serverId: number | null; serverName: string | null; label: string | null; health: "healthy" | "unhealthy" | "unknown" }[];
|
||
includedTraffic: number | null;
|
||
outgoingTraffic: number | null;
|
||
monthlyPrice: number | null;
|
||
}
|
||
|
||
export interface HetznerFloatingIpInfo {
|
||
id: number;
|
||
name: string | null;
|
||
ip: string;
|
||
type: "ipv4" | "ipv6";
|
||
serverId: number | null;
|
||
serverName: string | null;
|
||
location: string | null;
|
||
description: string | null;
|
||
}
|
||
|
||
export interface HetznerCertificateInfo {
|
||
id: number;
|
||
name: string;
|
||
type: string;
|
||
domains: string[];
|
||
notValidAfter: string | null;
|
||
issuance: string | null;
|
||
renewal: string | null;
|
||
error: string | null;
|
||
usedBy: number;
|
||
}
|
||
|
||
export interface HetznerProblemInfo {
|
||
key: string;
|
||
serverId: number;
|
||
message: string;
|
||
severity: "warning" | "critical";
|
||
}
|
||
|
||
/** One Hetzner Cloud project (an integration of type hetzner), as its page shows it. */
|
||
export interface HetznerProject {
|
||
id: number;
|
||
name: string;
|
||
enabled: boolean;
|
||
status: { at: string; ok: boolean; error: string | null } | null;
|
||
fresh: boolean;
|
||
state: {
|
||
/** linked: the server the app knows by its agent that this is; null when there is none. */
|
||
servers: (HetznerServerInfo & { linked: { id: number; name: string } | null })[];
|
||
/** Null when the volumes could not be listed, which is not the same as none. */
|
||
volumes: { id: number; name: string; size: number; serverId: number | null; serverName: string | null; location: string | null; status: string }[] | null;
|
||
images: { id: number; type: "snapshot" | "backup"; description: string | null; created: string | null; sizeGb: number | null; serverId: number | null; serverName: string | null }[] | null;
|
||
cost: { currency: string; servers: number; backups: number; volumes: number; snapshots: number; ips: number; loadBalancers?: number; floatingIps?: number; total: number; unassignedIps: number; unpriced: number } | null;
|
||
/** Each of these is null when it could not be listed, which is not the same as none. */
|
||
loadBalancers: HetznerLoadBalancerInfo[] | null;
|
||
floatingIps: HetznerFloatingIpInfo[] | null;
|
||
certificates: HetznerCertificateInfo[] | null;
|
||
updatedAt: string;
|
||
} | null;
|
||
problems: HetznerProblemInfo[];
|
||
}
|
||
|
||
export interface HetznerForServer {
|
||
match: {
|
||
integrationId: number;
|
||
integrationName: string;
|
||
fresh: boolean;
|
||
updatedAt: string;
|
||
server: HetznerServerInfo;
|
||
newestBackup: string | null;
|
||
snapshots: number;
|
||
problems: HetznerProblemInfo[];
|
||
forecast: HetznerTrafficForecast | null;
|
||
} | null;
|
||
}
|
||
|
||
export interface FragnetServerInfo {
|
||
/** The short id (8 characters) the game panel uses. */
|
||
id: string;
|
||
name: string;
|
||
description: string | null;
|
||
node: string | null;
|
||
/** The game, as the panel names it; null when it did not say. */
|
||
game: string | null;
|
||
dockerImage: string | null;
|
||
panelStatus: string | null;
|
||
suspended: boolean;
|
||
installing: boolean;
|
||
transferring: boolean;
|
||
owner: boolean;
|
||
/** running, starting, stopping, offline — or unknown when it could not be read. */
|
||
state: string;
|
||
allocations: { ip: string; alias: string | null; port: number; isDefault: boolean; notes: string | null }[];
|
||
sftp: string | null;
|
||
/** MB; 0 or null: no limit / not said. */
|
||
memoryLimitMb: number | null;
|
||
diskLimitMb: number | null;
|
||
cpuLimit: number | null;
|
||
databaseLimit: number | null;
|
||
backupLimit: number | null;
|
||
allocationLimit: number | null;
|
||
usage: { memoryBytes: number; cpu: number; diskBytes: number; rxBytes: number; txBytes: number; uptimeMs: number } | null;
|
||
/** Newest first; null when they could not be listed. */
|
||
backups: { uuid: string; name: string | null; bytes: number; createdAt: string | null; completedAt: string | null; successful: boolean; locked: boolean }[] | null;
|
||
schedules: { id: number; name: string; cron: string; active: boolean; processing: boolean; onlyWhenOnline: boolean; lastRunAt: string | null; nextRunAt: string | null }[] | null;
|
||
databases: number | null;
|
||
stateSince: string;
|
||
firstSeenAt: string;
|
||
/** The newest backup that worked, and whether a newer one failed; null when the backups could not be listed. */
|
||
newestBackup: { at: string | null; failedSince: boolean } | null;
|
||
}
|
||
|
||
/** One Fragnet game panel account (an integration of type fragnet), as its page shows it. */
|
||
export interface FragnetAccount {
|
||
id: number;
|
||
name: string;
|
||
enabled: boolean;
|
||
panelUrl: string;
|
||
status: { at: string; ok: boolean; error: string | null } | null;
|
||
fresh: boolean;
|
||
options: { backupDays: number; fullPercent: number; ignoreBackups: string[] };
|
||
state: { servers: FragnetServerInfo[]; updatedAt: string } | null;
|
||
problems: { key: string; serverId: string; message: string; severity: "warning" | "critical" }[];
|
||
}
|
||
|
||
/** One Sonarr, Radarr or Prowlarr (an integration of that type), as the media page shows it. */
|
||
export interface ArrApp {
|
||
id: number;
|
||
kind: "sonarr" | "radarr" | "prowlarr";
|
||
name: string;
|
||
enabled: boolean;
|
||
url: string;
|
||
status: { at: string; ok: boolean; error: string | null } | null;
|
||
fresh: boolean;
|
||
state: {
|
||
version: string | null;
|
||
/** What its own checks found: type is ok, notice, warning or error. */
|
||
health: { source: string; type: string; message: string }[];
|
||
/** Null when it could not be read (and always for Prowlarr, which has none). */
|
||
queue: { total: number; items: { id: number; title: string; status: string; tracked: "ok" | "warning" | "error" | null; state: string | null; messages: string[]; size: number | null; sizeLeft: number | null; added: string | null; etaAt: string | null; protocol: string | null; client: string | null; indexer: string | null }[] } | null;
|
||
disks: { path: string; label: string | null; free: number; total: number }[] | null;
|
||
missing: number | null;
|
||
indexers: { id: number; name: string; enabled: boolean; protocol: string | null; disabledTill: string | null; lastFailure: string | null }[] | null;
|
||
updatedAt: string;
|
||
/** The ids of the queue items that are stuck. */
|
||
stuck: number[];
|
||
} | null;
|
||
problems: { key: string; message: string; severity: "warning" | "critical" }[];
|
||
}
|
||
|
||
/** One AdGuard Home (an integration of type adguard), as its page shows it. */
|
||
export interface AdguardInstance {
|
||
id: number;
|
||
name: string;
|
||
enabled: boolean;
|
||
url: string;
|
||
status: { at: string; ok: boolean; error: string | null } | null;
|
||
fresh: boolean;
|
||
state: {
|
||
version: string | null;
|
||
running: boolean;
|
||
protectionEnabled: boolean;
|
||
protectionOffSince: string | null;
|
||
dnsPort: number;
|
||
stats: { queries: number; blocked: number; blockedPercent: number | null; avgMs: number | null; safeBrowsing: number; parental: number; safeSearch: number; periodHours: number | null; topBlocked: { name: string; count: number }[]; topClients: { name: string; count: number }[]; topQueried: { name: string; count: number }[] } | null;
|
||
filters: { enabled: boolean; lists: { name: string; enabled: boolean; rules: number | null; updated: string | null }[] } | null;
|
||
/** The real DNS question put to it. */
|
||
probe: { ok: boolean; ms: number | null; error: string | null; name: string; host: string } | null;
|
||
probeFailSince: string | null;
|
||
updatedAt: string;
|
||
staleLists: string[];
|
||
} | null;
|
||
problems: { key: string; message: string; severity: "warning" | "critical" }[];
|
||
}
|
||
|
||
/** One Grafana (an integration of type grafana), as its page shows it. */
|
||
export interface GrafanaInstance {
|
||
id: number;
|
||
name: string;
|
||
enabled: boolean;
|
||
url: string;
|
||
status: { at: string; ok: boolean; error: string | null } | null;
|
||
fresh: boolean;
|
||
state: {
|
||
version: string | null;
|
||
/** The rules firing, pending or failing, and how many there are in all; null when they could not be read. */
|
||
rules: { total: number; items: { name: string; uid: string | null; group: string; folder: string | null; state: string; health: string; lastError: string | null; severity: string | null; summary: string | null; activeAt: string | null }[] } | null;
|
||
datasources: { uid: string; name: string; type: string; isDefault: boolean; ok: boolean | null; message: string | null }[] | null;
|
||
updatedAt: string;
|
||
} | null;
|
||
problems: { key: string; message: string; severity: "warning" | "critical" }[];
|
||
}
|
||
|
||
export type FragnetSignal = "start" | "stop" | "restart" | "kill";
|
||
|
||
export interface CostItem {
|
||
id: number;
|
||
name: string;
|
||
amount: number;
|
||
currency: string;
|
||
period: "month" | "year";
|
||
category: string;
|
||
/** The day it is (or will first be) billed; the next time it falls is nextRenewal. */
|
||
renewsOn: string | null;
|
||
nextRenewal: string | null;
|
||
/** Per month, whatever the period it is paid in. */
|
||
monthly: number;
|
||
note: string | null;
|
||
}
|
||
|
||
export interface CostInput {
|
||
name: string;
|
||
amount: number;
|
||
currency: string;
|
||
period: "month" | "year";
|
||
category: string;
|
||
renewsOn: string | null;
|
||
note: string | null;
|
||
}
|
||
|
||
export interface CostsReport {
|
||
items: CostItem[];
|
||
/** What can be read rather than typed: a Hetzner project's estimate. */
|
||
automatic: { key: string; source: string; name: string; currency: string; monthly: number; detail: string; link: string; stale: boolean }[];
|
||
/** Per currency; none is converted into another. */
|
||
totals: { currency: string; monthly: number; yearly: number; items: number; categories: { category: string; monthly: number }[] }[];
|
||
categories: string[];
|
||
}
|
||
|
||
/** One Speedtest Tracker (an integration of type speedtest), as its page shows it. Speeds are bits per second. */
|
||
export interface SpeedtestInfo {
|
||
id: number;
|
||
name: string;
|
||
enabled: boolean;
|
||
status: { at: string; ok: boolean; error: string | null } | null;
|
||
fresh: boolean;
|
||
/** What the line is sold at (Mbit/s; null: not said) and the share below which it is called slow. */
|
||
expected: { downloadMbps: number | null; uploadMbps: number | null; minPercent: number };
|
||
state: {
|
||
latest: { at: string; download: number | null; upload: number | null; ping: number | null; healthy: boolean | null } | null;
|
||
/** The middle of the newest few completed tests — what the alerts judge. */
|
||
middle: { count: number; download: number | null; upload: number | null; ping: number | null };
|
||
lastTest: { at: string; status: string } | null;
|
||
stored: number;
|
||
} | null;
|
||
problems: { key: string; message: string; severity: "warning" }[];
|
||
}
|
||
|
||
export interface SpeedtestHistory {
|
||
days: number;
|
||
/** Mbit/s and milliseconds. */
|
||
points: { t: string; download: number | null; upload: number | null; ping: number | null }[];
|
||
}
|
||
|
||
/** One NetBox, as its page shows it. */
|
||
export interface NetBoxInfo {
|
||
id: number;
|
||
name: string;
|
||
enabled: boolean;
|
||
status: { at: string; ok: boolean; error: string | null } | null;
|
||
fresh: boolean;
|
||
state: {
|
||
version: string | null;
|
||
/** Null when NetBox did not say. */
|
||
workersRunning: number | null;
|
||
devices: number | null;
|
||
virtualMachines: number | null;
|
||
prefixes: number | null;
|
||
ipAddresses: number | null;
|
||
/** The servers this app manages that have no address in NetBox; null when NetBox's addresses could not be listed. */
|
||
missing: { id: number; name: string; ips: string[] }[] | null;
|
||
/** NetBox has more addresses than were read, so what is missing may be among the rest. */
|
||
truncated: boolean;
|
||
updatedAt: string;
|
||
} | null;
|
||
problems: { key: string; message: string; severity: "warning" | "critical" }[];
|
||
}
|
||
|
||
/** One n8n, as its page shows it. */
|
||
export interface N8nInfo {
|
||
id: number;
|
||
name: string;
|
||
enabled: boolean;
|
||
status: { at: string; ok: boolean; error: string | null } | null;
|
||
fresh: boolean;
|
||
state: {
|
||
workflows: { id: string; name: string; active: boolean; lastStatus: string | null; lastAt: string | null; failed24h: number }[];
|
||
/** False when the runs could not be asked: the last outcomes are then unknown. */
|
||
executionsKnown: boolean;
|
||
updatedAt: string;
|
||
} | null;
|
||
problems: { key: string; message: string; severity: "warning" | "critical" }[];
|
||
}
|
||
|
||
/** One Paperless-ngx, as its page shows it. */
|
||
export interface PaperlessInfo {
|
||
id: number;
|
||
name: string;
|
||
enabled: boolean;
|
||
status: { at: string; ok: boolean; error: string | null } | null;
|
||
fresh: boolean;
|
||
state: {
|
||
version: string | null;
|
||
latestVersion: string | null;
|
||
updateAvailable: boolean;
|
||
storage: { total: number; available: number } | null;
|
||
/** Null when the status could not be asked (it needs a superuser's token). */
|
||
components: { name: string; status: string; error: string | null }[] | null;
|
||
documents: number | null;
|
||
inbox: number | null;
|
||
/** Null when the tasks could not be asked. */
|
||
failed: { file: string; error: string | null; at: string | null }[] | null;
|
||
updatedAt: string;
|
||
} | null;
|
||
problems: { key: string; message: string; severity: "warning" | "critical" }[];
|
||
}
|
||
|
||
/** One Immich, as its page shows it. */
|
||
export interface ImmichInfo {
|
||
id: number;
|
||
name: string;
|
||
enabled: boolean;
|
||
status: { at: string; ok: boolean; error: string | null } | null;
|
||
fresh: boolean;
|
||
state: {
|
||
version: string | null;
|
||
latestVersion: string | null;
|
||
updateAvailable: boolean;
|
||
disk: { size: number; used: number; percent: number | null } | null;
|
||
photos: number | null;
|
||
videos: number | null;
|
||
usageBytes: number | null;
|
||
/** Null when the queues could not be asked. */
|
||
queues: { name: string; active: number; waiting: number; failed: number; paused: boolean }[] | null;
|
||
updatedAt: string;
|
||
} | null;
|
||
problems: { key: string; message: string; severity: "warning" | "critical" }[];
|
||
}
|
||
|
||
/** One Prometheus, as its page shows it. */
|
||
export interface PrometheusInfo {
|
||
id: number;
|
||
name: string;
|
||
enabled: boolean;
|
||
status: { at: string; ok: boolean; error: string | null } | null;
|
||
fresh: boolean;
|
||
state: {
|
||
version: string | null;
|
||
/** Null when the targets could not be asked. */
|
||
jobs: { job: string; up: number; down: number }[] | null;
|
||
down: { job: string; instance: string; error: string | null; since: string }[] | null;
|
||
alerts: { name: string; severity: string | null; state: "firing" | "pending"; summary: string | null; instance: string | null; activeAt: string | null }[] | null;
|
||
updatedAt: string;
|
||
} | null;
|
||
problems: { key: string; message: string; severity: "warning" | "critical" }[];
|
||
}
|
||
|
||
/** One Authentik, as its page shows it. */
|
||
export interface AuthentikInfo {
|
||
id: number;
|
||
name: string;
|
||
enabled: boolean;
|
||
status: { at: string; ok: boolean; error: string | null } | null;
|
||
fresh: boolean;
|
||
state: {
|
||
version: string | null;
|
||
latestVersion: string | null;
|
||
outdated: boolean;
|
||
workers: number | null;
|
||
outposts: { name: string; type: string; providers: number; healthy: number; instances: number; outdated: boolean; lastSeen: string | null }[];
|
||
certificates: { name: string; expires: string; days: number }[];
|
||
tokens: { identifier: string; intent: string; user: string | null; expires: string; days: number }[];
|
||
failedLogins24h: number | null;
|
||
configErrors24h: number | null;
|
||
lastConfigError: string | null;
|
||
updatedAt: string;
|
||
} | null;
|
||
problems: { key: string; message: string; severity: "warning" | "critical" }[];
|
||
}
|
||
|
||
export interface JellyfinHistory {
|
||
jellyfin: { id: number; name: string };
|
||
days: number;
|
||
points: { t: string; streams: number; transcodes: number }[];
|
||
}
|
||
|
||
/** A check the app could set up for you, from what it already knows. */
|
||
/** A backup job Duplicati reported, as the page shows it. */
|
||
export interface DuplicatiBackup {
|
||
id: number;
|
||
sourceId: number;
|
||
sourceName: string;
|
||
name: string;
|
||
state: "ok" | "warning" | "failed" | "stale";
|
||
/** What is wrong, in a sentence, when something is. */
|
||
problem: string | null;
|
||
lastReportAt: string | null;
|
||
lastResult: string | null;
|
||
lastSuccessAt: string | null;
|
||
durationSeconds: number | null;
|
||
examinedFiles: number | null;
|
||
sizeBytes: number | null;
|
||
addedFiles: number | null;
|
||
modifiedFiles: number | null;
|
||
deletedFiles: number | null;
|
||
warnings: number;
|
||
errors: number;
|
||
message: string | null;
|
||
consecutiveFailures: number;
|
||
expectedHours: number;
|
||
alert: boolean;
|
||
}
|
||
|
||
export interface DuplicatiSource {
|
||
id: number;
|
||
name: string;
|
||
tokenPrefix: string;
|
||
serverId: number | null;
|
||
serverName: string | null;
|
||
createdBy: string | null;
|
||
createdAt: string;
|
||
lastReportAt: string | null;
|
||
backups: number;
|
||
}
|
||
|
||
export interface DuplicatiOverview {
|
||
sources: DuplicatiSource[];
|
||
backups: DuplicatiBackup[];
|
||
servers: { id: number; name: string }[];
|
||
defaultExpectedHours: number;
|
||
}
|
||
|
||
export interface DuplicatiRun {
|
||
id: number;
|
||
at: string;
|
||
result: string;
|
||
durationSeconds: number | null;
|
||
sizeBytes: number | null;
|
||
filesChanged: number | null;
|
||
warnings: number;
|
||
errors: number;
|
||
}
|
||
|
||
export interface EndpointSuggestion {
|
||
key: string;
|
||
kind: "http" | "tls";
|
||
name: string;
|
||
target: string;
|
||
port: number | null;
|
||
serverId: number | null;
|
||
serverName: string | null;
|
||
reason: string;
|
||
/** For an app recognised from its container: what the check wants. */
|
||
checks?: string;
|
||
}
|
||
|
||
export type HeartbeatState = "off" | "waiting" | "up" | "running" | "late" | "failed";
|
||
/** A job that reports in: a cron job or backup script calls its address when it finishes. */
|
||
export interface Heartbeat {
|
||
id: number;
|
||
name: string;
|
||
periodMinutes: number;
|
||
graceMinutes: number;
|
||
serverId: number | null;
|
||
enabled: boolean;
|
||
notes: string | null;
|
||
lastPingAt: string | null;
|
||
lastStatus: "ok" | "fail" | null;
|
||
lastMessage: string | null;
|
||
lastDurationMs: number | null;
|
||
lastStartAt: string | null;
|
||
pingCount: number;
|
||
createdAt: string;
|
||
/** The address to call, without the host; only administrators are given it. */
|
||
path: string | null;
|
||
state: HeartbeatState;
|
||
/** ISO — when the next call is due by, counting the grace. */
|
||
dueBy: string;
|
||
server: { id: number; name: string } | null;
|
||
recent: { at: string; kind: "ok" | "fail"; durationMs: number | null }[];
|
||
}
|
||
export interface HeartbeatInput {
|
||
name: string;
|
||
periodMinutes: number;
|
||
graceMinutes?: number;
|
||
serverId?: number | null;
|
||
notes?: string | null;
|
||
enabled?: boolean;
|
||
}
|
||
|
||
export type AgendaKind = "secret" | "certificate" | "domain" | "tailscale" | "warranty" | "support" | "maintenance" | "restore" | "updates" | "todo" | "renewal";
|
||
|
||
/** One job on the to-do list. */
|
||
export interface TodoItem {
|
||
id: number;
|
||
title: string;
|
||
detail: string | null;
|
||
dueDate: string | null;
|
||
assignee: { id: number | null; name: string } | null;
|
||
target: { type: "server" | "device"; id: number; name: string } | null;
|
||
createdBy: string | null;
|
||
createdAt: string;
|
||
doneAt: string | null;
|
||
doneBy: string | null;
|
||
}
|
||
export interface TodoInput {
|
||
title: string;
|
||
detail?: string | null;
|
||
dueDate?: string | null;
|
||
assigneeId?: number | null;
|
||
targetType?: "server" | "device" | null;
|
||
targetId?: number | null;
|
||
}
|
||
export interface NoteItem {
|
||
targetType: "server" | "device";
|
||
targetId: number;
|
||
body: string;
|
||
updatedBy: string | null;
|
||
updatedAt: string;
|
||
}
|
||
/** A photo on a note, without its bytes (those are at `api.notePhotos.imageUrl`). */
|
||
export interface NotePhoto {
|
||
id: number;
|
||
caption: string | null;
|
||
contentType: string;
|
||
size: number;
|
||
createdBy: string | null;
|
||
createdAt: string;
|
||
}
|
||
export interface AgendaItem {
|
||
id: string;
|
||
kind: AgendaKind;
|
||
/** YYYY-MM-DD for a day; an ISO time for maintenance. */
|
||
at: string;
|
||
endsAt: string | null;
|
||
allDay: boolean;
|
||
title: string;
|
||
detail: string | null;
|
||
link: string;
|
||
serverId: number | null;
|
||
/** Whole days from today; negative once it has passed. */
|
||
daysLeft: number;
|
||
}
|
||
export interface Agenda {
|
||
generatedAt: string;
|
||
today: string;
|
||
items: AgendaItem[];
|
||
notes: string[];
|
||
}
|
||
|
||
export type ChangeKind = "servers" | "maintenance" | "alerts" | "settings" | "integrations" | "dependencies" | "inventory" | "backups" | "endpoints" | "other";
|
||
export interface ChangeEntry {
|
||
id: string;
|
||
at: string;
|
||
kind: ChangeKind;
|
||
tone: "good" | "bad" | "neutral" | "info";
|
||
title: string;
|
||
detail: string | null;
|
||
actor: string | null;
|
||
target: { type: string; id: string | null; name: string | null } | null;
|
||
link: string | null;
|
||
serverId: number | null;
|
||
}
|
||
|
||
export interface LifecycleItem {
|
||
id: number;
|
||
name: string;
|
||
kind: string;
|
||
endsOn: string;
|
||
basis: "support" | "warranty";
|
||
daysLeft: number;
|
||
cost: number | null;
|
||
costBasis: "replacement" | "purchase" | null;
|
||
}
|
||
export interface LifecycleReport {
|
||
past: LifecycleItem[];
|
||
years: { year: number; items: LifecycleItem[]; totalCost: number; unpriced: number }[];
|
||
later: LifecycleItem[];
|
||
undated: { id: number; name: string; kind: string }[];
|
||
currency: string;
|
||
}
|
||
|
||
export type AssetKind = "server" | "storage" | "network" | "power" | "client" | "other";
|
||
|
||
export type DependencyNodeType = "server" | "integration" | "device";
|
||
|
||
/** Something that would be affected if another went down (or that it needs): `distance` 1 is directly, 2 through one other, and so on. */
|
||
export interface DependencyImpactItem {
|
||
key: string;
|
||
type: DependencyNodeType;
|
||
id: number;
|
||
name: string;
|
||
distance: number;
|
||
silenced: boolean;
|
||
}
|
||
export interface DependencyImpact {
|
||
target: { key: string; type: DependencyNodeType; id: number; name: string };
|
||
dependents: DependencyImpactItem[];
|
||
needs: DependencyImpactItem[];
|
||
}
|
||
export interface DependencyGraphNode {
|
||
key: string;
|
||
type: DependencyNodeType;
|
||
id: number;
|
||
name: string;
|
||
status: "ok" | "bad" | "warn" | "unknown";
|
||
href: string;
|
||
}
|
||
export interface DependencyGraph {
|
||
nodes: DependencyGraphNode[];
|
||
/** From the thing that is needed to the thing that needs it. */
|
||
edges: { from: string; to: string; kind: "written" | "runs-on" | "uplink" }[];
|
||
}
|
||
export interface DependencyNode {
|
||
key: string;
|
||
type: DependencyNodeType;
|
||
id: number;
|
||
name: string;
|
||
}
|
||
/** A dependency the app offers to write, from what it already knows. */
|
||
export interface DependencySuggestion {
|
||
key: string;
|
||
from: { type: "integration"; id: number; name: string };
|
||
to: { type: "server"; id: number; name: string };
|
||
reason: string;
|
||
}
|
||
export interface DependencySuggestions {
|
||
suggestions: DependencySuggestion[];
|
||
dismissed: DependencySuggestion[];
|
||
}
|
||
|
||
export interface DependenciesResponse {
|
||
/** "A needs B", written here. */
|
||
dependencies: { id: number; from: { type: DependencyNodeType; id: number; name: string }; to: { type: DependencyNodeType; id: number; name: string }; createdAt: string }[];
|
||
/** The "runs on" links of servers, set on the server itself. */
|
||
runsOn: { from: { key: string; name: string }; to: { key: string; name: string } }[];
|
||
nodes: DependencyNode[];
|
||
}
|
||
|
||
/** What one person has taken on (GET /api/my-work). */
|
||
export interface MyWork {
|
||
alerts: { alertId: string; message: string; severity: string; source: string; link: string | null; note: string; role: "handed" | "acked"; ackedBy: string; ackedAt: string; until: string | null; endsSoon: boolean }[];
|
||
windows: { id: number; targetType: string; targetId: number; targetName: string; targetKind: string; reason: string | null; startedAt: string; endsAt: string; endsSoon: boolean }[];
|
||
updateRuns: { id: number; serverId: number; serverName: string; templateName: string; status: string; message: string | null; startedAt: string; finishedAt: string | null; running: boolean; updatesBefore: number | null; updatesAfter: number | null; rebootRequired: boolean }[];
|
||
/** Open jobs from the to-do list handed to this person. */
|
||
todos: { id: number; title: string; detail: string | null; dueDate: string | null; overdue: boolean; dueSoon: boolean; target: { type: string; id: number; name: string } | null }[];
|
||
needsAttention: number;
|
||
}
|
||
|
||
export type NetworkDeviceKind = "gateway" | "switch" | "access_point" | "other";
|
||
export type NetworkDeviceState = "online" | "offline" | "updating" | "pending" | "other";
|
||
|
||
/** A switch, access point or gateway read from a UniFi controller. */
|
||
export interface NetworkDevice {
|
||
id: number;
|
||
integrationId: number;
|
||
integrationName: string;
|
||
siteName: string | null;
|
||
name: string;
|
||
model: string | null;
|
||
kind: NetworkDeviceKind;
|
||
ip: string | null;
|
||
mac: string | null;
|
||
state: NetworkDeviceState;
|
||
uptimeSeconds: number | null;
|
||
firmware: string | null;
|
||
firmwareUpdatable: boolean;
|
||
/** The device it is connected through, as the controller says. */
|
||
uplink: { id: number; name: string } | null;
|
||
offlineSince: string | null;
|
||
lastOnlineAt: string | null;
|
||
updatedAt: string;
|
||
/** How many things need it (directly or through others), and how many it needs. */
|
||
dependents: number;
|
||
needs: number;
|
||
inMaintenance: boolean;
|
||
/** The servers plugged into it, as the controller says. */
|
||
servers: { serverId: number; serverName: string; port: number | null; wired: boolean }[];
|
||
}
|
||
|
||
/** A network (VLAN) or a Wi-Fi name a controller has set up. */
|
||
export interface NetworkSegment {
|
||
id: number;
|
||
integrationId: number;
|
||
integrationName: string;
|
||
externalId: string;
|
||
siteName: string | null;
|
||
name: string;
|
||
enabled: boolean;
|
||
vlanId: number | null;
|
||
subnet: string | null;
|
||
purpose: string | null;
|
||
security: string | null;
|
||
networkName: string | null;
|
||
updatedAt: string;
|
||
}
|
||
|
||
export interface UnifiSyncStatus {
|
||
/** When the controller was last read successfully. */
|
||
at: string;
|
||
ok: boolean;
|
||
error: string | null;
|
||
sites: string[];
|
||
mode: "api_key" | "login" | null;
|
||
devices: number;
|
||
networks: number;
|
||
ssids: number;
|
||
}
|
||
|
||
export interface NetworkOverview {
|
||
/** Which server is plugged into which device. */
|
||
serverLinks: { serverId: number; serverName: string; deviceId: number; deviceName: string; port: number | null; wired: boolean }[];
|
||
integrations: { id: number; name: string; enabled: boolean; status: UnifiSyncStatus | null }[];
|
||
devices: NetworkDevice[];
|
||
networks: NetworkSegment[];
|
||
ssids: NetworkSegment[];
|
||
}
|
||
|
||
export interface NpmHost {
|
||
id: number;
|
||
domains: string[];
|
||
forwardScheme: string;
|
||
forwardHost: string;
|
||
forwardPort: number | null;
|
||
enabled: boolean;
|
||
sslForced: boolean;
|
||
certificate: { id: number; name: string; expiresAt: string | null } | null;
|
||
online: boolean;
|
||
error: string | null;
|
||
/** The server the address it forwards to belongs to, when the app knows it. */
|
||
server: { id: number; name: string } | null;
|
||
}
|
||
|
||
export interface NpmCertificate {
|
||
id: number;
|
||
name: string;
|
||
provider: string;
|
||
domains: string[];
|
||
expiresAt: string | null;
|
||
}
|
||
|
||
export interface IntegrationProblem {
|
||
key: string;
|
||
kind: string;
|
||
severity: "critical" | "warning";
|
||
message: string;
|
||
}
|
||
|
||
export interface NpmOverview {
|
||
integrations: { id: number; name: string; readAt: string; error: string | null; version: string | null; hosts: NpmHost[]; certificates: NpmCertificate[]; problems: IntegrationProblem[] }[];
|
||
}
|
||
|
||
export interface HaSyncStatus {
|
||
at: string;
|
||
ok: boolean;
|
||
error: string | null;
|
||
entities: number;
|
||
}
|
||
|
||
export interface HaWatchedEntity {
|
||
entityId: string;
|
||
name: string | null;
|
||
above: number | null;
|
||
below: number | null;
|
||
entity: { friendlyName: string | null; state: string; value: number | null; unit: string | null; deviceClass: string | null; lastChanged: string | null; unavailableSince: string | null; updatedAt: string } | null;
|
||
}
|
||
|
||
/** One UPS: how it is now, what is wrong, and what is on it in the order to shut it down. */
|
||
export interface UpsInfo {
|
||
id: number;
|
||
name: string;
|
||
enabled: boolean;
|
||
protocol: "nut" | "snmp";
|
||
/** How the last read went; `at` is the last one that worked. */
|
||
status: { at: string; ok: boolean; error: string | null } | null;
|
||
/** The last good read is recent enough to be believed. */
|
||
fresh: boolean;
|
||
state: {
|
||
model: string | null;
|
||
manufacturer: string | null;
|
||
statusText: string;
|
||
onBattery: boolean;
|
||
lowBattery: boolean;
|
||
replaceBattery: boolean;
|
||
overload: boolean;
|
||
charge: number | null;
|
||
runtimeSeconds: number | null;
|
||
loadPercent: number | null;
|
||
inputVoltage: number | null;
|
||
outputVoltage: number | null;
|
||
onBatterySince: string | null;
|
||
updatedAt: string;
|
||
} | null;
|
||
problems: { key: string; kind: "battery" | "low" | "replace" | "load"; severity: "critical" | "warning"; message: string }[];
|
||
/** Everything that needs this UPS, directly or through something else; step 1 is shut down first. */
|
||
carries: { key: string; type: "server" | "integration" | "device"; id: number; name: string; step: number }[];
|
||
orderLooped: boolean;
|
||
}
|
||
|
||
export interface UpsHistory {
|
||
ups: { id: number; name: string };
|
||
days: number;
|
||
points: { t: string; charge: number | null; runtimeSeconds: number | null; loadPercent: number | null; inputVoltage: number | null; onBattery: boolean }[];
|
||
onBatteryPeriods: { from: string; to: string; ongoing: boolean }[];
|
||
}
|
||
|
||
export interface HaOverview {
|
||
integrations: { id: number; name: string; enabled: boolean; status: HaSyncStatus | null; fresh: boolean; watched: HaWatchedEntity[]; problems: IntegrationProblem[] }[];
|
||
}
|
||
|
||
export interface HaEntityChoice {
|
||
entityId: string;
|
||
name: string;
|
||
state: string;
|
||
unit: string | null;
|
||
deviceClass: string | null;
|
||
watched: boolean;
|
||
}
|
||
|
||
/** A piece of hardware in the inventory. */
|
||
export interface Asset {
|
||
id: number;
|
||
name: string;
|
||
kind: AssetKind;
|
||
manufacturer: string | null;
|
||
model: string | null;
|
||
serial: string | null;
|
||
purchaseDate: string | null;
|
||
purchasePrice: number | null;
|
||
warrantyUntil: string | null;
|
||
/** When the maker stops patching it, or you plan to retire it; the lifecycle report goes by this. */
|
||
endOfSupport: string | null;
|
||
/** What replacing it is expected to cost. */
|
||
replacementCost: number | null;
|
||
location: string | null;
|
||
rackUnit: string | null;
|
||
powerWatts: number | null;
|
||
serverId: number | null;
|
||
notes: string | null;
|
||
createdAt: string;
|
||
updatedAt: string;
|
||
/** The server it is, when it is one and that server still exists. */
|
||
server: { id: number; name: string } | null;
|
||
/** What that server's agent says the machine is, and the fields where that differs from what is written here. Null with no agent word. */
|
||
agent: { manufacturer: string | null; model: string | null; serial: string | null; differs: { manufacturer?: string; model?: string; serial?: string } } | null;
|
||
}
|
||
|
||
/** What an entry is saved from: blank text and nulls mean "no value". */
|
||
export interface AssetInput {
|
||
name: string;
|
||
kind: AssetKind;
|
||
manufacturer?: string | null;
|
||
model?: string | null;
|
||
serial?: string | null;
|
||
purchaseDate?: string | null;
|
||
purchasePrice?: number | null;
|
||
warrantyUntil?: string | null;
|
||
endOfSupport?: string | null;
|
||
replacementCost?: number | null;
|
||
location?: string | null;
|
||
rackUnit?: string | null;
|
||
powerWatts?: number | null;
|
||
serverId?: number | null;
|
||
notes?: string | null;
|
||
}
|
||
|
||
/** What the running cost is worked out with. */
|
||
export interface InventoryConfig {
|
||
currency: string;
|
||
pricePerKwh: number | null;
|
||
}
|
||
|
||
/** A note about what to do when something is wrong with a server, integration or DNS provider. */
|
||
export interface Runbook {
|
||
id: number;
|
||
targetType: MaintenanceTargetType;
|
||
targetId: number;
|
||
title: string;
|
||
body: string;
|
||
/** An alert category it is for, or null for anything about the target. */
|
||
category: AlertCategory | null;
|
||
updatedBy: string | null;
|
||
createdAt: string;
|
||
updatedAt: string;
|
||
}
|
||
|
||
/** A runbook's title and what it is for, without its text. */
|
||
export type RunbookSummary = Pick<Runbook, "id" | "targetType" | "targetId" | "category" | "title">;
|
||
|
||
/** What to do first about a kind of alert ("disk", "hetzner-cert" …), whichever server or integration it is about. */
|
||
export interface AlertKindRunbook {
|
||
kind: string;
|
||
title: string;
|
||
body: string;
|
||
/** A page to open; null when there is none. */
|
||
url: string | null;
|
||
updatedBy: string | null;
|
||
updatedAt: string;
|
||
}
|
||
|
||
export type AlertSeverity = "critical" | "warning" | "info";
|
||
export type AlertCategory = "offline" | "disk" | "services" | "backup" | "updates" | "expiry" | "automation" | "integration" | "monitoring" | "tickets";
|
||
|
||
export interface AlertItem {
|
||
id: string;
|
||
/** What kind of alert it is: the first part of its key ("disk", "hetzner-cert"). A runbook can be written for a kind. */
|
||
kind: string;
|
||
/** The kind of source it is about: an integration's type, "server" … */
|
||
type: string;
|
||
severity: AlertSeverity;
|
||
category: AlertCategory;
|
||
source: string;
|
||
message: string;
|
||
link: string | null;
|
||
/** Under a maintenance window: still a real problem, but its notifications are held back. */
|
||
silenced: boolean;
|
||
/** What a maintenance window would go on to silence it — what the Silence button acts on. Null when nothing can silence it. */
|
||
target?: { type: MaintenanceTargetType; id: number; name: string } | null;
|
||
/** Held back because another problem explains it (a guest down because its host is): the host's alert says so too. */
|
||
causedBy?: { name: string; alertId?: string };
|
||
/** On a host's alert: the servers on it whose own alerts are folded under this one. */
|
||
affects?: string[];
|
||
/** The osTicket ticket opened for it, if one was. */
|
||
ticket?: { number: string | null; url: string | null; grouped: boolean; openedAt: string | null; closedAt: string | null; canClose: boolean } | null;
|
||
/** Somebody has said they are on it. */
|
||
ack?: AlertAck | null;
|
||
/** The incident record this alert is part of, while it lasts. */
|
||
incidentId?: number | null;
|
||
/** Raised and cleared over and over: its raised/cleared messages are being held back. */
|
||
flapping?: boolean;
|
||
/** Snoozed until then: hidden like one under maintenance, and announced again if it is still there. */
|
||
snoozed?: { until: string; by: string };
|
||
/** Closed by somebody: hidden with no end, until it gets worse or has been gone for half an hour. */
|
||
closed?: { by: string; at: string; note: string | null };
|
||
}
|
||
|
||
export type AlertRuleMetric = "cpu" | "mem" | "disk" | "disk_temp";
|
||
|
||
export interface AlertRule {
|
||
id: number;
|
||
name: string;
|
||
enabled: boolean;
|
||
metric: AlertRuleMetric;
|
||
mount: string | null;
|
||
operator: "above" | "below";
|
||
threshold: number;
|
||
forMinutes: number;
|
||
severity: "warning" | "critical";
|
||
serverId: number | null;
|
||
serverName: string | null;
|
||
tag: string | null;
|
||
createdBy: string | null;
|
||
createdAt: string;
|
||
/** Where it is raised right now. */
|
||
firing: { serverId: number; serverName: string; detail: string | null; value: number; since: string | null }[];
|
||
}
|
||
|
||
export interface AlertRuleInput {
|
||
name: string;
|
||
enabled?: boolean;
|
||
metric: AlertRuleMetric;
|
||
mount?: string | null;
|
||
operator?: "above" | "below";
|
||
threshold: number;
|
||
forMinutes?: number;
|
||
severity?: "warning" | "critical";
|
||
serverId?: number | null;
|
||
tag?: string | null;
|
||
}
|
||
|
||
export interface StoragePool {
|
||
seriesId: number;
|
||
integrationId: number;
|
||
key: string;
|
||
label: string;
|
||
latest: number;
|
||
usedBytes: number | null;
|
||
totalBytes: number | null;
|
||
updatedAt: string;
|
||
trend: { perDay: number; daysToFull: number | null; fit: number; spanDays: number } | null;
|
||
/** Enough history and a straight enough climb to believe the trend. */
|
||
steady: boolean;
|
||
}
|
||
|
||
/** What a bulk action did: how many it changed, what it left alone and why, and the body that puts it back (to send to the same address). */
|
||
export interface BulkResult {
|
||
changed: number;
|
||
skipped: { id: string | number; name: string; reason: string }[];
|
||
undo: Record<string, unknown> | null;
|
||
silenced?: { type: string; id: number; name: string }[];
|
||
/** Closing several alerts with "also close their osTicket tickets": how the tickets went (not undone by Undo). */
|
||
tickets?: { closed: number; alreadyClosed: number; failed: { alertId: string; number: string | null; message: string }[]; notClosable: number } | null;
|
||
}
|
||
|
||
/** One alert that fires often, from the incident record. */
|
||
export interface NoiseRow {
|
||
alertId: string;
|
||
message: string;
|
||
category: AlertCategory;
|
||
source: string;
|
||
where: string;
|
||
fired: number;
|
||
totalMinutes: number;
|
||
averageMinutes: number;
|
||
longestMinutes: number;
|
||
mostInAnHour: number;
|
||
flapped: boolean;
|
||
flappingNow: boolean;
|
||
openNow: boolean;
|
||
lastAt: string;
|
||
link: string | null;
|
||
hint: string;
|
||
}
|
||
export interface NoiseReport {
|
||
days: number;
|
||
from: string;
|
||
to: string;
|
||
incidents: number;
|
||
distinctAlerts: number;
|
||
repeating: number;
|
||
flapped: number;
|
||
totalMinutes: number;
|
||
byCategory: { category: string; incidents: number; repeating: number }[];
|
||
rows: NoiseRow[];
|
||
}
|
||
|
||
export interface AlertAck {
|
||
note: string;
|
||
assignee: { id: number | null; name: string } | null;
|
||
ackedBy: string;
|
||
ackedAt: string;
|
||
/** ISO — when it runs out; null means it lasts until the alert is gone. */
|
||
until: string | null;
|
||
/** Still in force. */
|
||
active: boolean;
|
||
}
|
||
|
||
export interface AckInput {
|
||
alertId: string;
|
||
note: string;
|
||
assigneeId: number | null;
|
||
/** How long it lasts; null is until the alert is gone. */
|
||
hours: number | null;
|
||
}
|
||
|
||
export type TimelineKind = "alert" | "ack" | "maintenance" | "change" | "health" | "run" | "related" | "note";
|
||
|
||
export interface TimelineEvent {
|
||
at: string;
|
||
kind: TimelineKind;
|
||
tone: "good" | "bad" | "neutral" | "info";
|
||
title: string;
|
||
detail: string | null;
|
||
actor: string | null;
|
||
incidentId?: number;
|
||
noteId?: number;
|
||
}
|
||
|
||
export interface IncidentSummary {
|
||
id: number;
|
||
alertKey: string;
|
||
severity: string;
|
||
peakSeverity: string;
|
||
category: AlertCategory;
|
||
source: string;
|
||
message: string;
|
||
link: string | null;
|
||
target: { type: MaintenanceTargetType; id: number; name: string } | null;
|
||
causedBy: string | null;
|
||
openedAt: string;
|
||
resolvedAt: string | null;
|
||
durationMs: number;
|
||
open: boolean;
|
||
notes: number;
|
||
}
|
||
|
||
export interface BeforeSuspect {
|
||
at: string;
|
||
minutesBefore: number;
|
||
kind: "maintenance" | "update" | "alert" | "change" | "settings" | "metric" | "rule";
|
||
title: string;
|
||
detail: string | null;
|
||
actor: string | null;
|
||
relation: "same" | "needs" | "needed_by" | "everything" | "other";
|
||
about: string;
|
||
why: string;
|
||
score: number;
|
||
confidence: "likely" | "possible" | "background";
|
||
link: string | null;
|
||
incidentId?: number;
|
||
}
|
||
|
||
export interface BeforeReport {
|
||
incidentId: number;
|
||
openedAt: string;
|
||
windowMinutes: number;
|
||
from: string;
|
||
to: string;
|
||
suspects: BeforeSuspect[];
|
||
looked: { auditEntries: number; maintenanceWindows: number; updateRuns: number; otherAlerts: number; series: number };
|
||
}
|
||
|
||
export interface IncidentDetail {
|
||
incident: IncidentSummary;
|
||
ack: AlertAck | null;
|
||
timeline: TimelineEvent[];
|
||
notes: { id: number; author: string; body: string; at: string }[];
|
||
}
|
||
|
||
export type AlertTicketSeverity = "critical" | "warning" | "info";
|
||
|
||
export interface AlertTicketSettings {
|
||
enabled: boolean;
|
||
integrationId: number | null;
|
||
severities: AlertTicketSeverity[];
|
||
categories: string[];
|
||
requesterName: string;
|
||
requesterEmail: string;
|
||
topicId: number | null;
|
||
priorityId: number | null;
|
||
notifyStaff: boolean;
|
||
existingProblems: "ignore" | "ticket";
|
||
confirmChecks: number;
|
||
summaryAbove: number;
|
||
reopenAfterMinutes: number;
|
||
}
|
||
|
||
export interface AlertTicketRunSummary {
|
||
at: string;
|
||
skipped?: "disabled" | "busy";
|
||
error?: string;
|
||
ticketsOpened: number;
|
||
alertsCovered: number;
|
||
baseline: number;
|
||
pending: number;
|
||
cleared: number;
|
||
failed: number;
|
||
}
|
||
|
||
export interface AlertTicketOverview {
|
||
settings: AlertTicketSettings;
|
||
integrations: { id: number; name: string; enabled: boolean; ticketApiReady: boolean; /** A login for closing tickets is set. */ closeReady: boolean }[];
|
||
categories: { value: string; label: string }[];
|
||
status: { lastRun: AlertTicketRunSummary | null; open: number; pending: number; baseline: number; baselinePending: boolean };
|
||
}
|
||
|
||
export type DbSnapshotKind = "scheduled" | "manual" | "pre-restore" | "uploaded";
|
||
|
||
export interface DbSnapshot {
|
||
name: string;
|
||
kind: DbSnapshotKind;
|
||
sizeBytes: number;
|
||
at: string;
|
||
}
|
||
|
||
export interface DbSnapshotCheck {
|
||
ok: boolean;
|
||
integrity: string | null;
|
||
migrations: number | null;
|
||
appMigrations: number;
|
||
newerThanApp: boolean;
|
||
counts: { users: number; servers: number; integrations: number } | null;
|
||
problem: string | null;
|
||
}
|
||
|
||
export interface DbBackupSettings {
|
||
enabled: boolean;
|
||
time: string;
|
||
keep: number;
|
||
}
|
||
|
||
export interface DbStagedRestore {
|
||
from: string;
|
||
stagedAt: string;
|
||
by: string | null;
|
||
}
|
||
|
||
export interface DbBackupsOverview {
|
||
settings: DbBackupSettings;
|
||
snapshots: DbSnapshot[];
|
||
staged: DbStagedRestore | null;
|
||
lastRestore: { restoredAt: string; from: string; keptAs: string | null; by: string | null } | null;
|
||
lastAttempt: { at: string; ok: boolean; kind: DbSnapshotKind; error: string | null; name: string | null } | null;
|
||
nextRun: string | null;
|
||
folder: string;
|
||
}
|
||
|
||
export interface AlertsReport {
|
||
alerts: AlertItem[];
|
||
counts: {
|
||
critical: number;
|
||
warning: number;
|
||
info: number;
|
||
silenced: number;
|
||
grouped: number;
|
||
/** Alerts somebody has acknowledged (and that aren't silenced). */
|
||
acknowledged?: number;
|
||
/** What still needs somebody to look: the counts above, less what has been acknowledged. */
|
||
attention?: { critical: number; warning: number };
|
||
};
|
||
couldntCheck: { name: string; error: string; affects: string[] }[];
|
||
notes: string[];
|
||
generatedAt: string;
|
||
/** This is a recent result being reused, not a fresh check. */
|
||
cached: boolean;
|
||
}
|
||
|
||
export interface AdminLink {
|
||
id: number;
|
||
serverId: number;
|
||
serverName: string;
|
||
serverHostname: string | null;
|
||
label: string;
|
||
url: string;
|
||
}
|
||
|
||
export interface PortEntry {
|
||
/** Null for a port only known from the agent that has no note yet. */
|
||
id: number | null;
|
||
port: number;
|
||
protocol: "tcp" | "udp";
|
||
label: string | null;
|
||
comment: string | null;
|
||
/** The last scan from this app connected to it. */
|
||
scanOpen: boolean;
|
||
lastSeenOpenAt: string | null;
|
||
agent: { addresses: string[]; process: string | null; localOnly: boolean } | null;
|
||
state: "open" | "reserved";
|
||
/** Began listening after the first report and nobody has noted it: a "new port" alert is on. */
|
||
isNew: boolean;
|
||
}
|
||
|
||
export interface PortScanSummary {
|
||
at: string;
|
||
address: string;
|
||
from: number;
|
||
to: number;
|
||
open: number;
|
||
refused: number;
|
||
filtered: number;
|
||
responded: boolean;
|
||
}
|
||
|
||
export interface PortList {
|
||
ports: PortEntry[];
|
||
agentReporting: boolean;
|
||
agentReportedAt: string | null;
|
||
lastScan: PortScanSummary | null;
|
||
}
|
||
|
||
export interface PortScanResult extends Omit<PortList, "lastScan"> {
|
||
scan: PortScanSummary;
|
||
freeCount: number;
|
||
freeRanges: [number, number][];
|
||
}
|
||
|
||
export interface ServerUpdateInput {
|
||
name?: string;
|
||
hostname?: string;
|
||
description?: string;
|
||
proxmoxIntegrationId?: number | null;
|
||
proxmoxNode?: string | null;
|
||
proxmoxGuestType?: "qemu" | "lxc" | null;
|
||
proxmoxVmid?: number | null;
|
||
hideProxmoxLink?: boolean;
|
||
/** The server this one runs on; null goes back to working it out from the Proxmox node. */
|
||
parentServerId?: number | null;
|
||
/** True says it runs on nothing, which stops the guess from its Proxmox node. */
|
||
noParent?: boolean;
|
||
/** Its own alert limits; null goes back to following Settings. */
|
||
thresholds?: ServerThresholds | null;
|
||
}
|
||
|
||
/** A maintenance that repeats: "every Sunday 02:00–04:00 on these servers". */
|
||
export interface MaintenanceSchedule {
|
||
id: number;
|
||
name: string;
|
||
reason: string | null;
|
||
/** 0 = Sunday … 6 = Saturday. */
|
||
days: number[];
|
||
startTime: string;
|
||
durationMinutes: number;
|
||
timezone: string;
|
||
enabled: boolean;
|
||
createdBy: string | null;
|
||
targets: { type: MaintenanceTargetType; id: number; name: string; kind: string }[];
|
||
nextStart: string | null;
|
||
}
|
||
|
||
export interface MaintenanceScheduleInput {
|
||
name: string;
|
||
reason?: string;
|
||
targets: { type: MaintenanceTargetType; id: number }[];
|
||
days: number[];
|
||
startTime: string;
|
||
durationMinutes: number;
|
||
timezone: string;
|
||
}
|
||
|
||
export type ScheduleType = "cron" | "systemd_timer" | "windows_task" | "docker" | "backup" | "update" | "n8n_workflow" | "manual";
|
||
|
||
export interface TaskRecord {
|
||
id: number;
|
||
serverId: number;
|
||
serverName: string;
|
||
scheduleType: ScheduleType;
|
||
origin: "agent" | "manual";
|
||
name: string;
|
||
command: string | null;
|
||
scheduleExpression: string | null;
|
||
source: string | null;
|
||
enabled: boolean;
|
||
nextRunAt: string | null;
|
||
isStale: boolean;
|
||
firstSeenAt: string;
|
||
lastSeenAt: string;
|
||
}
|
||
|
||
export interface ManualTaskInput {
|
||
serverId: number;
|
||
scheduleType: ScheduleType;
|
||
name: string;
|
||
command?: string;
|
||
scheduleExpression?: string;
|
||
nextRunAt?: string;
|
||
enabled?: boolean;
|
||
}
|
||
|
||
export type IntegrationType = "proxmox" | "synology" | "semaphore" | "tailscale" | "gitea" | "dockhand" | "uptimekuma" | "phpipam" | "pbs" | "osticket" | "unifi" | "npm" | "homeassistant" | "ups" | "jellyfin" | "authentik" | "prometheus" | "immich" | "paperless" | "nextcloud" | "netbox" | "n8n" | "hetzner" | "speedtest" | "fragnet" | "sonarr" | "radarr" | "prowlarr" | "adguard" | "grafana";
|
||
|
||
export interface IntegrationField {
|
||
key: string;
|
||
label: string;
|
||
secret: boolean;
|
||
type?: "text" | "password" | "checkbox";
|
||
placeholder?: string;
|
||
optional?: boolean;
|
||
}
|
||
|
||
export interface IntegrationSummary {
|
||
id: number;
|
||
type: IntegrationType;
|
||
name: string;
|
||
baseUrl: string;
|
||
enabled: boolean;
|
||
createdAt: string;
|
||
/** How its latest calls have gone since the app started. Only present on the integrations list. */
|
||
health?: { status: "ok" | "failing" | "unknown" | "disabled"; consecutiveFailures: number };
|
||
}
|
||
|
||
export interface TailscaleDevice {
|
||
id: string;
|
||
nodeId: string;
|
||
hostname: string;
|
||
label: string;
|
||
addresses: string[];
|
||
primaryAddress: string;
|
||
os: string;
|
||
lastSeen: string | null;
|
||
isExitNode: boolean;
|
||
authorized: boolean;
|
||
online: boolean;
|
||
keyExpiry: string | null;
|
||
keyExpiryDisabled: boolean;
|
||
}
|
||
|
||
export interface TailscaleDevicesResponse {
|
||
devices: TailscaleDevice[];
|
||
summary: { total: number; online: number; unauthorized: number; expiringSoon: number };
|
||
}
|
||
|
||
export interface GiteaWorkflowRun {
|
||
id: number;
|
||
displayTitle: string;
|
||
status: string;
|
||
conclusion: string | null;
|
||
headBranch: string;
|
||
event: string;
|
||
runNumber: number;
|
||
htmlUrl: string;
|
||
startedAt: string | null;
|
||
completedAt: string | null;
|
||
}
|
||
|
||
export interface GiteaRepo {
|
||
owner: string;
|
||
name: string;
|
||
fullName: string;
|
||
htmlUrl: string;
|
||
private: boolean;
|
||
hasActions: boolean;
|
||
updatedAt: string;
|
||
latestRun: GiteaWorkflowRun | null;
|
||
}
|
||
|
||
export interface DomainRecord {
|
||
id: number;
|
||
name: string;
|
||
origin: "manual" | "zone";
|
||
expiresAt: string | null;
|
||
registrar: string | null;
|
||
lookupSource: "rdap" | "whois" | null;
|
||
lastCheckedAt: string | null;
|
||
lastCheckedOkAt: string | null;
|
||
lastCheckError: string | null;
|
||
createdAt: string;
|
||
status: "ok" | "expiring" | "expired" | "unknown";
|
||
daysLeft: number | null;
|
||
}
|
||
|
||
export interface DomainList {
|
||
domains: DomainRecord[];
|
||
warnDays: number;
|
||
checking: boolean;
|
||
}
|
||
|
||
export type ConsistencyKind = "ip_conflict" | "dns_stale" | "ipam_stale" | "not_in_ipam" | "no_dns";
|
||
export type ConsistencySeverity = "error" | "warning" | "info";
|
||
|
||
export interface ConsistencyFinding {
|
||
key: string;
|
||
kind: ConsistencyKind;
|
||
severity: ConsistencySeverity;
|
||
title: string;
|
||
detail: string;
|
||
ip: string | null;
|
||
servers: { id: number; name: string }[];
|
||
dnsNames: string[];
|
||
suggestedLabel: string | null;
|
||
}
|
||
|
||
export interface ConsistencyIgnore {
|
||
id: number;
|
||
key: string;
|
||
title: string;
|
||
reason: string | null;
|
||
createdBy: string | null;
|
||
createdAt: string;
|
||
stillPresent: boolean;
|
||
}
|
||
|
||
export interface ConsistencyReport {
|
||
findings: ConsistencyFinding[];
|
||
counts: Record<ConsistencySeverity, number>;
|
||
ignored: ConsistencyIgnore[];
|
||
excludedRanges: string[];
|
||
hiddenAddresses: number;
|
||
sources: {
|
||
servers: { total: number; withAddresses: number };
|
||
ipam: number;
|
||
dns: { zones: number; syncedZones: number; records: number; oldestSyncedAt: string | null; newestSyncedAt: string | null };
|
||
};
|
||
generatedAt: string;
|
||
}
|
||
|
||
export interface PrivacyOverview {
|
||
me: {
|
||
user: { email: string | null; name: string | null; role: UserRole; subject: string; createdAt: string; lastLoginAt: string | null };
|
||
auditEntries: number;
|
||
sessions: { ip: string | null; userAgent: string | null; lastAccess: string; expiresAt: string | null; current: boolean }[];
|
||
};
|
||
retention: { enabled: boolean; retentionDays: number; intervalHours: number };
|
||
outbound: {
|
||
integrationTypes: string[];
|
||
dnsProviderTypes: string[];
|
||
domainsTracked: number;
|
||
tlsCertificateChecks: number;
|
||
servers: number;
|
||
serversWithAgent: number;
|
||
profilePictures: ProfilePictureSettings & { identityProviderHost: string | null };
|
||
channels: Record<"gotify" | "ntfy" | "smtp" | "webhook" | "webPush", { enabled: boolean; host: string | null }>;
|
||
};
|
||
}
|
||
|
||
export interface NameThemeSource {
|
||
kind: "skatteverket";
|
||
sex: "girls" | "boys";
|
||
years: number[];
|
||
count: number;
|
||
importedAt: string;
|
||
}
|
||
|
||
export interface NameTheme {
|
||
id: string;
|
||
label: string;
|
||
names: string[];
|
||
lastImport?: NameThemeSource;
|
||
}
|
||
|
||
export interface NameImportPreview {
|
||
names: string[];
|
||
source: NameThemeSource;
|
||
missingYears: number[];
|
||
skipped: string[];
|
||
}
|
||
|
||
export interface TagEntry {
|
||
name: string;
|
||
/** "#rrggbb", or null for the automatic colour. */
|
||
color: string | null;
|
||
/** Servers currently carrying it. */
|
||
count: number;
|
||
}
|
||
|
||
export interface ServerSummary {
|
||
total: number;
|
||
online: number;
|
||
offline: { id: number; name: string; lastSeenAt: string; inMaintenance: boolean }[];
|
||
noData: number;
|
||
byOs: { linux: number; windows: number };
|
||
fullDisks: { id: number; name: string; mount: string; percent: number }[];
|
||
thresholds: { offlineMinutes: number; diskPercent: number };
|
||
}
|
||
|
||
export interface DockhandContainer {
|
||
id: string;
|
||
name: string;
|
||
image: string;
|
||
state: string;
|
||
status: string;
|
||
environmentId: number;
|
||
environmentName: string;
|
||
updateAvailable: boolean | null;
|
||
newerVersion: string | null;
|
||
checkedAt: string | null;
|
||
/** What is wrong with it, as the health pass would say it; null when nothing is. */
|
||
problem?: { kind: "restarting" | "unhealthy" | "stopped" | "created"; text: string; severity: "critical" | "warning" } | null;
|
||
/** It is on the list of containers to leave alone, so nothing is alerted about it. */
|
||
leftAlone?: boolean;
|
||
}
|
||
|
||
export interface DockhandVulnFinding {
|
||
cve: string;
|
||
severity: string;
|
||
package: string | null;
|
||
installedVersion: string | null;
|
||
fixedVersion: string | null;
|
||
imageName: string;
|
||
containers: string[];
|
||
}
|
||
|
||
export interface DockhandVulnerabilityEnvironment {
|
||
environmentId: number;
|
||
environmentName: string;
|
||
critical: number | null;
|
||
high: number | null;
|
||
medium: number | null;
|
||
low: number | null;
|
||
imagesScanned: number | null;
|
||
totalImages: number | null;
|
||
/** The critical findings (at most 100). */
|
||
findings: DockhandVulnFinding[];
|
||
/** The images its running containers use by age; null when they were never read. `over` is how many are older than the setting (null while it is off). */
|
||
images: { at: string | null; running: number; undated: number; over: number | null; oldest: { image: string; ageDays: number; containers: string[] }[] } | null;
|
||
updatedAt: string;
|
||
}
|
||
|
||
export interface DockhandVulnerabilitiesResponse {
|
||
/** Whether critical findings are alerted (Settings → Notifications). */
|
||
alerts: boolean;
|
||
/** A host with at least this many high findings is alerted too; 0 = never. */
|
||
highThreshold: number;
|
||
/** Running images older than this many days are alerted; 0 = off. */
|
||
imageAgeDays: number;
|
||
status: { at: string; ok: boolean; error: string | null } | null;
|
||
fresh: boolean;
|
||
environments: DockhandVulnerabilityEnvironment[];
|
||
}
|
||
|
||
export interface DockhandContainersResponse {
|
||
/** Docker hosts Dockhand could not read this time. */
|
||
unreachable?: { environmentId: number; environmentName: string; error: string }[];
|
||
/** Container alerts are switched on. */
|
||
alerts?: boolean;
|
||
containers: DockhandContainer[];
|
||
summary: { total: number; running: number };
|
||
}
|
||
|
||
export type UptimeKumaMonitorStatus = "up" | "down" | "pending" | "maintenance" | "unknown";
|
||
|
||
export interface UptimeKumaMonitor {
|
||
id: string;
|
||
name: string;
|
||
type: string;
|
||
target: string | null;
|
||
port: number | null;
|
||
status: UptimeKumaMonitorStatus;
|
||
responseTimeMs: number | null;
|
||
certDaysRemaining: number | null;
|
||
uptime24h: number | null;
|
||
uptime30d: number | null;
|
||
uptime1y: number | null;
|
||
matchedServer: { id: number; name: string } | null;
|
||
}
|
||
|
||
export interface UptimeKumaMonitorsResponse {
|
||
monitors: UptimeKumaMonitor[];
|
||
summary: { total: number; up: number; down: number; pending: number; maintenance: number; unknown: number };
|
||
}
|
||
|
||
export interface UptimeKumaSyncResult {
|
||
maintenances: {
|
||
id: number;
|
||
title: string;
|
||
strategy: string;
|
||
status: string;
|
||
monitorCount: number;
|
||
slots: { start: string; end: string }[];
|
||
targets: { type: MaintenanceTargetType; name: string }[];
|
||
unmatched: string[];
|
||
/** Why it produced no window, when it did not. */
|
||
note: string | null;
|
||
}[];
|
||
started: number;
|
||
updated: number;
|
||
removed: number;
|
||
}
|
||
|
||
export interface UptimeKumaImportResult {
|
||
imported: { serverId: number; serverName: string; monitorName: string; extended: boolean }[];
|
||
unmatched: string[];
|
||
monitorsInMaintenance: number;
|
||
/** How many monitors Uptime Kuma reported in all, so "nothing in maintenance" can be told apart from "nothing read". */
|
||
monitorsChecked: number;
|
||
}
|
||
|
||
export interface PbsFailedSnapshot {
|
||
backupType: string;
|
||
backupId: string;
|
||
backupTime: number;
|
||
}
|
||
|
||
export interface PbsDatastore {
|
||
name: string;
|
||
comment: string | null;
|
||
totalBytes: number | null;
|
||
usedBytes: number | null;
|
||
availBytes: number | null;
|
||
error: string | null;
|
||
snapshotCount: number;
|
||
failedCount: number;
|
||
unverifiedCount: number;
|
||
latestSnapshotAt: number | null;
|
||
recentFailures: PbsFailedSnapshot[];
|
||
}
|
||
|
||
export interface PbsDatastoresResponse {
|
||
datastores: PbsDatastore[];
|
||
summary: { datastoreCount: number; failedSnapshotCount: number; unverifiedSnapshotCount: number };
|
||
}
|
||
|
||
export interface PbsNodeStatus {
|
||
cpuUsagePercent: number | null;
|
||
cpuCores: number | null;
|
||
memTotalBytes: number | null;
|
||
memUsedBytes: number | null;
|
||
rootfsTotalBytes: number | null;
|
||
rootfsUsedBytes: number | null;
|
||
uptime: number | null;
|
||
}
|
||
|
||
export interface OsTicketTicket {
|
||
ticketId: number;
|
||
number: string;
|
||
subject: string | null;
|
||
statusName: string;
|
||
priorityName: string | null;
|
||
priorityColor: string | null;
|
||
departmentName: string | null;
|
||
staffName: string | null;
|
||
teamName: string | null;
|
||
requesterName: string | null;
|
||
requesterEmail: string | null;
|
||
source: string | null;
|
||
isOverdue: boolean;
|
||
isAnswered: boolean;
|
||
createdAt: string;
|
||
lastActivityAt: string | null;
|
||
dueAt: string | null;
|
||
}
|
||
|
||
export interface OsTicketTicketsResponse {
|
||
tickets: OsTicketTicket[];
|
||
summary: { total: number; overdue: number; awaitingReply: number };
|
||
}
|
||
|
||
export type SemaphoreTaskStatus =
|
||
| "waiting"
|
||
| "starting"
|
||
| "waiting_confirmation"
|
||
| "confirmed"
|
||
| "rejected"
|
||
| "running"
|
||
| "stopping"
|
||
| "stopped"
|
||
| "success"
|
||
| "error";
|
||
|
||
export interface SemaphoreTask {
|
||
id: number;
|
||
status: SemaphoreTaskStatus;
|
||
created: string | null;
|
||
start: string | null;
|
||
end: string | null;
|
||
}
|
||
|
||
export interface SemaphoreTemplate {
|
||
id: number;
|
||
projectId: number;
|
||
projectName: string;
|
||
name: string;
|
||
playbook: string;
|
||
lastTask: SemaphoreTask | null;
|
||
}
|
||
|
||
export interface SemaphoreTemplatesResponse {
|
||
templates: SemaphoreTemplate[];
|
||
summary: { total: number; failing: number };
|
||
}
|
||
|
||
export type ProxmoxGuestType = "qemu" | "lxc";
|
||
|
||
export interface ProxmoxGuest {
|
||
vmid: number;
|
||
name: string;
|
||
node: string;
|
||
type: ProxmoxGuestType;
|
||
status: string;
|
||
cpu: number | null;
|
||
maxmem: number | null;
|
||
mem: number | null;
|
||
uptime: number | null;
|
||
}
|
||
|
||
export interface ProxmoxGuestsResponse {
|
||
guests: ProxmoxGuest[];
|
||
summary: { total: number; running: number };
|
||
}
|
||
|
||
export interface ProxmoxStorage {
|
||
id: string;
|
||
type: string;
|
||
active: boolean;
|
||
shared: boolean;
|
||
totalBytes: number | null;
|
||
usedBytes: number | null;
|
||
availBytes: number | null;
|
||
}
|
||
|
||
export interface ProxmoxNodeStats {
|
||
node: string;
|
||
error: string | null;
|
||
uptime: number | null;
|
||
cpuUsagePercent: number | null;
|
||
cpuCores: number | null;
|
||
loadAverage: [number, number, number] | null;
|
||
memTotalBytes: number | null;
|
||
memUsedBytes: number | null;
|
||
swapTotalBytes: number | null;
|
||
swapUsedBytes: number | null;
|
||
rootfsTotalBytes: number | null;
|
||
rootfsUsedBytes: number | null;
|
||
pveVersion: string | null;
|
||
storages: ProxmoxStorage[];
|
||
}
|
||
|
||
export interface ProxmoxNodesResponse {
|
||
nodes: ProxmoxNodeStats[];
|
||
}
|
||
|
||
export interface ProxmoxBackupJob {
|
||
id: string;
|
||
enabled: boolean;
|
||
schedule: string;
|
||
storage: string;
|
||
node: string | null;
|
||
allGuests: boolean;
|
||
vmids: string | null;
|
||
exclude: string | null;
|
||
}
|
||
|
||
export interface ProxmoxBackupTask {
|
||
node: string;
|
||
upid: string;
|
||
guestId: string | null;
|
||
status: string;
|
||
ok: boolean;
|
||
startTime: string;
|
||
endTime: string | null;
|
||
}
|
||
|
||
export interface ProxmoxBackupsResponse {
|
||
jobs: ProxmoxBackupJob[];
|
||
tasks: ProxmoxBackupTask[];
|
||
uncoveredGuests: ProxmoxGuest[];
|
||
}
|
||
|
||
export interface SynologyVolume {
|
||
id: string;
|
||
status: string;
|
||
deviceType: string;
|
||
sizeTotal: number | null;
|
||
sizeUsed: number | null;
|
||
}
|
||
|
||
export interface SynologyDisk {
|
||
id: string;
|
||
name: string;
|
||
device: string;
|
||
status: string;
|
||
smartStatus: string;
|
||
temp: number | null;
|
||
exceedBadSectorThreshold: boolean;
|
||
belowRemainLifeThreshold: boolean;
|
||
}
|
||
|
||
export interface SynologyStorageResponse {
|
||
volumes: SynologyVolume[];
|
||
disks: SynologyDisk[];
|
||
summary: { volumeCount: number; volumesNotNormal: number; diskCount: number; disksNotNormal: number };
|
||
}
|
||
|
||
export interface SynologySystemInfo {
|
||
hostname: string | null;
|
||
model: string | null;
|
||
serial: string | null;
|
||
firmwareVersion: string | null;
|
||
uptime: string | null;
|
||
ipAddresses: string[];
|
||
cpu: { cores: number | null; clockSpeedMHz: number | null; loadPercent: number | null };
|
||
memory: { totalBytes: number | null; usedBytes: number | null };
|
||
}
|
||
|
||
export interface SearchResponse {
|
||
servers: { id: number; name: string; hostname: string | null }[];
|
||
secrets: { id: number; name: string; type: SecretType }[];
|
||
ipam: { id: number; ipAddress: string; label: string | null }[];
|
||
integrations: { id: number; type: IntegrationType; name: string }[];
|
||
dnsProviders: { id: number; providerType: DnsProviderType; name: string }[];
|
||
dnsZones: { providerId: number; zoneId: string; zoneName: string; providerName: string }[];
|
||
dnsRecords: {
|
||
providerId: number;
|
||
zoneId: string;
|
||
zoneName: string;
|
||
type: string;
|
||
name: string;
|
||
content: string;
|
||
providerName: string;
|
||
}[];
|
||
}
|
||
|
||
export class UnauthorizedError extends Error {}
|
||
export class ForbiddenError extends Error {}
|
||
|
||
async function request<T>(path: string, init?: RequestInit): Promise<T> {
|
||
const res = await fetch(path, {
|
||
...init,
|
||
headers: { "Content-Type": "application/json", ...(init?.headers ?? {}) },
|
||
credentials: "same-origin",
|
||
});
|
||
if (res.status === 401) {
|
||
throw new UnauthorizedError("unauthorized");
|
||
}
|
||
if (res.status === 403) {
|
||
throw new ForbiddenError("forbidden");
|
||
}
|
||
if (!res.ok) {
|
||
const body = await res.text().catch(() => "");
|
||
throw new Error(`Request failed (${res.status}): ${body}`);
|
||
}
|
||
if (res.status === 204) return undefined as T;
|
||
return (await res.json()) as T;
|
||
}
|
||
|
||
export const api = {
|
||
me: Object.assign(() => request<{ user: CurrentUser }>("/api/me"), {
|
||
setFavorites: (paths: string[]) => request<{ favorites: string[] }>("/api/me/favorites", { method: "PUT", body: JSON.stringify({ paths }) }),
|
||
setServerPage: (layout: PageLayout) => request<{ serverPage: PageLayout }>("/api/me/server-page", { method: "PUT", body: JSON.stringify(layout) }),
|
||
setDashboard: (layout: DashboardLayout) => request<{ dashboard: DashboardLayout }>("/api/me/dashboard", { method: "PUT", body: JSON.stringify(layout) }),
|
||
changes: () => request<ChangesSummary>("/api/me/changes"),
|
||
markChangesSeen: () => request<{ lastLookedAt: string }>("/api/me/changes/seen", { method: "POST" }),
|
||
}),
|
||
uptime: {
|
||
get: (days?: number) => request<UptimeReport>(days ? `/api/uptime?days=${days}` : "/api/uptime"),
|
||
},
|
||
apiTokens: {
|
||
list: () => request<{ tokens: ApiToken[]; max: number; expiryChoices: number[] }>("/api/me/tokens"),
|
||
create: (data: { label: string; expiresInDays: number | null }) => request<{ token: ApiToken; secret: string }>("/api/me/tokens", { method: "POST", body: JSON.stringify(data) }),
|
||
remove: (id: number) => request<void>(`/api/me/tokens/${id}`, { method: "DELETE" }),
|
||
},
|
||
metricsTokens: {
|
||
list: () => request<{ tokens: MetricsToken[] }>("/api/metrics-tokens"),
|
||
create: (label: string) => request<{ token: MetricsToken; secret: string }>("/api/metrics-tokens", { method: "POST", body: JSON.stringify({ label }) }),
|
||
remove: (id: number) => request<void>(`/api/metrics-tokens/${id}`, { method: "DELETE" }),
|
||
},
|
||
duplicati: {
|
||
overview: () => request<DuplicatiOverview>("/api/duplicati"),
|
||
runs: (backupId: number) => request<{ backup: { id: number; name: string }; runs: DuplicatiRun[] }>(`/api/duplicati/backups/${backupId}/runs`),
|
||
addSource: (data: { name: string; serverId: number | null }) => request<{ source: DuplicatiSource; token: string; path: string }>("/api/duplicati/sources", { method: "POST", body: JSON.stringify(data) }),
|
||
removeSource: (id: number) => request<void>(`/api/duplicati/sources/${id}`, { method: "DELETE" }),
|
||
updateBackup: (id: number, data: { expectedHours?: number; alert?: boolean }) => request<{ ok: boolean }>(`/api/duplicati/backups/${id}`, { method: "PATCH", body: JSON.stringify(data) }),
|
||
forgetBackup: (id: number) => request<void>(`/api/duplicati/backups/${id}`, { method: "DELETE" }),
|
||
},
|
||
away: {
|
||
get: () => request<AwayView>("/api/away"),
|
||
start: (data: { until: string; from?: string | null; criticalThrough: boolean; note?: string }) => request<AwayView>("/api/away", { method: "PUT", body: JSON.stringify(data) }),
|
||
end: () => request<AwayView & { sent: number }>("/api/away", { method: "DELETE" }),
|
||
},
|
||
serviceLevels: {
|
||
list: () => request<{ levels: ServiceLevel[]; subjects: Record<ServiceLevelSubject, { id: number; name: string }[]> }>("/api/service-levels"),
|
||
create: (data: ServiceLevelInput) => request<{ id: number }>("/api/service-levels", { method: "POST", body: JSON.stringify(data) }),
|
||
update: (id: number, data: ServiceLevelInput) => request<{ ok: boolean }>(`/api/service-levels/${id}`, { method: "PUT", body: JSON.stringify(data) }),
|
||
remove: (id: number) => request<void>(`/api/service-levels/${id}`, { method: "DELETE" }),
|
||
},
|
||
nextcloud: {
|
||
list: () => request<{ nextclouds: NextcloudInfo[] }>("/api/nextcloud"),
|
||
},
|
||
netbox: {
|
||
list: () => request<{ netboxes: NetBoxInfo[] }>("/api/netbox"),
|
||
},
|
||
costs: {
|
||
get: () => request<CostsReport>("/api/costs"),
|
||
create: (data: CostInput) => request<{ id: number }>("/api/costs", { method: "POST", body: JSON.stringify(data) }),
|
||
update: (id: number, data: CostInput) => request<{ id: number }>(`/api/costs/${id}`, { method: "PUT", body: JSON.stringify(data) }),
|
||
remove: (id: number) => request<void>(`/api/costs/${id}`, { method: "DELETE" }),
|
||
},
|
||
speedtest: {
|
||
list: () => request<{ speedtests: SpeedtestInfo[] }>("/api/speedtest"),
|
||
history: (id: number, days: number) => request<SpeedtestHistory>(`/api/speedtest/${id}/history?days=${days}`),
|
||
},
|
||
adguard: {
|
||
list: () => request<{ instances: AdguardInstance[] }>("/api/adguard"),
|
||
},
|
||
grafana: {
|
||
list: () => request<{ instances: GrafanaInstance[] }>("/api/grafana"),
|
||
},
|
||
arr: {
|
||
list: () => request<{ apps: ArrApp[] }>("/api/arr"),
|
||
},
|
||
fragnet: {
|
||
list: () => request<{ accounts: FragnetAccount[] }>("/api/fragnet"),
|
||
power: (integrationId: number, serverId: string, signal: FragnetSignal) => request<void>(`/api/fragnet/${integrationId}/servers/${serverId}/power`, { method: "POST", body: JSON.stringify({ signal }) }),
|
||
refresh: (integrationId: number) => request<{ status: { ok: boolean; error: string | null } }>(`/api/fragnet/${integrationId}/refresh`, { method: "POST" }),
|
||
},
|
||
hetzner: {
|
||
list: () => request<{ projects: HetznerProject[] }>("/api/hetzner"),
|
||
forServer: (serverId: number) => request<HetznerForServer>(`/api/hetzner/for-server/${serverId}`),
|
||
},
|
||
n8n: {
|
||
list: () => request<{ n8ns: N8nInfo[] }>("/api/n8n"),
|
||
},
|
||
paperless: {
|
||
list: () => request<{ paperlesses: PaperlessInfo[] }>("/api/paperless"),
|
||
},
|
||
immich: {
|
||
list: () => request<{ immiches: ImmichInfo[] }>("/api/immich"),
|
||
},
|
||
prometheus: {
|
||
list: () => request<{ prometheuses: PrometheusInfo[] }>("/api/prometheus"),
|
||
},
|
||
authentik: {
|
||
list: () => request<{ authentiks: AuthentikInfo[] }>("/api/authentik"),
|
||
},
|
||
jellyfin: {
|
||
list: () => request<{ jellyfins: JellyfinInfo[] }>("/api/jellyfin"),
|
||
history: (id: number, days: number) => request<JellyfinHistory>(`/api/jellyfin/${id}/history?days=${days}`),
|
||
watching: (serverId: number) => request<{ watching: { integrationId: number; integrationName: string; streams: JellyfinStream[] }[]; words: string }>(`/api/jellyfin/watching?serverId=${serverId}`),
|
||
},
|
||
ups: {
|
||
list: () => request<{ ups: UpsInfo[] }>("/api/ups"),
|
||
history: (id: number, days: number) => request<UpsHistory>(`/api/ups/${id}/history?days=${days}`),
|
||
},
|
||
eventWebhooks: {
|
||
list: () => request<{ webhooks: EventWebhook[]; events: WebhookEventName[] }>("/api/event-webhooks"),
|
||
create: (data: { label: string; url: string; secret?: string; events: WebhookEventName[] }) => request<{ webhook: EventWebhook }>("/api/event-webhooks", { method: "POST", body: JSON.stringify(data) }),
|
||
setEnabled: (id: number, enabled: boolean) => request<{ webhook: EventWebhook }>(`/api/event-webhooks/${id}`, { method: "PATCH", body: JSON.stringify({ enabled }) }),
|
||
remove: (id: number) => request<void>(`/api/event-webhooks/${id}`, { method: "DELETE" }),
|
||
test: (id: number) => request<{ ok: boolean; result: string }>(`/api/event-webhooks/${id}/test`, { method: "POST" }),
|
||
deliveries: (id: number) => request<{ deliveries: WebhookDelivery[] }>(`/api/event-webhooks/${id}/deliveries`),
|
||
retryDelivery: (id: number, deliveryId: number) => request<{ ok: boolean; result: string }>(`/api/event-webhooks/${id}/deliveries/${deliveryId}/retry`, { method: "POST" }),
|
||
},
|
||
dataUsage: {
|
||
get: () => request<DataUsage>("/api/data-usage"),
|
||
},
|
||
updateRuns: {
|
||
list: (serverId?: number) => request<{ runs: UpdateRun[] }>(`/api/update-runs${serverId ? `?serverId=${serverId}` : ""}`),
|
||
start: (data: UpdateRunInput) => request<{ run: UpdateRun }>("/api/update-runs", { method: "POST", body: JSON.stringify(data) }),
|
||
cancel: (id: number) => request<{ status: string }>(`/api/update-runs/${id}/cancel`, { method: "POST" }),
|
||
},
|
||
bulk: {
|
||
servers: (body: Record<string, unknown>) => request<BulkResult>("/api/servers/bulk", { method: "POST", body: JSON.stringify(body) }),
|
||
alerts: (body: Record<string, unknown>) => request<BulkResult>("/api/alerts/bulk", { method: "POST", body: JSON.stringify(body) }),
|
||
inventory: (body: Record<string, unknown>) => request<BulkResult>("/api/inventory/bulk", { method: "POST", body: JSON.stringify(body) }),
|
||
},
|
||
patchPlans: {
|
||
list: () => request<{ plans: PatchPlan[]; runs: PatchPlanRun[]; servers: { id: number; name: string; tags: string[] }[]; tags: string[] }>("/api/patch-plans"),
|
||
create: (data: PatchPlanInput) => request<{ plan: PatchPlan }>("/api/patch-plans", { method: "POST", body: JSON.stringify(data) }),
|
||
update: (id: number, data: PatchPlanInput) => request<{ plan: PatchPlan }>(`/api/patch-plans/${id}`, { method: "PUT", body: JSON.stringify(data) }),
|
||
remove: (id: number) => request<void>(`/api/patch-plans/${id}`, { method: "DELETE" }),
|
||
run: (id: number) => request<{ run: PatchPlanRun }>(`/api/patch-plans/${id}/run`, { method: "POST" }),
|
||
cancel: (runId: number) => request<{ run: PatchPlanRun }>(`/api/patch-plans/runs/${runId}/cancel`, { method: "POST" }),
|
||
},
|
||
reports: {
|
||
monthly: (month?: string) =>
|
||
request<{ report: MonthlyReport; months: { id: string; label: string }[]; quarters: { id: string; label: string }[]; years: { id: string; label: string }[] }>(`/api/reports/monthly${month ? `?month=${month}` : ""}`),
|
||
monthlyText: (month?: string) => request<{ title: string; message: string }>(`/api/reports/monthly?format=text${month ? `&month=${month}` : ""}`),
|
||
sendMonthly: (month?: string) => request<{ sent: boolean }>("/api/reports/monthly/send", { method: "POST", body: JSON.stringify({ month }) }),
|
||
},
|
||
backups: {
|
||
coverage: (staleDays: number, refresh = false) => request<BackupCoverage>(`/api/backups/coverage?staleDays=${staleDays}${refresh ? "&refresh=1" : ""}`),
|
||
restoreTests: () => request<{ limitDays: number; tests: RestoreTestEntry[]; custom: (RestoreInfo & { key: string; label: string })[] }>("/api/backups/restore-tests"),
|
||
recordRestoreTest: (data: { key?: string; label: string; testedAt?: string; result: RestoreResult; note?: string }) => request<{ test: RestoreTestEntry }>("/api/backups/restore-tests", { method: "POST", body: JSON.stringify(data) }),
|
||
removeRestoreTest: (id: number) => request<void>(`/api/backups/restore-tests/${id}`, { method: "DELETE" }),
|
||
},
|
||
endpoints: {
|
||
list: () => request<{ checks: EndpointCheck[]; servers: { id: number; name: string }[] }>("/api/endpoints"),
|
||
create: (data: EndpointInput) => request<{ check: EndpointCheck }>("/api/endpoints", { method: "POST", body: JSON.stringify(data) }),
|
||
update: (id: number, data: EndpointInput) => request<{ check: EndpointCheck }>(`/api/endpoints/${id}`, { method: "PUT", body: JSON.stringify(data) }),
|
||
remove: (id: number) => request<void>(`/api/endpoints/${id}`, { method: "DELETE" }),
|
||
check: (id: number) => request<{ result: { ok: boolean; ms: number | null; message: string } }>(`/api/endpoints/${id}/check`, { method: "POST" }),
|
||
history: (id: number, days: number) => request<EndpointHistory>(`/api/endpoints/${id}/history?days=${days}`),
|
||
suggestions: () => request<{ suggestions: EndpointSuggestion[]; dismissed: EndpointSuggestion[] }>("/api/endpoints/suggestions"),
|
||
addSuggestions: (keys: string[]) => request<{ added: { id: number; name: string }[] }>("/api/endpoints/suggestions/add", { method: "POST", body: JSON.stringify({ keys }) }),
|
||
dismissSuggestions: (keys: string[]) => request<{ suggestions: EndpointSuggestion[]; dismissed: EndpointSuggestion[] }>("/api/endpoints/suggestions/dismiss", { method: "POST", body: JSON.stringify({ keys }) }),
|
||
restoreSuggestions: () => request<{ suggestions: EndpointSuggestion[]; dismissed: EndpointSuggestion[] }>("/api/endpoints/suggestions/restore", { method: "POST" }),
|
||
},
|
||
heartbeats: {
|
||
list: () => request<{ heartbeats: Heartbeat[]; servers: { id: number; name: string }[]; baseUrl: string | null }>("/api/heartbeats"),
|
||
create: (data: HeartbeatInput) => request<{ heartbeat: Heartbeat }>("/api/heartbeats", { method: "POST", body: JSON.stringify(data) }),
|
||
update: (id: number, data: HeartbeatInput) => request<{ heartbeat: Heartbeat }>(`/api/heartbeats/${id}`, { method: "PUT", body: JSON.stringify(data) }),
|
||
remove: (id: number) => request<void>(`/api/heartbeats/${id}`, { method: "DELETE" }),
|
||
newAddress: (id: number) => request<{ path: string }>(`/api/heartbeats/${id}/new-address`, { method: "POST" }),
|
||
},
|
||
agenda: {
|
||
get: (days = 400) => request<Agenda>(`/api/agenda?days=${days}`),
|
||
},
|
||
changes: {
|
||
list: (params: { days?: number; kind?: string; serverId?: number; q?: string; before?: string; limit?: number }) => {
|
||
const q = new URLSearchParams();
|
||
for (const [k, v] of Object.entries(params)) if (v !== undefined && v !== "") q.set(k, String(v));
|
||
return request<{ entries: ChangeEntry[]; more: boolean; kinds: { id: ChangeKind; label: string }[] }>(`/api/changes?${q.toString()}`);
|
||
},
|
||
},
|
||
push: {
|
||
key: () => request<{ publicKey: string }>("/api/push/key"),
|
||
mine: () => request<{ enabled: boolean; subscriptions: PushDevice[] }>("/api/push/mine"),
|
||
subscribe: (data: { endpoint: string; keys: { p256dh: string; auth: string }; label?: string }) => request<{ id: number }>("/api/push/subscribe", { method: "POST", body: JSON.stringify(data) }),
|
||
remove: (id: number) => request<void>(`/api/push/${id}`, { method: "DELETE" }),
|
||
setPrefs: (id: number, data: { minSeverity: "warning" | "critical" | null; categories: AlertCategory[] | null }) =>
|
||
request<{ minSeverity: string | null; categories: AlertCategory[] | null }>(`/api/push/${id}`, { method: "PATCH", body: JSON.stringify(data) }),
|
||
test: () => request<{ sent: number; removed: number; failed: number }>("/api/push/test", { method: "POST" }),
|
||
},
|
||
myWork: {
|
||
get: () => request<MyWork>("/api/my-work"),
|
||
},
|
||
todos: {
|
||
list: (about?: { type: "server" | "device"; id: number }) =>
|
||
request<{ todos: TodoItem[]; people: { id: number; name: string; role: string }[] }>(`/api/todos${about ? `?targetType=${about.type}&targetId=${about.id}` : ""}`),
|
||
create: (data: TodoInput) => request<{ todo: TodoItem }>("/api/todos", { method: "POST", body: JSON.stringify(data) }),
|
||
update: (id: number, data: Partial<TodoInput> & { done?: boolean }) => request<{ todo: TodoItem }>(`/api/todos/${id}`, { method: "PATCH", body: JSON.stringify(data) }),
|
||
remove: (id: number) => request<void>(`/api/todos/${id}`, { method: "DELETE" }),
|
||
},
|
||
notes: {
|
||
get: (targetType: "server" | "device", targetId: number) => request<{ note: NoteItem | null }>(`/api/notes?targetType=${targetType}&targetId=${targetId}`),
|
||
save: (targetType: "server" | "device", targetId: number, body: string) => request<{ note: NoteItem | null }>("/api/notes", { method: "PUT", body: JSON.stringify({ targetType, targetId, body }) }),
|
||
},
|
||
notePhotos: {
|
||
list: (targetType: "server" | "device", targetId: number) => request<{ photos: NotePhoto[] }>(`/api/note-photos?targetType=${targetType}&targetId=${targetId}`),
|
||
/** The bytes are the body, as they are (the app makes them small first). */
|
||
add: async (targetType: "server" | "device", targetId: number, photo: Blob): Promise<{ photo: NotePhoto }> => {
|
||
const res = await fetch(`/api/note-photos?targetType=${targetType}&targetId=${targetId}`, { method: "POST", headers: { "Content-Type": photo.type || "application/octet-stream" }, body: photo, credentials: "same-origin" });
|
||
if (res.status === 401) throw new UnauthorizedError("unauthorized");
|
||
if (res.status === 403) throw new ForbiddenError("forbidden");
|
||
if (!res.ok) throw new Error(`Request failed (${res.status}): ${await res.text().catch(() => "")}`);
|
||
return (await res.json()) as { photo: NotePhoto };
|
||
},
|
||
setCaption: (id: number, caption: string | null) => request<{ photo: NotePhoto }>(`/api/note-photos/${id}`, { method: "PUT", body: JSON.stringify({ caption }) }),
|
||
remove: (id: number) => request<void>(`/api/note-photos/${id}`, { method: "DELETE" }),
|
||
imageUrl: (id: number) => `/api/note-photos/${id}/image`,
|
||
},
|
||
network: {
|
||
overview: () => request<NetworkOverview>("/api/network"),
|
||
sync: (integrationId?: number) => request<{ statuses: Record<number, UnifiSyncStatus> }>("/api/network/sync", { method: "POST", body: JSON.stringify(integrationId ? { integrationId } : {}) }),
|
||
},
|
||
alertRules: {
|
||
list: () => request<{ rules: AlertRule[]; servers: { id: number; name: string }[]; tags: string[] }>("/api/alert-rules"),
|
||
preview: (data: AlertRuleInput) => request<{ findings: { serverId: number; serverName: string; detail: string | null; value: number }[] }>("/api/alert-rules/preview", { method: "POST", body: JSON.stringify(data) }),
|
||
create: (data: AlertRuleInput) => request<{ rule: AlertRule }>("/api/alert-rules", { method: "POST", body: JSON.stringify(data) }),
|
||
update: (id: number, data: AlertRuleInput) => request<{ rule: AlertRule }>(`/api/alert-rules/${id}`, { method: "PUT", body: JSON.stringify(data) }),
|
||
remove: (id: number) => request<void>(`/api/alert-rules/${id}`, { method: "DELETE" }),
|
||
},
|
||
storage: {
|
||
overview: () => request<{ pools: StoragePool[]; forecastDays: number }>("/api/storage"),
|
||
history: (seriesId: number, days: number) => request<{ days: number; points: { t: string; v: number }[] }>(`/api/storage/${seriesId}/history?days=${days}`),
|
||
},
|
||
npm: {
|
||
overview: (refresh = false) => request<NpmOverview>(`/api/npm${refresh ? "?refresh=1" : ""}`),
|
||
},
|
||
homeAssistant: {
|
||
overview: () => request<HaOverview>("/api/home-assistant"),
|
||
entities: (id: number, q: string) => request<{ total: number; entities: HaEntityChoice[] }>(`/api/home-assistant/${id}/entities?q=${encodeURIComponent(q)}`),
|
||
watch: (id: number, body: { entityId: string; name?: string | null; above?: number | null; below?: number | null }) =>
|
||
request<{ ok: boolean; status: HaSyncStatus }>(`/api/home-assistant/${id}/watched`, { method: "PUT", body: JSON.stringify(body) }),
|
||
unwatch: (id: number, entityId: string) => request<void>(`/api/home-assistant/${id}/watched/${encodeURIComponent(entityId)}`, { method: "DELETE" }),
|
||
history: (id: number, entityId: string, days: number) =>
|
||
request<{ days: number; points: { t: string; v: number }[] }>(`/api/home-assistant/${id}/history?entity=${encodeURIComponent(entityId)}&days=${days}`),
|
||
sync: () => request<{ statuses: Record<number, HaSyncStatus> }>("/api/home-assistant/sync", { method: "POST", body: "{}" }),
|
||
},
|
||
dependencies: {
|
||
list: () => request<DependenciesResponse>("/api/dependencies"),
|
||
impact: (type: DependencyNodeType, id: number) => request<DependencyImpact>(`/api/dependencies/impact?type=${type}&id=${id}`),
|
||
graph: () => request<DependencyGraph>("/api/dependencies/graph"),
|
||
suggestions: () => request<DependencySuggestions>("/api/dependencies/suggestions"),
|
||
addSuggestions: (keys: string[]) => request<DependencySuggestions & { added: { id: number; from: string; to: string }[] }>("/api/dependencies/suggestions/add", { method: "POST", body: JSON.stringify({ keys }) }),
|
||
dismissSuggestions: (keys: string[]) => request<DependencySuggestions>("/api/dependencies/suggestions/dismiss", { method: "POST", body: JSON.stringify({ keys }) }),
|
||
restoreSuggestions: () => request<DependencySuggestions>("/api/dependencies/suggestions/restore", { method: "POST" }),
|
||
create: (data: { fromType: DependencyNodeType; fromId: number; toType: DependencyNodeType; toId: number }) => request<{ id: number }>("/api/dependencies", { method: "POST", body: JSON.stringify(data) }),
|
||
remove: (id: number) => request<void>(`/api/dependencies/${id}`, { method: "DELETE" }),
|
||
},
|
||
inventory: {
|
||
racks: () =>
|
||
request<{
|
||
racks: {
|
||
name: string;
|
||
units: number;
|
||
slots: { assetId: number; name: string; kind: string; model: string | null; from: number; to: number; powerWatts: number | null; serverId: number | null; clash: boolean }[];
|
||
unplaced: { assetId: number; name: string; kind: string }[];
|
||
usedUnits: number;
|
||
watts: number;
|
||
}[];
|
||
}>("/api/inventory/racks"),
|
||
list: () => request<{ assets: Asset[]; config: InventoryConfig; servers: { id: number; name: string }[] }>("/api/inventory"),
|
||
create: (data: AssetInput) => request<{ asset: Asset }>("/api/inventory", { method: "POST", body: JSON.stringify(data) }),
|
||
update: (id: number, data: AssetInput) => request<{ asset: Asset }>(`/api/inventory/${id}`, { method: "PUT", body: JSON.stringify(data) }),
|
||
remove: (id: number) => request<void>(`/api/inventory/${id}`, { method: "DELETE" }),
|
||
lifecycle: (years = 5) => request<LifecycleReport>(`/api/inventory/lifecycle?years=${years}`),
|
||
refreshFromAgent: (id: number) => request<{ asset: Asset; changed: string[] }>(`/api/inventory/${id}/refresh-from-agent`, { method: "POST" }),
|
||
setConfig: (data: InventoryConfig) => request<{ config: InventoryConfig }>("/api/inventory/config", { method: "PUT", body: JSON.stringify(data) }),
|
||
},
|
||
runbooks: {
|
||
list: (targetType: MaintenanceTargetType, targetId: number) => request<{ runbooks: Runbook[] }>(`/api/runbooks?targetType=${targetType}&targetId=${targetId}`),
|
||
summary: () => request<{ runbooks: RunbookSummary[] }>("/api/runbooks/summary"),
|
||
create: (data: { targetType: MaintenanceTargetType; targetId: number; title: string; body: string; category: AlertCategory | null }) =>
|
||
request<{ runbook: Runbook }>("/api/runbooks", { method: "POST", body: JSON.stringify(data) }),
|
||
update: (id: number, data: { title: string; body: string; category: AlertCategory | null }) =>
|
||
request<{ runbook: Runbook }>(`/api/runbooks/${id}`, { method: "PUT", body: JSON.stringify(data) }),
|
||
remove: (id: number) => request<void>(`/api/runbooks/${id}`, { method: "DELETE" }),
|
||
kinds: {
|
||
list: () => request<{ kinds: AlertKindRunbook[] }>("/api/runbooks/kinds"),
|
||
save: (kind: string, data: { title: string; body: string; url: string | null }) => request<{ runbook: AlertKindRunbook }>(`/api/runbooks/kinds/${encodeURIComponent(kind)}`, { method: "PUT", body: JSON.stringify(data) }),
|
||
remove: (kind: string) => request<void>(`/api/runbooks/kinds/${encodeURIComponent(kind)}`, { method: "DELETE" }),
|
||
},
|
||
},
|
||
shareLinks: {
|
||
list: () => request<{ links: ShareLink[] }>("/api/share-links"),
|
||
create: (data: { label: string; detail?: ShareLinkDetail; kind?: ShareLinkKind; title?: string; message?: string; expiresInDays: number | null }) =>
|
||
request<{ link: ShareLink; token: string; path: string }>("/api/share-links", { method: "POST", body: JSON.stringify(data) }),
|
||
remove: (id: number) => request<void>(`/api/share-links/${id}`, { method: "DELETE" }),
|
||
},
|
||
statusPages: {
|
||
get: (linkId: number) => request<{ title: string; message: string; items: StatusPageItem[]; maxItems: number }>("/api/share-links/" + linkId + "/status"),
|
||
choices: () => request<{ servers: { id: number; name: string }[]; integrations: { id: number; name: string; type: string }[] }>("/api/share-links/status-choices"),
|
||
save: (linkId: number, data: { title: string; message: string; items: { label: string; kind: StatusItemKind; targetId: number; monitorId: string | null }[] }) =>
|
||
request<{ title: string; message: string; items: StatusPageItem[] }>("/api/share-links/" + linkId + "/status", { method: "PUT", body: JSON.stringify(data) }),
|
||
},
|
||
publicStatus: {
|
||
get: async (token: string): Promise<PublicStatus> => {
|
||
const res = await fetch("/api/public/status/" + encodeURIComponent(token), { credentials: "omit", cache: "no-store" });
|
||
if (!res.ok) throw Object.assign(new Error("Request failed (" + res.status + ")"), { status: res.status });
|
||
return (await res.json()) as PublicStatus;
|
||
},
|
||
},
|
||
// Opened by someone who isn't signed in: no cookies, and the status is kept so a link that has ended can say so.
|
||
wall: {
|
||
extras: () => request<{ tiles: WallTile[]; groups: WallGroup[] }>("/api/wall/extras"),
|
||
},
|
||
publicWall: {
|
||
get: async (token: string): Promise<PublicWall> => {
|
||
const res = await fetch(`/api/public/wall/${encodeURIComponent(token)}`, { credentials: "omit", cache: "no-store" });
|
||
if (!res.ok) throw Object.assign(new Error(`Request failed (${res.status})`), { status: res.status });
|
||
return (await res.json()) as PublicWall;
|
||
},
|
||
},
|
||
search: {
|
||
query: (q: string) => request<SearchResponse>(`/api/search?q=${encodeURIComponent(q)}`),
|
||
},
|
||
users: {
|
||
list: () => request<{ users: UserRecord[]; rolesFollowGroups: boolean }>("/api/users"),
|
||
previewGroupRoles: (rules: Pick<SignInSettings, "groupsClaim" | "adminGroups" | "operatorGroups" | "otherwise">) =>
|
||
request<GroupRolePreview>("/api/users/preview-group-roles", { method: "POST", body: JSON.stringify(rules) }),
|
||
updateRole: (id: number, role: UserRole) =>
|
||
request<{ user: UserRecord }>(`/api/users/${id}/role`, {
|
||
method: "PATCH",
|
||
body: JSON.stringify({ role }),
|
||
}),
|
||
},
|
||
maintenance: {
|
||
list: () => request<{ windows: MaintenanceWindow[]; upcoming: MaintenanceWindow[]; aliases: MaintenanceAlias[]; targets: MaintenanceTargets }>("/api/maintenance"),
|
||
addAlias: (data: { address: string; targetType: MaintenanceTargetType; targetId: number }) =>
|
||
request<{ alias: MaintenanceAlias }>("/api/maintenance/aliases", { method: "POST", body: JSON.stringify(data) }),
|
||
removeAlias: (id: number) => request<void>(`/api/maintenance/aliases/${id}`, { method: "DELETE" }),
|
||
start: (data: { targetType: MaintenanceTargetType; targetId: number; minutes: number; reason?: string; withDependents?: boolean }) =>
|
||
request<{ window: MaintenanceWindow; alsoSilenced: { type: DependencyNodeType; id: number; name: string }[] }>("/api/maintenance", { method: "POST", body: JSON.stringify(data) }),
|
||
end: (id: number) => request<void>(`/api/maintenance/${id}`, { method: "DELETE" }),
|
||
startBulk: (data: { scope: MaintenanceBulkScope; minutes: number; reason?: string }) =>
|
||
request<{ started: number; extended: number; total: number }>("/api/maintenance/bulk", { method: "POST", body: JSON.stringify(data) }),
|
||
endAll: () => request<{ ended: number }>("/api/maintenance/end-all", { method: "POST" }),
|
||
schedules: {
|
||
list: () => request<{ schedules: MaintenanceSchedule[] }>("/api/maintenance/schedules"),
|
||
create: (data: MaintenanceScheduleInput) => request<{ id: number; windowsMade: number }>("/api/maintenance/schedules", { method: "POST", body: JSON.stringify(data) }),
|
||
update: (id: number, data: MaintenanceScheduleInput) => request<{ windowsMade: number }>(`/api/maintenance/schedules/${id}`, { method: "PUT", body: JSON.stringify(data) }),
|
||
setEnabled: (id: number, enabled: boolean) => request<{ enabled: boolean }>(`/api/maintenance/schedules/${id}`, { method: "PATCH", body: JSON.stringify({ enabled }) }),
|
||
remove: (id: number) => request<void>(`/api/maintenance/schedules/${id}`, { method: "DELETE" }),
|
||
},
|
||
syncUptimeKuma: (data: { integrationId: number }) =>
|
||
request<UptimeKumaSyncResult>("/api/maintenance/sync/uptimekuma", { method: "POST", body: JSON.stringify(data) }),
|
||
importUptimeKuma: (data: { integrationId: number; minutes: number }) =>
|
||
request<UptimeKumaImportResult>("/api/maintenance/import/uptimekuma", { method: "POST", body: JSON.stringify(data) }),
|
||
},
|
||
sessions: {
|
||
list: () => request<{ sessions: SessionSummary[]; currentSessionId: string }>("/api/sessions"),
|
||
revoke: (id: string) => request<void>(`/api/sessions/${encodeURIComponent(id)}`, { method: "DELETE" }),
|
||
},
|
||
auditLog: {
|
||
list: (limit = 200) => request<{ entries: AuditLogEntry[] }>(`/api/audit-log?limit=${limit}`),
|
||
},
|
||
diagLog: {
|
||
list: (params: { source?: string; ok?: boolean; limit?: number; offset?: number } = {}) => {
|
||
const qs = new URLSearchParams();
|
||
if (params.source) qs.set("source", params.source);
|
||
if (params.ok !== undefined) qs.set("ok", String(params.ok));
|
||
if (params.limit !== undefined) qs.set("limit", String(params.limit));
|
||
if (params.offset !== undefined) qs.set("offset", String(params.offset));
|
||
const query = qs.toString();
|
||
return request<DiagLogResponse>(`/api/diag-log${query ? `?${query}` : ""}`);
|
||
},
|
||
clear: () => request<void>("/api/diag-log", { method: "DELETE" }),
|
||
},
|
||
secrets: {
|
||
list: () => request<{ secrets: SecretRecord[] }>("/api/secrets"),
|
||
create: (data: SecretInput) =>
|
||
request<{ secret: SecretRecord }>("/api/secrets", { method: "POST", body: JSON.stringify(data) }),
|
||
update: (id: number, data: Partial<SecretInput>) =>
|
||
request<{ secret: SecretRecord }>(`/api/secrets/${id}`, {
|
||
method: "PATCH",
|
||
body: JSON.stringify(data),
|
||
}),
|
||
remove: (id: number) => request<void>(`/api/secrets/${id}`, { method: "DELETE" }),
|
||
checkTls: (id: number) =>
|
||
request<{ secret: SecretRecord; result: { ok: boolean; expiryDate?: string; error?: string } }>(
|
||
`/api/secrets/${id}/check-tls`,
|
||
{ method: "POST" },
|
||
),
|
||
},
|
||
ipam: {
|
||
list: () => request<{ entries: IpamEntry[]; excludedRanges: string[] }>("/api/ipam"),
|
||
create: (data: IpamInput) =>
|
||
request<{ entry: IpamEntry }>("/api/ipam", { method: "POST", body: JSON.stringify(data) }),
|
||
update: (id: number, data: Partial<Omit<IpamInput, "ipAddress">>) =>
|
||
request<{ entry: IpamEntry }>(`/api/ipam/${id}`, { method: "PATCH", body: JSON.stringify(data) }),
|
||
remove: (id: number) => request<void>(`/api/ipam/${id}`, { method: "DELETE" }),
|
||
syncTailscale: () => request<IpamSyncResult>("/api/ipam/sync-tailscale", { method: "POST" }),
|
||
syncProxmox: () => request<IpamSyncResult>("/api/ipam/sync-proxmox", { method: "POST" }),
|
||
syncPhpIpam: () => request<IpamSyncResult>("/api/ipam/sync-phpipam", { method: "POST" }),
|
||
syncUnifi: () => request<IpamSyncResult>("/api/ipam/sync-unifi", { method: "POST" }),
|
||
},
|
||
generator: {
|
||
themes: () => request<{ themes: NameTheme[]; builtinIds: string[] }>("/api/generator/themes"),
|
||
defaults: () => request<{ themes: NameTheme[] }>("/api/generator/themes/defaults"),
|
||
save: (themes: (Omit<NameTheme, "id"> & { id?: string })[]) => request<{ themes: NameTheme[] }>("/api/generator/themes", { method: "PUT", body: JSON.stringify({ themes }) }),
|
||
importNames: (sex: "girls" | "boys", years: number, count: number) =>
|
||
request<NameImportPreview>("/api/generator/themes/import", { method: "POST", body: JSON.stringify({ sex, years, count }) }),
|
||
},
|
||
map: {
|
||
get: () => request<MapData>("/api/map"),
|
||
},
|
||
alerts: {
|
||
list: (refresh = false) => request<AlertsReport>(`/api/alerts${refresh ? "?refresh=1" : ""}`),
|
||
assignees: () => request<{ users: { id: number; name: string; role: string }[] }>("/api/alerts/assignees"),
|
||
ack: (data: AckInput) => request<{ ack: AlertAck }>("/api/alerts/ack", { method: "PUT", body: JSON.stringify(data) }),
|
||
unack: (alertId: string) => request<void>(`/api/alerts/ack?alertId=${encodeURIComponent(alertId)}`, { method: "DELETE" }),
|
||
snooze: (alertId: string, until: string) => request<{ snooze: { until: string; snoozedBy: string } }>("/api/alerts/snooze", { method: "PUT", body: JSON.stringify({ alertId, until }) }),
|
||
close: (alertId: string, note: string | null, closeTicket = false) =>
|
||
request<{ closed: { by: string; at: string; note: string | null }; ticket: { number: string | null; result: "closed" | "already_closed" | "failed"; message: string | null } | null }>("/api/alerts/close", { method: "PUT", body: JSON.stringify({ alertId, note, closeTicket }) }),
|
||
reopen: (alertId: string) => request<void>(`/api/alerts/close?alertId=${encodeURIComponent(alertId)}`, { method: "DELETE" }),
|
||
unsnooze: (alertId: string) => request<void>(`/api/alerts/snooze?alertId=${encodeURIComponent(alertId)}`, { method: "DELETE" }),
|
||
noise: (days: number) => request<NoiseReport>(`/api/alerts/noise?days=${days}`),
|
||
},
|
||
incidents: {
|
||
list: () => request<{ incidents: IncidentSummary[] }>("/api/incidents"),
|
||
get: (id: number) => request<IncidentDetail>(`/api/incidents/${id}`),
|
||
before: (id: number, minutes: number) => request<BeforeReport>(`/api/incidents/${id}/before?minutes=${minutes}`),
|
||
addNote: (id: number, body: string) => request<{ id: number }>(`/api/incidents/${id}/notes`, { method: "POST", body: JSON.stringify({ body }) }),
|
||
removeNote: (id: number, noteId: number) => request<void>(`/api/incidents/${id}/notes/${noteId}`, { method: "DELETE" }),
|
||
},
|
||
dbBackups: {
|
||
overview: () => request<DbBackupsOverview>("/api/db-backups"),
|
||
create: () => request<{ snapshot: DbSnapshot; check: DbSnapshotCheck }>("/api/db-backups", { method: "POST" }),
|
||
check: (name: string) => request<{ check: DbSnapshotCheck }>(`/api/db-backups/${encodeURIComponent(name)}/check`, { method: "POST" }),
|
||
restore: (name: string) => request<{ staged: DbStagedRestore | null; check: DbSnapshotCheck }>(`/api/db-backups/${encodeURIComponent(name)}/restore`, { method: "POST" }),
|
||
cancelRestore: () => request<{ cancelled: boolean }>("/api/db-backups/restore/cancel", { method: "POST" }),
|
||
dismissRestoreResult: () => request<{ ok: true }>("/api/db-backups/restore-result/dismiss", { method: "POST" }),
|
||
remove: (name: string) => request<void>(`/api/db-backups/${encodeURIComponent(name)}`, { method: "DELETE" }),
|
||
saveSettings: (data: DbBackupSettings) => request<DbBackupsOverview>("/api/db-backups/settings", { method: "PUT", body: JSON.stringify(data) }),
|
||
/** A backup file chosen on this computer, sent as it is. */
|
||
upload: async (file: File) => {
|
||
const res = await fetch("/api/db-backups/upload", { method: "POST", headers: { "Content-Type": "application/octet-stream" }, body: file, credentials: "same-origin" });
|
||
if (!res.ok) throw new Error(await res.text().catch(() => `Upload failed (${res.status})`));
|
||
return (await res.json()) as { snapshot: DbSnapshot; check: DbSnapshotCheck };
|
||
},
|
||
downloadUrl: (name: string) => `/api/db-backups/${encodeURIComponent(name)}/download`,
|
||
},
|
||
alertTickets: {
|
||
get: () => request<AlertTicketOverview>("/api/alert-tickets"),
|
||
update: (patch: Partial<AlertTicketSettings>) => request<AlertTicketOverview>("/api/alert-tickets", { method: "PUT", body: JSON.stringify(patch) }),
|
||
test: () => request<{ ok: boolean; ticketNumber: string | null }>("/api/alert-tickets/test", { method: "POST" }),
|
||
testClose: (integrationId: number) => request<{ ok: boolean; problems: string[]; notes: string[] }>("/api/alert-tickets/test-close", { method: "POST", body: JSON.stringify({ integrationId }) }),
|
||
run: () => request<{ summary: AlertTicketRunSummary; status: AlertTicketOverview["status"] }>("/api/alert-tickets/run", { method: "POST" }),
|
||
},
|
||
ports: {
|
||
agent: () => request<AgentPortsResponse>("/api/ports/agent"),
|
||
forwards: {
|
||
list: () => request<{ forwards: PortForward[] }>("/api/ports/forwards"),
|
||
create: (data: PortForwardInput) =>
|
||
request<{ forward: PortForward }>("/api/ports/forwards", { method: "POST", body: JSON.stringify(data) }),
|
||
update: (id: number, data: Partial<PortForwardInput>) =>
|
||
request<{ forward: PortForward }>(`/api/ports/forwards/${id}`, { method: "PATCH", body: JSON.stringify(data) }),
|
||
remove: (id: number) => request<void>(`/api/ports/forwards/${id}`, { method: "DELETE" }),
|
||
},
|
||
},
|
||
dns: {
|
||
providerFields: () =>
|
||
request<{ fields: Record<DnsProviderType, DnsProviderField[]> }>("/api/dns/provider-fields"),
|
||
stats: () =>
|
||
request<{
|
||
totalProviders: number;
|
||
enabledProviders: number;
|
||
totalZones: number;
|
||
perProvider: { providerId: number; name: string; providerType: DnsProviderType; zoneCount: number; error: string | null }[];
|
||
totalRecords: number;
|
||
recordsByType: { type: string; count: number }[];
|
||
}>("/api/dns/stats"),
|
||
providers: {
|
||
list: () => request<{ providers: DnsProviderSummary[] }>("/api/dns/providers"),
|
||
create: (data: { providerType: DnsProviderType; name: string; config: Record<string, string | boolean> }) =>
|
||
request<{ provider: DnsProviderSummary }>("/api/dns/providers", {
|
||
method: "POST",
|
||
body: JSON.stringify(data),
|
||
}),
|
||
update: (id: number, data: { name?: string; enabled?: boolean; config?: Record<string, string | boolean> }) =>
|
||
request<{ provider: DnsProviderSummary }>(`/api/dns/providers/${id}`, {
|
||
method: "PATCH",
|
||
body: JSON.stringify(data),
|
||
}),
|
||
remove: (id: number) => request<void>(`/api/dns/providers/${id}`, { method: "DELETE" }),
|
||
test: (data: { providerType: DnsProviderType; config: Record<string, string | boolean> }) =>
|
||
request<{ ok: boolean; zoneCount?: number; error?: string }>("/api/dns/providers/test", {
|
||
method: "POST",
|
||
body: JSON.stringify(data),
|
||
}),
|
||
},
|
||
zones: {
|
||
list: (providerId: number) => request<{ zones: DnsZone[] }>(`/api/dns/providers/${providerId}/zones`),
|
||
},
|
||
records: {
|
||
list: (providerId: number, zoneId: string) =>
|
||
request<{ records: DnsRecord[]; syncedAt: string | null }>(
|
||
`/api/dns/providers/${providerId}/zones/${encodeURIComponent(zoneId)}/records`,
|
||
),
|
||
sync: (providerId: number, zoneId: string, zoneName?: string) =>
|
||
request<{ records: DnsRecord[]; syncedAt: string }>(
|
||
`/api/dns/providers/${providerId}/zones/${encodeURIComponent(zoneId)}/sync`,
|
||
{ method: "POST", body: JSON.stringify({ zoneName }) },
|
||
),
|
||
create: (providerId: number, zoneId: string, data: DnsRecordInput) =>
|
||
request<{ record: DnsRecord }>(
|
||
`/api/dns/providers/${providerId}/zones/${encodeURIComponent(zoneId)}/records`,
|
||
{ method: "POST", body: JSON.stringify(data) },
|
||
),
|
||
update: (providerId: number, zoneId: string, recordId: string, data: DnsRecordInput) =>
|
||
request<{ record: DnsRecord }>(
|
||
`/api/dns/providers/${providerId}/zones/${encodeURIComponent(zoneId)}/records/${encodeURIComponent(recordId)}`,
|
||
{ method: "PUT", body: JSON.stringify(data) },
|
||
),
|
||
remove: (providerId: number, zoneId: string, recordId: string) =>
|
||
request<void>(
|
||
`/api/dns/providers/${providerId}/zones/${encodeURIComponent(zoneId)}/records/${encodeURIComponent(recordId)}`,
|
||
{ method: "DELETE" },
|
||
),
|
||
},
|
||
clearCache: () => request<{ ok: true }>("/api/dns/cache/clear", { method: "POST" }),
|
||
},
|
||
servers: {
|
||
list: () => request<{ servers: ServerRecord[]; agentLatest: AgentLatest; agentAutoUpdate: boolean }>("/api/servers"),
|
||
setAgentAutoUpdate: (autoUpdate: boolean) => request<{ autoUpdate: boolean }>("/api/servers/agent-update", { method: "PUT", body: JSON.stringify({ autoUpdate }) }),
|
||
create: (data: { name: string; hostname?: string; description?: string; osType?: "linux" | "windows" }) =>
|
||
request<{ server: ServerRecord; token: string }>("/api/servers", {
|
||
method: "POST",
|
||
body: JSON.stringify(data),
|
||
}),
|
||
rotateToken: (id: number) =>
|
||
request<{ server: ServerRecord; token: string }>(`/api/servers/${id}/rotate-token`, {
|
||
method: "POST",
|
||
}),
|
||
update: (id: number, data: ServerUpdateInput) =>
|
||
request<{ server: ServerRecord }>(`/api/servers/${id}`, { method: "PATCH", body: JSON.stringify(data) }),
|
||
summary: () => request<ServerSummary>("/api/servers/summary"),
|
||
updates: () => request<{ servers: UpdatesServer[]; agentLatest: AgentLatest }>("/api/servers/updates"),
|
||
detail: (id: number) => request<ServerDetail>(`/api/servers/${id}/detail`),
|
||
activity: (id: number) => request<{ events: ServerActivityEvent[] }>(`/api/servers/${id}/activity`),
|
||
metrics: (id: number, days: number) => request<{ days: number; series: ServerMetricSeries[] }>(`/api/servers/${id}/metrics?days=${days}`),
|
||
baseline: (id: number) => request<BaselineView>(`/api/servers/${id}/baseline`),
|
||
remove: (id: number) => request<void>(`/api/servers/${id}`, { method: "DELETE" }),
|
||
setTags: (id: number, tags: string[]) =>
|
||
request<{ tags: string[] }>(`/api/servers/${id}/tags`, { method: "PUT", body: JSON.stringify({ tags }) }),
|
||
addLink: (id: number, data: { label: string; url: string }) =>
|
||
request<{ link: ServerLink }>(`/api/servers/${id}/links`, { method: "POST", body: JSON.stringify(data) }),
|
||
updateLink: (id: number, linkId: number, data: { label?: string; url?: string }) =>
|
||
request<{ link: ServerLink }>(`/api/servers/${id}/links/${linkId}`, { method: "PATCH", body: JSON.stringify(data) }),
|
||
removeLink: (id: number, linkId: number) =>
|
||
request<void>(`/api/servers/${id}/links/${linkId}`, { method: "DELETE" }),
|
||
allLinks: () => request<{ links: AdminLink[] }>("/api/servers/links"),
|
||
ports: {
|
||
list: (id: number) => request<PortList>(`/api/servers/${id}/ports`),
|
||
scan: (id: number, data: { address: string; from: number; to: number }) =>
|
||
request<PortScanResult>(`/api/servers/${id}/ports/scan`, { method: "POST", body: JSON.stringify(data) }),
|
||
save: (id: number, data: { port: number; protocol: "tcp" | "udp"; label?: string; comment?: string }) =>
|
||
request<{ ports: PortEntry[] }>(`/api/servers/${id}/ports`, { method: "PUT", body: JSON.stringify(data) }),
|
||
remove: (id: number, portId: number) => request<void>(`/api/servers/${id}/ports/${portId}`, { method: "DELETE" }),
|
||
},
|
||
},
|
||
tags: {
|
||
list: () => request<{ tags: TagEntry[] }>("/api/tags"),
|
||
create: (name: string, color?: string) =>
|
||
request<{ tags: TagEntry[] }>("/api/tags", { method: "POST", body: JSON.stringify({ name, color }) }),
|
||
setColor: (name: string, color: string | null) =>
|
||
request<{ tags: TagEntry[] }>("/api/tags/color", { method: "PUT", body: JSON.stringify({ name, color }) }),
|
||
rename: (from: string, to: string) =>
|
||
request<{ tags: TagEntry[]; updatedServers: number; merged: boolean }>("/api/tags/rename", { method: "POST", body: JSON.stringify({ from, to }) }),
|
||
remove: (name: string) =>
|
||
request<{ tags: TagEntry[]; updatedServers: number }>("/api/tags/delete", { method: "POST", body: JSON.stringify({ name }) }),
|
||
},
|
||
privacy: {
|
||
overview: () => request<PrivacyOverview>("/api/privacy"),
|
||
exportOwnData: async (): Promise<Blob> => {
|
||
const res = await fetch("/api/privacy/export", { credentials: "same-origin" });
|
||
if (!res.ok) throw new Error(`Request failed (${res.status}): ${await res.text().catch(() => "")}`);
|
||
return res.blob();
|
||
},
|
||
},
|
||
consistency: {
|
||
report: () => request<ConsistencyReport>("/api/consistency"),
|
||
ignore: (key: string, reason?: string) =>
|
||
request<{ ignore: ConsistencyIgnore }>("/api/consistency/ignore", { method: "POST", body: JSON.stringify({ key, reason }) }),
|
||
unignore: (id: number) => request<void>(`/api/consistency/ignore/${id}`, { method: "DELETE" }),
|
||
setExcludedRanges: (ranges: string[]) =>
|
||
request<{ excludedRanges: string[] }>("/api/consistency/excluded-ranges", { method: "PUT", body: JSON.stringify({ ranges }) }),
|
||
},
|
||
domains: {
|
||
list: () => request<DomainList>("/api/domains"),
|
||
add: (name: string) =>
|
||
request<{ domain: DomainRecord; resolvedFrom: string | null }>("/api/domains", { method: "POST", body: JSON.stringify({ name }) }),
|
||
refresh: () => request<DomainList>("/api/domains/refresh", { method: "POST" }),
|
||
check: (id: number) => request<{ domain: DomainRecord }>(`/api/domains/${id}/check`, { method: "POST" }),
|
||
remove: (id: number) => request<void>(`/api/domains/${id}`, { method: "DELETE" }),
|
||
},
|
||
tasks: {
|
||
list: (
|
||
params: { serverId?: number; scheduleType?: string; search?: string; includeStale?: boolean } = {},
|
||
) => {
|
||
const qs = new URLSearchParams();
|
||
if (params.serverId) qs.set("serverId", String(params.serverId));
|
||
if (params.scheduleType) qs.set("scheduleType", params.scheduleType);
|
||
if (params.search) qs.set("search", params.search);
|
||
if (params.includeStale) qs.set("includeStale", "true");
|
||
const query = qs.toString();
|
||
return request<{ tasks: TaskRecord[] }>(`/api/tasks${query ? `?${query}` : ""}`);
|
||
},
|
||
create: (data: ManualTaskInput) =>
|
||
request<{ task: TaskRecord }>("/api/tasks", { method: "POST", body: JSON.stringify(data) }),
|
||
update: (id: number, data: Partial<Omit<ManualTaskInput, "serverId">>) =>
|
||
request<{ task: TaskRecord }>(`/api/tasks/${id}`, { method: "PATCH", body: JSON.stringify(data) }),
|
||
remove: (id: number) => request<void>(`/api/tasks/${id}`, { method: "DELETE" }),
|
||
},
|
||
integrations: {
|
||
fields: () => request<{ fields: Partial<Record<IntegrationType, IntegrationField[]>> }>("/api/integrations/fields"),
|
||
list: () => request<{ integrations: IntegrationSummary[] }>("/api/integrations"),
|
||
create: (data: { type: IntegrationType; name: string; config: Record<string, string | boolean> }) =>
|
||
request<{ integration: IntegrationSummary }>("/api/integrations", {
|
||
method: "POST",
|
||
body: JSON.stringify(data),
|
||
}),
|
||
update: (id: number, data: { name?: string; enabled?: boolean; config?: Record<string, string | boolean> }) =>
|
||
request<{ integration: IntegrationSummary }>(`/api/integrations/${id}`, {
|
||
method: "PATCH",
|
||
body: JSON.stringify(data),
|
||
}),
|
||
remove: (id: number) => request<void>(`/api/integrations/${id}`, { method: "DELETE" }),
|
||
test: (data: { type: IntegrationType; config: Record<string, string | boolean> }) =>
|
||
request<{ ok: boolean; latencyMs?: number; error?: string }>("/api/integrations/test", {
|
||
method: "POST",
|
||
body: JSON.stringify(data),
|
||
}),
|
||
getConfig: (id: number) =>
|
||
request<{
|
||
integration: { id: number; type: IntegrationType; name: string; enabled: boolean };
|
||
config: Record<string, string | boolean>;
|
||
}>(`/api/integrations/${id}/config`),
|
||
testExisting: (id: number, config: Record<string, string | boolean>) =>
|
||
request<{ ok: boolean; latencyMs?: number; error?: string }>(`/api/integrations/${id}/test`, {
|
||
method: "POST",
|
||
body: JSON.stringify({ config }),
|
||
}),
|
||
tailscale: {
|
||
devices: (integrationId: number) =>
|
||
request<TailscaleDevicesResponse>(`/api/integrations/${integrationId}/tailscale/devices`),
|
||
setAuthorized: (integrationId: number, deviceId: string, authorized: boolean) =>
|
||
request<void>(`/api/integrations/${integrationId}/tailscale/devices/${encodeURIComponent(deviceId)}/authorize`, {
|
||
method: "POST",
|
||
body: JSON.stringify({ authorized }),
|
||
}),
|
||
remove: (integrationId: number, deviceId: string) =>
|
||
request<void>(`/api/integrations/${integrationId}/tailscale/devices/${encodeURIComponent(deviceId)}`, {
|
||
method: "DELETE",
|
||
}),
|
||
},
|
||
gitea: {
|
||
repos: (integrationId: number) => request<{ repos: GiteaRepo[] }>(`/api/integrations/${integrationId}/gitea/repos`),
|
||
rerunFailed: (integrationId: number, owner: string, repo: string, runId: number) =>
|
||
request<void>(
|
||
`/api/integrations/${integrationId}/gitea/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/runs/${runId}/rerun-failed`,
|
||
{ method: "POST" },
|
||
),
|
||
},
|
||
dockhand: {
|
||
containers: (integrationId: number) =>
|
||
request<DockhandContainersResponse>(`/api/integrations/${integrationId}/dockhand/containers`),
|
||
vulnerabilities: (integrationId: number) => request<DockhandVulnerabilitiesResponse>(`/api/integrations/${integrationId}/dockhand/vulnerabilities`),
|
||
leaveAlone: (integrationId: number, environmentName: string, name: string, leaveAlone: boolean) =>
|
||
request<{ containerIgnore: string[] }>(`/api/integrations/${integrationId}/dockhand/leave-alone`, { method: "PUT", body: JSON.stringify({ environmentName, name, leaveAlone }) }),
|
||
start: (integrationId: number, envId: number, containerId: string) =>
|
||
request<void>(
|
||
`/api/integrations/${integrationId}/dockhand/environments/${envId}/containers/${encodeURIComponent(containerId)}/start`,
|
||
{ method: "POST" },
|
||
),
|
||
stop: (integrationId: number, envId: number, containerId: string) =>
|
||
request<void>(
|
||
`/api/integrations/${integrationId}/dockhand/environments/${envId}/containers/${encodeURIComponent(containerId)}/stop`,
|
||
{ method: "POST" },
|
||
),
|
||
restart: (integrationId: number, envId: number, containerId: string) =>
|
||
request<void>(
|
||
`/api/integrations/${integrationId}/dockhand/environments/${envId}/containers/${encodeURIComponent(containerId)}/restart`,
|
||
{ method: "POST" },
|
||
),
|
||
checkForUpdates: (integrationId: number) =>
|
||
request<{ total: number; updatesFound: number }>(`/api/integrations/${integrationId}/dockhand/check-updates`, {
|
||
method: "POST",
|
||
}),
|
||
},
|
||
uptimekuma: {
|
||
monitors: (integrationId: number) =>
|
||
request<UptimeKumaMonitorsResponse>(`/api/integrations/${integrationId}/uptimekuma/monitors`),
|
||
},
|
||
pbs: {
|
||
datastores: (integrationId: number) =>
|
||
request<PbsDatastoresResponse>(`/api/integrations/${integrationId}/pbs/datastores`),
|
||
status: (integrationId: number) =>
|
||
request<PbsNodeStatus>(`/api/integrations/${integrationId}/pbs/status`),
|
||
},
|
||
osticket: {
|
||
tickets: (integrationId: number) =>
|
||
request<OsTicketTicketsResponse>(`/api/integrations/${integrationId}/osticket/tickets`),
|
||
},
|
||
semaphore: {
|
||
templates: (integrationId: number) =>
|
||
request<SemaphoreTemplatesResponse>(`/api/integrations/${integrationId}/semaphore/templates`),
|
||
/** `limit` runs it on those hosts only (ansible's --limit). */
|
||
run: (integrationId: number, projectId: number, templateId: number, options?: { limit?: string }) =>
|
||
request<{ task: SemaphoreTask }>(
|
||
`/api/integrations/${integrationId}/semaphore/projects/${projectId}/templates/${templateId}/run`,
|
||
{ method: "POST", body: JSON.stringify(options ?? {}) },
|
||
),
|
||
task: (integrationId: number, projectId: number, taskId: number) =>
|
||
request<{ task: SemaphoreTask }>(`/api/integrations/${integrationId}/semaphore/projects/${projectId}/tasks/${taskId}`),
|
||
},
|
||
proxmox: {
|
||
guests: (integrationId: number) => request<ProxmoxGuestsResponse>(`/api/integrations/${integrationId}/proxmox/guests`),
|
||
nodes: (integrationId: number) => request<ProxmoxNodesResponse>(`/api/integrations/${integrationId}/proxmox/nodes`),
|
||
backups: (integrationId: number) => request<ProxmoxBackupsResponse>(`/api/integrations/${integrationId}/proxmox/backups`),
|
||
start: (integrationId: number, node: string, type: ProxmoxGuestType, vmid: number) =>
|
||
request<void>(`/api/integrations/${integrationId}/proxmox/nodes/${node}/${type}/${vmid}/start`, { method: "POST" }),
|
||
stop: (integrationId: number, node: string, type: ProxmoxGuestType, vmid: number) =>
|
||
request<void>(`/api/integrations/${integrationId}/proxmox/nodes/${node}/${type}/${vmid}/stop`, { method: "POST" }),
|
||
restart: (integrationId: number, node: string, type: ProxmoxGuestType, vmid: number) =>
|
||
request<void>(`/api/integrations/${integrationId}/proxmox/nodes/${node}/${type}/${vmid}/restart`, { method: "POST" }),
|
||
shutdown: (integrationId: number, node: string, type: ProxmoxGuestType, vmid: number) =>
|
||
request<void>(`/api/integrations/${integrationId}/proxmox/nodes/${node}/${type}/${vmid}/shutdown`, { method: "POST" }),
|
||
},
|
||
synology: {
|
||
storage: (integrationId: number) => request<SynologyStorageResponse>(`/api/integrations/${integrationId}/synology/storage`),
|
||
system: (integrationId: number) => request<SynologySystemInfo>(`/api/integrations/${integrationId}/synology/system`),
|
||
},
|
||
},
|
||
settings: {
|
||
get: () => request<{ settings: AppSettings }>("/api/settings"),
|
||
providerColors: () => request<{ providerColors: Record<string, string> }>("/api/settings/provider-colors"),
|
||
integrationColors: () => request<{ integrationColors: Record<string, string> }>("/api/settings/integration-colors"),
|
||
display: () => request<{ display: DisplaySettings }>("/api/settings/display"),
|
||
update: (data: AppSettingsPatch) =>
|
||
request<{ settings: AppSettings }>("/api/settings", { method: "PUT", body: JSON.stringify(data) }),
|
||
testGotify: (data: { url: string; token: string; priority?: number }) =>
|
||
request<{ ok: true }>("/api/settings/test-gotify", { method: "POST", body: JSON.stringify(data) }),
|
||
testNtfy: (data: { url: string; topic: string; token?: string; priority?: number }) =>
|
||
request<{ ok: true }>("/api/settings/test-ntfy", { method: "POST", body: JSON.stringify(data) }),
|
||
testSmtp: (data: { host: string; port?: number; secure?: boolean; username?: string; password?: string; from: string; to: string }) =>
|
||
request<{ ok: true }>("/api/settings/test-smtp", { method: "POST", body: JSON.stringify(data) }),
|
||
testWebhook: (data: { url: string; secret?: string }) =>
|
||
request<{ ok: true }>("/api/settings/test-webhook", { method: "POST", body: JSON.stringify(data) }),
|
||
purgeLogs: () =>
|
||
request<{ diagDeleted: number; auditDeleted: number }>("/api/settings/purge-logs", { method: "POST" }),
|
||
exportConfig: (passphrase: string) =>
|
||
request<EncryptedExportFile>("/api/settings/export", { method: "POST", body: JSON.stringify({ passphrase }) }),
|
||
importConfig: (passphrase: string, file: EncryptedExportFile) =>
|
||
request<ImportResult>("/api/settings/import", { method: "POST", body: JSON.stringify({ passphrase, file }) }),
|
||
quietHoursQueue: () =>
|
||
request<{ count: number; items: { id: number; title: string; message: string; createdAt: string }[] }>(
|
||
"/api/settings/quiet-hours-queue",
|
||
),
|
||
flushQuietHours: () => request<{ flushed: number }>("/api/settings/flush-quiet-hours", { method: "POST" }),
|
||
digestPreview: () => request<{ title: string; message: string; quiet: boolean; channels: number }>("/api/settings/digest/preview"),
|
||
digestSend: () => request<{ sent: boolean; channels: number }>("/api/settings/digest/send", { method: "POST" }),
|
||
},
|
||
};
|