import { z } from 'zod' import { UserType } from '@shumai/db/enums' import { paginationPageInfoSchema, paginationParamsSchema } from './pagination' import { assetTypeFilterSchema } from './asset' export const createProjectRequestSchema = z.object({ name: z.string(), coverImageKey: z.string().optional(), enableNotification: z.boolean().default(true), }) export type CreateProjectRequest = z.infer export const updateProjectRequestSchema = z.object({ name: z.string().optional(), coverImageKey: z.string().optional(), enableNotification: z.boolean().optional(), }) export type UpdateProjectRequest = z.infer export const projectInfoSchema = z.object({ id: z.string(), name: z.string(), teamId: z.string(), rootFolder: z.string().optional(), coverImage: z.string().optional(), coverImageKey: z.string().optional(), enableNotification: z.boolean(), updatedAt: z.union([z.string(), z.date()]), }) export type ProjectInfo = z.infer import { previewFormatSchema, type PreviewFormat } from './search' export const listProjectsRequestSchema = z .object({ sortBy: z.string().optional(), sortDirection: z.enum(['asc', 'desc']).optional(), previewFormat: previewFormatSchema.optional(), }) .merge(paginationParamsSchema) export const listUserProjectsRequestSchema = z .object({ previewFormat: previewFormatSchema.optional(), }) .merge(paginationParamsSchema) export type ListUserProjectsRequest = z.infer export const listProjectsResponseSchema = z.object({ data: z.array(projectInfoSchema), pageInfo: paginationPageInfoSchema, }) export const getProjectTeamResponseSchema = z.object({ teamId: z.string(), }) export type GetProjectTeamResponse = z.infer export const projectUserInfoSchema = z.object({ id: z.string(), name: z.string(), role: z.enum(['owner', 'editor', 'reviewer', 'bot', 'unknown']), type: z.nativeEnum(UserType).optional(), image: z.string().optional(), scope: z.enum(['team', 'project']).optional(), hasCustomRole: z.boolean().optional(), }) export type ProjectUserInfo = z.infer export const recentlyDeletedRequestSchema = z .object({ assetType: assetTypeFilterSchema.optional().default('all'), sort: z.enum(['createdAt', 'name', 'size']).optional(), order: z.enum(['asc', 'desc']).optional(), }) .merge(paginationParamsSchema) export const updateProjectMemberRoleRequestSchema = z.object({ role: z.enum(['editor', 'reviewer']), }) export type UpdateProjectMemberRoleRequest = z.infer // Service Layer Interfaces export interface ServiceCreateProjectRequest { teamId: string name: string coverImageKey?: string enableNotification?: boolean } export interface ServiceUpdateProjectRequest { projectId: string name?: string coverImageKey?: string enableNotification?: boolean } export interface ServiceListProjectsRequest { teamId: string userId: string sortBy?: string sortDirection?: 'asc' | 'desc' previewFormat?: PreviewFormat pagination: z.infer } export interface ServiceAddProjectMemberRequest { projectId: string userId: string role: 'owner' | 'editor' | 'reviewer' | 'bot' | 'unknown' } export interface ServiceListProjectMembersRequest { projectId: string includeAgents?: boolean requesterUserId?: string } export interface ServiceUpdateProjectMemberRoleRequest { projectId: string userId: string role: 'editor' | 'reviewer' } export const addProjectMemberRequestSchema = z.object({ userId: z.string(), role: z.enum(['owner', 'editor', 'reviewer']), }) export type AddProjectMemberRequest = z.infer export const projectMeResponseSchema = z.object({ id: z.string(), name: z.string(), role: z.enum(['owner', 'editor', 'reviewer', 'bot', 'unknown']), image: z.string().optional(), }) export type ProjectMeResponse = z.infer