Files
CapaKraken/packages/api/src/router/timeline-read-schema-support.ts
T
Hartmut 17471af7f8
CI / Architecture Guardrails (push) Successful in 3m38s
CI / Assistant Split Regression (push) Successful in 4m40s
CI / Lint (push) Successful in 5m17s
CI / Typecheck (push) Successful in 5m46s
CI / Build (push) Successful in 7m1s
CI / Unit Tests (push) Failing after 9m41s
CI / Release Images (push) Has been cancelled
CI / Fresh-Linux Docker Deploy (push) Has been cancelled
CI / E2E Tests (push) Has started running
security: bound Zod inputs, add SSE per-user cap and tRPC body limit (#51, PR #59)
Closes #51 (ESLint rule + conventions doc remain as follow-up).

Co-authored-by: Hartmut Nörenberg <hn@hartmut-noerenberg.com>
Co-committed-by: Hartmut Nörenberg <hn@hartmut-noerenberg.com>
2026-04-18 13:53:28 +02:00

41 lines
1.3 KiB
TypeScript

import { z } from "zod";
const idFilter = () => z.array(z.string().max(64)).max(500);
const chapterFilter = () => z.array(z.string().max(100)).max(100);
const countryFilter = () => z.array(z.string().max(8)).max(300);
const dateStr = () => z.string().max(32);
export const TimelineWindowFiltersSchema = z.object({
startDate: z.coerce.date(),
endDate: z.coerce.date(),
resourceIds: idFilter().optional(),
projectIds: idFilter().optional(),
clientIds: idFilter().optional(),
chapters: chapterFilter().optional(),
eids: idFilter().optional(),
countryCodes: countryFilter().optional(),
});
export const TimelineDetailFiltersSchema = z.object({
startDate: dateStr().optional(),
endDate: dateStr().optional(),
durationDays: z.number().int().min(1).max(366).optional(),
resourceIds: idFilter().optional(),
projectIds: idFilter().optional(),
clientIds: idFilter().optional(),
chapters: chapterFilter().optional(),
eids: idFilter().optional(),
countryCodes: countryFilter().optional(),
});
export const TimelineProjectContextDetailSchema = z.object({
projectId: z.string().max(64),
startDate: dateStr().optional(),
endDate: dateStr().optional(),
durationDays: z.number().int().min(1).max(366).optional(),
});
export const TimelineProjectIdSchema = z.object({
projectId: z.string().max(64),
});