@3e/sqa-common 6.0.6-9 → 6.0.7-10

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 +146 -2
  2. package/package.json +1 -1
  3. package/sqa_common.js +959 -941
package/index.d.ts CHANGED
@@ -672,6 +672,24 @@ declare module '@3e/sqa-common' {
672
672
  body: Section[]
673
673
  }
674
674
 
675
+ export type Parameters = {
676
+ class: string
677
+ id: string
678
+ }
679
+
680
+ export type ViewData = SQView & {
681
+ artifact: {
682
+ type: string
683
+ version: string
684
+ }
685
+ body: {
686
+ body: Parameters[]
687
+ class: string
688
+ id: string
689
+ }[]
690
+ version: string
691
+ }
692
+
675
693
  export type ParameterOption = {
676
694
  options: {value: string; label: string}[]
677
695
  id: string
@@ -853,6 +871,34 @@ declare module '@3e/sqa-common' {
853
871
  stops?: [number, string][]
854
872
  }
855
873
 
874
+ export type MeasurementsRowExtraInfo = {
875
+ indicator?: {
876
+ label: string
877
+ indicator_label: string
878
+ reference_label: string
879
+ unit: string
880
+ unit_key: string
881
+ description: string
882
+ key: string
883
+ default_graphical_representation: string
884
+ level: LevelValue
885
+ }
886
+ object?: {
887
+ name: string
888
+ level: LevelValue
889
+ ref: string
890
+ }
891
+ }
892
+
893
+ export type MeasurementsWidgetResult = {
894
+ meta: {
895
+ rows: MeasurementsRowExtraInfo[]
896
+ }
897
+ header: string[]
898
+ rows: (string | number | null)[][]
899
+ }
900
+
901
+
856
902
  export interface Visualization {
857
903
  data: {
858
904
  datasets: []
@@ -1015,6 +1061,53 @@ declare module '@3e/sqa-common' {
1015
1061
  // TODO: Better types for PacoViewParameters
1016
1062
  type PacoViewParameters = any
1017
1063
 
1064
+ type SaveDataJobStatus =
1065
+ | {
1066
+ status: 'terminated'
1067
+ respResult: {downloadUrl: string}
1068
+ completedTime: ISODateString
1069
+ respStatus: number
1070
+ }
1071
+ | {status: 'running'}
1072
+
1073
+ type SaveDataJobResponse = SaveDataJobStatus & {
1074
+ actorSqid: string
1075
+ numRetries: number
1076
+ sqid: string
1077
+ maxRetries: number
1078
+
1079
+ /**
1080
+ * The arguments derived from the visualization given as argument
1081
+ * for the `createSaveDataJob` function
1082
+ */
1083
+ arguments: {
1084
+ object: string[]
1085
+ toDate: ISODateString
1086
+ filename: string
1087
+ replyTz: string
1088
+ fromDate: string
1089
+ indicator: string[]
1090
+ granularity: Granularity[] // must be a single value
1091
+ }
1092
+ /**
1093
+ * The place in the queue
1094
+ */
1095
+ priority: number
1096
+
1097
+ timeout: number
1098
+
1099
+ /**
1100
+ * currently can be just save_data
1101
+ */
1102
+ typeSqid: number
1103
+ }
1104
+
1105
+ type Parameter = {
1106
+ id: string
1107
+ class: 'Parameter'
1108
+ parameter: {class: string; label: string; initial: unknown; value: unknown}
1109
+ }
1110
+
1018
1111
  /**
1019
1112
  * Type definitions for all the API
1020
1113
  */
@@ -1122,6 +1215,23 @@ declare module '@3e/sqa-common' {
1122
1215
  */
1123
1216
  populateVisualisation(visualisation: Visualization): Promise<Visualization>
1124
1217
 
1218
+ /**
1219
+ * Creates a table for measurements, for a single selected object
1220
+ *
1221
+ * @param object - the object reference
1222
+ * @param granularity - the granularity for the data fetched
1223
+ * @param period - the period for the data fetched
1224
+ * @param callback - Callback function called with the populated table
1225
+ *
1226
+ * @returns a function to cancel the operation
1227
+ */
1228
+ getMeasurements(
1229
+ object: string,
1230
+ granularity: 'raw' | 'scaled' | 'normalised',
1231
+ period: Period,
1232
+ callback: (result: MeasurementsWidgetResult) => void,
1233
+ ): () => void
1234
+
1125
1235
  /**
1126
1236
  * Returns the granularity for the view
1127
1237
  * @param view
@@ -1153,7 +1263,7 @@ declare module '@3e/sqa-common' {
1153
1263
  * @param id - The ID of the parameter //TODO: Get list of possible parameters
1154
1264
  * @param value - Value of the parameter
1155
1265
  */
1156
- setObjectParameters(view: SQView, id: string, value: string): SQView
1266
+ setObjectParameter(view: SQView, id: string, value: string): SQView
1157
1267
 
1158
1268
  DataTimezoneModes: [
1159
1269
  {value: 'user'; label: 'Display data in my own timezone'},
@@ -1237,7 +1347,7 @@ declare module '@3e/sqa-common' {
1237
1347
  */
1238
1348
  getContainers(
1239
1349
  selectedLevel: LevelValue,
1240
- selectedContainerLdType: string,
1350
+ selectedContainerLdType?: string,
1241
1351
  ): Promise<Container[]>
1242
1352
 
1243
1353
  /**
@@ -1405,6 +1515,40 @@ declare module '@3e/sqa-common' {
1405
1515
  * @param visualization
1406
1516
  */
1407
1517
  updateVisualization(visualization: Visualization): Visualization
1518
+
1519
+ /**
1520
+ * Create a SAVE_DATA job request for a visualization. After a job is
1521
+ * successfully created, a *JobUrl* is returned to be polled for a status
1522
+ * on the job
1523
+ *
1524
+ * @param visualization - The visualization to be saved in a .csv format
1525
+ * @param filename - the name of the csv.zip file to be downloaded
1526
+ *
1527
+ * @throws An error in case the provided parameters were incorrect. Wrap the
1528
+ * request inside a `try-catch` block
1529
+ */
1530
+ createSaveDataJob(
1531
+ visualization: Visualization,
1532
+ filename: string,
1533
+ ): Promise<string>
1534
+
1535
+ /**
1536
+ * Used for polling the SQA API for the job status.
1537
+ *
1538
+ * Use the jobUrl returned from `createSaveDataJob` and poll until `status` is `terminated`
1539
+ * @param jobUrl
1540
+ *
1541
+ * @throws An error in case something goes wrong with the request or the job does not
1542
+ * exist. Wrap the call inside a `try-catch` block
1543
+ */
1544
+ checkJobStatus(jobUrl: string): Promise<SaveDataJobResponse>
1545
+
1546
+ /**
1547
+ * Returns the parameters of a view
1548
+ * @param view
1549
+ */
1550
+ getViewParameters(view: SQView): Parameter[]
1551
+
1408
1552
  }
1409
1553
 
1410
1554
  export const sqa: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3e/sqa-common",
3
- "version": "6.0.6-9",
3
+ "version": "6.0.7-10",
4
4
  "description": "SynaptiQ utilities package",
5
5
  "main": "sqa_common.js",
6
6
  "dependencies": {