Files
pulsenode/lib/config/schema.ts
T

52 lines
1.4 KiB
TypeScript
Raw Normal View History

2026-08-17 13:49:55 +02:00
import { z } from "zod";
const searchEngineSchema = z.enum(["duckduckgo", "google", "bing"]);
export const bookmarkWidgetSchema = z.object({
type: z.literal("bookmark"),
name: z.string(),
href: z.string().url(),
description: 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 widgetSchema = z.discriminatedUnion("type", [
bookmarkWidgetSchema,
searchWidgetSchema,
]);
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" });
export const configSchema = z.object({
theme: themeSchema,
settings: settingsSchema,
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>;