* chore: add initial db migration * test: add unit tests for packages auth, common, widgets * fix: deep source issues * fix: format issues * wip: add unit tests for api routers * fix: deep source issues * test: add missing unit tests for integration router * wip: board tests * test: add unit tests for board router * fix: remove unnecessary null assertions * fix: deepsource issues * fix: formatting * fix: pnpm lock * fix: lint and typecheck issues * chore: address pull request feedback * fix: non-null assertions * fix: lockfile broken
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import { z } from "zod";
|
|
|
|
import { commonItemSchema, createSectionSchema } from "./shared";
|
|
|
|
const boardNameSchema = z
|
|
.string()
|
|
.min(1)
|
|
.max(255)
|
|
.regex(/^[A-Za-z0-9-\\._]+$/);
|
|
|
|
const byNameSchema = z.object({
|
|
name: boardNameSchema,
|
|
});
|
|
|
|
const saveGeneralSettingsSchema = z.object({
|
|
pageTitle: z
|
|
.string()
|
|
.nullable()
|
|
.transform((value) => (value?.trim().length === 0 ? null : value)),
|
|
metaTitle: z
|
|
.string()
|
|
.nullable()
|
|
.transform((value) => (value?.trim().length === 0 ? null : value)),
|
|
logoImageUrl: z
|
|
.string()
|
|
.nullable()
|
|
.transform((value) => (value?.trim().length === 0 ? null : value)),
|
|
faviconImageUrl: z
|
|
.string()
|
|
.nullable()
|
|
.transform((value) => (value?.trim().length === 0 ? null : value)),
|
|
boardId: z.string(),
|
|
});
|
|
|
|
const saveSchema = z.object({
|
|
boardId: z.string(),
|
|
sections: z.array(createSectionSchema(commonItemSchema)),
|
|
});
|
|
|
|
const createSchema = z.object({ name: z.string() });
|
|
|
|
export const boardSchemas = {
|
|
byName: byNameSchema,
|
|
saveGeneralSettings: saveGeneralSettingsSchema,
|
|
save: saveSchema,
|
|
create: createSchema,
|
|
};
|