1import { z } from "zod";
2
3export const UpdateProfileDto = z.object({
4 name: z.string().min(1).max(100).optional(),
5 displayName: z.string().min(1).max(50).optional(),
6 email: z.string().email().max(254).optional(),
7 password: z.string().min(8).max(72).optional(),
8 currentPassword: z.string().min(1).max(72).optional(),
9 avatarUrl: z.string().url().max(2048).nullable().optional(),
10 locale: z.string().max(10).optional(),
11 timezone: z.string().max(50).optional(),
12 theme: z.enum(["light", "dark", "system"]).optional()
13});
14export type UpdateProfileInput = z.infer<typeof UpdateProfileDto>;
15
16export const ListUsersQuery = z.object({
17 workspaceId: z.string().min(1),
18 search: z.string().max(100).optional(),
19 cursor: z.string().optional(),
20 limit: z.string().optional()
21});
22export type ListUsersInput = z.infer<typeof ListUsersQuery>;
23
24
25
26export const RECENT_ITEM_TYPES = ["page", "database", "whiteboard", "task"] as const;
27export const RecordRecentItemDto = z.object({
28 itemType: z.enum(RECENT_ITEM_TYPES),
29 refId: z.string().min(1)
30});
31export type RecordRecentItemInput = z.infer<typeof RecordRecentItemDto>;
32
33
34
35const isoDate = z.string().refine((v) => Number.isFinite(Date.parse(v)), { message: "invalid ISO-8601 date" });
36const SEARCH_TYPES = ["page", "block", "database", "record", "comment", "file", "user"] as const;
37
38
39
40
41
42const SavedSearchQuery = z.object({
43 q: z.string().trim().min(1).max(200),
44 types: z.array(z.enum(SEARCH_TYPES)).max(7).optional(),
45 workspaceId: z.string().min(1).optional(),
46 teamId: z.string().min(1).optional(),
47 createdBy: z.string().min(1).optional(),
48 updatedAfter: isoDate.optional(),
49 updatedBefore: isoDate.optional(),
50 cursor: z.string().min(1).optional(),
51 limit: z.number().int().min(1).max(50).optional()
52});
53
54export const SavedSearchCreateDto = z.object({
55 name: z.string().min(1).max(100),
56 workspaceId: z.string().min(1).nullable().optional(),
57 query: SavedSearchQuery
58});
59export type SavedSearchCreateInput = z.infer<typeof SavedSearchCreateDto>;
60
61export const SavedSearchUpdateDto = z.object({
62 name: z.string().min(1).max(100).optional(),
63 workspaceId: z.string().min(1).nullable().optional(),
64 query: SavedSearchQuery.optional()
65});
66export type SavedSearchUpdateInput = z.infer<typeof SavedSearchUpdateDto>;
67