Files
Nexus/packages/api/src/router/project.ts
T
Hartmut 9bd3781c03 fix(types): flatten tRPC Zod schema types to resolve TS2589 inference depth errors
Cast Zod schemas with .refine()/.superRefine() to z.ZodType<InferredType> at the
procedure level. This short-circuits TypeScript's deep type recursion through
tRPC's middleware chain, eliminating 4 of 5 @ts-expect-error TS2589 suppressions
in web components (VacationModal, ProjectModal, UsersClient, CountriesClient).

Applied same pattern to allocation, timeline, staffing, dashboard, project, and
resource query/mutation procedures to reduce client-side type depth.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-10 15:28:12 +02:00

49 lines
1.8 KiB
TypeScript

import type { z } from "zod";
import { projectCostReadProcedures } from "./project-cost-read.js";
import { projectCoverProcedures } from "./project-cover.js";
import { projectIdentifierReadProcedures } from "./project-identifier-read.js";
import { createProjectLifecycleProcedures } from "./project-lifecycle.js";
import { createProjectMutationProcedures } from "./project-mutations.js";
import { createProjectBackgroundEffects } from "./project-background-effects.js";
import {
getProjectById,
getProjectShoringRatioData,
listProjects,
ProjectIdInputSchema,
ProjectListInputSchema,
ProjectShoringRatioInputSchema,
} from "./project-procedure-support.js";
import { controllerProcedure, createTRPCRouter } from "../trpc.js";
const projectBackgroundEffects = createProjectBackgroundEffects();
export const projectRouter = createTRPCRouter({
...projectCostReadProcedures,
...projectCoverProcedures,
...projectIdentifierReadProcedures,
...createProjectLifecycleProcedures({
invalidateDashboardCacheInBackground:
projectBackgroundEffects.invalidateDashboardCacheInBackground,
dispatchProjectWebhookInBackground: projectBackgroundEffects.dispatchProjectWebhookInBackground,
}),
...createProjectMutationProcedures(projectBackgroundEffects),
list: controllerProcedure
.input(
ProjectListInputSchema as z.ZodType<
z.infer<typeof ProjectListInputSchema>,
z.ZodTypeDef,
z.input<typeof ProjectListInputSchema>
>,
)
.query(({ ctx, input }) => listProjects(ctx, input)),
getById: controllerProcedure
.input(ProjectIdInputSchema)
.query(({ ctx, input }) => getProjectById(ctx, input)),
getShoringRatio: controllerProcedure
.input(ProjectShoringRatioInputSchema)
.query(({ ctx, input }) => getProjectShoringRatioData(ctx, input)),
});