feat!: release v2 (#6545)
Co-authored-by: Artur <145776561+arturict@users.noreply.github.com> Co-authored-by: arturict <arturict@users.noreply.github.com> Co-authored-by: Thomas <thomas@ajnart.fr> Co-authored-by: Afonso Jorge Ramos <afonsojorgeramos@gmail.com> Co-authored-by: Danura30082 <danura30082+github@gmail.com> Co-authored-by: Kushie <122986913+kushiemoon-dev@users.noreply.github.com> Co-authored-by: ajnart <thomas@ajnart.fr> Co-authored-by: ajnart <thomas@ajnart.dev> Co-authored-by: chenjun <chenjun@foxmail.com> Co-authored-by: Wikibear <wikibear@users.noreply.github.com> Co-authored-by: Bergasha <bergasha@gmail.com> Co-authored-by: leafyelin <43306196+leafyelin@users.noreply.github.com> Co-authored-by: Lucas Araujo <lucas.lra@gmail.com> Co-authored-by: GreenMonito <86085570+GreenMonito@users.noreply.github.com> Co-authored-by: Nerdy-Technician <roffo@nerdy-technician.social> Co-authored-by: Jun <34545896+jcstrong@users.noreply.github.com> Co-authored-by: Edmond Abraham <54119952+gitedmond@users.noreply.github.com> Co-authored-by: thrawnx <tight.bulb9384@fastmail.com> Co-authored-by: Chris <58918656+nordada@users.noreply.github.com> Co-authored-by: yi111 <153097222+Yi-111-a@users.noreply.github.com> Co-authored-by: Yanis <naamaneyanis@gmail.com> Co-authored-by: Wikibear <me@sej.de> Co-authored-by: alessiottavo <93441886+alessiottavo@users.noreply.github.com>
This commit is contained in:
3286 files changed
+284386
-139176
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { isRecord } from "@homarr/common";
|
||||
import { ResponseError } from "@homarr/common/server";
|
||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||
import { ErrorWithMetadata } from "@homarr/core/infrastructure/logs/error";
|
||||
@@ -10,6 +11,7 @@ import type { SessionStore } from "../base/session-store";
|
||||
import { createSessionStore } from "../base/session-store";
|
||||
import { TestConnectionError } from "../base/test-connection/test-connection-error";
|
||||
import type { TestingResult } from "../base/test-connection/test-connection-service";
|
||||
import type { IntegrationHttpAuthentication } from "../http-auth";
|
||||
import type {
|
||||
BeszelAlert,
|
||||
BeszelAlertHistory,
|
||||
@@ -66,7 +68,7 @@ export const normalizeRealtimeSnapshot = (
|
||||
const id = `realtime-${receivedAt.getTime()}`;
|
||||
const events: LiveStatsEvent[] = [];
|
||||
|
||||
if (payload.stats && typeof payload.stats === "object" && !Array.isArray(payload.stats)) {
|
||||
if (isRecord(payload.stats)) {
|
||||
events.push({
|
||||
type: "system_stats",
|
||||
record: { id, system: systemId, stats: payload.stats, type: "1m", created, updated: created },
|
||||
@@ -131,7 +133,29 @@ export class BeszelIntegration extends Integration {
|
||||
this.sessionStore = createSessionStore(integration);
|
||||
}
|
||||
|
||||
public override async getHttpAuthenticationAsync(): Promise<IntegrationHttpAuthentication> {
|
||||
const session = await this.authenticateAsync();
|
||||
|
||||
return {
|
||||
headers: { Authorization: session.token },
|
||||
redactValues: [session.token],
|
||||
};
|
||||
}
|
||||
|
||||
private pendingAuthentication: Promise<BeszelSession> | undefined;
|
||||
|
||||
private async authenticateAsync(): Promise<BeszelSession> {
|
||||
if (this.pendingAuthentication) return await this.pendingAuthentication;
|
||||
const pending = this.loadSessionAsync();
|
||||
this.pendingAuthentication = pending;
|
||||
try {
|
||||
return await pending;
|
||||
} finally {
|
||||
this.pendingAuthentication = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
private async loadSessionAsync(): Promise<BeszelSession> {
|
||||
const existingSession = await this.sessionStore.getAsync();
|
||||
if (existingSession && !isSessionExpired(existingSession)) {
|
||||
logger.debug("Using stored Beszel session", { integrationId: this.integration.id });
|
||||
@@ -151,6 +175,7 @@ export class BeszelIntegration extends Integration {
|
||||
const response = await fetchWithTrustedCertificatesAsync(authUrl, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
redirect: "error",
|
||||
body: JSON.stringify({
|
||||
identity: this.getSecretValue("username"),
|
||||
password: this.getSecretValue("password"),
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface BeszelSystemInfo {
|
||||
dp: number;
|
||||
/** battery [level%, charging state] */
|
||||
bat?: [number, number];
|
||||
/** bandwidth — public interface (Mbps, legacy). Use bb when available */
|
||||
/** bandwidth — public interface (MiB/s, legacy). Use bb when available */
|
||||
b?: number;
|
||||
/** bandwidth — public interface (bytes/s, newer format). Preferred over b */
|
||||
bb?: number;
|
||||
@@ -94,9 +94,9 @@ export interface BeszelSystemDetails {
|
||||
*
|
||||
* Units:
|
||||
* - CPU/GPU/memory/disk percentages: 0–100
|
||||
* - Memory/disk absolute values (mu, du, m, d, etc.): GB
|
||||
* - Disk I/O (dr, dw): MB/s
|
||||
* - Network (ns, nr): bytes/s — all interfaces (including loopback, docker bridges)
|
||||
* - Memory/disk absolute values (mu, du, m, d, etc.): GiB
|
||||
* - Disk I/O (dr, dw): MiB/s
|
||||
* - Legacy network (ns, nr): MiB/s — all interfaces (including loopback, docker bridges)
|
||||
* - Bandwidth (b): bytes/s [sent, recv] — public interfaces only. Prefer b over ns/nr for user-facing charts
|
||||
*/
|
||||
export interface BeszelSystemStats {
|
||||
@@ -110,49 +110,49 @@ export interface BeszelSystemStats {
|
||||
cpus?: number[];
|
||||
/** load average [1m, 5m, 15m] */
|
||||
la?: [number, number, number];
|
||||
/** total memory (GB) */
|
||||
/** total memory (GiB) */
|
||||
m: number;
|
||||
/** memory used (GB) */
|
||||
/** memory used (GiB) */
|
||||
mu: number;
|
||||
/** memory usage (%) */
|
||||
mp: number;
|
||||
/** memory buffer/cache (GB) */
|
||||
/** memory buffer/cache (GiB) */
|
||||
mb: number;
|
||||
/** memory max used (GB) */
|
||||
/** memory max used (GiB) */
|
||||
mm?: number;
|
||||
/** memory zfs arc (GB) */
|
||||
/** memory zfs arc (GiB) */
|
||||
mz?: number;
|
||||
/** total swap (GB) */
|
||||
/** total swap (GiB) */
|
||||
s: number;
|
||||
/** swap used (GB) */
|
||||
/** swap used (GiB) */
|
||||
su: number;
|
||||
/** total disk (GB) */
|
||||
/** total disk (GiB) */
|
||||
d: number;
|
||||
/** disk used (GB) */
|
||||
/** disk used (GiB) */
|
||||
du: number;
|
||||
/** disk usage (%) */
|
||||
dp: number;
|
||||
/** disk read (MB/s) */
|
||||
/** disk read (MiB/s) */
|
||||
dr?: number;
|
||||
/** disk write (MB/s) */
|
||||
/** disk write (MiB/s) */
|
||||
dw?: number;
|
||||
/** disk read max (MB/s) */
|
||||
/** disk read max (MiB/s) */
|
||||
drm?: number;
|
||||
/** disk write max (MB/s) */
|
||||
/** disk write max (MiB/s) */
|
||||
dwm?: number;
|
||||
/** disk IOPS [read, write] */
|
||||
/** disk throughput [read bytes/s, write bytes/s]. Prefer over dr/dw */
|
||||
dio?: [number, number];
|
||||
/** disk IOPS max [read, write] */
|
||||
/** disk throughput max [read bytes/s, write bytes/s] */
|
||||
diom?: [number, number];
|
||||
/** network sent — all interfaces (bytes/s) */
|
||||
/** legacy network sent — all interfaces (MiB/s) */
|
||||
ns?: number;
|
||||
/** network received — all interfaces (bytes/s) */
|
||||
/** legacy network received — all interfaces (MiB/s) */
|
||||
nr?: number;
|
||||
/** bandwidth — public interfaces only (bytes/s) [sent, recv]. Prefer over ns/nr */
|
||||
b?: [number, number];
|
||||
/** network sent max (bytes/s) */
|
||||
/** legacy network sent max (MiB/s) */
|
||||
nsm?: number;
|
||||
/** network received max (bytes/s) */
|
||||
/** legacy network received max (MiB/s) */
|
||||
nrm?: number;
|
||||
/** bandwidth max [sent, recv] (bytes/s) */
|
||||
bm?: [number, number];
|
||||
@@ -173,21 +173,21 @@ export interface BeszelExtraFsStats {
|
||||
d: number;
|
||||
/** disk used (GiB) */
|
||||
du: number;
|
||||
/** read (bytes/s) */
|
||||
/** legacy disk read (MiB/s) */
|
||||
r: number;
|
||||
/** write (bytes/s) */
|
||||
/** legacy disk write (MiB/s) */
|
||||
w: number;
|
||||
/** read max (bytes/s) */
|
||||
/** legacy disk read max (MiB/s) */
|
||||
rm?: number;
|
||||
/** write max (bytes/s) */
|
||||
/** legacy disk write max (MiB/s) */
|
||||
wm?: number;
|
||||
/** read (IOPS) */
|
||||
/** disk read (bytes/s) */
|
||||
rb?: number;
|
||||
/** write (IOPS) */
|
||||
/** disk write (bytes/s) */
|
||||
wb?: number;
|
||||
/** read max (IOPS) */
|
||||
/** disk read max (bytes/s) */
|
||||
rbm?: number;
|
||||
/** write max (IOPS) */
|
||||
/** disk write max (bytes/s) */
|
||||
wbm?: number;
|
||||
}
|
||||
|
||||
@@ -236,18 +236,18 @@ export interface BeszelContainer {
|
||||
* One entry per container in a BeszelContainerStatsRecord.
|
||||
*
|
||||
* Network fields: b (bandwidth) is preferred when available; fall back to ns/nr.
|
||||
* Units: m = MB, c = %, b/ns/nr = bytes/s
|
||||
* Units: m/ns/nr = MiB or MiB/s, c = %, b = bytes/s
|
||||
*/
|
||||
export interface BeszelContainerStats {
|
||||
/** container name */
|
||||
n: string;
|
||||
/** CPU usage (%) */
|
||||
c: number;
|
||||
/** memory usage (MB) */
|
||||
/** memory usage (MiB) */
|
||||
m: number;
|
||||
/** network sent (bytes/s) — legacy, use b when available */
|
||||
/** network sent (MiB/s) — legacy, use b when available */
|
||||
ns?: number;
|
||||
/** network received (bytes/s) — legacy, use b when available */
|
||||
/** network received (MiB/s) — legacy, use b when available */
|
||||
nr?: number;
|
||||
/** network bandwidth [sent, recv] (bytes/s) — preferred over ns/nr */
|
||||
b?: [number, number];
|
||||
@@ -388,7 +388,7 @@ export interface BeszelSystemRow {
|
||||
gpu: number;
|
||||
/** load average [1m, 5m, 15m] */
|
||||
loadAvg: [number, number, number] | null;
|
||||
/** public interface bandwidth (bytes/s). From info.bb or info.b * 1M */
|
||||
/** public interface bandwidth (bytes/s). From info.bb or legacy info.b normalized from MiB/s */
|
||||
netBytes: number;
|
||||
/** temperature (°C) */
|
||||
temp: number | null;
|
||||
|
||||
@@ -13,6 +13,7 @@ const BESZEL_PASSWORD = process.env.BESZEL_TEST_PASSWORD ?? "";
|
||||
const closeAgent = vi.hoisted(() => vi.fn().mockResolvedValue(undefined));
|
||||
|
||||
vi.mock("@homarr/redis", () => ({
|
||||
getIntegrationSessionStoreKey: (integrationId: string) => `session-store:${integrationId}`,
|
||||
createGetSetChannel: () => ({
|
||||
getAsync: vi.fn().mockResolvedValue(null),
|
||||
setAsync: vi.fn().mockResolvedValue(undefined),
|
||||
|
||||
@@ -12,6 +12,7 @@ vi.hoisted(() => {
|
||||
const store = vi.hoisted(() => new Map<string, { value: string; ttlSeconds?: number }>());
|
||||
|
||||
vi.mock("@homarr/redis", () => ({
|
||||
getIntegrationSessionStoreKey: (integrationId: string) => `session-store:${integrationId}`,
|
||||
createGetSetChannel: (name: string) => ({
|
||||
getAsync: () => Promise.resolve(store.get(name)?.value ?? null),
|
||||
setAsync: (value: string, options?: { ttlSeconds?: number }) => {
|
||||
|
||||
Reference in new issue
Block a user