@perses-dev/core 0.0.0-snapshot-panel-extra-content-2-2767e21 → 0.0.0-snapshot-scatter-chart-embed-8efdfab

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 (166) hide show
  1. package/dist/cjs/constants/dashboard-defaults.js +6 -2
  2. package/dist/cjs/constants/dialog.js +3 -1
  3. package/dist/cjs/constants/index.js +11 -9
  4. package/dist/cjs/index.js +12 -10
  5. package/dist/cjs/model/calculations.js +61 -51
  6. package/dist/cjs/model/http-proxy.js +16 -0
  7. package/dist/cjs/model/index.js +34 -26
  8. package/dist/cjs/model/kind.js +38 -0
  9. package/dist/cjs/model/legend.js +39 -19
  10. package/dist/cjs/model/resource.js +9 -0
  11. package/dist/cjs/model/rolebindings.js +16 -0
  12. package/dist/cjs/model/roles.js +59 -0
  13. package/dist/cjs/model/secrets.js +16 -0
  14. package/dist/cjs/model/time-series-queries.js +3 -1
  15. package/dist/cjs/model/time.js +147 -64
  16. package/dist/cjs/model/trace-data.js +16 -0
  17. package/dist/cjs/model/units/bytes.js +37 -25
  18. package/dist/cjs/model/units/constants.js +3 -1
  19. package/dist/cjs/model/units/decimal.js +22 -16
  20. package/dist/cjs/model/units/index.js +13 -11
  21. package/dist/cjs/model/units/percent.js +26 -19
  22. package/dist/cjs/model/units/throughput.js +113 -0
  23. package/dist/cjs/model/units/time.js +99 -38
  24. package/dist/cjs/model/units/types.js +5 -2
  25. package/dist/cjs/model/units/units.js +81 -45
  26. package/dist/cjs/model/units/utils.js +13 -7
  27. package/dist/cjs/model/variables.js +16 -3
  28. package/dist/cjs/utils/event.js +3 -1
  29. package/dist/cjs/utils/fetch.js +32 -7
  30. package/dist/cjs/utils/index.js +17 -14
  31. package/dist/cjs/utils/is-empty-object.js +3 -1
  32. package/dist/cjs/utils/mathjs.js +3 -1
  33. package/dist/cjs/utils/memo.js +10 -6
  34. package/dist/cjs/utils/panel-refs.js +9 -3
  35. package/dist/cjs/utils/text.js +39 -14
  36. package/dist/cjs/utils/time-series-data.js +21 -11
  37. package/dist/cjs/utils/types.js +16 -0
  38. package/dist/constants/dashboard-defaults.js.map +1 -1
  39. package/dist/constants/dialog.js.map +1 -1
  40. package/dist/constants/index.js.map +1 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/model/calculations.d.ts +9 -9
  43. package/dist/model/calculations.d.ts.map +1 -1
  44. package/dist/model/calculations.js +46 -46
  45. package/dist/model/calculations.js.map +1 -1
  46. package/dist/model/datasource.d.ts +11 -4
  47. package/dist/model/datasource.d.ts.map +1 -1
  48. package/dist/model/datasource.js.map +1 -1
  49. package/dist/model/display.d.ts +1 -1
  50. package/dist/model/display.d.ts.map +1 -1
  51. package/dist/model/display.js.map +1 -1
  52. package/dist/model/http-proxy.d.ts +16 -0
  53. package/dist/model/http-proxy.d.ts.map +1 -0
  54. package/dist/model/http-proxy.js +15 -0
  55. package/dist/model/http-proxy.js.map +1 -0
  56. package/dist/model/index.d.ts +6 -0
  57. package/dist/model/index.d.ts.map +1 -1
  58. package/dist/model/index.js +6 -0
  59. package/dist/model/index.js.map +1 -1
  60. package/dist/model/kind.d.ts +3 -0
  61. package/dist/model/kind.d.ts.map +1 -0
  62. package/dist/model/kind.js +30 -0
  63. package/dist/model/kind.js.map +1 -0
  64. package/dist/model/legend.d.ts +6 -6
  65. package/dist/model/legend.js +9 -9
  66. package/dist/model/legend.js.map +1 -1
  67. package/dist/model/panels.d.ts +5 -2
  68. package/dist/model/panels.d.ts.map +1 -1
  69. package/dist/model/panels.js.map +1 -1
  70. package/dist/model/query.d.ts +15 -2
  71. package/dist/model/query.d.ts.map +1 -1
  72. package/dist/model/query.js.map +1 -1
  73. package/dist/model/resource.d.ts +3 -2
  74. package/dist/model/resource.d.ts.map +1 -1
  75. package/dist/model/resource.js +3 -1
  76. package/dist/model/resource.js.map +1 -1
  77. package/dist/model/rolebindings.d.ts +27 -0
  78. package/dist/model/rolebindings.d.ts.map +1 -0
  79. package/dist/model/rolebindings.js +15 -0
  80. package/dist/model/rolebindings.js.map +1 -0
  81. package/dist/model/roles.d.ts +32 -0
  82. package/dist/model/roles.d.ts.map +1 -0
  83. package/dist/model/roles.js +40 -0
  84. package/dist/model/roles.js.map +1 -0
  85. package/dist/model/secrets.d.ts +44 -0
  86. package/dist/model/secrets.d.ts.map +1 -0
  87. package/dist/model/secrets.js +15 -0
  88. package/dist/model/secrets.js.map +1 -0
  89. package/dist/model/thresholds.d.ts +2 -2
  90. package/dist/model/thresholds.d.ts.map +1 -1
  91. package/dist/model/thresholds.js.map +1 -1
  92. package/dist/model/time-series-queries.js.map +1 -1
  93. package/dist/model/time.d.ts +3 -0
  94. package/dist/model/time.d.ts.map +1 -1
  95. package/dist/model/time.js +115 -55
  96. package/dist/model/time.js.map +1 -1
  97. package/dist/model/trace-data.d.ts +20 -0
  98. package/dist/model/trace-data.d.ts.map +1 -0
  99. package/dist/model/trace-data.js +15 -0
  100. package/dist/model/trace-data.js.map +1 -0
  101. package/dist/model/units/bytes.d.ts +8 -8
  102. package/dist/model/units/bytes.d.ts.map +1 -1
  103. package/dist/model/units/bytes.js +27 -21
  104. package/dist/model/units/bytes.js.map +1 -1
  105. package/dist/model/units/constants.js.map +1 -1
  106. package/dist/model/units/decimal.d.ts +8 -8
  107. package/dist/model/units/decimal.d.ts.map +1 -1
  108. package/dist/model/units/decimal.js +14 -14
  109. package/dist/model/units/decimal.js.map +1 -1
  110. package/dist/model/units/index.js.map +1 -1
  111. package/dist/model/units/percent.d.ts +7 -7
  112. package/dist/model/units/percent.d.ts.map +1 -1
  113. package/dist/model/units/percent.js +17 -16
  114. package/dist/model/units/percent.js.map +1 -1
  115. package/dist/model/units/throughput.d.ts +13 -0
  116. package/dist/model/units/throughput.d.ts.map +1 -0
  117. package/dist/model/units/throughput.js +94 -0
  118. package/dist/model/units/throughput.js.map +1 -0
  119. package/dist/model/units/time.d.ts +15 -15
  120. package/dist/model/units/time.d.ts.map +1 -1
  121. package/dist/model/units/time.js +87 -34
  122. package/dist/model/units/time.js.map +1 -1
  123. package/dist/model/units/types.d.ts +15 -6
  124. package/dist/model/units/types.d.ts.map +1 -1
  125. package/dist/model/units/types.js +2 -1
  126. package/dist/model/units/types.js.map +1 -1
  127. package/dist/model/units/units.d.ts +49 -30
  128. package/dist/model/units/units.d.ts.map +1 -1
  129. package/dist/model/units/units.js +52 -37
  130. package/dist/model/units/units.js.map +1 -1
  131. package/dist/model/units/utils.d.ts +2 -2
  132. package/dist/model/units/utils.d.ts.map +1 -1
  133. package/dist/model/units/utils.js +4 -4
  134. package/dist/model/units/utils.js.map +1 -1
  135. package/dist/model/variables.d.ts +26 -7
  136. package/dist/model/variables.d.ts.map +1 -1
  137. package/dist/model/variables.js +3 -0
  138. package/dist/model/variables.js.map +1 -1
  139. package/dist/test/setup-tests.js.map +1 -1
  140. package/dist/utils/event.js.map +1 -1
  141. package/dist/utils/fetch.d.ts +3 -1
  142. package/dist/utils/fetch.d.ts.map +1 -1
  143. package/dist/utils/fetch.js +21 -4
  144. package/dist/utils/fetch.js.map +1 -1
  145. package/dist/utils/index.d.ts +2 -1
  146. package/dist/utils/index.d.ts.map +1 -1
  147. package/dist/utils/index.js +2 -1
  148. package/dist/utils/index.js.map +1 -1
  149. package/dist/utils/is-empty-object.js.map +1 -1
  150. package/dist/utils/mathjs.js.map +1 -1
  151. package/dist/utils/memo.js +2 -2
  152. package/dist/utils/memo.js.map +1 -1
  153. package/dist/utils/panel-refs.js.map +1 -1
  154. package/dist/utils/text.d.ts +15 -3
  155. package/dist/utils/text.d.ts.map +1 -1
  156. package/dist/utils/text.js +29 -10
  157. package/dist/utils/text.js.map +1 -1
  158. package/dist/utils/time-series-data.d.ts +1 -1
  159. package/dist/utils/time-series-data.d.ts.map +1 -1
  160. package/dist/utils/time-series-data.js +7 -7
  161. package/dist/utils/time-series-data.js.map +1 -1
  162. package/dist/utils/types.d.ts +2 -0
  163. package/dist/utils/types.d.ts.map +1 -0
  164. package/dist/utils/types.js +15 -0
  165. package/dist/utils/types.js.map +1 -0
  166. package/package.json +5 -4
@@ -0,0 +1,113 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ THROUGHPUT_GROUP_CONFIG: function() {
25
+ return THROUGHPUT_GROUP_CONFIG;
26
+ },
27
+ THROUGHPUT_UNIT_CONFIG: function() {
28
+ return THROUGHPUT_UNIT_CONFIG;
29
+ },
30
+ formatThroughput: function() {
31
+ return formatThroughput;
32
+ }
33
+ });
34
+ const _constants = require("./constants");
35
+ const _utils = require("./utils");
36
+ const throughputUnits = [
37
+ 'counts/sec',
38
+ 'events/sec',
39
+ 'messages/sec',
40
+ 'ops/sec',
41
+ 'packets/sec',
42
+ 'reads/sec',
43
+ 'records/sec',
44
+ 'requests/sec',
45
+ 'rows/sec',
46
+ 'writes/sec'
47
+ ];
48
+ const THROUGHPUT_GROUP_CONFIG = {
49
+ label: 'Throughput',
50
+ decimalPlaces: true
51
+ };
52
+ const THROUGHPUT_GROUP = 'Throughput';
53
+ const THROUGHPUT_UNIT_CONFIG = {
54
+ 'counts/sec': {
55
+ group: THROUGHPUT_GROUP,
56
+ label: 'Counts/sec'
57
+ },
58
+ 'events/sec': {
59
+ group: THROUGHPUT_GROUP,
60
+ label: 'Events/sec'
61
+ },
62
+ 'messages/sec': {
63
+ group: THROUGHPUT_GROUP,
64
+ label: 'Messages/sec'
65
+ },
66
+ 'ops/sec': {
67
+ group: THROUGHPUT_GROUP,
68
+ label: 'Ops/sec'
69
+ },
70
+ 'packets/sec': {
71
+ group: THROUGHPUT_GROUP,
72
+ label: 'Packets/sec'
73
+ },
74
+ 'reads/sec': {
75
+ group: THROUGHPUT_GROUP,
76
+ label: 'Reads/sec'
77
+ },
78
+ 'requests/sec': {
79
+ group: THROUGHPUT_GROUP,
80
+ label: 'Requests/sec'
81
+ },
82
+ 'records/sec': {
83
+ group: THROUGHPUT_GROUP,
84
+ label: 'Records/sec'
85
+ },
86
+ 'rows/sec': {
87
+ group: THROUGHPUT_GROUP,
88
+ label: 'Rows/sec'
89
+ },
90
+ 'writes/sec': {
91
+ group: THROUGHPUT_GROUP,
92
+ label: 'Writes/sec'
93
+ }
94
+ };
95
+ function formatThroughput(value, { unit , shortValues , decimalPlaces }) {
96
+ const formatterOptions = {
97
+ style: 'decimal',
98
+ useGrouping: true
99
+ };
100
+ if ((0, _utils.shouldShortenValues)(shortValues)) {
101
+ formatterOptions.notation = 'compact';
102
+ }
103
+ if ((0, _utils.hasDecimalPlaces)(decimalPlaces)) {
104
+ formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
105
+ formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
106
+ } else {
107
+ if ((0, _utils.shouldShortenValues)(shortValues)) {
108
+ formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
109
+ }
110
+ }
111
+ const formatter = Intl.NumberFormat('en-US', formatterOptions);
112
+ return formatter.format(value) + ' ' + unit;
113
+ }
@@ -21,85 +21,146 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- PersesTimeToIntlTime: ()=>PersesTimeToIntlTime,
25
- TIME_GROUP_CONFIG: ()=>TIME_GROUP_CONFIG,
26
- TIME_UNIT_CONFIG: ()=>TIME_UNIT_CONFIG,
27
- formatTime: ()=>formatTime
24
+ PersesTimeToIntlTime: function() {
25
+ return PersesTimeToIntlTime;
26
+ },
27
+ TIME_GROUP_CONFIG: function() {
28
+ return TIME_GROUP_CONFIG;
29
+ },
30
+ TIME_UNIT_CONFIG: function() {
31
+ return TIME_UNIT_CONFIG;
32
+ },
33
+ formatTime: function() {
34
+ return formatTime;
35
+ }
28
36
  });
29
37
  const _constants = require("./constants");
30
38
  const _utils = require("./utils");
31
- const timeUnitKinds = [
32
- 'Milliseconds',
33
- 'Seconds',
34
- 'Minutes',
35
- 'Hours',
36
- 'Days',
37
- 'Weeks',
38
- 'Months',
39
- 'Years'
39
+ const timeUnits = [
40
+ 'milliseconds',
41
+ 'seconds',
42
+ 'minutes',
43
+ 'hours',
44
+ 'days',
45
+ 'weeks',
46
+ 'months',
47
+ 'years'
40
48
  ];
41
49
  const TIME_GROUP = 'Time';
42
50
  const TIME_GROUP_CONFIG = {
43
51
  label: 'Time',
44
- decimal_places: true
52
+ decimalPlaces: true
45
53
  };
46
54
  const TIME_UNIT_CONFIG = {
47
- Milliseconds: {
55
+ milliseconds: {
48
56
  group: TIME_GROUP,
49
57
  label: 'Milliseconds'
50
58
  },
51
- Seconds: {
59
+ seconds: {
52
60
  group: TIME_GROUP,
53
61
  label: 'Seconds'
54
62
  },
55
- Minutes: {
63
+ minutes: {
56
64
  group: TIME_GROUP,
57
65
  label: 'Minutes'
58
66
  },
59
- Hours: {
67
+ hours: {
60
68
  group: TIME_GROUP,
61
69
  label: 'Hours'
62
70
  },
63
- Days: {
71
+ days: {
64
72
  group: TIME_GROUP,
65
73
  label: 'Days'
66
74
  },
67
- Weeks: {
75
+ weeks: {
68
76
  group: TIME_GROUP,
69
77
  label: 'Weeks'
70
78
  },
71
- Months: {
79
+ months: {
72
80
  group: TIME_GROUP,
73
81
  label: 'Months'
74
82
  },
75
- Years: {
83
+ years: {
76
84
  group: TIME_GROUP,
77
85
  label: 'Years'
78
86
  }
79
87
  };
80
88
  var PersesTimeToIntlTime;
81
89
  (function(PersesTimeToIntlTime) {
82
- PersesTimeToIntlTime["Milliseconds"] = 'millisecond';
83
- PersesTimeToIntlTime["Seconds"] = 'second';
84
- PersesTimeToIntlTime["Minutes"] = 'minute';
85
- PersesTimeToIntlTime["Hours"] = 'hour';
86
- PersesTimeToIntlTime["Days"] = 'day';
87
- PersesTimeToIntlTime["Weeks"] = 'week';
88
- PersesTimeToIntlTime["Months"] = 'month';
89
- PersesTimeToIntlTime["Years"] = 'year';
90
+ PersesTimeToIntlTime["milliseconds"] = 'millisecond';
91
+ PersesTimeToIntlTime["seconds"] = 'second';
92
+ PersesTimeToIntlTime["minutes"] = 'minute';
93
+ PersesTimeToIntlTime["hours"] = 'hour';
94
+ PersesTimeToIntlTime["days"] = 'day';
95
+ PersesTimeToIntlTime["weeks"] = 'week';
96
+ PersesTimeToIntlTime["months"] = 'month';
97
+ PersesTimeToIntlTime["years"] = 'year';
90
98
  })(PersesTimeToIntlTime || (PersesTimeToIntlTime = {}));
91
- function formatTime(value, { kind , decimal_places }) {
92
- const isMonthOrYear = kind === 'Months' || kind === 'Years';
99
+ /**
100
+ * Note: This conversion will not be exactly accurate for months and years,
101
+ * due variations in the lengths of months (i.e. 28 - 31 days) and years (i.e. leap years).
102
+ * For precision with months and years, we would need more complex algorithms and/or external libraries.
103
+ * However, we expect that measurements in months and years will be rare.
104
+ */ const TIME_UNITS_IN_SECONDS = {
105
+ years: 31536000,
106
+ months: 2592000,
107
+ weeks: 604800,
108
+ days: 86400,
109
+ hours: 3600,
110
+ minutes: 60,
111
+ seconds: 1,
112
+ milliseconds: 0.001
113
+ };
114
+ const LARGEST_TO_SMALLEST_TIME_UNITS = [
115
+ 'years',
116
+ 'months',
117
+ 'weeks',
118
+ 'days',
119
+ 'hours',
120
+ 'minutes',
121
+ 'seconds',
122
+ 'milliseconds'
123
+ ];
124
+ /**
125
+ * Choose the first time unit that produces a number greater than 1, starting from the biggest time unit.
126
+ */ function getValueAndKindForNaturalNumbers(value, unit) {
127
+ const valueInSeconds = value * TIME_UNITS_IN_SECONDS[unit];
128
+ // Initialize for TS
129
+ const largestTimeUnit = LARGEST_TO_SMALLEST_TIME_UNITS[0] || 'years';
130
+ let timeUnit = largestTimeUnit;
131
+ let valueInTimeUnit = valueInSeconds / TIME_UNITS_IN_SECONDS[largestTimeUnit];
132
+ for (timeUnit of LARGEST_TO_SMALLEST_TIME_UNITS){
133
+ valueInTimeUnit = valueInSeconds / TIME_UNITS_IN_SECONDS[timeUnit];
134
+ if (valueInTimeUnit >= 1) {
135
+ return {
136
+ value: valueInTimeUnit,
137
+ unit: timeUnit
138
+ };
139
+ }
140
+ }
141
+ // If we didn't find a time unit, we have to settle for the smallest time unit (which is the last time unit).
142
+ return {
143
+ value: valueInTimeUnit,
144
+ unit: timeUnit
145
+ };
146
+ }
147
+ function isMonthOrYear(unit) {
148
+ return unit === 'months' || unit === 'years';
149
+ }
150
+ function formatTime(value, { unit , decimalPlaces }) {
151
+ if (value === 0) return '0s';
152
+ const results = getValueAndKindForNaturalNumbers(value, unit);
93
153
  const formatterOptions = {
94
154
  style: 'unit',
95
- unit: PersesTimeToIntlTime[kind],
96
- unitDisplay: isMonthOrYear ? 'long' : 'narrow'
155
+ unit: PersesTimeToIntlTime[results.unit],
156
+ unitDisplay: isMonthOrYear(results.unit) ? 'long' : 'narrow'
97
157
  };
98
- if ((0, _utils.hasDecimalPlaces)(decimal_places)) {
99
- formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
100
- formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimal_places);
158
+ if ((0, _utils.hasDecimalPlaces)(decimalPlaces)) {
159
+ formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
160
+ formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
101
161
  } else {
102
162
  formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
103
163
  }
104
- return Intl.NumberFormat('en-US', formatterOptions).format(value);
164
+ const formatter = Intl.NumberFormat('en-US', formatterOptions);
165
+ return formatter.format(results.value);
105
166
  }
@@ -18,11 +18,14 @@ Object.defineProperty(exports, "__esModule", {
18
18
  });
19
19
  Object.defineProperty(exports, "UNIT_GROUPS", {
20
20
  enumerable: true,
21
- get: ()=>UNIT_GROUPS
21
+ get: function() {
22
+ return UNIT_GROUPS;
23
+ }
22
24
  });
23
25
  const UNIT_GROUPS = [
24
26
  'Time',
25
27
  'Percent',
26
28
  'Decimal',
27
- 'Bytes'
29
+ 'Bytes',
30
+ 'Throughput'
28
31
  ];
@@ -21,81 +21,117 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- UNIT_GROUP_CONFIG: ()=>UNIT_GROUP_CONFIG,
25
- UNIT_CONFIG: ()=>UNIT_CONFIG,
26
- formatValue: ()=>formatValue,
27
- getUnitKindConfig: ()=>getUnitKindConfig,
28
- getUnitGroup: ()=>getUnitGroup,
29
- getUnitGroupConfig: ()=>getUnitGroupConfig,
30
- isTimeUnit: ()=>isTimeUnit,
31
- isPercentUnit: ()=>isPercentUnit,
32
- isDecimalUnit: ()=>isDecimalUnit,
33
- isBytesUnit: ()=>isBytesUnit,
34
- isUnitWithDecimalPlaces: ()=>isUnitWithDecimalPlaces,
35
- isUnitWithAbbreviate: ()=>isUnitWithAbbreviate
24
+ UNIT_GROUP_CONFIG: function() {
25
+ return UNIT_GROUP_CONFIG;
26
+ },
27
+ UNIT_CONFIG: function() {
28
+ return UNIT_CONFIG;
29
+ },
30
+ formatValue: function() {
31
+ return formatValue;
32
+ },
33
+ getUnitConfig: function() {
34
+ return getUnitConfig;
35
+ },
36
+ getUnitGroup: function() {
37
+ return getUnitGroup;
38
+ },
39
+ getUnitGroupConfig: function() {
40
+ return getUnitGroupConfig;
41
+ },
42
+ isTimeUnit: function() {
43
+ return isTimeUnit;
44
+ },
45
+ isPercentUnit: function() {
46
+ return isPercentUnit;
47
+ },
48
+ isDecimalUnit: function() {
49
+ return isDecimalUnit;
50
+ },
51
+ isBytesUnit: function() {
52
+ return isBytesUnit;
53
+ },
54
+ isUnitWithDecimalPlaces: function() {
55
+ return isUnitWithDecimalPlaces;
56
+ },
57
+ isUnitWithShortValues: function() {
58
+ return isUnitWithShortValues;
59
+ },
60
+ isThroughputUnit: function() {
61
+ return isThroughputUnit;
62
+ }
36
63
  });
37
64
  const _bytes = require("./bytes");
38
65
  const _decimal = require("./decimal");
39
66
  const _percent = require("./percent");
40
67
  const _time = require("./time");
68
+ const _throughput = require("./throughput");
41
69
  const UNIT_GROUP_CONFIG = {
42
70
  Time: _time.TIME_GROUP_CONFIG,
43
71
  Percent: _percent.PERCENT_GROUP_CONFIG,
44
72
  Decimal: _decimal.DECIMAL_GROUP_CONFIG,
45
- Bytes: _bytes.BYTES_GROUP_CONFIG
73
+ Bytes: _bytes.BYTES_GROUP_CONFIG,
74
+ Throughput: _throughput.THROUGHPUT_GROUP_CONFIG
46
75
  };
47
76
  const UNIT_CONFIG = {
48
77
  ..._time.TIME_UNIT_CONFIG,
49
78
  ..._percent.PERCENT_UNIT_CONFIG,
50
79
  ..._decimal.DECIMAL_UNIT_CONFIG,
51
- ..._bytes.BYTES_UNIT_CONFIG
80
+ ..._bytes.BYTES_UNIT_CONFIG,
81
+ ..._throughput.THROUGHPUT_UNIT_CONFIG
52
82
  };
53
- function formatValue(value, unitOptions) {
54
- if (unitOptions === undefined) {
83
+ function formatValue(value, formatOptions) {
84
+ if (formatOptions === undefined) {
55
85
  return value.toString();
56
86
  }
57
- if (isDecimalUnit(unitOptions)) {
58
- return (0, _decimal.formatDecimal)(value, unitOptions);
87
+ if (isBytesUnit(formatOptions)) {
88
+ return (0, _bytes.formatBytes)(value, formatOptions);
89
+ }
90
+ if (isDecimalUnit(formatOptions)) {
91
+ return (0, _decimal.formatDecimal)(value, formatOptions);
59
92
  }
60
- if (isTimeUnit(unitOptions)) {
61
- return (0, _time.formatTime)(value, unitOptions);
93
+ if (isPercentUnit(formatOptions)) {
94
+ return (0, _percent.formatPercent)(value, formatOptions);
62
95
  }
63
- if (isPercentUnit(unitOptions)) {
64
- return (0, _percent.formatPercent)(value, unitOptions);
96
+ if (isTimeUnit(formatOptions)) {
97
+ return (0, _time.formatTime)(value, formatOptions);
65
98
  }
66
- if (isBytesUnit(unitOptions)) {
67
- return (0, _bytes.formatBytes)(value, unitOptions);
99
+ if (isThroughputUnit(formatOptions)) {
100
+ return (0, _throughput.formatThroughput)(value, formatOptions);
68
101
  }
69
- const exhaustive = unitOptions;
102
+ const exhaustive = formatOptions;
70
103
  throw new Error(`Unknown unit options ${exhaustive}`);
71
104
  }
72
- function getUnitKindConfig(unitOptions) {
73
- return UNIT_CONFIG[unitOptions.kind];
105
+ function getUnitConfig(formatOptions) {
106
+ return UNIT_CONFIG[formatOptions.unit];
74
107
  }
75
- function getUnitGroup(unitOptions) {
76
- return getUnitKindConfig(unitOptions).group;
108
+ function getUnitGroup(formatOptions) {
109
+ return getUnitConfig(formatOptions).group;
77
110
  }
78
- function getUnitGroupConfig(unitOptions) {
79
- const unitConfig = getUnitKindConfig(unitOptions);
111
+ function getUnitGroupConfig(formatOptions) {
112
+ const unitConfig = getUnitConfig(formatOptions);
80
113
  return UNIT_GROUP_CONFIG[unitConfig.group];
81
114
  }
82
- function isTimeUnit(unitOptions) {
83
- return getUnitGroup(unitOptions) === 'Time';
115
+ function isTimeUnit(formatOptions) {
116
+ return getUnitGroup(formatOptions) === 'Time';
117
+ }
118
+ function isPercentUnit(formatOptions) {
119
+ return getUnitGroup(formatOptions) === 'Percent';
84
120
  }
85
- function isPercentUnit(unitOptions) {
86
- return getUnitGroup(unitOptions) === 'Percent';
121
+ function isDecimalUnit(formatOptions) {
122
+ return getUnitGroup(formatOptions) === 'Decimal';
87
123
  }
88
- function isDecimalUnit(unitOptions) {
89
- return getUnitGroup(unitOptions) === 'Decimal';
124
+ function isBytesUnit(formatOptions) {
125
+ return getUnitGroup(formatOptions) === 'Bytes';
90
126
  }
91
- function isBytesUnit(unitOptions) {
92
- return getUnitGroup(unitOptions) === 'Bytes';
127
+ function isUnitWithDecimalPlaces(formatOptions) {
128
+ const groupConfig = getUnitGroupConfig(formatOptions);
129
+ return !!groupConfig.decimalPlaces;
93
130
  }
94
- function isUnitWithDecimalPlaces(unitOptions) {
95
- const groupConfig = getUnitGroupConfig(unitOptions);
96
- return !!groupConfig.decimal_places;
131
+ function isUnitWithShortValues(formatOptions) {
132
+ const groupConfig = getUnitGroupConfig(formatOptions);
133
+ return !!groupConfig.shortValues;
97
134
  }
98
- function isUnitWithAbbreviate(unitOptions) {
99
- const groupConfig = getUnitGroupConfig(unitOptions);
100
- return !!groupConfig.abbreviate;
135
+ function isThroughputUnit(formatOptions) {
136
+ return getUnitGroup(formatOptions) == 'Throughput';
101
137
  }
@@ -21,15 +21,21 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- shouldAbbreviate: ()=>shouldAbbreviate,
25
- hasDecimalPlaces: ()=>hasDecimalPlaces,
26
- limitDecimalPlaces: ()=>limitDecimalPlaces
24
+ shouldShortenValues: function() {
25
+ return shouldShortenValues;
26
+ },
27
+ hasDecimalPlaces: function() {
28
+ return hasDecimalPlaces;
29
+ },
30
+ limitDecimalPlaces: function() {
31
+ return limitDecimalPlaces;
32
+ }
27
33
  });
28
- function shouldAbbreviate(abbreviate) {
29
- return abbreviate !== false;
34
+ function shouldShortenValues(shortValues) {
35
+ return shortValues !== false;
30
36
  }
31
- function hasDecimalPlaces(decimal_places) {
32
- return typeof decimal_places === 'number';
37
+ function hasDecimalPlaces(decimalPlaces) {
38
+ return typeof decimalPlaces === 'number';
33
39
  }
34
40
  function limitDecimalPlaces(num) {
35
41
  if (!num) return num;
@@ -14,8 +14,21 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- Object.defineProperty(exports, "DEFAULT_ALL_VALUE", {
18
- enumerable: true,
19
- get: ()=>DEFAULT_ALL_VALUE
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ getVariableProject: function() {
25
+ return getVariableProject;
26
+ },
27
+ DEFAULT_ALL_VALUE: function() {
28
+ return DEFAULT_ALL_VALUE;
29
+ }
20
30
  });
31
+ function getVariableProject(variable) {
32
+ return 'project' in variable.metadata ? variable.metadata.project : undefined;
33
+ }
21
34
  const DEFAULT_ALL_VALUE = '$__all';
@@ -16,7 +16,9 @@ Object.defineProperty(exports, "__esModule", {
16
16
  });
17
17
  Object.defineProperty(exports, "useEvent", {
18
18
  enumerable: true,
19
- get: ()=>useEvent
19
+ get: function() {
20
+ return useEvent;
21
+ }
20
22
  });
21
23
  const _react = require("react");
22
24
  function useEvent(handler) {
@@ -23,20 +23,41 @@ function _export(target, all) {
23
23
  });
24
24
  }
25
25
  _export(exports, {
26
- fetch: ()=>fetch,
27
- fetchJson: ()=>fetchJson,
28
- FetchError: ()=>FetchError,
29
- UserFriendlyError: ()=>UserFriendlyError
26
+ fetch: function() {
27
+ return fetch;
28
+ },
29
+ fetchJson: function() {
30
+ return fetchJson;
31
+ },
32
+ FetchError: function() {
33
+ return FetchError;
34
+ },
35
+ UserFriendlyError: function() {
36
+ return UserFriendlyError;
37
+ }
30
38
  });
39
+ function _define_property(obj, key, value) {
40
+ if (key in obj) {
41
+ Object.defineProperty(obj, key, {
42
+ value: value,
43
+ enumerable: true,
44
+ configurable: true,
45
+ writable: true
46
+ });
47
+ } else {
48
+ obj[key] = value;
49
+ }
50
+ return obj;
51
+ }
31
52
  async function fetch(...args) {
32
53
  const response = await global.fetch(...args);
33
54
  if (response.ok === false) {
34
55
  const json = await response.json();
35
56
  if (json.error) {
36
- throw new UserFriendlyError(json.error);
57
+ throw new UserFriendlyError(json.error, response.status);
37
58
  }
38
59
  if (json.message) {
39
- throw new UserFriendlyError(json.message);
60
+ throw new UserFriendlyError(json.message, response.status);
40
61
  }
41
62
  throw new FetchError(response);
42
63
  }
@@ -50,12 +71,16 @@ async function fetchJson(...args) {
50
71
  class FetchError extends Error {
51
72
  constructor(response){
52
73
  super(`${response.status} ${response.statusText}`);
74
+ _define_property(this, "status", void 0);
75
+ this.status = response.status;
53
76
  Object.setPrototypeOf(this, FetchError.prototype);
54
77
  }
55
78
  }
56
79
  class UserFriendlyError extends Error {
57
- constructor(message){
80
+ constructor(message, status){
58
81
  super(message);
82
+ _define_property(this, "status", void 0);
83
+ this.status = status;
59
84
  Object.setPrototypeOf(this, UserFriendlyError.prototype);
60
85
  }
61
86
  }
@@ -14,21 +14,24 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- _exportStar(require("./event"), exports);
18
- _exportStar(require("./fetch"), exports);
19
- _exportStar(require("./is-empty-object"), exports);
20
- _exportStar(require("./memo"), exports);
21
- _exportStar(require("./panel-refs"), exports);
22
- _exportStar(require("./time-series-data"), exports);
23
- _exportStar(require("./text"), exports);
24
- function _exportStar(from, to) {
17
+ _export_star(require("./event"), exports);
18
+ _export_star(require("./fetch"), exports);
19
+ _export_star(require("./is-empty-object"), exports);
20
+ _export_star(require("./memo"), exports);
21
+ _export_star(require("./panel-refs"), exports);
22
+ _export_star(require("./text"), exports);
23
+ _export_star(require("./time-series-data"), exports);
24
+ _export_star(require("./types"), exports);
25
+ function _export_star(from, to) {
25
26
  Object.keys(from).forEach(function(k) {
26
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
27
- enumerable: true,
28
- get: function() {
29
- return from[k];
30
- }
31
- });
27
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
28
+ Object.defineProperty(to, k, {
29
+ enumerable: true,
30
+ get: function() {
31
+ return from[k];
32
+ }
33
+ });
34
+ }
32
35
  });
33
36
  return from;
34
37
  }
@@ -18,7 +18,9 @@ Object.defineProperty(exports, "__esModule", {
18
18
  });
19
19
  Object.defineProperty(exports, "isEmptyObject", {
20
20
  enumerable: true,
21
- get: ()=>isEmptyObject
21
+ get: function() {
22
+ return isEmptyObject;
23
+ }
22
24
  });
23
25
  function isEmptyObject(obj) {
24
26
  return Object.getOwnPropertyNames(obj).length === 0;
@@ -16,7 +16,9 @@ Object.defineProperty(exports, "__esModule", {
16
16
  });
17
17
  Object.defineProperty(exports, "gcd", {
18
18
  enumerable: true,
19
- get: ()=>gcd
19
+ get: function() {
20
+ return gcd;
21
+ }
20
22
  });
21
23
  const _mathjs = require("mathjs");
22
24
  // This ensures we get a minimal mathjs bundle for just what we need (see https://mathjs.org/docs/custom_bundling.html)