@perses-dev/core 0.37.1 → 0.37.2

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.
@@ -23,6 +23,7 @@ function _export(target, all) {
23
23
  _export(exports, {
24
24
  MIN_STEP_INTERVAL_MS: ()=>MIN_STEP_INTERVAL_MS,
25
25
  getXValues: ()=>getXValues,
26
+ getTimeSeriesValues: ()=>getTimeSeriesValues,
26
27
  getYValues: ()=>getYValues,
27
28
  getCommonTimeScale: ()=>getCommonTimeScale
28
29
  });
@@ -37,6 +38,36 @@ function getXValues(timeScale) {
37
38
  }
38
39
  return xValues;
39
40
  }
41
+ function getTimeSeriesValues(series, timeScale) {
42
+ let timestamp = timeScale.startMs;
43
+ const values = series.values;
44
+ const processedValues = [];
45
+ for (const valueTuple of values){
46
+ // Fill in values up to the current series value timestamp with nulls
47
+ while(timestamp < valueTuple[0]){
48
+ processedValues.push([
49
+ timestamp,
50
+ null
51
+ ]);
52
+ timestamp += timeScale.stepMs;
53
+ }
54
+ // Now add the current value since timestamp should match
55
+ processedValues.push([
56
+ timestamp,
57
+ valueTuple[1]
58
+ ]);
59
+ timestamp += timeScale.stepMs;
60
+ }
61
+ // Add null values at the end of the series if necessary
62
+ while(timestamp <= timeScale.endMs){
63
+ processedValues.push([
64
+ timestamp,
65
+ null
66
+ ]);
67
+ timestamp += timeScale.stepMs;
68
+ }
69
+ return processedValues;
70
+ }
40
71
  function getYValues(series, timeScale) {
41
72
  let timestamp = timeScale.startMs;
42
73
  const yValues = [];
@@ -1,10 +1,16 @@
1
- import { TimeScale, TimeSeries, TimeSeriesData } from '../model';
1
+ import { TimeScale, TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '../model';
2
2
  export declare const MIN_STEP_INTERVAL_MS = 10;
3
3
  /**
4
4
  * Given a common time scale (see `getCommonTimeScale`), generates an array of
5
5
  * timestamp values in ms for the x axis of a graph.
6
6
  */
7
7
  export declare function getXValues(timeScale: TimeScale): number[];
8
+ /**
9
+ * Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),
10
+ * processes the time series values, filling in any timestamps that are missing
11
+ * from the time series data with `null` values.
12
+ */
13
+ export declare function getTimeSeriesValues(series: TimeSeries, timeScale: TimeScale): TimeSeriesValueTuple[];
8
14
  /**
9
15
  * Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),
10
16
  * gets the values for the y axis of a graph, filling in any timestamps that are
@@ -1 +1 @@
1
- {"version":3,"file":"time-series-data.d.ts","sourceRoot":"","sources":["../../src/utils/time-series-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAqB,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAGpF,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC;;;GAGG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,EAAE,CAQzD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAuBzF;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAC,GACzE,SAAS,GAAG,SAAS,CAgFvB"}
1
+ {"version":3,"file":"time-series-data.d.ts","sourceRoot":"","sources":["../../src/utils/time-series-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAqB,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAG1G,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC;;;GAGG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,EAAE,CAQzD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,0BAyB3E;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAuBzF;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAC,GACzE,SAAS,GAAG,SAAS,CAgFvB"}
@@ -24,6 +24,40 @@ export const MIN_STEP_INTERVAL_MS = 10;
24
24
  }
25
25
  return xValues;
26
26
  }
27
+ /**
28
+ * Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),
29
+ * processes the time series values, filling in any timestamps that are missing
30
+ * from the time series data with `null` values.
31
+ */ export function getTimeSeriesValues(series, timeScale) {
32
+ let timestamp = timeScale.startMs;
33
+ const values = series.values;
34
+ const processedValues = [];
35
+ for (const valueTuple of values){
36
+ // Fill in values up to the current series value timestamp with nulls
37
+ while(timestamp < valueTuple[0]){
38
+ processedValues.push([
39
+ timestamp,
40
+ null
41
+ ]);
42
+ timestamp += timeScale.stepMs;
43
+ }
44
+ // Now add the current value since timestamp should match
45
+ processedValues.push([
46
+ timestamp,
47
+ valueTuple[1]
48
+ ]);
49
+ timestamp += timeScale.stepMs;
50
+ }
51
+ // Add null values at the end of the series if necessary
52
+ while(timestamp <= timeScale.endMs){
53
+ processedValues.push([
54
+ timestamp,
55
+ null
56
+ ]);
57
+ timestamp += timeScale.stepMs;
58
+ }
59
+ return processedValues;
60
+ }
27
61
  /**
28
62
  * Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),
29
63
  * gets the values for the y axis of a graph, filling in any timestamps that are
@@ -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 } 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 * 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","getYValues","series","yValues","valueTuple","values","getCommonTimeScale","seriesData","timeRange","undefined","steps","data","start","end","i","length","Date","valueOf","rangeMs","calculatedStepMs"],"mappings":"AAAA,oCAAoC;AACpC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B,GAAG5B,GAAG,IAAImB,KAAK,CAAC,AAAC;QACvCV,MAAM,GAAGmB,gBAAgB,GAAG3B,oBAAoB,GAAGA,oBAAoB,GAAG2B,gBAAgB,CAAC;IAC7F,CAAC;IAED,MAAMtB,QAAO,GAAGW,SAAS,CAACI,KAAK,CAACK,OAAO,EAAE,AAAC;IAC1C,MAAMnB,MAAK,GAAGU,SAAS,CAACK,GAAG,CAACI,OAAO,EAAE,AAAC;IACtC,MAAMC,QAAO,GAAGpB,MAAK,GAAGD,QAAO,AAAC;IAEhC,OAAO;QAAEA,OAAO,EAAPA,QAAO;QAAEC,KAAK,EAALA,MAAK;QAAEE,MAAM;QAAEkB,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 * 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;A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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/core",
3
- "version": "0.37.1",
3
+ "version": "0.37.2",
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",