@things-factory/process 6.0.57 → 6.0.59

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 (58) hide show
  1. package/client/pages/event/event-importer.ts +97 -0
  2. package/client/pages/event/event-list-page.ts +348 -0
  3. package/client/pages/gateway/gateway-importer.ts +97 -0
  4. package/client/pages/gateway/gateway-list-page.ts +348 -0
  5. package/client/route.ts +8 -0
  6. package/dist-client/pages/event/event-importer.d.ts +22 -0
  7. package/dist-client/pages/event/event-importer.js +100 -0
  8. package/dist-client/pages/event/event-importer.js.map +1 -0
  9. package/dist-client/pages/event/event-list-page.d.ts +62 -0
  10. package/dist-client/pages/event/event-list-page.js +326 -0
  11. package/dist-client/pages/event/event-list-page.js.map +1 -0
  12. package/dist-client/pages/gateway/gateway-importer.d.ts +22 -0
  13. package/dist-client/pages/gateway/gateway-importer.js +100 -0
  14. package/dist-client/pages/gateway/gateway-importer.js.map +1 -0
  15. package/dist-client/pages/gateway/gateway-list-page.d.ts +62 -0
  16. package/dist-client/pages/gateway/gateway-list-page.js +326 -0
  17. package/dist-client/pages/gateway/gateway-list-page.js.map +1 -0
  18. package/dist-client/route.d.ts +1 -1
  19. package/dist-client/route.js +6 -0
  20. package/dist-client/route.js.map +1 -1
  21. package/dist-client/tsconfig.tsbuildinfo +1 -1
  22. package/dist-server/routes.js +52 -0
  23. package/dist-server/routes.js.map +1 -1
  24. package/dist-server/service/index.js +3 -3
  25. package/dist-server/service/index.js.map +1 -1
  26. package/dist-server/tsconfig.tsbuildinfo +1 -1
  27. package/helps/process/event.md +160 -0
  28. package/helps/process/gateway.md +160 -0
  29. package/package.json +10 -10
  30. package/server/routes.ts +52 -0
  31. package/server/service/index.ts +27 -15
  32. package/things-factory.config.js +3 -1
  33. package/dist-server/controllers/process-instance/assign.js +0 -41
  34. package/dist-server/controllers/process-instance/assign.js.map +0 -1
  35. package/dist-server/controllers/process-instance/draft.js +0 -74
  36. package/dist-server/controllers/process-instance/draft.js.map +0 -1
  37. package/dist-server/controllers/process-instance/issue.js +0 -105
  38. package/dist-server/controllers/process-instance/issue.js.map +0 -1
  39. package/dist-server/controllers/process-instance/pick.js +0 -33
  40. package/dist-server/controllers/process-instance/pick.js.map +0 -1
  41. package/dist-server/controllers/process-thread/delegate.js +0 -36
  42. package/dist-server/controllers/process-thread/delegate.js.map +0 -1
  43. package/dist-server/controllers/process-thread/restart.js +0 -36
  44. package/dist-server/controllers/process-thread/restart.js.map +0 -1
  45. package/dist-server/controllers/process-thread/save.js +0 -38
  46. package/dist-server/controllers/process-thread/save.js.map +0 -1
  47. package/dist-server/controllers/process-thread/submit.js +0 -37
  48. package/dist-server/controllers/process-thread/submit.js.map +0 -1
  49. package/dist-server/service/process/process-model-type.js +0 -138
  50. package/dist-server/service/process/process-model-type.js.map +0 -1
  51. package/dist-server/service/process-summary/index.js +0 -8
  52. package/dist-server/service/process-summary/index.js.map +0 -1
  53. package/dist-server/service/process-summary/process-summary-query.js +0 -109
  54. package/dist-server/service/process-summary/process-summary-query.js.map +0 -1
  55. package/dist-server/service/process-summary/process-summary.js +0 -28
  56. package/dist-server/service/process-summary/process-summary.js.map +0 -1
  57. package/dist-server/service/process-thread/process-thread-history.js +0 -194
  58. package/dist-server/service/process-thread/process-thread-history.js.map +0 -1
@@ -0,0 +1,160 @@
1
+ # Event
2
+
3
+ Paragraphs are separated by a blank line.
4
+
5
+ 2nd paragraph. _Italic_, **bold**, and `monospace`. Itemized lists
6
+ look like:
7
+
8
+ - this one
9
+ - that one
10
+ - the other one
11
+
12
+ Note that --- not considering the asterisk --- the actual text
13
+ content starts at 4-columns in.
14
+
15
+ > Block quotes are
16
+ > written like so.
17
+ >
18
+ > They can span multiple paragraphs,
19
+ > if you like.
20
+
21
+ Use 3 dashes for an em-dash. Use 2 dashes for ranges (ex., "it's all
22
+ in chapters 12--14"). Three dots ... will be converted to an ellipsis.
23
+ Unicode is supported. ☺
24
+
25
+ ## An h2 header
26
+
27
+ Here's a numbered list:
28
+
29
+ 1. first item
30
+ 2. second item
31
+ 3. third item
32
+
33
+ Note again how the actual text starts at 4 columns in (4 characters
34
+ from the left side). Here's a code sample:
35
+
36
+ # Let me re-iterate ...
37
+
38
+ for i in 1 .. 10 { do-something(i) }
39
+
40
+ As you probably guessed, indented 4 spaces. By the way, instead of
41
+ indenting the block, you can use delimited blocks, if you like:
42
+
43
+ ```
44
+ define foobar() {
45
+ print "Welcome to flavor country!";
46
+ }
47
+ ```
48
+
49
+ (which makes copying & pasting easier). You can optionally mark the
50
+ delimited block for Pandoc to syntax highlight it:
51
+
52
+ ```python
53
+ import time
54
+ # Quick, count to ten!
55
+ for i in range(10):
56
+ # (but not *too* quick)
57
+ time.sleep(0.5)
58
+ print(i)
59
+ ```
60
+
61
+ ### An h3 header
62
+
63
+ Now a nested list:
64
+
65
+ 1. First, get these ingredients:
66
+
67
+ - carrots
68
+ - celery
69
+ - lentils
70
+
71
+ 2. Boil some water.
72
+
73
+ 3. Dump everything in the pot and follow
74
+ this algorithm:
75
+
76
+ find wooden spoon
77
+ uncover pot
78
+ stir
79
+ cover pot
80
+ balance wooden spoon precariously on pot handle
81
+ wait 10 minutes
82
+ goto first step (or shut off burner when done)
83
+
84
+ Do not bump wooden spoon or it will fall.
85
+
86
+ Notice again how text always lines up on 4-space indents (including
87
+ that last line which continues item 3 above).
88
+
89
+ Here's a link to [a website](http://foo.bar), to a [local
90
+ doc](local-doc.html), and to a [section heading in the current
91
+ doc](#an-h2-header). Here's a footnote [^1].
92
+
93
+ [^1]: Some footnote text.
94
+
95
+ Tables can look like this:
96
+
97
+ Name Size Material Color
98
+
99
+ ---
100
+
101
+ All Business 9 leather brown
102
+ Roundabout 10 hemp canvas natural
103
+ Cinderella 11 glass transparent
104
+
105
+ Table: Shoes sizes, materials, and colors.
106
+
107
+ (The above is the caption for the table.) Pandoc also supports
108
+ multi-line tables:
109
+
110
+ ---
111
+
112
+ Keyword Text
113
+
114
+ ---
115
+
116
+ red Sunsets, apples, and
117
+ other red or reddish
118
+ things.
119
+
120
+ green Leaves, grass, frogs
121
+ and other things it's
122
+ not easy being.
123
+
124
+ ---
125
+
126
+ A horizontal rule follows.
127
+
128
+ ---
129
+
130
+ Here's a definition list:
131
+
132
+ apples
133
+ : Good for making applesauce.
134
+
135
+ oranges
136
+ : Citrus!
137
+
138
+ tomatoes
139
+ : There's no "e" in tomatoe.
140
+
141
+ Again, text is indented 4 spaces. (Put a blank line between each
142
+ term and its definition to spread things out more.)
143
+
144
+ Here's a "line block" (note how whitespace is honored):
145
+
146
+ | Line one
147
+ | Line too
148
+ | Line tree
149
+
150
+ and images can be specified like so:
151
+
152
+ ![example image](example-image.jpg 'An exemplary image')
153
+
154
+ Inline math equation: $\omega = d\phi / dt$. Display
155
+ math should get its own line like so:
156
+
157
+ $$I = \int \rho R^{2} dV$$
158
+
159
+ And note that you can backslash-escape any punctuation characters
160
+ which you wish to be displayed literally, ex.: \`foo\`, \*bar\*, etc.
@@ -0,0 +1,160 @@
1
+ # Gateway
2
+
3
+ Paragraphs are separated by a blank line.
4
+
5
+ 2nd paragraph. _Italic_, **bold**, and `monospace`. Itemized lists
6
+ look like:
7
+
8
+ - this one
9
+ - that one
10
+ - the other one
11
+
12
+ Note that --- not considering the asterisk --- the actual text
13
+ content starts at 4-columns in.
14
+
15
+ > Block quotes are
16
+ > written like so.
17
+ >
18
+ > They can span multiple paragraphs,
19
+ > if you like.
20
+
21
+ Use 3 dashes for an em-dash. Use 2 dashes for ranges (ex., "it's all
22
+ in chapters 12--14"). Three dots ... will be converted to an ellipsis.
23
+ Unicode is supported. ☺
24
+
25
+ ## An h2 header
26
+
27
+ Here's a numbered list:
28
+
29
+ 1. first item
30
+ 2. second item
31
+ 3. third item
32
+
33
+ Note again how the actual text starts at 4 columns in (4 characters
34
+ from the left side). Here's a code sample:
35
+
36
+ # Let me re-iterate ...
37
+
38
+ for i in 1 .. 10 { do-something(i) }
39
+
40
+ As you probably guessed, indented 4 spaces. By the way, instead of
41
+ indenting the block, you can use delimited blocks, if you like:
42
+
43
+ ```
44
+ define foobar() {
45
+ print "Welcome to flavor country!";
46
+ }
47
+ ```
48
+
49
+ (which makes copying & pasting easier). You can optionally mark the
50
+ delimited block for Pandoc to syntax highlight it:
51
+
52
+ ```python
53
+ import time
54
+ # Quick, count to ten!
55
+ for i in range(10):
56
+ # (but not *too* quick)
57
+ time.sleep(0.5)
58
+ print(i)
59
+ ```
60
+
61
+ ### An h3 header
62
+
63
+ Now a nested list:
64
+
65
+ 1. First, get these ingredients:
66
+
67
+ - carrots
68
+ - celery
69
+ - lentils
70
+
71
+ 2. Boil some water.
72
+
73
+ 3. Dump everything in the pot and follow
74
+ this algorithm:
75
+
76
+ find wooden spoon
77
+ uncover pot
78
+ stir
79
+ cover pot
80
+ balance wooden spoon precariously on pot handle
81
+ wait 10 minutes
82
+ goto first step (or shut off burner when done)
83
+
84
+ Do not bump wooden spoon or it will fall.
85
+
86
+ Notice again how text always lines up on 4-space indents (including
87
+ that last line which continues item 3 above).
88
+
89
+ Here's a link to [a website](http://foo.bar), to a [local
90
+ doc](local-doc.html), and to a [section heading in the current
91
+ doc](#an-h2-header). Here's a footnote [^1].
92
+
93
+ [^1]: Some footnote text.
94
+
95
+ Tables can look like this:
96
+
97
+ Name Size Material Color
98
+
99
+ ---
100
+
101
+ All Business 9 leather brown
102
+ Roundabout 10 hemp canvas natural
103
+ Cinderella 11 glass transparent
104
+
105
+ Table: Shoes sizes, materials, and colors.
106
+
107
+ (The above is the caption for the table.) Pandoc also supports
108
+ multi-line tables:
109
+
110
+ ---
111
+
112
+ Keyword Text
113
+
114
+ ---
115
+
116
+ red Sunsets, apples, and
117
+ other red or reddish
118
+ things.
119
+
120
+ green Leaves, grass, frogs
121
+ and other things it's
122
+ not easy being.
123
+
124
+ ---
125
+
126
+ A horizontal rule follows.
127
+
128
+ ---
129
+
130
+ Here's a definition list:
131
+
132
+ apples
133
+ : Good for making applesauce.
134
+
135
+ oranges
136
+ : Citrus!
137
+
138
+ tomatoes
139
+ : There's no "e" in tomatoe.
140
+
141
+ Again, text is indented 4 spaces. (Put a blank line between each
142
+ term and its definition to spread things out more.)
143
+
144
+ Here's a "line block" (note how whitespace is honored):
145
+
146
+ | Line one
147
+ | Line too
148
+ | Line tree
149
+
150
+ and images can be specified like so:
151
+
152
+ ![example image](example-image.jpg 'An exemplary image')
153
+
154
+ Inline math equation: $\omega = d\phi / dt$. Display
155
+ math should get its own line like so:
156
+
157
+ $$I = \int \rho R^{2} dV$$
158
+
159
+ And note that you can backslash-escape any punctuation characters
160
+ which you wish to be displayed literally, ex.: \`foo\`, \*bar\*, etc.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/process",
3
- "version": "6.0.57",
3
+ "version": "6.0.59",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -30,15 +30,15 @@
30
30
  "@operato/graphql": "^1.0.0",
31
31
  "@operato/grist-editor": "^1.0.0",
32
32
  "@operato/shell": "^1.0.0",
33
- "@things-factory/attachment-base": "^6.0.57",
34
- "@things-factory/auth-base": "^6.0.57",
35
- "@things-factory/board-service": "^6.0.57",
36
- "@things-factory/context-ui": "^6.0.57",
37
- "@things-factory/organization": "^6.0.57",
38
- "@things-factory/scheduler-client": "^6.0.57",
39
- "@things-factory/shell": "^6.0.57",
40
- "@things-factory/worklist": "^6.0.57",
33
+ "@things-factory/attachment-base": "^6.0.59",
34
+ "@things-factory/auth-base": "^6.0.59",
35
+ "@things-factory/board-service": "^6.0.59",
36
+ "@things-factory/context-ui": "^6.0.59",
37
+ "@things-factory/organization": "^6.0.59",
38
+ "@things-factory/scheduler-client": "^6.0.59",
39
+ "@things-factory/shell": "^6.0.59",
40
+ "@things-factory/worklist": "^6.0.59",
41
41
  "moment-timezone": "^0.5.40"
42
42
  },
43
- "gitHead": "7aaa2253e3046278972372263d13fd9b6dbb6e8b"
43
+ "gitHead": "b096d361b7139d73fddfa940bccb03aa62db7309"
44
44
  }
package/server/routes.ts CHANGED
@@ -13,6 +13,58 @@ process.on('bootstrap-module-global-private-route' as any, (app, globalPrivateRo
13
13
  /*
14
14
  * can add global private routes to application (auth required, tenancy not required)
15
15
  */
16
+ /* When a callback occurs from the scheduler when a scheduled dataset is on schedule, data collection task for the dataset should be issued. */
17
+ // globalPrivateRouter.post('/callback-schedule-for-start-event', async (context, next) => {
18
+ // const { client } = context.request.body as ScheduleRegisterRequest
19
+ // if (!client || typeof client !== 'object') {
20
+ // throw new Error('client property should be a part of callback body.')
21
+ // }
22
+ // const { group: domainId, key: dataSetId } = client
23
+ // if (!domainId || !dataSetId) {
24
+ // throw new Error(`group(${domainId}) and key(${dataSetId}) properties should not be empty`)
25
+ // }
26
+ // await getDataSource().transaction(async tx => {
27
+ // const domain = await tx.getRepository(Domain).findOneBy({ id: domainId })
28
+ // if (!domain) {
29
+ // throw new Error(`domain(${domainId}) not found`)
30
+ // }
31
+ // const dataSet = await tx.getRepository(DataSet).findOne({ where: { domain: { id: domainId }, id: dataSetId } })
32
+ // const activity = (await tx.getRepository(Activity).findOneBy({
33
+ // domain: { id: domainId },
34
+ // name: 'Collect Data'
35
+ // })) as Activity
36
+ // if (activity) {
37
+ // const { assignees } = dataSet
38
+ // /* 해당 dataset에 대한 데이타 수집 태스크를 dataset assignees에게 할당한다. */
39
+ // if (assignees && assignees instanceof Array && assignees.length > 0) {
40
+ // const activityInstance = {
41
+ // name: `[Data 수집] ${dataSet.name}`,
42
+ // description: dataSet.description,
43
+ // activityId: activity.id,
44
+ // dueAt: new Date(Date.now() + 24 * 60 * 60 * 1000),
45
+ // input: {
46
+ // dataSetId: dataSet.id,
47
+ // dataSetName: dataSet.name
48
+ // },
49
+ // assignees
50
+ // }
51
+ // context.state = {
52
+ // ...context.state,
53
+ // domain,
54
+ // tx
55
+ // }
56
+ // await issue(activityInstance, context)
57
+ // } else {
58
+ // throw new Error(
59
+ // `Assignees not set. So Data Collect Activity for ${dataSet.name}($dataSet.id) could not be issued.`
60
+ // )
61
+ // }
62
+ // } else {
63
+ // throw new Error(`Data Collect Activity is not installed.`)
64
+ // }
65
+ // })
66
+ // context.status = 200
67
+ // })
16
68
  })
17
69
 
18
70
  process.on('bootstrap-module-domain-public-route' as any, (app, domainPublicRouter) => {
@@ -4,29 +4,41 @@ export * from './process-instance/process-instance'
4
4
  export * from './process/process'
5
5
 
6
6
  /* IMPORT ENTITIES AND RESOLVERS */
7
- import { entities as ProcessThreadEntities, resolvers as ProcessThreadResolvers, subscribers as ProcessThreadSubscribers } from './process-thread'
8
- import { entities as ProcessInstanceEntities, resolvers as ProcessInstanceResolvers, subscribers as ProcessInstanceSubscribers } from './process-instance'
9
- import { entities as ProcessEntities, resolvers as ProcessResolvers, subscribers as ProcessSubscribers } from './process'
7
+ import {
8
+ entities as ProcessThreadEntities,
9
+ resolvers as ProcessThreadResolvers,
10
+ subscribers as ProcessThreadSubscribers
11
+ } from './process-thread'
12
+ import {
13
+ entities as ProcessInstanceEntities,
14
+ resolvers as ProcessInstanceResolvers,
15
+ subscribers as ProcessInstanceSubscribers
16
+ } from './process-instance'
17
+ import {
18
+ entities as ProcessEntities,
19
+ resolvers as ProcessResolvers,
20
+ subscribers as ProcessSubscribers
21
+ } from './process'
10
22
 
11
- export const entities = [
23
+ export const entities = [
12
24
  /* ENTITIES */
13
- ...ProcessThreadEntities,
14
- ...ProcessInstanceEntities,
15
- ...ProcessEntities,
16
- ]
25
+ ...ProcessThreadEntities,
26
+ ...ProcessInstanceEntities,
27
+ ...ProcessEntities
28
+ ]
17
29
 
18
30
  export const subscribers = [
19
31
  /* SUBSCRIBERS */
20
- ...ProcessThreadSubscribers,
21
- ...ProcessInstanceSubscribers,
22
- ...ProcessSubscribers,
32
+ ...ProcessThreadSubscribers,
33
+ ...ProcessInstanceSubscribers,
34
+ ...ProcessSubscribers
23
35
  ]
24
36
 
25
37
  export const schema = {
26
38
  resolverClasses: [
27
39
  /* RESOLVER CLASSES */
28
- ...ProcessThreadResolvers,
29
- ...ProcessInstanceResolvers,
30
- ...ProcessResolvers,
31
- ]
40
+ ...ProcessThreadResolvers,
41
+ ...ProcessInstanceResolvers,
42
+ ...ProcessResolvers
43
+ ]
32
44
  }
@@ -7,7 +7,9 @@ export default {
7
7
  { tagname: 'process-main', page: 'process-main' },
8
8
  { tagname: 'process-list-page', page: 'process-list' },
9
9
  { tagname: 'process-instance-list-page', page: 'process-instance-list' },
10
- { tagname: 'process-thread-list-page', page: 'process-thread-list' }
10
+ { tagname: 'process-thread-list-page', page: 'process-thread-list' },
11
+ { tagname: 'event-list-page', page: 'event-list' },
12
+ { tagname: 'gateway-list-page', page: 'gateway-list' }
11
13
  ],
12
14
  bootstrap
13
15
  }
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assign = void 0;
4
- const typeorm_1 = require("typeorm");
5
- const auth_base_1 = require("@things-factory/auth-base");
6
- const process_instance_1 = require("../../service/process-instance/process-instance");
7
- const common_1 = require("../common");
8
- async function assign({ id, assignees, reason, dueAt }, context) {
9
- const { domain, user, tx } = context.state;
10
- const repository = tx.getRepository(process_instance_1.ProcessInstance);
11
- var processInstance = await repository.findOne({
12
- where: { domain: { id: domain.id }, id },
13
- relations: ['domain', 'process', 'assigneeRole', 'supervisoryRole', 'updater', 'creator', 'starter', 'terminator']
14
- });
15
- if (!processInstance) {
16
- throw new Error(context.t('error.process-instance not found', {
17
- processInstance: id
18
- }));
19
- }
20
- /*
21
- Prerequisites for a Task to Be Assigned.
22
- - The previous state of the task must not be Assigned.
23
- */
24
- if (processInstance.state !== process_instance_1.ProcessInstanceStatus.Issued &&
25
- processInstance.state !== process_instance_1.ProcessInstanceStatus.PendingAssignment) {
26
- throw new Error(context.t(`error.process-instance should not be assigned`, {
27
- id,
28
- actual: processInstance.state
29
- }));
30
- }
31
- if (dueAt) {
32
- processInstance.dueAt = dueAt;
33
- }
34
- const assignedUsers = await tx.getRepository(auth_base_1.User).findBy({
35
- email: (0, typeorm_1.In)(assignees)
36
- });
37
- await (0, common_1.createProcessThreadsForUsers)('assign', processInstance, assignedUsers, context);
38
- return await tx.getRepository(process_instance_1.ProcessInstance).findOneBy({ id: processInstance.id });
39
- }
40
- exports.assign = assign;
41
- //# sourceMappingURL=assign.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assign.js","sourceRoot":"","sources":["../../../server/controllers/process-instance/assign.ts"],"names":[],"mappings":";;;AAAA,qCAA4B;AAE5B,yDAAgD;AAEhD,sFAAwG;AACxG,sCAAwD;AAEjD,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,CAAC,KAAK,CAAA;IAE1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,kCAAe,CAAC,CAAA;IAEpD,IAAI,eAAe,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;QAC7C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;QACxC,SAAS,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC;KACnH,CAAC,CAAA;IAEF,IAAI,CAAC,eAAe,EAAE;QACpB,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,CAAC,CAAC,kCAAkC,EAAE;YAC5C,eAAe,EAAE,EAAE;SACpB,CAAC,CACH,CAAA;KACF;IAED;;;MAGE;IACF,IACE,eAAe,CAAC,KAAK,KAAK,wCAAqB,CAAC,MAAM;QACtD,eAAe,CAAC,KAAK,KAAK,wCAAqB,CAAC,iBAAiB,EACjE;QACA,MAAM,IAAI,KAAK,CACb,OAAO,CAAC,CAAC,CAAC,+CAA+C,EAAE;YACzD,EAAE;YACF,MAAM,EAAE,eAAe,CAAC,KAAK;SAC9B,CAAC,CACH,CAAA;KACF;IAED,IAAI,KAAK,EAAE;QACT,eAAe,CAAC,KAAK,GAAG,KAAK,CAAA;KAC9B;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,qCAA4B,EAAC,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAE,OAAO,CAAC,CAAA;IAErF,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,kCAAe,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,eAAe,CAAC,EAAE,EAAE,CAAC,CAAA;AACtF,CAAC;AAhDD,wBAgDC","sourcesContent":["import { In } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\n\nimport { ProcessInstance, ProcessInstanceStatus } from '../../service/process-instance/process-instance'\nimport { createProcessThreadsForUsers } 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<ProcessInstance> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(ProcessInstance)\n\n var processInstance = await repository.findOne({\n where: { domain: { id: domain.id }, id },\n relations: ['domain', 'process', 'assigneeRole', 'supervisoryRole', 'updater', 'creator', 'starter', 'terminator']\n })\n\n if (!processInstance) {\n throw new Error(\n context.t('error.process-instance not found', {\n processInstance: 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 processInstance.state !== ProcessInstanceStatus.Issued &&\n processInstance.state !== ProcessInstanceStatus.PendingAssignment\n ) {\n throw new Error(\n context.t(`error.process-instance should not be assigned`, {\n id,\n actual: processInstance.state\n })\n )\n }\n\n if (dueAt) {\n processInstance.dueAt = dueAt\n }\n\n const assignedUsers = await tx.getRepository(User).findBy({\n email: In(assignees)\n })\n\n await createProcessThreadsForUsers('assign', processInstance, assignedUsers, context)\n\n return await tx.getRepository(ProcessInstance).findOneBy({ id: processInstance.id })\n}\n"]}
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.draft = void 0;
4
- const process_instance_1 = require("../../service/process-instance/process-instance");
5
- const process_1 = require("../../service/process/process");
6
- const common_1 = require("../common");
7
- async function draft(processInstance, context) {
8
- const { domain, user, tx } = context.state;
9
- const { id, processId, input, dueAt } = processInstance;
10
- var repository = tx.getRepository(process_1.Process);
11
- var process = {};
12
- if (id) {
13
- var previousProcessInstance = await tx.getRepository(process_instance_1.ProcessInstance).findOne({
14
- where: { domain: { id: domain.id }, id },
15
- relations: ['process']
16
- });
17
- if (!previousProcessInstance) {
18
- throw new Error(context.t('error.processInstance not found', {
19
- processInstance: id
20
- }));
21
- }
22
- if (previousProcessInstance.state !== process_instance_1.ProcessInstanceStatus.Draft) {
23
- throw new Error(context.t('error.processInstance state should be draft', {
24
- processInstance: id,
25
- state: previousProcessInstance.state
26
- }));
27
- }
28
- process = previousProcessInstance.process;
29
- }
30
- else {
31
- processInstance.adhocType = 'standard';
32
- processInstance.refBy = processId;
33
- }
34
- if (processId) {
35
- process = await repository.findOne({
36
- where: { domain: { id: domain.id }, id: processId },
37
- relations: ['assigneeRole', 'supervisoryRole']
38
- });
39
- if (!process) {
40
- throw new Error(context.t('error.process not found', {
41
- process: processId
42
- }));
43
- }
44
- }
45
- if (!processInstance.assignees) {
46
- processInstance.assignees = process.assignees;
47
- }
48
- if (!processInstance.approvalLine) {
49
- processInstance.approvalLine = process.approvalLine;
50
- }
51
- if (!dueAt && process.standardTime) {
52
- processInstance.dueAt = new Date(Date.now() + process.standardTime * 1000);
53
- }
54
- if (processInstance.assignees) {
55
- processInstance.assignees = processInstance.assignees.map(assignee => {
56
- return {
57
- type: assignee.type,
58
- value: assignee.value
59
- };
60
- });
61
- }
62
- if (processInstance.approvalLine) {
63
- processInstance.approvalLine = processInstance.approvalLine.map(approval => {
64
- return {
65
- type: approval.type,
66
- value: approval.value
67
- };
68
- });
69
- }
70
- const processSearchKeys = (0, common_1.fillProcessSearchKeys)(process === null || process === void 0 ? void 0 : process.searchKeys, input);
71
- return await tx.getRepository(process_instance_1.ProcessInstance).save(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, previousProcessInstance), { processType: process.processType, uiType: process.uiType, uiSource: process.uiSource, viewType: process.viewType, viewSource: process.viewSource, assigneeRole: process.assigneeRole, supervisoryRole: process.supervisoryRole }), processInstance), { transaction: 'draft', process }), processSearchKeys), { state: process_instance_1.ProcessInstanceStatus.Draft, domain, creator: user, updater: user }));
72
- }
73
- exports.draft = draft;
74
- //# sourceMappingURL=draft.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"draft.js","sourceRoot":"","sources":["../../../server/controllers/process-instance/draft.ts"],"names":[],"mappings":";;;AAAA,sFAAwG;AAExG,2DAAuD;AACvD,sCAAiD;AAE1C,KAAK,UAAU,KAAK,CAAC,eAAqC,EAAE,OAAwB;IACzF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAC1C,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,eAAe,CAAA;IAEvD,IAAI,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,iBAAO,CAAC,CAAA;IAC1C,IAAI,OAAO,GAAG,EAAa,CAAA;IAE3B,IAAI,EAAE,EAAE;QACN,IAAI,uBAAuB,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,kCAAe,CAAC,CAAC,OAAO,CAAC;YAC5E,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;YACxC,SAA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AE,IAAI,IACb,CAAA;AACJ,CAAC;AApGD,sBAoGC","sourcesContent":["import { ProcessInstance, ProcessInstanceStatus } from '../../service/process-instance/process-instance'\nimport { ProcessInstanceDraft } from '../../service/process-instance/process-instance-type'\nimport { Process } from '../../service/process/process'\nimport { fillProcessSearchKeys } from '../common'\n\nexport async function draft(processInstance: ProcessInstanceDraft, context: ResolverContext): Promise<ProcessInstance> {\n const { domain, user, tx } = context.state\n const { id, processId, input, dueAt } = processInstance\n\n var repository = tx.getRepository(Process)\n var process = {} as Process\n\n if (id) {\n var previousProcessInstance = await tx.getRepository(ProcessInstance).findOne({\n where: { domain: { id: domain.id }, id },\n relations: ['process']\n })\n\n if (!previousProcessInstance) {\n throw new Error(\n context.t('error.processInstance not found', {\n processInstance: id\n })\n )\n }\n\n if (previousProcessInstance.state !== ProcessInstanceStatus.Draft) {\n throw new Error(\n context.t('error.processInstance state should be draft', {\n processInstance: id,\n state: previousProcessInstance.state\n })\n )\n }\n\n process = previousProcessInstance.process\n } else {\n processInstance.adhocType = 'standard'\n processInstance.refBy = processId\n }\n\n if (processId) {\n process = await repository.findOne({\n where: { domain: { id: domain.id }, id: processId },\n relations: ['assigneeRole', 'supervisoryRole']\n })\n\n if (!process) {\n throw new Error(\n context.t('error.process not found', {\n process: processId\n })\n )\n }\n }\n\n if (!processInstance.assignees) {\n processInstance.assignees = process.assignees\n }\n if (!processInstance.approvalLine) {\n processInstance.approvalLine = process.approvalLine\n }\n\n if (!dueAt && process.standardTime) {\n processInstance.dueAt = new Date(Date.now() + process.standardTime * 1000)\n }\n\n if (processInstance.assignees) {\n processInstance.assignees = processInstance.assignees.map(assignee => {\n return {\n type: assignee.type,\n value: assignee.value\n }\n })\n }\n\n if (processInstance.approvalLine) {\n processInstance.approvalLine = processInstance.approvalLine.map(approval => {\n return {\n type: approval.type,\n value: approval.value\n }\n })\n }\n\n const processSearchKeys = fillProcessSearchKeys(process?.searchKeys, input)\n\n return await tx.getRepository(ProcessInstance).save({\n ...previousProcessInstance,\n processType: process.processType,\n uiType: process.uiType,\n uiSource: process.uiSource,\n viewType: process.viewType,\n viewSource: process.viewSource,\n assigneeRole: process.assigneeRole,\n supervisoryRole: process.supervisoryRole,\n ...processInstance,\n transaction: 'draft',\n process,\n ...processSearchKeys,\n state: ProcessInstanceStatus.Draft,\n domain,\n creator: user,\n updater: user\n })\n}\n"]}