1import { z } from "zod";
2import { WORKSPACE_ROLES, WORKSPACE_TYPES } from "../../constants.js";
3
4export const CreateWorkspaceDto = z.object({
5 name: z.string().min(1).max(50),
6 slug: z
7 .string()
8 .min(2)
9 .max(50)
10 .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)
11 .optional()
12});
13export type CreateWorkspaceInput = z.infer<typeof CreateWorkspaceDto>;
14
15export const UpdateWorkspaceDto = z.object({
16 name: z.string().min(1).max(50).optional(),
17 slug: z.string().min(2).max(50).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/).optional(),
18 description: z.string().max(500).nullable().optional(),
19 iconUrl: z.string().url().max(2048).nullable().optional(),
20
21 type: z.enum(WORKSPACE_TYPES).optional()
22});
23export type UpdateWorkspaceInput = z.infer<typeof UpdateWorkspaceDto>;
24
25
26
27
28export const ListWorkspacesQuery = z.object({
29 search: z.string().max(100).optional(),
30 type: z.enum(WORKSPACE_TYPES).optional(),
31 archived: z.enum(["true", "false"]).optional(),
32 sort: z.enum(["name", "recent", "created"]).optional()
33});
34export type ListWorkspacesInput = z.infer<typeof ListWorkspacesQuery>;
35
36export const InviteMemberDto = z.object({
37 email: z.string().email().max(254),
38 role: z.enum(WORKSPACE_ROLES).default("MEMBER")
39});
40export type InviteMemberInput = z.infer<typeof InviteMemberDto>;
41
42export const UpdateMemberRoleDto = z.object({
43 role: z.enum(WORKSPACE_ROLES)
44});
45export type UpdateMemberRoleInput = z.infer<typeof UpdateMemberRoleDto>;
46
47export const TransferWorkspaceDto = z.object({
48 newOwnerId: z.string().min(1)
49});
50export type TransferWorkspaceInput = z.infer<typeof TransferWorkspaceDto>;
51
52export const ListMembersQuery = z.object({
53 search: z.string().max(100).optional(),
54 cursor: z.string().optional(),
55 limit: z.string().optional()
56});
57export type ListMembersInput = z.infer<typeof ListMembersQuery>;
58