@perses-dev/core 0.39.0 → 0.40.0

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 (119) 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 -49
  6. package/dist/cjs/model/index.js +28 -26
  7. package/dist/cjs/model/legend.js +39 -19
  8. package/dist/cjs/model/resource.js +9 -0
  9. package/dist/cjs/model/time-series-queries.js +3 -1
  10. package/dist/cjs/model/time.js +147 -64
  11. package/dist/cjs/model/units/bytes.js +26 -20
  12. package/dist/cjs/model/units/constants.js +3 -1
  13. package/dist/cjs/model/units/decimal.js +20 -14
  14. package/dist/cjs/model/units/index.js +13 -11
  15. package/dist/cjs/model/units/percent.js +21 -15
  16. package/dist/cjs/model/units/time.js +68 -60
  17. package/dist/cjs/model/units/types.js +3 -1
  18. package/dist/cjs/model/units/units.js +67 -43
  19. package/dist/cjs/model/units/utils.js +13 -7
  20. package/dist/cjs/model/variables.js +16 -3
  21. package/dist/cjs/utils/event.js +3 -1
  22. package/dist/cjs/utils/fetch.js +12 -4
  23. package/dist/cjs/utils/index.js +17 -14
  24. package/dist/cjs/utils/is-empty-object.js +3 -1
  25. package/dist/cjs/utils/mathjs.js +3 -1
  26. package/dist/cjs/utils/memo.js +10 -6
  27. package/dist/cjs/utils/panel-refs.js +9 -3
  28. package/dist/cjs/utils/text.js +33 -21
  29. package/dist/cjs/utils/time-series-data.js +21 -11
  30. package/dist/cjs/utils/types.js +16 -0
  31. package/dist/constants/dashboard-defaults.js.map +1 -1
  32. package/dist/constants/dialog.js.map +1 -1
  33. package/dist/constants/index.js.map +1 -1
  34. package/dist/index.js.map +1 -1
  35. package/dist/model/calculations.d.ts +9 -8
  36. package/dist/model/calculations.d.ts.map +1 -1
  37. package/dist/model/calculations.js +46 -45
  38. package/dist/model/calculations.js.map +1 -1
  39. package/dist/model/datasource.d.ts +19 -3
  40. package/dist/model/datasource.d.ts.map +1 -1
  41. package/dist/model/datasource.js.map +1 -1
  42. package/dist/model/display.d.ts +1 -1
  43. package/dist/model/display.d.ts.map +1 -1
  44. package/dist/model/display.js.map +1 -1
  45. package/dist/model/index.js.map +1 -1
  46. package/dist/model/legend.d.ts +6 -6
  47. package/dist/model/legend.js +9 -9
  48. package/dist/model/legend.js.map +1 -1
  49. package/dist/model/panels.d.ts +5 -2
  50. package/dist/model/panels.d.ts.map +1 -1
  51. package/dist/model/panels.js.map +1 -1
  52. package/dist/model/resource.d.ts +3 -2
  53. package/dist/model/resource.d.ts.map +1 -1
  54. package/dist/model/resource.js +3 -1
  55. package/dist/model/resource.js.map +1 -1
  56. package/dist/model/thresholds.d.ts +2 -2
  57. package/dist/model/thresholds.d.ts.map +1 -1
  58. package/dist/model/thresholds.js.map +1 -1
  59. package/dist/model/time-series-queries.js.map +1 -1
  60. package/dist/model/time.d.ts +3 -0
  61. package/dist/model/time.d.ts.map +1 -1
  62. package/dist/model/time.js +115 -55
  63. package/dist/model/time.js.map +1 -1
  64. package/dist/model/units/bytes.d.ts +8 -8
  65. package/dist/model/units/bytes.d.ts.map +1 -1
  66. package/dist/model/units/bytes.js +16 -16
  67. package/dist/model/units/bytes.js.map +1 -1
  68. package/dist/model/units/constants.js.map +1 -1
  69. package/dist/model/units/decimal.d.ts +8 -8
  70. package/dist/model/units/decimal.d.ts.map +1 -1
  71. package/dist/model/units/decimal.js +12 -12
  72. package/dist/model/units/decimal.js.map +1 -1
  73. package/dist/model/units/index.js.map +1 -1
  74. package/dist/model/units/percent.d.ts +7 -7
  75. package/dist/model/units/percent.d.ts.map +1 -1
  76. package/dist/model/units/percent.js +12 -12
  77. package/dist/model/units/percent.js.map +1 -1
  78. package/dist/model/units/time.d.ts +15 -15
  79. package/dist/model/units/time.d.ts.map +1 -1
  80. package/dist/model/units/time.js +56 -56
  81. package/dist/model/units/time.js.map +1 -1
  82. package/dist/model/units/types.d.ts +14 -5
  83. package/dist/model/units/types.d.ts.map +1 -1
  84. package/dist/model/units/types.js.map +1 -1
  85. package/dist/model/units/units.d.ts +30 -30
  86. package/dist/model/units/units.d.ts.map +1 -1
  87. package/dist/model/units/units.js +31 -31
  88. package/dist/model/units/units.js.map +1 -1
  89. package/dist/model/units/utils.d.ts +2 -2
  90. package/dist/model/units/utils.d.ts.map +1 -1
  91. package/dist/model/units/utils.js +4 -4
  92. package/dist/model/units/utils.js.map +1 -1
  93. package/dist/model/variables.d.ts +25 -7
  94. package/dist/model/variables.d.ts.map +1 -1
  95. package/dist/model/variables.js +3 -0
  96. package/dist/model/variables.js.map +1 -1
  97. package/dist/test/setup-tests.js.map +1 -1
  98. package/dist/utils/event.js.map +1 -1
  99. package/dist/utils/fetch.js.map +1 -1
  100. package/dist/utils/index.d.ts +2 -1
  101. package/dist/utils/index.d.ts.map +1 -1
  102. package/dist/utils/index.js +2 -1
  103. package/dist/utils/index.js.map +1 -1
  104. package/dist/utils/is-empty-object.js.map +1 -1
  105. package/dist/utils/mathjs.js.map +1 -1
  106. package/dist/utils/memo.js +2 -2
  107. package/dist/utils/memo.js.map +1 -1
  108. package/dist/utils/panel-refs.js.map +1 -1
  109. package/dist/utils/text.d.ts +5 -5
  110. package/dist/utils/text.d.ts.map +1 -1
  111. package/dist/utils/text.js +17 -17
  112. package/dist/utils/text.js.map +1 -1
  113. package/dist/utils/time-series-data.js +6 -6
  114. package/dist/utils/time-series-data.js.map +1 -1
  115. package/dist/utils/types.d.ts +2 -0
  116. package/dist/utils/types.d.ts.map +1 -0
  117. package/dist/utils/types.js +15 -0
  118. package/dist/utils/types.js.map +1 -0
  119. package/package.json +5 -4
@@ -21,8 +21,12 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- DEFAULT_DASHBOARD_DURATION: ()=>DEFAULT_DASHBOARD_DURATION,
25
- DEFAULT_REFRESH_INTERVAL: ()=>DEFAULT_REFRESH_INTERVAL
24
+ DEFAULT_DASHBOARD_DURATION: function() {
25
+ return DEFAULT_DASHBOARD_DURATION;
26
+ },
27
+ DEFAULT_REFRESH_INTERVAL: function() {
28
+ return DEFAULT_REFRESH_INTERVAL;
29
+ }
26
30
  });
27
31
  const DEFAULT_DASHBOARD_DURATION = '1h';
28
32
  const DEFAULT_REFRESH_INTERVAL = '0s';
@@ -16,6 +16,8 @@ Object.defineProperty(exports, "__esModule", {
16
16
  });
17
17
  Object.defineProperty(exports, "SAVE_DEFAULTS_DIALOG_TEXT", {
18
18
  enumerable: true,
19
- get: ()=>SAVE_DEFAULTS_DIALOG_TEXT
19
+ get: function() {
20
+ return SAVE_DEFAULTS_DIALOG_TEXT;
21
+ }
20
22
  });
21
23
  const SAVE_DEFAULTS_DIALOG_TEXT = 'You have made changes to the time range or the variables values. Would you like to save these as defaults?';
@@ -14,16 +14,18 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- _exportStar(require("./dashboard-defaults"), exports);
18
- _exportStar(require("./dialog"), exports);
19
- function _exportStar(from, to) {
17
+ _export_star(require("./dashboard-defaults"), exports);
18
+ _export_star(require("./dialog"), exports);
19
+ function _export_star(from, to) {
20
20
  Object.keys(from).forEach(function(k) {
21
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
22
- enumerable: true,
23
- get: function() {
24
- return from[k];
25
- }
26
- });
21
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
22
+ Object.defineProperty(to, k, {
23
+ enumerable: true,
24
+ get: function() {
25
+ return from[k];
26
+ }
27
+ });
28
+ }
27
29
  });
28
30
  return from;
29
31
  }
package/dist/cjs/index.js CHANGED
@@ -14,17 +14,19 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- _exportStar(require("./constants"), exports);
18
- _exportStar(require("./model"), exports);
19
- _exportStar(require("./utils"), exports);
20
- function _exportStar(from, to) {
17
+ _export_star(require("./constants"), exports);
18
+ _export_star(require("./model"), exports);
19
+ _export_star(require("./utils"), exports);
20
+ function _export_star(from, to) {
21
21
  Object.keys(from).forEach(function(k) {
22
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
23
- enumerable: true,
24
- get: function() {
25
- return from[k];
26
- }
27
- });
22
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
23
+ Object.defineProperty(to, k, {
24
+ enumerable: true,
25
+ get: function() {
26
+ return from[k];
27
+ }
28
+ });
29
+ }
28
30
  });
29
31
  return from;
30
32
  }
@@ -21,51 +21,63 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- CalculationsMap: ()=>CalculationsMap,
25
- CALCULATIONS_CONFIG: ()=>CALCULATIONS_CONFIG,
26
- getCalculations: ()=>getCalculations,
27
- getCalculation: ()=>getCalculation
24
+ DEFAULT_CALCULATION: function() {
25
+ return DEFAULT_CALCULATION;
26
+ },
27
+ CalculationsMap: function() {
28
+ return CalculationsMap;
29
+ },
30
+ CALCULATIONS_CONFIG: function() {
31
+ return CALCULATIONS_CONFIG;
32
+ },
33
+ getCalculations: function() {
34
+ return getCalculations;
35
+ },
36
+ getCalculation: function() {
37
+ return getCalculation;
38
+ }
28
39
  });
40
+ const DEFAULT_CALCULATION = 'last-number';
29
41
  const CalculationsMap = {
30
- First: first,
31
- Last: last,
32
- FirstNumber: firstNumber,
33
- LastNumber: lastNumber,
34
- Mean: mean,
35
- Sum: sum,
36
- Min: min,
37
- Max: max
42
+ first: first,
43
+ last: last,
44
+ 'first-number': firstNumber,
45
+ 'last-number': lastNumber,
46
+ mean: mean,
47
+ sum: sum,
48
+ min: min,
49
+ max: max
38
50
  };
39
51
  const CALCULATIONS_CONFIG = {
40
- First: {
52
+ first: {
41
53
  label: 'First',
42
54
  description: 'First value'
43
55
  },
44
- Last: {
56
+ last: {
45
57
  label: 'Last',
46
58
  description: 'Last value'
47
59
  },
48
- FirstNumber: {
60
+ 'first-number': {
49
61
  label: 'First *',
50
62
  description: 'First numeric value'
51
63
  },
52
- LastNumber: {
64
+ 'last-number': {
53
65
  label: 'Last *',
54
66
  description: 'Last numeric value'
55
67
  },
56
- Mean: {
68
+ mean: {
57
69
  label: 'Avg',
58
70
  description: 'Average value excluding nulls'
59
71
  },
60
- Sum: {
72
+ sum: {
61
73
  label: 'Sum',
62
74
  description: 'The sum of all values'
63
75
  },
64
- Min: {
76
+ min: {
65
77
  label: 'Min',
66
78
  description: 'Minimum value'
67
79
  },
68
- Max: {
80
+ max: {
69
81
  label: 'Max',
70
82
  description: 'Maximum value'
71
83
  }
@@ -83,55 +95,55 @@ function getCalculations(values, includeCalculations) {
83
95
  // in a single iteration of the data to minimize the performance impact of
84
96
  // generating multiple calculations for large timeseries values. This is
85
97
  // less optimized for certain single calculations when done in isolation (e.g.
86
- // `Last`), but will be more performant in the more expensive cases where
98
+ // `last`), but will be more performant in the more expensive cases where
87
99
  // multiple values are being used (e.g. table legend).
88
100
  values.forEach((tuple, i)=>{
89
101
  const value = tuple[1];
90
- if (i === 0 && 'First' in calculations) {
91
- calculations.First = value;
102
+ if (i === 0 && 'first' in calculations) {
103
+ calculations.first = value;
92
104
  }
93
- if (i === values.length - 1 && 'Last' in calculations) {
94
- calculations.Last = value;
105
+ if (i === values.length - 1 && 'last' in calculations) {
106
+ calculations.last = value;
95
107
  }
96
108
  // Handling specific to non-null values.
97
109
  if (typeof value === 'number') {
98
110
  nonNullCount += 1;
99
111
  sum += value;
100
- if ('FirstNumber' in calculations && calculations.FirstNumber === undefined) {
112
+ if ('first-number' in calculations && calculations['first-number'] === undefined) {
101
113
  // Save the first number we see.
102
- calculations.FirstNumber = value;
114
+ calculations['first-number'] = value;
103
115
  }
104
- if ('LastNumber' in calculations) {
116
+ if ('last-number' in calculations) {
105
117
  // Keep setting the numbers we see, which will eventually be set to the
106
118
  // last number when finished iterating.
107
- calculations.LastNumber = value;
119
+ calculations['last-number'] = value;
108
120
  }
109
- if ('Min' in calculations) {
110
- if (typeof calculations.Min !== 'number') {
121
+ if ('min' in calculations) {
122
+ if (typeof calculations.min !== 'number') {
111
123
  // Init the first time we see a number
112
- calculations.Min = value;
124
+ calculations.min = value;
113
125
  } else {
114
126
  // Use lowest value once initialized
115
- calculations.Min = Math.min(calculations.Min, value);
127
+ calculations.min = Math.min(calculations.min, value);
116
128
  }
117
129
  }
118
- if ('Max' in calculations) {
119
- if (typeof calculations.Max !== 'number') {
130
+ if ('max' in calculations) {
131
+ if (typeof calculations.max !== 'number') {
120
132
  // Init the first time we see a number
121
- calculations.Max = value;
133
+ calculations.max = value;
122
134
  } else {
123
135
  // Use highest value once initialized
124
- calculations.Max = Math.max(calculations.Max, value);
136
+ calculations.max = Math.max(calculations.max, value);
125
137
  }
126
138
  }
127
139
  }
128
140
  });
129
141
  // Set calculations that require iterating over all values.
130
- if (nonNullCount > 0 && 'Sum' in calculations) {
131
- calculations.Sum = sum;
142
+ if (nonNullCount > 0 && 'sum' in calculations) {
143
+ calculations.sum = sum;
132
144
  }
133
- if (nonNullCount > 0 && 'Mean' in calculations) {
134
- calculations.Mean = sum / nonNullCount;
145
+ if (nonNullCount > 0 && 'mean' in calculations) {
146
+ calculations.mean = sum / nonNullCount;
135
147
  }
136
148
  return calculations;
137
149
  }
@@ -141,26 +153,26 @@ function getCalculation(values, calculation) {
141
153
  ])[calculation];
142
154
  }
143
155
  function first(values) {
144
- return getCalculation(values, 'First');
156
+ return getCalculation(values, 'first');
145
157
  }
146
158
  function last(values) {
147
- return getCalculation(values, 'Last');
159
+ return getCalculation(values, 'last');
148
160
  }
149
161
  function firstNumber(values) {
150
- return getCalculation(values, 'FirstNumber');
162
+ return getCalculation(values, 'first-number');
151
163
  }
152
164
  function lastNumber(values) {
153
- return getCalculation(values, 'LastNumber');
165
+ return getCalculation(values, 'last-number');
154
166
  }
155
167
  function mean(values) {
156
- return getCalculation(values, 'Mean');
168
+ return getCalculation(values, 'mean');
157
169
  }
158
170
  function sum(values) {
159
- return getCalculation(values, 'Sum');
171
+ return getCalculation(values, 'sum');
160
172
  }
161
173
  function min(values) {
162
- return getCalculation(values, 'Min');
174
+ return getCalculation(values, 'min');
163
175
  }
164
176
  function max(values) {
165
- return getCalculation(values, 'Max');
177
+ return getCalculation(values, 'max');
166
178
  }
@@ -14,33 +14,35 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- _exportStar(require("./calculations"), exports);
18
- _exportStar(require("./dashboard"), exports);
19
- _exportStar(require("./datasource"), exports);
20
- _exportStar(require("./definitions"), exports);
21
- _exportStar(require("./display"), exports);
22
- _exportStar(require("./http"), exports);
23
- _exportStar(require("./layout"), exports);
24
- _exportStar(require("./legend"), exports);
25
- _exportStar(require("./notice"), exports);
26
- _exportStar(require("./panels"), exports);
27
- _exportStar(require("./project"), exports);
28
- _exportStar(require("./query"), exports);
29
- _exportStar(require("./resource"), exports);
30
- _exportStar(require("./thresholds"), exports);
31
- _exportStar(require("./time"), exports);
32
- _exportStar(require("./time-series-data"), exports);
33
- _exportStar(require("./time-series-queries"), exports);
34
- _exportStar(require("./units"), exports);
35
- _exportStar(require("./variables"), exports);
36
- function _exportStar(from, to) {
17
+ _export_star(require("./calculations"), exports);
18
+ _export_star(require("./dashboard"), exports);
19
+ _export_star(require("./datasource"), exports);
20
+ _export_star(require("./definitions"), exports);
21
+ _export_star(require("./display"), exports);
22
+ _export_star(require("./http"), exports);
23
+ _export_star(require("./layout"), exports);
24
+ _export_star(require("./legend"), exports);
25
+ _export_star(require("./notice"), exports);
26
+ _export_star(require("./panels"), exports);
27
+ _export_star(require("./project"), exports);
28
+ _export_star(require("./query"), exports);
29
+ _export_star(require("./resource"), exports);
30
+ _export_star(require("./thresholds"), exports);
31
+ _export_star(require("./time"), exports);
32
+ _export_star(require("./time-series-data"), exports);
33
+ _export_star(require("./time-series-queries"), exports);
34
+ _export_star(require("./units"), exports);
35
+ _export_star(require("./variables"), exports);
36
+ function _export_star(from, to) {
37
37
  Object.keys(from).forEach(function(k) {
38
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
39
- enumerable: true,
40
- get: function() {
41
- return from[k];
42
- }
43
- });
38
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
39
+ Object.defineProperty(to, k, {
40
+ enumerable: true,
41
+ get: function() {
42
+ return from[k];
43
+ }
44
+ });
45
+ }
44
46
  });
45
47
  return from;
46
48
  }
@@ -25,28 +25,48 @@ function _export(target, all) {
25
25
  });
26
26
  }
27
27
  _export(exports, {
28
- legendPositions: ()=>legendPositions,
29
- legendModes: ()=>legendModes,
30
- legendSizes: ()=>legendSizes,
31
- isValidLegendPosition: ()=>isValidLegendPosition,
32
- isValidLegendMode: ()=>isValidLegendMode,
33
- isValidLegendSize: ()=>isValidLegendSize,
34
- DEFAULT_LEGEND: ()=>DEFAULT_LEGEND,
35
- getLegendPosition: ()=>getLegendPosition,
36
- getLegendMode: ()=>getLegendMode,
37
- getLegendSize: ()=>getLegendSize
28
+ legendPositions: function() {
29
+ return legendPositions;
30
+ },
31
+ legendModes: function() {
32
+ return legendModes;
33
+ },
34
+ legendSizes: function() {
35
+ return legendSizes;
36
+ },
37
+ isValidLegendPosition: function() {
38
+ return isValidLegendPosition;
39
+ },
40
+ isValidLegendMode: function() {
41
+ return isValidLegendMode;
42
+ },
43
+ isValidLegendSize: function() {
44
+ return isValidLegendSize;
45
+ },
46
+ DEFAULT_LEGEND: function() {
47
+ return DEFAULT_LEGEND;
48
+ },
49
+ getLegendPosition: function() {
50
+ return getLegendPosition;
51
+ },
52
+ getLegendMode: function() {
53
+ return getLegendMode;
54
+ },
55
+ getLegendSize: function() {
56
+ return getLegendSize;
57
+ }
38
58
  });
39
59
  const legendPositions = [
40
- 'Bottom',
41
- 'Right'
60
+ 'bottom',
61
+ 'right'
42
62
  ];
43
63
  const legendModes = [
44
- 'List',
45
- 'Table'
64
+ 'list',
65
+ 'table'
46
66
  ];
47
67
  const legendSizes = [
48
- 'Small',
49
- 'Medium'
68
+ 'small',
69
+ 'medium'
50
70
  ];
51
71
  function isValidLegendPosition(position) {
52
72
  return legendPositions.includes(position);
@@ -58,9 +78,9 @@ function isValidLegendSize(size) {
58
78
  return legendSizes.includes(size);
59
79
  }
60
80
  const DEFAULT_LEGEND = {
61
- position: 'Bottom',
62
- mode: 'List',
63
- size: 'Medium'
81
+ position: 'bottom',
82
+ mode: 'list',
83
+ size: 'medium'
64
84
  };
65
85
  function getLegendPosition(position) {
66
86
  if (position === undefined) {
@@ -14,3 +14,12 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
+ Object.defineProperty(exports, "getMetadataProject", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return getMetadataProject;
21
+ }
22
+ });
23
+ function getMetadataProject(metadata) {
24
+ return 'project' in metadata ? metadata.project : undefined;
25
+ }
@@ -16,7 +16,9 @@ Object.defineProperty(exports, "__esModule", {
16
16
  });
17
17
  Object.defineProperty(exports, "isTimeSeriesValueTuple", {
18
18
  enumerable: true,
19
- get: ()=>isTimeSeriesValueTuple
19
+ get: function() {
20
+ return isTimeSeriesValueTuple;
21
+ }
20
22
  });
21
23
  function isTimeSeriesValueTuple(data) {
22
24
  if (data.length !== 2) return false;