@things-factory/worklist 5.0.11 → 5.0.13

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 (111) hide show
  1. package/client/components/activity-/bowner-view.js +0 -1
  2. package/client/components/activity-instance-preview.js +1 -2
  3. package/client/components/activity-intro-view.ts +0 -1
  4. package/client/components/activity-reporter-view.js +0 -1
  5. package/client/components/activity-starter-form.js +2 -3
  6. package/client/pages/activity/{activity-list-page.js → activity-list-page.ts} +24 -34
  7. package/client/pages/activity/activity-model-item-list.js +4 -1
  8. package/client/pages/activity/activity-page.js +1 -2
  9. package/client/pages/activity-instance/activity-instance-page.js +1 -1
  10. package/client/pages/activity-thread/activity-thread-page.js +1 -1
  11. package/client/pages/todo/draft-list-page.js +2 -0
  12. package/client/pages/{worklist-home.js → worklist-home.ts} +2 -6
  13. package/dist-client/components/activity-/bowner-view.js +0 -1
  14. package/dist-client/components/activity-/bowner-view.js.map +1 -1
  15. package/dist-client/components/activity-instance-preview.js +1 -2
  16. package/dist-client/components/activity-instance-preview.js.map +1 -1
  17. package/dist-client/components/activity-intro-view.d.ts +0 -1
  18. package/dist-client/components/activity-intro-view.js +0 -1
  19. package/dist-client/components/activity-intro-view.js.map +1 -1
  20. package/dist-client/components/activity-reporter-view.js +0 -1
  21. package/dist-client/components/activity-reporter-view.js.map +1 -1
  22. package/dist-client/components/activity-starter-form.js +2 -3
  23. package/dist-client/components/activity-starter-form.js.map +1 -1
  24. package/dist-client/pages/activity/activity-list-page.d.ts +12 -262
  25. package/dist-client/pages/activity/activity-list-page.js +45 -34
  26. package/dist-client/pages/activity/activity-list-page.js.map +1 -1
  27. package/dist-client/pages/activity/activity-model-item-list.d.ts +25 -0
  28. package/dist-client/pages/activity/activity-model-item-list.js +4 -1
  29. package/dist-client/pages/activity/activity-model-item-list.js.map +1 -1
  30. package/dist-client/pages/activity/activity-page.js +1 -2
  31. package/dist-client/pages/activity/activity-page.js.map +1 -1
  32. package/dist-client/pages/activity-instance/activity-instance-page.js +1 -1
  33. package/dist-client/pages/activity-instance/activity-instance-page.js.map +1 -1
  34. package/dist-client/pages/activity-thread/activity-thread-page.js +1 -1
  35. package/dist-client/pages/activity-thread/activity-thread-page.js.map +1 -1
  36. package/dist-client/pages/todo/draft-list-page.js +2 -0
  37. package/dist-client/pages/todo/draft-list-page.js.map +1 -1
  38. package/dist-client/pages/worklist-home.js +7 -6
  39. package/dist-client/pages/worklist-home.js.map +1 -1
  40. package/dist-client/tsconfig.tsbuildinfo +1 -1
  41. package/dist-server/controllers/activity-instance/abort.js +4 -3
  42. package/dist-server/controllers/activity-instance/abort.js.map +1 -1
  43. package/dist-server/controllers/activity-instance/adjust.js +3 -2
  44. package/dist-server/controllers/activity-instance/adjust.js.map +1 -1
  45. package/dist-server/controllers/activity-instance/assign.js +9 -23
  46. package/dist-server/controllers/activity-instance/assign.js.map +1 -1
  47. package/dist-server/controllers/activity-instance/delegate.js +5 -4
  48. package/dist-server/controllers/activity-instance/delegate.js.map +1 -1
  49. package/dist-server/controllers/activity-instance/draft.js +6 -5
  50. package/dist-server/controllers/activity-instance/draft.js.map +1 -1
  51. package/dist-server/controllers/activity-instance/end.js +5 -4
  52. package/dist-server/controllers/activity-instance/end.js.map +1 -1
  53. package/dist-server/controllers/activity-instance/pick.js +6 -4
  54. package/dist-server/controllers/activity-instance/pick.js.map +1 -1
  55. package/dist-server/controllers/activity-instance/post.js +10 -4
  56. package/dist-server/controllers/activity-instance/post.js.map +1 -1
  57. package/dist-server/controllers/activity-instance/start.js +3 -2
  58. package/dist-server/controllers/activity-instance/start.js.map +1 -1
  59. package/dist-server/controllers/activity-instance/terminate.js +5 -4
  60. package/dist-server/controllers/activity-instance/terminate.js.map +1 -1
  61. package/dist-server/controllers/activity-thread/abort.js +3 -2
  62. package/dist-server/controllers/activity-thread/abort.js.map +1 -1
  63. package/dist-server/controllers/activity-thread/adjust.js +2 -1
  64. package/dist-server/controllers/activity-thread/adjust.js.map +1 -1
  65. package/dist-server/controllers/activity-thread/delegate.js +4 -3
  66. package/dist-server/controllers/activity-thread/delegate.js.map +1 -1
  67. package/dist-server/controllers/activity-thread/end.js +4 -3
  68. package/dist-server/controllers/activity-thread/end.js.map +1 -1
  69. package/dist-server/controllers/activity-thread/save.js +2 -1
  70. package/dist-server/controllers/activity-thread/save.js.map +1 -1
  71. package/dist-server/controllers/activity-thread/start.js +4 -3
  72. package/dist-server/controllers/activity-thread/start.js.map +1 -1
  73. package/dist-server/controllers/activity-thread/terminate.js +3 -2
  74. package/dist-server/controllers/activity-thread/terminate.js.map +1 -1
  75. package/dist-server/controllers/common.js +23 -6
  76. package/dist-server/controllers/common.js.map +1 -1
  77. package/dist-server/service/activity-instance/activity-instance-mutation.js +15 -17
  78. package/dist-server/service/activity-instance/activity-instance-mutation.js.map +1 -1
  79. package/dist-server/service/activity-instance/activity-instance-type.js +9 -1
  80. package/dist-server/service/activity-instance/activity-instance-type.js.map +1 -1
  81. package/dist-server/service/activity-template/activity-template-query.js +14 -0
  82. package/dist-server/service/activity-template/activity-template-query.js.map +1 -1
  83. package/dist-server/service/activity-thread/activity-thread-mutation.js +5 -5
  84. package/dist-server/service/activity-thread/activity-thread-mutation.js.map +1 -1
  85. package/dist-server/service/activity-thread/event-subscriber.js +3 -3
  86. package/dist-server/service/activity-thread/event-subscriber.js.map +1 -1
  87. package/dist-server/tsconfig.tsbuildinfo +1 -1
  88. package/package.json +2 -2
  89. package/server/controllers/activity-instance/abort.ts +6 -7
  90. package/server/controllers/activity-instance/adjust.ts +5 -7
  91. package/server/controllers/activity-instance/assign.ts +14 -42
  92. package/server/controllers/activity-instance/delegate.ts +7 -5
  93. package/server/controllers/activity-instance/draft.ts +7 -9
  94. package/server/controllers/activity-instance/end.ts +6 -5
  95. package/server/controllers/activity-instance/pick.ts +12 -5
  96. package/server/controllers/activity-instance/post.ts +14 -8
  97. package/server/controllers/activity-instance/start.ts +5 -3
  98. package/server/controllers/activity-instance/terminate.ts +7 -5
  99. package/server/controllers/activity-thread/abort.ts +4 -6
  100. package/server/controllers/activity-thread/adjust.ts +3 -6
  101. package/server/controllers/activity-thread/delegate.ts +5 -4
  102. package/server/controllers/activity-thread/end.ts +5 -4
  103. package/server/controllers/activity-thread/save.ts +3 -6
  104. package/server/controllers/activity-thread/start.ts +5 -8
  105. package/server/controllers/activity-thread/terminate.ts +3 -3
  106. package/server/controllers/common.ts +33 -14
  107. package/server/service/activity-instance/activity-instance-mutation.ts +10 -12
  108. package/server/service/activity-instance/activity-instance-type.ts +10 -4
  109. package/server/service/activity-template/activity-template-query.ts +10 -0
  110. package/server/service/activity-thread/activity-thread-mutation.ts +5 -5
  111. package/server/service/activity-thread/event-subscriber.ts +3 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/worklist",
3
- "version": "5.0.11",
3
+ "version": "5.0.13",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -33,5 +33,5 @@
33
33
  "@things-factory/board-service": "^5.0.11",
34
34
  "@things-factory/shell": "^5.0.11"
35
35
  },
36
- "gitHead": "37cd4feb62e062899cae7029588d86a5d4b4036a"
36
+ "gitHead": "72dfd33e398eab9872600e91d1b13fef0595c174"
37
37
  }
@@ -1,12 +1,11 @@
1
1
  import { getRepository } from 'typeorm'
2
2
 
3
3
  import { ActivityInstance } from '../../service/activity-instance/activity-instance'
4
- import { type ContextStatus, evalActivityInstanceState } from '../common'
4
+ import { evalActivityInstanceState } from '../common'
5
+
6
+ export async function abort({ id, reason }: { id: string; reason: string }, context: any): Promise<ActivityInstance> {
7
+ const { domain, user, tx } = context.state
5
8
 
6
- export async function abort(
7
- { id, reason }: { id: string; reason: string },
8
- { domain, user, tx, t }: ContextStatus
9
- ): Promise<ActivityInstance> {
10
9
  var repository = getRepository(ActivityInstance)
11
10
 
12
11
  var activityInstance = await repository.findOne({
@@ -15,7 +14,7 @@ export async function abort(
15
14
 
16
15
  if (!activityInstance) {
17
16
  throw new Error(
18
- t('error.activity-instance not found', {
17
+ context.t('error.activity-instance not found', {
19
18
  activityInstance: id
20
19
  })
21
20
  )
@@ -24,7 +23,7 @@ export async function abort(
24
23
  return await tx.getRepository(ActivityInstance).save({
25
24
  ...activityInstance,
26
25
  reason,
27
- state: await evalActivityInstanceState(id, { domain, user, tx, t }),
26
+ state: await evalActivityInstanceState(id, context),
28
27
  transaction: 'abort',
29
28
  updater: user,
30
29
  terminatedAt: new Date(),
@@ -1,12 +1,10 @@
1
1
  import { ActivityInstance } from '../../service/activity-instance/activity-instance'
2
2
  import { ActivityInstancePatch } from '../../service/activity-instance/activity-instance-type'
3
- import { type ContextStatus, evalActivityInstanceState } from '../common'
3
+ import { evalActivityInstanceState } from '../common'
4
+
5
+ export async function adjust(id: string, patch: ActivityInstancePatch, context: any): Promise<ActivityInstance> {
6
+ const { domain, user, tx } = context.state
4
7
 
5
- export async function adjust(
6
- id: string,
7
- patch: ActivityInstancePatch,
8
- { domain, user, tx, t }: ContextStatus
9
- ): Promise<ActivityInstance> {
10
8
  const repository = tx.getRepository(ActivityInstance)
11
9
  const activityInstance = await repository.findOne({
12
10
  where: { domain, id }
@@ -16,7 +14,7 @@ export async function adjust(
16
14
  ...activityInstance,
17
15
  ...patch,
18
16
  transaction: 'adjust',
19
- state: await evalActivityInstanceState(id, { domain, user, tx, t }),
17
+ state: await evalActivityInstanceState(id, context),
20
18
  updater: user
21
19
  })
22
20
  }
@@ -1,21 +1,17 @@
1
- import { getRepository } from 'typeorm'
1
+ import { In } from 'typeorm'
2
2
 
3
- import { Role } from '@things-factory/auth-base'
3
+ import { User } from '@things-factory/auth-base'
4
4
 
5
5
  import { ActivityInstance } from '../../service/activity-instance/activity-instance'
6
- import { type ContextStatus, evalActivityInstanceState } from '../common'
6
+ import { createActivityThreadsForUsers } from '../common'
7
7
 
8
8
  export async function assign(
9
- {
10
- id,
11
- assigneeRole,
12
- supervisoryRole,
13
- reason,
14
- dueAt
15
- }: { id: string; assigneeRole?: string; supervisoryRole?: string; reason?: string; dueAt?: Date },
16
- { domain, user, tx, t }: ContextStatus
9
+ { id, assignees, reason, dueAt }: { id: string; assignees?: string[]; reason?: string; dueAt?: Date },
10
+ context: any
17
11
  ): Promise<ActivityInstance> {
18
- var repository = getRepository(ActivityInstance)
12
+ const { domain, user, tx } = context.state
13
+
14
+ const repository = tx.getRepository(ActivityInstance)
19
15
 
20
16
  var activityInstance = await repository.findOne({
21
17
  where: { domain, id },
@@ -24,7 +20,7 @@ export async function assign(
24
20
 
25
21
  if (!activityInstance) {
26
22
  throw new Error(
27
- t('error.activity-instance not found', {
23
+ context.t('error.activity-instance not found', {
28
24
  activityInstance: id
29
25
  })
30
26
  )
@@ -34,35 +30,11 @@ export async function assign(
34
30
  activityInstance.dueAt = dueAt
35
31
  }
36
32
 
37
- if (assigneeRole) {
38
- activityInstance.assigneeRole = await getRepository(Role).findOne({
39
- domain,
40
- name: assigneeRole
41
- })
42
- }
43
-
44
- if (supervisoryRole) {
45
- activityInstance.supervisoryRole = await getRepository(Role).findOne({
46
- domain,
47
- name: supervisoryRole
48
- })
49
- }
33
+ const assignedUsers = await tx.getRepository(User).find({
34
+ email: In(assignees)
35
+ })
50
36
 
51
- if (!activityInstance.assigneeRole) {
52
- throw new Error(
53
- t('error.activity-instance assignee role not found', {
54
- activityInstance: id,
55
- role: assigneeRole
56
- })
57
- )
58
- }
37
+ await createActivityThreadsForUsers('assign', activityInstance, assignedUsers, context)
59
38
 
60
- if (activityInstance.assigneeRole)
61
- return await tx.getRepository(ActivityInstance).save({
62
- ...activityInstance,
63
- reason,
64
- transaction: 'assign',
65
- state: await evalActivityInstanceState(id, { domain, user, tx, t }),
66
- updater: user
67
- })
39
+ return await tx.getRepository(ActivityInstance).findOne(activityInstance.id)
68
40
  }
@@ -1,7 +1,7 @@
1
1
  import { getRepository } from 'typeorm'
2
2
 
3
3
  import { ActivityInstance } from '../../service/activity-instance/activity-instance'
4
- import { type ContextStatus, evalActivityInstanceState } from '../common'
4
+ import { evalActivityInstanceState } from '../common'
5
5
 
6
6
  export async function delegate(
7
7
  {
@@ -15,9 +15,11 @@ export async function delegate(
15
15
  dueAt?: Date
16
16
  reason?: string
17
17
  },
18
- { domain, user, tx, t }: ContextStatus
18
+ context: any
19
19
  ): Promise<ActivityInstance> {
20
- var repository = getRepository(ActivityInstance)
20
+ const { domain, user, tx } = context.state
21
+
22
+ const repository = getRepository(ActivityInstance)
21
23
 
22
24
  var activityInstance = await repository.findOne({
23
25
  where: { domain, id }
@@ -25,7 +27,7 @@ export async function delegate(
25
27
 
26
28
  if (!activityInstance) {
27
29
  throw new Error(
28
- t('error.activity-instance not found', {
30
+ context.t('error.activity-instance not found', {
29
31
  activityInstance: id
30
32
  })
31
33
  )
@@ -40,7 +42,7 @@ export async function delegate(
40
42
  reason,
41
43
  assigneeRole,
42
44
  transaction: 'delegate',
43
- state: await evalActivityInstanceState(id, { domain, user, tx, t }),
45
+ state: await evalActivityInstanceState(id, context),
44
46
  updater: user,
45
47
  assignedAt: new Date()
46
48
  })
@@ -3,12 +3,9 @@ import { getRepository } from 'typeorm'
3
3
  import { ActivityInstance, ActivityInstanceStatus } from '../../service/activity-instance/activity-instance'
4
4
  import { NewActivityInstance } from '../../service/activity-instance/activity-instance-type'
5
5
  import { Activity } from '../../service/activity/activity'
6
- import { type ContextStatus } from '../common'
7
6
 
8
- export async function draft(
9
- activityInstance: NewActivityInstance,
10
- { domain, user, tx, t }: ContextStatus
11
- ): Promise<ActivityInstance> {
7
+ export async function draft(activityInstance: NewActivityInstance, context: any): Promise<ActivityInstance> {
8
+ const { domain, user, tx } = context.state
12
9
  const { activityId, input, dueAt } = activityInstance
13
10
 
14
11
  var repository = getRepository(Activity)
@@ -22,16 +19,16 @@ export async function draft(
22
19
 
23
20
  if (!activity) {
24
21
  throw new Error(
25
- t('error.activity not found', {
22
+ context.t('error.activity not found', {
26
23
  activity: activityId
27
24
  })
28
25
  )
29
26
  }
30
-
31
- activity.adhocType = 'standard'
32
- activity.refBy = activityId
33
27
  }
34
28
 
29
+ activityInstance.adhocType = 'standard'
30
+ activityInstance.refBy = activityId
31
+
35
32
  if (!dueAt && activity.standardTime) {
36
33
  activityInstance.dueAt = new Date(Date.now() + activity.standardTime * 1000)
37
34
  }
@@ -46,6 +43,7 @@ export async function draft(
46
43
  refBy: activity.refBy,
47
44
  ...activityInstance,
48
45
  transaction: 'draft',
46
+ activity,
49
47
  state: ActivityInstanceStatus.Draft,
50
48
  domain,
51
49
  creator: user,
@@ -1,13 +1,14 @@
1
1
  import { getRepository } from 'typeorm'
2
2
 
3
3
  import { ActivityInstance } from '../../service/activity-instance/activity-instance'
4
- import { type ContextStatus, evalActivityInstanceState } from '../common'
4
+ import { evalActivityInstanceState } from '../common'
5
5
 
6
6
  export async function end(
7
7
  { id, output, reason }: { id: string; output?: object; reason?: string },
8
- { domain, user, tx, t }: ContextStatus
8
+ context: any
9
9
  ): Promise<ActivityInstance> {
10
- var repository = getRepository(ActivityInstance)
10
+ const { domain, user, tx } = context.state
11
+ const repository = getRepository(ActivityInstance)
11
12
 
12
13
  var activityInstance = await repository.findOne({
13
14
  where: { domain, id }
@@ -15,7 +16,7 @@ export async function end(
15
16
 
16
17
  if (!activityInstance) {
17
18
  throw new Error(
18
- t('error.activity-instance not found', {
19
+ context.t('error.activity-instance not found', {
19
20
  activityInstance: id
20
21
  })
21
22
  )
@@ -26,7 +27,7 @@ export async function end(
26
27
  reason,
27
28
  output,
28
29
  transaction: 'end',
29
- state: await evalActivityInstanceState(id, { domain, user, tx, t }),
30
+ state: await evalActivityInstanceState(id, context),
30
31
  updater: user,
31
32
  terminatedAt: new Date(),
32
33
  terminator: user
@@ -2,10 +2,11 @@ import { getRepository } from 'typeorm'
2
2
 
3
3
  import { ActivityInstance } from '../../service/activity-instance/activity-instance'
4
4
  import { ActivityThread } from '../../service/activity-thread/activity-thread'
5
- import { type ContextStatus, createActivityThreadsForUsers } from '../common'
5
+ import { createActivityThreadsForUsers } from '../common'
6
6
 
7
- export async function pick(id: string, { domain, user, tx, t }: ContextStatus): Promise<ActivityThread> {
8
- var repository = getRepository(ActivityInstance)
7
+ export async function pick(id: string, context: any): Promise<ActivityThread> {
8
+ const { domain, user, tx } = context.state
9
+ const repository = getRepository(ActivityInstance)
9
10
 
10
11
  var activityInstance = await repository.findOne({
11
12
  where: { domain, id }
@@ -13,11 +14,17 @@ export async function pick(id: string, { domain, user, tx, t }: ContextStatus):
13
14
 
14
15
  if (!activityInstance) {
15
16
  throw new Error(
16
- t('error.activity-instance not found', {
17
+ context.t('error.activity-instance not found', {
17
18
  activityInstance: id
18
19
  })
19
20
  )
20
21
  }
21
22
 
22
- return (await createActivityThreadsForUsers(activityInstance, [user], { domain, user, tx, t }))[0]
23
+ const picked = await tx.getRepository(ActivityInstance).save({
24
+ ...activityInstance,
25
+ transaction: 'pick',
26
+ updater: user
27
+ })
28
+
29
+ return (await createActivityThreadsForUsers('pick', picked, [user], context))[0]
23
30
  }
@@ -1,11 +1,13 @@
1
+ import { In } from 'typeorm'
2
+
3
+ import { User } from '@things-factory/auth-base'
4
+
1
5
  import { ActivityInstance, ActivityInstanceStatus } from '../../service/activity-instance/activity-instance'
2
6
  import { ActivityInstancePost } from '../../service/activity-instance/activity-instance-type'
3
- import { type ContextStatus, createActivityThreadsForAllRoleUsers, createActivityThreadsForUsers } from '../common'
7
+ import { createActivityThreadsForAllRoleUsers, createActivityThreadsForUsers } from '../common'
4
8
 
5
- export async function post(
6
- activityInstance: ActivityInstancePost,
7
- { domain, user, tx, t }: ContextStatus
8
- ): Promise<ActivityInstance> {
9
+ export async function post(activityInstance: ActivityInstancePost, context: any): Promise<ActivityInstance> {
10
+ const { domain, user, tx } = context.state
9
11
  const { id, assignees } = activityInstance
10
12
 
11
13
  var origin = id ? await tx.getRepository(ActivityInstance).findOne(id) : null
@@ -20,12 +22,16 @@ export async function post(
20
22
  updater: user
21
23
  })
22
24
 
25
+ const assignedUsers = await tx.getRepository(User).find({
26
+ email: In(assignees || [])
27
+ })
28
+
23
29
  if (posted.threadsMin === 0 && posted.assigneeRoleId) {
24
- await createActivityThreadsForAllRoleUsers(posted, { domain, user, tx, t })
30
+ await createActivityThreadsForAllRoleUsers('post', posted, context)
25
31
  }
26
32
 
27
- if (assignees instanceof Array) {
28
- await createActivityThreadsForUsers(activityInstance, assignees, { domain, user, tx, t })
33
+ if (assignedUsers.length > 0) {
34
+ await createActivityThreadsForUsers('post', posted, assignedUsers, context)
29
35
  }
30
36
 
31
37
  return await tx.getRepository(ActivityInstance).findOne(posted.id)
@@ -1,7 +1,9 @@
1
1
  import { ActivityInstance } from '../../service/activity-instance/activity-instance'
2
- import { type ContextStatus, evalActivityInstanceState } from '../common'
2
+ import { evalActivityInstanceState } from '../common'
3
+
4
+ export async function start(id: string, context: any): Promise<ActivityInstance> {
5
+ const { domain, user, tx } = context.state
3
6
 
4
- export async function start(id: string, { domain, user, tx, t }: ContextStatus): Promise<ActivityInstance> {
5
7
  const repository = tx.getRepository(ActivityInstance)
6
8
  const activityInstance = await repository.findOne({
7
9
  where: { domain, id }
@@ -10,7 +12,7 @@ export async function start(id: string, { domain, user, tx, t }: ContextStatus):
10
12
  return await repository.save({
11
13
  ...activityInstance,
12
14
  transaction: 'start',
13
- state: await evalActivityInstanceState(id, { domain, user, tx, t }),
15
+ state: await evalActivityInstanceState(id, context),
14
16
  updater: user,
15
17
  startedAt: new Date()
16
18
  })
@@ -1,13 +1,15 @@
1
1
  import { getRepository } from 'typeorm'
2
2
 
3
3
  import { ActivityInstance } from '../../service/activity-instance/activity-instance'
4
- import { type ContextStatus, evalActivityInstanceState } from '../common'
4
+ import { evalActivityInstanceState } from '../common'
5
5
 
6
6
  export async function terminate(
7
7
  { id, output, reason }: { id: string; output?: object; reason?: string },
8
- { domain, user, tx, t }: ContextStatus
8
+ context: any
9
9
  ): Promise<ActivityInstance> {
10
- var repository = getRepository(ActivityInstance)
10
+ const { domain, user, tx } = context.state
11
+
12
+ const repository = getRepository(ActivityInstance)
11
13
 
12
14
  var activityInstance = await repository.findOne({
13
15
  where: { domain, id }
@@ -15,7 +17,7 @@ export async function terminate(
15
17
 
16
18
  if (!activityInstance) {
17
19
  throw new Error(
18
- t('error.activity-instance not found', {
20
+ context.t('error.activity-instance not found', {
19
21
  activityInstance: id
20
22
  })
21
23
  )
@@ -26,7 +28,7 @@ export async function terminate(
26
28
  reason,
27
29
  output,
28
30
  transaction: 'terminate',
29
- state: await evalActivityInstanceState(id, { domain, user, tx, t }),
31
+ state: await evalActivityInstanceState(id, context),
30
32
  updater: user,
31
33
  terminatedAt: new Date(),
32
34
  terminator: user
@@ -1,12 +1,10 @@
1
1
  import { getRepository } from 'typeorm'
2
2
 
3
3
  import { ActivityThread, ActivityThreadStatus } from '../../service/activity-thread/activity-thread'
4
- import { type ContextStatus } from '../common'
5
4
 
6
- export async function abort(
7
- { id, reason }: { id: string; reason: string },
8
- { domain, user, tx, t }: ContextStatus
9
- ): Promise<ActivityThread> {
5
+ export async function abort({ id, reason }: { id: string; reason: string }, context: any): Promise<ActivityThread> {
6
+ const { domain, user, tx } = context.state
7
+
10
8
  var repository = getRepository(ActivityThread)
11
9
 
12
10
  var activityThread = await repository.findOne({
@@ -15,7 +13,7 @@ export async function abort(
15
13
 
16
14
  if (!activityThread) {
17
15
  throw new Error(
18
- t('error.activity-instance not found', {
16
+ context.t('error.activity-instance not found', {
19
17
  activityThread: id
20
18
  })
21
19
  )
@@ -1,13 +1,10 @@
1
1
  import { ActivityThread } from '../../service/activity-thread/activity-thread'
2
2
  import { ActivityThreadPatch } from '../../service/activity-thread/activity-thread-type'
3
- import { type ContextStatus } from '../common'
4
3
 
5
- export async function adjust(
6
- id: string,
7
- patch: ActivityThreadPatch,
8
- { domain, user, tx, t }: ContextStatus
9
- ): Promise<ActivityThread> {
4
+ export async function adjust(id: string, patch: ActivityThreadPatch, context: any): Promise<ActivityThread> {
5
+ const { domain, user, tx } = context.state
10
6
  const repository = tx.getRepository(ActivityThread)
7
+
11
8
  const activityThread = await repository.findOne({
12
9
  where: { domain, id }
13
10
  })
@@ -1,7 +1,6 @@
1
1
  import { getRepository } from 'typeorm'
2
2
 
3
3
  import { ActivityThread, ActivityThreadStatus } from '../../service/activity-thread/activity-thread'
4
- import { type ContextStatus } from '../common'
5
4
 
6
5
  export async function delegate(
7
6
  {
@@ -15,9 +14,11 @@ export async function delegate(
15
14
  dueAt?: Date
16
15
  reason?: string
17
16
  },
18
- { domain, user, tx, t }: ContextStatus
17
+ context: any
19
18
  ): Promise<ActivityThread> {
20
- var repository = getRepository(ActivityThread)
19
+ const { domain, user, tx } = context.state
20
+
21
+ const repository = getRepository(ActivityThread)
21
22
 
22
23
  var activityThread = await repository.findOne({
23
24
  where: { domain, id }
@@ -25,7 +26,7 @@ export async function delegate(
25
26
 
26
27
  if (!activityThread) {
27
28
  throw new Error(
28
- t('error.activity-instance not found', {
29
+ context.t('error.activity-instance not found', {
29
30
  activityThread: id
30
31
  })
31
32
  )
@@ -1,13 +1,14 @@
1
1
  import { getRepository } from 'typeorm'
2
2
 
3
3
  import { ActivityThread, ActivityThreadStatus } from '../../service/activity-thread/activity-thread'
4
- import { type ContextStatus } from '../common'
5
4
 
6
5
  export async function end(
7
6
  { id, output, reason }: { id: string; output?: object; reason?: string },
8
- { domain, user, tx, t }: ContextStatus
7
+ context: any
9
8
  ): Promise<ActivityThread> {
10
- var repository = getRepository(ActivityThread)
9
+ const { domain, user, tx } = context.state
10
+
11
+ const repository = getRepository(ActivityThread)
11
12
 
12
13
  var activityThread = await repository.findOne({
13
14
  where: { domain, id }
@@ -15,7 +16,7 @@ export async function end(
15
16
 
16
17
  if (!activityThread) {
17
18
  throw new Error(
18
- t('error.activity-thread not found', {
19
+ context.t('error.activity-thread not found', {
19
20
  activityThread: id
20
21
  })
21
22
  )
@@ -1,13 +1,10 @@
1
1
  import { ActivityThread } from '../../service/activity-thread/activity-thread'
2
2
  import { ActivityThreadSave } from '../../service/activity-thread/activity-thread-type'
3
- import { type ContextStatus } from '../common'
4
3
 
5
- export async function save(
6
- id: string,
7
- save: ActivityThreadSave,
8
- { domain, user, tx, t }: ContextStatus
9
- ): Promise<ActivityThread> {
4
+ export async function save(id: string, save: ActivityThreadSave, context: any): Promise<ActivityThread> {
5
+ const { domain, user, tx } = context.state
10
6
  const repository = tx.getRepository(ActivityThread)
7
+
11
8
  const activityThread = await repository.findOne({
12
9
  where: { domain, id }
13
10
  })
@@ -1,12 +1,8 @@
1
1
  import { ActivityThread, ActivityThreadStatus } from '../../service/activity-thread/activity-thread'
2
- import { type ContextStatus } from '../common'
3
2
 
4
- export async function start(
5
- id: string,
6
- output: object,
7
- reason: string,
8
- { domain, user, tx, t }: ContextStatus
9
- ): Promise<ActivityThread> {
3
+ export async function start(id: string, output: object, reason: string, context: any): Promise<ActivityThread> {
4
+ const { domain, user, tx } = context.state
5
+
10
6
  const repository = tx.getRepository(ActivityThread)
11
7
  const activityThread = await repository.findOne({
12
8
  where: { domain, id }
@@ -14,7 +10,7 @@ export async function start(
14
10
 
15
11
  if (!activityThread) {
16
12
  throw new Error(
17
- t('error.activity-instance not found', {
13
+ context.t('error.activity-instance not found', {
18
14
  activityInstance: id
19
15
  })
20
16
  )
@@ -28,6 +24,7 @@ export async function start(
28
24
  ...activityThread,
29
25
  reason,
30
26
  state: ActivityThreadStatus.Started,
27
+ transaction: 'start',
31
28
  updater: user,
32
29
  startedAt: new Date()
33
30
  })
@@ -1,12 +1,12 @@
1
1
  import { getRepository } from 'typeorm'
2
2
 
3
3
  import { ActivityThread, ActivityThreadStatus } from '../../service/activity-thread/activity-thread'
4
- import { type ContextStatus } from '../common'
5
4
 
6
5
  export async function terminate(
7
6
  { id, output, reason }: { id: string; output?: object; reason?: string },
8
- { domain, user, tx, t }: ContextStatus
7
+ context: any
9
8
  ): Promise<ActivityThread> {
9
+ const { domain, user, tx } = context.state
10
10
  var repository = getRepository(ActivityThread)
11
11
 
12
12
  var activityThread = await repository.findOne({
@@ -15,7 +15,7 @@ export async function terminate(
15
15
 
16
16
  if (!activityThread) {
17
17
  throw new Error(
18
- t('error.activity-instance not found', {
18
+ context.t('error.activity-instance not found', {
19
19
  activityThread: id
20
20
  })
21
21
  )