@things-factory/worklist 6.0.42 → 6.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. package/client/pages/activity-stats/activity-stats-importer.ts +97 -0
  2. package/client/pages/activity-stats/activity-stats-list-page.ts +348 -0
  3. package/client/pages/todo/approval-done-list-page.ts +340 -0
  4. package/client/pages/todo/approval-pending-list-page.ts +1 -1
  5. package/client/pages/todo/done-list-calendar-page.ts +115 -0
  6. package/client/pages/todo/done-list-page.ts +2 -3
  7. package/client/pages/todo/pickable-list-page.ts +2 -1
  8. package/client/pages/todo/todo-list-page.ts +1 -1
  9. package/client/route.ts +12 -0
  10. package/client/themes/calendar-theme.css +54 -0
  11. package/dist-client/pages/activity-stats/activity-stats-importer.d.ts +22 -0
  12. package/dist-client/pages/activity-stats/activity-stats-importer.js +100 -0
  13. package/dist-client/pages/activity-stats/activity-stats-importer.js.map +1 -0
  14. package/dist-client/pages/activity-stats/activity-stats-list-page.d.ts +62 -0
  15. package/dist-client/pages/activity-stats/activity-stats-list-page.js +326 -0
  16. package/dist-client/pages/activity-stats/activity-stats-list-page.js.map +1 -0
  17. package/dist-client/pages/todo/approval-done-list-page.d.ts +39 -0
  18. package/dist-client/pages/todo/approval-done-list-page.js +338 -0
  19. package/dist-client/pages/todo/approval-done-list-page.js.map +1 -0
  20. package/dist-client/pages/todo/approval-pending-list-page.js +1 -1
  21. package/dist-client/pages/todo/approval-pending-list-page.js.map +1 -1
  22. package/dist-client/pages/todo/done-list-calendar-page.d.ts +24 -0
  23. package/dist-client/pages/todo/done-list-calendar-page.js +107 -0
  24. package/dist-client/pages/todo/done-list-calendar-page.js.map +1 -0
  25. package/dist-client/pages/todo/done-list-page.js +2 -3
  26. package/dist-client/pages/todo/done-list-page.js.map +1 -1
  27. package/dist-client/pages/todo/pickable-list-page.d.ts +1 -0
  28. package/dist-client/pages/todo/pickable-list-page.js +2 -1
  29. package/dist-client/pages/todo/pickable-list-page.js.map +1 -1
  30. package/dist-client/pages/todo/todo-list-page.js +1 -1
  31. package/dist-client/pages/todo/todo-list-page.js.map +1 -1
  32. package/dist-client/route.d.ts +1 -1
  33. package/dist-client/route.js +9 -0
  34. package/dist-client/route.js.map +1 -1
  35. package/dist-client/tsconfig.tsbuildinfo +1 -1
  36. package/dist-server/controllers/activity-approval/_abort.js +11 -0
  37. package/dist-server/controllers/activity-approval/_abort.js.map +1 -0
  38. package/dist-server/controllers/activity-approval/abort.js +34 -0
  39. package/dist-server/controllers/activity-approval/abort.js.map +1 -0
  40. package/dist-server/controllers/activity-approval/approve.js +10 -0
  41. package/dist-server/controllers/activity-approval/approve.js.map +1 -1
  42. package/dist-server/controllers/activity-approval/delegate.js +10 -0
  43. package/dist-server/controllers/activity-approval/delegate.js.map +1 -1
  44. package/dist-server/controllers/activity-approval/reject.js +10 -0
  45. package/dist-server/controllers/activity-approval/reject.js.map +1 -1
  46. package/dist-server/controllers/activity-instance/abort.js +35 -1
  47. package/dist-server/controllers/activity-instance/abort.js.map +1 -1
  48. package/dist-server/controllers/activity-instance/adjust-xxx.js +16 -0
  49. package/dist-server/controllers/activity-instance/adjust-xxx.js.map +1 -0
  50. package/dist-server/controllers/activity-instance/assign.js +11 -0
  51. package/dist-server/controllers/activity-instance/assign.js.map +1 -1
  52. package/dist-server/controllers/activity-instance/end.js +34 -1
  53. package/dist-server/controllers/activity-instance/end.js.map +1 -1
  54. package/dist-server/controllers/activity-instance/index.js +0 -4
  55. package/dist-server/controllers/activity-instance/index.js.map +1 -1
  56. package/dist-server/controllers/activity-instance/pick.js +11 -0
  57. package/dist-server/controllers/activity-instance/pick.js.map +1 -1
  58. package/dist-server/controllers/activity-instance/post.js +10 -0
  59. package/dist-server/controllers/activity-instance/post.js.map +1 -1
  60. package/dist-server/controllers/activity-instance/start-xxx.js +16 -0
  61. package/dist-server/controllers/activity-instance/start-xxx.js.map +1 -0
  62. package/dist-server/controllers/activity-instance/terminate-xxx.js +25 -0
  63. package/dist-server/controllers/activity-instance/terminate-xxx.js.map +1 -0
  64. package/dist-server/controllers/activity-thread/_abort.js +29 -0
  65. package/dist-server/controllers/activity-thread/_abort.js.map +1 -0
  66. package/dist-server/controllers/activity-thread/abort.js +15 -2
  67. package/dist-server/controllers/activity-thread/abort.js.map +1 -1
  68. package/dist-server/controllers/activity-thread/delegate.js +10 -0
  69. package/dist-server/controllers/activity-thread/delegate.js.map +1 -1
  70. package/dist-server/controllers/activity-thread/end.js +12 -0
  71. package/dist-server/controllers/activity-thread/end.js.map +1 -1
  72. package/dist-server/controllers/activity-thread/index.js +0 -2
  73. package/dist-server/controllers/activity-thread/index.js.map +1 -1
  74. package/dist-server/controllers/activity-thread/restart.js +11 -0
  75. package/dist-server/controllers/activity-thread/restart.js.map +1 -1
  76. package/dist-server/controllers/activity-thread/save.js +13 -0
  77. package/dist-server/controllers/activity-thread/save.js.map +1 -1
  78. package/dist-server/controllers/activity-thread/start.js +10 -0
  79. package/dist-server/controllers/activity-thread/start.js.map +1 -1
  80. package/dist-server/controllers/activity-thread/submit.js +10 -0
  81. package/dist-server/controllers/activity-thread/submit.js.map +1 -1
  82. package/dist-server/service/activity-approval/activity-approval-query.js +48 -0
  83. package/dist-server/service/activity-approval/activity-approval-query.js.map +1 -1
  84. package/dist-server/service/activity-approval/activity-approval.js +1 -1
  85. package/dist-server/service/activity-approval/activity-approval.js.map +1 -1
  86. package/dist-server/service/activity-instance/activity-instance-mutation.js +0 -29
  87. package/dist-server/service/activity-instance/activity-instance-mutation.js.map +1 -1
  88. package/dist-server/service/activity-stats/activity-stats-query.js +93 -0
  89. package/dist-server/service/activity-stats/activity-stats-query.js.map +1 -0
  90. package/dist-server/service/activity-stats/activity-stats-type.js +47 -0
  91. package/dist-server/service/activity-stats/activity-stats-type.js.map +1 -0
  92. package/dist-server/service/activity-stats/index.js +6 -0
  93. package/dist-server/service/activity-stats/index.js.map +1 -0
  94. package/dist-server/service/activity-summary/activity-summary-query.js +4 -22
  95. package/dist-server/service/activity-summary/activity-summary-query.js.map +1 -1
  96. package/dist-server/service/index.js +2 -0
  97. package/dist-server/service/index.js.map +1 -1
  98. package/dist-server/tsconfig.tsbuildinfo +1 -1
  99. package/helps/worklist/activity-bank.md +22 -0
  100. package/helps/worklist/{activity-approval.md → activity-stats.md} +1 -1
  101. package/helps/worklist/draft-list.md +15 -0
  102. package/helps/worklist/worklist-concept.md +72 -0
  103. package/package.json +10 -9
  104. package/server/controllers/activity-approval/_abort.ts +20 -0
  105. package/server/controllers/activity-approval/abort.ts +44 -0
  106. package/server/controllers/activity-approval/approve.ts +13 -0
  107. package/server/controllers/activity-approval/delegate.ts +13 -0
  108. package/server/controllers/activity-approval/reject.ts +13 -0
  109. package/server/controllers/activity-instance/abort.ts +46 -2
  110. package/server/controllers/activity-instance/assign.ts +17 -1
  111. package/server/controllers/activity-instance/end.ts +45 -2
  112. package/server/controllers/activity-instance/index.ts +0 -4
  113. package/server/controllers/activity-instance/pick.ts +17 -1
  114. package/server/controllers/activity-instance/post.ts +13 -0
  115. package/server/controllers/activity-thread/_abort.ts +43 -0
  116. package/server/controllers/activity-thread/abort.ts +20 -10
  117. package/server/controllers/activity-thread/delegate.ts +13 -0
  118. package/server/controllers/activity-thread/end.ts +17 -0
  119. package/server/controllers/activity-thread/index.ts +0 -2
  120. package/server/controllers/activity-thread/restart.ts +14 -0
  121. package/server/controllers/activity-thread/save.ts +18 -0
  122. package/server/controllers/activity-thread/start.ts +13 -0
  123. package/server/controllers/activity-thread/submit.ts +13 -0
  124. package/server/service/activity-approval/activity-approval-query.ts +45 -1
  125. package/server/service/activity-approval/activity-approval.ts +1 -1
  126. package/server/service/activity-instance/activity-instance-mutation.ts +1 -23
  127. package/server/service/activity-stats/activity-stats-query.ts +94 -0
  128. package/server/service/activity-stats/activity-stats-type.ts +34 -0
  129. package/server/service/activity-stats/index.ts +3 -0
  130. package/server/service/activity-summary/activity-summary-query.ts +4 -22
  131. package/server/service/index.ts +2 -0
  132. package/things-factory.config.js +4 -1
  133. package/translations/en.json +10 -0
  134. package/translations/ko.json +12 -2
  135. package/translations/ms.json +10 -0
  136. package/translations/zh.json +10 -0
  137. package/server/controllers/activity-instance/adjust.ts +0 -25
  138. package/server/controllers/activity-instance/bid.ts +0 -52
  139. package/server/controllers/activity-instance/delegate.ts +0 -56
  140. package/server/controllers/activity-instance/start.ts +0 -20
  141. package/server/controllers/activity-instance/terminate.ts +0 -39
  142. package/server/controllers/activity-thread/adjust.ts +0 -40
  143. package/server/controllers/activity-thread/terminate.ts +0 -37
@@ -0,0 +1,22 @@
1
+ # 업무 뱅크
2
+
3
+ ## 개요
4
+
5
+ 워크리스트 시스템에서 미할당 업무들을 모아둔 곳인 업무뱅크는, 다양한 업무들을 포함하는 일종의 업무 목록 혹은 대기열(queue)입니다. 이 업무들은 일반적으로 프로젝트나 팀에서 진행해야 할 일들 중 미해결된 업무들로 구성됩니다. 업무뱅크에 포함된 업무들은 우선순위, 난이도, 기간 등 다양한 정보들을 가지고 있으며, 해당 업무를 담당하는 사용자가 할당되기 전까지는 "미할당 상태"로 존재합니다.
6
+
7
+ 업무뱅크에서 업무를 선택(pick)하면, 해당 업무를 수행할 수 있는 자격 역할을 가진 사용자가 그 업무를 자신의 TODO 리스트로 옮길 수 있습니다. 이렇게 옮겨진 업무는 해당 사용자의 개인 TODO 리스트에 추가되어, 이후 해당 사용자가 해당 업무를 수행하도록 할당됩니다.
8
+
9
+ 이러한 시스템을 통해, 업무뱅크를 통해 미할당된 업무들을 한 곳에서 모아서 효율적으로 관리할 수 있습니다. 또한, 업무를 수행하는 사용자들이 자신의 업무 선택을 할 수 있는 기능을 제공하여, 업무를 더욱 효과적으로 분배하고 업무 수행의 효율성을 높일 수 있습니다.
10
+
11
+ ## 업무 쇼핑
12
+
13
+ 아직 할당되지 않은 작업들의 리스트를 조회하고, 그 중에서 사용자가 스스로에게 해당 업무를 할당하여 수행할 수 있는 기능입니다.
14
+ 미할당 업무를 스스로에게 할당하는 것을 업무를 선택(PICK)한다고 하며, 이런 대상업무들이 업무뱅크에 리스트되어 있습니다.
15
+
16
+ 사용자가 업무뱅크에서 볼 수 있는 미할당 업무들은 사용자에게 할당되지는 않았지만, 해당 업무에 대해서 사용자가 수행할 수 있는 자격이 있는 업무들만 조회되게 됩니다.
17
+ 그러한 자격은 보통 시스템에서 부여된 역할(Role)에 의해서 결정됩니다.
18
+
19
+ 보통 업무를 정의하고 업무뱅크에 올릴 때(POST) 해당 업무를 수행할 수 있는 자격 역할(Role)을 지정하게 됩니다.
20
+ 따라서, 해당 역할(Role)을 가진 사용자들이 그 업무를 선택(PICK)할 수 있는 것입니다.
21
+
22
+ 사용자가 선택(PICK)한 업무는 나의 할일 리스트에 포함되게 되며, 업무뱅크 리스트에서 사라지게 됩니다.
@@ -1,4 +1,4 @@
1
- # ActivityApproval
1
+ # ActivityStats
2
2
 
3
3
  Paragraphs are separated by a blank line.
4
4
 
@@ -0,0 +1,15 @@
1
+ # 작성중인 업무
2
+
3
+ ## 개요
4
+
5
+ 워크리스트 시스템에서 작성중인 업무는 일반적으로 "Draft" 상태로 분류됩니다. 이러한 업무는 아직 완료되지 않았거나, 작업이 일시 중단된 상태이며, 업무를 작성하고 있는 사용자가 해당 업무를 다시 가져와서 작업을 계속할 수 있도록 보관되어야 하는 상태입니다.
6
+
7
+ 따라서, 워크리스트 시스템에서는 해당 사용자가 작성중인 업무를 리스팅할 수 있는 기능을 제공합니다. 이를 통해, 작성중인 업무를 쉽게 찾을 수 있으며, 다시 해당 업무를 가져와서 작업을 이어나갈 수 있습니다. 일반적으로, 작성중인 업무를 리스팅하는 기능은 사용자의 개인적인 작업 대시보드에서 제공되며, 해당 사용자가 작성 중인 모든 업무들의 요약 정보를 한 눈에 볼 수 있도록 구성되어 있습니다.
8
+
9
+ 또한, 해당 기능은 작성중인 업무들의 상세 정보를 확인할 수 있는 링크를 제공하여, 사용자가 해당 업무의 내용을 다시 확인하거나 수정할 수 있도록 합니다. 이러한 기능을 통해, 작성중인 업무들을 보다 쉽게 관리하고, 업무 작성에 대한 효율성을 높일 수 있습니다.
10
+
11
+ ## 작동 방식
12
+
13
+ "작성중인 업무"는 업무를 정의하고 할당하고자 하는 사용자가 업무를 기획하는 과정에서 초안작업(Draft) 중인 상태의 업무를 의미합니다.
14
+ 따라서, 이 상태의 업무는 아직 포스팅되기 전이며, 사용자가 그 과정에서 취소할 수도 있으며, 최종 완성하여 업무를 할당하거나 업무뱅크에 리스팅할 수도 있습니다.
15
+ 이렇게 작성완료되어 할당 또는 업무뱅크에 리스팅된 상태를 포스트(Posted) 상태라고 합니다.
@@ -0,0 +1,72 @@
1
+ # 워크리스트 개요
2
+
3
+ ## 유저태스크
4
+
5
+ 유저태스크(User Task)는 BPMN(Business Process Model and Notation)에서 프로세스를 구성하는 액티비티(Activity) 중 하나로, 사용자가 직접 수행하는 타입의 태스크를 의미합니다.
6
+
7
+ 유저태스크는 프로세스에서 발생하는 업무나 작업 중에서 인간의 개입이 필요한 부분을 나타내며, 일반적으로 사용자에게 할당되어 수행됩니다. 예를 들어, 고객 정보를 입력받는 폼을 작성하거나, 결재 문서를 검토하고 승인하는 과정 등이 유저태스크에 해당됩니다.
8
+
9
+ 유저태스크는 다른 액티비티와 마찬가지로 입력(Input), 출력(Output), 수행 조건(Condition) 등을 가지며, 이를 바탕으로 프로세스의 실행 흐름을 결정합니다. 또한, 유저태스크는 프로세스 진행 상황을 추적하고 모니터링할 수 있도록 사용자 인터페이스를 제공하는 것이 일반적입니다.
10
+
11
+ 유저태스크의 수행은 사용자가 직접 수행하는 것이기 때문에, 수행 시간이 상대적으로 불확실하고 변동이 큰 경우가 많습니다. 따라서, 프로세스의 설계나 구현 시에는 이러한 부분을 고려하여 적절한 조치를 취해야 합니다. 예를 들어, 대기 시간을 최소화하거나, 자동화된 예외 처리를 구현하는 등의 방법이 있습니다.
12
+
13
+ ## 워크리스트
14
+
15
+ 워크리스트(Worklist)는 BPM(Business Process Management) 시스템에서 유저태스크를 관리하는 데 사용되는 모듈입니다. 워크리스트는 사용자가 자신에게 할당된 유저태스크 목록을 제공하며, 이를 기반으로 작업을 수행하고, 결과를 제출할 수 있도록 도와줍니다.
16
+
17
+ 구체적인 기능으로는 다음과 같은 것들이 있습니다.
18
+
19
+ - 할당된 작업 목록 확인: 워크리스트는 사용자에게 할당된 모든 유저태스크 목록을 제공합니다. 이를 통해 사용자는 자신에게 할당된 작업의 현황을 한 눈에 파악할 수 있습니다.
20
+ - 작업 수행: 사용자는 워크리스트에서 제공하는 인터페이스를 통해 유저태스크를 수행할 수 있습니다. 예를 들어, 결재 문서를 검토하고 승인 또는 거절하는 등의 작업을 수행할 수 있습니다.
21
+ - 작업 상태 추적: 워크리스트는 각 유저태스크의 수행 상태를 추적하여, 현재 작업이 어느 단계에 있는지를 알려줍니다. 이를 통해 사용자는 작업이 얼마나 진행되었는지를 파악할 수 있습니다.
22
+ - 히스토리 조회: 워크리스트는 사용자가 수행한 작업의 히스토리를 제공합니다. 이를 통해 사용자는 자신이 어떤 작업을 수행했는지, 언제 수행했는지 등을 파악할 수 있습니다.
23
+ - 예외 처리: 워크리스트는 예외 상황 발생 시에도 적절한 조치를 취할 수 있도록 도와줍니다. 예를 들어, 다른 사용자에게 작업을 할당하거나, 자동으로 작업을 다시 할당하는 등의 기능을 제공합니다.
24
+
25
+ 이와 같은 기능을 통해 워크리스트는 사용자가 유저태스크를 효율적으로 수행할 수 있도록 도와주며, 프로세스의 실행을 원활하게 진행할 수 있도록 지원합니다.
26
+
27
+ ## 유저태스크 상태전이
28
+
29
+ 워크리스트에서 관리하는 유저태스크의 상태는 보통 다음과 같이 정의됩니다.
30
+
31
+ - 대기(Waiting): 유저태스크가 생성되었지만, 아직 수행 가능한 사용자가 할당되지 않은 상태입니다.
32
+ - 할당(Assigned): 유저태스크가 수행 가능한 사용자에게 할당된 상태입니다.
33
+ - 진행중(In progress): 유저태스크가 수행 중인 상태입니다.
34
+ - 보류(Hold): 유저태스크의 수행이 일시 중단된 상태입니다.
35
+ - 완료(Completed): 유저태스크의 수행이 완료된 상태입니다.
36
+
37
+ 각 상태 전이를 일으키는 이벤트는 다음과 같이 정의됩니다.
38
+
39
+ - 할당: 대기 상태의 유저태스크가 수행 가능한 사용자에게 할당됩니다.
40
+ - 수락: 할당 상태의 유저태스크가 사용자에게 수락되어 진행 중인 상태가 됩니다.
41
+ - 보류: 진행 중인 유저태스크가 보류 상태가 됩니다.
42
+ - 재개: 보류 상태의 유저태스크가 다시 진행 중인 상태가 됩니다.
43
+ - 완료: 진행 중인 유저태스크가 완료 상태가 됩니다.
44
+
45
+ ## TODO 리스트 (나의 할일 리스트)
46
+
47
+ TODO 리스트는 업무 처리에서 아직 해야 할 일들을 기록하고 추적하는 방법 중 하나입니다. 예를 들어, 업무 처리 중에 다음과 같은 상황이 생길 수 있습니다.
48
+
49
+ - 중요한 일을 먼저 처리해야 할 때
50
+ - 기한이 다가오는 일정을 놓치지 않기 위해 일정 조율이 필요할 때
51
+ - 다른 사람과 공유해야 할 정보를 적어두고 추적해야 할 때
52
+
53
+ 이런 경우, TODO 리스트를 작성하고 업무 처리 상황에 따라 업무를 우선순위에 따라 정렬하거나 필요한 정보를 추가로 작성하고 삭제하는 등의 작업을 수행할 수 있습니다. 이를 통해 업무 처리를 보다 체계적으로 관리할 수 있으며, 더욱 효율적으로 일을 처리할 수 있습니다.
54
+
55
+ 또한, TODO 리스트는 작성자의 생각을 정리하는 데에도 도움이 됩니다. 작성자가 어떤 일을 해야 하는지 명확하게 파악하고, 일을 처리하는 과정에서 생각이 더해질 경우 리스트에 추가하고, 처리가 완료된 일은 리스트에서 제거하여 업무 처리 상황을 파악할 수 있습니다. 이를 통해 업무 처리의 투명성을 높이고, 업무 처리에 대한 관리와 추적이 용이해집니다.
56
+
57
+ ## 승인 대기 리스트
58
+
59
+ 승인 대기 리스트는 업무 진행자가 자신이 수행한 업무에 대한 검토나 지속적인 추진을 위해서 관리자의 승인을 요청한 것들 중에서 내가 승인 또는 반려 처리해야하는 리스트를 보여줍니다.
60
+
61
+ 사용자는 승인 대기 리스트에서 처리하고자 하는 업무를 선택하고 승인 또는 반려 처리를 할 수 있습니다.
62
+ 이 과정에서 승인 또는 반려의 사유 등 판단의 근거를 코멘트로 남기도록 하고 있습니다.
63
+
64
+ 사용자가 승인 또는 반려한 업무 이력은 '내가 수행한 승인리스트'에서 조회할 수 있습니다.
65
+
66
+ ## 내가 수행한 승인리스트
67
+
68
+ 내가 수행한 승인리스트는 이미 처리된 승인 업무를 기록하는 리스트입니다.
69
+
70
+ 내가 수행한 승인리스트를 유지하는 것은 업무나 작업의 처리상태를 파악하고, 추후에 해당 작업이나 업무를 참조해야 할 때 유용합니다.
71
+
72
+ (이 페이지는 ChatGPT로 작성되었습니다.)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/worklist",
3
- "version": "6.0.42",
3
+ "version": "6.0.45",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -25,16 +25,17 @@
25
25
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
26
26
  },
27
27
  "dependencies": {
28
+ "@operato/event-view": "^1.0.0",
28
29
  "@operato/graphql": "^1.0.0",
29
30
  "@operato/grist-editor": "^1.0.0",
30
- "@things-factory/attachment-base": "^6.0.34",
31
- "@things-factory/auth-base": "^6.0.34",
32
- "@things-factory/board-service": "^6.0.34",
33
- "@things-factory/context-ui": "^6.0.34",
34
- "@things-factory/organization": "^6.0.40",
35
- "@things-factory/scheduler-client": "^6.0.35",
36
- "@things-factory/shell": "^6.0.34",
31
+ "@things-factory/attachment-base": "^6.0.43",
32
+ "@things-factory/auth-base": "^6.0.43",
33
+ "@things-factory/board-service": "^6.0.43",
34
+ "@things-factory/context-ui": "^6.0.43",
35
+ "@things-factory/organization": "^6.0.43",
36
+ "@things-factory/scheduler-client": "^6.0.43",
37
+ "@things-factory/shell": "^6.0.43",
37
38
  "moment-timezone": "^0.5.40"
38
39
  },
39
- "gitHead": "01c352d388f5c899aa3f662565e8dbb273c51104"
40
+ "gitHead": "7ed9a41bd28093df9b43126ee38c0cdd0522afda"
40
41
  }
@@ -0,0 +1,20 @@
1
+ import { ActivityApproval, ActivityApprovalJudgment } from '../../service/activity-approval/activity-approval'
2
+
3
+ export async function _abort(
4
+ { activityApproval, comment }: { activityApproval: ActivityApproval; comment: string },
5
+ context: ResolverContext
6
+ ): Promise<ActivityApproval> {
7
+ const { domain, user, tx } = context.state
8
+
9
+ var result = await tx.getRepository(ActivityApproval).save({
10
+ ...activityApproval,
11
+ judgment: ActivityApprovalJudgment.Aborted,
12
+ comment,
13
+ transaction: 'abort',
14
+ updater: user,
15
+ terminatedAt: new Date(),
16
+ terminator: user
17
+ })
18
+
19
+ return result
20
+ }
@@ -0,0 +1,44 @@
1
+ import { ActivityApproval, ActivityApprovalJudgment } from '../../service/activity-approval/activity-approval'
2
+ import { updateActivityInstanceState } from '../common'
3
+ import { _abort } from './_abort'
4
+
5
+ export async function abort(
6
+ { id, comment }: { id: string; comment: string },
7
+ context: ResolverContext
8
+ ): Promise<ActivityApproval> {
9
+ const { domain, user, tx } = context.state
10
+
11
+ var repository = tx.getRepository(ActivityApproval)
12
+
13
+ var activityApproval = await repository.findOne({
14
+ where: { domain: { id: domain.id }, id },
15
+ relations: ['activityThread']
16
+ })
17
+
18
+ if (!activityApproval) {
19
+ throw new Error(
20
+ context.t('error.activity-approval not found', {
21
+ activityApproval: id
22
+ })
23
+ )
24
+ }
25
+
26
+ /*
27
+ Prerequisite of Abortion
28
+ - Previous judgement should be 'pending'
29
+ */
30
+ if (activityApproval.judgment !== ActivityApprovalJudgment.Pending) {
31
+ throw new Error(
32
+ context.t(`error.activity-approval is already terminated`, {
33
+ activityInstance: id,
34
+ actual: activityApproval.judgment
35
+ })
36
+ )
37
+ }
38
+
39
+ var result = await _abort({ activityApproval, comment }, context)
40
+
41
+ await updateActivityInstanceState(activityApproval.activityThread.activityInstanceId, context)
42
+
43
+ return result
44
+ }
@@ -24,6 +24,19 @@ export async function approve(
24
24
  )
25
25
  }
26
26
 
27
+ /*
28
+ Prerequisite of Approval
29
+ - Previous judgement should be 'pending'
30
+ */
31
+ if (activityApproval.judgment !== ActivityApprovalJudgment.Pending) {
32
+ throw new Error(
33
+ context.t(`error.activity-approval is already terminated`, {
34
+ activityInstance: id,
35
+ actual: activityApproval.judgment
36
+ })
37
+ )
38
+ }
39
+
27
40
  const activityThread = await tx.getRepository(ActivityThread).findOne({
28
41
  where: { domain: { id: domain.id }, id: activityApproval.activityThreadId },
29
42
  relations: ['activityInstance']
@@ -22,6 +22,19 @@ export async function delegate(
22
22
  )
23
23
  }
24
24
 
25
+ /*
26
+ Prerequisite of Delegation
27
+ - Previous judgement should be 'pending'
28
+ */
29
+ if (activityApproval.judgment !== ActivityApprovalJudgment.Pending) {
30
+ throw new Error(
31
+ context.t(`error.activity-approval is already terminated`, {
32
+ activityInstance: id,
33
+ actual: activityApproval.judgment
34
+ })
35
+ )
36
+ }
37
+
25
38
  /* TODO user validation .. */
26
39
  const approver = await tx.getRepository(User).findOneBy({ id: to.id })
27
40
 
@@ -23,6 +23,19 @@ export async function reject(
23
23
  )
24
24
  }
25
25
 
26
+ /*
27
+ Prerequisite of Rejection
28
+ - Previous judgement should be 'pending'
29
+ */
30
+ if (activityApproval.judgment !== ActivityApprovalJudgment.Pending) {
31
+ throw new Error(
32
+ context.t(`error.activity-approval is already terminated`, {
33
+ activityInstance: id,
34
+ actual: activityApproval.judgment
35
+ })
36
+ )
37
+ }
38
+
26
39
  var result = await repository.save({
27
40
  ...activityApproval,
28
41
  judgment: ActivityApprovalJudgment.Rejected,
@@ -1,6 +1,9 @@
1
- import { ActivityInstance } from '../../service/activity-instance/activity-instance'
1
+ import { ActivityThreadStatus } from '../../service/activity-thread/activity-thread'
2
+ import { ActivityInstance, ActivityInstanceStatus } from '../../service/activity-instance/activity-instance'
2
3
  import { evalActivityInstanceState } from '../common'
3
4
 
5
+ import { _abort as abortActivityThread } from '../activity-thread/_abort'
6
+
4
7
  export async function abort(
5
8
  { id, reason }: { id: string; reason: string },
6
9
  context: ResolverContext
@@ -11,7 +14,17 @@ export async function abort(
11
14
 
12
15
  var activityInstance = await repository.findOne({
13
16
  where: { domain: { id: domain.id }, id },
14
- relations: ['domain', 'activity', 'assigneeRole', 'supervisoryRole', 'updater', 'creator', 'starter', 'terminator']
17
+ relations: [
18
+ 'domain',
19
+ 'activity',
20
+ 'activityThreads',
21
+ 'assigneeRole',
22
+ 'supervisoryRole',
23
+ 'updater',
24
+ 'creator',
25
+ 'starter',
26
+ 'terminator'
27
+ ]
15
28
  })
16
29
 
17
30
  if (!activityInstance) {
@@ -22,6 +35,37 @@ export async function abort(
22
35
  )
23
36
  }
24
37
 
38
+ /*
39
+ Prerequisites for a Task to Be Aborted.
40
+ - The previous state of the task must not be End or Aborted.
41
+ */
42
+ if (
43
+ activityInstance.state == ActivityInstanceStatus.Aborted ||
44
+ activityInstance.state == ActivityInstanceStatus.Ended
45
+ ) {
46
+ throw new Error(
47
+ context.t(`error.activity-instance is already terminated`, {
48
+ id,
49
+ state: activityInstance.state
50
+ })
51
+ )
52
+ }
53
+
54
+ /*
55
+ Actions to be processed when a task is aborted
56
+ - All related activity threads must be aborted.
57
+ */
58
+
59
+ const TERMINATED = [ActivityThreadStatus.Aborted, ActivityThreadStatus.Delegated, ActivityThreadStatus.Ended]
60
+
61
+ for (let activityThread of activityInstance.activityThreads) {
62
+ if (TERMINATED.includes(activityThread.state)) {
63
+ continue
64
+ }
65
+
66
+ await abortActivityThread({ activityThread, reason }, context)
67
+ }
68
+
25
69
  return await repository.save({
26
70
  ...activityInstance,
27
71
  reason,
@@ -2,7 +2,7 @@ import { In } from 'typeorm'
2
2
 
3
3
  import { User } from '@things-factory/auth-base'
4
4
 
5
- import { ActivityInstance } from '../../service/activity-instance/activity-instance'
5
+ import { ActivityInstance, ActivityInstanceStatus } from '../../service/activity-instance/activity-instance'
6
6
  import { createActivityThreadsForUsers } from '../common'
7
7
 
8
8
  export async function assign(
@@ -26,6 +26,22 @@ export async function assign(
26
26
  )
27
27
  }
28
28
 
29
+ /*
30
+ Prerequisites for a Task to Be Assigned.
31
+ - The previous state of the task must not be Assigned.
32
+ */
33
+ if (
34
+ activityInstance.state !== ActivityInstanceStatus.Posted &&
35
+ activityInstance.state !== ActivityInstanceStatus.PendingAssignment
36
+ ) {
37
+ throw new Error(
38
+ context.t(`error.activity-instance should not be assigned`, {
39
+ id,
40
+ actual: activityInstance.state
41
+ })
42
+ )
43
+ }
44
+
29
45
  if (dueAt) {
30
46
  activityInstance.dueAt = dueAt
31
47
  }
@@ -1,4 +1,5 @@
1
- import { ActivityInstance } from '../../service/activity-instance/activity-instance'
1
+ import { ActivityInstance, ActivityInstanceStatus } from '../../service/activity-instance/activity-instance'
2
+ import { ActivityThreadStatus } from '../../service/activity-thread/activity-thread'
2
3
  import { evalActivityInstanceState } from '../common'
3
4
 
4
5
  export async function end(
@@ -10,7 +11,17 @@ export async function end(
10
11
 
11
12
  var activityInstance = await repository.findOne({
12
13
  where: { domain: { id: domain.id }, id },
13
- relations: ['domain', 'activity', 'assigneeRole', 'supervisoryRole', 'updater', 'creator', 'starter', 'terminator']
14
+ relations: [
15
+ 'domain',
16
+ 'activity',
17
+ 'activityThreads',
18
+ 'assigneeRole',
19
+ 'supervisoryRole',
20
+ 'updater',
21
+ 'creator',
22
+ 'starter',
23
+ 'terminator'
24
+ ]
14
25
  })
15
26
 
16
27
  if (!activityInstance) {
@@ -21,6 +32,38 @@ export async function end(
21
32
  )
22
33
  }
23
34
 
35
+ /*
36
+ Prerequisites for a Task to Be End.
37
+ - The previous state of the task must not be End or Aborted.
38
+ - There should be no unfinished activity threads.
39
+ */
40
+ if (
41
+ activityInstance.state == ActivityInstanceStatus.Aborted ||
42
+ activityInstance.state == ActivityInstanceStatus.Ended
43
+ ) {
44
+ throw new Error(
45
+ context.t(`error.activity-instance is already terminated`, {
46
+ id,
47
+ state: activityInstance.state
48
+ })
49
+ )
50
+ }
51
+
52
+ const TERMINATED = [ActivityThreadStatus.Aborted, ActivityThreadStatus.Delegated, ActivityThreadStatus.Ended]
53
+
54
+ for (let activityThread of activityInstance.activityThreads) {
55
+ if (TERMINATED.includes(activityThread.state)) {
56
+ continue
57
+ }
58
+
59
+ throw new Error(
60
+ context.t(`error.all activity threads should be terminated`, {
61
+ activityThread: activityThread.id,
62
+ state: activityInstance.state
63
+ })
64
+ )
65
+ }
66
+
24
67
  if (!activityInstance.startedAt) {
25
68
  activityInstance.startedAt = new Date()
26
69
  }
@@ -2,9 +2,5 @@ export * from './draft'
2
2
  export * from './post'
3
3
  export * from './pick'
4
4
  export * from './assign'
5
- export * from './delegate'
6
5
  export * from './abort'
7
6
  export * from './end'
8
- export * from './start'
9
- export * from './terminate'
10
- export * from './adjust'
@@ -1,4 +1,4 @@
1
- import { ActivityInstance } from '../../service/activity-instance/activity-instance'
1
+ import { ActivityInstance, ActivityInstanceStatus } from '../../service/activity-instance/activity-instance'
2
2
  import { ActivityThread } from '../../service/activity-thread/activity-thread'
3
3
  import { createActivityThreadsForUsers } from '../common'
4
4
 
@@ -19,6 +19,22 @@ export async function pick(id: string, context: ResolverContext): Promise<Activi
19
19
  )
20
20
  }
21
21
 
22
+ /*
23
+ Prerequisites for a Task to Be Picked.
24
+ - The previous state of the task must not be Assigned.
25
+ */
26
+ if (
27
+ activityInstance.state !== ActivityInstanceStatus.Posted &&
28
+ activityInstance.state !== ActivityInstanceStatus.PendingAssignment
29
+ ) {
30
+ throw new Error(
31
+ context.t(`error.activity-instance should not be assigned`, {
32
+ id,
33
+ actual: activityInstance.state
34
+ })
35
+ )
36
+ }
37
+
22
38
  const picked = await repository.save({
23
39
  ...activityInstance,
24
40
  transaction: 'pick',
@@ -49,6 +49,19 @@ export async function post(
49
49
  })
50
50
  : null
51
51
 
52
+ /*
53
+ Prerequisites for a Task to Be Posted.
54
+ - The previous state of the task should be Draft.
55
+ */
56
+ if (origin && origin.state !== ActivityInstanceStatus.Draft) {
57
+ throw new Error(
58
+ context.t(`error.activity-instance is already posted`, {
59
+ id: id,
60
+ state: origin.state
61
+ })
62
+ )
63
+ }
64
+
52
65
  if (!origin && activityId) {
53
66
  var repository = tx.getRepository(Activity)
54
67
  var activity = {} as Activity
@@ -0,0 +1,43 @@
1
+ import { ActivityThread, ActivityThreadStatus } from '../../service/activity-thread/activity-thread'
2
+ import { ActivityApproval, ActivityApprovalJudgment } from '../../service/activity-approval/activity-approval'
3
+ import { _abort as abortActivityApproval } from '../activity-approval/_abort'
4
+
5
+ export async function _abort(
6
+ { activityThread, reason }: { activityThread: ActivityThread; reason: string },
7
+ context: ResolverContext
8
+ ): Promise<ActivityThread> {
9
+ const { domain, user, tx } = context.state
10
+
11
+ var repository = tx.getRepository(ActivityThread)
12
+
13
+ let activityApprovals = await tx.getRepository(ActivityApproval).find({
14
+ where: {
15
+ activityThread: { id: activityThread.id },
16
+ judgment: ActivityApprovalJudgment.Pending
17
+ }
18
+ })
19
+
20
+ /*
21
+ Actions to be processed when a activity thread is aborted
22
+ - All related activity approvals must be aborted.
23
+ */
24
+ for (let activityApproval of activityApprovals) {
25
+ await abortActivityApproval(
26
+ {
27
+ activityApproval,
28
+ comment: reason
29
+ },
30
+ context
31
+ )
32
+ }
33
+
34
+ return await repository.save({
35
+ ...activityThread,
36
+ reason,
37
+ state: ActivityThreadStatus.Aborted,
38
+ transaction: 'abort',
39
+ updater: user,
40
+ terminatedAt: new Date(),
41
+ terminator: user
42
+ })
43
+ }
@@ -1,5 +1,6 @@
1
1
  import { ActivityThread, ActivityThreadStatus } from '../../service/activity-thread/activity-thread'
2
2
  import { updateActivityInstanceState } from '../common'
3
+ import { _abort } from './_abort'
3
4
 
4
5
  export async function abort(
5
6
  { id, reason }: { id: string; reason: string },
@@ -22,21 +23,30 @@ export async function abort(
22
23
  )
23
24
  }
24
25
 
26
+ /*
27
+ Prerequisites for a activity thread to Be Aborted.
28
+ - The previous state of the activity thread must not be End or Aborted.
29
+ */
30
+ if (
31
+ activityThread.state == ActivityThreadStatus.Aborted ||
32
+ activityThread.state == ActivityThreadStatus.Ended ||
33
+ activityThread.state == ActivityThreadStatus.Delegated
34
+ ) {
35
+ throw new Error(
36
+ context.t(`error.activity-thread is already terminated`, {
37
+ id,
38
+ state: activityThread.state
39
+ })
40
+ )
41
+ }
42
+
25
43
  if (!activityThread.startedAt) {
26
44
  activityThread.startedAt = new Date()
27
45
  }
28
46
 
29
- activityThread = await repository.save({
30
- ...activityThread,
31
- reason,
32
- state: ActivityThreadStatus.Aborted,
33
- transaction: 'abort',
34
- updater: user,
35
- terminatedAt: new Date(),
36
- terminator: user
37
- })
47
+ const result = await _abort({ activityThread, reason }, context)
38
48
 
39
49
  await updateActivityInstanceState(activityThread.activityInstanceId, context)
40
50
 
41
- return activityThread
51
+ return result
42
52
  }
@@ -31,6 +31,19 @@ export async function delegate(
31
31
  )
32
32
  }
33
33
 
34
+ /*
35
+ Prerequisites for a activity thread to Be Delegated.
36
+ - The previous state of the activity thread should be assigned or started.
37
+ */
38
+ if (activityThread.state !== ActivityThreadStatus.Assigned && activityThread.state !== ActivityThreadStatus.Started) {
39
+ throw new Error(
40
+ context.t(`error.activity-thread is already terminated`, {
41
+ id,
42
+ actual: activityThread.state
43
+ })
44
+ )
45
+ }
46
+
34
47
  if (dueAt) {
35
48
  activityThread.dueAt = dueAt
36
49
  }
@@ -21,6 +21,23 @@ export async function end(
21
21
  )
22
22
  }
23
23
 
24
+ /*
25
+ Prerequisites for a activity thread to Be End.
26
+ - The previous state of the activity thread must not be End or End.
27
+ */
28
+ if (
29
+ activityThread.state == ActivityThreadStatus.Aborted ||
30
+ activityThread.state == ActivityThreadStatus.Ended ||
31
+ activityThread.state == ActivityThreadStatus.Delegated
32
+ ) {
33
+ throw new Error(
34
+ context.t(`error.activity-thread is already terminated`, {
35
+ id,
36
+ actual: activityThread.state
37
+ })
38
+ )
39
+ }
40
+
24
41
  if (!activityThread.startedAt) {
25
42
  activityThread.startedAt = new Date()
26
43
  }
@@ -5,5 +5,3 @@ export * from './submit'
5
5
  export * from './save'
6
6
  export * from './start'
7
7
  export * from './restart'
8
- export * from './terminate'
9
- export * from './adjust'