@perses-dev/core 0.33.0 → 0.35.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.
@@ -0,0 +1,168 @@
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
+ CalculationsMap: ()=>CalculationsMap,
25
+ CALCULATIONS_CONFIG: ()=>CALCULATIONS_CONFIG,
26
+ DEFAULT_CALCULATION: ()=>DEFAULT_CALCULATION,
27
+ getCalculations: ()=>getCalculations,
28
+ getCalculation: ()=>getCalculation
29
+ });
30
+ const CalculationsMap = {
31
+ First: first,
32
+ Last: last,
33
+ FirstNumber: firstNumber,
34
+ LastNumber: lastNumber,
35
+ Mean: mean,
36
+ Sum: sum,
37
+ Min: min,
38
+ Max: max
39
+ };
40
+ const CALCULATIONS_CONFIG = {
41
+ First: {
42
+ label: 'First',
43
+ description: 'First value'
44
+ },
45
+ Last: {
46
+ label: 'Last',
47
+ description: 'Last value'
48
+ },
49
+ FirstNumber: {
50
+ label: 'First *',
51
+ description: 'First numeric value'
52
+ },
53
+ LastNumber: {
54
+ label: 'Last *',
55
+ description: 'Last numeric value'
56
+ },
57
+ Mean: {
58
+ label: 'Average',
59
+ description: 'Average value excluding nulls'
60
+ },
61
+ Sum: {
62
+ label: 'Sum',
63
+ description: 'The sum of all values'
64
+ },
65
+ Min: {
66
+ label: 'Min',
67
+ description: 'Minimum value'
68
+ },
69
+ Max: {
70
+ label: 'Max',
71
+ description: 'Maximum value'
72
+ }
73
+ };
74
+ const DEFAULT_CALCULATION = 'Sum';
75
+ function getCalculations(values, includeCalculations) {
76
+ const calculations = includeCalculations.reduce((initResult, calculation)=>{
77
+ initResult[calculation] = undefined;
78
+ return initResult;
79
+ }, {});
80
+ // We save these values as separate values instead of directly setting them
81
+ // in the calculations because they are needed by multiple calculations.
82
+ let nonNullCount = 0;
83
+ let sum = 0;
84
+ // We use this large function capable of performing one or more calculations
85
+ // in a single iteration of the data to minimize the performance impact of
86
+ // generating multiple calculations for large timeseries values. This is
87
+ // less optimized for certain single calculations when done in isolation (e.g.
88
+ // `Last`), but will be more performant in the more expensive cases where
89
+ // multiple values are being used (e.g. table legend).
90
+ values.forEach((tuple, i)=>{
91
+ const value = tuple[1];
92
+ if (i === 0 && 'First' in calculations) {
93
+ calculations.First = value;
94
+ }
95
+ if (i === values.length - 1 && 'Last' in calculations) {
96
+ calculations.Last = value;
97
+ }
98
+ // Handling specific to non-null values.
99
+ if (typeof value === 'number') {
100
+ nonNullCount += 1;
101
+ sum += value;
102
+ if ('FirstNumber' in calculations && calculations.FirstNumber === undefined) {
103
+ // Save the first number we see.
104
+ calculations.FirstNumber = value;
105
+ }
106
+ if ('LastNumber' in calculations) {
107
+ // Keep setting the numbers we see, which will eventually be set to the
108
+ // last number when finished iterating.
109
+ calculations.LastNumber = value;
110
+ }
111
+ if ('Min' in calculations) {
112
+ if (typeof calculations.Min !== 'number') {
113
+ // Init the first time we see a number
114
+ calculations.Min = value;
115
+ } else {
116
+ // Use lowest value once initialized
117
+ calculations.Min = Math.min(calculations.Min, value);
118
+ }
119
+ }
120
+ if ('Max' in calculations) {
121
+ if (typeof calculations.Max !== 'number') {
122
+ // Init the first time we see a number
123
+ calculations.Max = value;
124
+ } else {
125
+ // Use highest value once initialized
126
+ calculations.Max = Math.max(calculations.Max, value);
127
+ }
128
+ }
129
+ }
130
+ });
131
+ // Set calculations that require iterating over all values.
132
+ if (nonNullCount > 0 && 'Sum' in calculations) {
133
+ calculations.Sum = sum;
134
+ }
135
+ if (nonNullCount > 0 && 'Mean' in calculations) {
136
+ calculations.Mean = sum / nonNullCount;
137
+ }
138
+ return calculations;
139
+ }
140
+ function getCalculation(values, calculation) {
141
+ return getCalculations(values, [
142
+ calculation
143
+ ])[calculation];
144
+ }
145
+ function first(values) {
146
+ return getCalculation(values, 'First');
147
+ }
148
+ function last(values) {
149
+ return getCalculation(values, 'Last');
150
+ }
151
+ function firstNumber(values) {
152
+ return getCalculation(values, 'FirstNumber');
153
+ }
154
+ function lastNumber(values) {
155
+ return getCalculation(values, 'LastNumber');
156
+ }
157
+ function mean(values) {
158
+ return getCalculation(values, 'Mean');
159
+ }
160
+ function sum(values) {
161
+ return getCalculation(values, 'Sum');
162
+ }
163
+ function min(values) {
164
+ return getCalculation(values, 'Min');
165
+ }
166
+ function max(values) {
167
+ return getCalculation(values, 'Max');
168
+ }
@@ -14,12 +14,14 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
+ _exportStar(require("./calculations"), exports);
17
18
  _exportStar(require("./dashboard"), exports);
18
19
  _exportStar(require("./datasource"), exports);
19
20
  _exportStar(require("./definitions"), exports);
20
21
  _exportStar(require("./display"), exports);
21
22
  _exportStar(require("./http"), exports);
22
23
  _exportStar(require("./layout"), exports);
24
+ _exportStar(require("./legend"), exports);
23
25
  _exportStar(require("./notice"), exports);
24
26
  _exportStar(require("./panels"), exports);
25
27
  _exportStar(require("./query"), exports);
@@ -0,0 +1,68 @@
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
+ // This file contains common/shared legend model code.
14
+ // See the `components` package for legend model code specific to the Legend
15
+ // component and the `plugin-system` package for legend model code specific to
16
+ // panel plugin specs.
17
+ "use strict";
18
+ Object.defineProperty(exports, "__esModule", {
19
+ value: true
20
+ });
21
+ function _export(target, all) {
22
+ for(var name in all)Object.defineProperty(target, name, {
23
+ enumerable: true,
24
+ get: all[name]
25
+ });
26
+ }
27
+ _export(exports, {
28
+ legendPositions: ()=>legendPositions,
29
+ legendModes: ()=>legendModes,
30
+ isValidLegendPosition: ()=>isValidLegendPosition,
31
+ isValidLegendMode: ()=>isValidLegendMode,
32
+ DEFAULT_LEGEND: ()=>DEFAULT_LEGEND,
33
+ getLegendPosition: ()=>getLegendPosition,
34
+ getLegendMode: ()=>getLegendMode
35
+ });
36
+ const legendPositions = [
37
+ 'Bottom',
38
+ 'Right'
39
+ ];
40
+ const legendModes = [
41
+ 'List',
42
+ 'Table'
43
+ ];
44
+ function isValidLegendPosition(position) {
45
+ return legendPositions.includes(position);
46
+ }
47
+ function isValidLegendMode(mode) {
48
+ return legendModes.includes(mode);
49
+ }
50
+ const DEFAULT_LEGEND = {
51
+ position: 'Bottom',
52
+ mode: 'List'
53
+ };
54
+ function getLegendPosition(position) {
55
+ if (position === undefined) {
56
+ return DEFAULT_LEGEND.position;
57
+ }
58
+ if (isValidLegendPosition(position)) {
59
+ return position;
60
+ }
61
+ return DEFAULT_LEGEND.position;
62
+ }
63
+ function getLegendMode(mode) {
64
+ if (!mode || !isValidLegendMode(mode)) {
65
+ return DEFAULT_LEGEND.mode;
66
+ }
67
+ return mode;
68
+ }
@@ -0,0 +1,45 @@
1
+ import { TimeSeriesValueTuple } from '@perses-dev/core';
2
+ export declare const CalculationsMap: {
3
+ First: typeof first;
4
+ Last: typeof last;
5
+ FirstNumber: typeof firstNumber;
6
+ LastNumber: typeof lastNumber;
7
+ Mean: typeof mean;
8
+ Sum: typeof sum;
9
+ Min: typeof min;
10
+ Max: typeof max;
11
+ };
12
+ export declare type CalculationType = keyof typeof CalculationsMap;
13
+ export declare type CalculationConfig = {
14
+ label: string;
15
+ description: string;
16
+ };
17
+ export declare const CALCULATIONS_CONFIG: Readonly<Record<CalculationType, CalculationConfig>>;
18
+ export declare const DEFAULT_CALCULATION: CalculationType;
19
+ declare type CalculationValue = number | null | undefined;
20
+ /**
21
+ * Calculate a multiple values for a set of time series data.
22
+ *
23
+ * @param values - Array of time series data.
24
+ * @param includeCalculations - Array of calculations to include.
25
+ */
26
+ export declare function getCalculations<IncludeCalcs extends CalculationType[]>(values: TimeSeriesValueTuple[], includeCalculations: IncludeCalcs): Record<Extract<CalculationType, IncludeCalcs[number]>, CalculationValue>;
27
+ /**
28
+ * Calculate a single value for a set of time series data.
29
+ *
30
+ * Use `getCalculations` instead if you need multiple calculations.
31
+ *
32
+ * @param values - Array of time series data.
33
+ * @param calculation - Name of the calculation to calculate.
34
+ */
35
+ export declare function getCalculation(values: TimeSeriesValueTuple[], calculation: CalculationType): CalculationValue;
36
+ declare function first(values: TimeSeriesValueTuple[]): CalculationValue;
37
+ declare function last(values: TimeSeriesValueTuple[]): CalculationValue;
38
+ declare function firstNumber(values: TimeSeriesValueTuple[]): CalculationValue;
39
+ declare function lastNumber(values: TimeSeriesValueTuple[]): CalculationValue;
40
+ declare function mean(values: TimeSeriesValueTuple[]): CalculationValue;
41
+ declare function sum(values: TimeSeriesValueTuple[]): CalculationValue;
42
+ declare function min(values: TimeSeriesValueTuple[]): CalculationValue;
43
+ declare function max(values: TimeSeriesValueTuple[]): CalculationValue;
44
+ export {};
45
+ //# sourceMappingURL=calculations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculations.d.ts","sourceRoot":"","sources":["../../src/model/calculations.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,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EAAE,oBAAoB,EAAE,GAAG,gBAAgB,CAE7D;AAED,iBAAS,GAAG,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,gBAAgB,CAE7D"}
@@ -0,0 +1,165 @@
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 const CalculationsMap = {
14
+ First: first,
15
+ Last: last,
16
+ FirstNumber: firstNumber,
17
+ LastNumber: lastNumber,
18
+ Mean: mean,
19
+ Sum: sum,
20
+ Min: min,
21
+ Max: max
22
+ };
23
+ export const CALCULATIONS_CONFIG = {
24
+ First: {
25
+ label: 'First',
26
+ description: 'First value'
27
+ },
28
+ Last: {
29
+ label: 'Last',
30
+ description: 'Last value'
31
+ },
32
+ FirstNumber: {
33
+ label: 'First *',
34
+ description: 'First numeric value'
35
+ },
36
+ LastNumber: {
37
+ label: 'Last *',
38
+ description: 'Last numeric value'
39
+ },
40
+ Mean: {
41
+ label: 'Average',
42
+ description: 'Average value excluding nulls'
43
+ },
44
+ Sum: {
45
+ label: 'Sum',
46
+ description: 'The sum of all values'
47
+ },
48
+ Min: {
49
+ label: 'Min',
50
+ description: 'Minimum value'
51
+ },
52
+ Max: {
53
+ label: 'Max',
54
+ description: 'Maximum value'
55
+ }
56
+ };
57
+ export const DEFAULT_CALCULATION = 'Sum';
58
+ /**
59
+ * Calculate a multiple values for a set of time series data.
60
+ *
61
+ * @param values - Array of time series data.
62
+ * @param includeCalculations - Array of calculations to include.
63
+ */ export function getCalculations(values, includeCalculations) {
64
+ const calculations = includeCalculations.reduce((initResult, calculation)=>{
65
+ initResult[calculation] = undefined;
66
+ return initResult;
67
+ }, {});
68
+ // We save these values as separate values instead of directly setting them
69
+ // in the calculations because they are needed by multiple calculations.
70
+ let nonNullCount = 0;
71
+ let sum = 0;
72
+ // We use this large function capable of performing one or more calculations
73
+ // in a single iteration of the data to minimize the performance impact of
74
+ // generating multiple calculations for large timeseries values. This is
75
+ // less optimized for certain single calculations when done in isolation (e.g.
76
+ // `Last`), but will be more performant in the more expensive cases where
77
+ // multiple values are being used (e.g. table legend).
78
+ values.forEach((tuple, i)=>{
79
+ const value = tuple[1];
80
+ if (i === 0 && 'First' in calculations) {
81
+ calculations.First = value;
82
+ }
83
+ if (i === values.length - 1 && 'Last' in calculations) {
84
+ calculations.Last = value;
85
+ }
86
+ // Handling specific to non-null values.
87
+ if (typeof value === 'number') {
88
+ nonNullCount += 1;
89
+ sum += value;
90
+ if ('FirstNumber' in calculations && calculations.FirstNumber === undefined) {
91
+ // Save the first number we see.
92
+ calculations.FirstNumber = value;
93
+ }
94
+ if ('LastNumber' in calculations) {
95
+ // Keep setting the numbers we see, which will eventually be set to the
96
+ // last number when finished iterating.
97
+ calculations.LastNumber = value;
98
+ }
99
+ if ('Min' in calculations) {
100
+ if (typeof calculations.Min !== 'number') {
101
+ // Init the first time we see a number
102
+ calculations.Min = value;
103
+ } else {
104
+ // Use lowest value once initialized
105
+ calculations.Min = Math.min(calculations.Min, value);
106
+ }
107
+ }
108
+ if ('Max' in calculations) {
109
+ if (typeof calculations.Max !== 'number') {
110
+ // Init the first time we see a number
111
+ calculations.Max = value;
112
+ } else {
113
+ // Use highest value once initialized
114
+ calculations.Max = Math.max(calculations.Max, value);
115
+ }
116
+ }
117
+ }
118
+ });
119
+ // Set calculations that require iterating over all values.
120
+ if (nonNullCount > 0 && 'Sum' in calculations) {
121
+ calculations.Sum = sum;
122
+ }
123
+ if (nonNullCount > 0 && 'Mean' in calculations) {
124
+ calculations.Mean = sum / nonNullCount;
125
+ }
126
+ return calculations;
127
+ }
128
+ /**
129
+ * Calculate a single value for a set of time series data.
130
+ *
131
+ * Use `getCalculations` instead if you need multiple calculations.
132
+ *
133
+ * @param values - Array of time series data.
134
+ * @param calculation - Name of the calculation to calculate.
135
+ */ export function getCalculation(values, calculation) {
136
+ return getCalculations(values, [
137
+ calculation
138
+ ])[calculation];
139
+ }
140
+ function first(values) {
141
+ return getCalculation(values, 'First');
142
+ }
143
+ function last(values) {
144
+ return getCalculation(values, 'Last');
145
+ }
146
+ function firstNumber(values) {
147
+ return getCalculation(values, 'FirstNumber');
148
+ }
149
+ function lastNumber(values) {
150
+ return getCalculation(values, 'LastNumber');
151
+ }
152
+ function mean(values) {
153
+ return getCalculation(values, 'Mean');
154
+ }
155
+ function sum(values) {
156
+ return getCalculation(values, 'Sum');
157
+ }
158
+ function min(values) {
159
+ return getCalculation(values, 'Min');
160
+ }
161
+ function max(values) {
162
+ return getCalculation(values, 'Max');
163
+ }
164
+
165
+ //# sourceMappingURL=calculations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/calculations.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 { TimeSeriesValueTuple } from '@perses-dev/core';\n\nexport const CalculationsMap = {\n First: first,\n Last: last,\n FirstNumber: firstNumber,\n LastNumber: lastNumber,\n Mean: mean,\n Sum: sum,\n Min: min,\n Max: max,\n};\n\nexport type CalculationType = keyof typeof CalculationsMap;\n\nexport type CalculationConfig = {\n label: string;\n description: string;\n};\n\nexport const CALCULATIONS_CONFIG: Readonly<Record<CalculationType, CalculationConfig>> = {\n First: {\n label: 'First',\n description: 'First value',\n },\n Last: {\n label: 'Last',\n description: 'Last value',\n },\n FirstNumber: {\n label: 'First *',\n description: 'First numeric value',\n },\n LastNumber: {\n label: 'Last *',\n description: 'Last numeric value',\n },\n Mean: {\n label: 'Average',\n description: 'Average value excluding nulls',\n },\n Sum: {\n label: 'Sum',\n description: 'The sum of all values',\n },\n Min: {\n label: 'Min',\n description: 'Minimum value',\n },\n Max: {\n label: 'Max',\n description: 'Maximum value',\n },\n} as const;\n\nexport const DEFAULT_CALCULATION: CalculationType = 'Sum';\n\ntype CalculationValue = number | null | undefined;\n\n/**\n * Calculate a multiple values for a set of time series data.\n *\n * @param values - Array of time series data.\n * @param includeCalculations - Array of calculations to include.\n */\nexport function getCalculations<IncludeCalcs extends CalculationType[]>(\n values: TimeSeriesValueTuple[],\n includeCalculations: IncludeCalcs\n): Record<\n // This extract combined with the generics above keeps the key of the returned\n // record to *just* the specified calculations.\n Extract<CalculationType, IncludeCalcs[number]>,\n CalculationValue\n> {\n const calculations = includeCalculations.reduce((initResult, calculation) => {\n initResult[calculation] = undefined;\n return initResult;\n }, {} as Record<string, CalculationValue>);\n\n // We save these values as separate values instead of directly setting them\n // in the calculations because they are needed by multiple calculations.\n let nonNullCount = 0;\n let sum = 0;\n\n // We use this large function capable of performing one or more calculations\n // in a single iteration of the data to minimize the performance impact of\n // generating multiple calculations for large timeseries values. This is\n // less optimized for certain single calculations when done in isolation (e.g.\n // `Last`), but will be more performant in the more expensive cases where\n // multiple values are being used (e.g. table legend).\n values.forEach((tuple, i) => {\n const value = tuple[1];\n\n if (i === 0 && 'First' in calculations) {\n calculations.First = value;\n }\n if (i === values.length - 1 && 'Last' in calculations) {\n calculations.Last = value;\n }\n\n // Handling specific to non-null values.\n if (typeof value === 'number') {\n nonNullCount += 1;\n sum += value;\n\n if ('FirstNumber' in calculations && calculations.FirstNumber === undefined) {\n // Save the first number we see.\n calculations.FirstNumber = value;\n }\n\n if ('LastNumber' in calculations) {\n // Keep setting the numbers we see, which will eventually be set to the\n // last number when finished iterating.\n calculations.LastNumber = value;\n }\n\n if ('Min' in calculations) {\n if (typeof calculations.Min !== 'number') {\n // Init the first time we see a number\n calculations.Min = value;\n } else {\n // Use lowest value once initialized\n calculations.Min = Math.min(calculations.Min, value);\n }\n }\n\n if ('Max' in calculations) {\n if (typeof calculations.Max !== 'number') {\n // Init the first time we see a number\n calculations.Max = value;\n } else {\n // Use highest value once initialized\n calculations.Max = Math.max(calculations.Max, value);\n }\n }\n }\n });\n\n // Set calculations that require iterating over all values.\n if (nonNullCount > 0 && 'Sum' in calculations) {\n calculations.Sum = sum;\n }\n\n if (nonNullCount > 0 && 'Mean' in calculations) {\n calculations.Mean = sum / nonNullCount;\n }\n\n return calculations;\n}\n\n/**\n * Calculate a single value for a set of time series data.\n *\n * Use `getCalculations` instead if you need multiple calculations.\n *\n * @param values - Array of time series data.\n * @param calculation - Name of the calculation to calculate.\n */\nexport function getCalculation(values: TimeSeriesValueTuple[], calculation: CalculationType) {\n return getCalculations(values, [calculation])[calculation];\n}\n\nfunction first(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'First');\n}\n\nfunction last(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'Last');\n}\n\nfunction firstNumber(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'FirstNumber');\n}\n\nfunction lastNumber(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'LastNumber');\n}\n\nfunction mean(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'Mean');\n}\n\nfunction sum(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'Sum');\n}\n\nfunction min(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'Min');\n}\n\nfunction max(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'Max');\n}\n"],"names":["CalculationsMap","First","first","Last","last","FirstNumber","firstNumber","LastNumber","lastNumber","Mean","mean","Sum","sum","Min","min","Max","max","CALCULATIONS_CONFIG","label","description","DEFAULT_CALCULATION","getCalculations","values","includeCalculations","calculations","reduce","initResult","calculation","undefined","nonNullCount","forEach","tuple","i","value","length","Math","getCalculation"],"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,OAAO,MAAMA,eAAe,GAAG;IAC7BC,KAAK,EAAEC,KAAK;IACZC,IAAI,EAAEC,IAAI;IACVC,WAAW,EAAEC,WAAW;IACxBC,UAAU,EAAEC,UAAU;IACtBC,IAAI,EAAEC,IAAI;IACVC,GAAG,EAAEC,GAAG;IACRC,GAAG,EAAEC,GAAG;IACRC,GAAG,EAAEC,GAAG;CACT,CAAC;AASF,OAAO,MAAMC,mBAAmB,GAAyD;IACvFhB,KAAK,EAAE;QACLiB,KAAK,EAAE,OAAO;QACdC,WAAW,EAAE,aAAa;KAC3B;IACDhB,IAAI,EAAE;QACJe,KAAK,EAAE,MAAM;QACbC,WAAW,EAAE,YAAY;KAC1B;IACDd,WAAW,EAAE;QACXa,KAAK,EAAE,SAAS;QAChBC,WAAW,EAAE,qBAAqB;KACnC;IACDZ,UAAU,EAAE;QACVW,KAAK,EAAE,QAAQ;QACfC,WAAW,EAAE,oBAAoB;KAClC;IACDV,IAAI,EAAE;QACJS,KAAK,EAAE,SAAS;QAChBC,WAAW,EAAE,+BAA+B;KAC7C;IACDR,GAAG,EAAE;QACHO,KAAK,EAAE,KAAK;QACZC,WAAW,EAAE,uBAAuB;KACrC;IACDN,GAAG,EAAE;QACHK,KAAK,EAAE,KAAK;QACZC,WAAW,EAAE,eAAe;KAC7B;IACDJ,GAAG,EAAE;QACHG,KAAK,EAAE,KAAK;QACZC,WAAW,EAAE,eAAe;KAC7B;CACF,AAAS,CAAC;AAEX,OAAO,M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zB,KAAK,CAACoB,MAA8B,EAAoB;IAC/D,OAAOc,cAAc,CAACd,MAAM,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAED,SAASlB,IAAI,CAACkB,MAA8B,EAAoB;IAC9D,OAAOc,cAAc,CAACd,MAAM,EAAE,MAAM,CAAC,CAAC;AACxC,CAAC;AAED,SAAShB,WAAW,CAACgB,MAA8B,EAAoB;IACrE,OAAOc,cAAc,CAACd,MAAM,EAAE,aAAa,CAAC,CAAC;AAC/C,CAAC;AAED,SAASd,UAAU,CAACc,MAA8B,EAAoB;IACpE,OAAOc,cAAc,CAACd,MAAM,EAAE,YAAY,CAAC,CAAC;AAC9C,CAAC;AAED,SAASZ,IAAI,CAACY,MAA8B,EAAoB;IAC9D,OAAOc,cAAc,CAACd,MAAM,EAAE,MAAM,CAAC,CAAC;AACxC,CAAC;AAED,SAASV,GAAG,CAACU,MAA8B,EAAoB;IAC7D,OAAOc,cAAc,CAACd,MAAM,EAAE,KAAK,CAAC,CAAC;AACvC,CAAC;AAED,SAASR,GAAG,CAACQ,MAA8B,EAAoB;IAC7D,OAAOc,cAAc,CAACd,MAAM,EAAE,KAAK,CAAC,CAAC;AACvC,CAAC;AAED,SAASN,GAAG,CAACM,MAA8B,EAAoB;IAC7D,OAAOc,cAAc,CAACd,MAAM,EAAE,KAAK,CAAC,CAAC;AACvC,CAAC"}
@@ -1,9 +1,11 @@
1
+ export * from './calculations';
1
2
  export * from './dashboard';
2
3
  export * from './datasource';
3
4
  export * from './definitions';
4
5
  export * from './display';
5
6
  export * from './http';
6
7
  export * from './layout';
8
+ export * from './legend';
7
9
  export * from './notice';
8
10
  export * from './panels';
9
11
  export * from './query';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
@@ -10,12 +10,14 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
+ export * from './calculations';
13
14
  export * from './dashboard';
14
15
  export * from './datasource';
15
16
  export * from './definitions';
16
17
  export * from './display';
17
18
  export * from './http';
18
19
  export * from './layout';
20
+ export * from './legend';
19
21
  export * from './notice';
20
22
  export * from './panels';
21
23
  export * from './query';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/index.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 * from './dashboard';\nexport * from './datasource';\nexport * from './definitions';\nexport * from './display';\nexport * from './http';\nexport * from './layout';\nexport * from './notice';\nexport * from './panels';\nexport * from './query';\nexport * from './resource';\nexport * from './thresholds';\nexport * from './time';\nexport * from './time-series-data';\nexport * from './time-series-queries';\nexport * from './variables';\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,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"sources":["../../src/model/index.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 * from './calculations';\nexport * from './dashboard';\nexport * from './datasource';\nexport * from './definitions';\nexport * from './display';\nexport * from './http';\nexport * from './layout';\nexport * from './legend';\nexport * from './notice';\nexport * from './panels';\nexport * from './query';\nexport * from './resource';\nexport * from './thresholds';\nexport * from './time';\nexport * from './time-series-data';\nexport * from './time-series-queries';\nexport * from './variables';\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,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
@@ -0,0 +1,14 @@
1
+ export declare const legendPositions: readonly ["Bottom", "Right"];
2
+ export declare type LegendPositions = (typeof legendPositions)[number];
3
+ export declare const legendModes: readonly ["List", "Table"];
4
+ export declare type LegendMode = (typeof legendModes)[number];
5
+ export interface LegendOptionsBase {
6
+ position: LegendPositions;
7
+ mode?: LegendMode;
8
+ }
9
+ export declare function isValidLegendPosition(position: LegendPositions): boolean;
10
+ export declare function isValidLegendMode(mode: LegendMode): boolean;
11
+ export declare const DEFAULT_LEGEND: Required<LegendOptionsBase>;
12
+ export declare function getLegendPosition(position?: LegendPositions): "Bottom" | "Right";
13
+ export declare function getLegendMode(mode?: LegendMode): "List" | "Table";
14
+ //# sourceMappingURL=legend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legend.d.ts","sourceRoot":"","sources":["../../src/model/legend.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,eAAe,8BAA+B,CAAC;AAC5D,oBAAY,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,eAAO,MAAM,WAAW,4BAA6B,CAAC;AACtD,oBAAY,UAAU,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAGtD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,WAE9D;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,WAEjD;AAED,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,iBAAiB,CAGtD,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,QAAQ,CAAC,EAAE,eAAe,sBAQ3D;AAED,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,UAAU,oBAM9C"}
@@ -0,0 +1,51 @@
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
+ // This file contains common/shared legend model code.
14
+ // See the `components` package for legend model code specific to the Legend
15
+ // component and the `plugin-system` package for legend model code specific to
16
+ // panel plugin specs.
17
+ export const legendPositions = [
18
+ 'Bottom',
19
+ 'Right'
20
+ ];
21
+ export const legendModes = [
22
+ 'List',
23
+ 'Table'
24
+ ];
25
+ export function isValidLegendPosition(position) {
26
+ return legendPositions.includes(position);
27
+ }
28
+ export function isValidLegendMode(mode) {
29
+ return legendModes.includes(mode);
30
+ }
31
+ export const DEFAULT_LEGEND = {
32
+ position: 'Bottom',
33
+ mode: 'List'
34
+ };
35
+ export function getLegendPosition(position) {
36
+ if (position === undefined) {
37
+ return DEFAULT_LEGEND.position;
38
+ }
39
+ if (isValidLegendPosition(position)) {
40
+ return position;
41
+ }
42
+ return DEFAULT_LEGEND.position;
43
+ }
44
+ export function getLegendMode(mode) {
45
+ if (!mode || !isValidLegendMode(mode)) {
46
+ return DEFAULT_LEGEND.mode;
47
+ }
48
+ return mode;
49
+ }
50
+
51
+ //# sourceMappingURL=legend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/legend.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\n// This file contains common/shared legend model code.\n// See the `components` package for legend model code specific to the Legend\n// component and the `plugin-system` package for legend model code specific to\n// panel plugin specs.\n\nexport const legendPositions = ['Bottom', 'Right'] as const;\nexport type LegendPositions = (typeof legendPositions)[number];\n\nexport const legendModes = ['List', 'Table'] as const;\nexport type LegendMode = (typeof legendModes)[number];\n\n// Common legend options used across some UI components and panel specifications\nexport interface LegendOptionsBase {\n position: LegendPositions;\n mode?: LegendMode;\n}\n\nexport function isValidLegendPosition(position: LegendPositions) {\n return (legendPositions as readonly string[]).includes(position);\n}\n\nexport function isValidLegendMode(mode: LegendMode) {\n return (legendModes as readonly string[]).includes(mode);\n}\n\nexport const DEFAULT_LEGEND: Required<LegendOptionsBase> = {\n position: 'Bottom',\n mode: 'List',\n};\n\nexport function getLegendPosition(position?: LegendPositions) {\n if (position === undefined) {\n return DEFAULT_LEGEND.position;\n }\n if (isValidLegendPosition(position)) {\n return position;\n }\n return DEFAULT_LEGEND.position;\n}\n\nexport function getLegendMode(mode?: LegendMode) {\n if (!mode || !isValidLegendMode(mode)) {\n return DEFAULT_LEGEND.mode;\n }\n\n return mode;\n}\n"],"names":["legendPositions","legendModes","isValidLegendPosition","position","includes","isValidLegendMode","mode","DEFAULT_LEGEND","getLegendPosition","undefined","getLegendMode"],"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,sDAAsD;AACtD,4EAA4E;AAC5E,+EAA+E;AAC/E,sBAAsB;AAEtB,OAAO,MAAMA,eAAe,GAAG;IAAC,QAAQ;IAAE,OAAO;CAAC,AAAS,CAAC;AAG5D,OAAO,MAAMC,WAAW,GAAG;IAAC,MAAM;IAAE,OAAO;CAAC,AAAS,CAAC;AAStD,OAAO,SAASC,qBAAqB,CAACC,QAAyB,EAAE;IAC/D,OAAO,AAACH,eAAe,CAAuBI,QAAQ,CAACD,QAAQ,CAAC,CAAC;AACnE,CAAC;AAED,OAAO,SAASE,iBAAiB,CAACC,IAAgB,EAAE;IAClD,OAAO,AAACL,WAAW,CAAuBG,QAAQ,CAACE,IAAI,CAAC,CAAC;AAC3D,CAAC;AAED,OAAO,MAAMC,cAAc,GAAgC;IACzDJ,QAAQ,EAAE,QAAQ;IAClBG,IAAI,EAAE,MAAM;CACb,CAAC;AAEF,OAAO,SAASE,iBAAiB,CAACL,QAA0B,EAAE;IAC5D,IAAIA,QAAQ,KAAKM,SAAS,EAAE;QAC1B,OAAOF,cAAc,CAACJ,QAAQ,CAAC;IACjC,CAAC;IACD,IAAID,qBAAqB,CAACC,QAAQ,CAAC,EAAE;QACnC,OAAOA,QAAQ,CAAC;IAClB,CAAC;IACD,OAAOI,cAAc,CAACJ,QAAQ,CAAC;AACjC,CAAC;AAED,OAAO,SAASO,aAAa,CAACJ,IAAiB,EAAE;IAC/C,IAAI,CAACA,IAAI,IAAI,CAACD,iBAAiB,CAACC,IAAI,CAAC,EAAE;QACrC,OAAOC,cAAc,CAACD,IAAI,CAAC;IAC7B,CAAC;IAED,OAAOA,IAAI,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/core",
3
- "version": "0.33.0",
3
+ "version": "0.35.0",
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",
@@ -30,16 +30,13 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "date-fns": "^2.28.0",
33
- "lodash-es": "^4.17.21",
33
+ "lodash": "^4.17.21",
34
34
  "mathjs": "^10.6.4"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "react": "^17.0.2 || ^18.0.0",
38
38
  "react-dom": "^17.0.2 || ^18.0.0"
39
39
  },
40
- "devDependencies": {
41
- "@types/lodash-es": "^4.17.6"
42
- },
43
40
  "files": [
44
41
  "dist"
45
42
  ]