@things-factory/kpi 9.0.18 → 9.0.20

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 (134) hide show
  1. package/client/bootstrap.ts +8 -0
  2. package/client/pages/kpi/kpi-list-page.ts +91 -11
  3. package/client/pages/kpi-category/kpi-category-list-page.ts +80 -8
  4. package/client/pages/kpi-history/kpi-history-list-page.ts +1 -1
  5. package/client/pages/kpi-metric/kpi-metric-list-page.ts +31 -7
  6. package/client/pages/kpi-metric-value/kpi-metric-value-importer.ts +65 -0
  7. package/client/pages/kpi-metric-value/kpi-metric-value-list-page.ts +299 -0
  8. package/client/pages/{kpi-value/kpi-value-manual-entry-form.ts → kpi-metric-value/kpi-metric-value-manual-entry-form.ts} +18 -44
  9. package/client/pages/{kpi-value/kpi-value-manual-entry-page.ts → kpi-metric-value/kpi-metric-value-manual-entry-page.ts} +21 -21
  10. package/client/pages/kpi-value/kpi-value-list-page.ts +4 -6
  11. package/client/route.ts +6 -2
  12. package/dist-client/bootstrap.d.ts +2 -0
  13. package/dist-client/bootstrap.js +7 -0
  14. package/dist-client/bootstrap.js.map +1 -0
  15. package/dist-client/pages/kpi/kpi-list-page.d.ts +6 -0
  16. package/dist-client/pages/kpi/kpi-list-page.js +94 -11
  17. package/dist-client/pages/kpi/kpi-list-page.js.map +1 -1
  18. package/dist-client/pages/kpi-category/kpi-category-list-page.d.ts +5 -0
  19. package/dist-client/pages/kpi-category/kpi-category-list-page.js +83 -8
  20. package/dist-client/pages/kpi-category/kpi-category-list-page.js.map +1 -1
  21. package/dist-client/pages/kpi-history/kpi-history-list-page.js +1 -1
  22. package/dist-client/pages/kpi-history/kpi-history-list-page.js.map +1 -1
  23. package/dist-client/pages/kpi-metric/kpi-metric-list-page.js +29 -5
  24. package/dist-client/pages/kpi-metric/kpi-metric-list-page.js.map +1 -1
  25. package/dist-client/pages/kpi-metric-value/kpi-metric-value-importer.d.ts +23 -0
  26. package/dist-client/pages/kpi-metric-value/kpi-metric-value-importer.js +75 -0
  27. package/dist-client/pages/kpi-metric-value/kpi-metric-value-importer.js.map +1 -0
  28. package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.d.ts +61 -0
  29. package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.js +301 -0
  30. package/dist-client/pages/kpi-metric-value/kpi-metric-value-list-page.js.map +1 -0
  31. package/dist-client/pages/{kpi-value/kpi-value-manual-entry-form.d.ts → kpi-metric-value/kpi-metric-value-manual-entry-form.d.ts} +3 -5
  32. package/dist-client/pages/{kpi-value/kpi-value-manual-entry-form.js → kpi-metric-value/kpi-metric-value-manual-entry-form.js} +27 -56
  33. package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-form.js.map +1 -0
  34. package/dist-client/pages/{kpi-value/kpi-value-manual-entry-page.d.ts → kpi-metric-value/kpi-metric-value-manual-entry-page.d.ts} +5 -5
  35. package/dist-client/pages/{kpi-value/kpi-value-manual-entry-page.js → kpi-metric-value/kpi-metric-value-manual-entry-page.js} +28 -28
  36. package/dist-client/pages/kpi-metric-value/kpi-metric-value-manual-entry-page.js.map +1 -0
  37. package/dist-client/pages/kpi-value/kpi-value-list-page.js +4 -6
  38. package/dist-client/pages/kpi-value/kpi-value-list-page.js.map +1 -1
  39. package/dist-client/route.d.ts +1 -1
  40. package/dist-client/route.js +5 -2
  41. package/dist-client/route.js.map +1 -1
  42. package/dist-client/tsconfig.tsbuildinfo +1 -1
  43. package/dist-server/service/index.d.ts +4 -2
  44. package/dist-server/service/index.js +6 -1
  45. package/dist-server/service/index.js.map +1 -1
  46. package/dist-server/service/kpi/aggregate-kpi.js +5 -7
  47. package/dist-server/service/kpi/aggregate-kpi.js.map +1 -1
  48. package/dist-server/service/kpi/kpi-history.d.ts +3 -1
  49. package/dist-server/service/kpi/kpi-history.js +10 -0
  50. package/dist-server/service/kpi/kpi-history.js.map +1 -1
  51. package/dist-server/service/kpi/kpi-mutation.js +1 -1
  52. package/dist-server/service/kpi/kpi-mutation.js.map +1 -1
  53. package/dist-server/service/kpi/kpi-type.d.ts +2 -0
  54. package/dist-server/service/kpi/kpi-type.js +8 -0
  55. package/dist-server/service/kpi/kpi-type.js.map +1 -1
  56. package/dist-server/service/kpi/kpi.d.ts +9 -0
  57. package/dist-server/service/kpi/kpi.js +23 -1
  58. package/dist-server/service/kpi/kpi.js.map +1 -1
  59. package/dist-server/service/kpi-category/kpi-category-mutation.js +0 -8
  60. package/dist-server/service/kpi-category/kpi-category-mutation.js.map +1 -1
  61. package/dist-server/service/kpi-category/kpi-category-type.d.ts +4 -2
  62. package/dist-server/service/kpi-category/kpi-category-type.js +16 -8
  63. package/dist-server/service/kpi-category/kpi-category-type.js.map +1 -1
  64. package/dist-server/service/kpi-category/kpi-category.d.ts +2 -2
  65. package/dist-server/service/kpi-category/kpi-category.js +8 -8
  66. package/dist-server/service/kpi-category/kpi-category.js.map +1 -1
  67. package/dist-server/service/kpi-metric/aggregate-kpi-metric.js +31 -74
  68. package/dist-server/service/kpi-metric/aggregate-kpi-metric.js.map +1 -1
  69. package/dist-server/service/kpi-metric/kpi-metric-mutation.d.ts +1 -1
  70. package/dist-server/service/kpi-metric/kpi-metric-mutation.js +15 -28
  71. package/dist-server/service/kpi-metric/kpi-metric-mutation.js.map +1 -1
  72. package/dist-server/service/kpi-metric/kpi-metric-type.d.ts +6 -4
  73. package/dist-server/service/kpi-metric/kpi-metric-type.js +20 -12
  74. package/dist-server/service/kpi-metric/kpi-metric-type.js.map +1 -1
  75. package/dist-server/service/kpi-metric/kpi-metric.d.ts +15 -2
  76. package/dist-server/service/kpi-metric/kpi-metric.js +34 -14
  77. package/dist-server/service/kpi-metric/kpi-metric.js.map +1 -1
  78. package/dist-server/service/kpi-metric-value/index.d.ts +6 -0
  79. package/dist-server/service/kpi-metric-value/index.js +10 -0
  80. package/dist-server/service/kpi-metric-value/index.js.map +1 -0
  81. package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.d.ts +11 -0
  82. package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.js +229 -0
  83. package/dist-server/service/kpi-metric-value/kpi-metric-value-mutation.js.map +1 -0
  84. package/dist-server/service/kpi-metric-value/kpi-metric-value-query.d.ts +13 -0
  85. package/dist-server/service/kpi-metric-value/kpi-metric-value-query.js +95 -0
  86. package/dist-server/service/kpi-metric-value/kpi-metric-value-query.js.map +1 -0
  87. package/dist-server/service/kpi-metric-value/kpi-metric-value-type.d.ts +26 -0
  88. package/dist-server/service/kpi-metric-value/kpi-metric-value-type.js +112 -0
  89. package/dist-server/service/kpi-metric-value/kpi-metric-value-type.js.map +1 -0
  90. package/dist-server/service/kpi-metric-value/kpi-metric-value.d.ts +23 -0
  91. package/dist-server/service/kpi-metric-value/kpi-metric-value.js +106 -0
  92. package/dist-server/service/kpi-metric-value/kpi-metric-value.js.map +1 -0
  93. package/dist-server/service/kpi-value/kpi-value-mutation.js +1 -2
  94. package/dist-server/service/kpi-value/kpi-value-mutation.js.map +1 -1
  95. package/dist-server/service/kpi-value/kpi-value-query.js +1 -1
  96. package/dist-server/service/kpi-value/kpi-value-query.js.map +1 -1
  97. package/dist-server/service/kpi-value/kpi-value-type.d.ts +2 -4
  98. package/dist-server/service/kpi-value/kpi-value-type.js +4 -18
  99. package/dist-server/service/kpi-value/kpi-value-type.js.map +1 -1
  100. package/dist-server/service/kpi-value/kpi-value.d.ts +3 -3
  101. package/dist-server/service/kpi-value/kpi-value.js +13 -14
  102. package/dist-server/service/kpi-value/kpi-value.js.map +1 -1
  103. package/dist-server/tsconfig.tsbuildinfo +1 -1
  104. package/package.json +5 -5
  105. package/server/service/index.ts +6 -1
  106. package/server/service/kpi/aggregate-kpi.ts +5 -8
  107. package/server/service/kpi/kpi-history.ts +9 -1
  108. package/server/service/kpi/kpi-mutation.ts +1 -1
  109. package/server/service/kpi/kpi-type.ts +6 -0
  110. package/server/service/kpi/kpi.ts +21 -0
  111. package/server/service/kpi-category/kpi-category-mutation.ts +0 -10
  112. package/server/service/kpi-category/kpi-category-type.ts +12 -6
  113. package/server/service/kpi-category/kpi-category.ts +6 -6
  114. package/server/service/kpi-metric/aggregate-kpi-metric.ts +29 -69
  115. package/server/service/kpi-metric/kpi-metric-mutation.ts +15 -26
  116. package/server/service/kpi-metric/kpi-metric-type.ts +17 -12
  117. package/server/service/kpi-metric/kpi-metric.ts +32 -11
  118. package/server/service/kpi-metric-value/index.ts +7 -0
  119. package/server/service/kpi-metric-value/kpi-metric-value-mutation.ts +215 -0
  120. package/server/service/kpi-metric-value/kpi-metric-value-query.ts +60 -0
  121. package/server/service/kpi-metric-value/kpi-metric-value-type.ts +82 -0
  122. package/server/service/kpi-metric-value/kpi-metric-value.ts +91 -0
  123. package/server/service/kpi-value/kpi-value-mutation.ts +1 -2
  124. package/server/service/kpi-value/kpi-value-query.ts +1 -1
  125. package/server/service/kpi-value/kpi-value-type.ts +4 -16
  126. package/server/service/kpi-value/kpi-value.ts +14 -14
  127. package/things-factory.config.js +5 -3
  128. package/translations/en.json +8 -1
  129. package/translations/ja.json +8 -1
  130. package/translations/ko.json +9 -2
  131. package/translations/ms.json +9 -2
  132. package/translations/zh.json +8 -1
  133. package/dist-client/pages/kpi-value/kpi-value-manual-entry-form.js.map +0 -1
  134. package/dist-client/pages/kpi-value/kpi-value-manual-entry-page.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import type { FileUpload } from 'graphql-upload/GraphQLUpload.js';
2
- import { KpiMetric } from './kpi-metric';
2
+ import { KpiMetric, KpiMetricPeriodType, KpiMetricCollectType } from './kpi-metric';
3
3
  export declare class NewKpiMetric {
4
4
  name: string;
5
5
  description?: string;
@@ -8,11 +8,12 @@ export declare class NewKpiMetric {
8
8
  dataSetId?: string;
9
9
  fieldName?: string;
10
10
  active?: boolean;
11
- formula?: string;
12
11
  schedule?: string;
13
12
  thumbnail?: FileUpload;
14
13
  timezone?: string;
15
14
  scheduleId?: string;
15
+ periodType?: KpiMetricPeriodType;
16
+ collectType?: KpiMetricCollectType;
16
17
  }
17
18
  export declare class KpiMetricPatch {
18
19
  id?: string;
@@ -23,12 +24,13 @@ export declare class KpiMetricPatch {
23
24
  dataSetId?: string;
24
25
  fieldName?: string;
25
26
  active?: boolean;
26
- formula?: string;
27
27
  schedule?: string;
28
28
  thumbnail?: FileUpload;
29
- cuFlag?: string;
30
29
  timezone?: string;
31
30
  scheduleId?: string;
31
+ periodType?: KpiMetricPeriodType;
32
+ cuFlag?: string;
33
+ collectType?: KpiMetricCollectType;
32
34
  }
33
35
  export declare class KpiMetricList {
34
36
  items: KpiMetric[];
@@ -36,10 +36,6 @@ tslib_1.__decorate([
36
36
  (0, type_graphql_1.Field)({ nullable: true, description: 'Indicates whether this metric is active and usable.' }),
37
37
  tslib_1.__metadata("design:type", Boolean)
38
38
  ], NewKpiMetric.prototype, "active", void 0);
39
- tslib_1.__decorate([
40
- (0, type_graphql_1.Field)({ nullable: true, description: 'Calculation formula for the metric, using other metric codes and operators.' }),
41
- tslib_1.__metadata("design:type", String)
42
- ], NewKpiMetric.prototype, "formula", void 0);
43
39
  tslib_1.__decorate([
44
40
  (0, type_graphql_1.Field)({
45
41
  nullable: true,
@@ -59,6 +55,14 @@ tslib_1.__decorate([
59
55
  (0, type_graphql_1.Field)({ nullable: true, description: 'Schedule ID for the registered cron job.' }),
60
56
  tslib_1.__metadata("design:type", String)
61
57
  ], NewKpiMetric.prototype, "scheduleId", void 0);
58
+ tslib_1.__decorate([
59
+ (0, type_graphql_1.Field)(type => kpi_metric_1.KpiMetricPeriodType, { nullable: true, description: 'Aggregation period type for this metric.' }),
60
+ tslib_1.__metadata("design:type", String)
61
+ ], NewKpiMetric.prototype, "periodType", void 0);
62
+ tslib_1.__decorate([
63
+ (0, type_graphql_1.Field)(type => kpi_metric_1.KpiMetricCollectType, { nullable: true, description: '데이터 수집 방식' }),
64
+ tslib_1.__metadata("design:type", String)
65
+ ], NewKpiMetric.prototype, "collectType", void 0);
62
66
  exports.NewKpiMetric = NewKpiMetric = tslib_1.__decorate([
63
67
  (0, type_graphql_1.InputType)({ description: 'Input type for creating a new KPI metric. Used in mutations to provide metric details.' })
64
68
  ], NewKpiMetric);
@@ -97,10 +101,6 @@ tslib_1.__decorate([
97
101
  (0, type_graphql_1.Field)({ nullable: true }),
98
102
  tslib_1.__metadata("design:type", Boolean)
99
103
  ], 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
104
  tslib_1.__decorate([
105
105
  (0, type_graphql_1.Field)({
106
106
  nullable: true,
@@ -112,10 +112,6 @@ tslib_1.__decorate([
112
112
  (0, type_graphql_1.Field)(type => GraphQLUpload_js_1.default, { nullable: true }),
113
113
  tslib_1.__metadata("design:type", Object)
114
114
  ], KpiMetricPatch.prototype, "thumbnail", void 0);
115
- tslib_1.__decorate([
116
- (0, type_graphql_1.Field)({ nullable: true }),
117
- tslib_1.__metadata("design:type", String)
118
- ], KpiMetricPatch.prototype, "cuFlag", void 0);
119
115
  tslib_1.__decorate([
120
116
  (0, type_graphql_1.Field)({ nullable: true, description: 'Timezone for the schedule.' }),
121
117
  tslib_1.__metadata("design:type", String)
@@ -124,6 +120,18 @@ tslib_1.__decorate([
124
120
  (0, type_graphql_1.Field)({ nullable: true, description: 'Schedule ID for the registered cron job.' }),
125
121
  tslib_1.__metadata("design:type", String)
126
122
  ], KpiMetricPatch.prototype, "scheduleId", void 0);
123
+ tslib_1.__decorate([
124
+ (0, type_graphql_1.Field)(type => kpi_metric_1.KpiMetricPeriodType, { nullable: true, description: 'Aggregation period type for this metric.' }),
125
+ tslib_1.__metadata("design:type", String)
126
+ ], KpiMetricPatch.prototype, "periodType", void 0);
127
+ tslib_1.__decorate([
128
+ (0, type_graphql_1.Field)({ nullable: true }),
129
+ tslib_1.__metadata("design:type", String)
130
+ ], KpiMetricPatch.prototype, "cuFlag", void 0);
131
+ tslib_1.__decorate([
132
+ (0, type_graphql_1.Field)(type => kpi_metric_1.KpiMetricCollectType, { nullable: true, description: '데이터 수집 방식' }),
133
+ tslib_1.__metadata("design:type", String)
134
+ ], KpiMetricPatch.prototype, "collectType", void 0);
127
135
  exports.KpiMetricPatch = KpiMetricPatch = tslib_1.__decorate([
128
136
  (0, type_graphql_1.InputType)()
129
137
  ], 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,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,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,4DAA4D,EAAE,CAAC;;4CACtF;AAGf;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC;;+CAC9E;AAGlB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,uDAAuD,EAAE,CAAC;;+CAC9E;AAGlB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,qDAAqD,EAAE,CAAC;;4CAC9E;AAG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iDACpB;AAGlB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACR;AAGlB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACV;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,6EAA6E,EAAE,CAAC;;+CACtG;AAMhB;IAJC,IAAA,oBAAK,EAAC;QACL,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,wFAAwF;KACtG,CAAC;;gDACe;AAGjB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,0BAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDAC3B;AAGtB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACX;AAGf;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;;gDACpD;AAEjB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;;kDAChE;yBA3CR,cAAc;IAD1B,IAAA,wBAAS,GAAE;GACC,cAAc,CA4C1B;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
+ {"version":3,"file":"kpi-metric-type.js","sourceRoot":"","sources":["../../../server/service/kpi-metric/kpi-metric-type.ts"],"names":[],"mappings":";;;;AACA,+FAA2D;AAC3D,+CAAsF;AAEtF,6CAAmF;AAG5E,IAAM,YAAY,GAAlB,MAAM,YAAY;CAyCxB,CAAA;AAzCY,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,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,4DAA4D,EAAE,CAAC;;4CACtF;AAGf;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC;;+CAC9E;AAGlB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,uDAAuD,EAAE,CAAC;;+CAC9E;AAGlB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,qDAAqD,EAAE,CAAC;;4CAC9E;AA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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 { KpiMetric, KpiMetricPeriodType, KpiMetricCollectType } 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({\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 @Field(type => KpiMetricPeriodType, { nullable: true, description: 'Aggregation period type for this metric.' })\n periodType?: KpiMetricPeriodType\n\n @Field(type => KpiMetricCollectType, { nullable: true, description: '데이터 수집 방식' })\n collectType?: KpiMetricCollectType\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({\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, description: 'Timezone for the schedule.' })\n timezone?: string\n\n @Field({ nullable: true, description: 'Schedule ID for the registered cron job.' })\n scheduleId?: string\n\n @Field(type => KpiMetricPeriodType, { nullable: true, description: 'Aggregation period type for this metric.' })\n periodType?: KpiMetricPeriodType\n\n @Field({ nullable: true })\n cuFlag?: string\n\n @Field(type => KpiMetricCollectType, { nullable: true, description: '데이터 수집 방식' })\n collectType?: KpiMetricCollectType\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,6 +1,19 @@
1
1
  import { Domain } from '@things-factory/shell';
2
2
  import { User } from '@things-factory/auth-base';
3
3
  import { DataSet } from '@things-factory/dataset';
4
+ export declare enum KpiMetricPeriodType {
5
+ DAY = "DAY",
6
+ WEEK = "WEEK",
7
+ MONTH = "MONTH",
8
+ QUARTER = "QUARTER",
9
+ RANGE = "RANGE"
10
+ }
11
+ export declare enum KpiMetricCollectType {
12
+ AUTO = "AUTO",// 데이터셋 등 자동 수집
13
+ MANUAL = "MANUAL",// 수동 입력
14
+ IMPORT = "IMPORT",// 외부 파일 등 임포트
15
+ EXTERNAL = "EXTERNAL"
16
+ }
4
17
  export declare class KpiMetric {
5
18
  readonly id: string;
6
19
  domain?: Domain;
@@ -13,10 +26,10 @@ export declare class KpiMetric {
13
26
  dataSetId?: string;
14
27
  fieldName?: string;
15
28
  active?: boolean;
16
- formula?: string;
17
- schedule?: string;
18
29
  scheduleId?: string;
19
30
  timezone?: string;
31
+ collectType: KpiMetricCollectType;
32
+ periodType: KpiMetricPeriodType;
20
33
  createdAt?: Date;
21
34
  updatedAt?: Date;
22
35
  deletedAt?: Date;
@@ -1,12 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KpiMetric = void 0;
3
+ exports.KpiMetric = exports.KpiMetricCollectType = exports.KpiMetricPeriodType = 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
9
  const dataset_1 = require("@things-factory/dataset");
10
+ var KpiMetricPeriodType;
11
+ (function (KpiMetricPeriodType) {
12
+ KpiMetricPeriodType["DAY"] = "DAY";
13
+ KpiMetricPeriodType["WEEK"] = "WEEK";
14
+ KpiMetricPeriodType["MONTH"] = "MONTH";
15
+ KpiMetricPeriodType["QUARTER"] = "QUARTER";
16
+ KpiMetricPeriodType["RANGE"] = "RANGE";
17
+ })(KpiMetricPeriodType || (exports.KpiMetricPeriodType = KpiMetricPeriodType = {}));
18
+ (0, type_graphql_1.registerEnumType)(KpiMetricPeriodType, {
19
+ name: 'KpiMetricPeriodType',
20
+ description: 'Aggregation period type for metric (DAY, WEEK, MONTH, QUARTER, RANGE)'
21
+ });
22
+ var KpiMetricCollectType;
23
+ (function (KpiMetricCollectType) {
24
+ KpiMetricCollectType["AUTO"] = "AUTO";
25
+ KpiMetricCollectType["MANUAL"] = "MANUAL";
26
+ KpiMetricCollectType["IMPORT"] = "IMPORT";
27
+ KpiMetricCollectType["EXTERNAL"] = "EXTERNAL"; // 외부 API 등
28
+ })(KpiMetricCollectType || (exports.KpiMetricCollectType = KpiMetricCollectType = {}));
29
+ (0, type_graphql_1.registerEnumType)(KpiMetricCollectType, {
30
+ name: 'KpiMetricCollectType',
31
+ description: '방식: AUTO(자동), MANUAL(수동), IMPORT(임포트), EXTERNAL(외부API)'
32
+ });
10
33
  let KpiMetric = class KpiMetric {
11
34
  };
12
35
  exports.KpiMetric = KpiMetric;
@@ -65,19 +88,6 @@ tslib_1.__decorate([
65
88
  (0, type_graphql_1.Field)({ nullable: true, description: 'Indicates whether this metric is active and usable.' }),
66
89
  tslib_1.__metadata("design:type", Boolean)
67
90
  ], KpiMetric.prototype, "active", void 0);
68
- tslib_1.__decorate([
69
- (0, typeorm_1.Column)({ 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
91
  tslib_1.__decorate([
82
92
  (0, typeorm_1.Column)({ nullable: true }),
83
93
  (0, type_graphql_1.Field)({ nullable: true, description: 'Schedule ID for the registered cron job.' }),
@@ -88,6 +98,16 @@ tslib_1.__decorate([
88
98
  (0, type_graphql_1.Field)({ nullable: true, description: 'Timezone for the schedule.' }),
89
99
  tslib_1.__metadata("design:type", String)
90
100
  ], KpiMetric.prototype, "timezone", void 0);
101
+ tslib_1.__decorate([
102
+ (0, typeorm_1.Column)({ type: 'enum', enum: KpiMetricCollectType, default: KpiMetricCollectType.AUTO }),
103
+ (0, type_graphql_1.Field)(type => KpiMetricCollectType, { description: '데이터 수집 방식' }),
104
+ tslib_1.__metadata("design:type", String)
105
+ ], KpiMetric.prototype, "collectType", void 0);
106
+ tslib_1.__decorate([
107
+ (0, typeorm_1.Column)({ default: 'DAY' }),
108
+ (0, type_graphql_1.Field)(type => KpiMetricPeriodType, { description: 'Aggregation period type for this metric.' }),
109
+ tslib_1.__metadata("design:type", String)
110
+ ], KpiMetric.prototype, "periodType", void 0);
91
111
  tslib_1.__decorate([
92
112
  (0, typeorm_1.CreateDateColumn)(),
93
113
  (0, type_graphql_1.Field)({ nullable: true, description: 'Timestamp when this KPI metric was created.' }),
@@ -1 +1 @@
1
- {"version":3,"file":"kpi-metric.js","sourceRoot":"","sources":["../../../server/service/kpi-metric/kpi-metric.ts"],"names":[],"mappings":";;;;AAAA,qCAUgB;AAChB,+CAA2E;AAE3E,iDAA8C;AAC9C,yDAAgD;AAChD,qDAAiD;AAQ1C,IAAM,SAAS,GAAf,MAAM,SAAS;CA8FrB,CAAA;AA9FY,8BAAS;AAGX;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;;qCAC1D;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,mDAAmD,EAAE,CAAC;sCACnF,cAAM;yCAAA;AAIf;IAFC,IAAA,oBAAU,EAAC,CAAC,MAAiB,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC;IAChD,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC;;2CACxE;AAIjB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,8DAA8D,EAAE,CAAC;;uCAC3E;AAIZ;IAFC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAA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cesContent":["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"]}
1
+ {"version":3,"file":"kpi-metric.js","sourceRoot":"","sources":["../../../server/service/kpi-metric/kpi-metric.ts"],"names":[],"mappings":";;;;AAAA,qCAUgB;AAChB,+CAA2E;AAE3E,iDAA8C;AAC9C,yDAAgD;AAChD,qDAAiD;AAEjD,IAAY,mBAMX;AAND,WAAY,mBAAmB;IAC7B,kCAAW,CAAA;IACX,oCAAa,CAAA;IACb,sCAAe,CAAA;IACf,0CAAmB,CAAA;I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AC,EAAE,WAAW,EAAE,wEAAwE,EAAE,CAAC;GACzF,SAAS,CA2FrB","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\nexport enum KpiMetricPeriodType {\n DAY = 'DAY',\n WEEK = 'WEEK',\n MONTH = 'MONTH',\n QUARTER = 'QUARTER',\n RANGE = 'RANGE'\n}\n\nregisterEnumType(KpiMetricPeriodType, {\n name: 'KpiMetricPeriodType',\n description: 'Aggregation period type for metric (DAY, WEEK, MONTH, QUARTER, RANGE)'\n})\n\nexport enum KpiMetricCollectType {\n AUTO = 'AUTO', // 데이터셋 등 자동 수집\n MANUAL = 'MANUAL', // 수동 입력\n IMPORT = 'IMPORT', // 외부 파일 등 임포트\n EXTERNAL = 'EXTERNAL' // 외부 API 등\n}\nregisterEnumType(KpiMetricCollectType, {\n name: 'KpiMetricCollectType',\n description: '방식: AUTO(자동), MANUAL(수동), IMPORT(임포트), EXTERNAL(외부API)'\n})\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: '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 @Column({ type: 'enum', enum: KpiMetricCollectType, default: KpiMetricCollectType.AUTO })\n @Field(type => KpiMetricCollectType, { description: '데이터 수집 방식' })\n collectType: KpiMetricCollectType\n\n @Column({ default: 'DAY' })\n @Field(type => KpiMetricPeriodType, { description: 'Aggregation period type for this metric.' })\n periodType: KpiMetricPeriodType\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"]}
@@ -0,0 +1,6 @@
1
+ import { KpiMetricValue } from './kpi-metric-value';
2
+ import { KpiMetricValueQuery } from './kpi-metric-value-query';
3
+ import { KpiMetricValueMutation } from './kpi-metric-value-mutation';
4
+ export declare const entities: (typeof KpiMetricValue)[];
5
+ export declare const resolvers: (typeof KpiMetricValueQuery | typeof KpiMetricValueMutation)[];
6
+ export declare const subscribers: any[];
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.subscribers = exports.resolvers = exports.entities = void 0;
4
+ const kpi_metric_value_1 = require("./kpi-metric-value");
5
+ const kpi_metric_value_query_1 = require("./kpi-metric-value-query");
6
+ const kpi_metric_value_mutation_1 = require("./kpi-metric-value-mutation");
7
+ exports.entities = [kpi_metric_value_1.KpiMetricValue];
8
+ exports.resolvers = [kpi_metric_value_query_1.KpiMetricValueQuery, kpi_metric_value_mutation_1.KpiMetricValueMutation];
9
+ exports.subscribers = [];
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/kpi-metric-value/index.ts"],"names":[],"mappings":";;;AAAA,yDAAmD;AACnD,qEAA8D;AAC9D,2EAAoE;AAEvD,QAAA,QAAQ,GAAG,CAAC,iCAAc,CAAC,CAAA;AAC3B,QAAA,SAAS,GAAG,CAAC,4CAAmB,EAAE,kDAAsB,CAAC,CAAA;AACzD,QAAA,WAAW,GAAG,EAAE,CAAA","sourcesContent":["import { KpiMetricValue } from './kpi-metric-value'\nimport { KpiMetricValueQuery } from './kpi-metric-value-query'\nimport { KpiMetricValueMutation } from './kpi-metric-value-mutation'\n\nexport const entities = [KpiMetricValue]\nexport const resolvers = [KpiMetricValueQuery, KpiMetricValueMutation]\nexport const subscribers = []\n"]}
@@ -0,0 +1,11 @@
1
+ import { KpiMetricValue } from './kpi-metric-value';
2
+ import { NewKpiMetricValue, KpiMetricValuePatch } from './kpi-metric-value-type';
3
+ export declare class KpiMetricValueMutation {
4
+ createKpiMetricValue(metricValue: NewKpiMetricValue, context: ResolverContext): Promise<KpiMetricValue>;
5
+ recordKpiMetricValue(metricName: string, value: number | null, meta: any, group: string | null, context: ResolverContext): Promise<KpiMetricValue>;
6
+ updateKpiMetricValue(id: string, patch: KpiMetricValuePatch, context: ResolverContext): Promise<KpiMetricValue>;
7
+ updateMultipleKpiMetricValue(patches: KpiMetricValuePatch[], context: ResolverContext): Promise<KpiMetricValue[]>;
8
+ deleteKpiMetricValue(id: string, context: ResolverContext): Promise<boolean>;
9
+ deleteKpiMetricValues(ids: string[], context: ResolverContext): Promise<boolean>;
10
+ importKpiMetricValues(metricValues: KpiMetricValuePatch[], context: ResolverContext): Promise<boolean>;
11
+ }
@@ -0,0 +1,229 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KpiMetricValueMutation = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const typeorm_1 = require("typeorm");
7
+ const shell_1 = require("@things-factory/shell");
8
+ const type_graphql_2 = require("type-graphql");
9
+ const kpi_1 = require("../kpi/kpi");
10
+ const kpi_metric_value_1 = require("./kpi-metric-value");
11
+ const kpi_metric_value_type_1 = require("./kpi-metric-value-type");
12
+ const kpi_metric_1 = require("../kpi-metric/kpi-metric");
13
+ const shell_2 = require("@things-factory/shell");
14
+ function getISOWeek(date) {
15
+ const tmp = new Date(date.getTime());
16
+ tmp.setHours(0, 0, 0, 0);
17
+ tmp.setDate(tmp.getDate() + 4 - (tmp.getDay() || 7));
18
+ const yearStart = new Date(tmp.getFullYear(), 0, 1);
19
+ const weekNo = Math.ceil(((tmp.getTime() - yearStart.getTime()) / 86400000 + 1) / 7);
20
+ return weekNo;
21
+ }
22
+ function getDefaultValueDate(periodType) {
23
+ const now = new Date();
24
+ switch (periodType) {
25
+ case kpi_1.KpiPeriodType.DAY:
26
+ return now.toISOString().slice(0, 10);
27
+ case kpi_1.KpiPeriodType.MONTH:
28
+ return now.toISOString().slice(0, 7);
29
+ case kpi_1.KpiPeriodType.QUARTER: {
30
+ const year = now.getFullYear();
31
+ const quarter = Math.floor(now.getMonth() / 3) + 1;
32
+ return `${year}-Q${quarter}`;
33
+ }
34
+ case kpi_1.KpiPeriodType.WEEK: {
35
+ const year = now.getFullYear();
36
+ const week = getISOWeek(now);
37
+ return `${year}-W${week}`;
38
+ }
39
+ default:
40
+ return now.toISOString().slice(0, 10);
41
+ }
42
+ }
43
+ let KpiMetricValueMutation = class KpiMetricValueMutation {
44
+ async createKpiMetricValue(metricValue, context) {
45
+ const { domain, user, tx } = context.state;
46
+ let metric = metricValue.metricId
47
+ ? await (0, shell_1.getRepository)(kpi_metric_1.KpiMetric).findOne({ where: { id: metricValue.metricId } })
48
+ : undefined;
49
+ const entity = {
50
+ metric,
51
+ metricId: metricValue.metricId,
52
+ valueDate: metricValue.valueDate,
53
+ periodType: metricValue.periodType,
54
+ value: metricValue.value,
55
+ group: metricValue.group,
56
+ unit: metricValue.unit,
57
+ meta: metricValue.meta,
58
+ domain: domain,
59
+ creator: user,
60
+ updater: user
61
+ };
62
+ return await (0, shell_1.getRepository)(kpi_metric_value_1.KpiMetricValue, tx).save(entity);
63
+ }
64
+ async recordKpiMetricValue(metricName, value, meta, group, context) {
65
+ const { domain, user, tx } = context.state;
66
+ const metric = await (0, shell_1.getRepository)(kpi_metric_1.KpiMetric).findOne({ where: { name: metricName, domain: { id: domain.id } } });
67
+ if (!metric)
68
+ throw new Error(`Metric not found: ${metricName}`);
69
+ const periodType = metric.periodType || kpi_1.KpiPeriodType.DAY;
70
+ const valueDateToUse = getDefaultValueDate(periodType);
71
+ if (value == null && meta == null) {
72
+ throw new Error('Either value or meta must be provided.');
73
+ }
74
+ const entity = {
75
+ metric,
76
+ metricId: metric.id,
77
+ value,
78
+ meta,
79
+ valueDate: valueDateToUse,
80
+ periodType,
81
+ group,
82
+ domain,
83
+ creator: user,
84
+ updater: user
85
+ };
86
+ return await (0, shell_1.getRepository)(kpi_metric_value_1.KpiMetricValue, tx).save(entity);
87
+ }
88
+ async updateKpiMetricValue(id, patch, context) {
89
+ const { domain, user, tx } = context.state;
90
+ const repository = (0, shell_1.getRepository)(kpi_metric_value_1.KpiMetricValue, tx);
91
+ const metricValue = await repository.findOne({
92
+ where: { domain: { id: domain.id }, id }
93
+ });
94
+ let metric = patch.metricId
95
+ ? await (0, shell_1.getRepository)(kpi_metric_1.KpiMetric).findOne({ where: { id: patch.metricId } })
96
+ : metricValue.metric;
97
+ const entity = {
98
+ ...metricValue,
99
+ ...patch,
100
+ metric,
101
+ updater: user
102
+ };
103
+ return await repository.save(entity);
104
+ }
105
+ async updateMultipleKpiMetricValue(patches, context) {
106
+ const { domain, user, tx } = context.state;
107
+ let results = [];
108
+ const _createRecords = patches.filter((patch) => patch.cuFlag && patch.cuFlag.toUpperCase() === '+');
109
+ const _updateRecords = patches.filter((patch) => patch.cuFlag && patch.cuFlag.toUpperCase() === 'M');
110
+ const metricValueRepo = (0, shell_1.getRepository)(kpi_metric_value_1.KpiMetricValue, tx);
111
+ if (_createRecords.length > 0) {
112
+ for (let i = 0; i < _createRecords.length; i++) {
113
+ const newRecord = _createRecords[i];
114
+ const result = await metricValueRepo.save({
115
+ ...newRecord,
116
+ domain,
117
+ creator: user,
118
+ updater: user
119
+ });
120
+ results.push({ ...result, cuFlag: '+' });
121
+ }
122
+ }
123
+ if (_updateRecords.length > 0) {
124
+ for (let i = 0; i < _updateRecords.length; i++) {
125
+ const updateRecord = _updateRecords[i];
126
+ const metricValue = await metricValueRepo.findOneBy({ id: updateRecord.id });
127
+ const result = await metricValueRepo.save({
128
+ ...metricValue,
129
+ ...updateRecord,
130
+ updater: user
131
+ });
132
+ results.push({ ...result, cuFlag: 'M' });
133
+ }
134
+ }
135
+ return results;
136
+ }
137
+ async deleteKpiMetricValue(id, context) {
138
+ const { domain, tx } = context.state;
139
+ await (0, shell_1.getRepository)(kpi_metric_value_1.KpiMetricValue, tx).delete({ domain: { id: domain.id }, id });
140
+ return true;
141
+ }
142
+ async deleteKpiMetricValues(ids, context) {
143
+ const { domain, tx } = context.state;
144
+ await (0, shell_1.getRepository)(kpi_metric_value_1.KpiMetricValue, tx).delete({
145
+ domain: { id: domain.id },
146
+ id: (0, typeorm_1.In)(ids)
147
+ });
148
+ return true;
149
+ }
150
+ async importKpiMetricValues(metricValues, context) {
151
+ const { domain, tx } = context.state;
152
+ await Promise.all(metricValues.map(async (metricValue) => {
153
+ await (0, shell_1.getRepository)(kpi_metric_value_1.KpiMetricValue, tx).save({ domain, ...metricValue });
154
+ }));
155
+ return true;
156
+ }
157
+ };
158
+ exports.KpiMetricValueMutation = KpiMetricValueMutation;
159
+ tslib_1.__decorate([
160
+ (0, type_graphql_1.Directive)('@transaction'),
161
+ (0, type_graphql_1.Mutation)(returns => kpi_metric_value_1.KpiMetricValue, { description: 'Create a new metric value with the provided details.' }),
162
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('metricValue', { description: 'Input object containing details for the new metric value.' })),
163
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
164
+ tslib_1.__metadata("design:type", Function),
165
+ tslib_1.__metadata("design:paramtypes", [kpi_metric_value_type_1.NewKpiMetricValue, Object]),
166
+ tslib_1.__metadata("design:returntype", Promise)
167
+ ], KpiMetricValueMutation.prototype, "createKpiMetricValue", null);
168
+ tslib_1.__decorate([
169
+ (0, type_graphql_1.Directive)('@transaction'),
170
+ (0, type_graphql_1.Mutation)(returns => kpi_metric_value_1.KpiMetricValue, { description: 'Record a metric value by metric name, value, meta, and group.' }),
171
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('metricName', { description: 'Metric code/name.' })),
172
+ tslib_1.__param(1, (0, type_graphql_1.Arg)('value', type => type_graphql_2.Float, { nullable: true, description: 'Metric value (number).' })),
173
+ tslib_1.__param(2, (0, type_graphql_1.Arg)('meta', type => shell_2.ScalarObject, { nullable: true, description: 'Extended or non-numeric information (JSON).' })),
174
+ tslib_1.__param(3, (0, type_graphql_1.Arg)('group', { nullable: true, description: 'Group key for this value (organization, line, user, etc.)' })),
175
+ tslib_1.__param(4, (0, type_graphql_1.Ctx)()),
176
+ tslib_1.__metadata("design:type", Function),
177
+ tslib_1.__metadata("design:paramtypes", [String, Number, Object, String, Object]),
178
+ tslib_1.__metadata("design:returntype", Promise)
179
+ ], KpiMetricValueMutation.prototype, "recordKpiMetricValue", null);
180
+ tslib_1.__decorate([
181
+ (0, type_graphql_1.Directive)('@transaction'),
182
+ (0, type_graphql_1.Mutation)(returns => kpi_metric_value_1.KpiMetricValue, { description: 'To modify KpiMetricValue information' }),
183
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
184
+ tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
185
+ tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
186
+ tslib_1.__metadata("design:type", Function),
187
+ tslib_1.__metadata("design:paramtypes", [String, kpi_metric_value_type_1.KpiMetricValuePatch, Object]),
188
+ tslib_1.__metadata("design:returntype", Promise)
189
+ ], KpiMetricValueMutation.prototype, "updateKpiMetricValue", null);
190
+ tslib_1.__decorate([
191
+ (0, type_graphql_1.Directive)('@transaction'),
192
+ (0, type_graphql_1.Mutation)(returns => [kpi_metric_value_1.KpiMetricValue], { description: "To modify multiple KpiMetricValues' information" }),
193
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [kpi_metric_value_type_1.KpiMetricValuePatch])),
194
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
195
+ tslib_1.__metadata("design:type", Function),
196
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
197
+ tslib_1.__metadata("design:returntype", Promise)
198
+ ], KpiMetricValueMutation.prototype, "updateMultipleKpiMetricValue", null);
199
+ tslib_1.__decorate([
200
+ (0, type_graphql_1.Directive)('@transaction'),
201
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete KpiMetricValue' }),
202
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
203
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
204
+ tslib_1.__metadata("design:type", Function),
205
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
206
+ tslib_1.__metadata("design:returntype", Promise)
207
+ ], KpiMetricValueMutation.prototype, "deleteKpiMetricValue", null);
208
+ tslib_1.__decorate([
209
+ (0, type_graphql_1.Directive)('@transaction'),
210
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple KpiMetricValues' }),
211
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
212
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
213
+ tslib_1.__metadata("design:type", Function),
214
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
215
+ tslib_1.__metadata("design:returntype", Promise)
216
+ ], KpiMetricValueMutation.prototype, "deleteKpiMetricValues", null);
217
+ tslib_1.__decorate([
218
+ (0, type_graphql_1.Directive)('@transaction'),
219
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple KpiMetricValues' }),
220
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('metricValues', type => [kpi_metric_value_type_1.KpiMetricValuePatch])),
221
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
222
+ tslib_1.__metadata("design:type", Function),
223
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
224
+ tslib_1.__metadata("design:returntype", Promise)
225
+ ], KpiMetricValueMutation.prototype, "importKpiMetricValues", null);
226
+ exports.KpiMetricValueMutation = KpiMetricValueMutation = tslib_1.__decorate([
227
+ (0, type_graphql_1.Resolver)(kpi_metric_value_1.KpiMetricValue)
228
+ ], KpiMetricValueMutation);
229
+ //# sourceMappingURL=kpi-metric-value-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kpi-metric-value-mutation.js","sourceRoot":"","sources":["../../../server/service/kpi-metric-value/kpi-metric-value-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAC5B,iDAAqD;AACrD,+CAAoC;AACpC,oCAA0C;AAE1C,yDAAmD;AACnD,mEAAgF;AAChF,yDAAoD;AACpD,iDAAoD;AAEpD,SAAS,UAAU,CAAC,IAAU;IAC5B,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IACpC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IACxB,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;IACpD,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IACnD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IACpF,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,mBAAmB,CAAC,UAAyB;IACpD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IACtB,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,mBAAa,CAAC,GAAG;YACpB,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC,KAAK,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,oCAAoC,EAAE,CAAC;IAEjF,mBAAA,IAAA,kBAAG,EAAC,cAAc,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,2CAAmB,CAAC,CAAC,CAAA;IAClD,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;mEASP;iCA1KU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,iCAAc,CAAC;GACZ,sBAAsB,CA2KlC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\nimport { getRepository } from '@things-factory/shell'\nimport { Float } from 'type-graphql'\nimport { KpiPeriodType } from '../kpi/kpi'\n\nimport { KpiMetricValue } from './kpi-metric-value'\nimport { NewKpiMetricValue, KpiMetricValuePatch } from './kpi-metric-value-type'\nimport { KpiMetric } from '../kpi-metric/kpi-metric'\nimport { ScalarObject } from '@things-factory/shell'\n\nfunction getISOWeek(date: Date): number {\n const tmp = new Date(date.getTime())\n tmp.setHours(0, 0, 0, 0)\n tmp.setDate(tmp.getDate() + 4 - (tmp.getDay() || 7))\n const yearStart = new Date(tmp.getFullYear(), 0, 1)\n const weekNo = Math.ceil(((tmp.getTime() - yearStart.getTime()) / 86400000 + 1) / 7)\n return weekNo\n}\n\nfunction getDefaultValueDate(periodType: KpiPeriodType): string {\n const now = new Date()\n switch (periodType) {\n case KpiPeriodType.DAY:\n return now.toISOString().slice(0, 10)\n case KpiPeriodType.MONTH:\n return now.toISOString().slice(0, 7)\n case KpiPeriodType.QUARTER: {\n const year = now.getFullYear()\n const quarter = Math.floor(now.getMonth() / 3) + 1\n return `${year}-Q${quarter}`\n }\n case KpiPeriodType.WEEK: {\n const year = now.getFullYear()\n const week = getISOWeek(now)\n return `${year}-W${week}`\n }\n default:\n return now.toISOString().slice(0, 10)\n }\n}\n\n@Resolver(KpiMetricValue)\nexport class KpiMetricValueMutation {\n @Directive('@transaction')\n @Mutation(returns => KpiMetricValue, { description: 'Create a new metric value with the provided details.' })\n async createKpiMetricValue(\n @Arg('metricValue', { description: 'Input object containing details for the new metric value.' })\n metricValue: NewKpiMetricValue,\n @Ctx() context: ResolverContext\n ): Promise<KpiMetricValue> {\n const { domain, user, tx } = context.state\n\n let metric = metricValue.metricId\n ? await getRepository(KpiMetric).findOne({ where: { id: metricValue.metricId } })\n : undefined\n\n const entity: Partial<KpiMetricValue> = {\n metric,\n metricId: metricValue.metricId,\n valueDate: metricValue.valueDate,\n periodType: metricValue.periodType,\n value: metricValue.value,\n group: metricValue.group,\n unit: metricValue.unit,\n meta: metricValue.meta,\n domain: domain,\n creator: user,\n updater: user\n }\n\n return await getRepository(KpiMetricValue, tx).save(entity)\n }\n\n @Directive('@transaction')\n @Mutation(returns => KpiMetricValue, { description: 'Record a metric value by metric name, value, meta, and group.' })\n async recordKpiMetricValue(\n @Arg('metricName', { description: 'Metric code/name.' }) metricName: string,\n @Arg('value', type => Float, { nullable: true, description: 'Metric value (number).' }) value: number | null,\n @Arg('meta', type => ScalarObject, { nullable: true, description: 'Extended or non-numeric information (JSON).' })\n meta: any,\n @Arg('group', { nullable: true, description: 'Group key for this value (organization, line, user, etc.)' })\n group: string | null,\n @Ctx() context: ResolverContext\n ): Promise<KpiMetricValue> {\n const { domain, user, tx } = context.state\n const metric = await getRepository(KpiMetric).findOne({ where: { name: metricName, domain: { id: domain.id } } })\n if (!metric) throw new Error(`Metric not found: ${metricName}`)\n const periodType = (metric.periodType as unknown as KpiPeriodType) || KpiPeriodType.DAY\n const valueDateToUse = getDefaultValueDate(periodType)\n if (value == null && meta == null) {\n throw new Error('Either value or meta must be provided.')\n }\n const entity: Partial<KpiMetricValue> = {\n metric,\n metricId: metric.id,\n value,\n meta,\n valueDate: valueDateToUse,\n periodType,\n group,\n domain,\n creator: user,\n updater: user\n }\n return await getRepository(KpiMetricValue, tx).save(entity)\n }\n\n @Directive('@transaction')\n @Mutation(returns => KpiMetricValue, { description: 'To modify KpiMetricValue information' })\n async updateKpiMetricValue(\n @Arg('id') id: string,\n @Arg('patch') patch: KpiMetricValuePatch,\n @Ctx() context: ResolverContext\n ): Promise<KpiMetricValue> {\n const { domain, user, tx } = context.state\n\n const repository = getRepository(KpiMetricValue, tx)\n const metricValue = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n let metric = patch.metricId\n ? await getRepository(KpiMetric).findOne({ where: { id: patch.metricId } })\n : metricValue.metric\n\n const entity: any = {\n ...metricValue,\n ...patch,\n metric,\n updater: user\n }\n\n return await repository.save(entity)\n }\n\n @Directive('@transaction')\n @Mutation(returns => [KpiMetricValue], { description: \"To modify multiple KpiMetricValues' information\" })\n async updateMultipleKpiMetricValue(\n @Arg('patches', type => [KpiMetricValuePatch]) patches: KpiMetricValuePatch[],\n @Ctx() context: ResolverContext\n ): Promise<KpiMetricValue[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag && patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag && patch.cuFlag.toUpperCase() === 'M')\n const metricValueRepo = getRepository(KpiMetricValue, tx)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n const result = await metricValueRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n } as any)\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 metricValue = await metricValueRepo.findOneBy({ id: updateRecord.id })\n const result = await metricValueRepo.save({\n ...metricValue,\n ...updateRecord,\n updater: user\n } as any)\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete KpiMetricValue' })\n async deleteKpiMetricValue(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n await getRepository(KpiMetricValue, tx).delete({ domain: { id: domain.id }, id })\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple KpiMetricValues' })\n async deleteKpiMetricValues(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n await getRepository(KpiMetricValue, tx).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To import multiple KpiMetricValues' })\n async importKpiMetricValues(\n @Arg('metricValues', type => [KpiMetricValuePatch]) metricValues: KpiMetricValuePatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n await Promise.all(\n metricValues.map(async (metricValue: KpiMetricValuePatch) => {\n await getRepository(KpiMetricValue, tx).save({ domain, ...metricValue } as any)\n })\n )\n return true\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { Domain, ListParam } from '@things-factory/shell';
2
+ import { User } from '@things-factory/auth-base';
3
+ import { KpiMetricValue } from './kpi-metric-value';
4
+ import { KpiMetricValueList } from './kpi-metric-value-type';
5
+ import { KpiMetric } from '../kpi-metric/kpi-metric';
6
+ export declare class KpiMetricValueQuery {
7
+ kpiMetricValues(params: ListParam, context: ResolverContext): Promise<KpiMetricValueList>;
8
+ kpiMetricValue(id: string, context: ResolverContext): Promise<KpiMetricValue | null>;
9
+ domain(metricValue: KpiMetricValue): Promise<Domain>;
10
+ updater(metricValue: KpiMetricValue): Promise<User>;
11
+ creator(metricValue: KpiMetricValue): Promise<User>;
12
+ metric(metricValue: KpiMetricValue): Promise<KpiMetric | null>;
13
+ }