refactor: remove central validation export to improve typescript performance (#2810)

* refactor: remove central validation export to improve typescript performance

* fix: missing package exports change in validation package

* chore: address pull request feedback
This commit is contained in:
Meier Lukas
2025-04-06 12:37:28 +02:00
committed by GitHub
parent c1cd563048
commit 75ba3f2ae7
81 changed files with 450 additions and 582 deletions

View File

@@ -5,7 +5,7 @@ import { AppForm } from "@homarr/forms-collection";
import { createModal } from "@homarr/modals";
import { showErrorNotification, showSuccessNotification } from "@homarr/notifications";
import { useI18n, useScopedI18n } from "@homarr/translation/client";
import type { validation } from "@homarr/validation";
import type { appManageSchema } from "@homarr/validation/app";
interface QuickAddAppModalProps {
onClose: (createdAppId: string) => Promise<void>;
@@ -24,7 +24,7 @@ export const QuickAddAppModal = createModal<QuickAddAppModalProps>(({ actions, i
},
});
const handleSubmit = (values: z.infer<typeof validation.app.manage>) => {
const handleSubmit = (values: z.infer<typeof appManageSchema>) => {
mutate(values, {
async onSuccess({ appId }) {
showSuccessNotification({

View File

@@ -8,11 +8,11 @@ import { useZodForm } from "@homarr/form";
import { createModal } from "@homarr/modals";
import { showErrorNotification, showSuccessNotification } from "@homarr/notifications";
import { useI18n } from "@homarr/translation/client";
import { validation } from "@homarr/validation";
import { boardColumnCountSchema, boardCreateSchema, boardNameSchema } from "@homarr/validation/board";
export const AddBoardModal = createModal(({ actions }) => {
const t = useI18n();
const form = useZodForm(validation.board.create, {
const form = useZodForm(boardCreateSchema, {
mode: "controlled",
initialValues: {
name: "",
@@ -28,7 +28,7 @@ export const AddBoardModal = createModal(({ actions }) => {
const boardNameStatus = useBoardNameStatus(form.values.name);
const columnCountChecks = validation.board.create.shape.columnCount._def.checks;
const columnCountChecks = boardColumnCountSchema._def.checks;
const minColumnCount = columnCountChecks.find((check) => check.kind === "min")?.value;
const maxColumnCount = columnCountChecks.find((check) => check.kind === "max")?.value;
@@ -97,7 +97,7 @@ export const useBoardNameStatus = (name: string) => {
const t = useI18n();
const [debouncedName] = useDebouncedValue(name, 250);
const { data: boardExists, isLoading } = clientApi.board.exists.useQuery(debouncedName, {
enabled: validation.board.create.shape.name.safeParse(debouncedName).success,
enabled: boardNameSchema.safeParse(debouncedName).success,
});
return {

View File

@@ -5,7 +5,7 @@ import type { MaybePromise } from "@homarr/common/types";
import { useZodForm } from "@homarr/form";
import { showErrorNotification, showSuccessNotification } from "@homarr/notifications";
import { useI18n } from "@homarr/translation/client";
import { validation } from "@homarr/validation";
import { boardDuplicateSchema } from "@homarr/validation/board";
import { createModal } from "../../../modals/src/creator";
import { useBoardNameStatus } from "./add-board-modal";
@@ -20,7 +20,7 @@ interface InnerProps {
export const DuplicateBoardModal = createModal<InnerProps>(({ actions, innerProps }) => {
const t = useI18n();
const form = useZodForm(validation.board.duplicate.omit({ id: true }), {
const form = useZodForm(boardDuplicateSchema.omit({ id: true }), {
mode: "controlled",
initialValues: {
name: innerProps.board.name,

View File

@@ -6,12 +6,12 @@ import { useZodForm } from "@homarr/form";
import { createModal } from "@homarr/modals";
import { showErrorNotification, showSuccessNotification } from "@homarr/notifications";
import { useI18n } from "@homarr/translation/client";
import { validation } from "@homarr/validation";
import { groupCreateSchema } from "@homarr/validation/group";
export const AddGroupModal = createModal<void>(({ actions }) => {
const t = useI18n();
const { mutate, isPending } = clientApi.group.createGroup.useMutation();
const form = useZodForm(validation.group.create, {
const form = useZodForm(groupCreateSchema, {
initialValues: {
name: "",
},