@perses-dev/plugin-system 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.
Files changed (56) hide show
  1. package/dist/cjs/components/CalculationSelector/CalculationSelector.js +4 -9
  2. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +153 -0
  3. package/dist/cjs/components/LegendOptionsEditor/index.js +28 -0
  4. package/dist/cjs/components/index.js +1 -0
  5. package/dist/cjs/index.js +1 -0
  6. package/dist/cjs/model/index.js +1 -1
  7. package/dist/cjs/model/legend.js +73 -0
  8. package/dist/cjs/runtime/template-variables.js +9 -1
  9. package/dist/cjs/utils/index.js +28 -0
  10. package/dist/cjs/utils/variables.js +68 -0
  11. package/dist/components/CalculationSelector/CalculationSelector.d.ts +1 -1
  12. package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
  13. package/dist/components/CalculationSelector/CalculationSelector.js +3 -8
  14. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  15. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts +8 -0
  16. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -0
  17. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +147 -0
  18. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -0
  19. package/dist/components/LegendOptionsEditor/index.d.ts +2 -0
  20. package/dist/components/LegendOptionsEditor/index.d.ts.map +1 -0
  21. package/dist/components/LegendOptionsEditor/index.js +15 -0
  22. package/dist/components/LegendOptionsEditor/index.js.map +1 -0
  23. package/dist/components/index.d.ts +1 -0
  24. package/dist/components/index.d.ts.map +1 -1
  25. package/dist/components/index.js +1 -0
  26. package/dist/components/index.js.map +1 -1
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +1 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/model/index.d.ts +1 -1
  32. package/dist/model/index.d.ts.map +1 -1
  33. package/dist/model/index.js +1 -1
  34. package/dist/model/index.js.map +1 -1
  35. package/dist/model/legend.d.ts +15 -0
  36. package/dist/model/legend.d.ts.map +1 -0
  37. package/dist/model/legend.js +65 -0
  38. package/dist/model/legend.js.map +1 -0
  39. package/dist/runtime/template-variables.d.ts +1 -0
  40. package/dist/runtime/template-variables.d.ts.map +1 -1
  41. package/dist/runtime/template-variables.js +8 -0
  42. package/dist/runtime/template-variables.js.map +1 -1
  43. package/dist/utils/index.d.ts +2 -0
  44. package/dist/utils/index.d.ts.map +1 -0
  45. package/dist/utils/index.js +15 -0
  46. package/dist/utils/index.js.map +1 -0
  47. package/dist/utils/variables.d.ts +9 -0
  48. package/dist/utils/variables.d.ts.map +1 -0
  49. package/dist/utils/variables.js +57 -0
  50. package/dist/utils/variables.js.map +1 -0
  51. package/package.json +4 -4
  52. package/dist/cjs/model/calculations.js +0 -82
  53. package/dist/model/calculations.d.ts +0 -21
  54. package/dist/model/calculations.d.ts.map +0 -1
  55. package/dist/model/calculations.js +0 -70
  56. package/dist/model/calculations.js.map +0 -1
@@ -1,70 +0,0 @@
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
- import { findLast, meanBy, sumBy } from 'lodash-es';
14
- // TODO: move this file and calculations.test.ts to @perses-dev/core
15
- export const CalculationsMap = {
16
- First: first,
17
- Last: last,
18
- LastNumber: lastNumber,
19
- Mean: mean,
20
- Sum: sum
21
- };
22
- export const CALCULATIONS_CONFIG = {
23
- First: {
24
- label: 'First'
25
- },
26
- Last: {
27
- label: 'Last'
28
- },
29
- LastNumber: {
30
- label: 'Last number'
31
- },
32
- Mean: {
33
- label: 'Mean'
34
- },
35
- Sum: {
36
- label: 'Sum'
37
- }
38
- };
39
- export const DEFAULT_CALCULATION = 'Sum';
40
- function first(values) {
41
- const tuple = values[0];
42
- return tuple === undefined ? undefined : getValue(tuple);
43
- }
44
- function last(values) {
45
- if (values.length <= 0) return undefined;
46
- const tuple = values[values.length - 1];
47
- return tuple === undefined ? undefined : getValue(tuple);
48
- }
49
- function lastNumber(values) {
50
- const tuple = findLast(values, (tuple)=>isNaN(getValue(tuple)) === false);
51
- return tuple === undefined ? undefined : getValue(tuple);
52
- }
53
- function mean(values) {
54
- if (values.length <= 0) return undefined;
55
- return meanBy(values, getValue);
56
- }
57
- function sum(values) {
58
- if (values.length <= 0) return undefined;
59
- return sumBy(values, getValue);
60
- }
61
- function getValue(valueTuple) {
62
- const value = valueTuple[1];
63
- if (value !== null) {
64
- return value;
65
- }
66
- // TODO: refactor utils so null can be returned and LastNotNull supported
67
- return NaN;
68
- }
69
-
70
- //# sourceMappingURL=calculations.js.map
@@ -1 +0,0 @@
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 { findLast, meanBy, sumBy } from 'lodash-es';\nimport { TimeSeriesValueTuple } from '@perses-dev/core';\n\n// TODO: move this file and calculations.test.ts to @perses-dev/core\nexport const CalculationsMap = {\n First: first,\n Last: last,\n LastNumber: lastNumber,\n Mean: mean,\n Sum: sum,\n};\n\nexport type CalculationType = keyof typeof CalculationsMap;\n\nexport type CalculationConfig = {\n label: string;\n};\nexport const CALCULATIONS_CONFIG: Readonly<Record<CalculationType, CalculationConfig>> = {\n First: {\n label: 'First',\n },\n Last: {\n label: 'Last',\n },\n LastNumber: {\n label: 'Last number',\n },\n Mean: {\n label: 'Mean',\n },\n Sum: {\n label: 'Sum',\n },\n} as const;\n\nexport const DEFAULT_CALCULATION: CalculationType = 'Sum';\n\nfunction first(values: TimeSeriesValueTuple[]): number | undefined {\n const tuple = values[0];\n return tuple === undefined ? undefined : getValue(tuple);\n}\n\nfunction last(values: TimeSeriesValueTuple[]): number | undefined {\n if (values.length <= 0) return undefined;\n\n const tuple = values[values.length - 1];\n return tuple === undefined ? undefined : getValue(tuple);\n}\n\nfunction lastNumber(values: TimeSeriesValueTuple[]): number | undefined {\n const tuple = findLast(values, (tuple) => isNaN(getValue(tuple)) === false);\n return tuple === undefined ? undefined : getValue(tuple);\n}\n\nfunction mean(values: TimeSeriesValueTuple[]): number | undefined {\n if (values.length <= 0) return undefined;\n return meanBy(values, getValue);\n}\n\nfunction sum(values: TimeSeriesValueTuple[]): number | undefined {\n if (values.length <= 0) return undefined;\n return sumBy(values, getValue);\n}\n\nfunction getValue(valueTuple: TimeSeriesValueTuple) {\n const value = valueTuple[1];\n if (value !== null) {\n return value;\n }\n // TODO: refactor utils so null can be returned and LastNotNull supported\n return NaN;\n}\n"],"names":["findLast","meanBy","sumBy","CalculationsMap","First","first","Last","last","LastNumber","lastNumber","Mean","mean","Sum","sum","CALCULATIONS_CONFIG","label","DEFAULT_CALCULATION","values","tuple","undefined","getValue","length","isNaN","valueTuple","value","NaN"],"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,SAASA,QAAQ,EAAEC,MAAM,EAAEC,KAAK,QAAQ,WAAW,CAAC;AA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