@things-factory/worklist-client 6.0.24
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/CHANGELOG.md +8 -0
- package/assets/images/gangsters-512x512.png +0 -0
- package/client/bootstrap.ts +1 -0
- package/client/index.ts +0 -0
- package/client/pages/work-center/work-center-importer.ts +97 -0
- package/client/pages/work-center/work-center-list-page.ts +332 -0
- package/client/pages/work-center/work-center-page.ts +95 -0
- package/client/route.ts +7 -0
- package/client/tsconfig.json +11 -0
- package/dist-client/bootstrap.d.ts +1 -0
- package/dist-client/bootstrap.js +2 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/index.d.ts +0 -0
- package/dist-client/index.js +2 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/pages/work-center/work-center-importer.d.ts +22 -0
- package/dist-client/pages/work-center/work-center-importer.js +100 -0
- package/dist-client/pages/work-center/work-center-importer.js.map +1 -0
- package/dist-client/pages/work-center/work-center-list-page.d.ts +62 -0
- package/dist-client/pages/work-center/work-center-list-page.js +317 -0
- package/dist-client/pages/work-center/work-center-list-page.js.map +1 -0
- package/dist-client/pages/work-center/work-center-page.d.ts +26 -0
- package/dist-client/pages/work-center/work-center-page.js +92 -0
- package/dist-client/pages/work-center/work-center-page.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +8 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-server/controllers/activity-registry.js +17 -0
- package/dist-server/controllers/activity-registry.js.map +1 -0
- package/dist-server/controllers/graphql-client.js +60 -0
- package/dist-server/controllers/graphql-client.js.map +1 -0
- package/dist-server/controllers/index.js +8 -0
- package/dist-server/controllers/index.js.map +1 -0
- package/dist-server/controllers/webhooks/decorators.js +17 -0
- package/dist-server/controllers/webhooks/decorators.js.map +1 -0
- package/dist-server/controllers/webhooks/index.js +48 -0
- package/dist-server/controllers/webhooks/index.js.map +1 -0
- package/dist-server/controllers/work-center/connect-work-center.js +17 -0
- package/dist-server/controllers/work-center/connect-work-center.js.map +1 -0
- package/dist-server/controllers/work-center/get-work-center.js +13 -0
- package/dist-server/controllers/work-center/get-work-center.js.map +1 -0
- package/dist-server/controllers/work-center/index.js +6 -0
- package/dist-server/controllers/work-center/index.js.map +1 -0
- package/dist-server/controllers/worklist-api/assign-activity-thread.js +6 -0
- package/dist-server/controllers/worklist-api/assign-activity-thread.js.map +1 -0
- package/dist-server/controllers/worklist-api/draft-activity-instance.js +6 -0
- package/dist-server/controllers/worklist-api/draft-activity-instance.js.map +1 -0
- package/dist-server/controllers/worklist-api/get-activity-list.js +6 -0
- package/dist-server/controllers/worklist-api/get-activity-list.js.map +1 -0
- package/dist-server/controllers/worklist-api/get-activity.js +6 -0
- package/dist-server/controllers/worklist-api/get-activity.js.map +1 -0
- package/dist-server/controllers/worklist-api/get-todo-list.js +6 -0
- package/dist-server/controllers/worklist-api/get-todo-list.js.map +1 -0
- package/dist-server/controllers/worklist-api/index.js +11 -0
- package/dist-server/controllers/worklist-api/index.js.map +1 -0
- package/dist-server/controllers/worklist-api/register-activity.js +6 -0
- package/dist-server/controllers/worklist-api/register-activity.js.map +1 -0
- package/dist-server/controllers/worklist-api/unregister-activity.js +6 -0
- package/dist-server/controllers/worklist-api/unregister-activity.js.map +1 -0
- package/dist-server/controllers/worklist-api/update-activity.js +6 -0
- package/dist-server/controllers/worklist-api/update-activity.js.map +1 -0
- package/dist-server/index.js +8 -0
- package/dist-server/index.js.map +1 -0
- package/dist-server/middlewares/index.js +8 -0
- package/dist-server/middlewares/index.js.map +1 -0
- package/dist-server/migrations/index.js +12 -0
- package/dist-server/migrations/index.js.map +1 -0
- package/dist-server/routes.js +42 -0
- package/dist-server/routes.js.map +1 -0
- package/dist-server/service/activity/activity-model-type.js +138 -0
- package/dist-server/service/activity/activity-model-type.js.map +1 -0
- package/dist-server/service/activity/activity-mutation.js +105 -0
- package/dist-server/service/activity/activity-mutation.js.map +1 -0
- package/dist-server/service/activity/activity-query.js +87 -0
- package/dist-server/service/activity/activity-query.js.map +1 -0
- package/dist-server/service/activity/activity-type.js +199 -0
- package/dist-server/service/activity/activity-type.js.map +1 -0
- package/dist-server/service/activity/activity.js +170 -0
- package/dist-server/service/activity/activity.js.map +1 -0
- package/dist-server/service/activity/index.js +9 -0
- package/dist-server/service/activity/index.js.map +1 -0
- package/dist-server/service/index.js +28 -0
- package/dist-server/service/index.js.map +1 -0
- package/dist-server/service/work-center/event-subscriber.js +21 -0
- package/dist-server/service/work-center/event-subscriber.js.map +1 -0
- package/dist-server/service/work-center/index.js +12 -0
- package/dist-server/service/work-center/index.js.map +1 -0
- package/dist-server/service/work-center/work-center-history.js +123 -0
- package/dist-server/service/work-center/work-center-history.js.map +1 -0
- package/dist-server/service/work-center/work-center-mutation.js +168 -0
- package/dist-server/service/work-center/work-center-mutation.js.map +1 -0
- package/dist-server/service/work-center/work-center-query.js +97 -0
- package/dist-server/service/work-center/work-center-query.js.map +1 -0
- package/dist-server/service/work-center/work-center-type.js +86 -0
- package/dist-server/service/work-center/work-center-type.js.map +1 -0
- package/dist-server/service/work-center/work-center.js +86 -0
- package/dist-server/service/work-center/work-center.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/helps/worklist-webhook/work-center.md +160 -0
- package/package.json +36 -0
- package/server/controllers/activity-registry.ts +17 -0
- package/server/controllers/graphql-client.ts +68 -0
- package/server/controllers/index.ts +4 -0
- package/server/controllers/webhooks/decorators.ts +18 -0
- package/server/controllers/webhooks/index.ts +30 -0
- package/server/controllers/work-center/connect-work-center.ts +15 -0
- package/server/controllers/work-center/get-work-center.ts +9 -0
- package/server/controllers/work-center/index.ts +2 -0
- package/server/controllers/worklist-api/assign-activity-thread.ts +3 -0
- package/server/controllers/worklist-api/draft-activity-instance.ts +3 -0
- package/server/controllers/worklist-api/get-activity-list.ts +3 -0
- package/server/controllers/worklist-api/get-activity.ts +3 -0
- package/server/controllers/worklist-api/get-todo-list.ts +4 -0
- package/server/controllers/worklist-api/index.ts +7 -0
- package/server/controllers/worklist-api/register-activity.ts +3 -0
- package/server/controllers/worklist-api/unregister-activity.ts +3 -0
- package/server/controllers/worklist-api/update-activity.ts +3 -0
- package/server/index.ts +5 -0
- package/server/middlewares/index.ts +3 -0
- package/server/migrations/index.ts +9 -0
- package/server/routes.ts +46 -0
- package/server/service/activity/activity-model-type.ts +106 -0
- package/server/service/activity/activity-mutation.ts +85 -0
- package/server/service/activity/activity-query.ts +61 -0
- package/server/service/activity/activity-type.ts +146 -0
- package/server/service/activity/activity.ts +135 -0
- package/server/service/activity/index.ts +6 -0
- package/server/service/index.ts +36 -0
- package/server/service/work-center/event-subscriber.ts +17 -0
- package/server/service/work-center/index.ts +9 -0
- package/server/service/work-center/work-center-history.ts +110 -0
- package/server/service/work-center/work-center-mutation.ts +198 -0
- package/server/service/work-center/work-center-query.ts +62 -0
- package/server/service/work-center/work-center-type.ts +61 -0
- package/server/service/work-center/work-center.ts +76 -0
- package/server/tsconfig.json +10 -0
- package/things-factory.config.js +11 -0
- package/translations/en.json +1 -0
- package/translations/ko.json +1 -0
- package/translations/ms.json +1 -0
- package/translations/zh.json +1 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# WorkCenter
|
|
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
|
+

|
|
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
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@things-factory/worklist-client",
|
|
3
|
+
"version": "6.0.24",
|
|
4
|
+
"main": "dist-server/index.js",
|
|
5
|
+
"browser": "dist-client/index.js",
|
|
6
|
+
"things-factory": true,
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "heartyoh <heartyoh@hatiolab.com>",
|
|
9
|
+
"description": "webhook endpoint for worklist service",
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public",
|
|
12
|
+
"@things-factory:registry": "https://registry.npmjs.org"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/hatiolab/things-factory.git",
|
|
17
|
+
"directory": "packages/worklist-client"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "npm run build:server && npm run build:client",
|
|
21
|
+
"build:client": "npx tsc --p ./client/tsconfig.json",
|
|
22
|
+
"build:server": "npx tsc --p ./server/tsconfig.json",
|
|
23
|
+
"clean:client": "npx rimraf dist-client",
|
|
24
|
+
"clean:server": "npx rimraf dist-server",
|
|
25
|
+
"clean": "npm run clean:server && npm run clean:client",
|
|
26
|
+
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@operato/graphql": "^1.0.0",
|
|
30
|
+
"@operato/shell": "^1.0.0",
|
|
31
|
+
"@things-factory/auth-base": "^6.0.24",
|
|
32
|
+
"@things-factory/oauth2-client": "^6.0.24",
|
|
33
|
+
"@things-factory/shell": "^6.0.24"
|
|
34
|
+
},
|
|
35
|
+
"gitHead": "27c1a4c3bcf4f293e7e676caa1f2daa3bb6ded11"
|
|
36
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Activity } from '../service/activity/activity'
|
|
2
|
+
|
|
3
|
+
export class ActivityRegistry {
|
|
4
|
+
static registry = new Map<string, Activity>()
|
|
5
|
+
|
|
6
|
+
static set(id: string, activity: Activity) {
|
|
7
|
+
ActivityRegistry.registry.set(id, activity)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static get(id: string) {
|
|
11
|
+
return ActivityRegistry.get(id)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static list(): Activity[] {
|
|
15
|
+
return ActivityRegistry.list()
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import 'cross-fetch/polyfill'
|
|
2
|
+
|
|
3
|
+
import { ApolloClient, ApolloLink, from, HttpLink, InMemoryCache } from '@apollo/client/core'
|
|
4
|
+
import { onError } from '@apollo/client/link/error'
|
|
5
|
+
import { Oauth2Client } from '@things-factory/oauth2-client'
|
|
6
|
+
import { getRepository } from '@things-factory/shell'
|
|
7
|
+
import { logger } from '@things-factory/utils'
|
|
8
|
+
import { config } from '@things-factory/env'
|
|
9
|
+
|
|
10
|
+
const defaultOptions: any = {
|
|
11
|
+
watchQuery: {
|
|
12
|
+
fetchPolicy: 'no-cache',
|
|
13
|
+
errorPolicy: 'ignore'
|
|
14
|
+
},
|
|
15
|
+
query: {
|
|
16
|
+
fetchPolicy: 'no-cache', //'network-only'
|
|
17
|
+
errorPolicy: 'all'
|
|
18
|
+
},
|
|
19
|
+
mutate: {
|
|
20
|
+
errorPolicy: 'all'
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const cache = new InMemoryCache({
|
|
25
|
+
addTypename: false
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const uri = config.get('worklist/service/uri', 'https://gangsters.hatiolab.com')
|
|
29
|
+
|
|
30
|
+
export async function connect() {
|
|
31
|
+
var ERROR_HANDLER: any = ({ graphQLErrors, networkError }) => {
|
|
32
|
+
if (graphQLErrors)
|
|
33
|
+
graphQLErrors.map(({ message, locations, path }) => {
|
|
34
|
+
logger.error(`[GraphQL error] Message: ${message}, Location: ${locations}, Path: ${path}`)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
if (networkError) {
|
|
38
|
+
logger.error(`[Network error - ${networkError.statusCode}] ${networkError}`)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const oauth2Client: Oauth2Client = await getRepository(Oauth2Client).findOneBy({ name: 'WORKLIST' })
|
|
43
|
+
|
|
44
|
+
const authMiddleware = new ApolloLink((operation, forward) => {
|
|
45
|
+
// add the authorization to the headers
|
|
46
|
+
operation.setContext(({ headers = {} }) => ({
|
|
47
|
+
headers: {
|
|
48
|
+
...headers,
|
|
49
|
+
...oauth2Client.getAuthHeaders()
|
|
50
|
+
}
|
|
51
|
+
}))
|
|
52
|
+
|
|
53
|
+
return forward(operation)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
return new ApolloClient({
|
|
57
|
+
defaultOptions,
|
|
58
|
+
cache,
|
|
59
|
+
link: from([
|
|
60
|
+
authMiddleware,
|
|
61
|
+
onError(ERROR_HANDLER),
|
|
62
|
+
new HttpLink({
|
|
63
|
+
uri,
|
|
64
|
+
credentials: 'include'
|
|
65
|
+
})
|
|
66
|
+
])
|
|
67
|
+
})
|
|
68
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { WorkCenter } from '../../service/work-center/work-center'
|
|
2
|
+
|
|
3
|
+
export const webhook = (target: Object, property: string, descriptor: TypedPropertyDescriptor<any>): any => {
|
|
4
|
+
const method = descriptor.value
|
|
5
|
+
|
|
6
|
+
descriptor.value = async function (request) {
|
|
7
|
+
const WorklistWebhook = this
|
|
8
|
+
|
|
9
|
+
var m = WorklistWebhook.handlers[method.name]
|
|
10
|
+
if (!m) {
|
|
11
|
+
throw Error(`Worklist Webhook doesn't have the handler ${method.name}`)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return await m.apply(this, [request])
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return descriptor
|
|
18
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { getRepository } from '@things-factory/shell'
|
|
2
|
+
|
|
3
|
+
import { WorkCenter } from '../../service/work-center/work-center'
|
|
4
|
+
import { webhook } from './decorators'
|
|
5
|
+
|
|
6
|
+
export class WorklistWebhook {
|
|
7
|
+
static handlers = {}
|
|
8
|
+
|
|
9
|
+
static registerHandlers(handlers) {
|
|
10
|
+
WorklistWebhook.handlers = handlers
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static async getWorkCenter(id: string) {
|
|
14
|
+
return await getRepository(WorkCenter).findOne({
|
|
15
|
+
where: { workCenterId: id }
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@webhook
|
|
20
|
+
static echo(center, req): any {}
|
|
21
|
+
|
|
22
|
+
@webhook
|
|
23
|
+
static onActivityApprovalUpdated(center, req): any {}
|
|
24
|
+
|
|
25
|
+
@webhook
|
|
26
|
+
static onActivityThreadUpdated(center, req): any {}
|
|
27
|
+
|
|
28
|
+
@webhook
|
|
29
|
+
static onActivityInstanceUpdated(center, req): any {}
|
|
30
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Domain, getRepository } from '@things-factory/shell'
|
|
2
|
+
import { Oauth2Client } from '@things-factory/oauth2-client'
|
|
3
|
+
|
|
4
|
+
export async function connectWorkCenter(domain: Domain) {
|
|
5
|
+
const client = await getRepository(Oauth2Client).findOneBy({
|
|
6
|
+
domain: { id: domain.id },
|
|
7
|
+
authUrl: 'https://gangsters.hatiolab.com/oauth/authorize'
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
if (client) {
|
|
11
|
+
return client
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// TODO else..
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Domain, getRepository } from '@things-factory/shell'
|
|
2
|
+
import { Oauth2Client } from '@things-factory/oauth2-client'
|
|
3
|
+
|
|
4
|
+
export async function getWorkCenter(domain: Domain): Promise<Oauth2Client> {
|
|
5
|
+
return await getRepository(Oauth2Client).findOneBy({
|
|
6
|
+
domain: { id: domain.id },
|
|
7
|
+
authUrl: 'https://gangsters.hatiolab.com/oauth/authorize'
|
|
8
|
+
})
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './assign-activity-thread'
|
|
2
|
+
export * from './draft-activity-instance'
|
|
3
|
+
export * from './get-activity-list'
|
|
4
|
+
export * from './get-todo-list'
|
|
5
|
+
export * from './register-activity'
|
|
6
|
+
export * from './unregister-activity'
|
|
7
|
+
export * from './update-activity'
|
package/server/index.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const glob = require('glob')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
|
|
4
|
+
export var migrations = []
|
|
5
|
+
|
|
6
|
+
glob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function(file) {
|
|
7
|
+
if (file.indexOf('index.js') !== -1) return
|
|
8
|
+
migrations = migrations.concat(Object.values(require(path.resolve(file))) || [])
|
|
9
|
+
})
|
package/server/routes.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { WorklistWebhook } from './controllers/webhooks'
|
|
2
|
+
|
|
3
|
+
process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRouter) => {
|
|
4
|
+
globalPublicRouter.post('/worklist-client', async (context, next) => {
|
|
5
|
+
var { req } = context
|
|
6
|
+
var { tag, domain, data } = req
|
|
7
|
+
|
|
8
|
+
const center = WorklistWebhook.getWorkCenter(domain.id)
|
|
9
|
+
|
|
10
|
+
switch (tag) {
|
|
11
|
+
case 'activity-approval':
|
|
12
|
+
WorklistWebhook.onActivityApprovalUpdated(center, data)
|
|
13
|
+
break
|
|
14
|
+
case 'activity-thread':
|
|
15
|
+
WorklistWebhook.onActivityThreadUpdated(center, data)
|
|
16
|
+
break
|
|
17
|
+
case 'activity-instance':
|
|
18
|
+
WorklistWebhook.onActivityInstanceUpdated(center, data)
|
|
19
|
+
break
|
|
20
|
+
default:
|
|
21
|
+
WorklistWebhook.echo(center, data)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
context.type = 'text/plain'
|
|
25
|
+
context.status = 200
|
|
26
|
+
context.body = 'OK'
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
process.on('bootstrap-module-global-private-route' as any, (app, globalPrivateRouter) => {
|
|
31
|
+
/*
|
|
32
|
+
* can add global private routes to application (auth required, tenancy not required)
|
|
33
|
+
*/
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
process.on('bootstrap-module-domain-public-route' as any, (app, domainPublicRouter) => {
|
|
37
|
+
/*
|
|
38
|
+
* can add domain public routes to application (auth not required, tenancy required)
|
|
39
|
+
*/
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
process.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {
|
|
43
|
+
/*
|
|
44
|
+
* can add domain private routes to application (auth required, tenancy required)
|
|
45
|
+
*/
|
|
46
|
+
})
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Field, InputType, Int, ObjectType, registerEnumType } from 'type-graphql'
|
|
2
|
+
|
|
3
|
+
import { ScalarObject } from '@things-factory/shell'
|
|
4
|
+
|
|
5
|
+
export enum ActivityModelItemInoutType {
|
|
6
|
+
in = 'in',
|
|
7
|
+
out = 'out',
|
|
8
|
+
inout = 'inout'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
registerEnumType(ActivityModelItemInoutType, {
|
|
12
|
+
name: 'ActivityModelItemInoutType',
|
|
13
|
+
description: 'inout enumeration of a activity-model-item'
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
export enum ActivityModelItemType {
|
|
17
|
+
number = 'number',
|
|
18
|
+
text = 'text',
|
|
19
|
+
textarea = 'textarea',
|
|
20
|
+
boolean = 'boolean',
|
|
21
|
+
select = 'select',
|
|
22
|
+
file = 'file'
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
registerEnumType(ActivityModelItemType, {
|
|
26
|
+
name: 'ActivityModelItemType',
|
|
27
|
+
description: 'data type enumeration of a activity-model-item'
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
@ObjectType({ description: 'Entity for ActivityModelItem' })
|
|
31
|
+
export class ActivityModelItem {
|
|
32
|
+
@Field()
|
|
33
|
+
name: string
|
|
34
|
+
|
|
35
|
+
@Field({ nullable: true })
|
|
36
|
+
description?: string
|
|
37
|
+
|
|
38
|
+
@Field({ nullable: true })
|
|
39
|
+
tag?: string
|
|
40
|
+
|
|
41
|
+
@Field({ nullable: true })
|
|
42
|
+
active?: boolean
|
|
43
|
+
|
|
44
|
+
@Field({ nullable: true })
|
|
45
|
+
hidden?: boolean
|
|
46
|
+
|
|
47
|
+
@Field({ nullable: true })
|
|
48
|
+
mandatory?: boolean
|
|
49
|
+
|
|
50
|
+
@Field(type => ActivityModelItemInoutType, { nullable: true })
|
|
51
|
+
inout?: ActivityModelItemInoutType
|
|
52
|
+
|
|
53
|
+
@Field({ nullable: true })
|
|
54
|
+
type?: ActivityModelItemType
|
|
55
|
+
|
|
56
|
+
@Field(type => ScalarObject, { nullable: true })
|
|
57
|
+
options?: { [option: string]: any }
|
|
58
|
+
|
|
59
|
+
@Field({ nullable: true })
|
|
60
|
+
unit?: string
|
|
61
|
+
|
|
62
|
+
@Field(type => [Int], { nullable: true })
|
|
63
|
+
quantifier: number[]
|
|
64
|
+
|
|
65
|
+
@Field(type => ScalarObject, { nullable: true })
|
|
66
|
+
spec?: { [key: string]: any }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@InputType()
|
|
70
|
+
export class ActivityModelItemPatch {
|
|
71
|
+
@Field({ nullable: true })
|
|
72
|
+
name?: string
|
|
73
|
+
|
|
74
|
+
@Field({ nullable: true })
|
|
75
|
+
description?: string
|
|
76
|
+
|
|
77
|
+
@Field({ nullable: true })
|
|
78
|
+
tag?: string
|
|
79
|
+
|
|
80
|
+
@Field(type => ActivityModelItemInoutType, { nullable: true })
|
|
81
|
+
inout?: ActivityModelItemInoutType
|
|
82
|
+
|
|
83
|
+
@Field(type => ActivityModelItemType, { nullable: true })
|
|
84
|
+
type?: ActivityModelItemType
|
|
85
|
+
|
|
86
|
+
@Field(type => ScalarObject, { nullable: true })
|
|
87
|
+
options?: { [option: string]: any }
|
|
88
|
+
|
|
89
|
+
@Field({ nullable: true })
|
|
90
|
+
unit?: string
|
|
91
|
+
|
|
92
|
+
@Field(type => [Int], { nullable: true })
|
|
93
|
+
quantifier: number[]
|
|
94
|
+
|
|
95
|
+
@Field({ nullable: true })
|
|
96
|
+
active?: boolean
|
|
97
|
+
|
|
98
|
+
@Field({ nullable: true })
|
|
99
|
+
mandatory?: boolean
|
|
100
|
+
|
|
101
|
+
@Field({ nullable: true })
|
|
102
|
+
hidden?: boolean
|
|
103
|
+
|
|
104
|
+
@Field(type => ScalarObject, { nullable: true })
|
|
105
|
+
spec?: { [key: string]: any }
|
|
106
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'
|
|
2
|
+
|
|
3
|
+
import { Activity } from './activity'
|
|
4
|
+
import { ActivityPatch, NewActivity } from './activity-type'
|
|
5
|
+
|
|
6
|
+
@Resolver(Activity)
|
|
7
|
+
export class ActivityMutation {
|
|
8
|
+
@Directive('@transaction')
|
|
9
|
+
@Mutation(returns => Activity, { description: 'To create new Activity' })
|
|
10
|
+
async createActivity(@Arg('activity') activity: NewActivity, @Ctx() context: ResolverContext): Promise<Activity> {
|
|
11
|
+
const { domain, user, tx } = context.state
|
|
12
|
+
|
|
13
|
+
// WorkCenter를 찾는다.
|
|
14
|
+
// WorkCenter에 graphql createActivity를 호출한다.
|
|
15
|
+
return
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Directive('@transaction')
|
|
19
|
+
@Mutation(returns => Activity, { description: 'To modify Activity information' })
|
|
20
|
+
async updateActivity(
|
|
21
|
+
@Arg('id') id: string,
|
|
22
|
+
@Arg('patch') patch: ActivityPatch,
|
|
23
|
+
@Ctx() context: ResolverContext
|
|
24
|
+
): Promise<Activity> {
|
|
25
|
+
const { domain, user, tx } = context.state
|
|
26
|
+
|
|
27
|
+
// workcenter의 토큰을 가져온다.
|
|
28
|
+
// remote graphql의 activity query를 호출한다.
|
|
29
|
+
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@Directive('@transaction')
|
|
34
|
+
@Mutation(returns => [Activity], { description: "To modify multiple Activities' information" })
|
|
35
|
+
async updateMultipleActivity(
|
|
36
|
+
@Arg('patches', type => [ActivityPatch]) patches: ActivityPatch[],
|
|
37
|
+
@Ctx() context: ResolverContext
|
|
38
|
+
): Promise<Activity[]> {
|
|
39
|
+
const { domain, user, tx } = context.state
|
|
40
|
+
|
|
41
|
+
// workcenter의 토큰을 가져온다.
|
|
42
|
+
// remote graphql의 activity query를 호출한다.
|
|
43
|
+
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Directive('@transaction')
|
|
48
|
+
@Mutation(returns => Boolean, { description: 'To delete Activity' })
|
|
49
|
+
async deleteActivity(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
50
|
+
const { domain, tx } = context.state
|
|
51
|
+
|
|
52
|
+
// workcenter의 토큰을 가져온다.
|
|
53
|
+
// remote graphql의 activity query를 호출한다.
|
|
54
|
+
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@Directive('@transaction')
|
|
59
|
+
@Mutation(returns => Boolean, { description: 'To delete multiple Activities' })
|
|
60
|
+
async deleteActivities(
|
|
61
|
+
@Arg('ids', type => [String]) ids: string[],
|
|
62
|
+
@Ctx() context: ResolverContext
|
|
63
|
+
): Promise<boolean> {
|
|
64
|
+
const { domain, tx } = context.state
|
|
65
|
+
|
|
66
|
+
// workcenter의 토큰을 가져온다.
|
|
67
|
+
// remote graphql의 activity query를 호출한다.
|
|
68
|
+
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@Directive('@transaction')
|
|
73
|
+
@Mutation(returns => Boolean, { description: 'To import multiple Activities' })
|
|
74
|
+
async importActivities(
|
|
75
|
+
@Arg('activities', type => [ActivityPatch]) activities: ActivityPatch[],
|
|
76
|
+
@Ctx() context: ResolverContext
|
|
77
|
+
): Promise<boolean> {
|
|
78
|
+
const { domain, tx } = context.state
|
|
79
|
+
|
|
80
|
+
// workcenter의 토큰을 가져온다.
|
|
81
|
+
// remote graphql의 activity query를 호출한다.
|
|
82
|
+
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
}
|