Replace entire codebase with homarr-labs/homarr
This commit is contained in:
76
packages/old-schema/src/app.ts
Normal file
76
packages/old-schema/src/app.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { z } from "zod/v4";
|
||||
|
||||
import { tileBaseSchema } from "./tile";
|
||||
|
||||
const appBehaviourSchema = z.object({
|
||||
externalUrl: z.string(),
|
||||
isOpeningNewTab: z.boolean().catch(true),
|
||||
tooltipDescription: z.string().optional().catch(undefined),
|
||||
});
|
||||
|
||||
const appNetworkSchema = z.object({
|
||||
enabledStatusChecker: z.boolean().catch(true),
|
||||
okStatus: z.array(z.number()).optional().catch([]),
|
||||
statusCodes: z.array(z.string()).catch([]),
|
||||
});
|
||||
|
||||
const appAppearanceSchema = z.object({
|
||||
iconUrl: z.string(),
|
||||
appNameStatus: z.union([z.literal("normal"), z.literal("hover"), z.literal("hidden")]).catch("normal"),
|
||||
positionAppName: z
|
||||
.union([z.literal("row"), z.literal("column"), z.literal("row-reverse"), z.literal("column-reverse")])
|
||||
.catch("column"),
|
||||
appNameFontSize: z.number().catch(16),
|
||||
lineClampAppName: z.number().catch(1),
|
||||
});
|
||||
|
||||
const integrationSchema = z.enum([
|
||||
"readarr",
|
||||
"radarr",
|
||||
"sonarr",
|
||||
"lidarr",
|
||||
"prowlarr",
|
||||
"sabnzbd",
|
||||
"jellyseerr",
|
||||
"overseerr",
|
||||
"deluge",
|
||||
"qBittorrent",
|
||||
"transmission",
|
||||
"plex",
|
||||
"jellyfin",
|
||||
"nzbGet",
|
||||
"pihole",
|
||||
"adGuardHome",
|
||||
"homeAssistant",
|
||||
"openmediavault",
|
||||
"proxmox",
|
||||
"tdarr",
|
||||
]);
|
||||
|
||||
export type OldmarrIntegrationType = z.infer<typeof integrationSchema>;
|
||||
|
||||
const appIntegrationPropertySchema = z.object({
|
||||
type: z.enum(["private", "public"]),
|
||||
field: z.enum(["apiKey", "password", "username"]),
|
||||
value: z.string().nullable().optional(),
|
||||
isDefined: z.boolean().optional(),
|
||||
});
|
||||
|
||||
const appIntegrationSchema = z.object({
|
||||
type: integrationSchema.optional().nullable(),
|
||||
properties: z.array(appIntegrationPropertySchema),
|
||||
});
|
||||
|
||||
export const oldmarrAppSchema = z
|
||||
.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
url: z.string(),
|
||||
behaviour: appBehaviourSchema,
|
||||
network: appNetworkSchema,
|
||||
appearance: appAppearanceSchema,
|
||||
integration: appIntegrationSchema.optional().nullable(),
|
||||
})
|
||||
.and(tileBaseSchema);
|
||||
|
||||
export type OldmarrApp = z.infer<typeof oldmarrAppSchema>;
|
||||
32
packages/old-schema/src/config.ts
Normal file
32
packages/old-schema/src/config.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { z } from "zod/v4";
|
||||
|
||||
import { oldmarrAppSchema } from "./app";
|
||||
import { settingsSchema } from "./setting";
|
||||
import { oldmarrWidgetSchema } from "./widget";
|
||||
|
||||
const categorySchema = z.object({
|
||||
id: z.string(),
|
||||
position: z.number(),
|
||||
name: z.string(),
|
||||
});
|
||||
|
||||
const wrapperSchema = z.object({
|
||||
id: z.string(),
|
||||
position: z.number(),
|
||||
});
|
||||
|
||||
export const oldmarrConfigSchema = z.object({
|
||||
schemaVersion: z.number(),
|
||||
configProperties: z.object({
|
||||
name: z.string(),
|
||||
}),
|
||||
categories: z.array(categorySchema),
|
||||
wrappers: z.array(wrapperSchema),
|
||||
apps: z.array(oldmarrAppSchema),
|
||||
widgets: z.array(oldmarrWidgetSchema),
|
||||
settings: settingsSchema,
|
||||
});
|
||||
|
||||
export type OldmarrConfig = z.infer<typeof oldmarrConfigSchema>;
|
||||
export type OldmarrCategorySection = z.infer<typeof categorySchema>;
|
||||
export type OldmarrEmptySection = z.infer<typeof wrapperSchema>;
|
||||
7
packages/old-schema/src/index.ts
Normal file
7
packages/old-schema/src/index.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export type { OldmarrConfig, OldmarrCategorySection, OldmarrEmptySection } from "./config";
|
||||
export { oldmarrConfigSchema } from "./config";
|
||||
export type { OldmarrApp, OldmarrIntegrationType } from "./app";
|
||||
export type { OldmarrWidget, OldmarrWidgetKind } from "./widget";
|
||||
export { oldmarrWidgetKinds } from "./widget";
|
||||
export { boardSizes, getBoardSizeName } from "./tile";
|
||||
export type { BoardSize, SizedShape } from "./tile";
|
||||
81
packages/old-schema/src/setting.ts
Normal file
81
packages/old-schema/src/setting.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { z } from "zod/v4";
|
||||
|
||||
const baseSearchEngineSchema = z.object({
|
||||
properties: z.object({
|
||||
openInNewTab: z.boolean().default(true),
|
||||
enabled: z.boolean().default(true),
|
||||
}),
|
||||
});
|
||||
|
||||
const commonSearchEngineSchema = z
|
||||
.object({
|
||||
type: z.enum(["google", "duckDuckGo", "bing"]),
|
||||
})
|
||||
.and(baseSearchEngineSchema);
|
||||
|
||||
const customSearchEngineSchema = z
|
||||
.object({
|
||||
type: z.literal("custom"),
|
||||
properties: z.object({
|
||||
template: z.string(),
|
||||
}),
|
||||
})
|
||||
.and(baseSearchEngineSchema);
|
||||
|
||||
const searchEngineSchema = z.union([commonSearchEngineSchema, customSearchEngineSchema]);
|
||||
|
||||
const commonSettingsSchema = z.object({
|
||||
searchEngine: searchEngineSchema,
|
||||
});
|
||||
|
||||
const accessSettingsSchema = z.object({
|
||||
allowGuests: z.boolean(),
|
||||
});
|
||||
|
||||
const gridstackSettingsSchema = z
|
||||
.object({
|
||||
columnCountSmall: z.number(),
|
||||
columnCountMedium: z.number(),
|
||||
columnCountLarge: z.number(),
|
||||
})
|
||||
.catch({
|
||||
columnCountSmall: 3,
|
||||
columnCountMedium: 6,
|
||||
columnCountLarge: 12,
|
||||
});
|
||||
|
||||
const layoutSettingsSchema = z.object({
|
||||
enabledLeftSidebar: z.boolean(),
|
||||
enabledRightSidebar: z.boolean(),
|
||||
enabledDocker: z.boolean(),
|
||||
enabledPing: z.boolean(),
|
||||
enabledSearchbar: z.boolean(),
|
||||
});
|
||||
|
||||
const colorsSettingsSchema = z.object({
|
||||
primary: z.string().optional(),
|
||||
secondary: z.string().optional(),
|
||||
shade: z.number().optional(),
|
||||
});
|
||||
|
||||
const customizationSettingsSchema = z.object({
|
||||
layout: layoutSettingsSchema,
|
||||
pageTitle: z.string().optional(),
|
||||
metaTitle: z.string().optional(),
|
||||
logoImageUrl: z.string().optional(),
|
||||
faviconUrl: z.string().optional(),
|
||||
backgroundImageUrl: z.string().optional(),
|
||||
backgroundImageAttachment: z.enum(["fixed", "scroll"]).optional(),
|
||||
backgroundImageSize: z.enum(["cover", "contain"]).optional(),
|
||||
backgroundImageRepeat: z.enum(["no-repeat", "repeat", "repeat-x", "repeat-y"]).optional(),
|
||||
customCss: z.string().optional(),
|
||||
colors: colorsSettingsSchema,
|
||||
appOpacity: z.number().optional(),
|
||||
gridstack: gridstackSettingsSchema,
|
||||
});
|
||||
|
||||
export const settingsSchema = z.object({
|
||||
common: commonSettingsSchema,
|
||||
customization: customizationSettingsSchema,
|
||||
access: accessSettingsSchema,
|
||||
});
|
||||
74
packages/old-schema/src/tile.ts
Normal file
74
packages/old-schema/src/tile.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import { z } from "zod/v4";
|
||||
|
||||
import { objectKeys } from "@homarr/common";
|
||||
|
||||
const createAreaSchema = <TType extends string, TPropertiesSchema extends z.ZodObject>(
|
||||
type: TType,
|
||||
propertiesSchema: TPropertiesSchema,
|
||||
) =>
|
||||
z.object({
|
||||
type: z.literal(type),
|
||||
properties: propertiesSchema,
|
||||
});
|
||||
|
||||
const wrapperAreaSchema = createAreaSchema(
|
||||
"wrapper",
|
||||
z.object({
|
||||
id: z.string(),
|
||||
}),
|
||||
);
|
||||
|
||||
const categoryAreaSchema = createAreaSchema(
|
||||
"category",
|
||||
z.object({
|
||||
id: z.string(),
|
||||
}),
|
||||
);
|
||||
|
||||
const sidebarAreaSchema = createAreaSchema(
|
||||
"sidebar",
|
||||
z.object({
|
||||
location: z.union([z.literal("right"), z.literal("left")]),
|
||||
}),
|
||||
);
|
||||
|
||||
const areaSchema = z.union([wrapperAreaSchema, categoryAreaSchema, sidebarAreaSchema]);
|
||||
|
||||
const sizedShapeSchema = z.object({
|
||||
location: z.object({
|
||||
x: z.number(),
|
||||
y: z.number(),
|
||||
}),
|
||||
size: z.object({
|
||||
width: z.number(),
|
||||
height: z.number(),
|
||||
}),
|
||||
});
|
||||
|
||||
const shapeSchema = z.object({
|
||||
lg: sizedShapeSchema.optional(),
|
||||
md: sizedShapeSchema.optional(),
|
||||
sm: sizedShapeSchema.optional(),
|
||||
});
|
||||
|
||||
export const tileBaseSchema = z.object({
|
||||
area: areaSchema,
|
||||
shape: shapeSchema,
|
||||
});
|
||||
|
||||
export type SizedShape = z.infer<typeof sizedShapeSchema>;
|
||||
|
||||
export const boardSizes = objectKeys(shapeSchema.def.shape);
|
||||
export type BoardSize = (typeof boardSizes)[number];
|
||||
|
||||
export const getBoardSizeName = (size: BoardSize) => {
|
||||
switch (size) {
|
||||
case "md":
|
||||
return "medium";
|
||||
case "sm":
|
||||
return "small";
|
||||
case "lg":
|
||||
default:
|
||||
return "large";
|
||||
}
|
||||
};
|
||||
40
packages/old-schema/src/widget.ts
Normal file
40
packages/old-schema/src/widget.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { z } from "zod/v4";
|
||||
|
||||
import { tileBaseSchema } from "./tile";
|
||||
|
||||
export const oldmarrWidgetKinds = [
|
||||
"calendar",
|
||||
"indexer-manager",
|
||||
"dashdot",
|
||||
"usenet",
|
||||
"weather",
|
||||
"torrents-status",
|
||||
"dlspeed",
|
||||
"date",
|
||||
"rss",
|
||||
"video-stream",
|
||||
"iframe",
|
||||
"media-server",
|
||||
"media-requests-list",
|
||||
"media-requests-stats",
|
||||
"dns-hole-summary",
|
||||
"dns-hole-controls",
|
||||
"bookmark",
|
||||
"notebook",
|
||||
"smart-home/entity-state",
|
||||
"smart-home/trigger-automation",
|
||||
"health-monitoring",
|
||||
"media-transcoding",
|
||||
] as const;
|
||||
|
||||
export type OldmarrWidgetKind = (typeof oldmarrWidgetKinds)[number];
|
||||
|
||||
export const oldmarrWidgetSchema = z
|
||||
.object({
|
||||
id: z.string(),
|
||||
type: z.enum(oldmarrWidgetKinds),
|
||||
properties: z.record(z.string(), z.unknown()),
|
||||
})
|
||||
.and(tileBaseSchema);
|
||||
|
||||
export type OldmarrWidget = z.infer<typeof oldmarrWidgetSchema>;
|
||||
Reference in New Issue
Block a user