task.ts 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /**
  2. * $table->text('description',512)->nullable();
  3. $table->jsonb('assignees')->index()->nullable();
  4. $table->jsonb('roles')->index()->nullable();
  5. $table->uuid('executor')->index()->nullable();
  6. $table->uuid('executor_relation_task')->index()->nullable();
  7. $table->uuid('parent')->index()->nullable();
  8. $table->jsonb('pre_task')->index()->nullable();
  9. $table->uuid('owner')->index();
  10. $table->uuid('editor')->index();
  11. $table->string('status',32)->index()->default('pending');
  12. $table->timestamps();
  13. */
  14. import type { IStudio } from "../auth/Studio"
  15. import type { IUser } from "../auth/User"
  16. import type { TPrivacy } from "./ai"
  17. export type TTaskStatus =
  18. | "pending"
  19. | "published"
  20. | "running"
  21. | "done"
  22. | "restarted"
  23. | "requested_restart"
  24. | "closed"
  25. | "canceled"
  26. | "expired"
  27. | "queue"
  28. | "stop"
  29. | "quit"
  30. | "pause";
  31. export const StatusButtons: TTaskStatus[] = [
  32. "pending",
  33. "published",
  34. "running",
  35. "done",
  36. "restarted",
  37. "requested_restart",
  38. "quit",
  39. ];
  40. export type TTaskType = "instance" | "workflow" | "group";
  41. export interface IProject {
  42. id: string;
  43. sn: number;
  44. title: string;
  45. description: string | null;
  46. weight: number;
  47. }
  48. export type TTaskCategory =
  49. | "translate"
  50. | "suggest"
  51. | "vocabulary"
  52. | "team"
  53. | "review"
  54. | "proofread";
  55. export const ATaskCategory: TTaskCategory[] = [
  56. "translate",
  57. "suggest",
  58. "vocabulary",
  59. "team",
  60. "review",
  61. "proofread",
  62. ];
  63. export interface ITaskData {
  64. id: string;
  65. title: string;
  66. description?: string | null;
  67. category?: TTaskCategory | null;
  68. progress?: number;
  69. html?: string | null;
  70. type: TTaskType;
  71. order?: number;
  72. assignees?: IUser[] | null;
  73. assignees_id?: string[] | null;
  74. parent?: ITaskData | null;
  75. parent_id?: string | null;
  76. roles?: string[] | null;
  77. executor?: IUser | null;
  78. executor_id?: string | null;
  79. executor_relation_task?: ITaskData | null;
  80. executor_relation_task_id?: string | null;
  81. pre_task?: ITaskData[] | null;
  82. pre_task_id?: string | null;
  83. next_task?: ITaskData[] | null;
  84. next_task_id?: string | null;
  85. is_milestone: boolean;
  86. project?: IProject | null;
  87. project_id?: string | null;
  88. owner?: IStudio;
  89. owner_id?: string | null;
  90. editor?: IUser;
  91. editor_id?: string | null;
  92. status?: TTaskStatus;
  93. created_at?: string;
  94. updated_at?: string;
  95. started_at?: string | null;
  96. finished_at?: string | null;
  97. children?: ITaskData[];
  98. }
  99. export interface ITaskUpdateRequest {
  100. id: string;
  101. studio_name: string;
  102. title?: string;
  103. description?: string | null;
  104. category?: TTaskCategory | null;
  105. type?: TTaskType;
  106. assignees_id?: string[] | null;
  107. parent_id?: string | null;
  108. project_id?: string | null;
  109. roles?: string[] | null;
  110. executor_id?: string | null;
  111. executor_relation_task_id?: string | null;
  112. pre_task_id?: string | null;
  113. next_task_id?: string | null;
  114. is_milestone?: boolean;
  115. status?: string;
  116. }
  117. export interface ITaskListResponse {
  118. ok: boolean;
  119. message: string;
  120. data: {
  121. rows: ITaskData[];
  122. count: number;
  123. };
  124. }
  125. export interface ITaskCreateRequest {
  126. title: string;
  127. studio: string;
  128. type: TTaskType;
  129. }
  130. export interface ITaskResponse {
  131. ok: boolean;
  132. message: string;
  133. data: ITaskData;
  134. }
  135. /**
  136. * $table->uuid('id')->primary()->default(DB::raw('uuid_generate_v1mc()'));
  137. $table->string('title',512)->index();
  138. $table->boolean('is_template')->index()->default(false);
  139. $table->text('description')->nullable();
  140. $table->jsonb('executors')->index()->nullable();
  141. $table->uuid('parent')->index()->nullable();
  142. $table->jsonb('milestone')->index()->nullable();
  143. $table->uuid('owner')->index();
  144. $table->uuid('editor')->index();
  145. $table->jsonb('status')->index();
  146. $table->timestamps();
  147. */
  148. export interface IProjectData {
  149. id: string;
  150. title: string;
  151. type: TProjectType;
  152. weight: number;
  153. description: string | null;
  154. parent?: IProjectData | null;
  155. parent_id?: string | null;
  156. path?: IProjectData[] | null;
  157. executors?: IUser[] | null;
  158. milestone?: IMilestoneInProject[] | null;
  159. owner: IStudio;
  160. editor: IUser;
  161. status: ITaskStatusInProject[];
  162. privacy: TPrivacy;
  163. created_at: string;
  164. updated_at: string;
  165. deleted_at?: string | null;
  166. started_at?: string | null;
  167. finished_at?: string | null;
  168. children?: IProjectData[];
  169. }
  170. export interface IProjectUpdateRequest {
  171. id?: string;
  172. studio_name?: string;
  173. title: string;
  174. type: TProjectType;
  175. privacy?: TPrivacy;
  176. weight?: number;
  177. description?: string | null;
  178. parent_id?: string | null;
  179. res_id?: string;
  180. }
  181. export interface IProjectListResponse {
  182. data: { rows: IProjectData[]; count: number };
  183. message: string;
  184. ok: boolean;
  185. }
  186. export interface IProjectResponse {
  187. data: IProjectData;
  188. message: string;
  189. ok: boolean;
  190. }
  191. export type TProjectType = "instance" | "workflow" | "endpoint";
  192. export interface IProjectCreateRequest {
  193. title: string;
  194. type: TProjectType;
  195. studio_name: string;
  196. }
  197. export interface IMilestoneData {
  198. id: string;
  199. title: string;
  200. }
  201. export interface IMilestoneCount {
  202. value: number;
  203. total: number;
  204. }
  205. export interface IMilestoneInProject {
  206. milestone: IMilestoneData;
  207. projects: IMilestoneCount;
  208. chars: IMilestoneCount;
  209. }
  210. export interface ITaskStatusInProject {
  211. status: string;
  212. count: number;
  213. percent: number;
  214. }
  215. export interface ITaskGroupInsertRequest {
  216. data: ITaskGroupInsertData[];
  217. }
  218. export interface ITaskGroupInsertData {
  219. project_id: string;
  220. tasks: ITaskData[];
  221. }
  222. export interface ITaskGroupResponse {
  223. ok: boolean;
  224. message: string;
  225. data: { taskCount: number; taskRelationCount: number };
  226. }
  227. export interface IProjectTreeInsertRequest {
  228. studio_name: string;
  229. parent_id?: string | null;
  230. title?: string;
  231. data: IProjectUpdateRequest[];
  232. }
  233. export interface IProjectTreeData {
  234. id: string;
  235. resId?: string;
  236. isLeaf: boolean;
  237. }
  238. export interface IProjectTreeResponse {
  239. ok: boolean;
  240. message: string;
  241. data: { rows: IProjectTreeData[]; count: number };
  242. }