@things-factory/kpi 1.0.0-alpha.5 → 9.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -0
- package/client/pages/kpi/kpi-list-page.ts +97 -47
- package/client/pages/kpi/kpi-overview-sample.ts +260 -0
- package/client/pages/kpi/kpi-overview.ts +271 -0
- package/client/pages/kpi-category/kpi-category-list-page.ts +39 -50
- package/client/pages/kpi-dashboard/kpi-alert-panel.ts +114 -0
- package/client/pages/kpi-dashboard/kpi-dashboard.ts +285 -0
- package/client/pages/kpi-dashboard/kpi-grade-visualization.ts +75 -0
- package/client/pages/kpi-dashboard/kpi-history-viewer.ts +58 -0
- package/client/pages/kpi-dashboard/kpi-list-summary.ts +100 -0
- package/client/pages/kpi-dashboard/kpi-performance-summary.ts +124 -0
- package/client/pages/kpi-dashboard/kpi-value-entry.ts +78 -0
- package/client/pages/kpi-grade/kpi-grade-list-page.ts +58 -68
- package/client/pages/kpi-history/kpi-history-list-page.ts +146 -0
- package/client/pages/kpi-metric/kpi-metric-list-page.ts +67 -63
- package/client/pages/kpi-value/kpi-value-list-page.ts +73 -72
- package/client/pages/kpi-value/kpi-value-manual-entry-form.ts +168 -0
- package/client/pages/kpi-value/kpi-value-manual-entry-page.ts +173 -0
- package/client/route.ts +35 -0
- package/dist-client/pages/kpi/kpi-importer.js +16 -17
- package/dist-client/pages/kpi/kpi-importer.js.map +1 -1
- package/dist-client/pages/kpi/kpi-list-page.js +128 -68
- package/dist-client/pages/kpi/kpi-list-page.js.map +1 -1
- package/dist-client/pages/kpi/kpi-overview-sample.d.ts +36 -0
- package/dist-client/pages/kpi/kpi-overview-sample.js +264 -0
- package/dist-client/pages/kpi/kpi-overview-sample.js.map +1 -0
- package/dist-client/pages/kpi/kpi-overview.d.ts +14 -0
- package/dist-client/pages/kpi/kpi-overview.js +290 -0
- package/dist-client/pages/kpi/kpi-overview.js.map +1 -0
- package/dist-client/pages/kpi-category/kpi-category-importer.js +16 -17
- package/dist-client/pages/kpi-category/kpi-category-importer.js.map +1 -1
- package/dist-client/pages/kpi-category/kpi-category-list-page.js +70 -71
- package/dist-client/pages/kpi-category/kpi-category-list-page.js.map +1 -1
- package/dist-client/pages/kpi-dashboard/kpi-alert-panel.d.ts +18 -0
- package/dist-client/pages/kpi-dashboard/kpi-alert-panel.js +128 -0
- package/dist-client/pages/kpi-dashboard/kpi-alert-panel.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard.d.ts +24 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard.js +305 -0
- package/dist-client/pages/kpi-dashboard/kpi-dashboard.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-grade-visualization.d.ts +12 -0
- package/dist-client/pages/kpi-dashboard/kpi-grade-visualization.js +82 -0
- package/dist-client/pages/kpi-dashboard/kpi-grade-visualization.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-history-viewer.d.ts +11 -0
- package/dist-client/pages/kpi-dashboard/kpi-history-viewer.js +65 -0
- package/dist-client/pages/kpi-dashboard/kpi-history-viewer.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-list-summary.d.ts +13 -0
- package/dist-client/pages/kpi-dashboard/kpi-list-summary.js +115 -0
- package/dist-client/pages/kpi-dashboard/kpi-list-summary.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-performance-summary.d.ts +15 -0
- package/dist-client/pages/kpi-dashboard/kpi-performance-summary.js +139 -0
- package/dist-client/pages/kpi-dashboard/kpi-performance-summary.js.map +1 -0
- package/dist-client/pages/kpi-dashboard/kpi-value-entry.d.ts +7 -0
- package/dist-client/pages/kpi-dashboard/kpi-value-entry.js +86 -0
- package/dist-client/pages/kpi-dashboard/kpi-value-entry.js.map +1 -0
- package/dist-client/pages/kpi-grade/kpi-grade-importer.js +16 -17
- package/dist-client/pages/kpi-grade/kpi-grade-importer.js.map +1 -1
- package/dist-client/pages/kpi-grade/kpi-grade-list-page.js +89 -89
- package/dist-client/pages/kpi-grade/kpi-grade-list-page.js.map +1 -1
- package/dist-client/pages/kpi-history/kpi-history-list-page.d.ts +16 -0
- package/dist-client/pages/kpi-history/kpi-history-list-page.js +155 -0
- package/dist-client/pages/kpi-history/kpi-history-list-page.js.map +1 -0
- package/dist-client/pages/kpi-metric/kpi-metric-importer.js +16 -17
- package/dist-client/pages/kpi-metric/kpi-metric-importer.js.map +1 -1
- package/dist-client/pages/kpi-metric/kpi-metric-list-page.js +98 -84
- package/dist-client/pages/kpi-metric/kpi-metric-list-page.js.map +1 -1
- package/dist-client/pages/kpi-value/kpi-value-importer.js +16 -17
- package/dist-client/pages/kpi-value/kpi-value-importer.js.map +1 -1
- package/dist-client/pages/kpi-value/kpi-value-list-page.js +104 -93
- package/dist-client/pages/kpi-value/kpi-value-list-page.js.map +1 -1
- package/dist-client/pages/kpi-value/kpi-value-manual-entry-form.d.ts +14 -0
- package/dist-client/pages/kpi-value/kpi-value-manual-entry-form.js +201 -0
- package/dist-client/pages/kpi-value/kpi-value-manual-entry-form.js.map +1 -0
- package/dist-client/pages/kpi-value/kpi-value-manual-entry-page.d.ts +41 -0
- package/dist-client/pages/kpi-value/kpi-value-manual-entry-page.js +180 -0
- package/dist-client/pages/kpi-value/kpi-value-manual-entry-page.js.map +1 -0
- package/dist-client/route.d.ts +1 -1
- package/dist-client/route.js +27 -0
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/index.d.ts +2 -1
- package/dist-server/index.js +2 -1
- package/dist-server/index.js.map +1 -1
- package/dist-server/migrations/1752188906708-SeedKpiCategory.d.ts +5 -0
- package/dist-server/migrations/1752188906708-SeedKpiCategory.js +56 -0
- package/dist-server/migrations/1752188906708-SeedKpiCategory.js.map +1 -0
- package/dist-server/migrations/1752190849681-SeedKpi.d.ts +5 -0
- package/dist-server/migrations/1752190849681-SeedKpi.js +107 -0
- package/dist-server/migrations/1752190849681-SeedKpi.js.map +1 -0
- package/dist-server/migrations/1752191090459-SeedKpiGrade.d.ts +5 -0
- package/dist-server/migrations/1752191090459-SeedKpiGrade.js +271 -0
- package/dist-server/migrations/1752191090459-SeedKpiGrade.js.map +1 -0
- package/dist-server/migrations/index.d.ts +1 -0
- package/dist-server/migrations/index.js +12 -0
- package/dist-server/migrations/index.js.map +1 -0
- package/dist-server/routes.d.ts +1 -0
- package/dist-server/routes.js +48 -0
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/index.d.ts +3 -4
- package/dist-server/service/index.js +4 -6
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/kpi/aggregate-kpi.d.ts +8 -0
- package/dist-server/service/kpi/aggregate-kpi.js +88 -0
- package/dist-server/service/kpi/aggregate-kpi.js.map +1 -0
- package/dist-server/service/kpi/event-subscriber.d.ts +2 -0
- package/dist-server/service/kpi/event-subscriber.js +10 -0
- package/dist-server/service/kpi/event-subscriber.js.map +1 -1
- package/dist-server/service/kpi/index.d.ts +2 -1
- package/dist-server/service/kpi/kpi-formula.service.d.ts +24 -0
- package/dist-server/service/kpi/kpi-formula.service.js +64 -0
- package/dist-server/service/kpi/kpi-formula.service.js.map +1 -0
- package/dist-server/service/kpi/kpi-history.d.ts +6 -2
- package/dist-server/service/kpi/kpi-history.js +29 -11
- package/dist-server/service/kpi/kpi-history.js.map +1 -1
- package/dist-server/service/kpi/kpi-mutation.d.ts +2 -0
- package/dist-server/service/kpi/kpi-mutation.js +215 -10
- package/dist-server/service/kpi/kpi-mutation.js.map +1 -1
- package/dist-server/service/kpi/kpi-query.d.ts +10 -0
- package/dist-server/service/kpi/kpi-query.js +87 -3
- package/dist-server/service/kpi/kpi-query.js.map +1 -1
- package/dist-server/service/kpi/kpi-type.d.ts +14 -3
- package/dist-server/service/kpi/kpi-type.js +81 -18
- package/dist-server/service/kpi/kpi-type.js.map +1 -1
- package/dist-server/service/kpi/kpi.d.ts +14 -3
- package/dist-server/service/kpi/kpi.js +96 -19
- package/dist-server/service/kpi/kpi.js.map +1 -1
- package/dist-server/service/kpi-alert/index.d.ts +2 -0
- package/dist-server/service/kpi-alert/index.js +6 -0
- package/dist-server/service/kpi-alert/index.js.map +1 -0
- package/dist-server/service/kpi-alert/kpi-alert-query.d.ts +4 -0
- package/dist-server/service/kpi-alert/kpi-alert-query.js +71 -0
- package/dist-server/service/kpi-alert/kpi-alert-query.js.map +1 -0
- package/dist-server/service/kpi-alert/kpi-alert-type.d.ts +8 -0
- package/dist-server/service/kpi-alert/kpi-alert-type.js +33 -0
- package/dist-server/service/kpi-alert/kpi-alert-type.js.map +1 -0
- package/dist-server/service/kpi-category/kpi-category-mutation.d.ts +1 -1
- package/dist-server/service/kpi-category/kpi-category-mutation.js +36 -10
- package/dist-server/service/kpi-category/kpi-category-mutation.js.map +1 -1
- package/dist-server/service/kpi-category/kpi-category-query.d.ts +2 -0
- package/dist-server/service/kpi-category/kpi-category-query.js +18 -2
- package/dist-server/service/kpi-category/kpi-category-query.js.map +1 -1
- package/dist-server/service/kpi-category/kpi-category-type.d.ts +3 -5
- package/dist-server/service/kpi-category/kpi-category-type.js +16 -20
- package/dist-server/service/kpi-category/kpi-category-type.js.map +1 -1
- package/dist-server/service/kpi-category/kpi-category.d.ts +7 -9
- package/dist-server/service/kpi-category/kpi-category.js +40 -38
- package/dist-server/service/kpi-category/kpi-category.js.map +1 -1
- package/dist-server/service/kpi-grade/index.d.ts +1 -2
- package/dist-server/service/kpi-grade/index.js +2 -4
- package/dist-server/service/kpi-grade/index.js.map +1 -1
- package/dist-server/service/kpi-grade/kpi-grade-mutation.d.ts +1 -1
- package/dist-server/service/kpi-grade/kpi-grade-mutation.js +33 -10
- package/dist-server/service/kpi-grade/kpi-grade-mutation.js.map +1 -1
- package/dist-server/service/kpi-grade/kpi-grade-query.js +2 -2
- package/dist-server/service/kpi-grade/kpi-grade-query.js.map +1 -1
- package/dist-server/service/kpi-grade/kpi-grade-type.d.ts +13 -4
- package/dist-server/service/kpi-grade/kpi-grade-type.js +54 -18
- package/dist-server/service/kpi-grade/kpi-grade-type.js.map +1 -1
- package/dist-server/service/kpi-grade/kpi-grade.d.ts +8 -8
- package/dist-server/service/kpi-grade/kpi-grade.js +48 -40
- package/dist-server/service/kpi-grade/kpi-grade.js.map +1 -1
- package/dist-server/service/kpi-metric/aggregate-kpi-metric.d.ts +8 -0
- package/dist-server/service/kpi-metric/aggregate-kpi-metric.js +134 -0
- package/dist-server/service/kpi-metric/aggregate-kpi-metric.js.map +1 -0
- package/dist-server/service/kpi-metric/index.d.ts +1 -2
- package/dist-server/service/kpi-metric/index.js +2 -4
- package/dist-server/service/kpi-metric/index.js.map +1 -1
- package/dist-server/service/kpi-metric/kpi-metric-mutation.d.ts +1 -1
- package/dist-server/service/kpi-metric/kpi-metric-mutation.js +139 -13
- package/dist-server/service/kpi-metric/kpi-metric-mutation.js.map +1 -1
- package/dist-server/service/kpi-metric/kpi-metric-query.js +3 -3
- package/dist-server/service/kpi-metric/kpi-metric-query.js.map +1 -1
- package/dist-server/service/kpi-metric/kpi-metric-type.d.ts +17 -4
- package/dist-server/service/kpi-metric/kpi-metric-type.js +69 -11
- package/dist-server/service/kpi-metric/kpi-metric-type.js.map +1 -1
- package/dist-server/service/kpi-metric/kpi-metric.d.ts +11 -8
- package/dist-server/service/kpi-metric/kpi-metric.js +62 -37
- package/dist-server/service/kpi-metric/kpi-metric.js.map +1 -1
- package/dist-server/service/kpi-value/kpi-value-mutation.js +66 -11
- package/dist-server/service/kpi-value/kpi-value-mutation.js.map +1 -1
- package/dist-server/service/kpi-value/kpi-value-query.d.ts +2 -0
- package/dist-server/service/kpi-value/kpi-value-query.js +15 -2
- package/dist-server/service/kpi-value/kpi-value-query.js.map +1 -1
- package/dist-server/service/kpi-value/kpi-value-type.d.ts +19 -10
- package/dist-server/service/kpi-value/kpi-value-type.js +87 -24
- package/dist-server/service/kpi-value/kpi-value-type.js.map +1 -1
- package/dist-server/service/kpi-value/kpi-value.d.ts +15 -9
- package/dist-server/service/kpi-value/kpi-value.js +86 -32
- package/dist-server/service/kpi-value/kpi-value.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/implement-plan/01-entity-type-resolver.md +57 -0
- package/implement-plan/02-dataset-integration.md +35 -0
- package/implement-plan/03-kpivalue-automation.md +34 -0
- package/implement-plan/04-version-history.md +33 -0
- package/implement-plan/05-grade-visualization.md +33 -0
- package/implement-plan/06-graphql-frontend.md +30 -0
- package/implement-plan/07-test-docs.md +35 -0
- package/implement-plan/TODO.md +41 -0
- package/package.json +18 -6
- package/server/index.ts +2 -1
- package/server/migrations/1752188906708-SeedKpiCategory.ts +61 -0
- package/server/migrations/1752190849681-SeedKpi.ts +112 -0
- package/server/migrations/1752191090459-SeedKpiGrade.ts +270 -0
- package/server/migrations/index.ts +9 -0
- package/server/routes.ts +55 -0
- package/server/service/index.ts +4 -6
- package/server/service/kpi/aggregate-kpi.ts +82 -0
- package/server/service/kpi/event-subscriber.ts +12 -0
- package/server/service/kpi/kpi-formula.service.ts +63 -0
- package/server/service/kpi/kpi-history.ts +29 -21
- package/server/service/kpi/kpi-mutation.ts +194 -12
- package/server/service/kpi/kpi-query.ts +57 -2
- package/server/service/kpi/kpi-type.ts +72 -19
- package/server/service/kpi/kpi.ts +96 -20
- package/server/service/kpi-alert/index.ts +3 -0
- package/server/service/kpi-alert/kpi-alert-query.ts +59 -0
- package/server/service/kpi-alert/kpi-alert-type.ts +20 -0
- package/server/service/kpi-category/kpi-category-mutation.ts +17 -4
- package/server/service/kpi-category/kpi-category-query.ts +20 -3
- package/server/service/kpi-category/kpi-category-type.ts +17 -19
- package/server/service/kpi-category/kpi-category.ts +39 -37
- package/server/service/kpi-grade/index.ts +2 -4
- package/server/service/kpi-grade/kpi-grade-mutation.ts +13 -4
- package/server/service/kpi-grade/kpi-grade-query.ts +5 -2
- package/server/service/kpi-grade/kpi-grade-type.ts +46 -19
- package/server/service/kpi-grade/kpi-grade.ts +44 -38
- package/server/service/kpi-metric/aggregate-kpi-metric.ts +128 -0
- package/server/service/kpi-metric/index.ts +2 -4
- package/server/service/kpi-metric/kpi-metric-mutation.ts +123 -7
- package/server/service/kpi-metric/kpi-metric-query.ts +9 -3
- package/server/service/kpi-metric/kpi-metric-type.ts +56 -13
- package/server/service/kpi-metric/kpi-metric.ts +55 -35
- package/server/service/kpi-value/kpi-value-mutation.ts +52 -14
- package/server/service/kpi-value/kpi-value-query.ts +12 -2
- package/server/service/kpi-value/kpi-value-type.ts +80 -25
- package/server/service/kpi-value/kpi-value.ts +81 -29
- package/things-factory.config.js +12 -4
- package/translations/en.json +12 -1
- package/translations/ja.json +12 -1
- package/translations/ko.json +12 -1
- package/translations/ms.json +12 -1
- package/translations/zh.json +12 -1
- package/client/pages/kpe-metric/kpe-metric-importer.ts +0 -90
- package/client/pages/kpe-metric/kpe-metric-list-page.ts +0 -398
- package/client/pages/kpi-formula/kpi-formula-importer.ts +0 -90
- package/client/pages/kpi-formula/kpi-formula-list-page.ts +0 -398
- package/client/pages/metric/metric-importer.ts +0 -90
- package/client/pages/metric/metric-list-page.ts +0 -398
- package/dist-client/pages/kpe-metric/kpe-metric-importer.d.ts +0 -23
- package/dist-client/pages/kpe-metric/kpe-metric-importer.js +0 -93
- package/dist-client/pages/kpe-metric/kpe-metric-importer.js.map +0 -1
- package/dist-client/pages/kpe-metric/kpe-metric-list-page.d.ts +0 -66
- package/dist-client/pages/kpe-metric/kpe-metric-list-page.js +0 -370
- package/dist-client/pages/kpe-metric/kpe-metric-list-page.js.map +0 -1
- package/dist-client/pages/kpi-formula/kpi-formula-importer.d.ts +0 -23
- package/dist-client/pages/kpi-formula/kpi-formula-importer.js +0 -93
- package/dist-client/pages/kpi-formula/kpi-formula-importer.js.map +0 -1
- package/dist-client/pages/kpi-formula/kpi-formula-list-page.d.ts +0 -66
- package/dist-client/pages/kpi-formula/kpi-formula-list-page.js +0 -370
- package/dist-client/pages/kpi-formula/kpi-formula-list-page.js.map +0 -1
- package/dist-client/pages/metric/metric-importer.d.ts +0 -23
- package/dist-client/pages/metric/metric-importer.js +0 -93
- package/dist-client/pages/metric/metric-importer.js.map +0 -1
- package/dist-client/pages/metric/metric-list-page.d.ts +0 -66
- package/dist-client/pages/metric/metric-list-page.js +0 -370
- package/dist-client/pages/metric/metric-list-page.js.map +0 -1
- package/dist-server/service/kpi-formula/event-subscriber.d.ts +0 -7
- package/dist-server/service/kpi-formula/event-subscriber.js +0 -21
- package/dist-server/service/kpi-formula/event-subscriber.js.map +0 -1
- package/dist-server/service/kpi-formula/index.d.ts +0 -7
- package/dist-server/service/kpi-formula/index.js +0 -12
- package/dist-server/service/kpi-formula/index.js.map +0 -1
- package/dist-server/service/kpi-formula/kpi-formula-history.d.ts +0 -25
- package/dist-server/service/kpi-formula/kpi-formula-history.js +0 -128
- package/dist-server/service/kpi-formula/kpi-formula-history.js.map +0 -1
- package/dist-server/service/kpi-formula/kpi-formula-mutation.d.ts +0 -10
- package/dist-server/service/kpi-formula/kpi-formula-mutation.js +0 -128
- package/dist-server/service/kpi-formula/kpi-formula-mutation.js.map +0 -1
- package/dist-server/service/kpi-formula/kpi-formula-query.d.ts +0 -11
- package/dist-server/service/kpi-formula/kpi-formula-query.js +0 -79
- package/dist-server/service/kpi-formula/kpi-formula-query.js.map +0 -1
- package/dist-server/service/kpi-formula/kpi-formula-type.d.ts +0 -20
- package/dist-server/service/kpi-formula/kpi-formula-type.js +0 -77
- package/dist-server/service/kpi-formula/kpi-formula-type.js.map +0 -1
- package/dist-server/service/kpi-formula/kpi-formula.d.ts +0 -24
- package/dist-server/service/kpi-formula/kpi-formula.js +0 -109
- package/dist-server/service/kpi-formula/kpi-formula.js.map +0 -1
- package/dist-server/service/kpi-grade/event-subscriber.d.ts +0 -7
- package/dist-server/service/kpi-grade/event-subscriber.js +0 -21
- package/dist-server/service/kpi-grade/event-subscriber.js.map +0 -1
- package/dist-server/service/kpi-grade/kpi-grade-history.d.ts +0 -25
- package/dist-server/service/kpi-grade/kpi-grade-history.js +0 -128
- package/dist-server/service/kpi-grade/kpi-grade-history.js.map +0 -1
- package/dist-server/service/kpi-metric/event-subscriber.d.ts +0 -7
- package/dist-server/service/kpi-metric/event-subscriber.js +0 -21
- package/dist-server/service/kpi-metric/event-subscriber.js.map +0 -1
- package/dist-server/service/kpi-metric/kpi-metric-history.d.ts +0 -25
- package/dist-server/service/kpi-metric/kpi-metric-history.js +0 -128
- package/dist-server/service/kpi-metric/kpi-metric-history.js.map +0 -1
- package/server/service/kpi-formula/event-subscriber.ts +0 -17
- package/server/service/kpi-formula/index.ts +0 -9
- package/server/service/kpi-formula/kpi-formula-history.ts +0 -116
- package/server/service/kpi-formula/kpi-formula-mutation.ts +0 -137
- package/server/service/kpi-formula/kpi-formula-query.ts +0 -48
- package/server/service/kpi-formula/kpi-formula-type.ts +0 -55
- package/server/service/kpi-formula/kpi-formula.ts +0 -95
- package/server/service/kpi-grade/event-subscriber.ts +0 -17
- package/server/service/kpi-grade/kpi-grade-history.ts +0 -116
- package/server/service/kpi-metric/event-subscriber.ts +0 -17
- package/server/service/kpi-metric/kpi-metric-history.ts +0 -116
|
@@ -9,31 +9,58 @@ let NewKpiMetric = class NewKpiMetric {
|
|
|
9
9
|
};
|
|
10
10
|
exports.NewKpiMetric = NewKpiMetric;
|
|
11
11
|
tslib_1.__decorate([
|
|
12
|
-
(0, type_graphql_1.Field)(),
|
|
12
|
+
(0, type_graphql_1.Field)({ description: 'Metric code, unique within the domain, used in KPI formulas.' }),
|
|
13
13
|
tslib_1.__metadata("design:type", String)
|
|
14
14
|
], NewKpiMetric.prototype, "name", void 0);
|
|
15
15
|
tslib_1.__decorate([
|
|
16
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
16
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'User-friendly name or description of the metric.' }),
|
|
17
17
|
tslib_1.__metadata("design:type", String)
|
|
18
18
|
], NewKpiMetric.prototype, "description", void 0);
|
|
19
19
|
tslib_1.__decorate([
|
|
20
|
-
(0, type_graphql_1.Field)(
|
|
20
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Unit of measurement for this metric (e.g., %, count, hours).' }),
|
|
21
21
|
tslib_1.__metadata("design:type", String)
|
|
22
|
-
], NewKpiMetric.prototype, "
|
|
22
|
+
], NewKpiMetric.prototype, "unit", void 0);
|
|
23
23
|
tslib_1.__decorate([
|
|
24
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
24
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Source of the metric data (e.g., system, method, dataset).' }),
|
|
25
|
+
tslib_1.__metadata("design:type", String)
|
|
26
|
+
], NewKpiMetric.prototype, "source", void 0);
|
|
27
|
+
tslib_1.__decorate([
|
|
28
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true, description: 'ID of the source dataset for this metric.' }),
|
|
29
|
+
tslib_1.__metadata("design:type", String)
|
|
30
|
+
], NewKpiMetric.prototype, "dataSetId", void 0);
|
|
31
|
+
tslib_1.__decorate([
|
|
32
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Name of the field in the dataset this metric maps to.' }),
|
|
33
|
+
tslib_1.__metadata("design:type", String)
|
|
34
|
+
], NewKpiMetric.prototype, "fieldName", void 0);
|
|
35
|
+
tslib_1.__decorate([
|
|
36
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Indicates whether this metric is active and usable.' }),
|
|
25
37
|
tslib_1.__metadata("design:type", Boolean)
|
|
26
38
|
], NewKpiMetric.prototype, "active", void 0);
|
|
27
39
|
tslib_1.__decorate([
|
|
28
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
40
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Calculation formula for the metric, using other metric codes and operators.' }),
|
|
29
41
|
tslib_1.__metadata("design:type", String)
|
|
30
|
-
], NewKpiMetric.prototype, "
|
|
42
|
+
], NewKpiMetric.prototype, "formula", void 0);
|
|
31
43
|
tslib_1.__decorate([
|
|
32
|
-
(0, type_graphql_1.Field)(
|
|
44
|
+
(0, type_graphql_1.Field)({
|
|
45
|
+
nullable: true,
|
|
46
|
+
description: 'Cron schedule string for periodic KPI value aggregation (e.g., "0 0 * * *" for daily).'
|
|
47
|
+
}),
|
|
48
|
+
tslib_1.__metadata("design:type", String)
|
|
49
|
+
], NewKpiMetric.prototype, "schedule", void 0);
|
|
50
|
+
tslib_1.__decorate([
|
|
51
|
+
(0, type_graphql_1.Field)(type => GraphQLUpload_js_1.default, { nullable: true, description: 'Thumbnail image or file for this metric.' }),
|
|
33
52
|
tslib_1.__metadata("design:type", Object)
|
|
34
53
|
], NewKpiMetric.prototype, "thumbnail", void 0);
|
|
54
|
+
tslib_1.__decorate([
|
|
55
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Timezone for the schedule.' }),
|
|
56
|
+
tslib_1.__metadata("design:type", String)
|
|
57
|
+
], NewKpiMetric.prototype, "timezone", void 0);
|
|
58
|
+
tslib_1.__decorate([
|
|
59
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Schedule ID for the registered cron job.' }),
|
|
60
|
+
tslib_1.__metadata("design:type", String)
|
|
61
|
+
], NewKpiMetric.prototype, "scheduleId", void 0);
|
|
35
62
|
exports.NewKpiMetric = NewKpiMetric = tslib_1.__decorate([
|
|
36
|
-
(0, type_graphql_1.InputType)()
|
|
63
|
+
(0, type_graphql_1.InputType)({ description: 'Input type for creating a new KPI metric. Used in mutations to provide metric details.' })
|
|
37
64
|
], NewKpiMetric);
|
|
38
65
|
let KpiMetricPatch = class KpiMetricPatch {
|
|
39
66
|
};
|
|
@@ -51,13 +78,36 @@ tslib_1.__decorate([
|
|
|
51
78
|
tslib_1.__metadata("design:type", String)
|
|
52
79
|
], KpiMetricPatch.prototype, "description", void 0);
|
|
53
80
|
tslib_1.__decorate([
|
|
54
|
-
(0, type_graphql_1.Field)(
|
|
81
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
55
82
|
tslib_1.__metadata("design:type", String)
|
|
56
|
-
], KpiMetricPatch.prototype, "
|
|
83
|
+
], KpiMetricPatch.prototype, "unit", void 0);
|
|
84
|
+
tslib_1.__decorate([
|
|
85
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
86
|
+
tslib_1.__metadata("design:type", String)
|
|
87
|
+
], KpiMetricPatch.prototype, "source", void 0);
|
|
88
|
+
tslib_1.__decorate([
|
|
89
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true }),
|
|
90
|
+
tslib_1.__metadata("design:type", String)
|
|
91
|
+
], KpiMetricPatch.prototype, "dataSetId", void 0);
|
|
92
|
+
tslib_1.__decorate([
|
|
93
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
94
|
+
tslib_1.__metadata("design:type", String)
|
|
95
|
+
], KpiMetricPatch.prototype, "fieldName", void 0);
|
|
57
96
|
tslib_1.__decorate([
|
|
58
97
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
59
98
|
tslib_1.__metadata("design:type", Boolean)
|
|
60
99
|
], KpiMetricPatch.prototype, "active", void 0);
|
|
100
|
+
tslib_1.__decorate([
|
|
101
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Calculation formula for the metric, using other metric codes and operators.' }),
|
|
102
|
+
tslib_1.__metadata("design:type", String)
|
|
103
|
+
], KpiMetricPatch.prototype, "formula", void 0);
|
|
104
|
+
tslib_1.__decorate([
|
|
105
|
+
(0, type_graphql_1.Field)({
|
|
106
|
+
nullable: true,
|
|
107
|
+
description: 'Cron schedule string for periodic KPI value aggregation (e.g., "0 0 * * *" for daily).'
|
|
108
|
+
}),
|
|
109
|
+
tslib_1.__metadata("design:type", String)
|
|
110
|
+
], KpiMetricPatch.prototype, "schedule", void 0);
|
|
61
111
|
tslib_1.__decorate([
|
|
62
112
|
(0, type_graphql_1.Field)(type => GraphQLUpload_js_1.default, { nullable: true }),
|
|
63
113
|
tslib_1.__metadata("design:type", Object)
|
|
@@ -66,6 +116,14 @@ tslib_1.__decorate([
|
|
|
66
116
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
67
117
|
tslib_1.__metadata("design:type", String)
|
|
68
118
|
], KpiMetricPatch.prototype, "cuFlag", void 0);
|
|
119
|
+
tslib_1.__decorate([
|
|
120
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Timezone for the schedule.' }),
|
|
121
|
+
tslib_1.__metadata("design:type", String)
|
|
122
|
+
], KpiMetricPatch.prototype, "timezone", void 0);
|
|
123
|
+
tslib_1.__decorate([
|
|
124
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Schedule ID for the registered cron job.' }),
|
|
125
|
+
tslib_1.__metadata("design:type", String)
|
|
126
|
+
], KpiMetricPatch.prototype, "scheduleId", void 0);
|
|
69
127
|
exports.KpiMetricPatch = KpiMetricPatch = tslib_1.__decorate([
|
|
70
128
|
(0, type_graphql_1.InputType)()
|
|
71
129
|
], KpiMetricPatch);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kpi-metric-type.js","sourceRoot":"","sources":["../../../server/service/kpi-metric/kpi-metric-type.ts"],"names":[],"mappings":";;;;AACA,+FAA2D;AAC3D,+CAAsF;AAItF,
|
|
1
|
+
{"version":3,"file":"kpi-metric-type.js","sourceRoot":"","sources":["../../../server/service/kpi-metric/kpi-metric-type.ts"],"names":[],"mappings":";;;;AACA,+FAA2D;AAC3D,+CAAsF;AAItF,6CAAwC;AAGjC,IAAM,YAAY,GAAlB,MAAM,YAAY;CAsCxB,CAAA;AAtCY,oCAAY;AAEvB;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,8DAA8D,EAAE,CAAC;;0CAC3E;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,kDAAkD,EAAE,CAAC;;iDACvE;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,8DAA8D,EAAE,CAAC;;0CAC1F;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QAA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C1B;AAGM,IAAM,aAAa,GAAnB,MAAM,aAAa;CAMzB,CAAA;AANY,sCAAa;AAExB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,sBAAS,CAAC,CAAC;;4CACT;AAGlB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;4CACN;wBALF,aAAa;IADzB,IAAA,yBAAU,GAAE;GACA,aAAa,CAMzB","sourcesContent":["import type { FileUpload } from 'graphql-upload/GraphQLUpload.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 { KpiMetric } from './kpi-metric'\n\n@InputType({ description: 'Input type for creating a new KPI metric. Used in mutations to provide metric details.' })\nexport class NewKpiMetric {\n @Field({ description: 'Metric code, unique within the domain, used in KPI formulas.' })\n name: string\n\n @Field({ nullable: true, description: 'User-friendly name or description of the metric.' })\n description?: string\n\n @Field({ nullable: true, description: 'Unit of measurement for this metric (e.g., %, count, hours).' })\n unit?: string\n\n @Field({ nullable: true, description: 'Source of the metric data (e.g., system, method, dataset).' })\n source?: string\n\n @Field(type => ID, { nullable: true, description: 'ID of the source dataset for this metric.' })\n dataSetId?: string\n\n @Field({ nullable: true, description: 'Name of the field in the dataset this metric maps to.' })\n fieldName?: string\n\n @Field({ nullable: true, description: 'Indicates whether this metric is active and usable.' })\n active?: boolean\n\n @Field({ nullable: true, description: 'Calculation formula for the metric, using other metric codes and operators.' })\n formula?: string\n\n @Field({\n nullable: true,\n description: 'Cron schedule string for periodic KPI value aggregation (e.g., \"0 0 * * *\" for daily).'\n })\n schedule?: string\n\n @Field(type => GraphQLUpload, { nullable: true, description: 'Thumbnail image or file for this metric.' })\n thumbnail?: FileUpload\n\n @Field({ nullable: true, description: 'Timezone for the schedule.' })\n timezone?: string\n @Field({ nullable: true, description: 'Schedule ID for the registered cron job.' })\n scheduleId?: string\n}\n\n@InputType()\nexport class KpiMetricPatch {\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({ nullable: true })\n unit?: string\n\n @Field({ nullable: true })\n source?: string\n\n @Field(type => ID, { nullable: true })\n dataSetId?: string\n\n @Field({ nullable: true })\n fieldName?: string\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true, description: 'Calculation formula for the metric, using other metric codes and operators.' })\n formula?: string\n\n @Field({\n nullable: true,\n description: 'Cron schedule string for periodic KPI value aggregation (e.g., \"0 0 * * *\" for daily).'\n })\n schedule?: string\n\n @Field(type => GraphQLUpload, { nullable: true })\n thumbnail?: FileUpload\n\n @Field({ nullable: true })\n cuFlag?: string\n\n @Field({ nullable: true, description: 'Timezone for the schedule.' })\n timezone?: string\n @Field({ nullable: true, description: 'Schedule ID for the registered cron job.' })\n scheduleId?: string\n}\n\n@ObjectType()\nexport class KpiMetricList {\n @Field(type => [KpiMetric])\n items: KpiMetric[]\n\n @Field(type => Int)\n total: number\n}\n"]}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { Domain } from '@things-factory/shell';
|
|
2
2
|
import { User } from '@things-factory/auth-base';
|
|
3
|
-
|
|
4
|
-
STATUS_A = "STATUS_A",
|
|
5
|
-
STATUS_B = "STATUS_B"
|
|
6
|
-
}
|
|
3
|
+
import { DataSet } from '@things-factory/dataset';
|
|
7
4
|
export declare class KpiMetric {
|
|
8
5
|
readonly id: string;
|
|
9
|
-
version?: number;
|
|
10
6
|
domain?: Domain;
|
|
11
7
|
domainId?: string;
|
|
12
|
-
name
|
|
8
|
+
name: string;
|
|
13
9
|
description?: string;
|
|
10
|
+
unit?: string;
|
|
11
|
+
source?: string;
|
|
12
|
+
dataSet?: DataSet;
|
|
13
|
+
dataSetId?: string;
|
|
14
|
+
fieldName?: string;
|
|
14
15
|
active?: boolean;
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
formula?: string;
|
|
17
|
+
schedule?: string;
|
|
18
|
+
scheduleId?: string;
|
|
19
|
+
timezone?: string;
|
|
17
20
|
createdAt?: Date;
|
|
18
21
|
updatedAt?: Date;
|
|
19
22
|
deletedAt?: Date;
|
|
@@ -1,105 +1,130 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KpiMetric =
|
|
3
|
+
exports.KpiMetric = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const typeorm_1 = require("typeorm");
|
|
6
6
|
const type_graphql_1 = require("type-graphql");
|
|
7
7
|
const shell_1 = require("@things-factory/shell");
|
|
8
8
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
9
|
-
|
|
10
|
-
(function (KpiMetricStatus) {
|
|
11
|
-
KpiMetricStatus["STATUS_A"] = "STATUS_A";
|
|
12
|
-
KpiMetricStatus["STATUS_B"] = "STATUS_B";
|
|
13
|
-
})(KpiMetricStatus || (exports.KpiMetricStatus = KpiMetricStatus = {}));
|
|
14
|
-
(0, type_graphql_1.registerEnumType)(KpiMetricStatus, {
|
|
15
|
-
name: 'KpiMetricStatus',
|
|
16
|
-
description: 'state enumeration of a kpiMetric'
|
|
17
|
-
});
|
|
9
|
+
const dataset_1 = require("@things-factory/dataset");
|
|
18
10
|
let KpiMetric = class KpiMetric {
|
|
19
|
-
constructor() {
|
|
20
|
-
this.version = 1;
|
|
21
|
-
}
|
|
22
11
|
};
|
|
23
12
|
exports.KpiMetric = KpiMetric;
|
|
24
13
|
tslib_1.__decorate([
|
|
25
14
|
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
26
|
-
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
|
15
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier for this KPI metric.' }),
|
|
27
16
|
tslib_1.__metadata("design:type", String)
|
|
28
17
|
], KpiMetric.prototype, "id", void 0);
|
|
29
|
-
tslib_1.__decorate([
|
|
30
|
-
(0, typeorm_1.VersionColumn)(),
|
|
31
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
32
|
-
tslib_1.__metadata("design:type", Number)
|
|
33
|
-
], KpiMetric.prototype, "version", void 0);
|
|
34
18
|
tslib_1.__decorate([
|
|
35
19
|
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
|
36
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
20
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Domain (tenant) to which this KPI metric belongs.' }),
|
|
37
21
|
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
38
22
|
], KpiMetric.prototype, "domain", void 0);
|
|
39
23
|
tslib_1.__decorate([
|
|
40
|
-
(0, typeorm_1.RelationId)((
|
|
24
|
+
(0, typeorm_1.RelationId)((metric) => metric.domain),
|
|
25
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'ID of the domain (tenant) for this KPI metric.' }),
|
|
41
26
|
tslib_1.__metadata("design:type", String)
|
|
42
27
|
], KpiMetric.prototype, "domainId", void 0);
|
|
43
28
|
tslib_1.__decorate([
|
|
44
29
|
(0, typeorm_1.Column)(),
|
|
45
|
-
(0, type_graphql_1.Field)({
|
|
30
|
+
(0, type_graphql_1.Field)({ description: 'Metric code, unique within the domain, used in KPI formulas.' }),
|
|
46
31
|
tslib_1.__metadata("design:type", String)
|
|
47
32
|
], KpiMetric.prototype, "name", void 0);
|
|
48
33
|
tslib_1.__decorate([
|
|
49
34
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
50
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
35
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'User-friendly name or description of the metric.' }),
|
|
51
36
|
tslib_1.__metadata("design:type", String)
|
|
52
37
|
], KpiMetric.prototype, "description", void 0);
|
|
38
|
+
tslib_1.__decorate([
|
|
39
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
40
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Unit of measurement for this metric (e.g., %, count, hours).' }),
|
|
41
|
+
tslib_1.__metadata("design:type", String)
|
|
42
|
+
], KpiMetric.prototype, "unit", void 0);
|
|
43
|
+
tslib_1.__decorate([
|
|
44
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
45
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Source of the metric data (e.g., system, method, dataset).' }),
|
|
46
|
+
tslib_1.__metadata("design:type", String)
|
|
47
|
+
], KpiMetric.prototype, "source", void 0);
|
|
48
|
+
tslib_1.__decorate([
|
|
49
|
+
(0, typeorm_1.ManyToOne)(type => dataset_1.DataSet, { nullable: true }),
|
|
50
|
+
(0, type_graphql_1.Field)(type => dataset_1.DataSet, { nullable: true, description: 'Reference to the source dataset for this metric.' }),
|
|
51
|
+
tslib_1.__metadata("design:type", dataset_1.DataSet)
|
|
52
|
+
], KpiMetric.prototype, "dataSet", void 0);
|
|
53
|
+
tslib_1.__decorate([
|
|
54
|
+
(0, typeorm_1.RelationId)((metric) => metric.dataSet),
|
|
55
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'ID of the referenced source dataset.' }),
|
|
56
|
+
tslib_1.__metadata("design:type", String)
|
|
57
|
+
], KpiMetric.prototype, "dataSetId", void 0);
|
|
58
|
+
tslib_1.__decorate([
|
|
59
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
60
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Name of the field in the dataset this metric maps to.' }),
|
|
61
|
+
tslib_1.__metadata("design:type", String)
|
|
62
|
+
], KpiMetric.prototype, "fieldName", void 0);
|
|
53
63
|
tslib_1.__decorate([
|
|
54
64
|
(0, typeorm_1.Column)({ nullable: false, default: false }),
|
|
55
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
65
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Indicates whether this metric is active and usable.' }),
|
|
56
66
|
tslib_1.__metadata("design:type", Boolean)
|
|
57
67
|
], KpiMetric.prototype, "active", void 0);
|
|
58
68
|
tslib_1.__decorate([
|
|
59
69
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
60
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
70
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Calculation formula for the metric, using other metric codes and operators.' }),
|
|
71
|
+
tslib_1.__metadata("design:type", String)
|
|
72
|
+
], KpiMetric.prototype, "formula", void 0);
|
|
73
|
+
tslib_1.__decorate([
|
|
74
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
75
|
+
(0, type_graphql_1.Field)({
|
|
76
|
+
nullable: true,
|
|
77
|
+
description: 'Cron schedule string for periodic KPI value aggregation (e.g., "0 0 * * *" for daily).'
|
|
78
|
+
}),
|
|
79
|
+
tslib_1.__metadata("design:type", String)
|
|
80
|
+
], KpiMetric.prototype, "schedule", void 0);
|
|
81
|
+
tslib_1.__decorate([
|
|
82
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
83
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Schedule ID for the registered cron job.' }),
|
|
61
84
|
tslib_1.__metadata("design:type", String)
|
|
62
|
-
], KpiMetric.prototype, "
|
|
85
|
+
], KpiMetric.prototype, "scheduleId", void 0);
|
|
63
86
|
tslib_1.__decorate([
|
|
64
87
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
65
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
88
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Timezone for the schedule.' }),
|
|
66
89
|
tslib_1.__metadata("design:type", String)
|
|
67
|
-
], KpiMetric.prototype, "
|
|
90
|
+
], KpiMetric.prototype, "timezone", void 0);
|
|
68
91
|
tslib_1.__decorate([
|
|
69
92
|
(0, typeorm_1.CreateDateColumn)(),
|
|
70
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
93
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Timestamp when this KPI metric was created.' }),
|
|
71
94
|
tslib_1.__metadata("design:type", Date)
|
|
72
95
|
], KpiMetric.prototype, "createdAt", void 0);
|
|
73
96
|
tslib_1.__decorate([
|
|
74
97
|
(0, typeorm_1.UpdateDateColumn)(),
|
|
75
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
98
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Timestamp when this KPI metric was last updated.' }),
|
|
76
99
|
tslib_1.__metadata("design:type", Date)
|
|
77
100
|
], KpiMetric.prototype, "updatedAt", void 0);
|
|
78
101
|
tslib_1.__decorate([
|
|
79
102
|
(0, typeorm_1.DeleteDateColumn)(),
|
|
80
|
-
(0, type_graphql_1.Field)({ nullable: true }),
|
|
103
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Timestamp when this KPI metric was deleted (soft delete).' }),
|
|
81
104
|
tslib_1.__metadata("design:type", Date)
|
|
82
105
|
], KpiMetric.prototype, "deletedAt", void 0);
|
|
83
106
|
tslib_1.__decorate([
|
|
84
107
|
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
85
|
-
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
108
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'User who created this KPI metric.' }),
|
|
86
109
|
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
87
110
|
], KpiMetric.prototype, "creator", void 0);
|
|
88
111
|
tslib_1.__decorate([
|
|
89
|
-
(0, typeorm_1.RelationId)((
|
|
112
|
+
(0, typeorm_1.RelationId)((metric) => metric.creator),
|
|
113
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'ID of the user who created this KPI metric.' }),
|
|
90
114
|
tslib_1.__metadata("design:type", String)
|
|
91
115
|
], KpiMetric.prototype, "creatorId", void 0);
|
|
92
116
|
tslib_1.__decorate([
|
|
93
117
|
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
94
|
-
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
118
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true, description: 'User who last updated this KPI metric.' }),
|
|
95
119
|
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
96
120
|
], KpiMetric.prototype, "updater", void 0);
|
|
97
121
|
tslib_1.__decorate([
|
|
98
|
-
(0, typeorm_1.RelationId)((
|
|
122
|
+
(0, typeorm_1.RelationId)((metric) => metric.updater),
|
|
123
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'ID of the user who last updated this KPI metric.' }),
|
|
99
124
|
tslib_1.__metadata("design:type", String)
|
|
100
125
|
], KpiMetric.prototype, "updaterId", void 0);
|
|
101
126
|
tslib_1.__decorate([
|
|
102
|
-
(0, type_graphql_1.Field)(type => String, { nullable: true }),
|
|
127
|
+
(0, type_graphql_1.Field)(type => String, { nullable: true, description: 'Thumbnail image or file path for this KPI metric.' }),
|
|
103
128
|
tslib_1.__metadata("design:type", String)
|
|
104
129
|
], KpiMetric.prototype, "thumbnail", void 0);
|
|
105
130
|
exports.KpiMetric = KpiMetric = tslib_1.__decorate([
|
|
@@ -108,6 +133,6 @@ exports.KpiMetric = KpiMetric = tslib_1.__decorate([
|
|
|
108
133
|
where: '"deleted_at" IS NULL',
|
|
109
134
|
unique: true
|
|
110
135
|
}),
|
|
111
|
-
(0, type_graphql_1.ObjectType)({ description: '
|
|
136
|
+
(0, type_graphql_1.ObjectType)({ description: 'KPI metric entity. Represents a source data item used in KPI formulas.' })
|
|
112
137
|
], KpiMetric);
|
|
113
138
|
//# sourceMappingURL=kpi-metric.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kpi-metric.js","sourceRoot":"","sources":["../../../server/service/kpi-metric/kpi-metric.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"kpi-metric.js","sourceRoot":"","sources":["../../../server/service/kpi-metric/kpi-metric.ts"],"names":[],"mappings":";;;;AAAA,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IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;sCACrF,gBAAI;0CAAA;AAId;IAFC,IAAA,oBAAU,EAAC,CAAC,MAAiB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC;IACjD,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,kDAAkD,EAAE,CAAC;;4CACzE;AAGlB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,mDAAmD,EAAE,CAAC;;4CAC1F;oBA7FP,SAAS;IANrB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,iBAAiB,EAAE,CAAC,SAAoB,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE;QACtF,KAAK,EAAE,sBAAsB;QAC7B,MAAM,EAAE,IAAI;KACb,CAAC;IACD,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,wEAAwE,EAAE,CAAC;GACzF,SAAS,CA8FrB","sourcesContent":["import {\n CreateDateColumn,\n UpdateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n Column,\n RelationId,\n ManyToOne,\n PrimaryGeneratedColumn\n} from 'typeorm'\nimport { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'\n\nimport { Domain } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { DataSet } from '@things-factory/dataset'\n\n@Entity()\n@Index('ix_kpi_metric_0', (kpiMetric: KpiMetric) => [kpiMetric.domain, kpiMetric.name], {\n where: '\"deleted_at\" IS NULL',\n unique: true\n})\n@ObjectType({ description: 'KPI metric entity. Represents a source data item used in KPI formulas.' })\nexport class KpiMetric {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier for this KPI metric.' })\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field({ nullable: true, description: 'Domain (tenant) to which this KPI metric belongs.' })\n domain?: Domain\n\n @RelationId((metric: KpiMetric) => metric.domain)\n @Field({ nullable: true, description: 'ID of the domain (tenant) for this KPI metric.' })\n domainId?: string\n\n @Column()\n @Field({ description: 'Metric code, unique within the domain, used in KPI formulas.' })\n name: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'User-friendly name or description of the metric.' })\n description?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Unit of measurement for this metric (e.g., %, count, hours).' })\n unit?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Source of the metric data (e.g., system, method, dataset).' })\n source?: string\n\n @ManyToOne(type => DataSet, { nullable: true })\n @Field(type => DataSet, { nullable: true, description: 'Reference to the source dataset for this metric.' })\n dataSet?: DataSet\n\n @RelationId((metric: KpiMetric) => metric.dataSet)\n @Field({ nullable: true, description: 'ID of the referenced source dataset.' })\n dataSetId?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Name of the field in the dataset this metric maps to.' })\n fieldName?: string\n\n @Column({ nullable: false, default: false })\n @Field({ nullable: true, description: 'Indicates whether this metric is active and usable.' })\n active?: boolean\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Calculation formula for the metric, using other metric codes and operators.' })\n formula?: string\n\n @Column({ nullable: true })\n @Field({\n nullable: true,\n description: 'Cron schedule string for periodic KPI value aggregation (e.g., \"0 0 * * *\" for daily).'\n })\n schedule?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Schedule ID for the registered cron job.' })\n scheduleId?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Timezone for the schedule.' })\n timezone?: string\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'Timestamp when this KPI metric was created.' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'Timestamp when this KPI metric was last updated.' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'Timestamp when this KPI metric was deleted (soft delete).' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'User who created this KPI metric.' })\n creator?: User\n\n @RelationId((metric: KpiMetric) => metric.creator)\n @Field({ nullable: true, description: 'ID of the user who created this KPI metric.' })\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'User who last updated this KPI metric.' })\n updater?: User\n\n @RelationId((metric: KpiMetric) => metric.updater)\n @Field({ nullable: true, description: 'ID of the user who last updated this KPI metric.' })\n updaterId?: string\n\n @Field(type => String, { nullable: true, description: 'Thumbnail image or file path for this KPI metric.' })\n thumbnail?: string\n}\n"]}
|
|
@@ -7,11 +7,37 @@ const typeorm_1 = require("typeorm");
|
|
|
7
7
|
const shell_1 = require("@things-factory/shell");
|
|
8
8
|
const kpi_value_1 = require("./kpi-value");
|
|
9
9
|
const kpi_value_type_1 = require("./kpi-value-type");
|
|
10
|
+
const kpi_1 = require("../kpi/kpi");
|
|
11
|
+
const kpi_value_2 = require("./kpi-value");
|
|
10
12
|
let KpiValueMutation = class KpiValueMutation {
|
|
11
13
|
async createKpiValue(kpiValue, context) {
|
|
12
14
|
const { domain, user, tx } = context.state;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
let kpi = kpiValue.kpiId ? await (0, shell_1.getRepository)(kpi_1.Kpi).findOne({ where: { id: kpiValue.kpiId } }) : undefined;
|
|
16
|
+
let inputType = undefined;
|
|
17
|
+
if (kpiValue.inputType) {
|
|
18
|
+
if (typeof kpiValue.inputType === 'string') {
|
|
19
|
+
inputType = kpi_value_2.KpiValueInputType[kpiValue.inputType];
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
inputType = kpiValue.inputType;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const entity = {
|
|
26
|
+
kpi,
|
|
27
|
+
kpiId: kpiValue.kpiId,
|
|
28
|
+
version: kpiValue.version,
|
|
29
|
+
valueDate: kpiValue.valueDate,
|
|
30
|
+
value: kpiValue.value,
|
|
31
|
+
groupId: kpiValue.groupId,
|
|
32
|
+
groupType: kpiValue.groupType,
|
|
33
|
+
source: kpiValue.source,
|
|
34
|
+
domain: domain,
|
|
35
|
+
creator: user,
|
|
36
|
+
updater: user
|
|
37
|
+
};
|
|
38
|
+
if (inputType)
|
|
39
|
+
entity.inputType = inputType;
|
|
40
|
+
return await (0, shell_1.getRepository)(kpi_value_1.KpiValue, tx).save(entity);
|
|
15
41
|
}
|
|
16
42
|
async updateKpiValue(id, patch, context) {
|
|
17
43
|
const { domain, user, tx } = context.state;
|
|
@@ -19,8 +45,28 @@ let KpiValueMutation = class KpiValueMutation {
|
|
|
19
45
|
const kpiValue = await repository.findOne({
|
|
20
46
|
where: { domain: { id: domain.id }, id }
|
|
21
47
|
});
|
|
22
|
-
|
|
23
|
-
|
|
48
|
+
let kpi = patch.kpiId ? await (0, shell_1.getRepository)(kpi_1.Kpi).findOne({ where: { id: patch.kpiId } }) : kpiValue.kpi;
|
|
49
|
+
let inputType = undefined;
|
|
50
|
+
if (patch.inputType) {
|
|
51
|
+
if (typeof patch.inputType === 'string') {
|
|
52
|
+
inputType = kpi_value_2.KpiValueInputType[patch.inputType];
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
inputType = patch.inputType;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
inputType = kpiValue.inputType;
|
|
60
|
+
}
|
|
61
|
+
const entity = {
|
|
62
|
+
...kpiValue,
|
|
63
|
+
...patch,
|
|
64
|
+
kpi,
|
|
65
|
+
updater: user
|
|
66
|
+
};
|
|
67
|
+
if (inputType)
|
|
68
|
+
entity.inputType = inputType;
|
|
69
|
+
return await repository.save(entity);
|
|
24
70
|
}
|
|
25
71
|
async updateMultipleKpiValue(patches, context) {
|
|
26
72
|
const { domain, user, tx } = context.state;
|
|
@@ -31,16 +77,25 @@ let KpiValueMutation = class KpiValueMutation {
|
|
|
31
77
|
if (_createRecords.length > 0) {
|
|
32
78
|
for (let i = 0; i < _createRecords.length; i++) {
|
|
33
79
|
const newRecord = _createRecords[i];
|
|
34
|
-
const result = await kpiValueRepo.save(
|
|
35
|
-
|
|
80
|
+
const result = await kpiValueRepo.save({
|
|
81
|
+
...newRecord,
|
|
82
|
+
domain,
|
|
83
|
+
creator: user,
|
|
84
|
+
updater: user
|
|
85
|
+
});
|
|
86
|
+
results.push({ ...result, cuFlag: '+' });
|
|
36
87
|
}
|
|
37
88
|
}
|
|
38
89
|
if (_updateRecords.length > 0) {
|
|
39
90
|
for (let i = 0; i < _updateRecords.length; i++) {
|
|
40
91
|
const updateRecord = _updateRecords[i];
|
|
41
92
|
const kpiValue = await kpiValueRepo.findOneBy({ id: updateRecord.id });
|
|
42
|
-
const result = await kpiValueRepo.save(
|
|
43
|
-
|
|
93
|
+
const result = await kpiValueRepo.save({
|
|
94
|
+
...kpiValue,
|
|
95
|
+
...updateRecord,
|
|
96
|
+
updater: user
|
|
97
|
+
});
|
|
98
|
+
results.push({ ...result, cuFlag: 'M' });
|
|
44
99
|
}
|
|
45
100
|
}
|
|
46
101
|
return results;
|
|
@@ -61,7 +116,7 @@ let KpiValueMutation = class KpiValueMutation {
|
|
|
61
116
|
async importKpiValues(kpiValues, context) {
|
|
62
117
|
const { domain, tx } = context.state;
|
|
63
118
|
await Promise.all(kpiValues.map(async (kpiValue) => {
|
|
64
|
-
const createdKpiValue = await (0, shell_1.getRepository)(kpi_value_1.KpiValue, tx).save(
|
|
119
|
+
const createdKpiValue = await (0, shell_1.getRepository)(kpi_value_1.KpiValue, tx).save({ domain, ...kpiValue });
|
|
65
120
|
}));
|
|
66
121
|
return true;
|
|
67
122
|
}
|
|
@@ -69,8 +124,8 @@ let KpiValueMutation = class KpiValueMutation {
|
|
|
69
124
|
exports.KpiValueMutation = KpiValueMutation;
|
|
70
125
|
tslib_1.__decorate([
|
|
71
126
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
72
|
-
(0, type_graphql_1.Mutation)(returns => kpi_value_1.KpiValue, { description: '
|
|
73
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('kpiValue')),
|
|
127
|
+
(0, type_graphql_1.Mutation)(returns => kpi_value_1.KpiValue, { description: 'Create a new KPI value with the provided details.' }),
|
|
128
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('kpiValue', { description: 'Input object containing details for the new KPI value.' })),
|
|
74
129
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
75
130
|
tslib_1.__metadata("design:type", Function),
|
|
76
131
|
tslib_1.__metadata("design:paramtypes", [kpi_value_type_1.NewKpiValue, Object]),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kpi-value-mutation.js","sourceRoot":"","sources":["../../../server/service/kpi-value/kpi-value-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAC5B,iDAAqD;AAErD,2CAAsC;AACtC,qDAA6D;AAGtD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAGrB,AAAN,KAAK,CAAC,cAAc,CAAkB,QAAqB,EAAS,OAAwB;QAC1F,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,IAAA,qBAAa,EAAC,oBAAQ,EAAE,EAAE,CAAC,CAAC,IAAI,iCAChD,QAAQ,KACX,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;IAIK,AAAN,KAAK,CAAC,cAAc,CACP,EAAU,EACP,KAAoB,EAC3B,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAA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directive } from 'type-graphql'\nimport { In } from 'typeorm'\nimport { getRepository } from '@things-factory/shell'\n\nimport { KpiValue } from './kpi-value'\nimport { NewKpiValue, KpiValuePatch } from './kpi-value-type'\n\n@Resolver(KpiValue)\nexport class KpiValueMutation {\n @Directive('@transaction')\n @Mutation(returns => KpiValue, { description: 'To create new KpiValue' })\n async createKpiValue(@Arg('kpiValue') kpiValue: NewKpiValue, @Ctx() context: ResolverContext): Promise<KpiValue> {\n const { domain, user, tx } = context.state\n\n const result = await getRepository(KpiValue, tx).save({\n ...kpiValue,\n domain,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => KpiValue, { description: 'To modify KpiValue information' })\n async updateKpiValue(\n @Arg('id') id: string,\n @Arg('patch') patch: KpiValuePatch,\n @Ctx() context: ResolverContext\n ): Promise<KpiValue> {\n const { domain, user, tx } = context.state\n\n const repository = getRepository(KpiValue, tx)\n const kpiValue = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...kpiValue,\n ...patch,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => [KpiValue], { description: \"To modify multiple KpiValues' information\" })\n async updateMultipleKpiValue(\n @Arg('patches', type => [KpiValuePatch]) patches: KpiValuePatch[],\n @Ctx() context: ResolverContext\n ): Promise<KpiValue[]> {\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 kpiValueRepo = getRepository(KpiValue, 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 kpiValueRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\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 kpiValue = await kpiValueRepo.findOneBy({ id: updateRecord.id })\n\n const result = await kpiValueRepo.save({\n ...kpiValue,\n ...updateRecord,\n updater: user\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 KpiValue' })\n async deleteKpiValue(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(KpiValue, tx).delete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple KpiValues' })\n async deleteKpiValues(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(KpiValue, tx).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To import multiple KpiValues' })\n async importKpiValues(\n @Arg('kpiValues', type => [KpiValuePatch]) kpiValues: KpiValuePatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n kpiValues.map(async (kpiValue: KpiValuePatch) => {\n const createdKpiValue: KpiValue = await getRepository(KpiValue, tx).save({ domain, ...kpiValue })\n })\n )\n\n return true\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"kpi-value-mutation.js","sourceRoot":"","sources":["../../../server/service/kpi-value/kpi-value-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAC5B,iDAAqD;AAErD,2CAAsC;AACtC,qDAA6D;AAC7D,oCAAgC;AAChC,2CAA+C;AAGxC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAGrB,AAAN,KAAK,CAAC,cAAc,CAC0E,QAAqB,EAC1G,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,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AW,EAAE,oBAAoB,EAAE,CAAC;IAC9C,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;sDAMjD;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;IAE3E,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;uDAUP;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,8BAA8B,EAAE,CAAC;IAE3E,mBAAA,IAAA,kBAAG,EAAC,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,8BAAa,CAAC,CAAC,CAAA;IACzC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;uDAWP;2BAnKU,gBAAgB;IAD5B,IAAA,uBAAQ,EAAC,oBAAQ,CAAC;GACN,gBAAgB,CAoK5B","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\nimport { getRepository } from '@things-factory/shell'\n\nimport { KpiValue } from './kpi-value'\nimport { NewKpiValue, KpiValuePatch } from './kpi-value-type'\nimport { Kpi } from '../kpi/kpi'\nimport { KpiValueInputType } from './kpi-value'\n\n@Resolver(KpiValue)\nexport class KpiValueMutation {\n @Directive('@transaction')\n @Mutation(returns => KpiValue, { description: 'Create a new KPI value with the provided details.' })\n async createKpiValue(\n @Arg('kpiValue', { description: 'Input object containing details for the new KPI value.' }) kpiValue: NewKpiValue,\n @Ctx() context: ResolverContext\n ): Promise<KpiValue> {\n const { domain, user, tx } = context.state\n\n let kpi = kpiValue.kpiId ? await getRepository(Kpi).findOne({ where: { id: kpiValue.kpiId } }) : undefined\n\n let inputType: KpiValueInputType | undefined = undefined\n if (kpiValue.inputType) {\n if (typeof kpiValue.inputType === 'string') {\n inputType = KpiValueInputType[kpiValue.inputType as keyof typeof KpiValueInputType]\n } else {\n inputType = kpiValue.inputType\n }\n }\n\n const entity: Partial<KpiValue> = {\n kpi,\n kpiId: kpiValue.kpiId,\n version: kpiValue.version,\n valueDate: kpiValue.valueDate,\n value: kpiValue.value,\n groupId: kpiValue.groupId,\n groupType: kpiValue.groupType,\n source: kpiValue.source,\n domain: domain,\n creator: user,\n updater: user\n }\n if (inputType) entity.inputType = inputType\n\n return await getRepository(KpiValue, tx).save(entity)\n }\n\n @Directive('@transaction')\n @Mutation(returns => KpiValue, { description: 'To modify KpiValue information' })\n async updateKpiValue(\n @Arg('id') id: string,\n @Arg('patch') patch: KpiValuePatch,\n @Ctx() context: ResolverContext\n ): Promise<KpiValue> {\n const { domain, user, tx } = context.state\n\n const repository = getRepository(KpiValue, tx)\n const kpiValue = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n let kpi = patch.kpiId ? await getRepository(Kpi).findOne({ where: { id: patch.kpiId } }) : kpiValue.kpi\n\n let inputType: KpiValueInputType | undefined = undefined\n if (patch.inputType) {\n if (typeof patch.inputType === 'string') {\n inputType = KpiValueInputType[patch.inputType as keyof typeof KpiValueInputType]\n } else {\n inputType = patch.inputType\n }\n } else {\n inputType = kpiValue.inputType\n }\n\n const entity: any = {\n ...kpiValue,\n ...patch,\n kpi,\n updater: user\n }\n if (inputType) entity.inputType = inputType\n\n return await repository.save(entity)\n }\n\n @Directive('@transaction')\n @Mutation(returns => [KpiValue], { description: \"To modify multiple KpiValues' information\" })\n async updateMultipleKpiValue(\n @Arg('patches', type => [KpiValuePatch]) patches: KpiValuePatch[],\n @Ctx() context: ResolverContext\n ): Promise<KpiValue[]> {\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 kpiValueRepo = getRepository(KpiValue, 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 kpiValueRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n } as any)\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 kpiValue = await kpiValueRepo.findOneBy({ id: updateRecord.id })\n\n const result = await kpiValueRepo.save({\n ...kpiValue,\n ...updateRecord,\n updater: user\n } as any)\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 KpiValue' })\n async deleteKpiValue(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(KpiValue, tx).delete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple KpiValues' })\n async deleteKpiValues(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(KpiValue, tx).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To import multiple KpiValues' })\n async importKpiValues(\n @Arg('kpiValues', type => [KpiValuePatch]) kpiValues: KpiValuePatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n kpiValues.map(async (kpiValue: KpiValuePatch) => {\n const createdKpiValue: KpiValue = await getRepository(KpiValue, tx).save({ domain, ...kpiValue } as any)\n })\n )\n\n return true\n }\n}\n"]}
|
|
@@ -2,10 +2,12 @@ import { Domain, ListParam } from '@things-factory/shell';
|
|
|
2
2
|
import { User } from '@things-factory/auth-base';
|
|
3
3
|
import { KpiValue } from './kpi-value';
|
|
4
4
|
import { KpiValueList } from './kpi-value-type';
|
|
5
|
+
import { Kpi } from '../kpi/kpi';
|
|
5
6
|
export declare class KpiValueQuery {
|
|
6
7
|
kpiValue(id: string, context: ResolverContext): Promise<KpiValue>;
|
|
7
8
|
kpiValues(params: ListParam, context: ResolverContext): Promise<KpiValueList>;
|
|
8
9
|
domain(kpiValue: KpiValue): Promise<Domain>;
|
|
9
10
|
updater(kpiValue: KpiValue): Promise<User>;
|
|
10
11
|
creator(kpiValue: KpiValue): Promise<User>;
|
|
12
|
+
kpi(kpiValue: KpiValue): Promise<Kpi | null>;
|
|
11
13
|
}
|
|
@@ -7,6 +7,7 @@ const shell_1 = require("@things-factory/shell");
|
|
|
7
7
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
8
8
|
const kpi_value_1 = require("./kpi-value");
|
|
9
9
|
const kpi_value_type_1 = require("./kpi-value-type");
|
|
10
|
+
const kpi_1 = require("../kpi/kpi");
|
|
10
11
|
let KpiValueQuery = class KpiValueQuery {
|
|
11
12
|
async kpiValue(id, context) {
|
|
12
13
|
const { domain } = context.state;
|
|
@@ -34,11 +35,16 @@ let KpiValueQuery = class KpiValueQuery {
|
|
|
34
35
|
async creator(kpiValue) {
|
|
35
36
|
return kpiValue.creatorId && (await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: kpiValue.creatorId }));
|
|
36
37
|
}
|
|
38
|
+
async kpi(kpiValue) {
|
|
39
|
+
if (!kpiValue.kpiId)
|
|
40
|
+
return null;
|
|
41
|
+
return await (0, shell_1.getRepository)(kpi_1.Kpi).findOneBy({ id: kpiValue.kpiId });
|
|
42
|
+
}
|
|
37
43
|
};
|
|
38
44
|
exports.KpiValueQuery = KpiValueQuery;
|
|
39
45
|
tslib_1.__decorate([
|
|
40
|
-
(0, type_graphql_1.Query)(returns => kpi_value_1.KpiValue, { nullable: true, description: '
|
|
41
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
46
|
+
(0, type_graphql_1.Query)(returns => kpi_value_1.KpiValue, { nullable: true, description: 'Fetch a single KPI value by its unique identifier.' }),
|
|
47
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id', { description: 'Unique identifier of the KPI value to fetch.' })),
|
|
42
48
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
43
49
|
tslib_1.__metadata("design:type", Function),
|
|
44
50
|
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
@@ -73,6 +79,13 @@ tslib_1.__decorate([
|
|
|
73
79
|
tslib_1.__metadata("design:paramtypes", [kpi_value_1.KpiValue]),
|
|
74
80
|
tslib_1.__metadata("design:returntype", Promise)
|
|
75
81
|
], KpiValueQuery.prototype, "creator", null);
|
|
82
|
+
tslib_1.__decorate([
|
|
83
|
+
(0, type_graphql_1.FieldResolver)(type => kpi_1.Kpi),
|
|
84
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
85
|
+
tslib_1.__metadata("design:type", Function),
|
|
86
|
+
tslib_1.__metadata("design:paramtypes", [kpi_value_1.KpiValue]),
|
|
87
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
88
|
+
], KpiValueQuery.prototype, "kpi", null);
|
|
76
89
|
exports.KpiValueQuery = KpiValueQuery = tslib_1.__decorate([
|
|
77
90
|
(0, type_graphql_1.Resolver)(kpi_value_1.KpiValue)
|
|
78
91
|
], KpiValueQuery);
|