declare namespace Api {
  namespace PersonalItem {
    interface PageParams {
      pageNo: number;
      pageSize: number;
    }

    type PersonalItemStatusCode = 'pending' | 'active' | 'paused' | 'completed' | 'cancelled';

    interface PersonalItemLifecycleAction {
      actionCode: string;
      actionName: string;
      needReason: boolean;
    }

    interface PersonalItem {
      id: string;
      taskTitle: string;
      type: string;
      ownerId: string;
      statusCode: PersonalItemStatusCode;
      terminal?: boolean;
      allowEdit?: boolean;
      availableActions?: PersonalItemLifecycleAction[] | null;
      progressRate: number;
      totalSpentHours?: number | null;
      plannedStartDate: string | null;
      plannedEndDate: string | null;
      actualStartDate: string | null;
      actualEndDate: string | null;
      taskDesc: string | null;
      lastStatusReason: string | null;
      attachments: Api.Project.AttachmentItem[] | null;
      creator: string;
      createTime: string;
      updater: string;
      updateTime: string;
      deleted: boolean;
      ownerName?: string | null;
      ownerNickname?: string | null;
      statusName?: string | null;
    }

    type PersonalItemSearchParams = CommonType.RecordNullable<
      Pick<PageParams, 'pageNo' | 'pageSize'> & {
        keyword: string;
        ownerId: string;
        statusCode: PersonalItemStatusCode;
        updateTime: string[];
      }
    >;

    interface PersonalItemPageResult {
      total: number;
      list: PersonalItem[];
    }

    interface SavePersonalItemParams {
      taskTitle: string;
      type: string;
      ownerId?: string;
      executionId?: string | null;
      progressRate?: number | null;
      plannedStartDate: string | null;
      plannedEndDate: string | null;
      taskDesc: string | null;
      attachments: Api.Project.AttachmentItem[] | null;
    }

    interface UpdatePersonalItemParams extends SavePersonalItemParams {
      id: string;
    }

    interface ChangePersonalItemStatusParams {
      actionCode: string;
      reason?: string | null;
    }

    interface PersonalItemExecutionOption {
      executionId: string;
      executionName: string;
      projectId?: string | null;
      projectName?: string | null;
    }

    interface BatchDeletePersonalItemParams {
      ids: string[];
    }

    interface BindPersonalItemExecutionParams {
      ids: string[];
      executionId: string;
    }

    type PersonalItemWorklog = Api.Project.TaskWorklog;
    type PersonalItemWorklogSearchParams = Api.Project.TaskWorklogSearchParams;
    type SavePersonalItemWorklogParams = Api.Project.SaveTaskWorklogParams;
  }
}
