@3e/sqa-common 6.0.6-2 → 6.0.6-5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +314 -108
  2. package/package.json +1 -1
  3. package/sqa_common.js +948 -922
package/index.d.ts CHANGED
@@ -672,21 +672,30 @@ declare module '@3e/sqa-common' {
672
672
  body: Section[]
673
673
  }
674
674
 
675
+ export type ParameterOption = {
676
+ options: {value: string; label: string}[]
677
+ id: string
678
+ label: string
679
+ ldType: string
680
+ container?: string
681
+ value: string
682
+ }
683
+
675
684
  export interface ApiConfig extends RequestInit {
676
685
  token?: string
677
686
  body?: any
678
687
  }
679
688
 
680
689
  export type ApiFn = (
681
- endpoint: string,
682
- config?: ApiConfig,
690
+ endpoint: string,
691
+ config?: ApiConfig,
683
692
  ) => Promise<
684
- {status: ErrorStatus} | {body: Record<string, any>; status: OKStatus}
685
- >
693
+ {status: ErrorStatus} | {body: Record<string, any>; status: OKStatus}
694
+ >
686
695
 
687
696
  export type TokenThunk = () => Promise<
688
- {status: OKStatus; body: {token: string}} | {status: ErrorStatus}
689
- >
697
+ {status: OKStatus; body: {token: string}} | {status: ErrorStatus}
698
+ >
690
699
 
691
700
  export interface InitialisationConfig {
692
701
  apiFn: ApiFn
@@ -695,75 +704,75 @@ declare module '@3e/sqa-common' {
695
704
  export type PeriodTimeMode = 'absolute' | 'local'
696
705
 
697
706
  export type ViewType =
698
- | 'time-chart'
699
- | 'object-chart'
700
- | 'object-heatmap'
701
- | 'scatter-chart'
702
- | 'object-table'
703
- | 'time-table'
704
- | 'kpis'
707
+ | 'time-chart'
708
+ | 'object-chart'
709
+ | 'object-heatmap'
710
+ | 'scatter-chart'
711
+ | 'object-table'
712
+ | 'time-table'
713
+ | 'kpis'
705
714
 
706
715
  export type Granularity =
707
- | '1 minute'
708
- | '5 minutes'
709
- | '10 minutes'
710
- | '15 minutes'
711
- | '30 minutes'
712
- | '1 hour'
713
- | '1 day'
714
- | '1 week'
715
- | '1 month'
716
- | '3 months'
717
- | '1 year'
716
+ | '1 minute'
717
+ | '5 minutes'
718
+ | '10 minutes'
719
+ | '15 minutes'
720
+ | '30 minutes'
721
+ | '1 hour'
722
+ | '1 day'
723
+ | '1 week'
724
+ | '1 month'
725
+ | '3 months'
726
+ | '1 year'
718
727
 
719
728
  export type Period =
720
- | 'last-7-days'
721
- | 'last-week'
722
- | 'since-beginning'
723
- | 'last-12-months'
724
- | 'year-to-date'
725
- | 'today'
726
- | 'current-month'
727
- | 'last-month'
728
- | 'forecast-4-days'
729
- | 'tomorrow'
730
- | 'last-24-hours'
731
- | 'last-30-days'
732
- | 'last-7x24-hours'
733
- | 'last-3x24-hours'
734
- | 'last-15-minutes'
735
- | 'last-3-days'
736
- | 'last-year'
737
- | 'yesterday'
738
- | 'forecast-10-days'
739
- | 'custom'
729
+ | 'last-7-days'
730
+ | 'last-week'
731
+ | 'since-beginning'
732
+ | 'last-12-months'
733
+ | 'year-to-date'
734
+ | 'today'
735
+ | 'current-month'
736
+ | 'last-month'
737
+ | 'forecast-4-days'
738
+ | 'tomorrow'
739
+ | 'last-24-hours'
740
+ | 'last-30-days'
741
+ | 'last-7x24-hours'
742
+ | 'last-3x24-hours'
743
+ | 'last-15-minutes'
744
+ | 'last-3-days'
745
+ | 'last-year'
746
+ | 'yesterday'
747
+ | 'forecast-10-days'
748
+ | 'custom'
740
749
 
741
750
  export type LevelValue =
742
- | 'site-group'
743
- | 'site'
744
- | 'ac-node'
745
- | 'ac-input'
746
- | 'ac-phase'
747
- | 'connection'
748
- | 'dc-input'
749
- | 'dc-node'
750
- | 'inverter'
751
- | 'inverter-device'
752
- | 'logger'
753
- | 'mppt'
754
- | 'module-group'
755
- | 'power-unit'
756
- | 'sensor'
757
- | 'strings'
758
- | 'tracker'
751
+ | 'site-group'
752
+ | 'site'
753
+ | 'ac-node'
754
+ | 'ac-input'
755
+ | 'ac-phase'
756
+ | 'connection'
757
+ | 'dc-input'
758
+ | 'dc-node'
759
+ | 'inverter'
760
+ | 'inverter-device'
761
+ | 'logger'
762
+ | 'mppt'
763
+ | 'module-group'
764
+ | 'power-unit'
765
+ | 'sensor'
766
+ | 'strings'
767
+ | 'tracker'
759
768
 
760
769
  export type RepresentationValue =
761
- | 'line'
762
- | 'line-and-marker'
763
- | 'marker'
764
- | 'spline'
765
- | 'column'
766
- | 'area'
770
+ | 'line'
771
+ | 'line-and-marker'
772
+ | 'marker'
773
+ | 'spline'
774
+ | 'column'
775
+ | 'area'
767
776
 
768
777
  export type StackingOptionValue = 'no' | 'normal' | 'percent'
769
778
 
@@ -777,6 +786,7 @@ declare module '@3e/sqa-common' {
777
786
  export type Level = {
778
787
  value: LevelValue
779
788
  label: string
789
+ models?: {label: string; value: string}[]
780
790
  }
781
791
 
782
792
  /**
@@ -787,6 +797,8 @@ declare module '@3e/sqa-common' {
787
797
  label: string
788
798
  }
789
799
 
800
+ export type ContainerValue = string
801
+
790
802
  /**
791
803
  * Containers (Actually physical plants)
792
804
  */
@@ -825,6 +837,15 @@ declare module '@3e/sqa-common' {
825
837
 
826
838
  export type ColorSchemeValue = 'scheme_blrd' | 'scheme_ylrdbl'
827
839
 
840
+ export type ColorSettings =
841
+ | {
842
+ label: string
843
+ value: string
844
+ type: 'palette'
845
+ colors: string[]
846
+ }
847
+ | {label: string; value: string; type: 'fixed'; color: string}
848
+
828
849
  export type ColorScheme = {
829
850
  value: ColorSchemeValue
830
851
  label: string
@@ -882,13 +903,63 @@ declare module '@3e/sqa-common' {
882
903
  }
883
904
  }
884
905
 
906
+ export interface LdType {
907
+ sqid: string
908
+ ref: string
909
+ label: string
910
+ }
911
+
912
+ export interface LDRoot {
913
+ sqid: string
914
+ ref: string
915
+ label: string
916
+ }
917
+
918
+ export interface Model {
919
+ sqid: string
920
+ ref: string
921
+ label: string
922
+ }
923
+
924
+ export interface LogicalDevice {
925
+ sqid: string
926
+ ld_type: string
927
+ ref: string
928
+ root: LDRoot
929
+ label: string
930
+ full_name: string
931
+ act_to: Date
932
+ act_from: Date
933
+ model: Model
934
+ }
935
+
936
+ export interface Indicator {
937
+ default_graphical_representation: string
938
+ description: string
939
+ key: string
940
+ label: string
941
+ level: LevelValue
942
+ unit: string
943
+ unit_key: string
944
+ }
945
+
946
+ export interface LDIndicator {
947
+ indicator_key: string
948
+ object_ref: string
949
+ unit: string
950
+ unit_key: string
951
+ }
952
+
885
953
  /**
886
954
  * Options for representing the dataset
887
955
  */
888
956
  export interface DatasetOptions {
889
- graphicalRepresentation: string
890
- id: string
891
- colorSetting: string
957
+ graphicalRepresentation?: string
958
+ id?: string
959
+ colorSetting?: string
960
+ stacking?: StackingOptionValue
961
+ showNullsAs?: string
962
+ label?: string
892
963
  }
893
964
 
894
965
  export interface DatasetTemplateSpec {
@@ -897,7 +968,52 @@ declare module '@3e/sqa-common' {
897
968
  selectedTemplate: string
898
969
  }
899
970
 
900
- export type Dataset = any //TODO: Better types here
971
+ export interface Object {
972
+ name: string
973
+ level: LevelValue
974
+ ref: string
975
+ type: string
976
+ statistics?: {
977
+ median: number
978
+ mean: number
979
+ sum: number
980
+ min: number
981
+ max: number
982
+ }
983
+ }
984
+
985
+ export interface ObjectSet {
986
+ template: string
987
+ level: string
988
+ objects: Object[]
989
+ }
990
+
991
+ export interface UnitScale {
992
+ min?: any
993
+ max?: any
994
+ }
995
+
996
+ export type Scaling = Record<string, UnitScale>
997
+
998
+ export interface Dataset {
999
+ objects?: any
1000
+ colorSetting?: ColorSettings
1001
+ indicators: Indicator[]
1002
+ objectSet: ObjectSet
1003
+ stacking: StackingOptionValue
1004
+ showNullsAs?: any
1005
+ representation: string
1006
+ label?: any
1007
+ id: string
1008
+ scaling: Scaling
1009
+ stack?: any
1010
+ error?: any
1011
+ idx: number
1012
+ objectSetLabel: string
1013
+ }
1014
+
1015
+ // TODO: Better types for PacoViewParameters
1016
+ type PacoViewParameters = any
901
1017
 
902
1018
  /**
903
1019
  * Type definitions for all the API
@@ -917,8 +1033,8 @@ declare module '@3e/sqa-common' {
917
1033
  * @param getToken - function with no arguments that returns the JWT token
918
1034
  */
919
1035
  wrapRefresh(
920
- apiFn: ApiFn,
921
- getToken: TokenThunk,
1036
+ apiFn: ApiFn,
1037
+ getToken: TokenThunk,
922
1038
  ): {apiFn: ApiFn; resetFn: () => void}
923
1039
 
924
1040
  /**
@@ -932,6 +1048,12 @@ declare module '@3e/sqa-common' {
932
1048
  */
933
1049
  newEmptyView(viewOptions: EmptyViewOptions): SQView
934
1050
 
1051
+ /**
1052
+ * Returns the type for the given view
1053
+ * @param view SQView
1054
+ */
1055
+ getViewType(view: SQView): ViewType
1056
+
935
1057
  /**
936
1058
  * Get title of the view
937
1059
  * @param view - the SQView
@@ -977,19 +1099,28 @@ declare module '@3e/sqa-common' {
977
1099
  * @param options - creation options
978
1100
  */
979
1101
  getVisualization(
980
- view: SQView,
981
- options: VisualisationOptions,
1102
+ view: SQView,
1103
+ options: VisualisationOptions,
982
1104
  ): Promise<Visualization>
983
1105
 
984
1106
  /**
985
1107
  * Populates a visualization with data, using the default `append-data` to append each page.
986
1108
  * @param visualisation - the visualization to be populated
987
- * @param callback - A callback that will be called when the operation is complete
1109
+ * @param callback - Callback function called with the populated viz when the operation is done
1110
+ *
1111
+ * @returns a function to cancel the operation
988
1112
  */
989
1113
  populateVisualisation(
990
- visualisation: Visualization,
991
- callback: (data: any) => void,
992
- ): Promise<void>
1114
+ visualisation: Visualization,
1115
+ callback: (visualization: Visualization) => void,
1116
+ ): () => void
1117
+
1118
+ /**
1119
+ * @param visualisation - the visualization to be populated
1120
+ *
1121
+ * @returns A promise with the populated visualization
1122
+ */
1123
+ populateVisualisation(visualisation: Visualization): Promise<Visualization>
993
1124
 
994
1125
  /**
995
1126
  * Returns the granularity for the view
@@ -999,9 +1130,10 @@ declare module '@3e/sqa-common' {
999
1130
 
1000
1131
  /**
1001
1132
  * Returns the granularity for the view
1002
- * @param view
1133
+ * @param view - the view to modify
1134
+ * @param granularity - the new granularity
1003
1135
  */
1004
- setGranularityParameter(view: SQView): Granularity
1136
+ setGranularityParameter(view: SQView, granularity: Granularity): SQView
1005
1137
 
1006
1138
  /**
1007
1139
  * Returns the object parameters for a view
@@ -1010,10 +1142,10 @@ declare module '@3e/sqa-common' {
1010
1142
  getObjectParameters(view: SQView): {
1011
1143
  id: string
1012
1144
  label: string
1013
- ldType: LDType
1014
- container: Container
1145
+ ldType: string
1146
+ container: string
1015
1147
  value: string
1016
- }
1148
+ }[]
1017
1149
 
1018
1150
  /**
1019
1151
  * Sets the object parameter with the given id
@@ -1028,12 +1160,14 @@ declare module '@3e/sqa-common' {
1028
1160
  {value: 'plant'; label: 'Display data in the timezone of the plant'},
1029
1161
  ]
1030
1162
 
1031
- ShowNullAsOptions: [
1163
+ ShowNullsAsOptions: [
1032
1164
  {value: 'no'; label: 'No'},
1033
1165
  {value: 'normal'; label: 'Normal'},
1034
1166
  {value: 'percent'; label: 'Percent'},
1035
1167
  ]
1036
1168
 
1169
+ ViewTypes: {label: string; value: ViewType}[]
1170
+
1037
1171
  /**
1038
1172
  * A collection of all timezones in the format {label, value}
1039
1173
  */
@@ -1056,12 +1190,33 @@ declare module '@3e/sqa-common' {
1056
1190
  */
1057
1191
  getColorSchemes(): ColorScheme[]
1058
1192
 
1193
+ /**
1194
+ * Returns the possible color settings for a certain view type
1195
+ * @param viewType
1196
+ */
1197
+ getColorSettings(viewType: ViewType): ColorSettings[]
1198
+
1199
+ getColorSettingsCssStyle(colorSetting: ColorSettings):
1200
+ | {
1201
+ backgroundColor: string
1202
+ }
1203
+ | {
1204
+ backgroundImage: string
1205
+ }
1206
+
1207
+ /**
1208
+ * Sets the colorscheme of a view
1209
+ * @param view the view to be modified
1210
+ * @param colorScheme - the new colorscheme
1211
+ */
1212
+ setViewColorScheme(view: SQView, colorScheme: string): SQView
1213
+
1059
1214
  /**
1060
1215
  * Array with available levels
1061
1216
  *
1062
1217
  * !! Only usable after `init` has been called
1063
1218
  */
1064
- getLevels: Level[]
1219
+ getLevels(): Level[]
1065
1220
 
1066
1221
  StackingOptions: StackingOption[]
1067
1222
 
@@ -1072,7 +1227,7 @@ declare module '@3e/sqa-common' {
1072
1227
  * Gets the container logical devices types to populate
1073
1228
  * @param level - level means container
1074
1229
  */
1075
- getContainerLdTypes(level: LevelValue): LDType[]
1230
+ getContainersLdTypes(level: LevelValue): Promise<LDType[]>
1076
1231
 
1077
1232
  /**
1078
1233
  * Based on the selected level and the Selected Logical Device type, returns
@@ -1081,16 +1236,22 @@ declare module '@3e/sqa-common' {
1081
1236
  * @param selectedContainerLdType
1082
1237
  */
1083
1238
  getContainers(
1084
- selectedLevel: LevelValue,
1085
- selectedContainerLdType: LDType,
1086
- ): Container[]
1239
+ selectedLevel: LevelValue,
1240
+ selectedContainerLdType: string,
1241
+ ): Promise<Container[]>
1087
1242
 
1088
1243
  /**
1089
1244
  * Get all available templates for the current selection
1090
- * @param selectedLevel
1091
- * @param selectedContainer
1245
+ * @param view
1246
+ * @param specification
1092
1247
  */
1093
- getTemplates(selectedLevel: Level, selectedContainer: Container): Template[]
1248
+ getTemplates(
1249
+ view: SQView,
1250
+ specification: {
1251
+ selectedLevel: LevelValue
1252
+ selectedContainer: ContainerValue
1253
+ },
1254
+ ): Promise<Template[]>
1094
1255
 
1095
1256
  /**
1096
1257
  * Sets the unit scaling for a view.
@@ -1100,9 +1261,9 @@ declare module '@3e/sqa-common' {
1100
1261
  * @param unitScaling
1101
1262
  */
1102
1263
  setUnitScaling(
1103
- view: SQView,
1104
- unitKey: string,
1105
- unitScaling: {min?: number; max?: number},
1264
+ view: SQView,
1265
+ unitKey: string,
1266
+ unitScaling: {min?: number; max?: number},
1106
1267
  ): SQView
1107
1268
 
1108
1269
  /**
@@ -1111,8 +1272,8 @@ declare module '@3e/sqa-common' {
1111
1272
  * @param unitKey - the
1112
1273
  */
1113
1274
  getUnitScaling(
1114
- view: SQView,
1115
- unitKey: string,
1275
+ view: SQView,
1276
+ unitKey: string,
1116
1277
  ): {
1117
1278
  min: number
1118
1279
  max: number
@@ -1175,7 +1336,7 @@ declare module '@3e/sqa-common' {
1175
1336
  periodTimeMode: PeriodTimeMode
1176
1337
  }
1177
1338
 
1178
- getDatasets(view: SQView): Dataset[]
1339
+ getDatasets(view: SQView): Promise<Dataset[]>
1179
1340
 
1180
1341
  /**
1181
1342
  * Adds a dataset to the view using a fixed set of objects.
@@ -1186,18 +1347,64 @@ declare module '@3e/sqa-common' {
1186
1347
  * @param options
1187
1348
  */
1188
1349
  addEnumDataset(
1189
- view: SQView,
1190
- objects: LDType,
1191
- indicators: [string],
1192
- options: DatasetOptions,
1350
+ view: SQView,
1351
+ objects: string[],
1352
+ indicators: [string],
1353
+ options: DatasetOptions,
1193
1354
  ): SQView
1194
1355
 
1195
1356
  addTemplateDataset(
1196
- view: SQView,
1197
- spec: DatasetTemplateSpec,
1198
- indicators: [string],
1199
- opts: DatasetOptions,
1357
+ view: SQView,
1358
+ spec: DatasetTemplateSpec,
1359
+ indicators: [string],
1360
+ opts: DatasetOptions,
1200
1361
  ): SQView
1362
+
1363
+ /**
1364
+ * Remove a dataset from the view
1365
+ * @param view the view to be modified
1366
+ * @param id the id of the dataset
1367
+ */
1368
+ removeDataset(view: SQView, id: string): SQView
1369
+
1370
+ /**
1371
+ * Set particular options on a dataset for a view
1372
+ * @param view - the view to be updated
1373
+ * @param id - the id of the dataset in the view body
1374
+ * @param options - the new options
1375
+ *
1376
+ * @returns The updated view
1377
+ */
1378
+ setDatasetOptions(view: SQView, id: string, options: DatasetOptions): SQView
1379
+
1380
+ /**
1381
+ * Returns the type of picker needed for the granularity
1382
+ * @param granularity
1383
+ */
1384
+ getClockOrCalendarMode(granularity: Granularity): 'clock' | 'calendar'
1385
+
1386
+ /**
1387
+ * Returns the type of picker needed for the granularity
1388
+ * @param granularity
1389
+ */
1390
+ getTimeMode(granularity: Granularity): 'clock' | 'calendar'
1391
+
1392
+ /**
1393
+ * Adds the statistics alongside the objects in the dataset
1394
+ * @param datasets - datasets to be updated
1395
+ * @param visualization - Visualization to be added to datasets
1396
+ */
1397
+ withStatistics(datasets: Dataset[], visualization: Visualization): Dataset[]
1398
+
1399
+ levelToLdTypeAndModel(level: LevelValue): {ldType: string; model: string}
1400
+
1401
+ viewVariablesRefCategories(viewParameters: PacoViewParameters): any
1402
+
1403
+ /**
1404
+ * Update a visualization
1405
+ * @param visualization
1406
+ */
1407
+ updateVisualization(visualization: Visualization): Visualization
1201
1408
  }
1202
1409
 
1203
1410
  export const sqa: {
@@ -1206,4 +1413,3 @@ declare module '@3e/sqa-common' {
1206
1413
 
1207
1414
  export default sqa
1208
1415
  }
1209
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3e/sqa-common",
3
- "version": "6.0.6-2",
3
+ "version": "6.0.6-5",
4
4
  "description": "SynaptiQ utilities package",
5
5
  "main": "sqa_common.js",
6
6
  "dependencies": {