task.ts 5.6 KB

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