@things-factory/worklist 7.1.34 → 7.1.47
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.
- package/dist-client/components/activity-instance-ribon.js +0 -4
- package/dist-client/components/activity-instance-ribon.js.map +1 -1
- package/dist-client/components/activity-thread-ribon.js +4 -0
- package/dist-client/components/activity-thread-ribon.js.map +1 -1
- package/dist-client/pages/activity/activity-page.d.ts +1 -1
- package/dist-client/pages/activity/activity-page.js +1 -1
- package/dist-client/pages/activity/activity-page.js.map +1 -1
- package/dist-client/pages/activity-approval/activity-approval-page.d.ts +1 -0
- package/dist-client/pages/activity-approval/activity-approval-page.js +1 -0
- package/dist-client/pages/activity-approval/activity-approval-page.js.map +1 -1
- package/dist-client/pages/activity-thread/activity-thread-page.d.ts +1 -0
- package/dist-client/pages/activity-thread/activity-thread-page.js +6 -1
- package/dist-client/pages/activity-thread/activity-thread-page.js.map +1 -1
- package/dist-client/pages/activity-thread/activity-thread-view-page.d.ts +1 -0
- package/dist-client/pages/activity-thread/activity-thread-view-page.js +1 -0
- package/dist-client/pages/activity-thread/activity-thread-view-page.js.map +1 -1
- package/dist-client/pages/activity-thread/activity-thread-view.js +4 -0
- package/dist-client/pages/activity-thread/activity-thread-view.js.map +1 -1
- package/dist-client/pages/todo/done-list-page.js +1 -1
- package/dist-client/pages/todo/done-list-page.js.map +1 -1
- package/dist-client/pages/todo/draft-list-page.js +1 -1
- package/dist-client/pages/todo/draft-list-page.js.map +1 -1
- package/dist-client/pages/todo/todo-list-page.js +2 -1
- package/dist-client/pages/todo/todo-list-page.js.map +1 -1
- package/dist-client/templates/activity-instance-context-template.js +0 -4
- package/dist-client/templates/activity-instance-context-template.js.map +1 -1
- package/dist-client/templates/activity-thread-context-template.js +4 -0
- package/dist-client/templates/activity-thread-context-template.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/types/activity-instance.d.ts +1 -1
- package/dist-client/types/activity-instance.js +1 -1
- package/dist-client/types/activity-instance.js.map +1 -1
- package/dist-server/controllers/activity-approval/abort.js +2 -0
- package/dist-server/controllers/activity-approval/abort.js.map +1 -1
- package/dist-server/controllers/activity-approval/approve.js +44 -14
- package/dist-server/controllers/activity-approval/approve.js.map +1 -1
- package/dist-server/controllers/activity-approval/check-authority.d.ts +2 -0
- package/dist-server/controllers/activity-approval/check-authority.js +24 -0
- package/dist-server/controllers/activity-approval/check-authority.js.map +1 -0
- package/dist-server/controllers/activity-approval/delegate.js +6 -1
- package/dist-server/controllers/activity-approval/delegate.js.map +1 -1
- package/dist-server/controllers/activity-approval/reject.js +2 -0
- package/dist-server/controllers/activity-approval/reject.js.map +1 -1
- package/dist-server/controllers/activity-approval/save.d.ts +5 -0
- package/dist-server/controllers/activity-approval/save.js +28 -0
- package/dist-server/controllers/activity-approval/save.js.map +1 -0
- package/dist-server/controllers/activity-instance/assign.js +1 -1
- package/dist-server/controllers/activity-instance/assign.js.map +1 -1
- package/dist-server/controllers/activity-instance/issue.js +27 -3
- package/dist-server/controllers/activity-instance/issue.js.map +1 -1
- package/dist-server/controllers/activity-instance/pick.js +1 -1
- package/dist-server/controllers/activity-instance/pick.js.map +1 -1
- package/dist-server/controllers/activity-thread/abort.js +2 -0
- package/dist-server/controllers/activity-thread/abort.js.map +1 -1
- package/dist-server/controllers/activity-thread/check-authority.d.ts +2 -0
- package/dist-server/controllers/activity-thread/check-authority.js +33 -0
- package/dist-server/controllers/activity-thread/check-authority.js.map +1 -0
- package/dist-server/controllers/activity-thread/delegate.js +2 -0
- package/dist-server/controllers/activity-thread/delegate.js.map +1 -1
- package/dist-server/controllers/activity-thread/end.js +2 -0
- package/dist-server/controllers/activity-thread/end.js.map +1 -1
- package/dist-server/controllers/activity-thread/restart.js +2 -0
- package/dist-server/controllers/activity-thread/restart.js.map +1 -1
- package/dist-server/controllers/activity-thread/save.js +4 -0
- package/dist-server/controllers/activity-thread/save.js.map +1 -1
- package/dist-server/controllers/activity-thread/start.js +2 -0
- package/dist-server/controllers/activity-thread/start.js.map +1 -1
- package/dist-server/controllers/activity-thread/submit.js +45 -14
- package/dist-server/controllers/activity-thread/submit.js.map +1 -1
- package/dist-server/controllers/common.d.ts +1 -0
- package/dist-server/controllers/common.js +21 -1
- package/dist-server/controllers/common.js.map +1 -1
- package/dist-server/service/activity-approval/activity-approval-mutation.d.ts +1 -1
- package/dist-server/service/activity-approval/activity-approval-mutation.js +3 -13
- package/dist-server/service/activity-approval/activity-approval-mutation.js.map +1 -1
- package/dist-server/service/activity-approval/activity-approval-query.js +14 -3
- package/dist-server/service/activity-approval/activity-approval-query.js.map +1 -1
- package/dist-server/service/activity-approval/activity-approval.d.ts +3 -1
- package/dist-server/service/activity-approval/activity-approval.js +9 -0
- package/dist-server/service/activity-approval/activity-approval.js.map +1 -1
- package/dist-server/service/activity-instance/activity-instance-query.js +1 -1
- package/dist-server/service/activity-instance/activity-instance-query.js.map +1 -1
- package/dist-server/service/activity-instance/activity-instance.d.ts +1 -1
- package/dist-server/service/activity-instance/activity-instance.js +1 -1
- package/dist-server/service/activity-instance/activity-instance.js.map +1 -1
- package/dist-server/service/activity-summary/activity-summary-query.js +30 -9
- package/dist-server/service/activity-summary/activity-summary-query.js.map +1 -1
- package/dist-server/service/activity-thread/activity-thread-history.js +2 -0
- package/dist-server/service/activity-thread/activity-thread-history.js.map +1 -1
- package/dist-server/service/activity-thread/activity-thread-query.js +17 -5
- package/dist-server/service/activity-thread/activity-thread-query.js.map +1 -1
- package/dist-server/service/activity-thread/activity-thread.d.ts +1 -0
- package/dist-server/service/activity-thread/activity-thread.js +1 -0
- package/dist-server/service/activity-thread/activity-thread.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/translations/en.json +14 -1
- package/translations/ja.json +14 -1
- package/translations/ko.json +59 -46
- package/translations/ms.json +14 -1
- package/translations/zh.json +14 -1
|
@@ -5,7 +5,7 @@ import { Activity, ActivityType, ActivityUIType } from './activity';
|
|
|
5
5
|
export declare enum ActivityInstanceStatus {
|
|
6
6
|
Draft = "draft",
|
|
7
7
|
Issued = "issued",
|
|
8
|
-
|
|
8
|
+
Unassigned = "unassigned",
|
|
9
9
|
Assigned = "assigned",
|
|
10
10
|
Started = "started",
|
|
11
11
|
Pending = "pending",
|
|
@@ -2,7 +2,7 @@ export var ActivityInstanceStatus;
|
|
|
2
2
|
(function (ActivityInstanceStatus) {
|
|
3
3
|
ActivityInstanceStatus["Draft"] = "draft";
|
|
4
4
|
ActivityInstanceStatus["Issued"] = "issued";
|
|
5
|
-
ActivityInstanceStatus["
|
|
5
|
+
ActivityInstanceStatus["Unassigned"] = "unassigned";
|
|
6
6
|
ActivityInstanceStatus["Assigned"] = "assigned";
|
|
7
7
|
ActivityInstanceStatus["Started"] = "started";
|
|
8
8
|
ActivityInstanceStatus["Pending"] = "pending";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activity-instance.js","sourceRoot":"","sources":["../../client/types/activity-instance.ts"],"names":[],"mappings":"AAMA,MAAM,CAAN,IAAY,sBASX;AATD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;IACjB,
|
|
1
|
+
{"version":3,"file":"activity-instance.js","sourceRoot":"","sources":["../../client/types/activity-instance.ts"],"names":[],"mappings":"AAMA,MAAM,CAAN,IAAY,sBASX;AATD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;IACjB,mDAAyB,CAAA;IACzB,+CAAqB,CAAA;IACrB,6CAAmB,CAAA;IACnB,6CAAmB,CAAA;IACnB,yCAAe,CAAA;IACf,6CAAmB,CAAA;AACrB,CAAC,EATW,sBAAsB,KAAtB,sBAAsB,QASjC;AAED,MAAM,OAAO,YAAY;CAMxB;AAED,MAAM,OAAO,gBAAgB;IAA7B;QAGE,YAAO,GAAY,CAAC,CAAA;QAYpB,UAAK,GAAY,EAAE,CAAA;QAEnB,UAAK,GAAY,EAAE,CAAA;QAEnB,UAAK,GAAY,EAAE,CAAA;QAEnB,UAAK,GAAY,EAAE,CAAA;QAEnB,UAAK,GAAY,EAAE,CAAA;QAQnB,aAAQ,GAAY,CAAC,CAAA;QAMrB,eAAU,GAAY,CAAC,CAAA;QAEvB,eAAU,GAAY,CAAC,CAAA;IA+DzB,CAAC;IATC,aAAa;QACX,QAAQ,IAAI,CAAC,KAAK,EAAE,CAAC;YACnB,KAAK,sBAAsB,CAAC,MAAM,CAAC;YACnC,KAAK,sBAAsB,CAAC,QAAQ;gBAClC,OAAO,IAAI,CAAA;YACb;gBACE,OAAO,KAAK,CAAA;QAChB,CAAC;IACH,CAAC;CACF","sourcesContent":["import { Domain, User, Role } from '@operato/shell'\nimport { OrgMemberTargetType, OrgMemberTarget, ApprovalLineItem } from '@things-factory/organization'\n\nimport { ActivityThread } from './activity-thread'\nimport { Activity, ActivityType, ActivityUIType } from './activity'\n\nexport enum ActivityInstanceStatus {\n Draft = 'draft',\n Issued = 'issued',\n Unassigned = 'unassigned',\n Assigned = 'assigned',\n Started = 'started',\n Pending = 'pending',\n Ended = 'ended',\n Aborted = 'aborted'\n}\n\nexport class AssigneeItem {\n type?: OrgMemberTargetType\n\n value?: string\n\n assignee?: OrgMemberTarget\n}\n\nexport class ActivityInstance {\n id?: string\n\n version?: number = 1\n\n domain?: Domain\n\n name?: string\n\n description?: string\n\n activityType?: ActivityType\n\n adhocType?: string\n\n key01?: string = ''\n\n key02?: string = ''\n\n key03?: string = ''\n\n key04?: string = ''\n\n key05?: string = ''\n\n activityThreads?: ActivityThread[]\n\n uiType?: ActivityUIType\n\n uiSource?: string\n\n priority?: number = 1\n\n state?: ActivityInstanceStatus\n\n reason?: string\n\n threadsMin?: number = 0\n\n threadsMax?: number = 0\n\n input?: { [key: string]: any }\n\n output?: { [key: string]: any }\n\n refBy?: string\n\n activity?: Activity\n\n assigneeRole?: Role\n\n supervisoryRole?: Role\n\n dueAt?: Date\n\n transaction?: string\n\n assignees?: AssigneeItem[]\n\n approvalLine?: ApprovalLineItem[]\n\n createdAt?: Date\n\n updatedAt?: Date\n\n assignedAt?: Date\n\n startedAt?: Date\n\n terminatedAt?: Date\n\n creator?: User\n\n creatorId?: string\n\n updater?: User\n\n updaterId?: string\n\n issuer?: User\n\n issuerId?: string\n\n starter?: User\n\n starterId?: string\n\n terminator?: User\n\n terminatorId?: string\n\n thumbnail?: string\n\n isDelegatable(): boolean {\n switch (this.state) {\n case ActivityInstanceStatus.Issued:\n case ActivityInstanceStatus.Assigned:\n return true\n default:\n return false\n }\n }\n}\n"]}
|
|
@@ -4,6 +4,7 @@ exports.abort = abort;
|
|
|
4
4
|
const activity_approval_1 = require("../../service/activity-approval/activity-approval");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const _abort_1 = require("./_abort");
|
|
7
|
+
const check_authority_1 = require("./check-authority");
|
|
7
8
|
async function abort({ id, comment }, context) {
|
|
8
9
|
const { domain, user, tx } = context.state;
|
|
9
10
|
var repository = tx.getRepository(activity_approval_1.ActivityApproval);
|
|
@@ -16,6 +17,7 @@ async function abort({ id, comment }, context) {
|
|
|
16
17
|
activityApproval: id
|
|
17
18
|
}));
|
|
18
19
|
}
|
|
20
|
+
await (0, check_authority_1.checkAuthority)(activityApproval, context);
|
|
19
21
|
/*
|
|
20
22
|
Prerequisite of Abortion
|
|
21
23
|
- Previous judgment should be 'pending'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abort.js","sourceRoot":"","sources":["../../../server/controllers/activity-approval/abort.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"abort.js","sourceRoot":"","sources":["../../../server/controllers/activity-approval/abort.ts"],"names":[],"mappings":";;AAKA,sBA6CC;AAlDD,yFAA8G;AAC9G,sCAAuD;AACvD,qCAAiC;AACjC,uDAAkD;AAE3C,KAAK,UAAU,KAAK,CACzB,EAAE,EAAE,EAAE,OAAO,EAAmC,EAChD,OAAwB;IAExB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAE1C,IAAI,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,oCAAgB,CAAC,CAAA;IAEnD,IAAI,gBAAgB,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;QAC9C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;QACxC,SAAS,EAAE,CAAC,gBAAgB,CAAC;KAC9B,CAAC,CAAA;IAEF,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,CAAC,CAAC,mCAAmC,EAAE;YAC7C,gBAAgB,EAAE,EAAE;SACrB,CAAC,CACH,CAAA;IACH,CAAC;IAED,MAAM,IAAA,gCAAc,EAAC,gBAAgB,EAAE,OAAO,CAAC,CAAA;IAE/C;;;MAGE;IACF,IAAI,gBAAgB,CAAC,QAAQ,KAAK,4CAAwB,CAAC,OAAO,EAAE,CAAC;QACnE,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,CAAC,CAAC,+CAA+C,EAAE;YACzD,gBAAgB,EAAE,EAAE;YACpB,MAAM,EAAE,gBAAgB,CAAC,QAAQ;SAClC,CAAC,CACH,CAAA;IACH,CAAC;IAED,IAAI,MAAM,GAAG,MAAM,IAAA,eAAM,EAAC,EAAE,gBAAgB,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,CAAA;IAEjE,MAAM,IAAA,oCAA2B,EAC/B,gBAAgB,CAAC,cAAc,CAAC,kBAAkB,EAClD,EAAE,QAAQ,EAAE,CAAC,gBAAgB,CAAC,cAAc,CAAC,EAAE,EAC/C,OAAO,CACR,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { ActivityApproval, ActivityApprovalJudgment } from '../../service/activity-approval/activity-approval'\nimport { updateActivityInstanceState } from '../common'\nimport { _abort } from './_abort'\nimport { checkAuthority } from './check-authority'\n\nexport async function abort(\n { id, comment }: { id: string; comment: string },\n context: ResolverContext\n): Promise<ActivityApproval> {\n const { domain, user, tx } = context.state\n\n var repository = tx.getRepository(ActivityApproval)\n\n var activityApproval = await repository.findOne({\n where: { domain: { id: domain.id }, id },\n relations: ['activityThread']\n })\n\n if (!activityApproval) {\n throw new Error(\n context.t('error.activity-approval not found', {\n activityApproval: id\n })\n )\n }\n\n await checkAuthority(activityApproval, context)\n\n /* \n Prerequisite of Abortion\n - Previous judgment should be 'pending'\n */\n if (activityApproval.judgment !== ActivityApprovalJudgment.Pending) {\n throw new Error(\n context.t(`error.activity-approval is already terminated`, {\n activityInstance: id,\n actual: activityApproval.judgment\n })\n )\n }\n\n var result = await _abort({ activityApproval, comment }, context)\n\n await updateActivityInstanceState(\n activityApproval.activityThread.activityInstanceId,\n { causedBy: [activityApproval.activityThread] },\n context\n )\n\n return result\n}\n"]}
|
|
@@ -4,7 +4,10 @@ exports.approve = approve;
|
|
|
4
4
|
const common_1 = require("../../controllers/common");
|
|
5
5
|
const activity_thread_1 = require("../../service/activity-thread/activity-thread");
|
|
6
6
|
const activity_approval_1 = require("../../service/activity-approval/activity-approval");
|
|
7
|
+
const organization_1 = require("@things-factory/organization");
|
|
8
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
7
9
|
const common_2 = require("../common");
|
|
10
|
+
const check_authority_1 = require("./check-authority");
|
|
8
11
|
async function approve({ id, comment }, context) {
|
|
9
12
|
const { domain, user, tx } = context.state;
|
|
10
13
|
var repository = tx.getRepository(activity_approval_1.ActivityApproval);
|
|
@@ -16,13 +19,14 @@ async function approve({ id, comment }, context) {
|
|
|
16
19
|
activityApproval: id
|
|
17
20
|
}));
|
|
18
21
|
}
|
|
22
|
+
await (0, check_authority_1.checkAuthority)(activityApproval, context);
|
|
19
23
|
/*
|
|
20
24
|
Prerequisite of Approval
|
|
21
25
|
- Previous judgment should be 'pending'
|
|
22
26
|
*/
|
|
23
27
|
if (activityApproval.judgment !== activity_approval_1.ActivityApprovalJudgment.Pending) {
|
|
24
28
|
throw new Error(context.t(`error.activity-approval is already terminated`, {
|
|
25
|
-
|
|
29
|
+
activityApproval: id,
|
|
26
30
|
actual: activityApproval.judgment
|
|
27
31
|
}));
|
|
28
32
|
}
|
|
@@ -35,20 +39,46 @@ async function approve({ id, comment }, context) {
|
|
|
35
39
|
const result = await tx.getRepository(activity_approval_1.ActivityApproval).save(Object.assign(Object.assign({}, activityApproval), { judgment: approvalLine[order] ? activity_approval_1.ActivityApprovalJudgment.Escalated : activity_approval_1.ActivityApprovalJudgment.Approved, comment, transaction: approvalLine[order] ? 'escalate' : 'approve', updater: user, terminatedAt: new Date(), terminator: user }));
|
|
36
40
|
if (approvalLine && approvalLine.length > order) {
|
|
37
41
|
// approvalLine에서 후속 승인자에게 escalating.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
if (approvalLine[order].type == organization_1.OrgMemberTargetType.Role) {
|
|
43
|
+
const approverRoleId = approvalLine[0].value;
|
|
44
|
+
if (approverRoleId) {
|
|
45
|
+
throw 'Cannot specify the approver role for this approval line';
|
|
46
|
+
}
|
|
47
|
+
const approverRole = await tx.getRepository(auth_base_1.Role).findOneBy({
|
|
48
|
+
id: approverRoleId
|
|
49
|
+
});
|
|
50
|
+
if (!approverRole) {
|
|
51
|
+
throw 'Cannot find the approver role for this approval line';
|
|
52
|
+
}
|
|
53
|
+
await tx.getRepository(activity_approval_1.ActivityApproval).save({
|
|
54
|
+
domain,
|
|
55
|
+
activityThread,
|
|
56
|
+
round: activityThread.round,
|
|
57
|
+
order: order + 1,
|
|
58
|
+
judgment: activity_approval_1.ActivityApprovalJudgment.Pending,
|
|
59
|
+
transaction: 'escalate',
|
|
60
|
+
approverRole: approverRole,
|
|
61
|
+
creator: user,
|
|
62
|
+
updater: user
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
var approverUser = await (0, common_1.getSystemUserFromOrgMemberItem)(approvalLine[order], context);
|
|
67
|
+
if (!approverUser) {
|
|
68
|
+
throw 'Cannot specify the approval user for this approval line';
|
|
69
|
+
}
|
|
70
|
+
await tx.getRepository(activity_approval_1.ActivityApproval).save({
|
|
71
|
+
domain,
|
|
72
|
+
activityThread,
|
|
73
|
+
round: activityThread.round,
|
|
74
|
+
order: order + 1,
|
|
75
|
+
judgment: activity_approval_1.ActivityApprovalJudgment.Pending,
|
|
76
|
+
transaction: 'escalate',
|
|
77
|
+
approver: approverUser,
|
|
78
|
+
creator: user,
|
|
79
|
+
updater: user
|
|
80
|
+
});
|
|
41
81
|
}
|
|
42
|
-
await tx.getRepository(activity_approval_1.ActivityApproval).save({
|
|
43
|
-
domain,
|
|
44
|
-
activityThread,
|
|
45
|
-
order: order + 1,
|
|
46
|
-
judgment: activity_approval_1.ActivityApprovalJudgment.Pending,
|
|
47
|
-
transaction: 'escalate',
|
|
48
|
-
approver: approverUser,
|
|
49
|
-
creator: user,
|
|
50
|
-
updater: user
|
|
51
|
-
});
|
|
52
82
|
activityThread = await tx.getRepository(activity_thread_1.ActivityThread).save(Object.assign(Object.assign({}, activityThread), { transaction: 'escalate', reaseon: comment, state: activity_thread_1.ActivityThreadStatus.Escalated, updater: user }));
|
|
53
83
|
}
|
|
54
84
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approve.js","sourceRoot":"","sources":["../../../server/controllers/activity-approval/approve.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"approve.js","sourceRoot":"","sources":["../../../server/controllers/activity-approval/approve.ts"],"names":[],"mappings":";;AAQA,0BA4HC;AApID,qDAAyE;AACzE,mFAAoG;AACpG,yFAA8G;AAC9G,+DAAoF;AACpF,yDAAgD;AAChD,sCAAuD;AACvD,uDAAkD;AAE3C,KAAK,UAAU,OAAO,CAC3B,EAAE,EAAE,EAAE,OAAO,EAAmC,EAChD,OAAwB;IAExB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,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Y,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAA;YAErF,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,MAAM,yDAAyD,CAAA;YACjE,CAAC;YAED,MAAM,EAAE,CAAC,aAAa,CAAC,oCAAgB,CAAC,CAAC,IAAI,CAAC;gBAC5C,MAAM;gBACN,cAAc;gBACd,KAAK,EAAE,cAAc,CAAC,KAAK;gBAC3B,KAAK,EAAE,KAAK,GAAG,CAAC;gBAChB,QAAQ,EAAE,4CAAwB,CAAC,OAAO;gBAC1C,WAAW,EAAE,UAAU;gBACvB,QAAQ,EAAE,YAAY;gBACtB,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,IAAI;aACd,CAAC,CAAA;QACJ,CAAC;QAED,cAAc,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,gCAAc,CAAC,CAAC,IAAI,iCACvD,cAAc,KACjB,WAAW,EAAE,UAAU,EACvB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,sCAAoB,CAAC,SAAS,EACrC,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;SAAM,CAAC;QACN,cAAc,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,gCAAc,CAAC,CAAC,IAAI,iCACvD,cAAc,KACjB,WAAW,EAAE,SAAS,EACtB,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,sCAAoB,CAAC,KAAK,EACjC,YAAY,EAAE,IAAI,IAAI,EAAE,EACxB,UAAU,EAAE,IAAI,EAChB,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;IAED,MAAM,IAAA,oCAA2B,EAAC,cAAc,CAAC,kBAAkB,EAAE,EAAE,QAAQ,EAAE,CAAC,cAAc,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;IAE7G,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { getSystemUserFromOrgMemberItem } from '../../controllers/common'\nimport { ActivityThread, ActivityThreadStatus } from '../../service/activity-thread/activity-thread'\nimport { ActivityApproval, ActivityApprovalJudgment } from '../../service/activity-approval/activity-approval'\nimport { ApprovalLineItem, OrgMemberTargetType } from '@things-factory/organization'\nimport { Role } from '@things-factory/auth-base'\nimport { updateActivityInstanceState } from '../common'\nimport { checkAuthority } from './check-authority'\n\nexport async function approve(\n { id, comment }: { id: string; comment: string },\n context: ResolverContext\n): Promise<ActivityApproval> {\n const { domain, user, tx } = context.state\n\n var repository = tx.getRepository(ActivityApproval)\n\n var activityApproval = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n if (!activityApproval) {\n throw new Error(\n context.t('error.activity-approval not found', {\n activityApproval: id\n })\n )\n }\n\n await checkAuthority(activityApproval, context)\n\n /* \n Prerequisite of Approval\n - Previous judgment should be 'pending'\n */\n if (activityApproval.judgment !== ActivityApprovalJudgment.Pending) {\n throw new Error(\n context.t(`error.activity-approval is already terminated`, {\n activityApproval: id,\n actual: activityApproval.judgment\n })\n )\n }\n\n var activityThread = await tx.getRepository(ActivityThread).findOne({\n where: { domain: { id: domain.id }, id: activityApproval.activityThreadId },\n relations: ['activityInstance']\n })\n\n const approvalLine: ApprovalLineItem[] = activityThread.activityInstance.approvalLine\n const order = activityApproval.order\n\n const result = await tx.getRepository(ActivityApproval).save({\n ...activityApproval,\n judgment: approvalLine[order] ? ActivityApprovalJudgment.Escalated : ActivityApprovalJudgment.Approved,\n comment,\n transaction: approvalLine[order] ? 'escalate' : 'approve',\n updater: user,\n terminatedAt: new Date(),\n terminator: user\n })\n\n if (approvalLine && approvalLine.length > order) {\n // approvalLine에서 후속 승인자에게 escalating.\n\n if (approvalLine[order].type == OrgMemberTargetType.Role) {\n const approverRoleId = approvalLine[0].value\n\n if (approverRoleId) {\n throw 'Cannot specify the approver role for this approval line'\n }\n\n const approverRole = await tx.getRepository(Role).findOneBy({\n id: approverRoleId\n })\n\n if (!approverRole) {\n throw 'Cannot find the approver role for this approval line'\n }\n\n await tx.getRepository(ActivityApproval).save({\n domain,\n activityThread,\n round: activityThread.round,\n order: order + 1,\n judgment: ActivityApprovalJudgment.Pending,\n transaction: 'escalate',\n approverRole: approverRole,\n creator: user,\n updater: user\n })\n } else {\n var approverUser = await getSystemUserFromOrgMemberItem(approvalLine[order], context)\n\n if (!approverUser) {\n throw 'Cannot specify the approval user for this approval line'\n }\n\n await tx.getRepository(ActivityApproval).save({\n domain,\n activityThread,\n round: activityThread.round,\n order: order + 1,\n judgment: ActivityApprovalJudgment.Pending,\n transaction: 'escalate',\n approver: approverUser,\n creator: user,\n updater: user\n })\n }\n\n activityThread = await tx.getRepository(ActivityThread).save({\n ...activityThread,\n transaction: 'escalate',\n reaseon: comment,\n state: ActivityThreadStatus.Escalated,\n updater: user\n })\n } else {\n activityThread = await tx.getRepository(ActivityThread).save({\n ...activityThread,\n transaction: 'approve',\n reason: comment,\n state: ActivityThreadStatus.Ended,\n terminatedAt: new Date(),\n terminator: user,\n updater: user\n })\n }\n\n await updateActivityInstanceState(activityThread.activityInstanceId, { causedBy: [activityThread] }, context)\n\n return result\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkAuthority = checkAuthority;
|
|
4
|
+
const shell_1 = require("@things-factory/shell");
|
|
5
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
6
|
+
async function checkAuthority(activityApproval, context) {
|
|
7
|
+
var _a;
|
|
8
|
+
const { user, tx } = context.state;
|
|
9
|
+
if (activityApproval.approverId && activityApproval.approverId === user.id) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (!activityApproval.approver && activityApproval.approverRoleId) {
|
|
13
|
+
const roles = (_a = (await (0, shell_1.getRepository)(auth_base_1.User, tx).findOne({
|
|
14
|
+
where: { id: user.id },
|
|
15
|
+
relations: ['roles']
|
|
16
|
+
}))) === null || _a === void 0 ? void 0 : _a.roles;
|
|
17
|
+
if (roles.find(role => role.id == activityApproval.approverRoleId)) {
|
|
18
|
+
activityApproval.approver = user;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
throw new Error(context.t(`error.not authorized to handle this task`));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=check-authority.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-authority.js","sourceRoot":"","sources":["../../../server/controllers/activity-approval/check-authority.ts"],"names":[],"mappings":";;AAIA,wCAsBC;AA1BD,iDAAqD;AACrD,yDAAgD;AAGzC,KAAK,UAAU,cAAc,CAAC,gBAAkC,EAAE,OAAwB;;IAC/F,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAElC,IAAI,gBAAgB,CAAC,UAAU,IAAI,gBAAgB,CAAC,UAAU,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC;QAC3E,OAAM;IACR,CAAC;IAED,IAAI,CAAC,gBAAgB,CAAC,QAAQ,IAAI,gBAAgB,CAAC,cAAc,EAAE,CAAC;QAClE,MAAM,KAAK,GAAG,MAAA,CACZ,MAAM,IAAA,qBAAa,EAAC,gBAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC;YACpC,KAAK,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE;YACtB,SAAS,EAAE,CAAC,OAAO,CAAC;SACrB,CAAC,CACH,0CAAE,KAAK,CAAA;QAER,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,gBAAgB,CAAC,cAAc,CAAC,EAAE,CAAC;YACnE,gBAAgB,CAAC,QAAQ,GAAG,IAAI,CAAA;YAChC,OAAM;QACR,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,0CAA0C,CAAC,CAAC,CAAA;AACxE,CAAC","sourcesContent":["import { getRepository } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { ActivityApproval } from '../../service/activity-approval/activity-approval'\n\nexport async function checkAuthority(activityApproval: ActivityApproval, context: ResolverContext) {\n const { user, tx } = context.state\n\n if (activityApproval.approverId && activityApproval.approverId === user.id) {\n return\n }\n\n if (!activityApproval.approver && activityApproval.approverRoleId) {\n const roles = (\n await getRepository(User, tx).findOne({\n where: { id: user.id },\n relations: ['roles']\n })\n )?.roles\n\n if (roles.find(role => role.id == activityApproval.approverRoleId)) {\n activityApproval.approver = user\n return\n }\n }\n\n throw new Error(context.t(`error.not authorized to handle this task`))\n}\n"]}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.delegate = delegate;
|
|
4
4
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
5
5
|
const activity_approval_1 = require("../../service/activity-approval/activity-approval");
|
|
6
|
+
const check_authority_1 = require("./check-authority");
|
|
6
7
|
async function delegate({ id, to, comment }, context) {
|
|
7
8
|
const { domain, user, tx } = context.state;
|
|
8
9
|
var repository = tx.getRepository(activity_approval_1.ActivityApproval);
|
|
@@ -15,6 +16,7 @@ async function delegate({ id, to, comment }, context) {
|
|
|
15
16
|
activityApproval: id
|
|
16
17
|
}));
|
|
17
18
|
}
|
|
19
|
+
await (0, check_authority_1.checkAuthority)(activityApproval, context);
|
|
18
20
|
/*
|
|
19
21
|
Prerequisite of Delegation
|
|
20
22
|
- Previous judgment should be 'pending'
|
|
@@ -26,7 +28,10 @@ async function delegate({ id, to, comment }, context) {
|
|
|
26
28
|
}));
|
|
27
29
|
}
|
|
28
30
|
/* TODO user validation .. */
|
|
29
|
-
const approver = await tx.getRepository(auth_base_1.User).findOneBy({ id: to.id });
|
|
31
|
+
const approver = await tx.getRepository(auth_base_1.User).findOneBy({ id: to.id, status: auth_base_1.UserStatus.ACTIVATED });
|
|
32
|
+
if (!approver) {
|
|
33
|
+
throw new Error(context.t(`error.user not found`));
|
|
34
|
+
}
|
|
30
35
|
/* create new delegated approval */
|
|
31
36
|
await repository.save(Object.assign(Object.assign({}, activityApproval), { originalApproval: activityApproval, comment,
|
|
32
37
|
approver, creator: user, updater: user }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegate.js","sourceRoot":"","sources":["../../../server/controllers/activity-approval/delegate.ts"],"names":[],"mappings":";;AAKA,
|
|
1
|
+
{"version":3,"file":"delegate.js","sourceRoot":"","sources":["../../../server/controllers/activity-approval/delegate.ts"],"names":[],"mappings":";;AAKA,4BAiEC;AAtED,yDAA4D;AAE5D,yFAA8G;AAC9G,uDAAkD;AAE3C,KAAK,UAAU,QAAQ,CAC5B,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAkD,EACnE,OAAwB;IAExB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAE1C,IAAI,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,oCAAgB,CAAC,CAAA;IAEnD,IAAI,gBAAgB,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;QAC9C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;QACxC,SAAS,EAAE,CAAC,QAAQ,EAAE,gBAAgB,CAAC;KACxC,CAAC,CAAA;IAEF,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,CAAC,CAAC,mCAAmC,EAAE;YAC7C,gBAAgB,EAAE,EAAE;SACrB,CAAC,CACH,CAAA;IACH,CAAC;IAED,MAAM,IAAA,gCAAc,EAAC,gBAAgB,EAAE,OAAO,CAAC,CAAA;IAE/C;;;MAGE;IACF,IAAI,gBAAgB,CAAC,QAAQ,KAAK,4CAAwB,CAAC,OAAO,EAAE,CAAC;QACnE,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,CAAC,CAAC,+CAA+C,EAAE;YACzD,gBAAgB,EAAE,EAAE;YACpB,MAAM,EAAE,gBAAgB,CAAC,QAAQ;SAClC,CAAC,CACH,CAAA;IACH,CAAC;IAED,6BAA6B;IAC7B,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,gBAAI,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,sBAAU,CAAC,SAAS,EAAE,CAAC,CAAA;IAEpG,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAA;IACpD,CAAC;IAED,mCAAmC;IACnC,MAAM,UAAU,CAAC,IAAI,iCAChB,gBAAgB,KACnB,gBAAgB,EAAE,gBAAgB,EAClC,OAAO;QACP,QAAQ,EACR,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;IAEF,+BAA+B;IAC/B,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,IAAI,iCAC/B,gBAAgB,KACnB,QAAQ,EAAE,4CAAwB,CAAC,SAAS,EAC5C,MAAM,EAAE,OAAO,EACf,WAAW,EAAE,UAAU,EACvB,OAAO,EAAE,IAAI,EACb,UAAU,EAAE,IAAI,EAChB,YAAY,EAAE,IAAI,IAAI,EAAE,IACxB,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { User, UserStatus } from '@things-factory/auth-base'\nimport { ObjectRef } from '@things-factory/shell'\nimport { ActivityApproval, ActivityApprovalJudgment } from '../../service/activity-approval/activity-approval'\nimport { checkAuthority } from './check-authority'\n\nexport async function delegate(\n { id, to, comment }: { id: string; to: ObjectRef; comment: string },\n context: ResolverContext\n): Promise<ActivityApproval> {\n const { domain, user, tx } = context.state\n\n var repository = tx.getRepository(ActivityApproval)\n\n var activityApproval = await repository.findOne({\n where: { domain: { id: domain.id }, id },\n relations: ['domain', 'activityThread']\n })\n\n if (!activityApproval) {\n throw new Error(\n context.t('error.activity-approval not found', {\n activityApproval: id\n })\n )\n }\n\n await checkAuthority(activityApproval, context)\n\n /* \n Prerequisite of Delegation\n - Previous judgment should be 'pending'\n */\n if (activityApproval.judgment !== ActivityApprovalJudgment.Pending) {\n throw new Error(\n context.t(`error.activity-approval is already terminated`, {\n activityInstance: id,\n actual: activityApproval.judgment\n })\n )\n }\n\n /* TODO user validation .. */\n const approver = await tx.getRepository(User).findOneBy({ id: to.id, status: UserStatus.ACTIVATED })\n\n if (!approver) {\n throw new Error(context.t(`error.user not found`))\n }\n\n /* create new delegated approval */\n await repository.save({\n ...activityApproval,\n originalApproval: activityApproval,\n comment,\n approver,\n creator: user,\n updater: user\n })\n\n /* terminate origin approval */\n const result = await repository.save({\n ...activityApproval,\n judgment: ActivityApprovalJudgment.Delegated,\n reason: comment,\n transaction: 'delegate',\n updater: user,\n terminator: user,\n terminatedAt: new Date()\n })\n\n return result\n}\n"]}
|
|
@@ -4,6 +4,7 @@ exports.reject = reject;
|
|
|
4
4
|
const activity_thread_1 = require("../../service/activity-thread/activity-thread");
|
|
5
5
|
const activity_approval_1 = require("../../service/activity-approval/activity-approval");
|
|
6
6
|
const common_1 = require("../common");
|
|
7
|
+
const check_authority_1 = require("./check-authority");
|
|
7
8
|
async function reject({ id, comment }, context) {
|
|
8
9
|
const { domain, user, tx } = context.state;
|
|
9
10
|
var repository = tx.getRepository(activity_approval_1.ActivityApproval);
|
|
@@ -16,6 +17,7 @@ async function reject({ id, comment }, context) {
|
|
|
16
17
|
activityApproval: id
|
|
17
18
|
}));
|
|
18
19
|
}
|
|
20
|
+
await (0, check_authority_1.checkAuthority)(activityApproval, context);
|
|
19
21
|
/*
|
|
20
22
|
Prerequisite of Rejection
|
|
21
23
|
- Previous judgment should be 'pending'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reject.js","sourceRoot":"","sources":["../../../server/controllers/activity-approval/reject.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"re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,YAAY,EAAE,IAAI,IAAI,EAAE,EACxB,UAAU,EAAE,IAAI,IAChB,CAAA;IAEF,IAAI,cAAc,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,gCAAc,CAAC,CAAC,IAAI,iCAC3D,gBAAgB,CAAC,cAAc,KAClC,WAAW,EAAE,QAAQ,EACrB,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,sCAAoB,CAAC,QAAQ,EACpC,OAAO,EAAE,IAAI,IACb,CAAA;IAEF,MAAM,IAAA,oCAA2B,EAC/B,gBAAgB,CAAC,cAAc,CAAC,kBAAkB,EAClD,EAAE,QAAQ,EAAE,CAAC,cAAc,CAAC,EAAE,EAC9B,OAAO,CACR,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { ActivityThread, ActivityThreadStatus } from '../../service/activity-thread/activity-thread'\nimport { ActivityApproval, ActivityApprovalJudgment } from '../../service/activity-approval/activity-approval'\nimport { updateActivityInstanceState } from '../common'\nimport { checkAuthority } from './check-authority'\n\nexport async function reject(\n { id, comment }: { id: string; comment: string },\n context: ResolverContext\n): Promise<ActivityApproval> {\n const { domain, user, tx } = context.state\n\n var repository = tx.getRepository(ActivityApproval)\n\n var activityApproval = await repository.findOne({\n where: { domain: { id: domain.id }, id },\n relations: ['activityThread']\n })\n\n if (!activityApproval) {\n throw new Error(\n context.t('error.activity-approval not found', {\n activityApproval: id\n })\n )\n }\n\n await checkAuthority(activityApproval, context)\n\n /* \n Prerequisite of Rejection\n - Previous judgment should be 'pending'\n */\n if (activityApproval.judgment !== ActivityApprovalJudgment.Pending) {\n throw new Error(\n context.t(`error.activity-approval is already terminated`, {\n activityInstance: id,\n actual: activityApproval.judgment\n })\n )\n }\n\n var result = await repository.save({\n ...activityApproval,\n judgment: ActivityApprovalJudgment.Rejected,\n comment,\n transaction: 'reject',\n updater: user,\n terminatedAt: new Date(),\n terminator: user\n })\n\n var activityThread = await tx.getRepository(ActivityThread).save({\n ...activityApproval.activityThread,\n transaction: 'reject',\n reason: comment,\n state: ActivityThreadStatus.Rejected,\n updater: user\n })\n\n await updateActivityInstanceState(\n activityApproval.activityThread.activityInstanceId,\n { causedBy: [activityThread] },\n context\n )\n\n return result\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.save = save;
|
|
4
|
+
const shell_1 = require("@things-factory/shell");
|
|
5
|
+
const check_authority_1 = require("./check-authority");
|
|
6
|
+
const activity_approval_1 = require("../../service/activity-approval/activity-approval");
|
|
7
|
+
const activity_thread_1 = require("../../service/activity-thread/activity-thread");
|
|
8
|
+
const common_1 = require("../common");
|
|
9
|
+
async function save({ id, comment }, context) {
|
|
10
|
+
const { domain, user, tx } = context.state;
|
|
11
|
+
var repository = (0, shell_1.getRepository)(activity_approval_1.ActivityApproval, tx);
|
|
12
|
+
var activityApproval = await repository.findOne({
|
|
13
|
+
where: { domain: { id: domain.id }, id }
|
|
14
|
+
});
|
|
15
|
+
if (!activityApproval) {
|
|
16
|
+
throw new Error(context.t('error.activity-approval not found', {
|
|
17
|
+
activityApproval: id
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
await (0, check_authority_1.checkAuthority)(activityApproval, context);
|
|
21
|
+
const result = await repository.save(Object.assign(Object.assign({}, activityApproval), { comment, updater: user }));
|
|
22
|
+
const activityThread = await (0, shell_1.getRepository)(activity_thread_1.ActivityThread).findOneBy({
|
|
23
|
+
id: activityApproval.activityThreadId
|
|
24
|
+
});
|
|
25
|
+
await (0, common_1.updateActivityInstanceState)(activityThread === null || activityThread === void 0 ? void 0 : activityThread.activityInstanceId, { causedBy: [activityThread] }, context);
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=save.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save.js","sourceRoot":"","sources":["../../../server/controllers/activity-approval/save.ts"],"names":[],"mappings":";;AAMA,oBAmCC;AAzCD,iDAAqD;AACrD,uDAAkD;AAClD,yFAAoF;AACpF,mFAA8E;AAC9E,sCAAuD;AAEhD,KAAK,UAAU,IAAI,CACxB,EAAE,EAAE,EAAE,OAAO,EAAmC,EAChD,OAAwB;IAExB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAE1C,IAAI,UAAU,GAAG,IAAA,qBAAa,EAAC,oCAAgB,EAAE,EAAE,CAAC,CAAA;IAEpD,IAAI,gBAAgB,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;QAC9C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;KACzC,CAAC,CAAA;IAEF,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,CAAC,CAAC,mCAAmC,EAAE;YAC7C,gBAAgB,EAAE,EAAE;SACrB,CAAC,CACH,CAAA;IACH,CAAC;IAED,MAAM,IAAA,gCAAc,EAAC,gBAAgB,EAAE,OAAO,CAAC,CAAA;IAE/C,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,IAAI,iCAC/B,gBAAgB,KACnB,OAAO,EACP,OAAO,EAAE,IAAI,IACb,CAAA;IAEF,MAAM,cAAc,GAAG,MAAM,IAAA,qBAAa,EAAC,gCAAc,CAAC,CAAC,SAAS,CAAC;QACnE,EAAE,EAAE,gBAAgB,CAAC,gBAAgB;KACtC,CAAC,CAAA;IAEF,MAAM,IAAA,oCAA2B,EAAC,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,kBAAkB,EAAE,EAAE,QAAQ,EAAE,CAAC,cAAc,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;IAE9G,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { getRepository } from '@things-factory/shell'\nimport { checkAuthority } from './check-authority'\nimport { ActivityApproval } from '../../service/activity-approval/activity-approval'\nimport { ActivityThread } from '../../service/activity-thread/activity-thread'\nimport { updateActivityInstanceState } from '../common'\n\nexport async function save(\n { id, comment }: { id: string; comment: string },\n context: ResolverContext\n): Promise<ActivityApproval> {\n const { domain, user, tx } = context.state\n\n var repository = getRepository(ActivityApproval, tx)\n\n var activityApproval = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n if (!activityApproval) {\n throw new Error(\n context.t('error.activity-approval not found', {\n activityApproval: id\n })\n )\n }\n\n await checkAuthority(activityApproval, context)\n\n const result = await repository.save({\n ...activityApproval,\n comment,\n updater: user\n })\n\n const activityThread = await getRepository(ActivityThread).findOneBy({\n id: activityApproval.activityThreadId\n })\n\n await updateActivityInstanceState(activityThread?.activityInstanceId, { causedBy: [activityThread] }, context)\n\n return result\n}\n"]}
|
|
@@ -22,7 +22,7 @@ async function assign({ id, assignees, reason, dueAt }, context) {
|
|
|
22
22
|
- The previous state of the task must not be Assigned.
|
|
23
23
|
*/
|
|
24
24
|
if (activityInstance.state !== activity_instance_1.ActivityInstanceStatus.Issued &&
|
|
25
|
-
activityInstance.state !== activity_instance_1.ActivityInstanceStatus.
|
|
25
|
+
activityInstance.state !== activity_instance_1.ActivityInstanceStatus.Unassigned) {
|
|
26
26
|
throw new Error(context.t(`error.activity-instance should not be assigned`, {
|
|
27
27
|
id,
|
|
28
28
|
actual: activityInstance.state
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assign.js","sourceRoot":"","sources":["../../../server/controllers/activity-instance/assign.ts"],"names":[],"mappings":";;AAOA,wBAgDC;AAvDD,qCAA4B;AAE5B,yDAAgD;AAEhD,yFAA4G;AAC5G,sCAAyD;AAElD,KAAK,UAAU,MAAM,CAC1B,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAuE,EACrG,OAAwB;IAExB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,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E,EAAE;QACxC,SAAS,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC;KACpH,CAAC,CAAA;IAEF,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,CAAC,CAAC,mCAAmC,EAAE;YAC7C,gBAAgB,EAAE,EAAE;SACrB,CAAC,CACH,CAAA;IACH,CAAC;IAED;;;MAGE;IACF,IACE,gBAAgB,CAAC,KAAK,KAAK,0CAAsB,CAAC,MAAM;QACxD,gBAAgB,CAAC,KAAK,KAAK,0CAAsB,CAAC,UAAU,EAC5D,CAAC;QACD,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,CAAC,CAAC,gDAAgD,EAAE;YAC1D,EAAE;YACF,MAAM,EAAE,gBAAgB,CAAC,KAAK;SAC/B,CAAC,CACH,CAAA;IACH,CAAC;IAED,IAAI,KAAK,EAAE,CAAC;QACV,gBAAgB,CAAC,KAAK,GAAG,KAAK,CAAA;IAChC,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,gBAAI,CAAC,CAAC,MAAM,CAAC;QACxD,KAAK,EAAE,IAAA,YAAE,EAAC,SAAS,CAAC;KACrB,CAAC,CAAA;IAEF,MAAM,IAAA,sCAA6B,EAAC,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,OAAO,CAAC,CAAA;IAEvF,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,oCAAgB,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAAA;AACxF,CAAC","sourcesContent":["import { In } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\n\nimport { ActivityInstance, ActivityInstanceStatus } from '../../service/activity-instance/activity-instance'\nimport { createActivityThreadsForUsers } from '../common'\n\nexport async function assign(\n { id, assignees, reason, dueAt }: { id: string; assignees?: string[]; reason?: string; dueAt?: Date },\n context: ResolverContext\n): Promise<ActivityInstance> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(ActivityInstance)\n\n var activityInstance = await repository.findOne({\n where: { domain: { id: domain.id }, id },\n relations: ['domain', 'activity', 'assigneeRole', 'supervisoryRole', 'updater', 'creator', 'starter', 'terminator']\n })\n\n if (!activityInstance) {\n throw new Error(\n context.t('error.activity-instance not found', {\n activityInstance: id\n })\n )\n }\n\n /* \n Prerequisites for a Task to Be Assigned.\n - The previous state of the task must not be Assigned.\n */\n if (\n activityInstance.state !== ActivityInstanceStatus.Issued &&\n activityInstance.state !== ActivityInstanceStatus.Unassigned\n ) {\n throw new Error(\n context.t(`error.activity-instance should not be assigned`, {\n id,\n actual: activityInstance.state\n })\n )\n }\n\n if (dueAt) {\n activityInstance.dueAt = dueAt\n }\n\n const assignedUsers = await tx.getRepository(User).findBy({\n email: In(assignees)\n })\n\n await createActivityThreadsForUsers('assign', activityInstance, assignedUsers, context)\n\n return await tx.getRepository(ActivityInstance).findOneBy({ id: activityInstance.id })\n}\n"]}
|
|
@@ -93,11 +93,35 @@ async function issue(activityInstance, context) {
|
|
|
93
93
|
}
|
|
94
94
|
else {
|
|
95
95
|
const issued = await tx.getRepository(activity_instance_1.ActivityInstance).save(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ creator: user }, origin), activityInstance), { transaction: 'issue', activity }), activitySearchKeys), { state: activity_instance_1.ActivityInstanceStatus.Issued, domain, issuer: user, updater: user, issuedAt }));
|
|
96
|
+
/*
|
|
97
|
+
1. 하나의 thread가 필요한 경우 (대부분)
|
|
98
|
+
조건 : activityInstance의 threadsMin이 1 이어야 한다.
|
|
99
|
+
로직 1 : getSystemUserFromOrgMemberItem 의 결과가 한명이라면 그대로 activityThread.assignee로 직접 할당한다.
|
|
100
|
+
로직 2 : getSystemUserFromOrgMemberItem 의 결과가 한명이 아니라면, assignee타입이 assigneeRole 인 경우에만 처리가 가능하다.
|
|
101
|
+
이 경우에는 assignee를 비운다. - createActivityThreadWithUnassigned
|
|
102
|
+
2. 할당되지 않은 복수개의 thread가 필요한 경우
|
|
103
|
+
조건 : threadsMin이 1 이상이어야 한다.
|
|
104
|
+
로직 1 : getSystemUserFromOrgMemberItem 의 결과와 threadsMin 값이 같다면, 그대로 activityThread.assignee로 직접 할당한다. createActivityThreadsForAllRoleUsers
|
|
105
|
+
로직 2 : createActivityThreadWithUnassigned
|
|
106
|
+
3. 모든 assignee가 처리를 해야하는 경우
|
|
107
|
+
조건 : threadsMin이 0 이어야 한다.
|
|
108
|
+
로직 : getSystemUserFromOrgMemberItem 의 결과로 createActivityThreadsForUsers
|
|
109
|
+
*/
|
|
110
|
+
// assignees가 복수인 것은 아무 의미가 없다.
|
|
96
111
|
const assignedUsers = await Promise.all((assignees || []).map(assignee => (0, common_1.getSystemUserFromOrgMemberItem)(assignee, context)));
|
|
97
|
-
if (assignedUsers.length == 0
|
|
98
|
-
|
|
112
|
+
if (assignedUsers.length == 0) {
|
|
113
|
+
if (issued.assigneeRoleId) {
|
|
114
|
+
if (issued.threadsMin === 0) {
|
|
115
|
+
/* assigneeRoleId에 해당하는 모든 assignee 에게 태스크를 할당하는 경우 */
|
|
116
|
+
await (0, common_1.createActivityThreadsForAllRoleUsers)('issue', issued, context);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
/* minimum threads 설정에 따른 pending assignment 상태로 activityThread를 만드는 경우 */
|
|
120
|
+
await (0, common_1.createActivityThreadWithUnassigned)('issue', issued, context);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
99
123
|
}
|
|
100
|
-
|
|
124
|
+
else {
|
|
101
125
|
await (0, common_1.createActivityThreadsForUsers)('issue', issued, assignedUsers, context);
|
|
102
126
|
}
|
|
103
127
|
return await tx.getRepository(activity_instance_1.ActivityInstance).findOneBy({ id: issued.id });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue.js","sourceRoot":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OAAO,CAAC,CAAA;QACtE,CAAC;QAED,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAA,sCAA6B,EAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC,CAAA;QAC9E,CAAC;QAED,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,oCAAgB,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAA;IAC9E,CAAC;AACH,CAAC","sourcesContent":["import { In } from 'typeorm'\nimport { Activity } from '../../service/activity/activity'\nimport { ActivityInstance, ActivityInstanceStatus } from '../../service/activity-instance/activity-instance'\nimport { ActivityInstanceIssue } from '../../service/activity-instance/activity-instance-type'\nimport {\n createActivityThreadsForAllRoleUsers,\n createActivityThreadsForUsers,\n getSystemUserFromOrgMemberItem,\n createActivityThreadForUser,\n fillActivitySearchKeys\n} from '../common'\nimport { submit } from '../activity-thread/submit'\n\nexport async function issue(\n activityInstance: ActivityInstanceIssue,\n context: ResolverContext\n): Promise<ActivityInstance> {\n const { domain, user, tx } = context.state\n const issuedAt = new Date()\n var {\n id,\n name,\n description,\n assignees,\n uiType,\n uiSource,\n viewType,\n viewSource,\n dueAt,\n priority,\n approvalLine,\n activityId,\n activityType,\n assigneeRole,\n supervisoryRole,\n input\n } = activityInstance\n\n var origin = id\n ? await tx.getRepository(ActivityInstance).findOne({\n where: { domain: { id: domain.id }, id },\n relations: [\n 'domain',\n 'activity',\n 'assigneeRole',\n 'supervisoryRole',\n 'updater',\n 'creator',\n 'starter',\n 'terminator'\n ]\n })\n : null\n\n /* \n Prerequisites for a Task to Be Issued.\n - The previous state of the task should be Draft.\n */\n if (origin && origin.state !== ActivityInstanceStatus.Draft) {\n throw new Error(\n context.t(`error.activity-instance is already issued`, {\n id: id,\n state: origin.state\n })\n )\n }\n\n var repository = tx.getRepository(Activity)\n var activity =\n origin?.activity ||\n (await repository.findOne({\n where: { domain: domain.parentId ? { id: In([domain.id, domain.parentId]) } : { id: domain.id }, id: activityId },\n relations: ['assigneeRole', 'supervisoryRole']\n }))\n\n if (!activity) {\n throw new Error(\n context.t('error.activity not found', {\n activity: activityId\n })\n )\n }\n\n if (!origin) {\n activityInstance.name = name || activity.name\n activityInstance.description = description || activity.description\n activityInstance.activityType = activityType || activity.activityType\n activityInstance.uiType = uiType || activity.uiType\n activityInstance.uiSource = uiSource || activity.uiSource\n activityInstance.viewType = viewType || activity.viewType\n activityInstance.viewSource = viewSource || activity.viewSource\n activityInstance.assigneeRole = assigneeRole || activity.assigneeRole\n activityInstance.supervisoryRole = supervisoryRole || activity.supervisoryRole\n activityInstance.priority = priority ?? activity.priority\n\n activityInstance.adhocType = 'standard'\n activityInstance.refBy = activityId\n\n if (!assignees || !approvalLine) {\n if (!assignees) {\n assignees = activityInstance.assignees = activity.assignees\n }\n\n if (!approvalLine) {\n approvalLine = activityInstance.approvalLine = activity.approvalLine\n }\n\n if (!dueAt && activity.standardTime) {\n activityInstance.dueAt = new Date(issuedAt.getTime() + activity.standardTime * 1000)\n }\n }\n }\n\n const activitySearchKeys = fillActivitySearchKeys(activity?.searchKeys, input)\n\n if (activity.startingType == 'post') {\n /* \n startingType이 'post'이면, \n activityInstance 이슈와 동시에 issuer에게 할당된 activityThread가 생성되고 submit까지 모두 완료되게 된다.\n 만일, 결재선이 있다면, 상신되게 된다.\n */\n const posted = await tx.getRepository(ActivityInstance).save({\n creator: user,\n ...origin,\n ...activityInstance,\n transaction: 'post',\n activity,\n ...activitySearchKeys,\n state: ActivityInstanceStatus.Started,\n domain,\n issuer: user,\n updater: user,\n issuedAt,\n startedAt: issuedAt\n })\n\n const thread = await createActivityThreadForUser('post', posted, user, context)\n\n /* post 방식은 thread가 하나이므로, instance의 output을 그대로 thread의 output이라고 판단할 수 있다. 따라서, 아래 로직은 제거한다. */\n // const data = { ...activityInstance.input, ...activityInstance.output }\n // const output = (activity.model || [])\n // .filter(item => item.inout === 'inout' || item.inout === 'out')\n // .reduce((inout, item) => {\n // inout[item.tag] = data[item.tag]\n // return inout\n // }, {})\n\n await submit({ id: thread.id, output: activityInstance.output }, context)\n\n return await tx.getRepository(ActivityInstance).findOneBy({ id: posted.id })\n } else {\n const issued = await tx.getRepository(ActivityInstance).save({\n creator: user,\n ...origin,\n ...activityInstance,\n transaction: 'issue',\n activity,\n ...activitySearchKeys,\n state: ActivityInstanceStatus.Issued,\n domain,\n issuer: user,\n updater: user,\n issuedAt\n })\n\n const assignedUsers = await Promise.all(\n (assignees || []).map(assignee => getSystemUserFromOrgMemberItem(assignee, context))\n )\n\n if (assignedUsers.length == 0 && issued.threadsMin === 0 && issued.assigneeRoleId) {\n await createActivityThreadsForAllRoleUsers('issue', issued, context)\n }\n\n if (assignedUsers.length > 0) {\n await createActivityThreadsForUsers('issue', issued, assignedUsers, context)\n }\n\n return await tx.getRepository(ActivityInstance).findOneBy({ id: issued.id })\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"issue.js","sourceRoot":"","sources":["../../../server/controllers/activity-instance/issue.ts"],"names":[],"mappings":";;AAcA,sBA4LC;AA1MD,qCAA4B;AAC5B,8DAA0D;AAC1D,yFAA4G;AAE5G,sCAOkB;AAClB,sDAAkD;AAE3C,KAAK,UAAU,KAAK,CACzB,gBAAuC,EACvC,OAAwB;IAExB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAC1C,MAAM,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAA;IAC3B,IAAI,EACF,EAAE,EACF,IAAI,EACJ,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,KAAK,EACN,GAAG,gBAAgB,CAAA;IAEpB,IAAI,MAAM,GAAG,EAAE;QACb,CAAC,CAAC,MA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ActivityInstanceStatus } from '../../service/activity-instance/activity-instance'\nimport { ActivityInstanceIssue } from '../../service/activity-instance/activity-instance-type'\nimport {\n createActivityThreadWithUnassigned,\n createActivityThreadsForAllRoleUsers,\n createActivityThreadsForUsers,\n getSystemUserFromOrgMemberItem,\n createActivityThreadForUser,\n fillActivitySearchKeys\n} from '../common'\nimport { submit } from '../activity-thread/submit'\n\nexport async function issue(\n activityInstance: ActivityInstanceIssue,\n context: ResolverContext\n): Promise<ActivityInstance> {\n const { domain, user, tx } = context.state\n const issuedAt = new Date()\n var {\n id,\n name,\n description,\n assignees,\n uiType,\n uiSource,\n viewType,\n viewSource,\n dueAt,\n priority,\n approvalLine,\n activityId,\n activityType,\n assigneeRole,\n supervisoryRole,\n input\n } = activityInstance\n\n var origin = id\n ? await tx.getRepository(ActivityInstance).findOne({\n where: { domain: { id: domain.id }, id },\n relations: [\n 'domain',\n 'activity',\n 'assigneeRole',\n 'supervisoryRole',\n 'updater',\n 'creator',\n 'starter',\n 'terminator'\n ]\n })\n : null\n\n /* \n Prerequisites for a Task to Be Issued.\n - The previous state of the task should be Draft.\n */\n if (origin && origin.state !== ActivityInstanceStatus.Draft) {\n throw new Error(\n context.t(`error.activity-instance is already issued`, {\n id: id,\n state: origin.state\n })\n )\n }\n\n var repository = tx.getRepository(Activity)\n var activity =\n origin?.activity ||\n (await repository.findOne({\n where: { domain: domain.parentId ? { id: In([domain.id, domain.parentId]) } : { id: domain.id }, id: activityId },\n relations: ['assigneeRole', 'supervisoryRole']\n }))\n\n if (!activity) {\n throw new Error(\n context.t('error.activity not found', {\n activity: activityId\n })\n )\n }\n\n if (!origin) {\n activityInstance.name = name || activity.name\n activityInstance.description = description || activity.description\n activityInstance.activityType = activityType || activity.activityType\n activityInstance.uiType = uiType || activity.uiType\n activityInstance.uiSource = uiSource || activity.uiSource\n activityInstance.viewType = viewType || activity.viewType\n activityInstance.viewSource = viewSource || activity.viewSource\n activityInstance.assigneeRole = assigneeRole || activity.assigneeRole\n activityInstance.supervisoryRole = supervisoryRole || activity.supervisoryRole\n activityInstance.priority = priority ?? activity.priority\n\n activityInstance.adhocType = 'standard'\n activityInstance.refBy = activityId\n\n if (!assignees || !approvalLine) {\n if (!assignees) {\n assignees = activityInstance.assignees = activity.assignees\n }\n\n if (!approvalLine) {\n approvalLine = activityInstance.approvalLine = activity.approvalLine\n }\n\n if (!dueAt && activity.standardTime) {\n activityInstance.dueAt = new Date(issuedAt.getTime() + activity.standardTime * 1000)\n }\n }\n }\n\n const activitySearchKeys = fillActivitySearchKeys(activity?.searchKeys, input)\n\n if (activity.startingType == 'post') {\n /* \n startingType이 'post'이면, \n activityInstance 이슈와 동시에 issuer에게 할당된 activityThread가 생성되고 submit까지 모두 완료되게 된다.\n 만일, 결재선이 있다면, 상신되게 된다.\n */\n const posted = await tx.getRepository(ActivityInstance).save({\n creator: user,\n ...origin,\n ...activityInstance,\n transaction: 'post',\n activity,\n ...activitySearchKeys,\n state: ActivityInstanceStatus.Started,\n domain,\n issuer: user,\n updater: user,\n issuedAt,\n startedAt: issuedAt\n })\n\n const thread = await createActivityThreadForUser('post', posted, user, context)\n\n /* post 방식은 thread가 하나이므로, instance의 output을 그대로 thread의 output이라고 판단할 수 있다. 따라서, 아래 로직은 제거한다. */\n // const data = { ...activityInstance.input, ...activityInstance.output }\n // const output = (activity.model || [])\n // .filter(item => item.inout === 'inout' || item.inout === 'out')\n // .reduce((inout, item) => {\n // inout[item.tag] = data[item.tag]\n // return inout\n // }, {})\n\n await submit({ id: thread.id, output: activityInstance.output }, context)\n\n return await tx.getRepository(ActivityInstance).findOneBy({ id: posted.id })\n } else {\n const issued = await tx.getRepository(ActivityInstance).save({\n creator: user,\n ...origin,\n ...activityInstance,\n transaction: 'issue',\n activity,\n ...activitySearchKeys,\n state: ActivityInstanceStatus.Issued,\n domain,\n issuer: user,\n updater: user,\n issuedAt\n })\n\n /*\n 1. 하나의 thread가 필요한 경우 (대부분)\n 조건 : activityInstance의 threadsMin이 1 이어야 한다.\n 로직 1 : getSystemUserFromOrgMemberItem 의 결과가 한명이라면 그대로 activityThread.assignee로 직접 할당한다.\n 로직 2 : getSystemUserFromOrgMemberItem 의 결과가 한명이 아니라면, assignee타입이 assigneeRole 인 경우에만 처리가 가능하다.\n 이 경우에는 assignee를 비운다. - createActivityThreadWithUnassigned\n 2. 할당되지 않은 복수개의 thread가 필요한 경우\n 조건 : threadsMin이 1 이상이어야 한다.\n 로직 1 : getSystemUserFromOrgMemberItem 의 결과와 threadsMin 값이 같다면, 그대로 activityThread.assignee로 직접 할당한다. createActivityThreadsForAllRoleUsers\n 로직 2 : createActivityThreadWithUnassigned\n 3. 모든 assignee가 처리를 해야하는 경우\n 조건 : threadsMin이 0 이어야 한다.\n 로직 : getSystemUserFromOrgMemberItem 의 결과로 createActivityThreadsForUsers\n */\n\n // assignees가 복수인 것은 아무 의미가 없다.\n const assignedUsers = await Promise.all(\n (assignees || []).map(assignee => getSystemUserFromOrgMemberItem(assignee, context))\n )\n\n if (assignedUsers.length == 0) {\n if (issued.assigneeRoleId) {\n if (issued.threadsMin === 0) {\n /* assigneeRoleId에 해당하는 모든 assignee 에게 태스크를 할당하는 경우 */\n await createActivityThreadsForAllRoleUsers('issue', issued, context)\n } else {\n /* minimum threads 설정에 따른 pending assignment 상태로 activityThread를 만드는 경우 */\n await createActivityThreadWithUnassigned('issue', issued, context)\n }\n }\n } else {\n await createActivityThreadsForUsers('issue', issued, assignedUsers, context)\n }\n\n return await tx.getRepository(ActivityInstance).findOneBy({ id: issued.id })\n }\n}\n"]}
|
|
@@ -20,7 +20,7 @@ async function pick(id, context) {
|
|
|
20
20
|
- The previous state of the task must not be Assigned.
|
|
21
21
|
*/
|
|
22
22
|
if (activityInstance.state !== activity_instance_1.ActivityInstanceStatus.Issued &&
|
|
23
|
-
activityInstance.state !== activity_instance_1.ActivityInstanceStatus.
|
|
23
|
+
activityInstance.state !== activity_instance_1.ActivityInstanceStatus.Unassigned) {
|
|
24
24
|
throw new Error(context.t(`error.activity-instance should not be assigned`, {
|
|
25
25
|
id,
|
|
26
26
|
actual: activityInstance.state
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pick.js","sourceRoot":"","sources":["../../../server/controllers/activity-instance/pick.ts"],"names":[],"mappings":";;AAIA,oBAwCC;AA5CD,yFAA4G;AAE5G,sCAAyD;AAElD,KAAK,UAAU,IAAI,CAAC,EAAU,EAAE,OAAwB;IAC7D,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAC1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,oCAAgB,CAAC,CAAA;IAErD,IAAI,gBAAgB,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;QAC9C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;QACxC,SAAS,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC;KACpH,CAAC,CAAA;IAEF,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,CAAC,CAAC,mCAAmC,EAAE;YAC7C,gBAAgB,EAAE,EAAE;SACrB,CAAC,CACH,CAAA;IACH,CAAC;IAED;;;MAGE;IACF,IACE,gBAAgB,CAAC,KAAK,KAAK,0CAAsB,CAAC,MAAM;QACxD,gBAAgB,CAAC,KAAK,KAAK,0CAAsB,CAAC,
|
|
1
|
+
{"version":3,"file":"pick.js","sourceRoot":"","sources":["../../../server/controllers/activity-instance/pick.ts"],"names":[],"mappings":";;AAIA,oBAwCC;AA5CD,yFAA4G;AAE5G,sCAAyD;AAElD,KAAK,UAAU,IAAI,CAAC,EAAU,EAAE,OAAwB;IAC7D,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAC1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,oCAAgB,CAAC,CAAA;IAErD,IAAI,gBAAgB,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;QAC9C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;QACxC,SAAS,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC;KACpH,CAAC,CAAA;IAEF,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,CAAC,CAAC,mCAAmC,EAAE;YAC7C,gBAAgB,EAAE,EAAE;SACrB,CAAC,CACH,CAAA;IACH,CAAC;IAED;;;MAGE;IACF,IACE,gBAAgB,CAAC,KAAK,KAAK,0CAAsB,CAAC,MAAM;QACxD,gBAAgB,CAAC,KAAK,KAAK,0CAAsB,CAAC,UAAU,EAC5D,CAAC;QACD,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,CAAC,CAAC,gDAAgD,EAAE;YAC1D,EAAE;YACF,MAAM,EAAE,gBAAgB,CAAC,KAAK;SAC/B,CAAC,CACH,CAAA;IACH,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,IAAI,iCAC/B,gBAAgB,KACnB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,IAAI,IACb,CAAA;IAEF,OAAO,CAAC,MAAM,IAAA,sCAA6B,EAAC,MAAM,EAAE,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAClF,CAAC","sourcesContent":["import { ActivityInstance, ActivityInstanceStatus } from '../../service/activity-instance/activity-instance'\nimport { ActivityThread } from '../../service/activity-thread/activity-thread'\nimport { createActivityThreadsForUsers } from '../common'\n\nexport async function pick(id: string, context: ResolverContext): Promise<ActivityThread> {\n const { domain, user, tx } = context.state\n const repository = tx.getRepository(ActivityInstance)\n\n var activityInstance = await repository.findOne({\n where: { domain: { id: domain.id }, id },\n relations: ['domain', 'activity', 'assigneeRole', 'supervisoryRole', 'updater', 'creator', 'starter', 'terminator']\n })\n\n if (!activityInstance) {\n throw new Error(\n context.t('error.activity-instance not found', {\n activityInstance: id\n })\n )\n }\n\n /* \n Prerequisites for a Task to Be Picked.\n - The previous state of the task must not be Assigned.\n */\n if (\n activityInstance.state !== ActivityInstanceStatus.Issued &&\n activityInstance.state !== ActivityInstanceStatus.Unassigned\n ) {\n throw new Error(\n context.t(`error.activity-instance should not be assigned`, {\n id,\n actual: activityInstance.state\n })\n )\n }\n\n const picked = await repository.save({\n ...activityInstance,\n transaction: 'pick',\n updater: user\n })\n\n return (await createActivityThreadsForUsers('pick', picked, [user], context))[0]\n}\n"]}
|
|
@@ -4,6 +4,7 @@ exports.abort = abort;
|
|
|
4
4
|
const activity_thread_1 = require("../../service/activity-thread/activity-thread");
|
|
5
5
|
const common_1 = require("../common");
|
|
6
6
|
const _abort_1 = require("./_abort");
|
|
7
|
+
const check_authority_1 = require("./check-authority");
|
|
7
8
|
async function abort({ id, reason }, context) {
|
|
8
9
|
const { domain, user, tx } = context.state;
|
|
9
10
|
var repository = tx.getRepository(activity_thread_1.ActivityThread);
|
|
@@ -16,6 +17,7 @@ async function abort({ id, reason }, context) {
|
|
|
16
17
|
activityThread: id
|
|
17
18
|
}));
|
|
18
19
|
}
|
|
20
|
+
await (0, check_authority_1.checkAuthority)(activityThread, context);
|
|
19
21
|
/*
|
|
20
22
|
Prerequisites for a activity thread to Be Aborted.
|
|
21
23
|
- The previous state of the activity thread must not be End or Aborted.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abort.js","sourceRoot":"","sources":["../../../server/controllers/activity-thread/abort.ts"],"names":[],"mappings":";;
|
|
1
|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IAAI,EAAE,CAAA;IACvC,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,IAAA,eAAM,EAAC,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,CAAA;IAEhE,MAAM,IAAA,oCAA2B,EAAC,cAAc,CAAC,kBAAkB,EAAE,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;IAErG,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { ActivityThread, ActivityThreadStatus } from '../../service/activity-thread/activity-thread'\nimport { updateActivityInstanceState } from '../common'\nimport { _abort } from './_abort'\nimport { checkAuthority } from './check-authority'\n\nexport async function abort(\n { id, reason }: { id: string; reason: string },\n context: ResolverContext\n): Promise<ActivityThread> {\n const { domain, user, tx } = context.state\n\n var repository = tx.getRepository(ActivityThread)\n\n var activityThread = await repository.findOne({\n where: { domain: { id: domain.id }, id },\n relations: ['domain', 'activityInstance', 'assignee', 'creator', 'updater']\n })\n\n if (!activityThread) {\n throw new Error(\n context.t('error.activity-thread not found', {\n activityThread: id\n })\n )\n }\n\n await checkAuthority(activityThread, context)\n\n /* \n Prerequisites for a activity thread to Be Aborted.\n - The previous state of the activity thread must not be End or Aborted.\n */\n if (activityThread.state == ActivityThreadStatus.Aborted || activityThread.state == ActivityThreadStatus.Ended) {\n throw new Error(\n context.t(`error.activity-thread is already terminated`, {\n id,\n state: activityThread.state\n })\n )\n }\n\n if (!activityThread.startedAt) {\n activityThread.startedAt = new Date()\n }\n\n const result = await _abort({ activityThread, reason }, context)\n\n await updateActivityInstanceState(activityThread.activityInstanceId, { causedBy: [result] }, context)\n\n return result\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkAuthority = checkAuthority;
|
|
4
|
+
const shell_1 = require("@things-factory/shell");
|
|
5
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
6
|
+
const activity_thread_1 = require("../../service/activity-thread/activity-thread");
|
|
7
|
+
const activity_instance_1 = require("../../service/activity-instance/activity-instance");
|
|
8
|
+
async function checkAuthority(activityThread, context) {
|
|
9
|
+
var _a;
|
|
10
|
+
const { user, tx } = context.state;
|
|
11
|
+
if (activityThread.assigneeId && activityThread.assigneeId === user.id) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
// TODO activityInstance의 cardinality를 기준으로 unassigned thread를 추가로 만들 지, assigned thread로 대체할 지를 구현해야한다.
|
|
15
|
+
if (activityThread.state == activity_thread_1.ActivityThreadStatus.Unassigned) {
|
|
16
|
+
const activityInstance = await (0, shell_1.getRepository)(activity_instance_1.ActivityInstance, tx).findOneBy({
|
|
17
|
+
id: activityThread.activityInstanceId
|
|
18
|
+
});
|
|
19
|
+
if (activityInstance && activityInstance.assigneeRoleId) {
|
|
20
|
+
const roles = (_a = (await (0, shell_1.getRepository)(auth_base_1.User, tx).findOne({
|
|
21
|
+
where: { id: user.id },
|
|
22
|
+
relations: ['roles']
|
|
23
|
+
}))) === null || _a === void 0 ? void 0 : _a.roles;
|
|
24
|
+
if (roles.find(role => role.id == activityInstance.assigneeRoleId)) {
|
|
25
|
+
activityThread.assignee = user;
|
|
26
|
+
activityThread.state = activity_thread_1.ActivityThreadStatus.Assigned;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
throw new Error(context.t(`error.not authorized to handle this task`));
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=check-authority.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-authority.js","sourceRoot":"","sources":["../../../server/controllers/activity-thread/check-authority.ts"],"names":[],"mappings":";;AAKA,wCA+BC;AApCD,iDAAqD;AACrD,yDAAgD;AAChD,mFAAoG;AACpG,yFAAoF;AAE7E,KAAK,UAAU,cAAc,CAAC,cAA8B,EAAE,OAAwB;;IAC3F,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAElC,IAAI,cAAc,CAAC,UAAU,IAAI,cAAc,CAAC,UAAU,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC;QACvE,OAAM;IACR,CAAC;IAED,wGAAwG;IACxG,IAAI,cAAc,CAAC,KAAK,IAAI,sCAAoB,CAAC,UAAU,EAAE,CAAC;QAC5D,MAAM,gBAAgB,GAAG,MAAM,IAAA,qBAAa,EAAC,oCAAgB,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC;YAC3E,EAAE,EAAE,cAAc,CAAC,kBAAkB;SACtC,CAAC,CAAA;QAEF,IAAI,gBAAgB,IAAI,gBAAgB,CAAC,cAAc,EAAE,CAAC;YACxD,MAAM,KAAK,GAAG,MAAA,CACZ,MAAM,IAAA,qBAAa,EAAC,gBAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC;gBACpC,KAAK,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE;gBACtB,SAAS,EAAE,CAAC,OAAO,CAAC;aACrB,CAAC,CACH,0CAAE,KAAK,CAAA;YAER,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,gBAAgB,CAAC,cAAc,CAAC,EAAE,CAAC;gBACnE,cAAc,CAAC,QAAQ,GAAG,IAAI,CAAA;gBAC9B,cAAc,CAAC,KAAK,GAAG,sCAAoB,CAAC,QAAQ,CAAA;gBAEpD,OAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,0CAA0C,CAAC,CAAC,CAAA;AACxE,CAAC","sourcesContent":["import { getRepository } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { ActivityThread, ActivityThreadStatus } from '../../service/activity-thread/activity-thread'\nimport { ActivityInstance } from '../../service/activity-instance/activity-instance'\n\nexport async function checkAuthority(activityThread: ActivityThread, context: ResolverContext) {\n const { user, tx } = context.state\n\n if (activityThread.assigneeId && activityThread.assigneeId === user.id) {\n return\n }\n\n // TODO activityInstance의 cardinality를 기준으로 unassigned thread를 추가로 만들 지, assigned thread로 대체할 지를 구현해야한다.\n if (activityThread.state == ActivityThreadStatus.Unassigned) {\n const activityInstance = await getRepository(ActivityInstance, tx).findOneBy({\n id: activityThread.activityInstanceId\n })\n\n if (activityInstance && activityInstance.assigneeRoleId) {\n const roles = (\n await getRepository(User, tx).findOne({\n where: { id: user.id },\n relations: ['roles']\n })\n )?.roles\n\n if (roles.find(role => role.id == activityInstance.assigneeRoleId)) {\n activityThread.assignee = user\n activityThread.state = ActivityThreadStatus.Assigned\n\n return\n }\n }\n }\n\n throw new Error(context.t(`error.not authorized to handle this task`))\n}\n"]}
|