Files
homarr/packages/old-schema/src/tile.ts
Meier Lukas 5404cebf5b 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
2024-09-07 18:13:24 +02:00

56 lines
1.1 KiB
TypeScript

import { z } from "zod";
const createAreaSchema = <TType extends string, TPropertiesSchema extends z.AnyZodObject>(
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,
});