refactor(trpc): type openapi fetch handler and form-data parsing

This commit is contained in:
ephraimduncan
2026-08-15 13:52:02 +00:00
parent 688ef2fdf3
commit 53ccd42ee8
13 changed files with 1421 additions and 27 deletions
+2 -3
View File
@@ -5,7 +5,6 @@ import {
BRANDING_LOGO_MAX_SIZE_MB,
} from '@documenso/lib/constants/branding';
import { megabytesToBytes } from '@documenso/lib/universal/unit-convertions';
import type { ZodRawShape } from 'zod';
import z from 'zod';
import { zfd } from 'zod-form-data';
@@ -49,10 +48,10 @@ export const zfdBrandingImageFile = () => {
* an error. This provides the same functionality as `zfd.formData()` but
* can be considered somewhat safer.
*/
export const zodFormData = <T extends ZodRawShape>(schema: T) => {
export const zodFormData = <T extends Parameters<typeof z.object>[0]>(schema: T) => {
return z.preprocess((data) => {
if (data instanceof FormData) {
const formData: Record<string, unknown> = {};
const formData: Record<string, FormDataEntryValue | FormDataEntryValue[]> = {};
for (const key of data.keys()) {
const values = data.getAll(key);