feat: add import for config files from oldmarr (#1019)
* wip: add oldmarr config import
* wip: add support for wrong amount of categories / sections with autofix, color mapping, position adjustments of wrappers
* fix: lockfile broken
* feat: add support for form data trpc requests
* wip: improve file upload
* refactor: restructure import, add import configuration
* wip: add configurations for import to modal
* refactor: move oldmarr import to old-import package
* fix: column count not respects screen size for board
* feat: add beta badge for oldmarr config import
* chore: address pull request feedback
* fix: format issues
* fix: inconsistent versions
* fix: deepsource issues
* fix: revert {} to Record<string, never> convertion to prevent typecheck issue
* fix: inconsistent zod version
* fix: format issue
* chore: address pull request feedback
* fix: wrong import
* fix: broken lock file
* fix: inconsistent versions
* fix: format issues
This commit is contained in:
75
packages/old-schema/src/setting.ts
Normal file
75
packages/old-schema/src/setting.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import { z } from "zod";
|
||||
|
||||
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(),
|
||||
});
|
||||
|
||||
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,
|
||||
});
|
||||
Reference in New Issue
Block a user