@perses-dev/core 0.39.0 → 0.40.1

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
@@ -15,34 +15,34 @@
15
15
  * Else, only return the dashboard name
16
16
  * @param dashboard
17
17
  */ export function getDashboardDisplayName(dashboard) {
18
- var ref;
19
- var ref1;
20
- return (ref1 = (ref = dashboard.spec.display) === null || ref === void 0 ? void 0 : ref.name) !== null && ref1 !== void 0 ? ref1 : dashboard.metadata.name;
18
+ var _dashboard_spec_display;
19
+ var _dashboard_spec_display_name;
20
+ return (_dashboard_spec_display_name = (_dashboard_spec_display = dashboard.spec.display) === null || _dashboard_spec_display === void 0 ? void 0 : _dashboard_spec_display.name) !== null && _dashboard_spec_display_name !== void 0 ? _dashboard_spec_display_name : dashboard.metadata.name;
21
21
  }
22
22
  /**
23
23
  * If the variable has a display name, return the variable display name
24
24
  * Else, only return the variable name
25
25
  * @param variable Project or Global variable
26
26
  */ export function getVariableDisplayName(variable) {
27
- var ref;
28
- var ref1;
29
- return (ref1 = (ref = variable.spec.spec.display) === null || ref === void 0 ? void 0 : ref.name) !== null && ref1 !== void 0 ? ref1 : variable.metadata.name;
27
+ var _variable_spec_spec_display;
28
+ var _variable_spec_spec_display_name;
29
+ return (_variable_spec_spec_display_name = (_variable_spec_spec_display = variable.spec.spec.display) === null || _variable_spec_spec_display === void 0 ? void 0 : _variable_spec_spec_display.name) !== null && _variable_spec_spec_display_name !== void 0 ? _variable_spec_spec_display_name : variable.metadata.name;
30
30
  }
31
31
  /**
32
32
  * If the variable has a display name, return the datasource display name
33
33
  * Else, only return the datasource name
34
- * @param variable Project or Global datasource
34
+ * @param datasource Project or Global datasource
35
35
  */ export function getDatasourceDisplayName(datasource) {
36
- var ref;
37
- return ((ref = datasource.spec.display) === null || ref === void 0 ? void 0 : ref.name) || datasource.metadata.name;
36
+ var _datasource_spec_display;
37
+ return ((_datasource_spec_display = datasource.spec.display) === null || _datasource_spec_display === void 0 ? void 0 : _datasource_spec_display.name) || datasource.metadata.name;
38
38
  }
39
39
  /**
40
40
  * If the dashboard has a display name, return the dashboard display name and the dashboard name
41
41
  * Else, only return the dashboard name
42
42
  * @param dashboard
43
43
  */ export function getDashboardExtendedDisplayName(dashboard) {
44
- var ref;
45
- if ((ref = dashboard.spec.display) === null || ref === void 0 ? void 0 : ref.name) {
44
+ var _dashboard_spec_display;
45
+ if ((_dashboard_spec_display = dashboard.spec.display) === null || _dashboard_spec_display === void 0 ? void 0 : _dashboard_spec_display.name) {
46
46
  return `${dashboard.spec.display.name} (Name: ${dashboard.metadata.name})`;
47
47
  }
48
48
  return dashboard.metadata.name;
@@ -52,8 +52,8 @@
52
52
  * Else, only return the variable name
53
53
  * @param variable Project or Global variable
54
54
  */ export function getVariableExtendedDisplayName(variable) {
55
- var ref;
56
- if ((ref = variable.spec.spec.display) === null || ref === void 0 ? void 0 : ref.name) {
55
+ var _variable_spec_spec_display;
56
+ if ((_variable_spec_spec_display = variable.spec.spec.display) === null || _variable_spec_spec_display === void 0 ? void 0 : _variable_spec_spec_display.name) {
57
57
  return `${variable.spec.spec.display.name} (Name: ${variable.metadata.name})`;
58
58
  }
59
59
  return variable.metadata.name;
@@ -61,11 +61,11 @@
61
61
  /**
62
62
  * If the datasource has a display name, return the datasource display name and the datasource name
63
63
  * Else, only return the datasource name
64
- * @param variable Project or Global datasource
64
+ * @param datasource Project or Global datasource
65
65
  */ export function getDatasourceExtendedDisplayName(datasource) {
66
- var ref;
67
- if ((ref = datasource.spec.display) === null || ref === void 0 ? void 0 : ref.name) {
68
- return `${datasource.spec.display.name} (ID: ${datasource.metadata.name})`;
66
+ var _datasource_spec_display;
67
+ if ((_datasource_spec_display = datasource.spec.display) === null || _datasource_spec_display === void 0 ? void 0 : _datasource_spec_display.name) {
68
+ return `${datasource.spec.display.name} (Name: ${datasource.metadata.name})`;
69
69
  }
70
70
  return datasource.metadata.name;
71
71
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/text.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Datasource, DashboardResource, VariableResource } from '../model';\n\n/**\n * If the dashboard has a display name, return the dashboard display name\n * Else, only return the dashboard name\n * @param dashboard\n */\nexport function getDashboardDisplayName(dashboard: DashboardResource) {\n return dashboard.spec.display?.name ?? dashboard.metadata.name;\n}\n\n/**\n * If the variable has a display name, return the variable display name\n * Else, only return the variable name\n * @param variable Project or Global variable\n */\nexport function getVariableDisplayName(variable: VariableResource) {\n return variable.spec.spec.display?.name ?? variable.metadata.name;\n}\n\n/**\n * If the variable has a display name, return the datasource display name\n * Else, only return the datasource name\n * @param variable Project or Global datasource\n */\nexport function getDatasourceDisplayName(datasource: Datasource) {\n return datasource.spec.display?.name || datasource.metadata.name;\n}\n\n/**\n * If the dashboard has a display name, return the dashboard display name and the dashboard name\n * Else, only return the dashboard name\n * @param dashboard\n */\nexport function getDashboardExtendedDisplayName(dashboard: DashboardResource) {\n if (dashboard.spec.display?.name) {\n return `${dashboard.spec.display.name} (Name: ${dashboard.metadata.name})`;\n }\n return dashboard.metadata.name;\n}\n\n/**\n * If the variable has a display name, return the variable display name and the variable name\n * Else, only return the variable name\n * @param variable Project or Global variable\n */\nexport function getVariableExtendedDisplayName(variable: VariableResource) {\n if (variable.spec.spec.display?.name) {\n return `${variable.spec.spec.display.name} (Name: ${variable.metadata.name})`;\n }\n return variable.metadata.name;\n}\n\n/**\n * If the datasource has a display name, return the datasource display name and the datasource name\n * Else, only return the datasource name\n * @param variable Project or Global datasource\n */\nexport function getDatasourceExtendedDisplayName(datasource: Datasource) {\n if (datasource.spec.display?.name) {\n return `${datasource.spec.display.name} (ID: ${datasource.metadata.name})`;\n }\n return datasource.metadata.name;\n}\n"],"names":["getDashboardDisplayName","dashboard","spec","display","name","metadata","getVariableDisplayName","variable","getDatasourceDisplayName","datasource","getDashboardExtendedDisplayName","getVariableExtendedDisplayName","getDatasourceExtendedDisplayName"],"mappings":"AAAA,oCAAoC;AACpC,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AC;AAClC,CAAC"}
1
+ {"version":3,"sources":["../../src/utils/text.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DashboardResource, Variable, Datasource } from '../model';\n\n/**\n * If the dashboard has a display name, return the dashboard display name\n * Else, only return the dashboard name\n * @param dashboard\n */\nexport function getDashboardDisplayName(dashboard: DashboardResource) {\n return dashboard.spec.display?.name ?? dashboard.metadata.name;\n}\n\n/**\n * If the variable has a display name, return the variable display name\n * Else, only return the variable name\n * @param variable Project or Global variable\n */\nexport function getVariableDisplayName(variable: Variable) {\n return variable.spec.spec.display?.name ?? variable.metadata.name;\n}\n\n/**\n * If the variable has a display name, return the datasource display name\n * Else, only return the datasource name\n * @param datasource Project or Global datasource\n */\nexport function getDatasourceDisplayName(datasource: Datasource) {\n return datasource.spec.display?.name || datasource.metadata.name;\n}\n\n/**\n * If the dashboard has a display name, return the dashboard display name and the dashboard name\n * Else, only return the dashboard name\n * @param dashboard\n */\nexport function getDashboardExtendedDisplayName(dashboard: DashboardResource) {\n if (dashboard.spec.display?.name) {\n return `${dashboard.spec.display.name} (Name: ${dashboard.metadata.name})`;\n }\n return dashboard.metadata.name;\n}\n\n/**\n * If the variable has a display name, return the variable display name and the variable name\n * Else, only return the variable name\n * @param variable Project or Global variable\n */\nexport function getVariableExtendedDisplayName(variable: Variable) {\n if (variable.spec.spec.display?.name) {\n return `${variable.spec.spec.display.name} (Name: ${variable.metadata.name})`;\n }\n return variable.metadata.name;\n}\n\n/**\n * If the datasource has a display name, return the datasource display name and the datasource name\n * Else, only return the datasource name\n * @param datasource Project or Global datasource\n */\nexport function getDatasourceExtendedDisplayName(datasource: Datasource) {\n if (datasource.spec.display?.name) {\n return `${datasource.spec.display.name} (Name: ${datasource.metadata.name})`;\n }\n return datasource.metadata.name;\n}\n"],"names":["getDashboardDisplayName","dashboard","spec","display","name","metadata","getVariableDisplayName","variable","getDatasourceDisplayName","datasource","getDashboardExtendedDisplayName","getVariableExtendedDisplayName","getDatasourceExtendedDisplayName"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC;;;;CAIC,GACD,OAAO,SAASA,wBAAwBC,SAA4B;QAC3DA;QAAAA;IAAP,OAAOA,CAAAA,+BAAAA,CAAAA,0BAAAA,UAAUC,KAAKC,qBAAfF,qCAAAA,KAAAA,IAAAA,wBAAwBG,kBAAxBH,0CAAAA,+BAAgCA,UAAUI,SAASD;AAC5D;AAEA;;;;CAIC,GACD,OAAO,SAASE,uBAAuBC,QAAkB;QAChDA;QAAAA;IAAP,OAAOA,CAAAA,mCAAAA,CAAAA,8BAAAA,SAASL,KAAKA,KAAKC,qBAAnBI,yCAAAA,KAAAA,IAAAA,4BAA4BH,kBAA5BG,8CAAAA,mCAAoCA,SAASF,SAASD;AAC/D;AAEA;;;;CAIC,GACD,OAAO,SAASI,yBAAyBC,UAAsB;QACtDA;IAAP,OAAOA,CAAAA,CAAAA,2BAAAA,WAAWP,KAAKC,qBAAhBM,sCAAAA,KAAAA,IAAAA,yBAAyBL,IAAG,KAAKK,WAAWJ,SAASD;AAC9D;AAEA;;;;CAIC,GACD,OAAO,SAASM,gCAAgCT,SAA4B;QACtEA;IAAJ,IAAIA,CAAAA,0BAAAA,UAAUC,KAAKC,qBAAfF,qCAAAA,KAAAA,IAAAA,wBAAwBG,MAAM;QAChC,OAAO,CAAC,EAAEH,UAAUC,KAAKC,QAAQC,KAAK,QAAQ,EAAEH,UAAUI,SAASD,KAAK,CAAC,CAAC;IAC5E;IACA,OAAOH,UAAUI,SAASD;AAC5B;AAEA;;;;CAIC,GACD,OAAO,SAASO,+BAA+BJ,QAAkB;QAC3DA;IAAJ,IAAIA,CAAAA,8BAAAA,SAASL,KAAKA,KAAKC,qBAAnBI,yCAAAA,KAAAA,IAAAA,4BAA4BH,MAAM;QACpC,OAAO,CAAC,EAAEG,SAASL,KAAKA,KAAKC,QAAQC,KAAK,QAAQ,EAAEG,SAASF,SAASD,KAAK,CAAC,CAAC;IAC/E;IACA,OAAOG,SAASF,SAASD;AAC3B;AAEA;;;;CAIC,GACD,OAAO,SAASQ,iCAAiCH,UAAsB;QACjEA;IAAJ,IAAIA,CAAAA,2BAAAA,WAAWP,KAAKC,qBAAhBM,sCAAAA,KAAAA,IAAAA,yBAAyBL,MAAM;QACjC,OAAO,CAAC,EAAEK,WAAWP,KAAKC,QAAQC,KAAK,QAAQ,EAAEK,WAAWJ,SAASD,KAAK,CAAC,CAAC;IAC9E;IACA,OAAOK,WAAWJ,SAASD;AAC7B"}
@@ -153,14 +153,14 @@ export const MIN_STEP_INTERVAL_MS = 10;
153
153
  const calculatedStepMs = gcd(...steps);
154
154
  stepMs = calculatedStepMs < MIN_STEP_INTERVAL_MS ? MIN_STEP_INTERVAL_MS : calculatedStepMs;
155
155
  }
156
- const startMs1 = timeRange.start.valueOf();
157
- const endMs1 = timeRange.end.valueOf();
158
- const rangeMs1 = endMs1 - startMs1;
156
+ const startMs = timeRange.start.valueOf();
157
+ const endMs = timeRange.end.valueOf();
158
+ const rangeMs = endMs - startMs;
159
159
  return {
160
- startMs: startMs1,
161
- endMs: endMs1,
160
+ startMs,
161
+ endMs,
162
162
  stepMs,
163
- rangeMs: rangeMs1
163
+ rangeMs
164
164
  };
165
165
  }
166
166
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/time-series-data.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { AbsoluteTimeRange, TimeScale, TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '../model';\nimport { gcd } from './mathjs';\n\nexport const MIN_STEP_INTERVAL_MS = 10;\n\n/**\n * Given a common time scale (see `getCommonTimeScale`), generates an array of\n * timestamp values in ms for the x axis of a graph.\n */\nexport function getXValues(timeScale: TimeScale): number[] {\n const xValues: number[] = [];\n let timestamp = timeScale.startMs;\n while (timestamp <= timeScale.endMs) {\n xValues.push(timestamp);\n timestamp += timeScale.stepMs;\n }\n return xValues;\n}\n\n/**\n * Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),\n * processes the time series values, filling in any timestamps that are missing\n * from the time series data with `null` values.\n */\nexport function getTimeSeriesValues(series: TimeSeries, timeScale: TimeScale) {\n let timestamp = timeScale.startMs;\n\n const values = series.values;\n const processedValues: TimeSeriesValueTuple[] = [];\n\n for (const valueTuple of values) {\n // Fill in values up to the current series value timestamp with nulls\n while (timestamp < valueTuple[0]) {\n processedValues.push([timestamp, null]);\n timestamp += timeScale.stepMs;\n }\n\n // Now add the current value since timestamp should match\n processedValues.push([timestamp, valueTuple[1]]);\n timestamp += timeScale.stepMs;\n }\n\n // Add null values at the end of the series if necessary\n while (timestamp <= timeScale.endMs) {\n processedValues.push([timestamp, null]);\n timestamp += timeScale.stepMs;\n }\n\n return processedValues;\n}\n\n/**\n * [DEPRECATED] Used for legacy LineChart 'category' axis approach.\n * Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),\n * gets the values for the y axis of a graph, filling in any timestamps that are\n * missing from the time series data with `null` values.\n */\nexport function getYValues(series: TimeSeries, timeScale: TimeScale): Array<number | null> {\n let timestamp = timeScale.startMs;\n\n const yValues: Array<number | null> = [];\n for (const valueTuple of series.values) {\n // Fill in values up to the current series value timestamp with nulls\n while (timestamp < valueTuple[0]) {\n yValues.push(null);\n timestamp += timeScale.stepMs;\n }\n\n // Now add the current value since timestamp should match\n yValues.push(valueTuple[1]);\n timestamp += timeScale.stepMs;\n }\n\n // Add null values at the end of the series if necessary\n while (timestamp <= timeScale.endMs) {\n yValues.push(null);\n timestamp += timeScale.stepMs;\n }\n\n return yValues;\n}\n\n/**\n * Given a list of running queries, calculates a common time scale for use on\n * the x axis (i.e. start/end dates and a step that is divisible into all of\n * the queries' steps).\n */\nexport function getCommonTimeScale(\n seriesData: Array<TimeSeriesData | Pick<TimeSeries, 'values'> | undefined>\n): TimeScale | undefined {\n let timeRange: AbsoluteTimeRange | undefined = undefined;\n const steps: number[] = [];\n\n for (const data of seriesData) {\n if (data && 'timeRange' in data) {\n if (data === undefined || data.timeRange === undefined || data.stepMs === undefined) continue;\n\n // Keep track of query steps so we can calculate a common one for the graph\n steps.push(data.stepMs);\n\n // If we don't have an overall time range yet, just start with this one\n if (timeRange === undefined) {\n timeRange = data.timeRange;\n continue;\n }\n\n // Otherwise, see if this query has a start or end outside of the current\n // time range\n if (data.timeRange.start < timeRange.start) {\n timeRange.start = data.timeRange.start;\n }\n if (data.timeRange.end > timeRange.end) {\n timeRange.end = data.timeRange.end;\n }\n } else if (data && 'values' in data) {\n for (let i = 0; i < data.values.length; i++) {\n const values = data.values[i];\n if (values === undefined) {\n continue;\n }\n\n const [timestamp] = values;\n const start = new Date(timestamp);\n const end = new Date(timestamp);\n\n if (timeRange === undefined) {\n timeRange = {\n start,\n end,\n };\n continue;\n }\n\n if (start < timeRange.start) {\n timeRange.start = start;\n }\n\n if (end > timeRange.end) {\n timeRange.end = end;\n }\n }\n\n if (timeRange === undefined) return undefined;\n\n const startMs = timeRange.start.valueOf();\n const endMs = timeRange.end.valueOf();\n const rangeMs = endMs - startMs;\n\n return { startMs, endMs, rangeMs, stepMs: MIN_STEP_INTERVAL_MS };\n }\n }\n\n if (timeRange === undefined) return undefined;\n\n // Use the greatest common divisor of all step values as the overall step\n // for the x axis (or if only one query, just use that query's step value)\n let stepMs: number;\n if (steps.length === 1) {\n stepMs = steps[0] as number;\n } else {\n const calculatedStepMs = gcd(...steps);\n stepMs = calculatedStepMs < MIN_STEP_INTERVAL_MS ? MIN_STEP_INTERVAL_MS : calculatedStepMs;\n }\n\n const startMs = timeRange.start.valueOf();\n const endMs = timeRange.end.valueOf();\n const rangeMs = endMs - startMs;\n\n return { startMs, endMs, stepMs, rangeMs };\n}\n"],"names":["gcd","MIN_STEP_INTERVAL_MS","getXValues","timeScale","xValues","timestamp","startMs","endMs","push","stepMs","getTimeSeriesValues","series","values","processedValues","valueTuple","getYValues","yValues","getCommonTimeScale","seriesData","timeRange","undefined","steps","data","start","end","i","length","Date","valueOf","rangeMs","calculatedStepMs"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,GAAG,QAAQ,UAAU,CAAC;AAE/B,OAAO,MAAMC,oBAAoB,GAAG,EAAE,CAAC;AAEvC;;;CAGC,GACD,OAAO,SAASC,UAAU,CAACC,SAAoB,EAAY;IACzD,MAAMC,OAAO,GAAa,EAAE,AAAC;IAC7B,IAAIC,SAAS,GAAGF,SAAS,CAACG,OAAO,AAAC;IAClC,MAAOD,SAAS,IAAIF,SAAS,CAACI,KAAK,CAAE;QACnCH,OAAO,CAACI,IAAI,CAACH,SAAS,CAAC,CAAC;QACxBA,SAAS,IAAIF,SAAS,CAACM,MAAM,CAAC;IAChC,CAAC;IACD,OAAOL,OAAO,CAAC;AACjB,CAAC;AAED;;;;C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IACH,CAAC;IAED,IAAIkB,SAAS,KAAKC,SAAS,EAAE,OAAOA,SAAS,CAAC;IAE9C,yEAAyE;IACzE,0EAA0E;IAC1E,IAAIX,MAAM,AAAQ,AAAC;IACnB,IAAIY,KAAK,CAACK,MAAM,KAAK,CAAC,EAAE;QACtBjB,MAAM,GAAGY,KAAK,CAAC,CAAC,CAAC,AAAU,CAAC;IAC9B,OAAO;QACL,MAAMS,gBAAgB,GAAG9B,GAAG,IAAIqB,KAAK,CAAC,AAAC;QACvCZ,MAAM,GAAGqB,gBAAgB,GAAG7B,oBAAoB,GAAGA,oBAAoB,GAAG6B,gBAAgB,CAAC;IAC7F,CAAC;IAED,MAAMxB,QAAO,GAAGa,SAAS,CAACI,KAAK,CAACK,OAAO,EAAE,AAAC;IAC1C,MAAMrB,MAAK,GAAGY,SAAS,CAACK,GAAG,CAACI,OAAO,EAAE,AAAC;IACtC,MAAMC,QAAO,GAAGtB,MAAK,GAAGD,QAAO,AAAC;IAEhC,OAAO;QAAEA,OAAO,EAAPA,QAAO;QAAEC,KAAK,EAALA,MAAK;QAAEE,MAAM;QAAEoB,OAAO,EAAPA,QAAO;KAAE,CAAC;AAC7C,CAAC"}
1
+ {"version":3,"sources":["../../src/utils/time-series-data.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { AbsoluteTimeRange, TimeScale, TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '../model';\nimport { gcd } from './mathjs';\n\nexport const MIN_STEP_INTERVAL_MS = 10;\n\n/**\n * Given a common time scale (see `getCommonTimeScale`), generates an array of\n * timestamp values in ms for the x axis of a graph.\n */\nexport function getXValues(timeScale: TimeScale): number[] {\n const xValues: number[] = [];\n let timestamp = timeScale.startMs;\n while (timestamp <= timeScale.endMs) {\n xValues.push(timestamp);\n timestamp += timeScale.stepMs;\n }\n return xValues;\n}\n\n/**\n * Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),\n * processes the time series values, filling in any timestamps that are missing\n * from the time series data with `null` values.\n */\nexport function getTimeSeriesValues(series: TimeSeries, timeScale: TimeScale) {\n let timestamp = timeScale.startMs;\n\n const values = series.values;\n const processedValues: TimeSeriesValueTuple[] = [];\n\n for (const valueTuple of values) {\n // Fill in values up to the current series value timestamp with nulls\n while (timestamp < valueTuple[0]) {\n processedValues.push([timestamp, null]);\n timestamp += timeScale.stepMs;\n }\n\n // Now add the current value since timestamp should match\n processedValues.push([timestamp, valueTuple[1]]);\n timestamp += timeScale.stepMs;\n }\n\n // Add null values at the end of the series if necessary\n while (timestamp <= timeScale.endMs) {\n processedValues.push([timestamp, null]);\n timestamp += timeScale.stepMs;\n }\n\n return processedValues;\n}\n\n/**\n * [DEPRECATED] Used for legacy LineChart 'category' axis approach.\n * Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),\n * gets the values for the y axis of a graph, filling in any timestamps that are\n * missing from the time series data with `null` values.\n */\nexport function getYValues(series: TimeSeries, timeScale: TimeScale): Array<number | null> {\n let timestamp = timeScale.startMs;\n\n const yValues: Array<number | null> = [];\n for (const valueTuple of series.values) {\n // Fill in values up to the current series value timestamp with nulls\n while (timestamp < valueTuple[0]) {\n yValues.push(null);\n timestamp += timeScale.stepMs;\n }\n\n // Now add the current value since timestamp should match\n yValues.push(valueTuple[1]);\n timestamp += timeScale.stepMs;\n }\n\n // Add null values at the end of the series if necessary\n while (timestamp <= timeScale.endMs) {\n yValues.push(null);\n timestamp += timeScale.stepMs;\n }\n\n return yValues;\n}\n\n/**\n * Given a list of running queries, calculates a common time scale for use on\n * the x axis (i.e. start/end dates and a step that is divisible into all of\n * the queries' steps).\n */\nexport function getCommonTimeScale(\n seriesData: Array<TimeSeriesData | Pick<TimeSeries, 'values'> | undefined>\n): TimeScale | undefined {\n let timeRange: AbsoluteTimeRange | undefined = undefined;\n const steps: number[] = [];\n\n for (const data of seriesData) {\n if (data && 'timeRange' in data) {\n if (data === undefined || data.timeRange === undefined || data.stepMs === undefined) continue;\n\n // Keep track of query steps so we can calculate a common one for the graph\n steps.push(data.stepMs);\n\n // If we don't have an overall time range yet, just start with this one\n if (timeRange === undefined) {\n timeRange = data.timeRange;\n continue;\n }\n\n // Otherwise, see if this query has a start or end outside of the current\n // time range\n if (data.timeRange.start < timeRange.start) {\n timeRange.start = data.timeRange.start;\n }\n if (data.timeRange.end > timeRange.end) {\n timeRange.end = data.timeRange.end;\n }\n } else if (data && 'values' in data) {\n for (let i = 0; i < data.values.length; i++) {\n const values = data.values[i];\n if (values === undefined) {\n continue;\n }\n\n const [timestamp] = values;\n const start = new Date(timestamp);\n const end = new Date(timestamp);\n\n if (timeRange === undefined) {\n timeRange = {\n start,\n end,\n };\n continue;\n }\n\n if (start < timeRange.start) {\n timeRange.start = start;\n }\n\n if (end > timeRange.end) {\n timeRange.end = end;\n }\n }\n\n if (timeRange === undefined) return undefined;\n\n const startMs = timeRange.start.valueOf();\n const endMs = timeRange.end.valueOf();\n const rangeMs = endMs - startMs;\n\n return { startMs, endMs, rangeMs, stepMs: MIN_STEP_INTERVAL_MS };\n }\n }\n\n if (timeRange === undefined) return undefined;\n\n // Use the greatest common divisor of all step values as the overall step\n // for the x axis (or if only one query, just use that query's step value)\n let stepMs: number;\n if (steps.length === 1) {\n stepMs = steps[0] as number;\n } else {\n const calculatedStepMs = gcd(...steps);\n stepMs = calculatedStepMs < MIN_STEP_INTERVAL_MS ? MIN_STEP_INTERVAL_MS : calculatedStepMs;\n }\n\n const startMs = timeRange.start.valueOf();\n const endMs = timeRange.end.valueOf();\n const rangeMs = endMs - startMs;\n\n return { startMs, endMs, stepMs, rangeMs };\n}\n"],"names":["gcd","MIN_STEP_INTERVAL_MS","getXValues","timeScale","xValues","timestamp","startMs","endMs","push","stepMs","getTimeSeriesValues","series","values","processedValues","valueTuple","getYValues","yValues","getCommonTimeScale","seriesData","timeRange","undefined","steps","data","start","end","i","length","Date","valueOf","rangeMs","calculatedStepMs"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,GAAG,QAAQ,WAAW;AAE/B,OAAO,MAAMC,uBAAuB,GAAG;AAEvC;;;CAGC,GACD,OAAO,SAASC,WAAWC,SAAoB;IAC7C,MAAMC,UAAoB,EAAE;IAC5B,IAAIC,YAAYF,UAAUG;IAC1B,MAAOD,aAAaF,UAAUI,MAAO;QACnCH,QAAQI,KAAKH;QACbA,aAAaF,UAAUM;IACzB;IACA,OAAOL;AACT;AAEA;;;;CAIC,GACD,OAAO,SAASM,oBAAoBC,MAAkB,EAAER,SAAoB;IAC1E,IAAIE,YAAYF,UAAUG;IAE1B,MAAMM,SAASD,OAAOC;IACtB,MAAMC,kBAA0C,EAAE;IAElD,KAAK,MAAMC,cAAcF,OAAQ;QAC/B,qEAAqE;QACrE,MAAOP,YAAYS,UAAU,CAAC,EAAE,CAAE;YAChCD,gBAAgBL,KAAK;gBAACH;gBAAW;aAAK;YACtCA,aAAaF,UAAUM;QACzB;QAEA,yDAAyD;QACzDI,gBAAgBL,KAAK;YAACH;YAAWS,UAAU,CAAC,EAAE;SAAC;QAC/CT,aAAaF,UAAUM;IACzB;IAEA,wDAAwD;IACxD,MAAOJ,aAAaF,UAAUI,MAAO;QACnCM,gBAAgBL,KAAK;YAACH;YAAW;SAAK;QACtCA,aAAaF,UAAUM;IACzB;IAEA,OAAOI;AACT;AAEA;;;;;CAKC,GACD,OAAO,SAASE,WAAWJ,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AQ,IAAII,KAAKtB;gBACvB,MAAMmB,MAAM,IAAIG,KAAKtB;gBAErB,IAAIc,cAAcC,WAAW;oBAC3BD,YAAY;wBACVI;wBACAC;oBACF;oBACA;gBACF;gBAEA,IAAID,QAAQJ,UAAUI,OAAO;oBAC3BJ,UAAUI,QAAQA;gBACpB;gBAEA,IAAIC,MAAML,UAAUK,KAAK;oBACvBL,UAAUK,MAAMA;gBAClB;YACF;YAEA,IAAIL,cAAcC,WAAW,OAAOA;YAEpC,MAAMd,UAAUa,UAAUI,MAAMK;YAChC,MAAMrB,QAAQY,UAAUK,IAAII;YAC5B,MAAMC,UAAUtB,QAAQD;YAExB,OAAO;gBAAEA;gBAASC;gBAAOsB;gBAASpB,QAAQR;YAAqB;QACjE;IACF;IAEA,IAAIkB,cAAcC,WAAW,OAAOA;IAEpC,yEAAyE;IACzE,0EAA0E;IAC1E,IAAIX;IACJ,IAAIY,MAAMK,WAAW,GAAG;QACtBjB,SAASY,KAAK,CAAC,EAAE;IACnB,OAAO;QACL,MAAMS,mBAAmB9B,OAAOqB;QAChCZ,SAASqB,mBAAmB7B,uBAAuBA,uBAAuB6B;IAC5E;IAEA,MAAMxB,UAAUa,UAAUI,MAAMK;IAChC,MAAMrB,QAAQY,UAAUK,IAAII;IAC5B,MAAMC,UAAUtB,QAAQD;IAExB,OAAO;QAAEA;QAASC;QAAOE;QAAQoB;IAAQ;AAC3C"}
@@ -0,0 +1,2 @@
1
+ export declare type DispatchWithPromise<A> = (value: A) => Promise<void>;
2
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAaA,oBAAY,mBAAmB,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,15 @@
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
+ export { };
14
+
15
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/types.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport type DispatchWithPromise<A> = (value: A) => Promise<void>;\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,WAAiE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/core",
3
- "version": "0.39.0",
3
+ "version": "0.40.1",
4
4
  "description": "Core functionality consumed by both the Perses UI and plugins",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -23,8 +23,8 @@
23
23
  "build:types": "tsc --project tsconfig.build.json",
24
24
  "type-check": "tsc --noEmit",
25
25
  "start": "concurrently -P \"npm:build:* -- {*}\" -- --watch",
26
- "test": "TZ=UTC jest",
27
- "test:watch": "TZ=UTC jest --watch",
26
+ "test": "cross-env TZ=UTC jest",
27
+ "test:watch": "cross-env TZ=UTC jest --watch",
28
28
  "lint": "eslint src --ext .ts,.tsx",
29
29
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
30
30
  },
@@ -32,7 +32,8 @@
32
32
  "date-fns": "^2.28.0",
33
33
  "lodash": "^4.17.21",
34
34
  "mathjs": "^10.6.4",
35
- "numbro": "^2.3.6"
35
+ "numbro": "^2.3.6",
36
+ "zod": "^3.21.4"
36
37
  },
37
38
  "peerDependencies": {
38
39
  "react": "^17.0.2 || ^18.0.0",