@perses-dev/core 0.0.0-snapshot-scatterplot-fix-imports-95e1b59 → 0.0.0-snapshot-explorer-plugin-c4a7621
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.
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/model/calculations.js +1 -1
- package/dist/cjs/model/index.js +3 -0
- package/dist/cjs/model/query.js +12 -0
- package/dist/cjs/model/resource.js +14 -3
- package/dist/cjs/model/time.js +9 -11
- package/dist/cjs/model/trace-data.js +29 -1
- package/dist/cjs/model/transforms.js +28 -0
- package/dist/cjs/model/units/bytes.js +0 -3
- package/dist/cjs/model/units/decimal.js +0 -3
- package/dist/cjs/model/units/percent.js +0 -5
- package/dist/cjs/model/units/throughput.js +18 -12
- package/dist/cjs/model/units/time.js +0 -10
- package/dist/cjs/model/units/types.js +0 -13
- package/dist/cjs/model/units/units.js +1 -1
- package/dist/cjs/model/user.js +16 -0
- package/dist/cjs/model/value-mapping.js +16 -0
- package/dist/cjs/schema/datasource.js +85 -0
- package/dist/cjs/schema/display.js +27 -0
- package/dist/cjs/schema/duration.js +25 -0
- package/dist/cjs/schema/index.js +40 -0
- package/dist/cjs/schema/metadata.js +41 -0
- package/dist/cjs/schema/panel.js +106 -0
- package/dist/cjs/schema/plugin.js +27 -0
- package/dist/cjs/schema/role.js +86 -0
- package/dist/cjs/schema/rolebinding.js +65 -0
- package/dist/cjs/schema/secret.js +174 -0
- package/dist/cjs/schema/user.js +57 -0
- package/dist/cjs/schema/variable.js +171 -0
- package/dist/cjs/utils/fetch.js +14 -20
- package/dist/cjs/utils/index.js +3 -0
- package/dist/cjs/utils/memo.js +1 -2
- package/dist/cjs/utils/regexp.js +54 -0
- package/dist/cjs/utils/text.js +21 -46
- package/dist/cjs/utils/transform-data.js +167 -0
- package/dist/cjs/utils/value-mapping.js +105 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/model/calculations.d.ts +1 -1
- package/dist/model/calculations.d.ts.map +1 -1
- package/dist/model/calculations.js +1 -1
- package/dist/model/calculations.js.map +1 -1
- package/dist/model/datasource.d.ts +8 -8
- package/dist/model/datasource.d.ts.map +1 -1
- package/dist/model/datasource.js.map +1 -1
- package/dist/model/http.d.ts +5 -0
- package/dist/model/http.d.ts.map +1 -1
- package/dist/model/http.js.map +1 -1
- package/dist/model/index.d.ts +3 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +3 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/legend.d.ts +3 -3
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js.map +1 -1
- package/dist/model/panels.d.ts +17 -1
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/project.d.ts +5 -0
- package/dist/model/project.d.ts.map +1 -1
- package/dist/model/project.js.map +1 -1
- package/dist/model/query.d.ts +10 -0
- package/dist/model/query.d.ts.map +1 -1
- package/dist/model/query.js +8 -3
- package/dist/model/query.js.map +1 -1
- package/dist/model/resource.d.ts +7 -0
- package/dist/model/resource.d.ts.map +1 -1
- package/dist/model/resource.js +3 -0
- package/dist/model/resource.js.map +1 -1
- package/dist/model/time-series-data.d.ts +1 -0
- package/dist/model/time-series-data.d.ts.map +1 -1
- package/dist/model/time-series-data.js.map +1 -1
- package/dist/model/time.d.ts.map +1 -1
- package/dist/model/time.js +9 -11
- package/dist/model/time.js.map +1 -1
- package/dist/model/trace-data.d.ts +80 -7
- package/dist/model/trace-data.d.ts.map +1 -1
- package/dist/model/trace-data.js +7 -3
- package/dist/model/trace-data.js.map +1 -1
- package/dist/model/transforms.d.ts +34 -0
- package/dist/model/transforms.d.ts.map +1 -0
- package/dist/model/transforms.js +21 -0
- package/dist/model/transforms.js.map +1 -0
- package/dist/model/units/bytes.d.ts +1 -2
- package/dist/model/units/bytes.d.ts.map +1 -1
- package/dist/model/units/bytes.js +0 -3
- package/dist/model/units/bytes.js.map +1 -1
- package/dist/model/units/decimal.d.ts +1 -2
- package/dist/model/units/decimal.d.ts.map +1 -1
- package/dist/model/units/decimal.js +0 -3
- package/dist/model/units/decimal.js.map +1 -1
- package/dist/model/units/percent.d.ts +1 -2
- package/dist/model/units/percent.d.ts.map +1 -1
- package/dist/model/units/percent.js +0 -5
- package/dist/model/units/percent.js.map +1 -1
- package/dist/model/units/throughput.d.ts +1 -2
- package/dist/model/units/throughput.d.ts.map +1 -1
- package/dist/model/units/throughput.js +18 -12
- package/dist/model/units/throughput.js.map +1 -1
- package/dist/model/units/time.d.ts +1 -2
- package/dist/model/units/time.d.ts.map +1 -1
- package/dist/model/units/time.js +0 -10
- package/dist/model/units/time.js.map +1 -1
- package/dist/model/units/types.d.ts +1 -2
- package/dist/model/units/types.d.ts.map +1 -1
- package/dist/model/units/types.js +1 -7
- package/dist/model/units/types.js.map +1 -1
- package/dist/model/units/units.d.ts +2 -0
- package/dist/model/units/units.d.ts.map +1 -1
- package/dist/model/units/units.js +1 -1
- package/dist/model/units/units.js.map +1 -1
- package/dist/model/units/utils.d.ts.map +1 -1
- package/dist/model/units/utils.js.map +1 -1
- package/dist/model/user.d.ts +21 -0
- package/dist/model/user.d.ts.map +1 -0
- package/dist/model/user.js +15 -0
- package/dist/model/user.js.map +1 -0
- package/dist/model/value-mapping.d.ts +35 -0
- package/dist/model/value-mapping.d.ts.map +1 -0
- package/dist/model/value-mapping.js +15 -0
- package/dist/model/value-mapping.js.map +1 -0
- package/dist/model/variables.d.ts +9 -8
- package/dist/model/variables.d.ts.map +1 -1
- package/dist/model/variables.js.map +1 -1
- package/dist/schema/datasource.d.ts +61 -0
- package/dist/schema/datasource.d.ts.map +1 -0
- package/dist/schema/datasource.js +54 -0
- package/dist/schema/datasource.js.map +1 -0
- package/dist/schema/display.d.ts +12 -0
- package/dist/schema/display.d.ts.map +1 -0
- package/dist/schema/display.js +19 -0
- package/dist/schema/display.js.map +1 -0
- package/dist/schema/duration.d.ts +3 -0
- package/dist/schema/duration.d.ts.map +1 -0
- package/dist/schema/duration.js +17 -0
- package/dist/schema/duration.js.map +1 -0
- package/dist/schema/index.d.ts +12 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +25 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/metadata.d.ts +21 -0
- package/dist/schema/metadata.d.ts.map +1 -0
- package/dist/schema/metadata.js +22 -0
- package/dist/schema/metadata.js.map +1 -0
- package/dist/schema/panel.d.ts +13 -0
- package/dist/schema/panel.d.ts.map +1 -0
- package/dist/schema/panel.js +69 -0
- package/dist/schema/panel.js.map +1 -0
- package/dist/schema/plugin.d.ts +14 -0
- package/dist/schema/plugin.d.ts.map +1 -0
- package/dist/schema/plugin.js +19 -0
- package/dist/schema/plugin.js.map +1 -0
- package/dist/schema/role.d.ts +58 -0
- package/dist/schema/role.d.ts.map +1 -0
- package/dist/schema/role.js +61 -0
- package/dist/schema/role.js.map +1 -0
- package/dist/schema/rolebinding.d.ts +58 -0
- package/dist/schema/rolebinding.d.ts.map +1 -0
- package/dist/schema/rolebinding.js +40 -0
- package/dist/schema/rolebinding.js.map +1 -0
- package/dist/schema/secret.d.ts +1140 -0
- package/dist/schema/secret.d.ts.map +1 -0
- package/dist/schema/secret.js +152 -0
- package/dist/schema/secret.js.map +1 -0
- package/dist/schema/user.d.ts +8 -0
- package/dist/schema/user.d.ts.map +1 -0
- package/dist/schema/user.js +36 -0
- package/dist/schema/user.js.map +1 -0
- package/dist/schema/variable.d.ts +92 -0
- package/dist/schema/variable.d.ts.map +1 -0
- package/dist/schema/variable.js +119 -0
- package/dist/schema/variable.js.map +1 -0
- package/dist/utils/fetch.d.ts +5 -2
- package/dist/utils/fetch.d.ts.map +1 -1
- package/dist/utils/fetch.js +15 -21
- package/dist/utils/fetch.js.map +1 -1
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/is-empty-object.d.ts.map +1 -1
- package/dist/utils/is-empty-object.js.map +1 -1
- package/dist/utils/memo.d.ts.map +1 -1
- package/dist/utils/memo.js +1 -2
- package/dist/utils/memo.js.map +1 -1
- package/dist/utils/panel-refs.d.ts +2 -2
- package/dist/utils/panel-refs.d.ts.map +1 -1
- package/dist/utils/panel-refs.js.map +1 -1
- package/dist/utils/regexp.d.ts +11 -0
- package/dist/utils/regexp.d.ts.map +1 -0
- package/dist/utils/regexp.js +42 -0
- package/dist/utils/regexp.js.map +1 -0
- package/dist/utils/text.d.ts +7 -33
- package/dist/utils/text.d.ts.map +1 -1
- package/dist/utils/text.js +21 -52
- package/dist/utils/text.js.map +1 -1
- package/dist/utils/time-series-data.d.ts.map +1 -1
- package/dist/utils/time-series-data.js.map +1 -1
- package/dist/utils/transform-data.d.ts +8 -0
- package/dist/utils/transform-data.d.ts.map +1 -0
- package/dist/utils/transform-data.js +221 -0
- package/dist/utils/transform-data.js.map +1 -0
- package/dist/utils/value-mapping.d.ts +3 -0
- package/dist/utils/value-mapping.d.ts.map +1 -0
- package/dist/utils/value-mapping.js +97 -0
- package/dist/utils/value-mapping.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/is-empty-object.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/**\n * Determines if an object is an empty object\n */\nexport function isEmptyObject(obj: object) {\n return Object.getOwnPropertyNames(obj).length === 0;\n}\n"],"names":["isEmptyObject","obj","Object","getOwnPropertyNames","length"],"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;;CAEC,GACD,OAAO,SAASA,cAAcC,GAAW;IACvC,OAAOC,OAAOC,mBAAmB,CAACF,KAAKG,MAAM,KAAK;AACpD"}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/is-empty-object.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/**\n * Determines if an object is an empty object\n */\nexport function isEmptyObject(obj: object): boolean {\n return Object.getOwnPropertyNames(obj).length === 0;\n}\n"],"names":["isEmptyObject","obj","Object","getOwnPropertyNames","length"],"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;;CAEC,GACD,OAAO,SAASA,cAAcC,GAAW;IACvC,OAAOC,OAAOC,mBAAmB,CAACF,KAAKG,MAAM,KAAK;AACpD"}
|
package/dist/utils/memo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memo.d.ts","sourceRoot":"","sources":["../../src/utils/memo.ts"],"names":[],"mappings":"AAaA,OAAO,EAAU,cAAc,EAAE,MAAM,OAAO,CAAC;AAQ/C;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"memo.d.ts","sourceRoot":"","sources":["../../src/utils/memo.ts"],"names":[],"mappings":"AAaA,OAAO,EAAU,cAAc,EAAE,MAAM,OAAO,CAAC;AAQ/C;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,cAAc,GAAG,CAAC,CAgBxE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,cAAc,GAAG,CAAC,CAMxE"}
|
package/dist/utils/memo.js
CHANGED
|
@@ -20,8 +20,7 @@ import isEqual from 'lodash/isEqual';
|
|
|
20
20
|
const ref = useRef();
|
|
21
21
|
let areEqual = true;
|
|
22
22
|
for(let i = 0; i < deps.length; i++){
|
|
23
|
-
|
|
24
|
-
if (((_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.deps[i]) !== deps[i]) {
|
|
23
|
+
if (ref.current?.deps[i] !== deps[i]) {
|
|
25
24
|
areEqual = false;
|
|
26
25
|
break;
|
|
27
26
|
}
|
package/dist/utils/memo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/memo.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 { useRef, DependencyList } from 'react';\nimport isEqual from 'lodash/isEqual';\n\ntype MemoRef<T> = {\n value: T;\n deps: DependencyList;\n};\n\n/**\n * Like React's useMemo, but guarantees the value will only be recalulated if\n * a dependency changes. Uses strict equality (===) for comparison. (React's\n * useMemo does not offer this guarantee, it's only a performance optimization).\n */\nexport function useMemoized<T>(factory: () => T, deps: DependencyList) {\n const ref = useRef<MemoRef<T>>();\n\n let areEqual = true;\n for (let i = 0; i < deps.length; i++) {\n if (ref.current?.deps[i] !== deps[i]) {\n areEqual = false;\n break;\n }\n }\n\n if (ref.current === undefined || areEqual === false) {\n ref.current = { value: factory(), deps: deps };\n }\n\n return ref.current.value;\n}\n\n/**\n * Like React's useMemo, except it does a deep equality comparison with lodash's\n * isEqual on the dependency list.\n */\nexport function useDeepMemo<T>(factory: () => T, deps: DependencyList): T {\n const ref = useRef<MemoRef<T>>();\n if (ref.current === undefined || isEqual(deps, ref.current.deps) === false) {\n ref.current = { value: factory(), deps };\n }\n return ref.current.value;\n}\n"],"names":["useRef","isEqual","useMemoized","factory","deps","ref","areEqual","i","length","current","undefined","value","useDeepMemo"],"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,MAAM,QAAwB,QAAQ;AAC/C,OAAOC,aAAa,iBAAiB;AAOrC;;;;CAIC,GACD,OAAO,SAASC,YAAeC,OAAgB,EAAEC,IAAoB;IACnE,MAAMC,MAAML;IAEZ,IAAIM,WAAW;IACf,IAAK,IAAIC,IAAI,GAAGA,IAAIH,KAAKI,MAAM,EAAED,IAAK;
|
|
1
|
+
{"version":3,"sources":["../../src/utils/memo.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 { useRef, DependencyList } from 'react';\nimport isEqual from 'lodash/isEqual';\n\ntype MemoRef<T> = {\n value: T;\n deps: DependencyList;\n};\n\n/**\n * Like React's useMemo, but guarantees the value will only be recalulated if\n * a dependency changes. Uses strict equality (===) for comparison. (React's\n * useMemo does not offer this guarantee, it's only a performance optimization).\n */\nexport function useMemoized<T>(factory: () => T, deps: DependencyList): T {\n const ref = useRef<MemoRef<T>>();\n\n let areEqual = true;\n for (let i = 0; i < deps.length; i++) {\n if (ref.current?.deps[i] !== deps[i]) {\n areEqual = false;\n break;\n }\n }\n\n if (ref.current === undefined || areEqual === false) {\n ref.current = { value: factory(), deps: deps };\n }\n\n return ref.current.value;\n}\n\n/**\n * Like React's useMemo, except it does a deep equality comparison with lodash's\n * isEqual on the dependency list.\n */\nexport function useDeepMemo<T>(factory: () => T, deps: DependencyList): T {\n const ref = useRef<MemoRef<T>>();\n if (ref.current === undefined || isEqual(deps, ref.current.deps) === false) {\n ref.current = { value: factory(), deps };\n }\n return ref.current.value;\n}\n"],"names":["useRef","isEqual","useMemoized","factory","deps","ref","areEqual","i","length","current","undefined","value","useDeepMemo"],"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,MAAM,QAAwB,QAAQ;AAC/C,OAAOC,aAAa,iBAAiB;AAOrC;;;;CAIC,GACD,OAAO,SAASC,YAAeC,OAAgB,EAAEC,IAAoB;IACnE,MAAMC,MAAML;IAEZ,IAAIM,WAAW;IACf,IAAK,IAAIC,IAAI,GAAGA,IAAIH,KAAKI,MAAM,EAAED,IAAK;QACpC,IAAIF,IAAII,OAAO,EAAEL,IAAI,CAACG,EAAE,KAAKH,IAAI,CAACG,EAAE,EAAE;YACpCD,WAAW;YACX;QACF;IACF;IAEA,IAAID,IAAII,OAAO,KAAKC,aAAaJ,aAAa,OAAO;QACnDD,IAAII,OAAO,GAAG;YAAEE,OAAOR;YAAWC,MAAMA;QAAK;IAC/C;IAEA,OAAOC,IAAII,OAAO,CAACE,KAAK;AAC1B;AAEA;;;CAGC,GACD,OAAO,SAASC,YAAeT,OAAgB,EAAEC,IAAoB;IACnE,MAAMC,MAAML;IACZ,IAAIK,IAAII,OAAO,KAAKC,aAAaT,QAAQG,MAAMC,IAAII,OAAO,CAACL,IAAI,MAAM,OAAO;QAC1EC,IAAII,OAAO,GAAG;YAAEE,OAAOR;YAAWC;QAAK;IACzC;IACA,OAAOC,IAAII,OAAO,CAACE,KAAK;AAC1B"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { DashboardSpec, PanelRef } from '../model';
|
|
1
|
+
import { DashboardSpec, PanelDefinition, PanelRef } from '../model';
|
|
2
2
|
/**
|
|
3
3
|
* Resolve a PanelRef (JSON reference) against the provided DashboardSpec to
|
|
4
4
|
* a PanelDefinition.
|
|
5
5
|
*/
|
|
6
|
-
export declare function resolvePanelRef(spec: DashboardSpec, panelRef: PanelRef):
|
|
6
|
+
export declare function resolvePanelRef(spec: DashboardSpec, panelRef: PanelRef): PanelDefinition;
|
|
7
7
|
/**
|
|
8
8
|
* Gets the unique key for a panel from a PanelRef.
|
|
9
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panel-refs.d.ts","sourceRoot":"","sources":["../../src/utils/panel-refs.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"panel-refs.d.ts","sourceRoot":"","sources":["../../src/utils/panel-refs.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpE;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,GAAG,eAAe,CAOxF;AAMD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAE7D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAEzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/panel-refs.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 { DashboardSpec, PanelRef } from '../model';\n\n/**\n * Resolve a PanelRef (JSON reference) against the provided DashboardSpec to\n * a PanelDefinition.\n */\nexport function resolvePanelRef(spec: DashboardSpec, panelRef: PanelRef) {\n const panelsKey = getPanelKeyFromRef(panelRef);\n const panelDefinition = spec.panels[panelsKey];\n if (panelDefinition === undefined) {\n throw new Error(`Could not resolve panels reference ${panelRef.$ref}`);\n }\n return panelDefinition;\n}\n\n// Currently, panel refs are prefixed with `#/spec/panels/`. If that format changes, we'll definitely need to update\n// the code in here relying on it being that format.\nconst REF_PREFIX_LENGTH = 14;\n\n/**\n * Gets the unique key for a panel from a PanelRef.\n */\nexport function getPanelKeyFromRef(panelRef: PanelRef) {\n return panelRef.$ref.substring(REF_PREFIX_LENGTH);\n}\n\n/**\n * Creates a PanelRef for a panel with the given key.\n */\nexport function createPanelRef(panelKey: string): PanelRef {\n return { $ref: `#/spec/panels/${panelKey}` };\n}\n"],"names":["resolvePanelRef","spec","panelRef","panelsKey","getPanelKeyFromRef","panelDefinition","panels","undefined","Error","$ref","REF_PREFIX_LENGTH","substring","createPanelRef","panelKey"],"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;;;CAGC,GACD,OAAO,SAASA,gBAAgBC,IAAmB,EAAEC,QAAkB;IACrE,MAAMC,YAAYC,mBAAmBF;IACrC,MAAMG,kBAAkBJ,KAAKK,MAAM,CAACH,UAAU;IAC9C,IAAIE,oBAAoBE,WAAW;QACjC,MAAM,IAAIC,MAAM,CAAC,mCAAmC,EAAEN,SAASO,IAAI,CAAC,CAAC;IACvE;IACA,OAAOJ;AACT;AAEA,oHAAoH;AACpH,oDAAoD;AACpD,MAAMK,oBAAoB;AAE1B;;CAEC,GACD,OAAO,SAASN,mBAAmBF,QAAkB;IACnD,OAAOA,SAASO,IAAI,CAACE,SAAS,CAACD;AACjC;AAEA;;CAEC,GACD,OAAO,SAASE,eAAeC,QAAgB;IAC7C,OAAO;QAAEJ,MAAM,CAAC,cAAc,EAAEI,SAAS,CAAC;IAAC;AAC7C"}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/panel-refs.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 { DashboardSpec, PanelDefinition, PanelRef } from '../model';\n\n/**\n * Resolve a PanelRef (JSON reference) against the provided DashboardSpec to\n * a PanelDefinition.\n */\nexport function resolvePanelRef(spec: DashboardSpec, panelRef: PanelRef): PanelDefinition {\n const panelsKey = getPanelKeyFromRef(panelRef);\n const panelDefinition = spec.panels[panelsKey];\n if (panelDefinition === undefined) {\n throw new Error(`Could not resolve panels reference ${panelRef.$ref}`);\n }\n return panelDefinition;\n}\n\n// Currently, panel refs are prefixed with `#/spec/panels/`. If that format changes, we'll definitely need to update\n// the code in here relying on it being that format.\nconst REF_PREFIX_LENGTH = 14;\n\n/**\n * Gets the unique key for a panel from a PanelRef.\n */\nexport function getPanelKeyFromRef(panelRef: PanelRef): string {\n return panelRef.$ref.substring(REF_PREFIX_LENGTH);\n}\n\n/**\n * Creates a PanelRef for a panel with the given key.\n */\nexport function createPanelRef(panelKey: string): PanelRef {\n return { $ref: `#/spec/panels/${panelKey}` };\n}\n"],"names":["resolvePanelRef","spec","panelRef","panelsKey","getPanelKeyFromRef","panelDefinition","panels","undefined","Error","$ref","REF_PREFIX_LENGTH","substring","createPanelRef","panelKey"],"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;;;CAGC,GACD,OAAO,SAASA,gBAAgBC,IAAmB,EAAEC,QAAkB;IACrE,MAAMC,YAAYC,mBAAmBF;IACrC,MAAMG,kBAAkBJ,KAAKK,MAAM,CAACH,UAAU;IAC9C,IAAIE,oBAAoBE,WAAW;QACjC,MAAM,IAAIC,MAAM,CAAC,mCAAmC,EAAEN,SAASO,IAAI,CAAC,CAAC;IACvE;IACA,OAAOJ;AACT;AAEA,oHAAoH;AACpH,oDAAoD;AACpD,MAAMK,oBAAoB;AAE1B;;CAEC,GACD,OAAO,SAASN,mBAAmBF,QAAkB;IACnD,OAAOA,SAASO,IAAI,CAACE,SAAS,CAACD;AACjC;AAEA;;CAEC,GACD,OAAO,SAASE,eAAeC,QAAgB;IAC7C,OAAO;QAAEJ,MAAM,CAAC,cAAc,EAAEI,SAAS,CAAC;IAAC;AAC7C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a string is a regex pattern.
|
|
3
|
+
*/
|
|
4
|
+
export declare function isRegexPattern(input: string | null | undefined): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Converts a string to RegExp. Handles both regular strings and regex patterns.
|
|
7
|
+
* For regular strings, creates exact match regex.
|
|
8
|
+
* For patterns like "/pattern/flags", creates corresponding RegExp.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createRegexFromString(input: string): RegExp;
|
|
11
|
+
//# sourceMappingURL=regexp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regexp.d.ts","sourceRoot":"","sources":["../../src/utils/regexp.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAExE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAuB3D"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Copyright 2024 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
|
+
/**
|
|
14
|
+
* Checks if a string is a regex pattern.
|
|
15
|
+
*/ export function isRegexPattern(input) {
|
|
16
|
+
return Boolean(input?.startsWith('/'));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Converts a string to RegExp. Handles both regular strings and regex patterns.
|
|
20
|
+
* For regular strings, creates exact match regex.
|
|
21
|
+
* For patterns like "/pattern/flags", creates corresponding RegExp.
|
|
22
|
+
*/ export function createRegexFromString(input) {
|
|
23
|
+
if (!input) {
|
|
24
|
+
throw new Error('Input string cannot be empty');
|
|
25
|
+
}
|
|
26
|
+
if (!isRegexPattern(input)) {
|
|
27
|
+
return new RegExp(`^${input}$`);
|
|
28
|
+
}
|
|
29
|
+
const regexPattern = /^\/(.+)\/([gimy]*)$/;
|
|
30
|
+
const matches = input.match(regexPattern);
|
|
31
|
+
if (!matches) {
|
|
32
|
+
throw new Error(`Invalid regular expression format: ${input}`);
|
|
33
|
+
}
|
|
34
|
+
const [, pattern = '', flags = ''] = matches;
|
|
35
|
+
try {
|
|
36
|
+
return new RegExp(pattern, flags);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
throw new Error(`Failed to create RegExp ${error}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=regexp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/regexp.ts"],"sourcesContent":["// Copyright 2024 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/**\n * Checks if a string is a regex pattern.\n */\nexport function isRegexPattern(input: string | null | undefined): boolean {\n return Boolean(input?.startsWith('/'));\n}\n\n/**\n * Converts a string to RegExp. Handles both regular strings and regex patterns.\n * For regular strings, creates exact match regex.\n * For patterns like \"/pattern/flags\", creates corresponding RegExp.\n */\nexport function createRegexFromString(input: string): RegExp {\n if (!input) {\n throw new Error('Input string cannot be empty');\n }\n\n if (!isRegexPattern(input)) {\n return new RegExp(`^${input}$`);\n }\n\n const regexPattern = /^\\/(.+)\\/([gimy]*)$/;\n const matches = input.match(regexPattern);\n\n if (!matches) {\n throw new Error(`Invalid regular expression format: ${input}`);\n }\n\n const [, pattern = '', flags = ''] = matches;\n\n try {\n return new RegExp(pattern, flags);\n } catch (error) {\n throw new Error(`Failed to create RegExp ${error}`);\n }\n}\n"],"names":["isRegexPattern","input","Boolean","startsWith","createRegexFromString","Error","RegExp","regexPattern","matches","match","pattern","flags","error"],"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;;CAEC,GACD,OAAO,SAASA,eAAeC,KAAgC;IAC7D,OAAOC,QAAQD,OAAOE,WAAW;AACnC;AAEA;;;;CAIC,GACD,OAAO,SAASC,sBAAsBH,KAAa;IACjD,IAAI,CAACA,OAAO;QACV,MAAM,IAAII,MAAM;IAClB;IAEA,IAAI,CAACL,eAAeC,QAAQ;QAC1B,OAAO,IAAIK,OAAO,CAAC,CAAC,EAAEL,MAAM,CAAC,CAAC;IAChC;IAEA,MAAMM,eAAe;IACrB,MAAMC,UAAUP,MAAMQ,KAAK,CAACF;IAE5B,IAAI,CAACC,SAAS;QACZ,MAAM,IAAIH,MAAM,CAAC,mCAAmC,EAAEJ,MAAM,CAAC;IAC/D;IAEA,MAAM,GAAGS,UAAU,EAAE,EAAEC,QAAQ,EAAE,CAAC,GAAGH;IAErC,IAAI;QACF,OAAO,IAAIF,OAAOI,SAASC;IAC7B,EAAE,OAAOC,OAAO;QACd,MAAM,IAAIP,MAAM,CAAC,wBAAwB,EAAEO,MAAM,CAAC;IACpD;AACF"}
|
package/dist/utils/text.d.ts
CHANGED
|
@@ -1,38 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Resource } from '../model';
|
|
2
2
|
/**
|
|
3
|
-
* If the
|
|
4
|
-
* Else, only return the
|
|
5
|
-
* @param dashboard
|
|
3
|
+
* If the resource has a display name, return the variable display name
|
|
4
|
+
* Else, only return the resource metdata name
|
|
6
5
|
*/
|
|
7
|
-
export declare function
|
|
6
|
+
export declare function getResourceDisplayName<T extends Resource>(resource: T): string;
|
|
8
7
|
/**
|
|
9
|
-
* If the
|
|
10
|
-
* Else, only return the
|
|
11
|
-
* @param variable Project or Global variable
|
|
8
|
+
* If the resource has a display name, return the resource display name with the resource name too
|
|
9
|
+
* Else, only return the resource name
|
|
12
10
|
*/
|
|
13
|
-
export declare function
|
|
14
|
-
/**
|
|
15
|
-
* If the variable has a display name, return the datasource display name
|
|
16
|
-
* Else, only return the datasource name
|
|
17
|
-
* @param datasource Project or Global datasource
|
|
18
|
-
*/
|
|
19
|
-
export declare function getDatasourceDisplayName(datasource: Datasource): string;
|
|
20
|
-
/**
|
|
21
|
-
* If the dashboard has a display name, return the dashboard display name and the dashboard name
|
|
22
|
-
* Else, only return the dashboard name
|
|
23
|
-
* @param dashboard
|
|
24
|
-
*/
|
|
25
|
-
export declare function getDashboardExtendedDisplayName(dashboard: DashboardResource | EphemeralDashboardResource): string;
|
|
26
|
-
/**
|
|
27
|
-
* If the variable has a display name, return the variable display name and the variable name
|
|
28
|
-
* Else, only return the variable name
|
|
29
|
-
* @param variable Project or Global variable
|
|
30
|
-
*/
|
|
31
|
-
export declare function getVariableExtendedDisplayName(variable: Variable): string;
|
|
32
|
-
/**
|
|
33
|
-
* If the datasource has a display name, return the datasource display name and the datasource name
|
|
34
|
-
* Else, only return the datasource name
|
|
35
|
-
* @param datasource Project or Global datasource
|
|
36
|
-
*/
|
|
37
|
-
export declare function getDatasourceExtendedDisplayName(datasource: Datasource): string;
|
|
11
|
+
export declare function getResourceExtendedDisplayName<T extends Resource>(resource: T): string;
|
|
38
12
|
//# sourceMappingURL=text.d.ts.map
|
package/dist/utils/text.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/utils/text.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/utils/text.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,QAAQ,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,CAY9E;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,SAAS,QAAQ,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,CAYtF"}
|
package/dist/utils/text.js
CHANGED
|
@@ -11,63 +11,32 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
/**
|
|
14
|
-
* If the
|
|
15
|
-
* Else, only return the
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* If the variable has a display name, return the variable display name
|
|
24
|
-
* Else, only return the variable name
|
|
25
|
-
* @param variable Project or Global variable
|
|
26
|
-
*/ export function getVariableDisplayName(variable) {
|
|
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
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* If the variable has a display name, return the datasource display name
|
|
33
|
-
* Else, only return the datasource name
|
|
34
|
-
* @param datasource Project or Global datasource
|
|
35
|
-
*/ export function getDatasourceDisplayName(datasource) {
|
|
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
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* If the dashboard has a display name, return the dashboard display name and the dashboard name
|
|
41
|
-
* Else, only return the dashboard name
|
|
42
|
-
* @param dashboard
|
|
43
|
-
*/ export function getDashboardExtendedDisplayName(dashboard) {
|
|
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
|
-
return `${dashboard.spec.display.name} (Name: ${dashboard.metadata.name})`;
|
|
14
|
+
* If the resource has a display name, return the variable display name
|
|
15
|
+
* Else, only return the resource metdata name
|
|
16
|
+
*/ export function getResourceDisplayName(resource) {
|
|
17
|
+
// Variables
|
|
18
|
+
if (resource.spec.spec?.display?.name) {
|
|
19
|
+
return resource.spec.spec.display.name;
|
|
47
20
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
* If the variable has a display name, return the variable display name and the variable name
|
|
52
|
-
* Else, only return the variable name
|
|
53
|
-
* @param variable Project or Global variable
|
|
54
|
-
*/ export function getVariableExtendedDisplayName(variable) {
|
|
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
|
-
return `${variable.spec.spec.display.name} (Name: ${variable.metadata.name})`;
|
|
21
|
+
// Other resources with display
|
|
22
|
+
if (resource.spec.display?.name) {
|
|
23
|
+
return resource.spec.display.name;
|
|
58
24
|
}
|
|
59
|
-
return
|
|
25
|
+
return resource.metadata.name;
|
|
60
26
|
}
|
|
61
27
|
/**
|
|
62
|
-
* If the
|
|
63
|
-
* Else, only return the
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
28
|
+
* If the resource has a display name, return the resource display name with the resource name too
|
|
29
|
+
* Else, only return the resource name
|
|
30
|
+
*/ export function getResourceExtendedDisplayName(resource) {
|
|
31
|
+
// Variables
|
|
32
|
+
if (resource.spec.spec?.display?.name) {
|
|
33
|
+
return `${resource.spec.spec.display.name} (ID: ${resource.metadata.name})`;
|
|
34
|
+
}
|
|
35
|
+
// Other resources with display
|
|
36
|
+
if (resource.spec.display?.name) {
|
|
37
|
+
return `${resource.spec.display.name} (ID: ${resource.metadata.name})`;
|
|
69
38
|
}
|
|
70
|
-
return
|
|
39
|
+
return resource.metadata.name;
|
|
71
40
|
}
|
|
72
41
|
|
|
73
42
|
//# sourceMappingURL=text.js.map
|
package/dist/utils/text.js.map
CHANGED
|
@@ -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 {
|
|
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 { Resource } from '../model';\n\n/**\n * If the resource has a display name, return the variable display name\n * Else, only return the resource metdata name\n */\nexport function getResourceDisplayName<T extends Resource>(resource: T): string {\n // Variables\n if (resource.spec.spec?.display?.name) {\n return resource.spec.spec.display.name;\n }\n\n // Other resources with display\n if (resource.spec.display?.name) {\n return resource.spec.display.name;\n }\n\n return resource.metadata.name;\n}\n\n/**\n * If the resource has a display name, return the resource display name with the resource name too\n * Else, only return the resource name\n */\nexport function getResourceExtendedDisplayName<T extends Resource>(resource: T): string {\n // Variables\n if (resource.spec.spec?.display?.name) {\n return `${resource.spec.spec.display.name} (ID: ${resource.metadata.name})`;\n }\n\n // Other resources with display\n if (resource.spec.display?.name) {\n return `${resource.spec.display.name} (ID: ${resource.metadata.name})`;\n }\n\n return resource.metadata.name;\n}\n"],"names":["getResourceDisplayName","resource","spec","display","name","metadata","getResourceExtendedDisplayName"],"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;;;CAGC,GACD,OAAO,SAASA,uBAA2CC,QAAW;IACpE,YAAY;IACZ,IAAIA,SAASC,IAAI,CAACA,IAAI,EAAEC,SAASC,MAAM;QACrC,OAAOH,SAASC,IAAI,CAACA,IAAI,CAACC,OAAO,CAACC,IAAI;IACxC;IAEA,+BAA+B;IAC/B,IAAIH,SAASC,IAAI,CAACC,OAAO,EAAEC,MAAM;QAC/B,OAAOH,SAASC,IAAI,CAACC,OAAO,CAACC,IAAI;IACnC;IAEA,OAAOH,SAASI,QAAQ,CAACD,IAAI;AAC/B;AAEA;;;CAGC,GACD,OAAO,SAASE,+BAAmDL,QAAW;IAC5E,YAAY;IACZ,IAAIA,SAASC,IAAI,CAACA,IAAI,EAAEC,SAASC,MAAM;QACrC,OAAO,CAAC,EAAEH,SAASC,IAAI,CAACA,IAAI,CAACC,OAAO,CAACC,IAAI,CAAC,MAAM,EAAEH,SAASI,QAAQ,CAACD,IAAI,CAAC,CAAC,CAAC;IAC7E;IAEA,+BAA+B;IAC/B,IAAIH,SAASC,IAAI,CAACC,OAAO,EAAEC,MAAM;QAC/B,OAAO,CAAC,EAAEH,SAASC,IAAI,CAACC,OAAO,CAACC,IAAI,CAAC,MAAM,EAAEH,SAASI,QAAQ,CAACD,IAAI,CAAC,CAAC,CAAC;IACxE;IAEA,OAAOH,SAASI,QAAQ,CAACD,IAAI;AAC/B"}
|
|
@@ -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,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,
|
|
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,GAAG,oBAAoB,EAAE,CAyBpG;AAED;;;;;GAKG;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 +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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AAW;oBACxB;gBACF;gBAEA,MAAM,CAACf,UAAU,GAAGO;gBACpB,MAAMW,QAAQ,IAAII,KAAKtB;gBACvB,MAAMmB,MAAM,IAAIG,KAAKtB;gBAErB,IAAIc,cAAcC,WAAW;oBAC3BD,YAAY;wBACVI;wBACAC;oBACF;oBACA;gBACF;gBAEA,IAAID,QAAQJ,UAAUI,KAAK,EAAE;oBAC3BJ,UAAUI,KAAK,GAAGA;gBACpB;gBAEA,IAAIC,MAAML,UAAUK,GAAG,EAAE;oBACvBL,UAAUK,GAAG,GAAGA;gBAClB;YACF;YAEA,IAAIL,cAAcC,WAAW,OAAOA;YAEpC,MAAMd,UAAUa,UAAUI,KAAK,CAACK,OAAO;YACvC,MAAMrB,QAAQY,UAAUK,GAAG,CAACI,OAAO;YACnC,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,MAAM,KAAK,GAAG;QACtBjB,SAASY,KAAK,CAAC,EAAE;IACnB,OAAO;QACL,MAAMS,mBAAmB9B,OAAOqB;QAChCZ,SAASqB,mBAAmB7B,uBAAuBA,uBAAuB6B;IAC5E;IAEA,MAAMxB,UAAUa,UAAUI,KAAK,CAACK,OAAO;IACvC,MAAMrB,QAAQY,UAAUK,GAAG,CAACI,OAAO;IACnC,MAAMC,UAAUtB,QAAQD;IAExB,OAAO;QAAEA;QAASC;QAAOE;QAAQoB;IAAQ;AAC3C"}
|
|
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): TimeSeriesValueTuple[] {\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,OAAO;IACjC,MAAOD,aAAaF,UAAUI,KAAK,CAAE;QACnCH,QAAQI,IAAI,CAACH;QACbA,aAAaF,UAAUM,MAAM;IAC/B;IACA,OAAOL;AACT;AAEA;;;;CAIC,GACD,OAAO,SAASM,oBAAoBC,MAAkB,EAAER,SAAoB;IAC1E,IAAIE,YAAYF,UAAUG,OAAO;IAEjC,MAAMM,SAASD,OAAOC,MAAM;IAC5B,MAAMC,kBAA0C,EAAE;IAElD,KAAK,MAAMC,cAAcF,OAAQ;QAC/B,qEAAqE;QACrE,MAAOP,YAAYS,UAAU,CAAC,EAAE,CAAE;YAChCD,gBAAgBL,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MAAMS,mBAAmB9B,OAAOqB;QAChCZ,SAASqB,mBAAmB7B,uBAAuBA,uBAAuB6B;IAC5E;IAEA,MAAMxB,UAAUa,UAAUI,KAAK,CAACK,OAAO;IACvC,MAAMrB,QAAQY,UAAUK,GAAG,CAACI,OAAO;IACnC,MAAMC,UAAUtB,QAAQD;IAExB,OAAO;QAAEA;QAASC;QAAOE;QAAQoB;IAAQ;AAC3C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Transform } from '@perses-dev/core';
|
|
2
|
+
export declare function applyJoinTransform(data: Array<Record<string, unknown>>, columns: string[]): Array<Record<string, unknown>>;
|
|
3
|
+
export declare function applyMergeColumnsTransform(data: Array<Record<string, unknown>>, selectedColumns: string[], outputName: string): Array<Record<string, unknown>>;
|
|
4
|
+
export declare function applyMergeIndexedColumnsTransform(data: Array<Record<string, unknown>>, column: string): Array<Record<string, unknown>>;
|
|
5
|
+
export declare function applyMergeSeriesTransform(data: Array<Record<string, unknown>>): Array<Record<string, unknown>>;
|
|
6
|
+
export declare function transformData(data: Array<Record<string, unknown>>, transforms: Transform[]): Array<Record<string, unknown>>;
|
|
7
|
+
export declare function useTransformData(data: Array<Record<string, unknown>>, transforms: Transform[]): Array<Record<string, unknown>>;
|
|
8
|
+
//# sourceMappingURL=transform-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-data.d.ts","sourceRoot":"","sources":["../../src/utils/transform-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAsB7C,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACpC,OAAO,EAAE,MAAM,EAAE,GAChB,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAsBhC;AA0BD,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACpC,eAAe,EAAE,MAAM,EAAE,EACzB,UAAU,EAAE,MAAM,GACjB,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAuBhC;AA0BD,wBAAgB,iCAAiC,CAC/C,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACpC,MAAM,EAAE,MAAM,GACb,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAwBhC;AAmBD,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAmB9G;AAKD,wBAAgB,aAAa,CAC3B,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACpC,UAAU,EAAE,SAAS,EAAE,GACtB,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA2ChC;AAED,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACpC,UAAU,EAAE,SAAS,EAAE,GACtB,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAEhC"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// Copyright 2024 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 { useMemo } from 'react';
|
|
14
|
+
/*
|
|
15
|
+
* Join: Regroup rows with equal cell value in a column.
|
|
16
|
+
* If there are multiple line with same value, next row values override the current one
|
|
17
|
+
*
|
|
18
|
+
* Example: Join on 'mount' column
|
|
19
|
+
* INPUT:
|
|
20
|
+
* | timestamp | value #1 | value #3 | mount |
|
|
21
|
+
* |------------|----------|----------|-----------|
|
|
22
|
+
* | 1630000000 | 1 | | / |
|
|
23
|
+
* | 1630000000 | 2 | | /boot/efi |
|
|
24
|
+
* | 1630000000 | | 3 | / |
|
|
25
|
+
* | 1630000000 | | 4 | /boot/efi |
|
|
26
|
+
*
|
|
27
|
+
* OUTPUT:
|
|
28
|
+
* | timestamp | value #1 | value #3 | mount |
|
|
29
|
+
* |------------|----------|----------|-----------|
|
|
30
|
+
* | 1630000000 | 1 | 3 | / |
|
|
31
|
+
* | 1630000000 | 2 | 4 | /boot/efi |
|
|
32
|
+
*/ export function applyJoinTransform(data, columns) {
|
|
33
|
+
// If column is undefined or empty, return data as is
|
|
34
|
+
if (columns.length === 0) {
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
const rowHashed = {};
|
|
38
|
+
for (const row of data){
|
|
39
|
+
const rowHash = Object.keys(row).filter((k)=>columns.includes(k)).map((k)=>row[k]).join('|');
|
|
40
|
+
const rowHashedValue = rowHashed[rowHash];
|
|
41
|
+
if (rowHashedValue) {
|
|
42
|
+
rowHashed[rowHash] = {
|
|
43
|
+
...rowHashedValue,
|
|
44
|
+
...row
|
|
45
|
+
};
|
|
46
|
+
} else {
|
|
47
|
+
rowHashed[rowHash] = {
|
|
48
|
+
...row
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return Object.values(rowHashed);
|
|
53
|
+
}
|
|
54
|
+
/*
|
|
55
|
+
* Merges selected columns into a single column.
|
|
56
|
+
*
|
|
57
|
+
* Example: Merge columns 'value #1' and 'value #2' into a single column 'MERGED'
|
|
58
|
+
* INPUT:
|
|
59
|
+
* +------------+----------+----------+-----------+-----------+
|
|
60
|
+
* | timestamp | value #1 | value #2 | mount #1 | mount #2 |
|
|
61
|
+
* +------------+----------+----------+-----------+-----------+
|
|
62
|
+
* | 1630000000 | 1 | | / | |
|
|
63
|
+
* | 1630000000 | 2 | | /boot/efi | |
|
|
64
|
+
* | 1630000000 | | 3 | | / |
|
|
65
|
+
* | 1630000000 | | 4 | | /boot/efi |
|
|
66
|
+
* +------------+----------+----------+-----------+-----------+
|
|
67
|
+
*
|
|
68
|
+
* OUTPUT:
|
|
69
|
+
* +------------+--------+-----------+-----------+
|
|
70
|
+
* | timestamp | MERGED | mount #1 | mount #2 |
|
|
71
|
+
* +------------+--------+-----------+-----------+
|
|
72
|
+
* | 1630000000 | 1 | / | |
|
|
73
|
+
* | 1630000000 | 2 | /boot/efi | |
|
|
74
|
+
* | 1630000000 | 2 | | / |
|
|
75
|
+
* | 1630000000 | 3 | | /boot/efi |
|
|
76
|
+
* +------------+--------+-----------+-----------+
|
|
77
|
+
*/ export function applyMergeColumnsTransform(data, selectedColumns, outputName) {
|
|
78
|
+
const result = [];
|
|
79
|
+
for (const row of data){
|
|
80
|
+
const columns = Object.keys(row).filter((k)=>selectedColumns.includes(k));
|
|
81
|
+
const selectedColumnValues = {};
|
|
82
|
+
for (const column of columns){
|
|
83
|
+
selectedColumnValues[column] = row[column];
|
|
84
|
+
delete row[column];
|
|
85
|
+
}
|
|
86
|
+
for (const column of columns){
|
|
87
|
+
result.push({
|
|
88
|
+
...row,
|
|
89
|
+
[outputName]: selectedColumnValues[column]
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (columns.length === 0) {
|
|
93
|
+
result.push(row);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
/*
|
|
99
|
+
* Merge Indexed Columns: All indexed columns are merged to one column
|
|
100
|
+
*
|
|
101
|
+
* Example: Join on 'value' column
|
|
102
|
+
* INPUT:
|
|
103
|
+
* | timestamp #1 | timestamp #2 | value #1 | value #2 | instance #1 | instance #2 |
|
|
104
|
+
* |--------------|--------------|----------|----------|-------------|-------------|
|
|
105
|
+
* | 1630000000 | | 55 | | toto | |
|
|
106
|
+
* | 1630000000 | | 33 | | toto | |
|
|
107
|
+
* | 1630000000 | | 45 | | toto | |
|
|
108
|
+
* | | 1630000000 | | 112 | | titi |
|
|
109
|
+
* | | 1630000000 | | 20 | | titi |
|
|
110
|
+
* | | 1630000000 | | 10 | | titi |
|
|
111
|
+
*
|
|
112
|
+
* OUTPUT:
|
|
113
|
+
* | timestamp #1 | timestamp #2 | value | instance #1 | instance #2 |
|
|
114
|
+
* |--------------|--------------|-------|-------------|-------------|
|
|
115
|
+
* | 1630000000 | | 55 | toto | |
|
|
116
|
+
* | 1630000000 | | 33 | toto | |
|
|
117
|
+
* | 1630000000 | | 45 | toto | |
|
|
118
|
+
* | | 1630000000 | 112 | | titi |
|
|
119
|
+
* | | 1630000000 | 20 | | titi |
|
|
120
|
+
* | | 1630000000 | 10 | | titi |
|
|
121
|
+
*/ export function applyMergeIndexedColumnsTransform(data, column) {
|
|
122
|
+
const result = [];
|
|
123
|
+
for (const entry of data){
|
|
124
|
+
const indexedColumns = Object.keys(entry).filter((k)=>new RegExp('^(' + column + ' #\\d+)|(' + column + ')$').test(k));
|
|
125
|
+
const indexedColumnValues = {};
|
|
126
|
+
for (const indexedColumn of indexedColumns){
|
|
127
|
+
indexedColumnValues[indexedColumn] = entry[indexedColumn];
|
|
128
|
+
delete entry[indexedColumn];
|
|
129
|
+
}
|
|
130
|
+
for (const indexedColumn of indexedColumns){
|
|
131
|
+
result.push({
|
|
132
|
+
...entry,
|
|
133
|
+
[column]: indexedColumnValues[indexedColumn]
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
if (indexedColumns.length === 0) {
|
|
137
|
+
result.push(entry);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
/*
|
|
143
|
+
* Merge Indexed Columns: All indexed columns are merged to one column
|
|
144
|
+
*
|
|
145
|
+
* INPUT:
|
|
146
|
+
* | timestamp | value #1 | value #2 | mount #1 | mount #2 | instance #1 | instance #2 | env #1 | env #2 |
|
|
147
|
+
* |------------|----------|----------|-----------|-----------|-------------|-------------|--------|--------|
|
|
148
|
+
* | 1630000000 | 1 | | / | | test:44 | | prd | |
|
|
149
|
+
* | 1630000000 | 2 | | /boot/efi | | test:44 | | prd | |
|
|
150
|
+
* | 1630000000 | | 5 | | / | | test:44 | | prd |
|
|
151
|
+
* | 1630000000 | | 6 | | /boot/efi | | test:44 | | prd |
|
|
152
|
+
*
|
|
153
|
+
* OUTPUT:
|
|
154
|
+
* | timestamp | value #1 | value #2 | mount | instance | env |
|
|
155
|
+
* |------------|----------|----------|-----------|----------|-----|
|
|
156
|
+
* | 1630000000 | 1 | 5 | / | test:44 | prd |
|
|
157
|
+
* | 1630000000 | 2 | 6 | /boot/efi | test:44 | prd |
|
|
158
|
+
*/ export function applyMergeSeriesTransform(data) {
|
|
159
|
+
let result = [
|
|
160
|
+
...data
|
|
161
|
+
];
|
|
162
|
+
const labelColumns = Array.from(new Set(data.flatMap(Object.keys).map((label)=>label.replace(/ #\d+/, '')).filter((label)=>label !== 'value')));
|
|
163
|
+
for (const label of labelColumns){
|
|
164
|
+
result = applyMergeIndexedColumnsTransform(result, label);
|
|
165
|
+
}
|
|
166
|
+
result = applyJoinTransform(result, labelColumns);
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
169
|
+
/*
|
|
170
|
+
* Transforms query data with the given transforms
|
|
171
|
+
*/ export function transformData(data, transforms) {
|
|
172
|
+
let result = data;
|
|
173
|
+
// Apply transforms by their orders
|
|
174
|
+
for (const transform of transforms ?? []){
|
|
175
|
+
if (transform.spec.disabled) continue;
|
|
176
|
+
switch(transform.kind){
|
|
177
|
+
case 'JoinByColumnValue':
|
|
178
|
+
{
|
|
179
|
+
if (transform.spec.columns && transform.spec.columns.length > 0) {
|
|
180
|
+
result = applyJoinTransform(result, transform.spec.columns);
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
case 'MergeIndexedColumns':
|
|
185
|
+
{
|
|
186
|
+
if (transform.spec.column) {
|
|
187
|
+
result = applyMergeIndexedColumnsTransform(result, transform.spec.column);
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
case 'MergeColumns':
|
|
192
|
+
{
|
|
193
|
+
if (transform.spec.columns && transform.spec.columns.length > 0 && transform.spec.name) {
|
|
194
|
+
result = applyMergeColumnsTransform(result, transform.spec.columns, transform.spec.name);
|
|
195
|
+
}
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
case 'MergeSeries':
|
|
199
|
+
{
|
|
200
|
+
result = applyMergeSeriesTransform(result);
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// Ordering data column alphabetically
|
|
206
|
+
result = result.map((row)=>{
|
|
207
|
+
return Object.keys(row).sort().reduce((obj, key)=>{
|
|
208
|
+
obj[key] = row[key];
|
|
209
|
+
return obj;
|
|
210
|
+
}, {});
|
|
211
|
+
});
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
export function useTransformData(data, transforms) {
|
|
215
|
+
return useMemo(()=>transformData(data, transforms), [
|
|
216
|
+
data,
|
|
217
|
+
transforms
|
|
218
|
+
]);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
//# sourceMappingURL=transform-data.js.map
|