@things-factory/kpi 1.0.0-alpha.5

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 (259) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/assets/images/hatiolab-logo.png +0 -0
  3. package/client/index.ts +0 -0
  4. package/client/pages/kpe-metric/kpe-metric-importer.ts +90 -0
  5. package/client/pages/kpe-metric/kpe-metric-list-page.ts +398 -0
  6. package/client/pages/kpi/kpi-importer.ts +90 -0
  7. package/client/pages/kpi/kpi-list-page.ts +398 -0
  8. package/client/pages/kpi-category/kpi-category-importer.ts +90 -0
  9. package/client/pages/kpi-category/kpi-category-list-page.ts +398 -0
  10. package/client/pages/kpi-formula/kpi-formula-importer.ts +90 -0
  11. package/client/pages/kpi-formula/kpi-formula-list-page.ts +398 -0
  12. package/client/pages/kpi-grade/kpi-grade-importer.ts +90 -0
  13. package/client/pages/kpi-grade/kpi-grade-list-page.ts +398 -0
  14. package/client/pages/kpi-metric/kpi-metric-importer.ts +90 -0
  15. package/client/pages/kpi-metric/kpi-metric-list-page.ts +398 -0
  16. package/client/pages/kpi-value/kpi-value-importer.ts +90 -0
  17. package/client/pages/kpi-value/kpi-value-list-page.ts +398 -0
  18. package/client/pages/metric/metric-importer.ts +90 -0
  19. package/client/pages/metric/metric-list-page.ts +398 -0
  20. package/client/route.ts +4 -0
  21. package/client/tsconfig.json +11 -0
  22. package/design-entities.md +97 -0
  23. package/dist-client/index.d.ts +0 -0
  24. package/dist-client/index.js +2 -0
  25. package/dist-client/index.js.map +1 -0
  26. package/dist-client/pages/kpe-metric/kpe-metric-importer.d.ts +23 -0
  27. package/dist-client/pages/kpe-metric/kpe-metric-importer.js +93 -0
  28. package/dist-client/pages/kpe-metric/kpe-metric-importer.js.map +1 -0
  29. package/dist-client/pages/kpe-metric/kpe-metric-list-page.d.ts +66 -0
  30. package/dist-client/pages/kpe-metric/kpe-metric-list-page.js +370 -0
  31. package/dist-client/pages/kpe-metric/kpe-metric-list-page.js.map +1 -0
  32. package/dist-client/pages/kpi/kpi-importer.d.ts +23 -0
  33. package/dist-client/pages/kpi/kpi-importer.js +93 -0
  34. package/dist-client/pages/kpi/kpi-importer.js.map +1 -0
  35. package/dist-client/pages/kpi/kpi-list-page.d.ts +66 -0
  36. package/dist-client/pages/kpi/kpi-list-page.js +370 -0
  37. package/dist-client/pages/kpi/kpi-list-page.js.map +1 -0
  38. package/dist-client/pages/kpi-category/kpi-category-importer.d.ts +23 -0
  39. package/dist-client/pages/kpi-category/kpi-category-importer.js +93 -0
  40. package/dist-client/pages/kpi-category/kpi-category-importer.js.map +1 -0
  41. package/dist-client/pages/kpi-category/kpi-category-list-page.d.ts +66 -0
  42. package/dist-client/pages/kpi-category/kpi-category-list-page.js +370 -0
  43. package/dist-client/pages/kpi-category/kpi-category-list-page.js.map +1 -0
  44. package/dist-client/pages/kpi-formula/kpi-formula-importer.d.ts +23 -0
  45. package/dist-client/pages/kpi-formula/kpi-formula-importer.js +93 -0
  46. package/dist-client/pages/kpi-formula/kpi-formula-importer.js.map +1 -0
  47. package/dist-client/pages/kpi-formula/kpi-formula-list-page.d.ts +66 -0
  48. package/dist-client/pages/kpi-formula/kpi-formula-list-page.js +370 -0
  49. package/dist-client/pages/kpi-formula/kpi-formula-list-page.js.map +1 -0
  50. package/dist-client/pages/kpi-grade/kpi-grade-importer.d.ts +23 -0
  51. package/dist-client/pages/kpi-grade/kpi-grade-importer.js +93 -0
  52. package/dist-client/pages/kpi-grade/kpi-grade-importer.js.map +1 -0
  53. package/dist-client/pages/kpi-grade/kpi-grade-list-page.d.ts +66 -0
  54. package/dist-client/pages/kpi-grade/kpi-grade-list-page.js +370 -0
  55. package/dist-client/pages/kpi-grade/kpi-grade-list-page.js.map +1 -0
  56. package/dist-client/pages/kpi-metric/kpi-metric-importer.d.ts +23 -0
  57. package/dist-client/pages/kpi-metric/kpi-metric-importer.js +93 -0
  58. package/dist-client/pages/kpi-metric/kpi-metric-importer.js.map +1 -0
  59. package/dist-client/pages/kpi-metric/kpi-metric-list-page.d.ts +66 -0
  60. package/dist-client/pages/kpi-metric/kpi-metric-list-page.js +370 -0
  61. package/dist-client/pages/kpi-metric/kpi-metric-list-page.js.map +1 -0
  62. package/dist-client/pages/kpi-value/kpi-value-importer.d.ts +23 -0
  63. package/dist-client/pages/kpi-value/kpi-value-importer.js +93 -0
  64. package/dist-client/pages/kpi-value/kpi-value-importer.js.map +1 -0
  65. package/dist-client/pages/kpi-value/kpi-value-list-page.d.ts +66 -0
  66. package/dist-client/pages/kpi-value/kpi-value-list-page.js +370 -0
  67. package/dist-client/pages/kpi-value/kpi-value-list-page.js.map +1 -0
  68. package/dist-client/pages/metric/metric-importer.d.ts +23 -0
  69. package/dist-client/pages/metric/metric-importer.js +93 -0
  70. package/dist-client/pages/metric/metric-importer.js.map +1 -0
  71. package/dist-client/pages/metric/metric-list-page.d.ts +66 -0
  72. package/dist-client/pages/metric/metric-list-page.js +370 -0
  73. package/dist-client/pages/metric/metric-list-page.js.map +1 -0
  74. package/dist-client/route.d.ts +1 -0
  75. package/dist-client/route.js +5 -0
  76. package/dist-client/route.js.map +1 -0
  77. package/dist-client/tsconfig.tsbuildinfo +1 -0
  78. package/dist-server/index.d.ts +2 -0
  79. package/dist-server/index.js +6 -0
  80. package/dist-server/index.js.map +1 -0
  81. package/dist-server/routes.d.ts +0 -0
  82. package/dist-server/routes.js +24 -0
  83. package/dist-server/routes.js.map +1 -0
  84. package/dist-server/service/index.d.ts +16 -0
  85. package/dist-server/service/index.js +45 -0
  86. package/dist-server/service/index.js.map +1 -0
  87. package/dist-server/service/kpi/event-subscriber.d.ts +7 -0
  88. package/dist-server/service/kpi/event-subscriber.js +21 -0
  89. package/dist-server/service/kpi/event-subscriber.js.map +1 -0
  90. package/dist-server/service/kpi/index.d.ts +7 -0
  91. package/dist-server/service/kpi/index.js +12 -0
  92. package/dist-server/service/kpi/index.js.map +1 -0
  93. package/dist-server/service/kpi/kpi-history.d.ts +25 -0
  94. package/dist-server/service/kpi/kpi-history.js +128 -0
  95. package/dist-server/service/kpi/kpi-history.js.map +1 -0
  96. package/dist-server/service/kpi/kpi-mutation.d.ts +10 -0
  97. package/dist-server/service/kpi/kpi-mutation.js +169 -0
  98. package/dist-server/service/kpi/kpi-mutation.js.map +1 -0
  99. package/dist-server/service/kpi/kpi-query.d.ts +12 -0
  100. package/dist-server/service/kpi/kpi-query.js +97 -0
  101. package/dist-server/service/kpi/kpi-query.js.map +1 -0
  102. package/dist-server/service/kpi/kpi-type.d.ts +23 -0
  103. package/dist-server/service/kpi/kpi-type.js +86 -0
  104. package/dist-server/service/kpi/kpi-type.js.map +1 -0
  105. package/dist-server/service/kpi/kpi.d.ts +25 -0
  106. package/dist-server/service/kpi/kpi.js +113 -0
  107. package/dist-server/service/kpi/kpi.js.map +1 -0
  108. package/dist-server/service/kpi-category/index.d.ts +6 -0
  109. package/dist-server/service/kpi-category/index.js +10 -0
  110. package/dist-server/service/kpi-category/index.js.map +1 -0
  111. package/dist-server/service/kpi-category/kpi-category-mutation.d.ts +10 -0
  112. package/dist-server/service/kpi-category/kpi-category-mutation.js +128 -0
  113. package/dist-server/service/kpi-category/kpi-category-mutation.js.map +1 -0
  114. package/dist-server/service/kpi-category/kpi-category-query.d.ts +11 -0
  115. package/dist-server/service/kpi-category/kpi-category-query.js +79 -0
  116. package/dist-server/service/kpi-category/kpi-category-query.js.map +1 -0
  117. package/dist-server/service/kpi-category/kpi-category-type.d.ts +20 -0
  118. package/dist-server/service/kpi-category/kpi-category-type.js +77 -0
  119. package/dist-server/service/kpi-category/kpi-category-type.js.map +1 -0
  120. package/dist-server/service/kpi-category/kpi-category.d.ts +22 -0
  121. package/dist-server/service/kpi-category/kpi-category.js +95 -0
  122. package/dist-server/service/kpi-category/kpi-category.js.map +1 -0
  123. package/dist-server/service/kpi-formula/event-subscriber.d.ts +7 -0
  124. package/dist-server/service/kpi-formula/event-subscriber.js +21 -0
  125. package/dist-server/service/kpi-formula/event-subscriber.js.map +1 -0
  126. package/dist-server/service/kpi-formula/index.d.ts +7 -0
  127. package/dist-server/service/kpi-formula/index.js +12 -0
  128. package/dist-server/service/kpi-formula/index.js.map +1 -0
  129. package/dist-server/service/kpi-formula/kpi-formula-history.d.ts +25 -0
  130. package/dist-server/service/kpi-formula/kpi-formula-history.js +128 -0
  131. package/dist-server/service/kpi-formula/kpi-formula-history.js.map +1 -0
  132. package/dist-server/service/kpi-formula/kpi-formula-mutation.d.ts +10 -0
  133. package/dist-server/service/kpi-formula/kpi-formula-mutation.js +128 -0
  134. package/dist-server/service/kpi-formula/kpi-formula-mutation.js.map +1 -0
  135. package/dist-server/service/kpi-formula/kpi-formula-query.d.ts +11 -0
  136. package/dist-server/service/kpi-formula/kpi-formula-query.js +79 -0
  137. package/dist-server/service/kpi-formula/kpi-formula-query.js.map +1 -0
  138. package/dist-server/service/kpi-formula/kpi-formula-type.d.ts +20 -0
  139. package/dist-server/service/kpi-formula/kpi-formula-type.js +77 -0
  140. package/dist-server/service/kpi-formula/kpi-formula-type.js.map +1 -0
  141. package/dist-server/service/kpi-formula/kpi-formula.d.ts +24 -0
  142. package/dist-server/service/kpi-formula/kpi-formula.js +109 -0
  143. package/dist-server/service/kpi-formula/kpi-formula.js.map +1 -0
  144. package/dist-server/service/kpi-grade/event-subscriber.d.ts +7 -0
  145. package/dist-server/service/kpi-grade/event-subscriber.js +21 -0
  146. package/dist-server/service/kpi-grade/event-subscriber.js.map +1 -0
  147. package/dist-server/service/kpi-grade/index.d.ts +7 -0
  148. package/dist-server/service/kpi-grade/index.js +12 -0
  149. package/dist-server/service/kpi-grade/index.js.map +1 -0
  150. package/dist-server/service/kpi-grade/kpi-grade-history.d.ts +25 -0
  151. package/dist-server/service/kpi-grade/kpi-grade-history.js +128 -0
  152. package/dist-server/service/kpi-grade/kpi-grade-history.js.map +1 -0
  153. package/dist-server/service/kpi-grade/kpi-grade-mutation.d.ts +10 -0
  154. package/dist-server/service/kpi-grade/kpi-grade-mutation.js +128 -0
  155. package/dist-server/service/kpi-grade/kpi-grade-mutation.js.map +1 -0
  156. package/dist-server/service/kpi-grade/kpi-grade-query.d.ts +11 -0
  157. package/dist-server/service/kpi-grade/kpi-grade-query.js +79 -0
  158. package/dist-server/service/kpi-grade/kpi-grade-query.js.map +1 -0
  159. package/dist-server/service/kpi-grade/kpi-grade-type.d.ts +20 -0
  160. package/dist-server/service/kpi-grade/kpi-grade-type.js +77 -0
  161. package/dist-server/service/kpi-grade/kpi-grade-type.js.map +1 -0
  162. package/dist-server/service/kpi-grade/kpi-grade.d.ts +24 -0
  163. package/dist-server/service/kpi-grade/kpi-grade.js +109 -0
  164. package/dist-server/service/kpi-grade/kpi-grade.js.map +1 -0
  165. package/dist-server/service/kpi-metric/event-subscriber.d.ts +7 -0
  166. package/dist-server/service/kpi-metric/event-subscriber.js +21 -0
  167. package/dist-server/service/kpi-metric/event-subscriber.js.map +1 -0
  168. package/dist-server/service/kpi-metric/index.d.ts +7 -0
  169. package/dist-server/service/kpi-metric/index.js +12 -0
  170. package/dist-server/service/kpi-metric/index.js.map +1 -0
  171. package/dist-server/service/kpi-metric/kpi-metric-history.d.ts +25 -0
  172. package/dist-server/service/kpi-metric/kpi-metric-history.js +128 -0
  173. package/dist-server/service/kpi-metric/kpi-metric-history.js.map +1 -0
  174. package/dist-server/service/kpi-metric/kpi-metric-mutation.d.ts +10 -0
  175. package/dist-server/service/kpi-metric/kpi-metric-mutation.js +169 -0
  176. package/dist-server/service/kpi-metric/kpi-metric-mutation.js.map +1 -0
  177. package/dist-server/service/kpi-metric/kpi-metric-query.d.ts +12 -0
  178. package/dist-server/service/kpi-metric/kpi-metric-query.js +97 -0
  179. package/dist-server/service/kpi-metric/kpi-metric-query.js.map +1 -0
  180. package/dist-server/service/kpi-metric/kpi-metric-type.d.ts +23 -0
  181. package/dist-server/service/kpi-metric/kpi-metric-type.js +86 -0
  182. package/dist-server/service/kpi-metric/kpi-metric-type.js.map +1 -0
  183. package/dist-server/service/kpi-metric/kpi-metric.d.ts +25 -0
  184. package/dist-server/service/kpi-metric/kpi-metric.js +113 -0
  185. package/dist-server/service/kpi-metric/kpi-metric.js.map +1 -0
  186. package/dist-server/service/kpi-value/index.d.ts +6 -0
  187. package/dist-server/service/kpi-value/index.js +10 -0
  188. package/dist-server/service/kpi-value/index.js.map +1 -0
  189. package/dist-server/service/kpi-value/kpi-value-mutation.d.ts +10 -0
  190. package/dist-server/service/kpi-value/kpi-value-mutation.js +128 -0
  191. package/dist-server/service/kpi-value/kpi-value-mutation.js.map +1 -0
  192. package/dist-server/service/kpi-value/kpi-value-query.d.ts +11 -0
  193. package/dist-server/service/kpi-value/kpi-value-query.js +79 -0
  194. package/dist-server/service/kpi-value/kpi-value-query.js.map +1 -0
  195. package/dist-server/service/kpi-value/kpi-value-type.d.ts +20 -0
  196. package/dist-server/service/kpi-value/kpi-value-type.js +77 -0
  197. package/dist-server/service/kpi-value/kpi-value-type.js.map +1 -0
  198. package/dist-server/service/kpi-value/kpi-value.d.ts +22 -0
  199. package/dist-server/service/kpi-value/kpi-value.js +95 -0
  200. package/dist-server/service/kpi-value/kpi-value.js.map +1 -0
  201. package/dist-server/tsconfig.tsbuildinfo +1 -0
  202. package/helps/kpi/kpe-metric.md +160 -0
  203. package/helps/kpi/kpi-category.md +160 -0
  204. package/helps/kpi/kpi-formula.md +160 -0
  205. package/helps/kpi/kpi-grade.md +160 -0
  206. package/helps/kpi/kpi-metric.md +160 -0
  207. package/helps/kpi/kpi-value.md +160 -0
  208. package/helps/kpi/kpi.md +160 -0
  209. package/helps/kpi/metric.md +160 -0
  210. package/kpi-grade.csv +41 -0
  211. package/package.json +36 -0
  212. package/server/index.ts +3 -0
  213. package/server/routes.ts +26 -0
  214. package/server/service/index.ts +43 -0
  215. package/server/service/kpi/event-subscriber.ts +17 -0
  216. package/server/service/kpi/index.ts +9 -0
  217. package/server/service/kpi/kpi-history.ts +116 -0
  218. package/server/service/kpi/kpi-mutation.ts +198 -0
  219. package/server/service/kpi/kpi-query.ts +62 -0
  220. package/server/service/kpi/kpi-type.ts +61 -0
  221. package/server/service/kpi/kpi.ts +98 -0
  222. package/server/service/kpi-category/index.ts +7 -0
  223. package/server/service/kpi-category/kpi-category-mutation.ts +137 -0
  224. package/server/service/kpi-category/kpi-category-query.ts +48 -0
  225. package/server/service/kpi-category/kpi-category-type.ts +55 -0
  226. package/server/service/kpi-category/kpi-category.ts +84 -0
  227. package/server/service/kpi-formula/event-subscriber.ts +17 -0
  228. package/server/service/kpi-formula/index.ts +9 -0
  229. package/server/service/kpi-formula/kpi-formula-history.ts +116 -0
  230. package/server/service/kpi-formula/kpi-formula-mutation.ts +137 -0
  231. package/server/service/kpi-formula/kpi-formula-query.ts +48 -0
  232. package/server/service/kpi-formula/kpi-formula-type.ts +55 -0
  233. package/server/service/kpi-formula/kpi-formula.ts +95 -0
  234. package/server/service/kpi-grade/event-subscriber.ts +17 -0
  235. package/server/service/kpi-grade/index.ts +9 -0
  236. package/server/service/kpi-grade/kpi-grade-history.ts +116 -0
  237. package/server/service/kpi-grade/kpi-grade-mutation.ts +137 -0
  238. package/server/service/kpi-grade/kpi-grade-query.ts +48 -0
  239. package/server/service/kpi-grade/kpi-grade-type.ts +55 -0
  240. package/server/service/kpi-grade/kpi-grade.ts +95 -0
  241. package/server/service/kpi-metric/event-subscriber.ts +17 -0
  242. package/server/service/kpi-metric/index.ts +9 -0
  243. package/server/service/kpi-metric/kpi-metric-history.ts +116 -0
  244. package/server/service/kpi-metric/kpi-metric-mutation.ts +198 -0
  245. package/server/service/kpi-metric/kpi-metric-query.ts +62 -0
  246. package/server/service/kpi-metric/kpi-metric-type.ts +61 -0
  247. package/server/service/kpi-metric/kpi-metric.ts +98 -0
  248. package/server/service/kpi-value/index.ts +7 -0
  249. package/server/service/kpi-value/kpi-value-mutation.ts +137 -0
  250. package/server/service/kpi-value/kpi-value-query.ts +48 -0
  251. package/server/service/kpi-value/kpi-value-type.ts +55 -0
  252. package/server/service/kpi-value/kpi-value.ts +84 -0
  253. package/server/tsconfig.json +10 -0
  254. package/things-factory.config.js +10 -0
  255. package/translations/en.json +1 -0
  256. package/translations/ja.json +1 -0
  257. package/translations/ko.json +1 -0
  258. package/translations/ms.json +1 -0
  259. package/translations/zh.json +1 -0
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KpiHistory = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const typeorm_1 = require("typeorm");
7
+ const typeorm_history_1 = require("@operato/typeorm-history");
8
+ const auth_base_1 = require("@things-factory/auth-base");
9
+ const env_1 = require("@things-factory/env");
10
+ const shell_1 = require("@things-factory/shell");
11
+ const kpi_1 = require("./kpi");
12
+ const ORMCONFIG = env_1.config.get('ormconfig', {});
13
+ const DATABASE_TYPE = ORMCONFIG.type;
14
+ let KpiHistory = class KpiHistory {
15
+ constructor() {
16
+ this.version = 1;
17
+ }
18
+ };
19
+ exports.KpiHistory = KpiHistory;
20
+ tslib_1.__decorate([
21
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
22
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID),
23
+ tslib_1.__metadata("design:type", String)
24
+ ], KpiHistory.prototype, "id", void 0);
25
+ tslib_1.__decorate([
26
+ (0, typeorm_1.Column)({ nullable: true, default: 1 }),
27
+ (0, type_graphql_1.Field)({ nullable: true }),
28
+ tslib_1.__metadata("design:type", Number)
29
+ ], KpiHistory.prototype, "version", void 0);
30
+ tslib_1.__decorate([
31
+ (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
32
+ (0, type_graphql_1.Field)({ nullable: true }),
33
+ tslib_1.__metadata("design:type", shell_1.Domain)
34
+ ], KpiHistory.prototype, "domain", void 0);
35
+ tslib_1.__decorate([
36
+ (0, typeorm_1.RelationId)((kpi) => kpi.domain),
37
+ tslib_1.__metadata("design:type", String)
38
+ ], KpiHistory.prototype, "domainId", void 0);
39
+ tslib_1.__decorate([
40
+ (0, typeorm_1.Column)(),
41
+ (0, type_graphql_1.Field)(),
42
+ tslib_1.__metadata("design:type", String)
43
+ ], KpiHistory.prototype, "name", void 0);
44
+ tslib_1.__decorate([
45
+ (0, typeorm_1.Column)({ nullable: true }),
46
+ (0, type_graphql_1.Field)({ nullable: true }),
47
+ tslib_1.__metadata("design:type", String)
48
+ ], KpiHistory.prototype, "description", void 0);
49
+ tslib_1.__decorate([
50
+ (0, typeorm_1.Column)({ nullable: true }),
51
+ (0, type_graphql_1.Field)({ nullable: true }),
52
+ tslib_1.__metadata("design:type", Boolean)
53
+ ], KpiHistory.prototype, "active", void 0);
54
+ tslib_1.__decorate([
55
+ (0, typeorm_1.Column)({ nullable: true }),
56
+ (0, type_graphql_1.Field)({ nullable: true }),
57
+ tslib_1.__metadata("design:type", String)
58
+ ], KpiHistory.prototype, "state", void 0);
59
+ tslib_1.__decorate([
60
+ (0, typeorm_1.Column)({ nullable: true }),
61
+ (0, type_graphql_1.Field)({ nullable: true }),
62
+ tslib_1.__metadata("design:type", String)
63
+ ], KpiHistory.prototype, "params", void 0);
64
+ tslib_1.__decorate([
65
+ (0, typeorm_1.Column)({ nullable: true }),
66
+ (0, type_graphql_1.Field)({ nullable: true }),
67
+ tslib_1.__metadata("design:type", Date)
68
+ ], KpiHistory.prototype, "createdAt", void 0);
69
+ tslib_1.__decorate([
70
+ (0, typeorm_1.Column)({ nullable: true }),
71
+ (0, type_graphql_1.Field)({ nullable: true }),
72
+ tslib_1.__metadata("design:type", Date)
73
+ ], KpiHistory.prototype, "updatedAt", void 0);
74
+ tslib_1.__decorate([
75
+ (0, typeorm_1.Column)({ nullable: true }),
76
+ (0, type_graphql_1.Field)({ nullable: true }),
77
+ tslib_1.__metadata("design:type", Date)
78
+ ], KpiHistory.prototype, "deletedAt", void 0);
79
+ tslib_1.__decorate([
80
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
81
+ (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
82
+ tslib_1.__metadata("design:type", auth_base_1.User)
83
+ ], KpiHistory.prototype, "creator", void 0);
84
+ tslib_1.__decorate([
85
+ (0, typeorm_1.RelationId)((kpi) => kpi.creator),
86
+ tslib_1.__metadata("design:type", String)
87
+ ], KpiHistory.prototype, "creatorId", void 0);
88
+ tslib_1.__decorate([
89
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
90
+ (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
91
+ tslib_1.__metadata("design:type", auth_base_1.User)
92
+ ], KpiHistory.prototype, "updater", void 0);
93
+ tslib_1.__decorate([
94
+ (0, typeorm_1.RelationId)((kpi) => kpi.updater),
95
+ tslib_1.__metadata("design:type", String)
96
+ ], KpiHistory.prototype, "updaterId", void 0);
97
+ tslib_1.__decorate([
98
+ (0, type_graphql_1.Field)(type => String, { nullable: true }),
99
+ tslib_1.__metadata("design:type", String)
100
+ ], KpiHistory.prototype, "thumbnail", void 0);
101
+ tslib_1.__decorate([
102
+ (0, typeorm_history_1.HistoryOriginalIdColumn)(),
103
+ tslib_1.__metadata("design:type", String)
104
+ ], KpiHistory.prototype, "originalId", void 0);
105
+ tslib_1.__decorate([
106
+ (0, typeorm_history_1.HistoryActionColumn)({
107
+ nullable: false,
108
+ type: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
109
+ ? 'enum'
110
+ : DATABASE_TYPE == 'oracle'
111
+ ? 'varchar2'
112
+ : DATABASE_TYPE == 'mssql'
113
+ ? 'nvarchar'
114
+ : 'varchar',
115
+ enum: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
116
+ ? typeorm_history_1.HistoryActionType
117
+ : undefined,
118
+ length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 32
119
+ }),
120
+ tslib_1.__metadata("design:type", String)
121
+ ], KpiHistory.prototype, "action", void 0);
122
+ exports.KpiHistory = KpiHistory = tslib_1.__decorate([
123
+ (0, typeorm_1.Entity)(),
124
+ (0, typeorm_1.Index)('ix_kpi_history_0', (kpiHistory) => [kpiHistory.originalId, kpiHistory.version], { unique: true }),
125
+ (0, typeorm_1.Index)('ix_kpi_history_1', (kpiHistory) => [kpiHistory.domain, kpiHistory.originalId, kpiHistory.version], { unique: true }),
126
+ (0, type_graphql_1.ObjectType)({ description: 'History Entity of Kpi' })
127
+ ], KpiHistory);
128
+ //# sourceMappingURL=kpi-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kpi-history.js","sourceRoot":"","sources":["../../../server/service/kpi/kpi-history.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,qCAA8F;AAE9F,8DAKiC;AACjC,yDAAsD;AACtD,6CAA4C;AAC5C,iDAA8C;AAE9C,+BAAsC;AAEtC,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAc7B,IAAM,UAAU,GAAhB,MAAM,UAAU;IAAhB;QAOL,YAAO,GAAY,CAAC,CAAA;IA8EtB,CAAC;CAAA,CAAA;AArFY,gCAAU;AAGZ;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;sCACC;AAInB;IAFC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACtC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACN;AAIpB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACj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Aa,IAAI,UAAU,IAAI,aAAa,IAAI,OAAO,IAAI,aAAa,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAA,CAAC,CAAC,EAAE;KAC9G,CAAC;;0CAC+B;qBApFtB,UAAU;IAZtB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EACJ,kBAAkB,EAClB,CAAC,UAAsB,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,EACvE,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,eAAK,EACJ,kBAAkB,EAClB,CAAC,UAAsB,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,EAC1F,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC;GACxC,UAAU,CAqFtB","sourcesContent":["import { Field, ID, ObjectType } from 'type-graphql'\nimport { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId } from 'typeorm'\n\nimport {\n HistoryActionColumn,\n HistoryActionType,\n HistoryEntityInterface,\n HistoryOriginalIdColumn\n} from '@operato/typeorm-history'\nimport { Role, User } from '@things-factory/auth-base'\nimport { config } from '@things-factory/env'\nimport { Domain } from '@things-factory/shell'\n\nimport { Kpi, KpiStatus } from './kpi'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\n@Entity()\n@Index(\n 'ix_kpi_history_0',\n (kpiHistory: KpiHistory) => [kpiHistory.originalId, kpiHistory.version],\n { unique: true }\n)\n@Index(\n 'ix_kpi_history_1',\n (kpiHistory: KpiHistory) => [kpiHistory.domain, kpiHistory.originalId, kpiHistory.version],\n { unique: true }\n)\n@ObjectType({ description: 'History Entity of Kpi' })\nexport class KpiHistory implements HistoryEntityInterface<Kpi> {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @Column({ nullable: true, default: 1 })\n @Field({ nullable: true })\n version?: number = 1\n\n @ManyToOne(type => Domain)\n @Field({ nullable: true })\n domain?: Domain\n\n @RelationId((kpi: Kpi) => kpi.domain)\n domainId?: string\n\n @Column()\n @Field()\n name: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n description?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n active?: boolean\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n state?: KpiStatus\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n params?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n createdAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n updatedAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((kpi: Kpi) => kpi.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n updater?: User\n\n @RelationId((kpi: Kpi) => kpi.updater)\n updaterId?: string\n\n @Field(type => String, { nullable: true })\n thumbnail?: string\n\n @HistoryOriginalIdColumn()\n public originalId!: string\n\n @HistoryActionColumn({\n nullable: false,\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : DATABASE_TYPE == 'mssql'\n ? 'nvarchar'\n : 'varchar',\n enum:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? HistoryActionType\n : undefined,\n length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined: 32\n })\n public action!: HistoryActionType\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { Kpi } from './kpi';
2
+ import { NewKpi, KpiPatch } from './kpi-type';
3
+ export declare class KpiMutation {
4
+ createKpi(kpi: NewKpi, context: ResolverContext): Promise<Kpi>;
5
+ updateKpi(id: string, patch: KpiPatch, context: ResolverContext): Promise<Kpi>;
6
+ updateMultipleKpi(patches: KpiPatch[], context: ResolverContext): Promise<Kpi[]>;
7
+ deleteKpi(id: string, context: ResolverContext): Promise<boolean>;
8
+ deleteKpis(ids: string[], context: ResolverContext): Promise<boolean>;
9
+ importKpis(kpis: KpiPatch[], context: ResolverContext): Promise<boolean>;
10
+ }
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KpiMutation = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const typeorm_1 = require("typeorm");
7
+ const shell_1 = require("@things-factory/shell");
8
+ const attachment_base_1 = require("@things-factory/attachment-base");
9
+ const kpi_1 = require("./kpi");
10
+ const kpi_type_1 = require("./kpi-type");
11
+ let KpiMutation = class KpiMutation {
12
+ async createKpi(kpi, context) {
13
+ const { domain, user, tx } = context.state;
14
+ const result = await (0, shell_1.getRepository)(kpi_1.Kpi, tx).save(Object.assign(Object.assign({}, kpi), { domain, creator: user, updater: user }));
15
+ if (kpi.thumbnail) {
16
+ await (0, attachment_base_1.createAttachment)(null, {
17
+ attachment: {
18
+ file: kpi.thumbnail,
19
+ refType: kpi_1.Kpi.name,
20
+ refBy: result.id
21
+ }
22
+ }, context);
23
+ }
24
+ return result;
25
+ }
26
+ async updateKpi(id, patch, context) {
27
+ const { domain, user, tx } = context.state;
28
+ const repository = (0, shell_1.getRepository)(kpi_1.Kpi, tx);
29
+ const kpi = await repository.findOne({
30
+ where: { domain: { id: domain.id }, id }
31
+ });
32
+ const result = await repository.save(Object.assign(Object.assign(Object.assign({}, kpi), patch), { updater: user }));
33
+ if (patch.thumbnail) {
34
+ await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [result.id] }, context);
35
+ await (0, attachment_base_1.createAttachment)(null, {
36
+ attachment: {
37
+ file: patch.thumbnail,
38
+ refType: kpi_1.Kpi.name,
39
+ refBy: result.id
40
+ }
41
+ }, context);
42
+ }
43
+ return result;
44
+ }
45
+ async updateMultipleKpi(patches, context) {
46
+ const { domain, user, tx } = context.state;
47
+ let results = [];
48
+ const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
49
+ const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
50
+ const kpiRepo = (0, shell_1.getRepository)(kpi_1.Kpi, tx);
51
+ if (_createRecords.length > 0) {
52
+ for (let i = 0; i < _createRecords.length; i++) {
53
+ const newRecord = _createRecords[i];
54
+ const result = await kpiRepo.save(Object.assign(Object.assign({}, newRecord), { domain, creator: user, updater: user }));
55
+ if (newRecord.thumbnail) {
56
+ await (0, attachment_base_1.createAttachment)(null, {
57
+ attachment: {
58
+ file: newRecord.thumbnail,
59
+ refType: kpi_1.Kpi.name,
60
+ refBy: result.id
61
+ }
62
+ }, context);
63
+ }
64
+ results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
65
+ }
66
+ }
67
+ if (_updateRecords.length > 0) {
68
+ for (let i = 0; i < _updateRecords.length; i++) {
69
+ const updateRecord = _updateRecords[i];
70
+ const kpi = await kpiRepo.findOneBy({ id: updateRecord.id });
71
+ const result = await kpiRepo.save(Object.assign(Object.assign(Object.assign({}, kpi), updateRecord), { updater: user }));
72
+ if (updateRecord.thumbnail) {
73
+ await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [result.id] }, context);
74
+ await (0, attachment_base_1.createAttachment)(null, {
75
+ attachment: {
76
+ file: updateRecord.thumbnail,
77
+ refType: kpi_1.Kpi.name,
78
+ refBy: result.id
79
+ }
80
+ }, context);
81
+ }
82
+ results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
83
+ }
84
+ }
85
+ return results;
86
+ }
87
+ async deleteKpi(id, context) {
88
+ const { domain, tx } = context.state;
89
+ await (0, shell_1.getRepository)(kpi_1.Kpi, tx).delete({ domain: { id: domain.id }, id });
90
+ await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [id] }, context);
91
+ return true;
92
+ }
93
+ async deleteKpis(ids, context) {
94
+ const { domain, tx } = context.state;
95
+ await (0, shell_1.getRepository)(kpi_1.Kpi, tx).delete({
96
+ domain: { id: domain.id },
97
+ id: (0, typeorm_1.In)(ids)
98
+ });
99
+ await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: ids }, context);
100
+ return true;
101
+ }
102
+ async importKpis(kpis, context) {
103
+ const { domain, tx } = context.state;
104
+ await Promise.all(kpis.map(async (kpi) => {
105
+ const createdKpi = await (0, shell_1.getRepository)(kpi_1.Kpi, tx).save(Object.assign({ domain }, kpi));
106
+ }));
107
+ return true;
108
+ }
109
+ };
110
+ exports.KpiMutation = KpiMutation;
111
+ tslib_1.__decorate([
112
+ (0, type_graphql_1.Directive)('@transaction'),
113
+ (0, type_graphql_1.Mutation)(returns => kpi_1.Kpi, { description: 'To create new Kpi' }),
114
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('kpi')),
115
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
116
+ tslib_1.__metadata("design:type", Function),
117
+ tslib_1.__metadata("design:paramtypes", [kpi_type_1.NewKpi, Object]),
118
+ tslib_1.__metadata("design:returntype", Promise)
119
+ ], KpiMutation.prototype, "createKpi", null);
120
+ tslib_1.__decorate([
121
+ (0, type_graphql_1.Directive)('@transaction'),
122
+ (0, type_graphql_1.Mutation)(returns => kpi_1.Kpi, { description: 'To modify Kpi information' }),
123
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
124
+ tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
125
+ tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
126
+ tslib_1.__metadata("design:type", Function),
127
+ tslib_1.__metadata("design:paramtypes", [String, kpi_type_1.KpiPatch, Object]),
128
+ tslib_1.__metadata("design:returntype", Promise)
129
+ ], KpiMutation.prototype, "updateKpi", null);
130
+ tslib_1.__decorate([
131
+ (0, type_graphql_1.Directive)('@transaction'),
132
+ (0, type_graphql_1.Mutation)(returns => [kpi_1.Kpi], { description: "To modify multiple Kpis' information" }),
133
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [kpi_type_1.KpiPatch])),
134
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
135
+ tslib_1.__metadata("design:type", Function),
136
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
137
+ tslib_1.__metadata("design:returntype", Promise)
138
+ ], KpiMutation.prototype, "updateMultipleKpi", null);
139
+ tslib_1.__decorate([
140
+ (0, type_graphql_1.Directive)('@transaction'),
141
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete Kpi' }),
142
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
143
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
144
+ tslib_1.__metadata("design:type", Function),
145
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
146
+ tslib_1.__metadata("design:returntype", Promise)
147
+ ], KpiMutation.prototype, "deleteKpi", null);
148
+ tslib_1.__decorate([
149
+ (0, type_graphql_1.Directive)('@transaction'),
150
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple Kpis' }),
151
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
152
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
153
+ tslib_1.__metadata("design:type", Function),
154
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
155
+ tslib_1.__metadata("design:returntype", Promise)
156
+ ], KpiMutation.prototype, "deleteKpis", null);
157
+ tslib_1.__decorate([
158
+ (0, type_graphql_1.Directive)('@transaction'),
159
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple Kpis' }),
160
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('kpis', type => [kpi_type_1.KpiPatch])),
161
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
162
+ tslib_1.__metadata("design:type", Function),
163
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
164
+ tslib_1.__metadata("design:returntype", Promise)
165
+ ], KpiMutation.prototype, "importKpis", null);
166
+ exports.KpiMutation = KpiMutation = tslib_1.__decorate([
167
+ (0, type_graphql_1.Resolver)(kpi_1.Kpi)
168
+ ], KpiMutation);
169
+ //# sourceMappingURL=kpi-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kpi-mutation.js","sourceRoot":"","sources":["../../../server/service/kpi/kpi-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAC5B,iDAAqD;AAErD,qEAA0F;AAC1F,+BAA2B;AAC3B,yCAA6C;AAGtC,IAAM,WAAW,GAAjB,MAAM,WAAW;IAGhB,AAAN,KAAK,CAAC,SAAS,CAAa,GAAW,EAAS,OAAwB;QACtE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAa,EAAC,SAAG,EAAE,EAAE,CAAC,CAAC,IAAI,iCAC3C,GAAG,KACN,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;QAEF,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;YAClB,MAAM,IAAA,kCAAgB,EACpB,IAAI,EACJ;gBACE,UAAU,EAAE;oBACV,IAAI,EAAE,GAAG,CAAC,SAAS;oBACnB,OAAO,EAAE,SAAG,CAAC,IAAI;oBACjB,KAAK,EAAE,MAAM,CAAC,EAAE;iBACjB;aACF,EACD,OAAO,CACR,CAAA;QACH,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;IAIK,AAAN,KAAK,CAAC,SAAS,CACF,EAAU,EACP,KAAe,EACtB,OAAwB;QAE/B,MAAM,EAAE,MAAM,EA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import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\nimport { getRepository } from '@things-factory/shell'\n\nimport { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'\nimport { Kpi } from './kpi'\nimport { NewKpi, KpiPatch } from './kpi-type'\n\n@Resolver(Kpi)\nexport class KpiMutation {\n @Directive('@transaction')\n @Mutation(returns => Kpi, { description: 'To create new Kpi' })\n async createKpi(@Arg('kpi') kpi: NewKpi, @Ctx() context: ResolverContext): Promise<Kpi> {\n const { domain, user, tx } = context.state\n\n const result = await getRepository(Kpi, tx).save({\n ...kpi,\n domain,\n creator: user,\n updater: user\n })\n\n if (kpi.thumbnail) {\n await createAttachment(\n null,\n {\n attachment: {\n file: kpi.thumbnail,\n refType: Kpi.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => Kpi, { description: 'To modify Kpi information' })\n async updateKpi(\n @Arg('id') id: string,\n @Arg('patch') patch: KpiPatch,\n @Ctx() context: ResolverContext\n ): Promise<Kpi> {\n const { domain, user, tx } = context.state\n\n const repository = getRepository(Kpi, tx)\n const kpi = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...kpi,\n ...patch,\n updater: user\n })\n\n if (patch.thumbnail) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: patch.thumbnail,\n refType: Kpi.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => [Kpi], { description: \"To modify multiple Kpis' information\" })\n async updateMultipleKpi(\n @Arg('patches', type => [KpiPatch]) patches: KpiPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Kpi[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const kpiRepo = getRepository(Kpi, tx)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await kpiRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n if (newRecord.thumbnail) {\n await createAttachment(\n null,\n {\n attachment: {\n file: newRecord.thumbnail,\n refType: Kpi.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const kpi = await kpiRepo.findOneBy({ id: updateRecord.id })\n\n const result = await kpiRepo.save({\n ...kpi,\n ...updateRecord,\n updater: user\n })\n\n if (updateRecord.thumbnail) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: updateRecord.thumbnail,\n refType: Kpi.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete Kpi' })\n async deleteKpi(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(Kpi, tx).delete({ domain: { id: domain.id }, id })\n await deleteAttachmentsByRef(null, { refBys: [id] }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple Kpis' })\n async deleteKpis(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(Kpi, tx).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n await deleteAttachmentsByRef(null, { refBys: ids }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To import multiple Kpis' })\n async importKpis(\n @Arg('kpis', type => [KpiPatch]) kpis: KpiPatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n kpis.map(async (kpi: KpiPatch) => {\n const createdKpi: Kpi = await getRepository(Kpi, tx).save({ domain, ...kpi })\n })\n )\n\n return true\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { Domain, ListParam } from '@things-factory/shell';
2
+ import { User } from '@things-factory/auth-base';
3
+ import { Kpi } from './kpi';
4
+ import { KpiList } from './kpi-type';
5
+ export declare class KpiQuery {
6
+ kpi(id: string, context: ResolverContext): Promise<Kpi>;
7
+ kpis(params: ListParam, context: ResolverContext): Promise<KpiList>;
8
+ thumbnail(kpi: Kpi): Promise<string | undefined>;
9
+ domain(kpi: Kpi): Promise<Domain>;
10
+ updater(kpi: Kpi): Promise<User>;
11
+ creator(kpi: Kpi): Promise<User>;
12
+ }
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KpiQuery = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const attachment_base_1 = require("@things-factory/attachment-base");
7
+ const shell_1 = require("@things-factory/shell");
8
+ const auth_base_1 = require("@things-factory/auth-base");
9
+ const kpi_1 = require("./kpi");
10
+ const kpi_type_1 = require("./kpi-type");
11
+ let KpiQuery = class KpiQuery {
12
+ async kpi(id, context) {
13
+ const { domain } = context.state;
14
+ return await (0, shell_1.getRepository)(kpi_1.Kpi).findOne({
15
+ where: { domain: { id: domain.id }, id }
16
+ });
17
+ }
18
+ async kpis(params, context) {
19
+ const { domain } = context.state;
20
+ const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
21
+ domain,
22
+ params,
23
+ repository: await (0, shell_1.getRepository)(kpi_1.Kpi),
24
+ searchables: ['name', 'description']
25
+ });
26
+ const [items, total] = await queryBuilder.getManyAndCount();
27
+ return { items, total };
28
+ }
29
+ async thumbnail(kpi) {
30
+ const attachment = await (0, shell_1.getRepository)(attachment_base_1.Attachment).findOne({
31
+ where: {
32
+ domain: { id: kpi.domainId },
33
+ refType: kpi_1.Kpi.name,
34
+ refBy: kpi.id
35
+ }
36
+ });
37
+ return attachment === null || attachment === void 0 ? void 0 : attachment.fullpath;
38
+ }
39
+ async domain(kpi) {
40
+ return kpi.domainId && (await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: kpi.domainId }));
41
+ }
42
+ async updater(kpi) {
43
+ return kpi.updaterId && (await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: kpi.updaterId }));
44
+ }
45
+ async creator(kpi) {
46
+ return kpi.creatorId && (await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: kpi.creatorId }));
47
+ }
48
+ };
49
+ exports.KpiQuery = KpiQuery;
50
+ tslib_1.__decorate([
51
+ (0, type_graphql_1.Query)(returns => kpi_1.Kpi, { nullable: true, description: 'To fetch a Kpi' }),
52
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
53
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
54
+ tslib_1.__metadata("design:type", Function),
55
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
56
+ tslib_1.__metadata("design:returntype", Promise)
57
+ ], KpiQuery.prototype, "kpi", null);
58
+ tslib_1.__decorate([
59
+ (0, type_graphql_1.Query)(returns => kpi_type_1.KpiList, { description: 'To fetch multiple Kpis' }),
60
+ tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
61
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
62
+ tslib_1.__metadata("design:type", Function),
63
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
64
+ tslib_1.__metadata("design:returntype", Promise)
65
+ ], KpiQuery.prototype, "kpis", null);
66
+ tslib_1.__decorate([
67
+ (0, type_graphql_1.FieldResolver)(type => String),
68
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
69
+ tslib_1.__metadata("design:type", Function),
70
+ tslib_1.__metadata("design:paramtypes", [kpi_1.Kpi]),
71
+ tslib_1.__metadata("design:returntype", Promise)
72
+ ], KpiQuery.prototype, "thumbnail", null);
73
+ tslib_1.__decorate([
74
+ (0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
75
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
76
+ tslib_1.__metadata("design:type", Function),
77
+ tslib_1.__metadata("design:paramtypes", [kpi_1.Kpi]),
78
+ tslib_1.__metadata("design:returntype", Promise)
79
+ ], KpiQuery.prototype, "domain", null);
80
+ tslib_1.__decorate([
81
+ (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
82
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
83
+ tslib_1.__metadata("design:type", Function),
84
+ tslib_1.__metadata("design:paramtypes", [kpi_1.Kpi]),
85
+ tslib_1.__metadata("design:returntype", Promise)
86
+ ], KpiQuery.prototype, "updater", null);
87
+ tslib_1.__decorate([
88
+ (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
89
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
90
+ tslib_1.__metadata("design:type", Function),
91
+ tslib_1.__metadata("design:paramtypes", [kpi_1.Kpi]),
92
+ tslib_1.__metadata("design:returntype", Promise)
93
+ ], KpiQuery.prototype, "creator", null);
94
+ exports.KpiQuery = KpiQuery = tslib_1.__decorate([
95
+ (0, type_graphql_1.Resolver)(kpi_1.Kpi)
96
+ ], KpiQuery);
97
+ //# sourceMappingURL=kpi-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kpi-query.js","sourceRoot":"","sources":["../../../server/service/kpi/kpi-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,qEAA4D;AAC5D,iDAAuG;AACvG,yDAAgD;AAChD,+BAA2B;AAC3B,yCAAoC;AAG7B,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAEb,AAAN,KAAK,CAAC,GAAG,CAAY,EAAU,EAAS,OAAwB;QAC9D,MAAM,EAAE,MAAM,EA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B;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,SAAG;;uCAE7B;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,SAAG;;uCAE7B;mBApDU,QAAQ;IADpB,IAAA,uBAAQ,EAAC,SAAG,CAAC;GACD,QAAQ,CAqDpB","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'\nimport { Attachment } from '@things-factory/attachment-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Kpi } from './kpi'\nimport { KpiList } from './kpi-type'\n\n@Resolver(Kpi)\nexport class KpiQuery {\n @Query(returns => Kpi!, { nullable: true, description: 'To fetch a Kpi' })\n async kpi(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Kpi> {\n const { domain } = context.state\n\n return await getRepository(Kpi).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Query(returns => KpiList, { description: 'To fetch multiple Kpis' })\n async kpis(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<KpiList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(Kpi),\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => String)\n async thumbnail(@Root() kpi: Kpi): Promise<string | undefined> {\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: {\n domain: { id: kpi.domainId },\n refType: Kpi.name,\n refBy: kpi.id\n }\n })\n\n return attachment?.fullpath\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() kpi: Kpi): Promise<Domain> {\n return kpi.domainId && (await getRepository(Domain).findOneBy({ id: kpi.domainId }))\n }\n\n @FieldResolver(type => User)\n async updater(@Root() kpi: Kpi): Promise<User> {\n return kpi.updaterId && (await getRepository(User).findOneBy({ id: kpi.updaterId }))\n }\n\n @FieldResolver(type => User)\n async creator(@Root() kpi: Kpi): Promise<User> {\n return kpi.creatorId && (await getRepository(User).findOneBy({ id: kpi.creatorId }))\n }\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import type { FileUpload } from 'graphql-upload/GraphQLUpload.js';
2
+ import { Kpi, KpiStatus } from './kpi';
3
+ export declare class NewKpi {
4
+ name: string;
5
+ description?: string;
6
+ state?: KpiStatus;
7
+ active?: boolean;
8
+ params?: string;
9
+ thumbnail?: FileUpload;
10
+ }
11
+ export declare class KpiPatch {
12
+ id?: string;
13
+ name?: string;
14
+ description?: string;
15
+ state?: KpiStatus;
16
+ active?: boolean;
17
+ thumbnail?: FileUpload;
18
+ cuFlag?: string;
19
+ }
20
+ export declare class KpiList {
21
+ items: Kpi[];
22
+ total: number;
23
+ }
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KpiList = exports.KpiPatch = exports.NewKpi = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const GraphQLUpload_js_1 = tslib_1.__importDefault(require("graphql-upload/GraphQLUpload.js"));
6
+ const type_graphql_1 = require("type-graphql");
7
+ const kpi_1 = require("./kpi");
8
+ let NewKpi = class NewKpi {
9
+ };
10
+ exports.NewKpi = NewKpi;
11
+ tslib_1.__decorate([
12
+ (0, type_graphql_1.Field)(),
13
+ tslib_1.__metadata("design:type", String)
14
+ ], NewKpi.prototype, "name", void 0);
15
+ tslib_1.__decorate([
16
+ (0, type_graphql_1.Field)({ nullable: true }),
17
+ tslib_1.__metadata("design:type", String)
18
+ ], NewKpi.prototype, "description", void 0);
19
+ tslib_1.__decorate([
20
+ (0, type_graphql_1.Field)(type => kpi_1.KpiStatus, { nullable: true }),
21
+ tslib_1.__metadata("design:type", String)
22
+ ], NewKpi.prototype, "state", void 0);
23
+ tslib_1.__decorate([
24
+ (0, type_graphql_1.Field)({ nullable: true }),
25
+ tslib_1.__metadata("design:type", Boolean)
26
+ ], NewKpi.prototype, "active", void 0);
27
+ tslib_1.__decorate([
28
+ (0, type_graphql_1.Field)({ nullable: true }),
29
+ tslib_1.__metadata("design:type", String)
30
+ ], NewKpi.prototype, "params", void 0);
31
+ tslib_1.__decorate([
32
+ (0, type_graphql_1.Field)(type => GraphQLUpload_js_1.default, { nullable: true }),
33
+ tslib_1.__metadata("design:type", Object)
34
+ ], NewKpi.prototype, "thumbnail", void 0);
35
+ exports.NewKpi = NewKpi = tslib_1.__decorate([
36
+ (0, type_graphql_1.InputType)()
37
+ ], NewKpi);
38
+ let KpiPatch = class KpiPatch {
39
+ };
40
+ exports.KpiPatch = KpiPatch;
41
+ tslib_1.__decorate([
42
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true }),
43
+ tslib_1.__metadata("design:type", String)
44
+ ], KpiPatch.prototype, "id", void 0);
45
+ tslib_1.__decorate([
46
+ (0, type_graphql_1.Field)({ nullable: true }),
47
+ tslib_1.__metadata("design:type", String)
48
+ ], KpiPatch.prototype, "name", void 0);
49
+ tslib_1.__decorate([
50
+ (0, type_graphql_1.Field)({ nullable: true }),
51
+ tslib_1.__metadata("design:type", String)
52
+ ], KpiPatch.prototype, "description", void 0);
53
+ tslib_1.__decorate([
54
+ (0, type_graphql_1.Field)(type => kpi_1.KpiStatus, { nullable: true }),
55
+ tslib_1.__metadata("design:type", String)
56
+ ], KpiPatch.prototype, "state", void 0);
57
+ tslib_1.__decorate([
58
+ (0, type_graphql_1.Field)({ nullable: true }),
59
+ tslib_1.__metadata("design:type", Boolean)
60
+ ], KpiPatch.prototype, "active", void 0);
61
+ tslib_1.__decorate([
62
+ (0, type_graphql_1.Field)(type => GraphQLUpload_js_1.default, { nullable: true }),
63
+ tslib_1.__metadata("design:type", Object)
64
+ ], KpiPatch.prototype, "thumbnail", void 0);
65
+ tslib_1.__decorate([
66
+ (0, type_graphql_1.Field)({ nullable: true }),
67
+ tslib_1.__metadata("design:type", String)
68
+ ], KpiPatch.prototype, "cuFlag", void 0);
69
+ exports.KpiPatch = KpiPatch = tslib_1.__decorate([
70
+ (0, type_graphql_1.InputType)()
71
+ ], KpiPatch);
72
+ let KpiList = class KpiList {
73
+ };
74
+ exports.KpiList = KpiList;
75
+ tslib_1.__decorate([
76
+ (0, type_graphql_1.Field)(type => [kpi_1.Kpi]),
77
+ tslib_1.__metadata("design:type", Array)
78
+ ], KpiList.prototype, "items", void 0);
79
+ tslib_1.__decorate([
80
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int),
81
+ tslib_1.__metadata("design:type", Number)
82
+ ], KpiList.prototype, "total", void 0);
83
+ exports.KpiList = KpiList = tslib_1.__decorate([
84
+ (0, type_graphql_1.ObjectType)()
85
+ ], KpiList);
86
+ //# sourceMappingURL=kpi-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kpi-type.js","sourceRoot":"","sources":["../../../server/service/kpi/kpi-type.ts"],"names":[],"mappings":";;;;AACA,+FAA2D;AAC3D,+CAAsF;AAItF,+BAAsC;AAG/B,IAAM,MAAM,GAAZ,MAAM,MAAM;CAkBlB,CAAA;AAlBY,wBAAM;AAEjB;IADC,IAAA,oBAAK,GAAE;;oCACI;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACN;AAGpB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,eAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qCAC5B;AAGjB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sCACV;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;sCACX;AAGf;IADC,IAAA,oBAAK,EAAC,IAAI,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.js'\nimport GraphQLUpload from 'graphql-upload/GraphQLUpload.js'\nimport { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'\n\nimport { ObjectRef, ScalarObject } from '@things-factory/shell'\n\nimport { Kpi, KpiStatus } from './kpi'\n\n@InputType()\nexport class NewKpi {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field(type => KpiStatus, { nullable: true })\n state?: KpiStatus\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true })\n params?: string\n\n @Field(type => GraphQLUpload, { nullable: true })\n thumbnail?: FileUpload\n}\n\n@InputType()\nexport class KpiPatch {\n @Field(type => ID, { nullable: true })\n id?: string\n\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field(type => KpiStatus, { nullable: true })\n state?: KpiStatus\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field(type => GraphQLUpload, { nullable: true })\n thumbnail?: FileUpload\n \n @Field({ nullable: true })\n cuFlag?: string\n}\n\n@ObjectType()\nexport class KpiList {\n @Field(type => [Kpi])\n items: Kpi[]\n\n @Field(type => Int)\n total: number\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import { Domain } from '@things-factory/shell';
2
+ import { User } from '@things-factory/auth-base';
3
+ export declare enum KpiStatus {
4
+ STATUS_A = "STATUS_A",
5
+ STATUS_B = "STATUS_B"
6
+ }
7
+ export declare class Kpi {
8
+ readonly id: string;
9
+ version?: number;
10
+ domain?: Domain;
11
+ domainId?: string;
12
+ name?: string;
13
+ description?: string;
14
+ active?: boolean;
15
+ state?: KpiStatus;
16
+ params?: string;
17
+ createdAt?: Date;
18
+ updatedAt?: Date;
19
+ deletedAt?: Date;
20
+ creator?: User;
21
+ creatorId?: string;
22
+ updater?: User;
23
+ updaterId?: string;
24
+ thumbnail?: string;
25
+ }