@dssp/supervision 0.0.2

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 (174) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/assets/images/hatiolab-logo.png +0 -0
  3. package/client/actions/main.ts +1 -0
  4. package/client/bootstrap.ts +8 -0
  5. package/client/index.ts +1 -0
  6. package/client/pages/action-plan/action-plan-importer.ts +96 -0
  7. package/client/pages/action-plan/action-plan-list-page.ts +355 -0
  8. package/client/pages/check-item/check-item-importer.ts +96 -0
  9. package/client/pages/check-item/check-item-list-page.ts +355 -0
  10. package/client/pages/issue/issue-importer.ts +96 -0
  11. package/client/pages/issue/issue-list-page.ts +355 -0
  12. package/client/pages/main.ts +25 -0
  13. package/client/pages/project-report/project-report-importer.ts +96 -0
  14. package/client/pages/project-report/project-report-list-page.ts +355 -0
  15. package/client/pages/supervisor/supervisor-importer.ts +96 -0
  16. package/client/pages/supervisor/supervisor-list-page.ts +355 -0
  17. package/client/reducers/main.ts +17 -0
  18. package/client/route.ts +27 -0
  19. package/client/tsconfig.json +11 -0
  20. package/dist-client/actions/main.d.ts +1 -0
  21. package/dist-client/actions/main.js +2 -0
  22. package/dist-client/actions/main.js.map +1 -0
  23. package/dist-client/bootstrap.d.ts +1 -0
  24. package/dist-client/bootstrap.js +8 -0
  25. package/dist-client/bootstrap.js.map +1 -0
  26. package/dist-client/index.d.ts +1 -0
  27. package/dist-client/index.js +2 -0
  28. package/dist-client/index.js.map +1 -0
  29. package/dist-client/pages/action-plan/action-plan-importer.d.ts +9 -0
  30. package/dist-client/pages/action-plan/action-plan-importer.js +100 -0
  31. package/dist-client/pages/action-plan/action-plan-importer.js.map +1 -0
  32. package/dist-client/pages/action-plan/action-plan-list-page.d.ts +62 -0
  33. package/dist-client/pages/action-plan/action-plan-list-page.js +331 -0
  34. package/dist-client/pages/action-plan/action-plan-list-page.js.map +1 -0
  35. package/dist-client/pages/check-item/check-item-importer.d.ts +9 -0
  36. package/dist-client/pages/check-item/check-item-importer.js +100 -0
  37. package/dist-client/pages/check-item/check-item-importer.js.map +1 -0
  38. package/dist-client/pages/check-item/check-item-list-page.d.ts +62 -0
  39. package/dist-client/pages/check-item/check-item-list-page.js +331 -0
  40. package/dist-client/pages/check-item/check-item-list-page.js.map +1 -0
  41. package/dist-client/pages/issue/issue-importer.d.ts +9 -0
  42. package/dist-client/pages/issue/issue-importer.js +100 -0
  43. package/dist-client/pages/issue/issue-importer.js.map +1 -0
  44. package/dist-client/pages/issue/issue-list-page.d.ts +62 -0
  45. package/dist-client/pages/issue/issue-list-page.js +331 -0
  46. package/dist-client/pages/issue/issue-list-page.js.map +1 -0
  47. package/dist-client/pages/main.d.ts +1 -0
  48. package/dist-client/pages/main.js +27 -0
  49. package/dist-client/pages/main.js.map +1 -0
  50. package/dist-client/pages/project-report/project-report-importer.d.ts +9 -0
  51. package/dist-client/pages/project-report/project-report-importer.js +100 -0
  52. package/dist-client/pages/project-report/project-report-importer.js.map +1 -0
  53. package/dist-client/pages/project-report/project-report-list-page.d.ts +62 -0
  54. package/dist-client/pages/project-report/project-report-list-page.js +331 -0
  55. package/dist-client/pages/project-report/project-report-list-page.js.map +1 -0
  56. package/dist-client/pages/supervisor/supervisor-importer.d.ts +9 -0
  57. package/dist-client/pages/supervisor/supervisor-importer.js +100 -0
  58. package/dist-client/pages/supervisor/supervisor-importer.js.map +1 -0
  59. package/dist-client/pages/supervisor/supervisor-list-page.d.ts +62 -0
  60. package/dist-client/pages/supervisor/supervisor-list-page.js +331 -0
  61. package/dist-client/pages/supervisor/supervisor-list-page.js.map +1 -0
  62. package/dist-client/reducers/main.d.ts +6 -0
  63. package/dist-client/reducers/main.js +14 -0
  64. package/dist-client/reducers/main.js.map +1 -0
  65. package/dist-client/route.d.ts +1 -0
  66. package/dist-client/route.js +23 -0
  67. package/dist-client/route.js.map +1 -0
  68. package/dist-client/tsconfig.tsbuildinfo +1 -0
  69. package/dist-server/controllers/index.js +1 -0
  70. package/dist-server/controllers/index.js.map +1 -0
  71. package/dist-server/index.js +7 -0
  72. package/dist-server/index.js.map +1 -0
  73. package/dist-server/middlewares/index.js +8 -0
  74. package/dist-server/middlewares/index.js.map +1 -0
  75. package/dist-server/migrations/index.js +12 -0
  76. package/dist-server/migrations/index.js.map +1 -0
  77. package/dist-server/routes.js +25 -0
  78. package/dist-server/routes.js.map +1 -0
  79. package/dist-server/service/action-plan/action-plan-mutation.js +168 -0
  80. package/dist-server/service/action-plan/action-plan-mutation.js.map +1 -0
  81. package/dist-server/service/action-plan/action-plan-query.js +97 -0
  82. package/dist-server/service/action-plan/action-plan-query.js.map +1 -0
  83. package/dist-server/service/action-plan/action-plan-type.js +86 -0
  84. package/dist-server/service/action-plan/action-plan-type.js.map +1 -0
  85. package/dist-server/service/action-plan/action-plan.js +116 -0
  86. package/dist-server/service/action-plan/action-plan.js.map +1 -0
  87. package/dist-server/service/action-plan/index.js +10 -0
  88. package/dist-server/service/action-plan/index.js.map +1 -0
  89. package/dist-server/service/check-item/check-item-mutation.js +168 -0
  90. package/dist-server/service/check-item/check-item-mutation.js.map +1 -0
  91. package/dist-server/service/check-item/check-item-query.js +97 -0
  92. package/dist-server/service/check-item/check-item-query.js.map +1 -0
  93. package/dist-server/service/check-item/check-item-type.js +86 -0
  94. package/dist-server/service/check-item/check-item-type.js.map +1 -0
  95. package/dist-server/service/check-item/check-item.js +117 -0
  96. package/dist-server/service/check-item/check-item.js.map +1 -0
  97. package/dist-server/service/check-item/index.js +10 -0
  98. package/dist-server/service/check-item/index.js.map +1 -0
  99. package/dist-server/service/index.js +43 -0
  100. package/dist-server/service/index.js.map +1 -0
  101. package/dist-server/service/issue/index.js +10 -0
  102. package/dist-server/service/issue/index.js.map +1 -0
  103. package/dist-server/service/issue/issue-mutation.js +168 -0
  104. package/dist-server/service/issue/issue-mutation.js.map +1 -0
  105. package/dist-server/service/issue/issue-query.js +97 -0
  106. package/dist-server/service/issue/issue-query.js.map +1 -0
  107. package/dist-server/service/issue/issue-type.js +86 -0
  108. package/dist-server/service/issue/issue-type.js.map +1 -0
  109. package/dist-server/service/issue/issue.js +117 -0
  110. package/dist-server/service/issue/issue.js.map +1 -0
  111. package/dist-server/service/project-report/index.js +10 -0
  112. package/dist-server/service/project-report/index.js.map +1 -0
  113. package/dist-server/service/project-report/project-report-mutation.js +168 -0
  114. package/dist-server/service/project-report/project-report-mutation.js.map +1 -0
  115. package/dist-server/service/project-report/project-report-query.js +97 -0
  116. package/dist-server/service/project-report/project-report-query.js.map +1 -0
  117. package/dist-server/service/project-report/project-report-type.js +86 -0
  118. package/dist-server/service/project-report/project-report-type.js.map +1 -0
  119. package/dist-server/service/project-report/project-report.js +128 -0
  120. package/dist-server/service/project-report/project-report.js.map +1 -0
  121. package/dist-server/service/supervisor/index.js +10 -0
  122. package/dist-server/service/supervisor/index.js.map +1 -0
  123. package/dist-server/service/supervisor/supervisor-mutation.js +168 -0
  124. package/dist-server/service/supervisor/supervisor-mutation.js.map +1 -0
  125. package/dist-server/service/supervisor/supervisor-query.js +97 -0
  126. package/dist-server/service/supervisor/supervisor-query.js.map +1 -0
  127. package/dist-server/service/supervisor/supervisor-type.js +86 -0
  128. package/dist-server/service/supervisor/supervisor-type.js.map +1 -0
  129. package/dist-server/service/supervisor/supervisor.js +127 -0
  130. package/dist-server/service/supervisor/supervisor.js.map +1 -0
  131. package/dist-server/tsconfig.tsbuildinfo +1 -0
  132. package/helps/supervision/action-plan.md +160 -0
  133. package/helps/supervision/check-item.md +160 -0
  134. package/helps/supervision/issue.md +160 -0
  135. package/helps/supervision/project-report.md +160 -0
  136. package/helps/supervision/supervisor.md +160 -0
  137. package/package.json +37 -0
  138. package/server/controllers/index.ts +0 -0
  139. package/server/index.ts +4 -0
  140. package/server/middlewares/index.ts +3 -0
  141. package/server/migrations/index.ts +9 -0
  142. package/server/routes.ts +28 -0
  143. package/server/service/action-plan/action-plan-mutation.ts +198 -0
  144. package/server/service/action-plan/action-plan-query.ts +62 -0
  145. package/server/service/action-plan/action-plan-type.ts +61 -0
  146. package/server/service/action-plan/action-plan.ts +103 -0
  147. package/server/service/action-plan/index.ts +7 -0
  148. package/server/service/check-item/check-item-mutation.ts +198 -0
  149. package/server/service/check-item/check-item-query.ts +62 -0
  150. package/server/service/check-item/check-item-type.ts +61 -0
  151. package/server/service/check-item/check-item.ts +111 -0
  152. package/server/service/check-item/index.ts +7 -0
  153. package/server/service/index.ts +42 -0
  154. package/server/service/issue/index.ts +7 -0
  155. package/server/service/issue/issue-mutation.ts +198 -0
  156. package/server/service/issue/issue-query.ts +62 -0
  157. package/server/service/issue/issue-type.ts +61 -0
  158. package/server/service/issue/issue.ts +105 -0
  159. package/server/service/project-report/index.ts +7 -0
  160. package/server/service/project-report/project-report-mutation.ts +198 -0
  161. package/server/service/project-report/project-report-query.ts +62 -0
  162. package/server/service/project-report/project-report-type.ts +61 -0
  163. package/server/service/project-report/project-report.ts +113 -0
  164. package/server/service/supervisor/index.ts +7 -0
  165. package/server/service/supervisor/supervisor-mutation.ts +198 -0
  166. package/server/service/supervisor/supervisor-query.ts +62 -0
  167. package/server/service/supervisor/supervisor-type.ts +61 -0
  168. package/server/service/supervisor/supervisor.ts +113 -0
  169. package/server/tsconfig.json +10 -0
  170. package/things-factory.config.js +15 -0
  171. package/translations/en.json +1 -0
  172. package/translations/ko.json +1 -0
  173. package/translations/ms.json +1 -0
  174. package/translations/zh.json +1 -0
@@ -0,0 +1,160 @@
1
+ # Supervisor
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 ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@dssp/supervision",
3
+ "version": "0.0.2",
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": "Module Providing Supervisory Functions",
10
+ "publishConfig": {
11
+ "access": "public",
12
+ "@dssp:registry": "https://registry.npmjs.org"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/hatiolab/dssp-m.git",
17
+ "directory": "packages/supervision"
18
+ },
19
+ "scripts": {
20
+ "build": "npm run build:server && npm run build:client",
21
+ "copy:files": "copyfiles -e \"./client/**/*.{ts,js,json}\" -u 1 \"./client/**/*\" dist-client",
22
+ "build:client": "npm run copy:files && npx tsc --p ./client/tsconfig.json",
23
+ "build:server": "npx tsc --p ./server/tsconfig.json",
24
+ "clean:client": "npx rimraf dist-client",
25
+ "clean:server": "npx rimraf dist-server",
26
+ "clean": "npm run clean:server && npm run clean:client",
27
+ "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
28
+ },
29
+ "dependencies": {
30
+ "@dssp/project": "^0.0.2",
31
+ "@operato/graphql": "^7.0.0",
32
+ "@operato/shell": "^7.0.0",
33
+ "@things-factory/auth-base": "^7.0.0",
34
+ "@things-factory/shell": "^7.0.0"
35
+ },
36
+ "gitHead": "d2d9c69dd4dc2e4098becc405c3641dc440766b7"
37
+ }
File without changes
@@ -0,0 +1,4 @@
1
+ export * from './migrations'
2
+ export * from './middlewares'
3
+
4
+ import './routes'
@@ -0,0 +1,3 @@
1
+ export function initMiddlewares(app) {
2
+ /* can add middlewares into app */
3
+ }
@@ -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
+ })
@@ -0,0 +1,28 @@
1
+ // const debug = require('debug')('dssp:supervision:routes')
2
+
3
+ process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRouter) => {
4
+ /*
5
+ * can add global public routes to application (auth not required, tenancy not required)
6
+ *
7
+ * ex) routes.get('/path', async(context, next) => {})
8
+ * ex) routes.post('/path', async(context, next) => {})
9
+ */
10
+ })
11
+
12
+ process.on('bootstrap-module-global-private-route' as any, (app, globalPrivateRouter) => {
13
+ /*
14
+ * can add global private routes to application (auth required, tenancy not required)
15
+ */
16
+ })
17
+
18
+ process.on('bootstrap-module-domain-public-route' as any, (app, domainPublicRouter) => {
19
+ /*
20
+ * can add domain public routes to application (auth not required, tenancy required)
21
+ */
22
+ })
23
+
24
+ process.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {
25
+ /*
26
+ * can add domain private routes to application (auth required, tenancy required)
27
+ */
28
+ })
@@ -0,0 +1,198 @@
1
+ import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
2
+ import { In } from 'typeorm'
3
+
4
+ import { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'
5
+
6
+ import { ActionPlan } from './action-plan'
7
+ import { NewActionPlan, ActionPlanPatch } from './action-plan-type'
8
+
9
+ @Resolver(ActionPlan)
10
+ export class ActionPlanMutation {
11
+ @Directive('@transaction')
12
+ @Mutation(returns => ActionPlan, { description: 'To create new ActionPlan' })
13
+ async createActionPlan(@Arg('actionPlan') actionPlan: NewActionPlan, @Ctx() context: ResolverContext): Promise<ActionPlan> {
14
+ const { domain, user, tx } = context.state
15
+
16
+ const result = await tx.getRepository(ActionPlan).save({
17
+ ...actionPlan,
18
+ domain,
19
+ creator: user,
20
+ updater: user
21
+ })
22
+
23
+ if (actionPlan.thumbnail) {
24
+ await createAttachment(
25
+ null,
26
+ {
27
+ attachment: {
28
+ file: actionPlan.thumbnail,
29
+ refType: ActionPlan.name,
30
+ refBy: result.id
31
+ }
32
+ },
33
+ context
34
+ )
35
+ }
36
+
37
+ return result
38
+ }
39
+
40
+ @Directive('@transaction')
41
+ @Mutation(returns => ActionPlan, { description: 'To modify ActionPlan information' })
42
+ async updateActionPlan(
43
+ @Arg('id') id: string,
44
+ @Arg('patch') patch: ActionPlanPatch,
45
+ @Ctx() context: ResolverContext
46
+ ): Promise<ActionPlan> {
47
+ const { domain, user, tx } = context.state
48
+
49
+ const repository = tx.getRepository(ActionPlan)
50
+ const actionPlan = await repository.findOne({
51
+ where: { domain: { id: domain.id }, id }
52
+ })
53
+
54
+ const result = await repository.save({
55
+ ...actionPlan,
56
+ ...patch,
57
+ updater: user
58
+ })
59
+
60
+ if (patch.thumbnail) {
61
+ await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)
62
+ await createAttachment(
63
+ null,
64
+ {
65
+ attachment: {
66
+ file: patch.thumbnail,
67
+ refType: ActionPlan.name,
68
+ refBy: result.id
69
+ }
70
+ },
71
+ context
72
+ )
73
+ }
74
+
75
+ return result
76
+ }
77
+
78
+ @Directive('@transaction')
79
+ @Mutation(returns => [ActionPlan], { description: "To modify multiple ActionPlans' information" })
80
+ async updateMultipleActionPlan(
81
+ @Arg('patches', type => [ActionPlanPatch]) patches: ActionPlanPatch[],
82
+ @Ctx() context: ResolverContext
83
+ ): Promise<ActionPlan[]> {
84
+ const { domain, user, tx } = context.state
85
+
86
+ let results = []
87
+ const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
88
+ const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
89
+ const actionPlanRepo = tx.getRepository(ActionPlan)
90
+
91
+ if (_createRecords.length > 0) {
92
+ for (let i = 0; i < _createRecords.length; i++) {
93
+ const newRecord = _createRecords[i]
94
+
95
+ const result = await actionPlanRepo.save({
96
+ ...newRecord,
97
+ domain,
98
+ creator: user,
99
+ updater: user
100
+ })
101
+
102
+ if (newRecord.thumbnail) {
103
+ await createAttachment(
104
+ null,
105
+ {
106
+ attachment: {
107
+ file: newRecord.thumbnail,
108
+ refType: ActionPlan.name,
109
+ refBy: result.id
110
+ }
111
+ },
112
+ context
113
+ )
114
+ }
115
+
116
+ results.push({ ...result, cuFlag: '+' })
117
+ }
118
+ }
119
+
120
+ if (_updateRecords.length > 0) {
121
+ for (let i = 0; i < _updateRecords.length; i++) {
122
+ const updateRecord = _updateRecords[i]
123
+ const actionPlan = await actionPlanRepo.findOneBy({ id: updateRecord.id })
124
+
125
+ const result = await actionPlanRepo.save({
126
+ ...actionPlan,
127
+ ...updateRecord,
128
+ updater: user
129
+ })
130
+
131
+ if (updateRecord.thumbnail) {
132
+ await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)
133
+ await createAttachment(
134
+ null,
135
+ {
136
+ attachment: {
137
+ file: updateRecord.thumbnail,
138
+ refType: ActionPlan.name,
139
+ refBy: result.id
140
+ }
141
+ },
142
+ context
143
+ )
144
+ }
145
+
146
+ results.push({ ...result, cuFlag: 'M' })
147
+ }
148
+ }
149
+
150
+ return results
151
+ }
152
+
153
+ @Directive('@transaction')
154
+ @Mutation(returns => Boolean, { description: 'To delete ActionPlan' })
155
+ async deleteActionPlan(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
156
+ const { domain, tx } = context.state
157
+
158
+ await tx.getRepository(ActionPlan).delete({ domain: { id: domain.id }, id })
159
+ await deleteAttachmentsByRef(null, { refBys: [id] }, context)
160
+
161
+ return true
162
+ }
163
+
164
+ @Directive('@transaction')
165
+ @Mutation(returns => Boolean, { description: 'To delete multiple ActionPlans' })
166
+ async deleteActionPlans(
167
+ @Arg('ids', type => [String]) ids: string[],
168
+ @Ctx() context: ResolverContext
169
+ ): Promise<boolean> {
170
+ const { domain, tx } = context.state
171
+
172
+ await tx.getRepository(ActionPlan).delete({
173
+ domain: { id: domain.id },
174
+ id: In(ids)
175
+ })
176
+
177
+ await deleteAttachmentsByRef(null, { refBys: ids }, context)
178
+
179
+ return true
180
+ }
181
+
182
+ @Directive('@transaction')
183
+ @Mutation(returns => Boolean, { description: 'To import multiple ActionPlans' })
184
+ async importActionPlans(
185
+ @Arg('actionPlans', type => [ActionPlanPatch]) actionPlans: ActionPlanPatch[],
186
+ @Ctx() context: ResolverContext
187
+ ): Promise<boolean> {
188
+ const { domain, tx } = context.state
189
+
190
+ await Promise.all(
191
+ actionPlans.map(async (actionPlan: ActionPlanPatch) => {
192
+ const createdActionPlan: ActionPlan = await tx.getRepository(ActionPlan).save({ domain, ...actionPlan })
193
+ })
194
+ )
195
+
196
+ return true
197
+ }
198
+ }
@@ -0,0 +1,62 @@
1
+ import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
2
+ import { Attachment } from '@things-factory/attachment-base'
3
+ import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
4
+ import { User } from '@things-factory/auth-base'
5
+ import { ActionPlan } from './action-plan'
6
+ import { ActionPlanList } from './action-plan-type'
7
+
8
+ @Resolver(ActionPlan)
9
+ export class ActionPlanQuery {
10
+ @Query(returns => ActionPlan!, { nullable: true, description: 'To fetch a ActionPlan' })
11
+ async actionPlan(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ActionPlan> {
12
+ const { domain } = context.state
13
+
14
+ return await getRepository(ActionPlan).findOne({
15
+ where: { domain: { id: domain.id }, id }
16
+ })
17
+ }
18
+
19
+ @Query(returns => ActionPlanList, { description: 'To fetch multiple ActionPlans' })
20
+ async actionPlans(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ActionPlanList> {
21
+ const { domain } = context.state
22
+
23
+ const queryBuilder = getQueryBuilderFromListParams({
24
+ domain,
25
+ params,
26
+ repository: await getRepository(ActionPlan),
27
+ searchables: ['name', 'description']
28
+ })
29
+
30
+ const [items, total] = await queryBuilder.getManyAndCount()
31
+
32
+ return { items, total }
33
+ }
34
+
35
+ @FieldResolver(type => String)
36
+ async thumbnail(@Root() actionPlan: ActionPlan): Promise<string | undefined> {
37
+ const attachment: Attachment = await getRepository(Attachment).findOne({
38
+ where: {
39
+ domain: { id: actionPlan.domainId },
40
+ refType: ActionPlan.name,
41
+ refBy: actionPlan.id
42
+ }
43
+ })
44
+
45
+ return attachment?.fullpath
46
+ }
47
+
48
+ @FieldResolver(type => Domain)
49
+ async domain(@Root() actionPlan: ActionPlan): Promise<Domain> {
50
+ return await getRepository(Domain).findOneBy({ id: actionPlan.domainId })
51
+ }
52
+
53
+ @FieldResolver(type => User)
54
+ async updater(@Root() actionPlan: ActionPlan): Promise<User> {
55
+ return await getRepository(User).findOneBy({ id: actionPlan.updaterId })
56
+ }
57
+
58
+ @FieldResolver(type => User)
59
+ async creator(@Root() actionPlan: ActionPlan): Promise<User> {
60
+ return await getRepository(User).findOneBy({ id: actionPlan.creatorId })
61
+ }
62
+ }
@@ -0,0 +1,61 @@
1
+ import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'
2
+ import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
3
+ import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'
4
+
5
+ import { ObjectRef, ScalarObject } from '@things-factory/shell'
6
+
7
+ import { ActionPlan, ActionPlanStatus } from './action-plan'
8
+
9
+ @InputType()
10
+ export class NewActionPlan {
11
+ @Field()
12
+ name: string
13
+
14
+ @Field({ nullable: true })
15
+ description?: string
16
+
17
+ @Field(type => ActionPlanStatus, { nullable: true })
18
+ state?: ActionPlanStatus
19
+
20
+ @Field({ nullable: true })
21
+ active?: boolean
22
+
23
+ @Field({ nullable: true })
24
+ params?: string
25
+
26
+ @Field(type => GraphQLUpload, { nullable: true })
27
+ thumbnail?: FileUpload
28
+ }
29
+
30
+ @InputType()
31
+ export class ActionPlanPatch {
32
+ @Field(type => ID, { nullable: true })
33
+ id?: string
34
+
35
+ @Field({ nullable: true })
36
+ name?: string
37
+
38
+ @Field({ nullable: true })
39
+ description?: string
40
+
41
+ @Field(type => ActionPlanStatus, { nullable: true })
42
+ state?: ActionPlanStatus
43
+
44
+ @Field({ nullable: true })
45
+ active?: boolean
46
+
47
+ @Field(type => GraphQLUpload, { nullable: true })
48
+ thumbnail?: FileUpload
49
+
50
+ @Field({ nullable: true })
51
+ cuFlag?: string
52
+ }
53
+
54
+ @ObjectType()
55
+ export class ActionPlanList {
56
+ @Field(type => [ActionPlan])
57
+ items: ActionPlan[]
58
+
59
+ @Field(type => Int)
60
+ total: number
61
+ }
@@ -0,0 +1,103 @@
1
+ import {
2
+ CreateDateColumn,
3
+ UpdateDateColumn,
4
+ DeleteDateColumn,
5
+ Entity,
6
+ Index,
7
+ Column,
8
+ RelationId,
9
+ ManyToOne,
10
+ PrimaryGeneratedColumn,
11
+ VersionColumn
12
+ } from 'typeorm'
13
+ import { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'
14
+
15
+ import { Domain } from '@things-factory/shell'
16
+ import { User } from '@things-factory/auth-base'
17
+ import { Issue } from '../issue/issue'
18
+
19
+ export enum ActionPlanStatus {
20
+ STATUS_A = 'STATUS_A',
21
+ STATUS_B = 'STATUS_B'
22
+ }
23
+
24
+ registerEnumType(ActionPlanStatus, {
25
+ name: 'ActionPlanStatus',
26
+ description: 'state enumeration of a actionPlan'
27
+ })
28
+
29
+ @Entity()
30
+ @Index('ix_action_plan_0', (actionPlan: ActionPlan) => [actionPlan.domain, actionPlan.name], {
31
+ unique: true,
32
+ where: '"deleted_at" IS NULL'
33
+ })
34
+ @ObjectType({ description: 'Entity for ActionPlan' })
35
+ export class ActionPlan {
36
+ @PrimaryGeneratedColumn('uuid')
37
+ @Field(type => ID)
38
+ readonly id: string
39
+
40
+ @ManyToOne(type => Domain)
41
+ @Field({ nullable: true })
42
+ domain?: Domain
43
+
44
+ @RelationId((actionPlan: ActionPlan) => actionPlan.domain)
45
+ domainId?: string
46
+
47
+ @Column()
48
+ @Field({ nullable: true })
49
+ name?: string
50
+
51
+ @Column({ nullable: true })
52
+ @Field({ nullable: true })
53
+ description?: string
54
+
55
+ @Column({ nullable: true })
56
+ @Field({ nullable: true })
57
+ active?: boolean
58
+
59
+ @Column({ nullable: true })
60
+ @Field({ nullable: true })
61
+ state?: ActionPlanStatus
62
+
63
+ @Column({ nullable: true })
64
+ @Field({ nullable: true })
65
+ params?: string
66
+
67
+ @Field(() => Issue)
68
+ @ManyToOne(() => Issue, issue => issue.actionPlans)
69
+ issue: Issue
70
+
71
+ @Column({ nullable: true })
72
+ @Field({ nullable: true })
73
+ content: string
74
+
75
+ @CreateDateColumn()
76
+ @Field({ nullable: true })
77
+ createdAt?: Date
78
+
79
+ @UpdateDateColumn()
80
+ @Field({ nullable: true })
81
+ updatedAt?: Date
82
+
83
+ @DeleteDateColumn()
84
+ @Field({ nullable: true })
85
+ deletedAt?: Date
86
+
87
+ @ManyToOne(type => User, { nullable: true })
88
+ @Field(type => User, { nullable: true })
89
+ creator?: User
90
+
91
+ @RelationId((actionPlan: ActionPlan) => actionPlan.creator)
92
+ creatorId?: string
93
+
94
+ @ManyToOne(type => User, { nullable: true })
95
+ @Field(type => User, { nullable: true })
96
+ updater?: User
97
+
98
+ @RelationId((actionPlan: ActionPlan) => actionPlan.updater)
99
+ updaterId?: string
100
+
101
+ @Field(type => String, { nullable: true })
102
+ thumbnail?: string
103
+ }
@@ -0,0 +1,7 @@
1
+ import { ActionPlan } from './action-plan'
2
+ import { ActionPlanQuery } from './action-plan-query'
3
+ import { ActionPlanMutation } from './action-plan-mutation'
4
+
5
+ export const entities = [ActionPlan]
6
+ export const resolvers = [ActionPlanQuery, ActionPlanMutation]
7
+ export const subscribers = []