Files
pulsenode/lib/config/schema.ts
T
valknar 4308169608
CI / Static checks (push) Successful in 34s
CI / Build and push image (push) Skipped
feat: brand icons for widgets, fix stale accent color
Two separate issues, both real bugs:

- Dark mode was showing light blue instead of green: config.yml still
  had a leftover --pn-accent: #38bdf8 override from before the design
  redesign, which won via the runtime theme injector regardless of
  what app/globals.css defaulted to. Removed the override and pushed
  the dark-mode default from a soft mint (#5ee08c) to an actual neon
  green (#39ff88) - closer to what "neon" means and closer to the real
  phosphor-green a cardiac monitor trace uses, which fits the pulse
  metaphor better than the pastel version did.

- No per-service brand icons anywhere. Added an optional `icon` field
  to docker/bookmark widgets (a key into lib/brand-icons.ts) rather
  than guessing from containerName, since a heuristic would silently
  misfire for anyone's own container naming. database widgets derive
  their icon automatically from `engine` (postgres/redis) since that's
  already required and unambiguous. Icon path data comes from the CC0
  simple-icons package via scripts/extract-brand-icons.py, extracted
  and committed as plain TS data (lib/brand-icons.ts) rather than
  imported live - keeps it self-hosted (no unpkg.com/CDN calls at
  runtime, matching the fonts) and pinned regardless of dependency
  updates. Rendered monochrome (currentColor, not each brand's own
  hex) to stay consistent with the single-accent design rather than a
  dozen competing colors - only the shape carries the identity.

Wired real icons into config.yml for every service that has one:
traefik, coolify, gitea (+ gitea_runner), immich (+ immich_ml), n8n,
passbolt, umami, headscale, plus postgresql/redis on every database
widget. code and mailpit have no brand match in the curated set, so
they render without one rather than a wrong/generic substitute.

Verified in the actual rendered page: compiled CSS confirms
--pn-accent is #39ff88 (dark) / #339a5a (light) with no trace of the
old #38bdf8, and all 18 expected icon instances (10 docker + 8
database widgets) are present.
2026-08-17 17:55:27 +02:00

129 lines
3.4 KiB
TypeScript

import { z } from "zod";
const searchEngineSchema = z.enum(["duckduckgo", "google", "bing"]);
const durationSchema = z
.string()
.regex(/^\d+(ms|s|m|h)$/, 'Expected a duration like "500ms", "5s", "1m", or "1h"');
export const bookmarkWidgetSchema = z.object({
type: z.literal("bookmark"),
name: z.string(),
href: z.string().url(),
description: z.string().optional(),
icon: z.string().optional(),
});
export const searchWidgetSchema = z.object({
type: z.literal("search"),
engines: z.array(searchEngineSchema).min(1).default(["duckduckgo"]),
defaultEngine: searchEngineSchema.optional(),
});
export const dockerWidgetSchema = z.object({
type: z.literal("docker"),
name: z.string(),
containerName: z.string(),
href: z.string().url().optional(),
showStats: z.boolean().default(true),
interval: durationSchema.default("5s"),
icon: z.string().optional(),
});
export const databaseWidgetSchema = z.object({
type: z.literal("database"),
name: z.string(),
containerName: z.string(),
engine: z.enum(["postgres", "redis"]),
interval: durationSchema.default("10s"),
});
export const systemWidgetSchema = z.object({
type: z.literal("system"),
name: z.string().default("System"),
interval: durationSchema.default("5s"),
});
export const httpWidgetSchema = z.object({
type: z.literal("http"),
name: z.string(),
url: z.string().url(),
method: z.enum(["GET", "HEAD", "POST"]).default("GET"),
timeout: durationSchema.default("5s"),
interval: durationSchema.default("30s"),
expect: z
.object({
status: z.number().int().min(100).max(599).default(200),
})
.default({ status: 200 }),
});
export const traefikWidgetSchema = z.object({
type: z.literal("traefik"),
name: z.string().default("Traefik"),
apiUrl: z.string().url(),
interval: durationSchema.default("15s"),
});
export const widgetSchema = z.discriminatedUnion("type", [
bookmarkWidgetSchema,
searchWidgetSchema,
dockerWidgetSchema,
databaseWidgetSchema,
systemWidgetSchema,
httpWidgetSchema,
traefikWidgetSchema,
]);
export const groupSchema = z.object({
name: z.string(),
widgets: z.array(widgetSchema),
});
export const themeSchema = z
.object({
mode: z.enum(["dark", "light", "auto"]).default("dark"),
variables: z.record(z.string(), z.string()).default({}),
customCssPath: z.string().optional(),
})
.default({ mode: "dark", variables: {} });
export const settingsSchema = z
.object({
title: z.string().default("PulseNode"),
})
.default({ title: "PulseNode" });
const dockerDiscoveryDefaults = {
enabled: false,
socketPath: "/var/run/docker.sock",
labelPrefix: "traefik",
excludeLabels: [] as string[],
};
const dockerDiscoverySchema = z.object({
enabled: z.boolean().default(false),
socketPath: z.string().default("/var/run/docker.sock"),
labelPrefix: z.string().default("traefik"),
network: z.string().optional(),
excludeLabels: z.array(z.string()).default([]),
});
export const discoverySchema = z
.object({
docker: dockerDiscoverySchema.default(dockerDiscoveryDefaults),
})
.default({ docker: dockerDiscoveryDefaults });
export const configSchema = z.object({
theme: themeSchema,
settings: settingsSchema,
discovery: discoverySchema,
groups: z.array(groupSchema).default([]),
});
export type Config = z.infer<typeof configSchema>;
export type Widget = z.infer<typeof widgetSchema>;
export type Group = z.infer<typeof groupSchema>;
export type SearchEngine = z.infer<typeof searchEngineSchema>;