@perses-dev/core 0.33.0 → 0.34.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,89 @@
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
+ });
28
+ const _findLast = /*#__PURE__*/ _interopRequireDefault(require("lodash/findLast"));
29
+ const _meanBy = /*#__PURE__*/ _interopRequireDefault(require("lodash/meanBy"));
30
+ const _sumBy = /*#__PURE__*/ _interopRequireDefault(require("lodash/sumBy"));
31
+ function _interopRequireDefault(obj) {
32
+ return obj && obj.__esModule ? obj : {
33
+ default: obj
34
+ };
35
+ }
36
+ const CalculationsMap = {
37
+ First: first,
38
+ Last: last,
39
+ LastNumber: lastNumber,
40
+ Mean: mean,
41
+ Sum: sum
42
+ };
43
+ const CALCULATIONS_CONFIG = {
44
+ First: {
45
+ label: 'First'
46
+ },
47
+ Last: {
48
+ label: 'Last'
49
+ },
50
+ LastNumber: {
51
+ label: 'Last number'
52
+ },
53
+ Mean: {
54
+ label: 'Mean'
55
+ },
56
+ Sum: {
57
+ label: 'Sum'
58
+ }
59
+ };
60
+ const DEFAULT_CALCULATION = 'Sum';
61
+ function first(values) {
62
+ const tuple = values[0];
63
+ return tuple === undefined ? undefined : getValue(tuple);
64
+ }
65
+ function last(values) {
66
+ if (values.length <= 0) return undefined;
67
+ const tuple = values[values.length - 1];
68
+ return tuple === undefined ? undefined : getValue(tuple);
69
+ }
70
+ function lastNumber(values) {
71
+ const tuple = (0, _findLast.default)(values, (tuple)=>isNaN(getValue(tuple)) === false);
72
+ return tuple === undefined ? undefined : getValue(tuple);
73
+ }
74
+ function mean(values) {
75
+ if (values.length <= 0) return undefined;
76
+ return (0, _meanBy.default)(values, getValue);
77
+ }
78
+ function sum(values) {
79
+ if (values.length <= 0) return undefined;
80
+ return (0, _sumBy.default)(values, getValue);
81
+ }
82
+ function getValue(valueTuple) {
83
+ const value = valueTuple[1];
84
+ if (value !== null) {
85
+ return value;
86
+ }
87
+ // TODO: refactor utils so null can be returned and LastNotNull supported
88
+ return NaN;
89
+ }
@@ -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,21 @@
1
+ import { TimeSeriesValueTuple } from '@perses-dev/core';
2
+ export declare const CalculationsMap: {
3
+ First: typeof first;
4
+ Last: typeof last;
5
+ LastNumber: typeof lastNumber;
6
+ Mean: typeof mean;
7
+ Sum: typeof sum;
8
+ };
9
+ export declare type CalculationType = keyof typeof CalculationsMap;
10
+ export declare type CalculationConfig = {
11
+ label: string;
12
+ };
13
+ export declare const CALCULATIONS_CONFIG: Readonly<Record<CalculationType, CalculationConfig>>;
14
+ export declare const DEFAULT_CALCULATION: CalculationType;
15
+ declare function first(values: TimeSeriesValueTuple[]): number | undefined;
16
+ declare function last(values: TimeSeriesValueTuple[]): number | undefined;
17
+ declare function lastNumber(values: TimeSeriesValueTuple[]): number | undefined;
18
+ declare function mean(values: TimeSeriesValueTuple[]): number | undefined;
19
+ declare function sum(values: TimeSeriesValueTuple[]): number | undefined;
20
+ export {};
21
+ //# sourceMappingURL=calculations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculations.d.ts","sourceRoot":"","sources":["../../src/model/calculations.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD,eAAO,MAAM,eAAe;;;;;;CAM3B,CAAC;AAEF,oBAAY,eAAe,GAAG,MAAM,OAAO,eAAe,CAAC;AAE3D,oBAAY,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AACF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAgB3E,CAAC;AAEX,eAAO,MAAM,mBAAmB,EAAE,eAAuB,CAAC;AAE1D,iBAAS,KAAK,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,GAAG,SAAS,CAGjE;AAED,iBAAS,IAAI,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,GAAG,SAAS,CAKhE;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,GAAG,SAAS,CAGtE;AAED,iBAAS,IAAI,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,GAAG,SAAS,CAGhE;AAED,iBAAS,GAAG,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,MAAM,GAAG,SAAS,CAG/D"}
@@ -0,0 +1,72 @@
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 from 'lodash/findLast';
14
+ import meanBy from 'lodash/meanBy';
15
+ import sumBy from 'lodash/sumBy';
16
+ // TODO: move this file and calculations.test.ts to @perses-dev/core
17
+ export const CalculationsMap = {
18
+ First: first,
19
+ Last: last,
20
+ LastNumber: lastNumber,
21
+ Mean: mean,
22
+ Sum: sum
23
+ };
24
+ export const CALCULATIONS_CONFIG = {
25
+ First: {
26
+ label: 'First'
27
+ },
28
+ Last: {
29
+ label: 'Last'
30
+ },
31
+ LastNumber: {
32
+ label: 'Last number'
33
+ },
34
+ Mean: {
35
+ label: 'Mean'
36
+ },
37
+ Sum: {
38
+ label: 'Sum'
39
+ }
40
+ };
41
+ export const DEFAULT_CALCULATION = 'Sum';
42
+ function first(values) {
43
+ const tuple = values[0];
44
+ return tuple === undefined ? undefined : getValue(tuple);
45
+ }
46
+ function last(values) {
47
+ if (values.length <= 0) return undefined;
48
+ const tuple = values[values.length - 1];
49
+ return tuple === undefined ? undefined : getValue(tuple);
50
+ }
51
+ function lastNumber(values) {
52
+ const tuple = findLast(values, (tuple)=>isNaN(getValue(tuple)) === false);
53
+ return tuple === undefined ? undefined : getValue(tuple);
54
+ }
55
+ function mean(values) {
56
+ if (values.length <= 0) return undefined;
57
+ return meanBy(values, getValue);
58
+ }
59
+ function sum(values) {
60
+ if (values.length <= 0) return undefined;
61
+ return sumBy(values, getValue);
62
+ }
63
+ function getValue(valueTuple) {
64
+ const value = valueTuple[1];
65
+ if (value !== null) {
66
+ return value;
67
+ }
68
+ // TODO: refactor utils so null can be returned and LastNotNull supported
69
+ return NaN;
70
+ }
71
+
72
+ //# 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 findLast from 'lodash/findLast';\nimport meanBy from 'lodash/meanBy';\nimport sumBy from 'lodash/sumBy';\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,OAAOA,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAOC,MAAM,MAAM,eAAe,CAAC;AACnC,OAAOC,KAAK,MAAM,cAAc,CAAC;AAGjC,oEAAoE;AACpE,OAAO,MAAMC,eAAe,GAAG;IAC7BC,KAAK,EAAEC,KAAK;IACZC,IAAI,EAAEC,IAAI;IACVC,UAAU,EAAEC,UAAU;IACtBC,IAAI,EAAEC,IAAI;IACVC,GAAG,EAAEC,GAAG;CACT,CAAC;AAOF,OAAO,MAAMC,mBAAmB,GAAyD;IACvFV,KAAK,EAAE;QACLW,KAAK,EAAE,OAAO;KACf;IACDT,IAAI,EAAE;QACJS,KAAK,EAAE,MAAM;KACd;IACDP,UAAU,EAAE;QACVO,KAAK,EAAE,aAAa;KACrB;IACDL,IAAI,EAAE;QACJK,KAAK,EAAE,MAAM;KACd;IACDH,GAAG,EAAE;QACHG,KAAK,EAAE,KAAK;KACb;CACF,AAAS,CAAC;AAEX,OAAO,MAAMC,mBAAmB,GAAoB,KAAK,CAAC;AAE1D,SAASX,KAAK,CAACY,MAA8B,EAAsB;IACjE,MAAMC,KAAK,GAAGD,MAAM,CAAC,CAAC,CAAC,AAAC;IACxB,OAAOC,KAAK,KAAKC,SAAS,GAAGA,SAAS,GAAGC,QAAQ,CAACF,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED,SAASX,IAAI,CAACU,MAA8B,EAAsB;IAChE,IAAIA,MAAM,CAACI,MAAM,IAAI,CAAC,EAAE,OAAOF,SAAS,CAAC;IAEzC,MAAMD,KAAK,GAAGD,MAAM,CAACA,MAAM,CAACI,MAAM,GAAG,CAAC,CAAC,AAAC;IACxC,OAAOH,KAAK,KAAKC,SAAS,GAAGA,SAAS,GAAGC,QAAQ,CAACF,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED,SAAST,UAAU,CAACQ,MAA8B,EAAsB;IACtE,MAAMC,KAAK,GAAGlB,QAAQ,CAACiB,MAAM,EAAE,CAACC,KAAK,GAAKI,KAAK,CAACF,QAAQ,CAACF,KAAK,CAAC,CAAC,KAAK,KAAK,CAAC,AAAC;IAC5E,OAAOA,KAAK,KAAKC,SAAS,GAAGA,SAAS,GAAGC,QAAQ,CAACF,KAAK,CAAC,CAAC;AAC3D,CAAC;AAED,SAASP,IAAI,CAACM,MAA8B,EAAsB;IAChE,IAAIA,MAAM,CAACI,MAAM,IAAI,CAAC,EAAE,OAAOF,SAAS,CAAC;IACzC,OAAOlB,MAAM,CAACgB,MAAM,EAAEG,QAAQ,CAAC,CAAC;AAClC,CAAC;AAED,SAASP,GAAG,CAACI,MAA8B,EAAsB;IAC/D,IAAIA,MAAM,CAACI,MAAM,IAAI,CAAC,EAAE,OAAOF,SAAS,CAAC;IACzC,OAAOjB,KAAK,CAACe,MAAM,EAAEG,QAAQ,CAAC,CAAC;AACjC,CAAC;AAED,SAASA,QAAQ,CAACG,UAAgC,EAAE;IAClD,MAAMC,KAAK,GAAGD,UAAU,CAAC,CAAC,CAAC,AAAC;IAC5B,IAAIC,KAAK,KAAK,IAAI,EAAE;QAClB,OAAOA,KAAK,CAAC;IACf,CAAC;IACD,yEAAyE;IACzE,OAAOC,GAAG,CAAC;AACb,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.34.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
  ]