@things-factory/kpi 9.0.31 → 9.0.33

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 (365) hide show
  1. package/README.md +1 -2
  2. package/client/charts/kpi-boxplot-chart.ts +182 -42
  3. package/client/charts/kpi-radar-chart.ts +9 -9
  4. package/client/pages/kpi/kpi-list-page.ts +196 -32
  5. package/client/pages/kpi/kpi-overview.ts +9 -11
  6. package/client/pages/kpi/kpi-tree-page.ts +409 -0
  7. package/client/pages/kpi/kpi-view.ts +187 -0
  8. package/client/pages/kpi-dashboard/cards/kpi-level1-card.ts +1 -1
  9. package/client/pages/kpi-dashboard/cards/kpi-level2-comparison.ts +1 -1
  10. package/client/pages/kpi-dashboard/cards/kpi-level3-comparison.ts +1 -1
  11. package/client/pages/kpi-dashboard/components/kpi-left-panel.ts +198 -160
  12. package/client/pages/kpi-dashboard/components/kpi-map-panel.ts +133 -0
  13. package/client/pages/kpi-dashboard/components/kpi-region-popup.ts +3 -2
  14. package/client/pages/kpi-dashboard/kpi-dashboard-map.ts +291 -48
  15. package/client/pages/kpi-dashboard/kpi-dashboard.ts +28 -30
  16. package/client/pages/kpi-history/kpi-history-list-page.ts +11 -11
  17. package/client/pages/kpi-metric/kpi-metric-list-page.ts +10 -2
  18. package/client/pages/kpi-metric-value/kpi-metric-value-editor-page.ts +7 -7
  19. package/client/pages/kpi-metric-value/kpi-metric-value-importer.ts +2 -2
  20. package/client/pages/kpi-metric-value/kpi-metric-value-list-page.ts +16 -8
  21. package/client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.ts +5 -5
  22. package/client/pages/kpi-statistic/kpi-statistic-editor-page.ts +1 -2
  23. package/client/pages/kpi-statistic/kpi-statistic-list-page.ts +10 -2
  24. package/client/pages/kpi-value/kpi-value-editor-page.ts +11 -7
  25. package/client/pages/kpi-value/kpi-value-list-page.ts +31 -7
  26. package/client/route.ts +2 -9
  27. package/design-entities.md +8 -12
  28. package/dist-client/charts/kpi-boxplot-chart.d.ts +2 -0
  29. package/dist-client/charts/kpi-boxplot-chart.js +168 -42
  30. package/dist-client/charts/kpi-boxplot-chart.js.map +1 -1
  31. package/dist-client/charts/kpi-radar-chart.js +9 -9
  32. package/dist-client/charts/kpi-radar-chart.js.map +1 -1
  33. package/dist-client/pages/kpi/kpi-list-page.d.ts +19 -3
  34. package/dist-client/pages/kpi/kpi-list-page.js +188 -32
  35. package/dist-client/pages/kpi/kpi-list-page.js.map +1 -1
  36. package/dist-client/pages/kpi/kpi-overview.js +9 -11
  37. package/dist-client/pages/kpi/kpi-overview.js.map +1 -1
  38. package/dist-client/pages/kpi/kpi-tree-page.d.ts +59 -0
  39. package/dist-client/pages/kpi/kpi-tree-page.js +403 -0
  40. package/dist-client/pages/kpi/kpi-tree-page.js.map +1 -0
  41. package/dist-client/pages/kpi/kpi-view.d.ts +12 -0
  42. package/dist-client/pages/kpi/kpi-view.js +191 -0
  43. package/dist-client/pages/kpi/kpi-view.js.map +1 -0
  44. package/dist-client/pages/kpi-dashboard/cards/kpi-level1-card.js +1 -1
  45. package/dist-client/pages/kpi-dashboard/cards/kpi-level1-card.js.map +1 -1
  46. package/dist-client/pages/kpi-dashboard/cards/kpi-level2-comparison.js +1 -1
  47. package/dist-client/pages/kpi-dashboard/cards/kpi-level2-comparison.js.map +1 -1
  48. package/dist-client/pages/kpi-dashboard/cards/kpi-level3-comparison.js +1 -1
  49. package/dist-client/pages/kpi-dashboard/cards/kpi-level3-comparison.js.map +1 -1
  50. package/dist-client/pages/kpi-dashboard/components/kpi-left-panel.d.ts +3 -1
  51. package/dist-client/pages/kpi-dashboard/components/kpi-left-panel.js +197 -161
  52. package/dist-client/pages/kpi-dashboard/components/kpi-left-panel.js.map +1 -1
  53. package/dist-client/pages/kpi-dashboard/components/kpi-map-panel.d.ts +5 -0
  54. package/dist-client/pages/kpi-dashboard/components/kpi-map-panel.js +146 -0
  55. package/dist-client/pages/kpi-dashboard/components/kpi-map-panel.js.map +1 -1
  56. package/dist-client/pages/kpi-dashboard/components/kpi-region-popup.js +3 -2
  57. package/dist-client/pages/kpi-dashboard/components/kpi-region-popup.js.map +1 -1
  58. package/dist-client/pages/kpi-dashboard/kpi-dashboard-map.d.ts +3 -1
  59. package/dist-client/pages/kpi-dashboard/kpi-dashboard-map.js +268 -46
  60. package/dist-client/pages/kpi-dashboard/kpi-dashboard-map.js.map +1 -1
  61. package/dist-client/pages/kpi-dashboard/kpi-dashboard.js +28 -30
  62. package/dist-client/pages/kpi-dashboard/kpi-dashboard.js.map +1 -1
  63. package/dist-client/pages/kpi-history/kpi-history-list-page.d.ts +6 -1
  64. package/dist-client/pages/kpi-history/kpi-history-list-page.js +11 -11
  65. package/dist-client/pages/kpi-history/kpi-history-list-page.js.map +1 -1
  66. package/dist-client/pages/kpi-metric/kpi-metric-list-page.d.ts +5 -0
  67. package/dist-client/pages/kpi-metric/kpi-metric-list-page.js +10 -2
  68. package/dist-client/pages/kpi-metric/kpi-metric-list-page.js.map +1 -1
  69. package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.d.ts +1 -1
  70. package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.js +8 -8
  71. package/dist-client/pages/kpi-metric-value/kpi-metric-value-editor-page.js.map +1 -1
  72. package/dist-client/pages/kpi-metric-value/kpi-metric-value-importer.js +2 -2
  73. package/dist-client/pages/kpi-metric-value/kpi-metric-value-importer.js.map +1 -1
  74. package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.d.ts +5 -0
  75. package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.js +16 -8
  76. package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.js.map +1 -1
  77. package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.d.ts +1 -1
  78. package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.js +6 -6
  79. package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.js.map +1 -1
  80. package/dist-client/pages/kpi-statistic/kpi-statistic-editor-page.js +1 -2
  81. package/dist-client/pages/kpi-statistic/kpi-statistic-editor-page.js.map +1 -1
  82. package/dist-client/pages/kpi-statistic/kpi-statistic-list-page.d.ts +5 -0
  83. package/dist-client/pages/kpi-statistic/kpi-statistic-list-page.js +10 -2
  84. package/dist-client/pages/kpi-statistic/kpi-statistic-list-page.js.map +1 -1
  85. package/dist-client/pages/kpi-value/kpi-value-editor-page.d.ts +2 -1
  86. package/dist-client/pages/kpi-value/kpi-value-editor-page.js +16 -8
  87. package/dist-client/pages/kpi-value/kpi-value-editor-page.js.map +1 -1
  88. package/dist-client/pages/kpi-value/kpi-value-list-page.d.ts +5 -0
  89. package/dist-client/pages/kpi-value/kpi-value-list-page.js +31 -7
  90. package/dist-client/pages/kpi-value/kpi-value-list-page.js.map +1 -1
  91. package/dist-client/route.d.ts +1 -1
  92. package/dist-client/route.js +2 -8
  93. package/dist-client/route.js.map +1 -1
  94. package/dist-client/tsconfig.tsbuildinfo +1 -1
  95. package/dist-server/controllers/kpi-metric-value-provider.d.ts +1 -1
  96. package/dist-server/controllers/kpi-metric-value-provider.js +4 -4
  97. package/dist-server/controllers/kpi-metric-value-provider.js.map +1 -1
  98. package/dist-server/controllers/kpi-value-provider.d.ts +1 -1
  99. package/dist-server/controllers/kpi-value-provider.js +3 -3
  100. package/dist-server/controllers/kpi-value-provider.js.map +1 -1
  101. package/dist-server/migrations/1752190849680-seed-kpi-metrics.d.ts +6 -0
  102. package/dist-server/migrations/1752190849680-seed-kpi-metrics.js +101 -0
  103. package/dist-server/migrations/1752190849680-seed-kpi-metrics.js.map +1 -0
  104. package/dist-server/migrations/1752190849681-seed-kpi.d.ts +5 -0
  105. package/dist-server/migrations/1752190849681-seed-kpi.js +315 -0
  106. package/dist-server/migrations/1752190849681-seed-kpi.js.map +1 -0
  107. package/dist-server/migrations/1752192090123-add-grades-to-kpi.d.ts +7 -0
  108. package/dist-server/migrations/1752192090123-add-grades-to-kpi.js +51 -0
  109. package/dist-server/migrations/1752192090123-add-grades-to-kpi.js.map +1 -0
  110. package/dist-server/migrations/1752192090124-add-kpi-statistics.d.ts +5 -0
  111. package/dist-server/migrations/1752192090124-add-kpi-statistics.js +710 -0
  112. package/dist-server/migrations/1752192090124-add-kpi-statistics.js.map +1 -0
  113. package/dist-server/migrations/1752192090128-seed-kpi-org-scope.d.ts +6 -0
  114. package/dist-server/migrations/1752192090128-seed-kpi-org-scope.js +111 -0
  115. package/dist-server/migrations/1752192090128-seed-kpi-org-scope.js.map +1 -0
  116. package/dist-server/migrations/1752192090129-seed-kpi-values.d.ts +6 -0
  117. package/dist-server/migrations/1752192090129-seed-kpi-values.js +187 -0
  118. package/dist-server/migrations/1752192090129-seed-kpi-values.js.map +1 -0
  119. package/dist-server/migrations/grade-data/x11-performance-table.json +962 -0
  120. package/dist-server/migrations/grade-data/x12-performance-table.json +611 -0
  121. package/dist-server/migrations/grade-data/x14-performance-table.json +42 -0
  122. package/dist-server/migrations/grade-data/x21-performance-table.json +889 -0
  123. package/dist-server/migrations/grade-data/x22-performance-table.json +1064 -0
  124. package/dist-server/migrations/grade-data/x23-performance-table.json +42 -0
  125. package/dist-server/migrations/grade-data/x31-performance-table.json +644 -0
  126. package/dist-server/migrations/grade-data/x32-performance-table.json +993 -0
  127. package/dist-server/migrations/grade-data/x33-performance-table.json +195 -0
  128. package/dist-server/migrations/grade-data/x34-performance-table.json +12 -0
  129. package/dist-server/migrations/grade-data/x35-performance-table.json +42 -0
  130. package/dist-server/migrations/grade-data/x41-performance-table.json +825 -0
  131. package/dist-server/migrations/grade-data/x42-performance-table.json +786 -0
  132. package/dist-server/migrations/grade-data/x43-performance-table.json +12 -0
  133. package/dist-server/migrations/grade-data/x44-performance-table.json +42 -0
  134. package/dist-server/migrations/grade-data/x51-performance-table.json +924 -0
  135. package/dist-server/migrations/grade-data/x52-performance-table.json +42 -0
  136. package/dist-server/migrations/grade-data/x61-performance-table.json +261 -0
  137. package/dist-server/migrations/grade-data/x62-performance-table.json +42 -0
  138. package/dist-server/migrations/seed-data/kpi-metrics-seed.json +454 -0
  139. package/dist-server/migrations/seed-data/kpi-org-scope-seed.json +1676 -0
  140. package/dist-server/migrations/seed-data/kpi-scopes-seed.json +121 -0
  141. package/dist-server/migrations/seed-data/kpi-values-seed.json +402 -0
  142. package/dist-server/migrations/seed-data/kpis-seed.json +488 -0
  143. package/dist-server/migrations/seed-data/scope-definitions-seed.json +90 -0
  144. package/dist-server/service/index.d.ts +4 -7
  145. package/dist-server/service/index.js +10 -13
  146. package/dist-server/service/index.js.map +1 -1
  147. package/dist-server/service/kpi/aggregate-kpi.js +30 -13
  148. package/dist-server/service/kpi/aggregate-kpi.js.map +1 -1
  149. package/dist-server/service/kpi/kpi-formula.service.d.ts +15 -0
  150. package/dist-server/service/kpi/kpi-formula.service.js +90 -0
  151. package/dist-server/service/kpi/kpi-formula.service.js.map +1 -1
  152. package/dist-server/service/kpi/kpi-history.d.ts +0 -3
  153. package/dist-server/service/kpi/kpi-history.js +0 -10
  154. package/dist-server/service/kpi/kpi-history.js.map +1 -1
  155. package/dist-server/service/kpi/kpi-mutation.d.ts +1 -1
  156. package/dist-server/service/kpi/kpi-mutation.js +57 -20
  157. package/dist-server/service/kpi/kpi-mutation.js.map +1 -1
  158. package/dist-server/service/kpi/kpi-query.d.ts +7 -3
  159. package/dist-server/service/kpi/kpi-query.js +126 -10
  160. package/dist-server/service/kpi/kpi-query.js.map +1 -1
  161. package/dist-server/service/kpi/kpi-type.d.ts +4 -2
  162. package/dist-server/service/kpi/kpi-type.js +12 -4
  163. package/dist-server/service/kpi/kpi-type.js.map +1 -1
  164. package/dist-server/service/kpi/kpi.d.ts +4 -3
  165. package/dist-server/service/kpi/kpi.js +20 -8
  166. package/dist-server/service/kpi/kpi.js.map +1 -1
  167. package/dist-server/service/kpi-metric/aggregate-kpi-metric.js +46 -11
  168. package/dist-server/service/kpi-metric/aggregate-kpi-metric.js.map +1 -1
  169. package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.d.ts +1 -1
  170. package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.js +6 -6
  171. package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.js.map +1 -1
  172. package/dist-server/service/kpi-metric-value/kpi-metric-value-type.d.ts +2 -2
  173. package/dist-server/service/kpi-metric-value/kpi-metric-value-type.js +4 -4
  174. package/dist-server/service/kpi-metric-value/kpi-metric-value-type.js.map +1 -1
  175. package/dist-server/service/kpi-metric-value/kpi-metric-value.d.ts +1 -1
  176. package/dist-server/service/kpi-metric-value/kpi-metric-value.js +3 -3
  177. package/dist-server/service/kpi-metric-value/kpi-metric-value.js.map +1 -1
  178. package/dist-server/service/kpi-org-scope/index.d.ts +5 -0
  179. package/dist-server/service/kpi-org-scope/index.js +9 -0
  180. package/dist-server/service/kpi-org-scope/index.js.map +1 -0
  181. package/dist-server/service/kpi-org-scope/kpi-org-scope-mutation.d.ts +8 -0
  182. package/dist-server/service/kpi-org-scope/kpi-org-scope-mutation.js +170 -0
  183. package/dist-server/service/kpi-org-scope/kpi-org-scope-mutation.js.map +1 -0
  184. package/dist-server/service/kpi-org-scope/kpi-org-scope-query.d.ts +14 -0
  185. package/dist-server/service/kpi-org-scope/kpi-org-scope-query.js +152 -0
  186. package/dist-server/service/kpi-org-scope/kpi-org-scope-query.js.map +1 -0
  187. package/dist-server/service/kpi-org-scope/kpi-org-scope-type.d.ts +26 -0
  188. package/dist-server/service/kpi-org-scope/kpi-org-scope-type.js +101 -0
  189. package/dist-server/service/kpi-org-scope/kpi-org-scope-type.js.map +1 -0
  190. package/dist-server/service/kpi-org-scope/kpi-org-scope.d.ts +26 -0
  191. package/dist-server/service/kpi-org-scope/kpi-org-scope.js +135 -0
  192. package/dist-server/service/kpi-org-scope/kpi-org-scope.js.map +1 -0
  193. package/dist-server/service/kpi-scope/index.d.ts +9 -0
  194. package/dist-server/service/kpi-scope/index.js +14 -0
  195. package/dist-server/service/kpi-scope/index.js.map +1 -0
  196. package/dist-server/service/kpi-scope/kpi-scope-mutation.d.ts +9 -0
  197. package/dist-server/service/kpi-scope/kpi-scope-mutation.js +135 -0
  198. package/dist-server/service/kpi-scope/kpi-scope-mutation.js.map +1 -0
  199. package/dist-server/service/kpi-scope/kpi-scope-query.d.ts +11 -0
  200. package/dist-server/service/kpi-scope/kpi-scope-query.js +89 -0
  201. package/dist-server/service/kpi-scope/kpi-scope-query.js.map +1 -0
  202. package/dist-server/service/kpi-scope/kpi-scope-type.d.ts +35 -0
  203. package/dist-server/service/kpi-scope/kpi-scope-type.js +138 -0
  204. package/dist-server/service/kpi-scope/kpi-scope-type.js.map +1 -0
  205. package/dist-server/service/kpi-scope/kpi-scope.d.ts +38 -0
  206. package/dist-server/service/kpi-scope/kpi-scope.js +144 -0
  207. package/dist-server/service/kpi-scope/kpi-scope.js.map +1 -0
  208. package/dist-server/service/kpi-statistic/kpi-statistic-batch.service.d.ts +43 -0
  209. package/dist-server/service/kpi-statistic/kpi-statistic-batch.service.js +181 -0
  210. package/dist-server/service/kpi-statistic/kpi-statistic-batch.service.js.map +1 -0
  211. package/dist-server/service/kpi-statistic/kpi-statistic-calculation.service.d.ts +50 -0
  212. package/dist-server/service/kpi-statistic/kpi-statistic-calculation.service.js +324 -0
  213. package/dist-server/service/kpi-statistic/kpi-statistic-calculation.service.js.map +1 -0
  214. package/dist-server/service/kpi-statistic/kpi-statistic-mutation.d.ts +4 -0
  215. package/dist-server/service/kpi-statistic/kpi-statistic-mutation.js +76 -0
  216. package/dist-server/service/kpi-statistic/kpi-statistic-mutation.js.map +1 -1
  217. package/dist-server/service/kpi-statistic/kpi-statistic-query.d.ts +5 -1
  218. package/dist-server/service/kpi-statistic/kpi-statistic-query.js +92 -1
  219. package/dist-server/service/kpi-statistic/kpi-statistic-query.js.map +1 -1
  220. package/dist-server/service/kpi-statistic/kpi-statistic.d.ts +4 -0
  221. package/dist-server/service/kpi-statistic/kpi-statistic.js +33 -0
  222. package/dist-server/service/kpi-statistic/kpi-statistic.js.map +1 -1
  223. package/dist-server/service/kpi-value/kpi-value-mutation.js +71 -7
  224. package/dist-server/service/kpi-value/kpi-value-mutation.js.map +1 -1
  225. package/dist-server/service/kpi-value/kpi-value-type.d.ts +4 -2
  226. package/dist-server/service/kpi-value/kpi-value-type.js +12 -4
  227. package/dist-server/service/kpi-value/kpi-value-type.js.map +1 -1
  228. package/dist-server/service/kpi-value/kpi-value.d.ts +3 -1
  229. package/dist-server/service/kpi-value/kpi-value.js +11 -5
  230. package/dist-server/service/kpi-value/kpi-value.js.map +1 -1
  231. package/dist-server/service/utils/value-date-util.d.ts +1 -0
  232. package/dist-server/service/utils/value-date-util.js +41 -0
  233. package/dist-server/service/utils/value-date-util.js.map +1 -1
  234. package/dist-server/tsconfig.json +10 -0
  235. package/dist-server/tsconfig.tsbuildinfo +1 -1
  236. package/package.json +7 -6
  237. package/server/@types/index.d.ts +11 -0
  238. package/server/controllers/kpi-metric-value-provider.ts +5 -5
  239. package/server/controllers/kpi-value-provider.ts +4 -4
  240. package/server/migrations/1752190849680-seed-kpi-metrics.ts +124 -0
  241. package/server/migrations/1752190849681-seed-kpi.ts +356 -0
  242. package/server/migrations/1752192090123-add-grades-to-kpi.ts +67 -0
  243. package/server/migrations/1752192090124-add-kpi-statistics.ts +719 -0
  244. package/server/migrations/1752192090128-seed-kpi-org-scope.ts +132 -0
  245. package/server/migrations/1752192090129-seed-kpi-values.ts +207 -0
  246. package/server/migrations/grade-data/x11-performance-table.json +962 -0
  247. package/server/migrations/grade-data/x12-performance-table.json +611 -0
  248. package/server/migrations/grade-data/x14-performance-table.json +42 -0
  249. package/server/migrations/grade-data/x21-performance-table.json +889 -0
  250. package/server/migrations/grade-data/x22-performance-table.json +1064 -0
  251. package/server/migrations/grade-data/x23-performance-table.json +42 -0
  252. package/server/migrations/grade-data/x31-performance-table.json +644 -0
  253. package/server/migrations/grade-data/x32-performance-table.json +993 -0
  254. package/server/migrations/grade-data/x33-performance-table.json +195 -0
  255. package/server/migrations/grade-data/x34-performance-table.json +12 -0
  256. package/server/migrations/grade-data/x35-performance-table.json +42 -0
  257. package/server/migrations/grade-data/x41-performance-table.json +825 -0
  258. package/server/migrations/grade-data/x42-performance-table.json +786 -0
  259. package/server/migrations/grade-data/x43-performance-table.json +12 -0
  260. package/server/migrations/grade-data/x44-performance-table.json +42 -0
  261. package/server/migrations/grade-data/x51-performance-table.json +924 -0
  262. package/server/migrations/grade-data/x52-performance-table.json +42 -0
  263. package/server/migrations/grade-data/x61-performance-table.json +261 -0
  264. package/server/migrations/grade-data/x62-performance-table.json +42 -0
  265. package/server/migrations/seed-data/kpi-metrics-seed.json +454 -0
  266. package/server/migrations/seed-data/kpi-org-scope-seed.json +1676 -0
  267. package/server/migrations/seed-data/kpi-scopes-seed.json +121 -0
  268. package/server/migrations/seed-data/kpi-values-seed.json +402 -0
  269. package/server/migrations/seed-data/kpis-seed.json +488 -0
  270. package/server/migrations/seed-data/scope-definitions-seed.json +90 -0
  271. package/server/service/index.ts +10 -13
  272. package/server/service/kpi/aggregate-kpi.ts +31 -13
  273. package/server/service/kpi/kpi-formula.service.ts +101 -0
  274. package/server/service/kpi/kpi-history.ts +0 -8
  275. package/server/service/kpi/kpi-mutation.ts +59 -19
  276. package/server/service/kpi/kpi-query.ts +119 -8
  277. package/server/service/kpi/kpi-type.ts +10 -4
  278. package/server/service/kpi/kpi.ts +17 -7
  279. package/server/service/kpi-metric/aggregate-kpi-metric.ts +55 -11
  280. package/server/service/kpi-metric-value/kpi-metric-value-mutation.ts +6 -6
  281. package/server/service/kpi-metric-value/kpi-metric-value-type.ts +4 -4
  282. package/server/service/kpi-metric-value/kpi-metric-value.ts +3 -3
  283. package/server/service/kpi-org-scope/index.ts +6 -0
  284. package/server/service/kpi-org-scope/kpi-org-scope-mutation.ts +173 -0
  285. package/server/service/kpi-org-scope/kpi-org-scope-query.ts +127 -0
  286. package/server/service/kpi-org-scope/kpi-org-scope-type.ts +68 -0
  287. package/server/service/kpi-org-scope/kpi-org-scope.ts +123 -0
  288. package/server/service/kpi-scope/index.ts +11 -0
  289. package/server/service/kpi-scope/kpi-scope-mutation.ts +129 -0
  290. package/server/service/kpi-scope/kpi-scope-query.ts +63 -0
  291. package/server/service/kpi-scope/kpi-scope-type.ts +96 -0
  292. package/server/service/kpi-scope/kpi-scope.ts +143 -0
  293. package/server/service/kpi-statistic/kpi-statistic-batch.service.ts +231 -0
  294. package/server/service/kpi-statistic/kpi-statistic-calculation.service.ts +410 -0
  295. package/server/service/kpi-statistic/kpi-statistic-mutation.ts +97 -0
  296. package/server/service/kpi-statistic/kpi-statistic-query.ts +89 -2
  297. package/server/service/kpi-statistic/kpi-statistic.ts +32 -0
  298. package/server/service/kpi-value/kpi-value-mutation.ts +73 -7
  299. package/server/service/kpi-value/kpi-value-type.ts +10 -4
  300. package/server/service/kpi-value/kpi-value.ts +10 -5
  301. package/server/service/utils/value-date-util.ts +47 -0
  302. package/server/types/global.d.ts +8 -0
  303. package/things-factory.config.js +1 -0
  304. package/translations/en.json +15 -3
  305. package/translations/ja.json +13 -3
  306. package/translations/ko.json +15 -3
  307. package/translations/ms.json +13 -3
  308. package/translations/zh.json +13 -3
  309. package/client/pages/kpi-category/kpi-category-importer.ts +0 -90
  310. package/client/pages/kpi-category/kpi-category-list-page.ts +0 -537
  311. package/client/pages/kpi-category/kpi-category-value-calculator.ts +0 -233
  312. package/client/pages/kpi-category-value/kpi-category-value-list-page.ts +0 -404
  313. package/dist-client/pages/kpi-category/kpi-category-importer.d.ts +0 -23
  314. package/dist-client/pages/kpi-category/kpi-category-importer.js +0 -92
  315. package/dist-client/pages/kpi-category/kpi-category-importer.js.map +0 -1
  316. package/dist-client/pages/kpi-category/kpi-category-list-page.d.ts +0 -74
  317. package/dist-client/pages/kpi-category/kpi-category-list-page.js +0 -517
  318. package/dist-client/pages/kpi-category/kpi-category-list-page.js.map +0 -1
  319. package/dist-client/pages/kpi-category/kpi-category-value-calculator.d.ts +0 -13
  320. package/dist-client/pages/kpi-category/kpi-category-value-calculator.js +0 -256
  321. package/dist-client/pages/kpi-category/kpi-category-value-calculator.js.map +0 -1
  322. package/dist-client/pages/kpi-category-value/kpi-category-value-list-page.d.ts +0 -63
  323. package/dist-client/pages/kpi-category-value/kpi-category-value-list-page.js +0 -393
  324. package/dist-client/pages/kpi-category-value/kpi-category-value-list-page.js.map +0 -1
  325. package/dist-server/service/kpi-category/index.d.ts +0 -6
  326. package/dist-server/service/kpi-category/index.js +0 -10
  327. package/dist-server/service/kpi-category/index.js.map +0 -1
  328. package/dist-server/service/kpi-category/kpi-category-mutation.d.ts +0 -9
  329. package/dist-server/service/kpi-category/kpi-category-mutation.js +0 -221
  330. package/dist-server/service/kpi-category/kpi-category-mutation.js.map +0 -1
  331. package/dist-server/service/kpi-category/kpi-category-query.d.ts +0 -18
  332. package/dist-server/service/kpi-category/kpi-category-query.js +0 -115
  333. package/dist-server/service/kpi-category/kpi-category-query.js.map +0 -1
  334. package/dist-server/service/kpi-category/kpi-category-type.d.ts +0 -24
  335. package/dist-server/service/kpi-category/kpi-category-type.js +0 -100
  336. package/dist-server/service/kpi-category/kpi-category-type.js.map +0 -1
  337. package/dist-server/service/kpi-category/kpi-category.d.ts +0 -22
  338. package/dist-server/service/kpi-category/kpi-category.js +0 -106
  339. package/dist-server/service/kpi-category/kpi-category.js.map +0 -1
  340. package/dist-server/service/kpi-category-value/index.d.ts +0 -6
  341. package/dist-server/service/kpi-category-value/index.js +0 -10
  342. package/dist-server/service/kpi-category-value/index.js.map +0 -1
  343. package/dist-server/service/kpi-category-value/kpi-category-value-mutation.d.ts +0 -8
  344. package/dist-server/service/kpi-category-value/kpi-category-value-mutation.js +0 -102
  345. package/dist-server/service/kpi-category-value/kpi-category-value-mutation.js.map +0 -1
  346. package/dist-server/service/kpi-category-value/kpi-category-value-query.d.ts +0 -13
  347. package/dist-server/service/kpi-category-value/kpi-category-value-query.js +0 -91
  348. package/dist-server/service/kpi-category-value/kpi-category-value-query.js.map +0 -1
  349. package/dist-server/service/kpi-category-value/kpi-category-value-type.d.ts +0 -19
  350. package/dist-server/service/kpi-category-value/kpi-category-value-type.js +0 -73
  351. package/dist-server/service/kpi-category-value/kpi-category-value-type.js.map +0 -1
  352. package/dist-server/service/kpi-category-value/kpi-category-value.d.ts +0 -19
  353. package/dist-server/service/kpi-category-value/kpi-category-value.js +0 -91
  354. package/dist-server/service/kpi-category-value/kpi-category-value.js.map +0 -1
  355. package/helps/kpi/kpi-category.md +0 -160
  356. package/server/service/kpi-category/index.ts +0 -7
  357. package/server/service/kpi-category/kpi-category-mutation.ts +0 -217
  358. package/server/service/kpi-category/kpi-category-query.ts +0 -87
  359. package/server/service/kpi-category/kpi-category-type.ts +0 -73
  360. package/server/service/kpi-category/kpi-category.ts +0 -95
  361. package/server/service/kpi-category-value/index.ts +0 -7
  362. package/server/service/kpi-category-value/kpi-category-value-mutation.ts +0 -88
  363. package/server/service/kpi-category-value/kpi-category-value-query.ts +0 -62
  364. package/server/service/kpi-category-value/kpi-category-value-type.ts +0 -48
  365. package/server/service/kpi-category-value/kpi-category-value.ts +0 -79
@@ -1,221 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KpiCategoryMutation = void 0;
4
- const tslib_1 = require("tslib");
5
- const type_graphql_1 = require("type-graphql");
6
- const shell_1 = require("@things-factory/shell");
7
- const kpi_category_1 = require("./kpi-category");
8
- const kpi_category_type_1 = require("./kpi-category-type");
9
- const kpi_category_query_1 = require("./kpi-category-query");
10
- const parser_1 = require("../../calculator/parser");
11
- const evaluator_1 = require("../../calculator/evaluator");
12
- const functions_1 = require("../../calculator/functions");
13
- const kpi_value_provider_1 = require("../../controllers/kpi-value-provider");
14
- const value_date_util_1 = require("../utils/value-date-util");
15
- const kpi_1 = require("../kpi/kpi");
16
- const kpi_value_score_service_1 = require("../kpi-value/kpi-value-score.service");
17
- const kpi_category_value_1 = require("../kpi-category-value/kpi-category-value");
18
- let KpiCategoryMutation = class KpiCategoryMutation {
19
- async createKpiCategory(kpiCategory, context) {
20
- const { domain, user, tx } = context.state;
21
- const result = await (0, shell_1.getRepository)(kpi_category_1.KpiCategory, tx).save({
22
- ...kpiCategory,
23
- domain,
24
- creator: user,
25
- updater: user
26
- });
27
- return result;
28
- }
29
- async updateKpiCategory(id, patch, context) {
30
- const { domain, user, tx } = context.state;
31
- const kpiCategory = await (0, shell_1.getRepository)(kpi_category_1.KpiCategory, tx).findOne({
32
- where: { id, domain: { id: domain.id } }
33
- });
34
- if (!kpiCategory) {
35
- throw new Error(`KPI category with id ${id} not found`);
36
- }
37
- Object.assign(kpiCategory, {
38
- ...patch,
39
- updater: user
40
- });
41
- return await (0, shell_1.getRepository)(kpi_category_1.KpiCategory, tx).save(kpiCategory);
42
- }
43
- async deleteKpiCategory(id, context) {
44
- const { domain, tx } = context.state;
45
- const kpiCategory = await (0, shell_1.getRepository)(kpi_category_1.KpiCategory, tx).findOne({
46
- where: { id, domain: { id: domain.id } }
47
- });
48
- if (!kpiCategory) {
49
- throw new Error(`KPI category with id ${id} not found`);
50
- }
51
- await (0, shell_1.getRepository)(kpi_category_1.KpiCategory, tx).remove(kpiCategory);
52
- return true;
53
- }
54
- async calculateKpiValue(categoryId, valueDate, group, context) {
55
- const { domain, user, tx } = context.state;
56
- // 1. 카테고리 정보 조회
57
- const category = await (0, shell_1.getRepository)(kpi_category_1.KpiCategory, tx).findOne({
58
- where: { id: categoryId, domain: { id: domain.id } }
59
- });
60
- if (!category)
61
- return { score: null };
62
- // 기본 계산 기준일 설정 (카테고리 periodType 사용)
63
- const defaultDate = valueDate || (0, value_date_util_1.getDefaultValueDate)(category.periodType || kpi_1.KpiPeriodType.DAY, 'last');
64
- // 2. 카테고리 formula가 있으면 formula로 계산
65
- if (category.formula) {
66
- const ast = (0, parser_1.parseFormula)(category.formula);
67
- const provider = new kpi_value_provider_1.KpiValueProvider({
68
- valueDate: defaultDate,
69
- group,
70
- domainId: domain.id,
71
- tx
72
- });
73
- const evalContext = { functions: functions_1.builtinFunctions, provider };
74
- const value = await (0, evaluator_1.evaluateFormula)(ast, evalContext);
75
- // 카테고리 formula 결과를 score로 변환 (0-1 범위)
76
- const score = value !== null && value !== undefined && !isNaN(value) ? Math.max(0, Math.min(1, value)) : null;
77
- // KpiCategoryValue에 저장 (for formula case)
78
- const kpiCategoryValue = (0, shell_1.getRepository)(kpi_category_value_1.KpiCategoryValue, tx).create({
79
- domainId: domain.id,
80
- categoryId: categoryId,
81
- valueDate: defaultDate,
82
- group,
83
- score,
84
- creator: user,
85
- updater: user
86
- });
87
- await (0, shell_1.getRepository)(kpi_category_value_1.KpiCategoryValue, tx).save(kpiCategoryValue);
88
- return {
89
- score,
90
- valueDate: defaultDate,
91
- group
92
- };
93
- }
94
- // 3. formula가 없으면 KPI score들의 가중 평균으로 category score 계산
95
- const { Kpi } = require('../kpi/kpi');
96
- const kpis = await (0, shell_1.getRepository)(Kpi, tx).find({
97
- where: { domain: { id: domain.id }, category: { id: categoryId } }
98
- });
99
- if (!kpis.length)
100
- return { score: null };
101
- // 가중치 정규화를 위한 전체 가중치 합 계산
102
- let totalWeightSum = 0;
103
- for (const kpi of kpis) {
104
- const weight = kpi.weight ?? 1;
105
- totalWeightSum += weight;
106
- }
107
- // 가중치가 0이면 기본값 1로 설정
108
- if (totalWeightSum === 0) {
109
- totalWeightSum = kpis.length;
110
- }
111
- let weightedScoreSum = 0;
112
- for (const kpi of kpis) {
113
- // KPI value 계산
114
- let value = null;
115
- if (kpi.formula) {
116
- const ast = (0, parser_1.parseFormula)(kpi.formula);
117
- const provider = new kpi_value_provider_1.KpiValueProvider({
118
- valueDate: defaultDate,
119
- group,
120
- domainId: domain.id,
121
- tx
122
- });
123
- const evalContext = { functions: functions_1.builtinFunctions, provider };
124
- value = await (0, evaluator_1.evaluateFormula)(ast, evalContext);
125
- }
126
- else {
127
- const { KpiValue } = require('../kpi-value/kpi-value');
128
- const kpiValue = await (0, shell_1.getRepository)(KpiValue, tx).findOne({
129
- where: {
130
- kpi: { id: kpi.id },
131
- valueDate: defaultDate,
132
- group: group ?? '',
133
- domain: { id: domain.id }
134
- }
135
- });
136
- value = kpiValue?.value ?? 0;
137
- }
138
- // KPI score 계산
139
- const scoreService = new kpi_value_score_service_1.KpiValueScoreService();
140
- let kpiScore = null;
141
- if (value !== null && value !== undefined) {
142
- let scoreResult = await scoreService.calculateScoreFromFormula(kpi, value);
143
- if (!scoreResult) {
144
- scoreResult = scoreService.calculateScoreFromLookup(kpi, value);
145
- }
146
- kpiScore = scoreResult?.score ?? null;
147
- }
148
- // 정규화된 가중치 계산 (전체 가중치 합으로 나누어 비율로 변환)
149
- const normalizedWeight = (kpi.weight ?? 1) / totalWeightSum;
150
- if (kpiScore !== null) {
151
- weightedScoreSum += kpiScore * normalizedWeight;
152
- }
153
- }
154
- // category score 계산 (정규화된 가중치로 계산된 결과)
155
- const categoryScore = weightedScoreSum;
156
- // KpiCategoryValue에 저장
157
- const kpiCategoryValue = (0, shell_1.getRepository)(kpi_category_value_1.KpiCategoryValue, tx).create({
158
- domainId: domain.id,
159
- categoryId: categoryId,
160
- valueDate: defaultDate,
161
- group,
162
- score: categoryScore,
163
- creator: user,
164
- updater: user
165
- });
166
- await (0, shell_1.getRepository)(kpi_category_value_1.KpiCategoryValue, tx).save(kpiCategoryValue);
167
- return {
168
- score: categoryScore,
169
- valueDate: defaultDate,
170
- group
171
- };
172
- }
173
- };
174
- exports.KpiCategoryMutation = KpiCategoryMutation;
175
- tslib_1.__decorate([
176
- (0, type_graphql_1.Directive)('@transaction'),
177
- (0, type_graphql_1.Directive)('@privilege(category: "kpi", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
178
- (0, type_graphql_1.Mutation)(returns => kpi_category_1.KpiCategory, { description: 'Create a new KPI category.' }),
179
- tslib_1.__param(0, (0, type_graphql_1.Arg)('kpiCategory')),
180
- tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
181
- tslib_1.__metadata("design:type", Function),
182
- tslib_1.__metadata("design:paramtypes", [kpi_category_type_1.NewKpiCategory, Object]),
183
- tslib_1.__metadata("design:returntype", Promise)
184
- ], KpiCategoryMutation.prototype, "createKpiCategory", null);
185
- tslib_1.__decorate([
186
- (0, type_graphql_1.Directive)('@transaction'),
187
- (0, type_graphql_1.Directive)('@privilege(category: "kpi", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
188
- (0, type_graphql_1.Mutation)(returns => kpi_category_1.KpiCategory, { description: 'Update an existing KPI category.' }),
189
- tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
190
- tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
191
- tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
192
- tslib_1.__metadata("design:type", Function),
193
- tslib_1.__metadata("design:paramtypes", [String, kpi_category_type_1.KpiCategoryPatch, Object]),
194
- tslib_1.__metadata("design:returntype", Promise)
195
- ], KpiCategoryMutation.prototype, "updateKpiCategory", null);
196
- tslib_1.__decorate([
197
- (0, type_graphql_1.Directive)('@transaction'),
198
- (0, type_graphql_1.Directive)('@privilege(category: "kpi", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
199
- (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'Delete a KPI category.' }),
200
- tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
201
- tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
202
- tslib_1.__metadata("design:type", Function),
203
- tslib_1.__metadata("design:paramtypes", [String, Object]),
204
- tslib_1.__metadata("design:returntype", Promise)
205
- ], KpiCategoryMutation.prototype, "deleteKpiCategory", null);
206
- tslib_1.__decorate([
207
- (0, type_graphql_1.Directive)('@transaction'),
208
- (0, type_graphql_1.Directive)('@privilege(category: "kpi", privilege: "mutation", domainOwnerGranted: true, superUserGranted: true)'),
209
- (0, type_graphql_1.Mutation)(returns => kpi_category_query_1.KpiCategoryValueResult, { description: 'Calculate KPI category value and score.' }),
210
- tslib_1.__param(0, (0, type_graphql_1.Arg)('categoryId')),
211
- tslib_1.__param(1, (0, type_graphql_1.Arg)('valueDate', { nullable: true })),
212
- tslib_1.__param(2, (0, type_graphql_1.Arg)('group', { nullable: true })),
213
- tslib_1.__param(3, (0, type_graphql_1.Ctx)()),
214
- tslib_1.__metadata("design:type", Function),
215
- tslib_1.__metadata("design:paramtypes", [String, String, String, Object]),
216
- tslib_1.__metadata("design:returntype", Promise)
217
- ], KpiCategoryMutation.prototype, "calculateKpiValue", null);
218
- exports.KpiCategoryMutation = KpiCategoryMutation = tslib_1.__decorate([
219
- (0, type_graphql_1.Resolver)(kpi_category_1.KpiCategory)
220
- ], KpiCategoryMutation);
221
- //# sourceMappingURL=kpi-category-mutation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kpi-category-mutation.js","sourceRoot":"","sources":["../../../server/service/kpi-category/kpi-category-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,iDAAqD;AACrD,iDAA4C;AAC5C,2DAAsE;AACtE,6DAA6D;AAC7D,oDAAsD;AACtD,0DAA4D;AAC5D,0DAA6D;AAC7D,6EAAuE;AACvE,8DAA8D;AAC9D,oCAA0C;AAC1C,kFAA2E;AAC3E,iFAA2E;AAGpE,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAIxB,AAAN,KAAK,CAAC,iBAAiB,CACD,WAA2B,EACxC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAa,EAAC,0BAAW,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC;YACvD,GAAG,WAAW;YACd,MAAM;YACN,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;IAKK,AAAN,KAAK,CAAC,iBAAiB,CACV,EAAU,EACP,KAAuB,EAC9B,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE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AAmB,CAyM/B","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { getRepository } from '@things-factory/shell'\nimport { KpiCategory } from './kpi-category'\nimport { NewKpiCategory, KpiCategoryPatch } from './kpi-category-type'\nimport { KpiCategoryValueResult } from './kpi-category-query'\nimport { parseFormula } from '../../calculator/parser'\nimport { evaluateFormula } from '../../calculator/evaluator'\nimport { builtinFunctions } from '../../calculator/functions'\nimport { KpiValueProvider } from '../../controllers/kpi-value-provider'\nimport { getDefaultValueDate } from '../utils/value-date-util'\nimport { KpiPeriodType } from '../kpi/kpi'\nimport { KpiValueScoreService } from '../kpi-value/kpi-value-score.service'\nimport { KpiCategoryValue } from '../kpi-category-value/kpi-category-value'\n\n@Resolver(KpiCategory)\nexport class KpiCategoryMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"kpi\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)')\n @Mutation(returns => KpiCategory, { description: 'Create a new KPI category.' })\n async createKpiCategory(\n @Arg('kpiCategory') kpiCategory: NewKpiCategory,\n @Ctx() context: ResolverContext\n ): Promise<KpiCategory> {\n const { domain, user, tx } = context.state\n\n const result = await getRepository(KpiCategory, tx).save({\n ...kpiCategory,\n domain,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"kpi\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)')\n @Mutation(returns => KpiCategory, { description: 'Update an existing KPI category.' })\n async updateKpiCategory(\n @Arg('id') id: string,\n @Arg('patch') patch: KpiCategoryPatch,\n @Ctx() context: ResolverContext\n ): Promise<KpiCategory> {\n const { domain, user, tx } = context.state\n\n const kpiCategory = await getRepository(KpiCategory, tx).findOne({\n where: { id, domain: { id: domain.id } }\n })\n if (!kpiCategory) {\n throw new Error(`KPI category with id ${id} not found`)\n }\n\n Object.assign(kpiCategory, {\n ...patch,\n updater: user\n })\n\n return await getRepository(KpiCategory, tx).save(kpiCategory)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"kpi\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)')\n @Mutation(returns => Boolean, { description: 'Delete a KPI category.' })\n async deleteKpiCategory(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n const kpiCategory = await getRepository(KpiCategory, tx).findOne({\n where: { id, domain: { id: domain.id } }\n })\n if (!kpiCategory) {\n throw new Error(`KPI category with id ${id} not found`)\n }\n\n await getRepository(KpiCategory, tx).remove(kpiCategory)\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"kpi\", privilege: \"mutation\", domainOwnerGranted: true, superUserGranted: true)')\n @Mutation(returns => KpiCategoryValueResult, { description: 'Calculate KPI category value and score.' })\n async calculateKpiValue(\n @Arg('categoryId') categoryId: string,\n @Arg('valueDate', { nullable: true }) valueDate: string,\n @Arg('group', { nullable: true }) group: string,\n @Ctx() context: ResolverContext\n ): Promise<KpiCategoryValueResult> {\n const { domain, user, tx } = context.state\n\n // 1. 카테고리 정보 조회\n const category = await getRepository(KpiCategory, tx).findOne({\n where: { id: categoryId, domain: { id: domain.id } }\n })\n if (!category) return { score: null }\n\n // 기본 계산 기준일 설정 (카테고리 periodType 사용)\n const defaultDate = valueDate || getDefaultValueDate(category.periodType || KpiPeriodType.DAY, 'last')\n\n // 2. 카테고리 formula가 있으면 formula로 계산\n if (category.formula) {\n const ast = parseFormula(category.formula)\n const provider = new KpiValueProvider({\n valueDate: defaultDate,\n group,\n domainId: domain.id,\n tx\n })\n const evalContext = { functions: builtinFunctions, provider }\n const value = await evaluateFormula(ast, evalContext)\n // 카테고리 formula 결과를 score로 변환 (0-1 범위)\n const score = value !== null && value !== undefined && !isNaN(value) ? Math.max(0, Math.min(1, value)) : null\n\n // KpiCategoryValue에 저장 (for formula case)\n const kpiCategoryValue = getRepository(KpiCategoryValue, tx).create({\n domainId: domain.id,\n categoryId: categoryId,\n valueDate: defaultDate,\n group,\n score,\n creator: user,\n updater: user\n })\n await getRepository(KpiCategoryValue, tx).save(kpiCategoryValue)\n\n return {\n score,\n valueDate: defaultDate,\n group\n }\n }\n\n // 3. formula가 없으면 KPI score들의 가중 평균으로 category score 계산\n const { Kpi } = require('../kpi/kpi')\n const kpis = await getRepository(Kpi, tx).find({\n where: { domain: { id: domain.id }, category: { id: categoryId } }\n })\n if (!kpis.length) return { score: null }\n\n // 가중치 정규화를 위한 전체 가중치 합 계산\n let totalWeightSum = 0\n for (const kpi of kpis as any[]) {\n const weight = kpi.weight ?? 1\n totalWeightSum += weight\n }\n\n // 가중치가 0이면 기본값 1로 설정\n if (totalWeightSum === 0) {\n totalWeightSum = kpis.length\n }\n\n let weightedScoreSum = 0\n\n for (const kpi of kpis as any[]) {\n // KPI value 계산\n let value = null\n if (kpi.formula) {\n const ast = parseFormula(kpi.formula)\n const provider = new KpiValueProvider({\n valueDate: defaultDate,\n group,\n domainId: domain.id,\n tx\n })\n const evalContext = { functions: builtinFunctions, provider }\n value = await evaluateFormula(ast, evalContext)\n } else {\n const { KpiValue } = require('../kpi-value/kpi-value')\n const kpiValue = await getRepository(KpiValue, tx).findOne({\n where: {\n kpi: { id: kpi.id },\n valueDate: defaultDate,\n group: group ?? '',\n domain: { id: domain.id }\n }\n })\n value = (kpiValue as any)?.value ?? 0\n }\n\n // KPI score 계산\n const scoreService = new KpiValueScoreService()\n let kpiScore = null\n if (value !== null && value !== undefined) {\n let scoreResult = await scoreService.calculateScoreFromFormula(kpi as any, value)\n if (!scoreResult) {\n scoreResult = scoreService.calculateScoreFromLookup(kpi as any, value)\n }\n kpiScore = scoreResult?.score ?? null\n }\n\n // 정규화된 가중치 계산 (전체 가중치 합으로 나누어 비율로 변환)\n const normalizedWeight = (kpi.weight ?? 1) / totalWeightSum\n if (kpiScore !== null) {\n weightedScoreSum += kpiScore * normalizedWeight\n }\n }\n\n // category score 계산 (정규화된 가중치로 계산된 결과)\n const categoryScore = weightedScoreSum\n\n // KpiCategoryValue에 저장\n const kpiCategoryValue = getRepository(KpiCategoryValue, tx).create({\n domainId: domain.id,\n categoryId: categoryId,\n valueDate: defaultDate,\n group,\n score: categoryScore,\n creator: user,\n updater: user\n })\n await getRepository(KpiCategoryValue, tx).save(kpiCategoryValue)\n\n return {\n score: categoryScore,\n valueDate: defaultDate,\n group\n }\n }\n}\n"]}
@@ -1,18 +0,0 @@
1
- import { Domain, ListParam } from '@things-factory/shell';
2
- import { User } from '@things-factory/auth-base';
3
- import { KpiCategory } from './kpi-category';
4
- import { KpiCategoryList } from './kpi-category-type';
5
- import { Kpi } from '../kpi/kpi';
6
- export declare class KpiCategoryValueResult {
7
- score?: number;
8
- valueDate?: string;
9
- group?: string;
10
- }
11
- export declare class KpiCategoryQuery {
12
- kpiCategory(id: string, context: ResolverContext): Promise<KpiCategory>;
13
- kpiCategories(params: ListParam, context: ResolverContext): Promise<KpiCategoryList>;
14
- kpis(kpiCategory: KpiCategory): Promise<Kpi[]>;
15
- domain(kpiCategory: KpiCategory): Promise<Domain>;
16
- updater(kpiCategory: KpiCategory): Promise<User>;
17
- creator(kpiCategory: KpiCategory): Promise<User>;
18
- }
@@ -1,115 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KpiCategoryQuery = exports.KpiCategoryValueResult = void 0;
4
- const tslib_1 = require("tslib");
5
- const type_graphql_1 = require("type-graphql");
6
- const shell_1 = require("@things-factory/shell");
7
- const auth_base_1 = require("@things-factory/auth-base");
8
- const kpi_category_1 = require("./kpi-category");
9
- const kpi_category_type_1 = require("./kpi-category-type");
10
- const kpi_1 = require("../kpi/kpi");
11
- let KpiCategoryValueResult = class KpiCategoryValueResult {
12
- };
13
- exports.KpiCategoryValueResult = KpiCategoryValueResult;
14
- tslib_1.__decorate([
15
- (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'Performance score for this category (0-1 range)' }),
16
- tslib_1.__metadata("design:type", Number)
17
- ], KpiCategoryValueResult.prototype, "score", void 0);
18
- tslib_1.__decorate([
19
- (0, type_graphql_1.Field)({ nullable: true }),
20
- tslib_1.__metadata("design:type", String)
21
- ], KpiCategoryValueResult.prototype, "valueDate", void 0);
22
- tslib_1.__decorate([
23
- (0, type_graphql_1.Field)({ nullable: true }),
24
- tslib_1.__metadata("design:type", String)
25
- ], KpiCategoryValueResult.prototype, "group", void 0);
26
- exports.KpiCategoryValueResult = KpiCategoryValueResult = tslib_1.__decorate([
27
- (0, type_graphql_1.ObjectType)()
28
- ], KpiCategoryValueResult);
29
- let KpiCategoryQuery = class KpiCategoryQuery {
30
- async kpiCategory(id, context) {
31
- const { domain } = context.state;
32
- return await (0, shell_1.getRepository)(kpi_category_1.KpiCategory).findOne({
33
- where: { domain: { id: domain.id }, id }
34
- });
35
- }
36
- async kpiCategories(params, context) {
37
- const { domain } = context.state;
38
- const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
39
- domain,
40
- params,
41
- repository: await (0, shell_1.getRepository)(kpi_category_1.KpiCategory),
42
- searchables: ['name', 'description']
43
- });
44
- const [items, total] = await queryBuilder.getManyAndCount();
45
- return { items, total };
46
- }
47
- async kpis(kpiCategory) {
48
- return await (0, shell_1.getRepository)(kpi_1.Kpi).find({
49
- where: { domain: { id: kpiCategory.domainId }, category: { id: kpiCategory.id } }
50
- });
51
- }
52
- async domain(kpiCategory) {
53
- return kpiCategory.domainId && (await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: kpiCategory.domainId }));
54
- }
55
- async updater(kpiCategory) {
56
- return kpiCategory.updaterId && (await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: kpiCategory.updaterId }));
57
- }
58
- async creator(kpiCategory) {
59
- return kpiCategory.creatorId && (await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: kpiCategory.creatorId }));
60
- }
61
- };
62
- exports.KpiCategoryQuery = KpiCategoryQuery;
63
- tslib_1.__decorate([
64
- (0, type_graphql_1.Directive)('@privilege(category: "kpi", privilege: "query", domainOwnerGranted: true, superUserGranted: true)'),
65
- (0, type_graphql_1.Query)(returns => kpi_category_1.KpiCategory, {
66
- nullable: true,
67
- description: 'Fetch a single KPI category by its unique identifier.'
68
- }),
69
- tslib_1.__param(0, (0, type_graphql_1.Arg)('id', { description: 'Unique identifier of the KPI category to fetch.' })),
70
- tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
71
- tslib_1.__metadata("design:type", Function),
72
- tslib_1.__metadata("design:paramtypes", [String, Object]),
73
- tslib_1.__metadata("design:returntype", Promise)
74
- ], KpiCategoryQuery.prototype, "kpiCategory", null);
75
- tslib_1.__decorate([
76
- (0, type_graphql_1.Directive)('@privilege(category: "kpi", privilege: "query", domainOwnerGranted: true, superUserGranted: true)'),
77
- (0, type_graphql_1.Query)(returns => kpi_category_type_1.KpiCategoryList, { description: 'To fetch multiple KpiCategories' }),
78
- tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
79
- tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
80
- tslib_1.__metadata("design:type", Function),
81
- tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
82
- tslib_1.__metadata("design:returntype", Promise)
83
- ], KpiCategoryQuery.prototype, "kpiCategories", null);
84
- tslib_1.__decorate([
85
- (0, type_graphql_1.FieldResolver)(type => [kpi_1.Kpi]),
86
- tslib_1.__param(0, (0, type_graphql_1.Root)()),
87
- tslib_1.__metadata("design:type", Function),
88
- tslib_1.__metadata("design:paramtypes", [kpi_category_1.KpiCategory]),
89
- tslib_1.__metadata("design:returntype", Promise)
90
- ], KpiCategoryQuery.prototype, "kpis", null);
91
- tslib_1.__decorate([
92
- (0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
93
- tslib_1.__param(0, (0, type_graphql_1.Root)()),
94
- tslib_1.__metadata("design:type", Function),
95
- tslib_1.__metadata("design:paramtypes", [kpi_category_1.KpiCategory]),
96
- tslib_1.__metadata("design:returntype", Promise)
97
- ], KpiCategoryQuery.prototype, "domain", null);
98
- tslib_1.__decorate([
99
- (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
100
- tslib_1.__param(0, (0, type_graphql_1.Root)()),
101
- tslib_1.__metadata("design:type", Function),
102
- tslib_1.__metadata("design:paramtypes", [kpi_category_1.KpiCategory]),
103
- tslib_1.__metadata("design:returntype", Promise)
104
- ], KpiCategoryQuery.prototype, "updater", null);
105
- tslib_1.__decorate([
106
- (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
107
- tslib_1.__param(0, (0, type_graphql_1.Root)()),
108
- tslib_1.__metadata("design:type", Function),
109
- tslib_1.__metadata("design:paramtypes", [kpi_category_1.KpiCategory]),
110
- tslib_1.__metadata("design:returntype", Promise)
111
- ], KpiCategoryQuery.prototype, "creator", null);
112
- exports.KpiCategoryQuery = KpiCategoryQuery = tslib_1.__decorate([
113
- (0, type_graphql_1.Resolver)(kpi_category_1.KpiCategory)
114
- ], KpiCategoryQuery);
115
- //# sourceMappingURL=kpi-category-query.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kpi-category-query.js","sourceRoot":"","sources":["../../../server/service/kpi-category/kpi-category-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAwH;AACxH,iDAAuG;AACvG,yDAAgD;AAChD,iDAA4C;AAC5C,2DAAqD;AACrD,oCAAgC;AAWzB,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;CASlC,CAAA;AATY,wDAAsB;AAEjC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,iDAAiD,EAAE,CAAC;;qDAC3F;AAGd;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yDACR;AAGlB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACZ;iCARH,sBAAsB;IADlC,IAAA,yBAAU,GAAE;GACA,sBAAsB,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B,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAc,0BAAW;;4CAI1C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAc,0BAAW;;8CAE5C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAc,0BAAW;;+CAE7C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAc,0BAAW;;+CAE7C;2BAzDU,gBAAgB;IAD5B,IAAA,uBAAQ,EAAC,0BAAW,CAAC;GACT,gBAAgB,CA0D5B","sourcesContent":["import { Resolver, Query, FieldResolver, Float, Root, Args, Arg, Ctx, Directive, ObjectType, Field } from 'type-graphql'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { KpiCategory } from './kpi-category'\nimport { KpiCategoryList } from './kpi-category-type'\nimport { Kpi } from '../kpi/kpi'\nimport { KpiValue } from '../kpi-value/kpi-value'\nimport { parseFormula } from '../../calculator/parser'\nimport { evaluateFormula } from '../../calculator/evaluator'\nimport { builtinFunctions } from '../../calculator/functions'\nimport { KpiValueProvider } from '../../controllers/kpi-value-provider'\nimport { getDefaultValueDate } from '../utils/value-date-util'\nimport { KpiPeriodType } from '../kpi/kpi'\nimport { KpiValueScoreService } from '../kpi-value/kpi-value-score.service'\n\n@ObjectType()\nexport class KpiCategoryValueResult {\n @Field(type => Float, { nullable: true, description: 'Performance score for this category (0-1 range)' })\n score?: number\n\n @Field({ nullable: true })\n valueDate?: string\n\n @Field({ nullable: true })\n group?: string\n}\n\n@Resolver(KpiCategory)\nexport class KpiCategoryQuery {\n @Directive('@privilege(category: \"kpi\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => KpiCategory!, {\n nullable: true,\n description: 'Fetch a single KPI category by its unique identifier.'\n })\n async kpiCategory(\n @Arg('id', { description: 'Unique identifier of the KPI category to fetch.' }) id: string,\n @Ctx() context: ResolverContext\n ): Promise<KpiCategory> {\n const { domain } = context.state\n\n return await getRepository(KpiCategory).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Directive('@privilege(category: \"kpi\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => KpiCategoryList, { description: 'To fetch multiple KpiCategories' })\n async kpiCategories(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<KpiCategoryList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(KpiCategory),\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => [Kpi])\n async kpis(@Root() kpiCategory: KpiCategory): Promise<Kpi[]> {\n return await getRepository(Kpi).find({\n where: { domain: { id: kpiCategory.domainId }, category: { id: kpiCategory.id } }\n })\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() kpiCategory: KpiCategory): Promise<Domain> {\n return kpiCategory.domainId && (await getRepository(Domain).findOneBy({ id: kpiCategory.domainId }))\n }\n\n @FieldResolver(type => User)\n async updater(@Root() kpiCategory: KpiCategory): Promise<User> {\n return kpiCategory.updaterId && (await getRepository(User).findOneBy({ id: kpiCategory.updaterId }))\n }\n\n @FieldResolver(type => User)\n async creator(@Root() kpiCategory: KpiCategory): Promise<User> {\n return kpiCategory.creatorId && (await getRepository(User).findOneBy({ id: kpiCategory.creatorId }))\n }\n}\n"]}
@@ -1,24 +0,0 @@
1
- import { KpiCategory } from './kpi-category';
2
- import { KpiPeriodType } from '../kpi/kpi';
3
- export declare class NewKpiCategory {
4
- name: string;
5
- description?: string;
6
- active?: boolean;
7
- formula?: string;
8
- weight?: number;
9
- periodType?: KpiPeriodType;
10
- }
11
- export declare class KpiCategoryPatch {
12
- id?: string;
13
- name?: string;
14
- description?: string;
15
- active?: boolean;
16
- formula?: string;
17
- weight?: number;
18
- periodType?: KpiPeriodType;
19
- cuFlag?: string;
20
- }
21
- export declare class KpiCategoryList {
22
- items: KpiCategory[];
23
- total: number;
24
- }
@@ -1,100 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KpiCategoryList = exports.KpiCategoryPatch = exports.NewKpiCategory = void 0;
4
- const tslib_1 = require("tslib");
5
- const type_graphql_1 = require("type-graphql");
6
- const kpi_category_1 = require("./kpi-category");
7
- const kpi_1 = require("../kpi/kpi");
8
- let NewKpiCategory = class NewKpiCategory {
9
- };
10
- exports.NewKpiCategory = NewKpiCategory;
11
- tslib_1.__decorate([
12
- (0, type_graphql_1.Field)({ description: 'Name of the KPI category.' }),
13
- tslib_1.__metadata("design:type", String)
14
- ], NewKpiCategory.prototype, "name", void 0);
15
- tslib_1.__decorate([
16
- (0, type_graphql_1.Field)({ nullable: true, description: 'Detailed description of this KPI category.' }),
17
- tslib_1.__metadata("design:type", String)
18
- ], NewKpiCategory.prototype, "description", void 0);
19
- tslib_1.__decorate([
20
- (0, type_graphql_1.Field)({ nullable: true, description: 'Whether this category is active (usable) or not.' }),
21
- tslib_1.__metadata("design:type", Boolean)
22
- ], NewKpiCategory.prototype, "active", void 0);
23
- tslib_1.__decorate([
24
- (0, type_graphql_1.Field)({ nullable: true, description: 'Aggregation formula using child KPI codes.' }),
25
- tslib_1.__metadata("design:type", String)
26
- ], NewKpiCategory.prototype, "formula", void 0);
27
- tslib_1.__decorate([
28
- (0, type_graphql_1.Field)({ nullable: true, description: 'Weight for aggregation in higher-level summary.' }),
29
- tslib_1.__metadata("design:type", Number)
30
- ], NewKpiCategory.prototype, "weight", void 0);
31
- tslib_1.__decorate([
32
- (0, type_graphql_1.Field)(type => kpi_1.KpiPeriodType, {
33
- nullable: true,
34
- description: 'Calculation formula for category score using KPI score variables. Example: "avg(sales_score, profit_score)" or "sales_score * 0.6 + profit_score * 0.4". If not provided, weighted average of child KPI scores will be used.'
35
- }),
36
- tslib_1.__metadata("design:type", String)
37
- ], NewKpiCategory.prototype, "periodType", void 0);
38
- exports.NewKpiCategory = NewKpiCategory = tslib_1.__decorate([
39
- (0, type_graphql_1.InputType)({
40
- description: 'Input type for creating a new KPI category. Used in mutations to provide category details.'
41
- })
42
- ], NewKpiCategory);
43
- let KpiCategoryPatch = class KpiCategoryPatch {
44
- };
45
- exports.KpiCategoryPatch = KpiCategoryPatch;
46
- tslib_1.__decorate([
47
- (0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true, description: 'ID of the KPI category to update.' }),
48
- tslib_1.__metadata("design:type", String)
49
- ], KpiCategoryPatch.prototype, "id", void 0);
50
- tslib_1.__decorate([
51
- (0, type_graphql_1.Field)({ nullable: true, description: 'Name of the KPI category.' }),
52
- tslib_1.__metadata("design:type", String)
53
- ], KpiCategoryPatch.prototype, "name", void 0);
54
- tslib_1.__decorate([
55
- (0, type_graphql_1.Field)({ nullable: true, description: 'Detailed description of this KPI category.' }),
56
- tslib_1.__metadata("design:type", String)
57
- ], KpiCategoryPatch.prototype, "description", void 0);
58
- tslib_1.__decorate([
59
- (0, type_graphql_1.Field)({ nullable: true, description: 'Whether this category is active (usable) or not.' }),
60
- tslib_1.__metadata("design:type", Boolean)
61
- ], KpiCategoryPatch.prototype, "active", void 0);
62
- tslib_1.__decorate([
63
- (0, type_graphql_1.Field)({
64
- nullable: true,
65
- description: 'Calculation formula for category score using KPI score variables. Example: "avg(sales_score, profit_score)" or "sales_score * 0.6 + profit_score * 0.4". If not provided, weighted average of child KPI scores will be used.'
66
- }),
67
- tslib_1.__metadata("design:type", String)
68
- ], KpiCategoryPatch.prototype, "formula", void 0);
69
- tslib_1.__decorate([
70
- (0, type_graphql_1.Field)({ nullable: true, description: 'Weight for aggregation in higher-level summary.' }),
71
- tslib_1.__metadata("design:type", Number)
72
- ], KpiCategoryPatch.prototype, "weight", void 0);
73
- tslib_1.__decorate([
74
- (0, type_graphql_1.Field)(type => kpi_1.KpiPeriodType, { nullable: true, description: 'Aggregation period type for this category.' }),
75
- tslib_1.__metadata("design:type", String)
76
- ], KpiCategoryPatch.prototype, "periodType", void 0);
77
- tslib_1.__decorate([
78
- (0, type_graphql_1.Field)({ nullable: true, description: 'Custom flag for update operations (internal use).' }),
79
- tslib_1.__metadata("design:type", String)
80
- ], KpiCategoryPatch.prototype, "cuFlag", void 0);
81
- exports.KpiCategoryPatch = KpiCategoryPatch = tslib_1.__decorate([
82
- (0, type_graphql_1.InputType)({
83
- description: 'Input type for updating an existing KPI category. Used in mutations to patch category details.'
84
- })
85
- ], KpiCategoryPatch);
86
- let KpiCategoryList = class KpiCategoryList {
87
- };
88
- exports.KpiCategoryList = KpiCategoryList;
89
- tslib_1.__decorate([
90
- (0, type_graphql_1.Field)(type => [kpi_category_1.KpiCategory]),
91
- tslib_1.__metadata("design:type", Array)
92
- ], KpiCategoryList.prototype, "items", void 0);
93
- tslib_1.__decorate([
94
- (0, type_graphql_1.Field)(type => type_graphql_1.Int),
95
- tslib_1.__metadata("design:type", Number)
96
- ], KpiCategoryList.prototype, "total", void 0);
97
- exports.KpiCategoryList = KpiCategoryList = tslib_1.__decorate([
98
- (0, type_graphql_1.ObjectType)()
99
- ], KpiCategoryList);
100
- //# sourceMappingURL=kpi-category-type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kpi-category-type.js","sourceRoot":"","sources":["../../../server/service/kpi-category/kpi-category-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,iDAA4C;AAC5C,oCAA0C;AAKnC,IAAM,cAAc,GAApB,MAAM,cAAc;CAsB1B,CAAA;AAtBY,wCAAc;AAEzB;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;;4CACxC;AAGZ;IADC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ACT,8NAA8N;KACjO,CAAC;;iDACc;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,iDAAiD,EAAE,CAAC;;gDAC3E;AAGf;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,mBAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,4CAA4C,EAAE,CAAC;;oDAClF;AAG1B;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,mDAAmD,EAAE,CAAC;;gDAC7E;2BA3BJ,gBAAgB;IAH5B,IAAA,wBAAS,EAAC;QACT,WAAW,EAAE,gGAAgG;KAC9G,CAAC;GACW,gBAAgB,CA4B5B;AAGM,IAAM,eAAe,GAArB,MAAM,eAAe;CAM3B,CAAA;AANY,0CAAe;AAE1B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,0BAAW,CAAC,CAAC;;8CACT;AAGpB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;8CACN;0BALF,eAAe;IAD3B,IAAA,yBAAU,GAAE;GACA,eAAe,CAM3B","sourcesContent":["import { ObjectType, Field, InputType, Int, ID } from 'type-graphql'\n\nimport { KpiCategory } from './kpi-category'\nimport { KpiPeriodType } from '../kpi/kpi'\n\n@InputType({\n description: 'Input type for creating a new KPI category. Used in mutations to provide category details.'\n})\nexport class NewKpiCategory {\n @Field({ description: 'Name of the KPI category.' })\n name: string\n\n @Field({ nullable: true, description: 'Detailed description of this KPI category.' })\n description?: string\n\n @Field({ nullable: true, description: 'Whether this category is active (usable) or not.' })\n active?: boolean\n\n @Field({ nullable: true, description: 'Aggregation formula using child KPI codes.' })\n formula?: string\n\n @Field({ nullable: true, description: 'Weight for aggregation in higher-level summary.' })\n weight?: number\n\n @Field(type => KpiPeriodType, {\n nullable: true,\n description:\n 'Calculation formula for category score using KPI score variables. Example: \"avg(sales_score, profit_score)\" or \"sales_score * 0.6 + profit_score * 0.4\". If not provided, weighted average of child KPI scores will be used.'\n })\n periodType?: KpiPeriodType\n}\n\n@InputType({\n description: 'Input type for updating an existing KPI category. Used in mutations to patch category details.'\n})\nexport class KpiCategoryPatch {\n @Field(type => ID, { nullable: true, description: 'ID of the KPI category to update.' })\n id?: string\n\n @Field({ nullable: true, description: 'Name of the KPI category.' })\n name?: string\n\n @Field({ nullable: true, description: 'Detailed description of this KPI category.' })\n description?: string\n\n @Field({ nullable: true, description: 'Whether this category is active (usable) or not.' })\n active?: boolean\n\n @Field({\n nullable: true,\n description:\n 'Calculation formula for category score using KPI score variables. Example: \"avg(sales_score, profit_score)\" or \"sales_score * 0.6 + profit_score * 0.4\". If not provided, weighted average of child KPI scores will be used.'\n })\n formula?: string\n\n @Field({ nullable: true, description: 'Weight for aggregation in higher-level summary.' })\n weight?: number\n\n @Field(type => KpiPeriodType, { nullable: true, description: 'Aggregation period type for this category.' })\n periodType?: KpiPeriodType\n\n @Field({ nullable: true, description: 'Custom flag for update operations (internal use).' })\n cuFlag?: string\n}\n\n@ObjectType()\nexport class KpiCategoryList {\n @Field(type => [KpiCategory])\n items: KpiCategory[]\n\n @Field(type => Int)\n total: number\n}\n"]}
@@ -1,22 +0,0 @@
1
- import { Domain } from '@things-factory/shell';
2
- import { User } from '@things-factory/auth-base';
3
- import { Kpi } from '../kpi/kpi';
4
- import { KpiPeriodType } from '../kpi/kpi';
5
- export declare class KpiCategory {
6
- readonly id: string;
7
- domain?: Domain;
8
- domainId?: string;
9
- name: string;
10
- description?: string;
11
- active?: boolean;
12
- formula?: string;
13
- weight?: number;
14
- periodType: KpiPeriodType;
15
- creator?: User;
16
- creatorId?: string;
17
- updater?: User;
18
- updaterId?: string;
19
- createdAt?: Date;
20
- updatedAt?: Date;
21
- kpis?: Kpi[];
22
- }