From ae5508794389f78825f39454a809ad0a8bc4c67f Mon Sep 17 00:00:00 2001 From: tobinio Date: Wed, 20 May 2026 19:29:32 +0200 Subject: [PATCH] remove unused zod definitions --- app/utils/types.ts | 123 ++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 73 deletions(-) diff --git a/app/utils/types.ts b/app/utils/types.ts index 3b441c2..dac9cf3 100644 --- a/app/utils/types.ts +++ b/app/utils/types.ts @@ -1,78 +1,55 @@ -import { z } from "zod"; - export type UUID = string; -const TimeRange = z.object({ - type: z.literal("range"), - start: z.iso.date(), - end: z.iso.date(), -}); -export type TimeRange = Omit, "type">; - -const TimePoint = z.object({ - type: z.literal("point"), - time: z.iso.datetime(), -}); -export type TimePoint = Omit, "type">; - -const TimeRecurringDaily = z.object({ - type: z.literal("recurring"), - mode: z.literal("daily"), -}); +export type TimeRange = { + start: string; // ISO date + end: string; // ISO date +}; -const TimeRecurringWeekly = z.object({ - type: z.literal("recurring"), - mode: z.literal("weekly"), - start: z.number().optional(), - end: z.number().optional(), -}); - -const TimeRecurring = z.discriminatedUnion("mode", [ - TimeRecurringDaily, - TimeRecurringWeekly, -]); +export type TimePoint = { + time: string; // ISO datetime +}; export type TimeRecurring = - | Omit, "type"> - | Omit, "type">; - -export const Time = z.discriminatedUnion("type", [ - TimeRange, - TimePoint, - TimeRecurring, -]); -export type Time = z.infer; - -export const PushSubscriptionJSON = z.object({ - endpoint: z.string(), - expirationTime: z.number().nullable().optional(), - keys: z.object({ - auth: z.string(), - p256dh: z.string(), - }), -}); -export type PushSubscriptionJSON = z.infer; - -export const Todo = z.object({ - uuid: z.uuid(), - title: z.string().min(1), - note: z.string(), - time: Time.optional(), - tags: z.array(z.uuid()), - category: z.uuid().optional(), - checks: z.array(z.iso.date()), -}); -export type Todo = z.infer; -export type TodoData = Omit; - -export const Label = z.object({ - uuid: z.uuid(), - name: z.string().min(1), - color: z.string().startsWith("#").length(7), -}); -export type Label = z.infer; - -export const Category = Label.extend({ - icon: z.string(), -}); -export type Category = z.infer; + | { + mode: "daily"; + } + | { + mode: "weekly"; + start?: number; + end?: number; + }; + +export type Time = + | (TimeRange & { type: "range" }) + | (TimePoint & { type: "point" }) + | (TimeRecurring & { type: "recurring" }); + +export type TodoData = { + title: string; + note: string; + time?: Time; + tags: UUID[]; + category?: UUID; + checks: string[]; // ISO dates +}; + +export type Todo = TodoData & { uuid: UUID }; + +export type Label = { + uuid: UUID; + name: string; + color: string; // "#RRGGBB" +}; + +export type Category = Label & { + icon: string; +}; + +export type PushSubscriptionJSON = { + endpoint: string; + expirationTime?: number | null; + keys: { + auth: string; + p256dh: string; + }; +}; -- 2.51.2