task.ts 6.0 KB

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