@perses-dev/trace-table-plugin 0.6.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.
- package/LICENSE +201 -0
- package/README.md +41 -0
- package/__mf/css/async/341.3d4493d2.css +1 -0
- package/__mf/css/async/759.3d4493d2.css +1 -0
- package/__mf/font/lato-all-300-normal.322bdf14.woff +0 -0
- package/__mf/font/lato-all-400-normal.63513b00.woff +0 -0
- package/__mf/font/lato-all-700-normal.bb27db94.woff +0 -0
- package/__mf/font/lato-all-900-normal.a27049a3.woff +0 -0
- package/__mf/font/lato-latin-300-normal.c5195215.woff2 +0 -0
- package/__mf/font/lato-latin-400-normal.b7ffde23.woff2 +0 -0
- package/__mf/font/lato-latin-700-normal.d5eb20bc.woff2 +0 -0
- package/__mf/font/lato-latin-900-normal.d884a71c.woff2 +0 -0
- package/__mf/font/lato-latin-ext-300-normal.abcc64a9.woff2 +0 -0
- package/__mf/font/lato-latin-ext-400-normal.6ebed106.woff2 +0 -0
- package/__mf/font/lato-latin-ext-700-normal.8697d1d5.woff2 +0 -0
- package/__mf/font/lato-latin-ext-900-normal.20a2b415.woff2 +0 -0
- package/__mf/js/152.cad35107.js +5 -0
- package/__mf/js/TraceTable.80656031.js +5 -0
- package/__mf/js/async/129.6a1a1c7d.js +147 -0
- package/__mf/js/async/129.6a1a1c7d.js.LICENSE.txt +27 -0
- package/__mf/js/async/156.525f3a44.js +1 -0
- package/__mf/js/async/173.f0db00ba.js +2 -0
- package/__mf/js/async/173.f0db00ba.js.LICENSE.txt +19 -0
- package/__mf/js/async/377.d6e7ba1a.js +2 -0
- package/__mf/js/async/377.d6e7ba1a.js.LICENSE.txt +32 -0
- package/__mf/js/async/559.b30e0b88.js +29 -0
- package/__mf/js/async/559.b30e0b88.js.LICENSE.txt +84 -0
- package/__mf/js/async/620.006d05f8.js +2 -0
- package/__mf/js/async/620.006d05f8.js.LICENSE.txt +9 -0
- package/__mf/js/async/651.4fdbe698.js +1 -0
- package/__mf/js/async/694.3c3c415f.js +1 -0
- package/__mf/js/async/740.fe5d3770.js +1 -0
- package/__mf/js/async/75.c1d82ca8.js +1 -0
- package/__mf/js/async/770.6cac4f4b.js +1 -0
- package/__mf/js/async/835.2f07f9d8.js +80 -0
- package/__mf/js/async/835.2f07f9d8.js.LICENSE.txt +9 -0
- package/__mf/js/async/960.dc16b984.js +2 -0
- package/__mf/js/async/960.dc16b984.js.LICENSE.txt +8 -0
- package/__mf/js/async/964.01c67113.js +2 -0
- package/__mf/js/async/964.01c67113.js.LICENSE.txt +9 -0
- package/__mf/js/async/__federation_expose_TraceTable.0f16deca.js +1 -0
- package/__mf/js/main.57cf0123.js +1 -0
- package/lib/DataTable.d.ts +15 -0
- package/lib/DataTable.d.ts.map +1 -0
- package/lib/DataTable.js +240 -0
- package/lib/DataTable.js.map +1 -0
- package/lib/TraceTable.d.ts +8 -0
- package/lib/TraceTable.d.ts.map +1 -0
- package/lib/TraceTable.js +25 -0
- package/lib/TraceTable.js.map +1 -0
- package/lib/TraceTablePanel.d.ts +19 -0
- package/lib/TraceTablePanel.d.ts.map +1 -0
- package/lib/TraceTablePanel.js +55 -0
- package/lib/TraceTablePanel.js.map +1 -0
- package/lib/bootstrap.d.ts +2 -0
- package/lib/bootstrap.d.ts.map +1 -0
- package/lib/bootstrap.js +19 -0
- package/lib/bootstrap.js.map +1 -0
- package/lib/cjs/DataTable.js +253 -0
- package/lib/cjs/TraceTable.js +31 -0
- package/lib/cjs/TraceTablePanel.js +71 -0
- package/lib/cjs/bootstrap.js +26 -0
- package/lib/cjs/env.d.js +14 -0
- package/lib/cjs/getPluginModule.js +27 -0
- package/lib/cjs/index-federation.js +55 -0
- package/lib/cjs/index.js +28 -0
- package/lib/cjs/setup-tests.js +19 -0
- package/lib/cjs/test/mock-trace-data.js +130 -0
- package/lib/cjs/trace-table-model.js +28 -0
- package/lib/cjs/utils/palette.js +83 -0
- package/lib/cjs/utils/utils.js +40 -0
- package/lib/env.d.js +15 -0
- package/lib/env.d.js.map +1 -0
- package/lib/getPluginModule.d.ts +6 -0
- package/lib/getPluginModule.d.ts.map +1 -0
- package/lib/getPluginModule.js +16 -0
- package/lib/getPluginModule.js.map +1 -0
- package/lib/index-federation.d.ts +1 -0
- package/lib/index-federation.d.ts.map +1 -0
- package/lib/index-federation.js +15 -0
- package/lib/index-federation.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -0
- package/lib/setup-tests.d.ts +2 -0
- package/lib/setup-tests.d.ts.map +1 -0
- package/lib/setup-tests.js +17 -0
- package/lib/setup-tests.js.map +1 -0
- package/lib/test/mock-trace-data.d.ts +73 -0
- package/lib/test/mock-trace-data.d.ts.map +1 -0
- package/lib/test/mock-trace-data.js +114 -0
- package/lib/test/mock-trace-data.js.map +1 -0
- package/lib/trace-table-model.d.ts +17 -0
- package/lib/trace-table-model.d.ts.map +1 -0
- package/lib/trace-table-model.js +22 -0
- package/lib/trace-table-model.js.map +1 -0
- package/lib/utils/palette.d.ts +6 -0
- package/lib/utils/palette.d.ts.map +1 -0
- package/lib/utils/palette.js +64 -0
- package/lib/utils/palette.js.map +1 -0
- package/lib/utils/utils.d.ts +4 -0
- package/lib/utils/utils.d.ts.map +1 -0
- package/lib/utils/utils.js +32 -0
- package/lib/utils/utils.js.map +1 -0
- package/mf-manifest.json +235 -0
- package/mf-stats.json +271 -0
- package/package.json +56 -0
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
/**
|
|
14
|
+
* The Options object type supported by the TraceTable panel plugin.
|
|
15
|
+
*/ // Note: The interface attributes must match cue/schemas/panels/trace-table/trace-table.cue
|
|
16
|
+
"use strict";
|
|
17
|
+
Object.defineProperty(exports, "__esModule", {
|
|
18
|
+
value: true
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "createInitialTraceTableOptions", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return createInitialTraceTableOptions;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
function createInitialTraceTableOptions() {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
"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
|
+
getConsistentCategoricalColor: function() {
|
|
25
|
+
return getConsistentCategoricalColor;
|
|
26
|
+
},
|
|
27
|
+
getConsistentColor: function() {
|
|
28
|
+
return getConsistentColor;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const _colorhash = /*#__PURE__*/ _interop_require_default(require("color-hash"));
|
|
32
|
+
function _interop_require_default(obj) {
|
|
33
|
+
return obj && obj.__esModule ? obj : {
|
|
34
|
+
default: obj
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
// Valid hue values are 0 to 360 and can be adjusted to control the generated colors.
|
|
38
|
+
// More info: https://github.com/zenozeng/color-hash#custom-hue
|
|
39
|
+
// Picked min of 20 and max of 360 to exclude common threshold colors (red).
|
|
40
|
+
// Items with "error" in them will always be generated as red.
|
|
41
|
+
const ERROR_HUE_CUTOFF = 20;
|
|
42
|
+
const colorGenerator = new _colorhash.default({
|
|
43
|
+
hue: {
|
|
44
|
+
min: ERROR_HUE_CUTOFF,
|
|
45
|
+
max: 360
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const redColorGenerator = new _colorhash.default({
|
|
49
|
+
hue: {
|
|
50
|
+
min: 0,
|
|
51
|
+
max: ERROR_HUE_CUTOFF
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
function computeConsistentColor(name, error) {
|
|
55
|
+
const [hue, saturation, lightness] = error ? redColorGenerator.hsl(name) : colorGenerator.hsl(name);
|
|
56
|
+
const saturationPercent = `${(saturation * 100).toFixed(0)}%`;
|
|
57
|
+
const lightnessPercent = `${(lightness * 100).toFixed(0)}%`;
|
|
58
|
+
return `hsla(${hue.toFixed(2)},${saturationPercent},${lightnessPercent},0.9)`;
|
|
59
|
+
}
|
|
60
|
+
// To check whether a color has already been generated for a given string.
|
|
61
|
+
// TODO: Predefined color aliases will be defined here
|
|
62
|
+
const colorLookup = {};
|
|
63
|
+
function getConsistentColor(name, error) {
|
|
64
|
+
const key = `${name}_____${error}`;
|
|
65
|
+
let value = colorLookup[key];
|
|
66
|
+
if (!value) {
|
|
67
|
+
value = computeConsistentColor(name, error);
|
|
68
|
+
colorLookup[key] = value;
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
function getConsistentCategoricalColor(name, error, categoricalPalette, errorPalette) {
|
|
73
|
+
const palette = error ? errorPalette : categoricalPalette;
|
|
74
|
+
if (palette.length === 0) {
|
|
75
|
+
console.warn('getConsistentCategoricalColor() called with empty color palette, fallback to #000');
|
|
76
|
+
return '#000';
|
|
77
|
+
}
|
|
78
|
+
let hash = 0;
|
|
79
|
+
for(let i = 0; i < name.length; i++){
|
|
80
|
+
hash = name.charCodeAt(i) + ((hash << 5) - hash);
|
|
81
|
+
}
|
|
82
|
+
return palette[Math.abs(hash) % palette.length] ?? '#000';
|
|
83
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "getServiceColor", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return getServiceColor;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _palette = require("./palette");
|
|
24
|
+
function getServiceColor(muiTheme, chartsTheme, paletteMode, serviceName, error = false) {
|
|
25
|
+
switch(paletteMode){
|
|
26
|
+
case 'categorical':
|
|
27
|
+
{
|
|
28
|
+
// ECharts type for color is not always an array but it is always an array in ChartsProvider
|
|
29
|
+
const categoricalPalette = chartsTheme.echartsTheme.color;
|
|
30
|
+
const errorPalette = [
|
|
31
|
+
muiTheme.palette.error.light,
|
|
32
|
+
muiTheme.palette.error.main,
|
|
33
|
+
muiTheme.palette.error.dark
|
|
34
|
+
];
|
|
35
|
+
return (0, _palette.getConsistentCategoricalColor)(serviceName, error, categoricalPalette, errorPalette);
|
|
36
|
+
}
|
|
37
|
+
default:
|
|
38
|
+
return (0, _palette.getConsistentColor)(serviceName, error);
|
|
39
|
+
}
|
|
40
|
+
}
|
package/lib/env.d.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
/// <reference types="@rsbuild/core/types" />
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=env.d.js.map
|
package/lib/env.d.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/env.d.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/// <reference types=\"@rsbuild/core/types\" />\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,6CAA6C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPluginModule.d.ts","sourceRoot":"","sources":["../../src/getPluginModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAC;AAGnF;;GAEG;AACH,wBAAgB,eAAe,IAAI,oBAAoB,CAUtD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import packageJson from '../package.json';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the plugin module information from package.json
|
|
4
|
+
*/ export function getPluginModule() {
|
|
5
|
+
const { name, version, perses } = packageJson;
|
|
6
|
+
return {
|
|
7
|
+
kind: 'PluginModule',
|
|
8
|
+
metadata: {
|
|
9
|
+
name,
|
|
10
|
+
version
|
|
11
|
+
},
|
|
12
|
+
spec: perses
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=getPluginModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/getPluginModule.ts"],"sourcesContent":["import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system';\nimport packageJson from '../package.json';\n\n/**\n * Returns the plugin module information from package.json\n */\nexport function getPluginModule(): PluginModuleResource {\n const { name, version, perses } = packageJson;\n return {\n kind: 'PluginModule',\n metadata: {\n name,\n version,\n },\n spec: perses as PluginModuleSpec,\n };\n}\n"],"names":["packageJson","getPluginModule","name","version","perses","kind","metadata","spec"],"mappings":"AACA,OAAOA,iBAAiB,kBAAkB;AAE1C;;CAEC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGJ;IAClC,OAAO;QACLK,MAAM;QACNC,UAAU;YACRJ;YACAC;QACF;QACAI,MAAMH;IACR;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index-federation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-federation.d.ts","sourceRoot":"","sources":["../../src/index-federation.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
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('./bootstrap');
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index-federation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index-federation.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\nimport('./bootstrap');\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,MAAM,CAAC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC"}
|
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './DataTable';\nexport { getPluginModule } from './getPluginModule';\nexport * from './trace-table-model';\nexport * from './TraceTable';\nexport * from './TraceTablePanel';\n"],"names":["getPluginModule"],"mappings":"AAAA,cAAc,cAAc;AAC5B,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,sBAAsB;AACpC,cAAc,eAAe;AAC7B,cAAc,oBAAoB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 '@testing-library/jest-dom';
|
|
14
|
+
// Always mock e-charts during tests since we don't have a proper canvas in jsdom
|
|
15
|
+
jest.mock('echarts/core');
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=setup-tests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/setup-tests.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 '@testing-library/jest-dom';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\njest.mock('echarts/core');\n"],"names":["jest","mock"],"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,OAAO,4BAA4B;AAEnC,iFAAiF;AACjFA,KAAKC,IAAI,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { TraceData } from '@perses-dev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Mock data we get from getTraceData() in @perses/tempo-plugin.
|
|
4
|
+
*/
|
|
5
|
+
export declare const MOCK_TRACE_SEARCH_RESULT: TraceData;
|
|
6
|
+
export declare const MOCK_TRACE_SEARCH_RESULT_EMPTY: TraceData;
|
|
7
|
+
/**
|
|
8
|
+
* Mocks results obtained from useTraceQueries() in @perses/plugin-system/runtime.
|
|
9
|
+
* This function uses then React TanStack function useQueries(fooQuery) to
|
|
10
|
+
* handle fetching.
|
|
11
|
+
*/
|
|
12
|
+
export declare const MOCK_TRACE_SEARCH_RESULT_QUERY_RESULT: {
|
|
13
|
+
status: string;
|
|
14
|
+
fetchStatus: string;
|
|
15
|
+
isLoading: boolean;
|
|
16
|
+
isSuccess: boolean;
|
|
17
|
+
isError: boolean;
|
|
18
|
+
data: TraceData;
|
|
19
|
+
dataUpdatedAt: number;
|
|
20
|
+
definition: {
|
|
21
|
+
kind: string;
|
|
22
|
+
spec: {
|
|
23
|
+
plugin: {
|
|
24
|
+
kind: string;
|
|
25
|
+
spec: {
|
|
26
|
+
query: string;
|
|
27
|
+
datasource: {
|
|
28
|
+
kind: string;
|
|
29
|
+
name: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
error: null;
|
|
36
|
+
errorUpdatedAt: number;
|
|
37
|
+
failureCount: number;
|
|
38
|
+
errorUpdateCount: number;
|
|
39
|
+
isFetched: boolean;
|
|
40
|
+
isFetchedAfterMount: boolean;
|
|
41
|
+
isFetching: boolean;
|
|
42
|
+
isRefetching: boolean;
|
|
43
|
+
isLoadingError: boolean;
|
|
44
|
+
isPaused: boolean;
|
|
45
|
+
isPlaceholderData: boolean;
|
|
46
|
+
isPreviousData: boolean;
|
|
47
|
+
isRefetchError: boolean;
|
|
48
|
+
isStale: boolean;
|
|
49
|
+
}[];
|
|
50
|
+
export declare const MOCK_TRACE_SEARCH_RESULT_QUERY_RESULT_EMPTY: {
|
|
51
|
+
status: string;
|
|
52
|
+
fetchStatus: string;
|
|
53
|
+
isLoading: boolean;
|
|
54
|
+
isSuccess: boolean;
|
|
55
|
+
isError: boolean;
|
|
56
|
+
data: TraceData;
|
|
57
|
+
dataUpdatedAt: number;
|
|
58
|
+
error: null;
|
|
59
|
+
errorUpdatedAt: number;
|
|
60
|
+
failureCount: number;
|
|
61
|
+
errorUpdateCount: number;
|
|
62
|
+
isFetched: boolean;
|
|
63
|
+
isFetchedAfterMount: boolean;
|
|
64
|
+
isFetching: boolean;
|
|
65
|
+
isRefetching: boolean;
|
|
66
|
+
isLoadingError: boolean;
|
|
67
|
+
isPaused: boolean;
|
|
68
|
+
isPlaceholderData: boolean;
|
|
69
|
+
isPreviousData: boolean;
|
|
70
|
+
isRefetchError: boolean;
|
|
71
|
+
isStale: boolean;
|
|
72
|
+
}[];
|
|
73
|
+
//# sourceMappingURL=mock-trace-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-trace-data.d.ts","sourceRoot":"","sources":["../../../src/test/mock-trace-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,SAsBtC,CAAC;AAEF,eAAO,MAAM,8BAA8B,EAAE,SAK5C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCjD,CAAC;AAEF,eAAO,MAAM,2CAA2C;;;;;;;;;;;;;;;;;;;;;;GAwBvD,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
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
|
+
/**
|
|
14
|
+
* Mock data we get from getTraceData() in @perses/tempo-plugin.
|
|
15
|
+
*/ export const MOCK_TRACE_SEARCH_RESULT = {
|
|
16
|
+
searchResult: [
|
|
17
|
+
{
|
|
18
|
+
startTimeUnixMs: 1702915645000,
|
|
19
|
+
durationMs: 100,
|
|
20
|
+
serviceStats: {
|
|
21
|
+
'service-name': {
|
|
22
|
+
spanCount: 10
|
|
23
|
+
},
|
|
24
|
+
'second-service-name': {
|
|
25
|
+
spanCount: 3,
|
|
26
|
+
errorCount: 2
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
traceId: '123',
|
|
30
|
+
rootServiceName: 'service-name',
|
|
31
|
+
rootTraceName: 'span-name'
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
metadata: {
|
|
35
|
+
executedQueryString: '{duration > 500ms}'
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export const MOCK_TRACE_SEARCH_RESULT_EMPTY = {
|
|
39
|
+
searchResult: [],
|
|
40
|
+
metadata: {
|
|
41
|
+
executedQueryString: '{duration > 500ms}'
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Mocks results obtained from useTraceQueries() in @perses/plugin-system/runtime.
|
|
46
|
+
* This function uses then React TanStack function useQueries(fooQuery) to
|
|
47
|
+
* handle fetching.
|
|
48
|
+
*/ export const MOCK_TRACE_SEARCH_RESULT_QUERY_RESULT = [
|
|
49
|
+
{
|
|
50
|
+
status: 'success',
|
|
51
|
+
fetchStatus: 'idle',
|
|
52
|
+
isLoading: false,
|
|
53
|
+
isSuccess: true,
|
|
54
|
+
isError: false,
|
|
55
|
+
data: MOCK_TRACE_SEARCH_RESULT,
|
|
56
|
+
dataUpdatedAt: 1666500979895,
|
|
57
|
+
definition: {
|
|
58
|
+
kind: 'TraceQuery',
|
|
59
|
+
spec: {
|
|
60
|
+
plugin: {
|
|
61
|
+
kind: 'TempoTraceQuery',
|
|
62
|
+
spec: {
|
|
63
|
+
query: '{}',
|
|
64
|
+
datasource: {
|
|
65
|
+
kind: 'TempoDatasource',
|
|
66
|
+
name: 'tempolocal'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
error: null,
|
|
73
|
+
errorUpdatedAt: 0,
|
|
74
|
+
failureCount: 0,
|
|
75
|
+
errorUpdateCount: 0,
|
|
76
|
+
isFetched: true,
|
|
77
|
+
isFetchedAfterMount: true,
|
|
78
|
+
isFetching: false,
|
|
79
|
+
isRefetching: false,
|
|
80
|
+
isLoadingError: false,
|
|
81
|
+
isPaused: false,
|
|
82
|
+
isPlaceholderData: false,
|
|
83
|
+
isPreviousData: false,
|
|
84
|
+
isRefetchError: false,
|
|
85
|
+
isStale: true
|
|
86
|
+
}
|
|
87
|
+
];
|
|
88
|
+
export const MOCK_TRACE_SEARCH_RESULT_QUERY_RESULT_EMPTY = [
|
|
89
|
+
{
|
|
90
|
+
status: 'success',
|
|
91
|
+
fetchStatus: 'idle',
|
|
92
|
+
isLoading: false,
|
|
93
|
+
isSuccess: true,
|
|
94
|
+
isError: false,
|
|
95
|
+
data: MOCK_TRACE_SEARCH_RESULT_EMPTY,
|
|
96
|
+
dataUpdatedAt: 1666500979895,
|
|
97
|
+
error: null,
|
|
98
|
+
errorUpdatedAt: 0,
|
|
99
|
+
failureCount: 0,
|
|
100
|
+
errorUpdateCount: 0,
|
|
101
|
+
isFetched: true,
|
|
102
|
+
isFetchedAfterMount: true,
|
|
103
|
+
isFetching: false,
|
|
104
|
+
isRefetching: false,
|
|
105
|
+
isLoadingError: false,
|
|
106
|
+
isPaused: false,
|
|
107
|
+
isPlaceholderData: false,
|
|
108
|
+
isPreviousData: false,
|
|
109
|
+
isRefetchError: false,
|
|
110
|
+
isStale: true
|
|
111
|
+
}
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
//# sourceMappingURL=mock-trace-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/test/mock-trace-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 { TraceData } from '@perses-dev/core';\n\n/**\n * Mock data we get from getTraceData() in @perses/tempo-plugin.\n */\nexport const MOCK_TRACE_SEARCH_RESULT: TraceData = {\n searchResult: [\n {\n startTimeUnixMs: 1702915645000, // unix epoch time in milliseconds\n durationMs: 100,\n serviceStats: {\n 'service-name': {\n spanCount: 10,\n },\n 'second-service-name': {\n spanCount: 3,\n errorCount: 2,\n },\n },\n traceId: '123',\n rootServiceName: 'service-name',\n rootTraceName: 'span-name',\n },\n ],\n metadata: {\n executedQueryString: '{duration > 500ms}',\n },\n};\n\nexport const MOCK_TRACE_SEARCH_RESULT_EMPTY: TraceData = {\n searchResult: [],\n metadata: {\n executedQueryString: '{duration > 500ms}',\n },\n};\n\n/**\n * Mocks results obtained from useTraceQueries() in @perses/plugin-system/runtime.\n * This function uses then React TanStack function useQueries(fooQuery) to\n * handle fetching.\n */\nexport const MOCK_TRACE_SEARCH_RESULT_QUERY_RESULT = [\n {\n status: 'success',\n fetchStatus: 'idle',\n isLoading: false,\n isSuccess: true,\n isError: false,\n data: MOCK_TRACE_SEARCH_RESULT,\n dataUpdatedAt: 1666500979895,\n definition: {\n kind: 'TraceQuery',\n spec: {\n plugin: {\n kind: 'TempoTraceQuery',\n spec: {\n query: '{}',\n datasource: {\n kind: 'TempoDatasource',\n name: 'tempolocal',\n },\n },\n },\n },\n },\n error: null,\n errorUpdatedAt: 0,\n failureCount: 0,\n errorUpdateCount: 0,\n isFetched: true,\n isFetchedAfterMount: true,\n isFetching: false,\n isRefetching: false,\n isLoadingError: false,\n isPaused: false,\n isPlaceholderData: false,\n isPreviousData: false,\n isRefetchError: false,\n isStale: true,\n },\n];\n\nexport const MOCK_TRACE_SEARCH_RESULT_QUERY_RESULT_EMPTY = [\n {\n status: 'success',\n fetchStatus: 'idle',\n isLoading: false,\n isSuccess: true,\n isError: false,\n data: MOCK_TRACE_SEARCH_RESULT_EMPTY,\n dataUpdatedAt: 1666500979895,\n error: null,\n errorUpdatedAt: 0,\n failureCount: 0,\n errorUpdateCount: 0,\n isFetched: true,\n isFetchedAfterMount: true,\n isFetching: false,\n isRefetching: false,\n isLoadingError: false,\n isPaused: false,\n isPlaceholderData: false,\n isPreviousData: false,\n isRefetchError: false,\n isStale: true,\n },\n];\n"],"names":["MOCK_TRACE_SEARCH_RESULT","searchResult","startTimeUnixMs","durationMs","serviceStats","spanCount","errorCount","traceId","rootServiceName","rootTraceName","metadata","executedQueryString","MOCK_TRACE_SEARCH_RESULT_EMPTY","MOCK_TRACE_SEARCH_RESULT_QUERY_RESULT","status","fetchStatus","isLoading","isSuccess","isError","data","dataUpdatedAt","definition","kind","spec","plugin","query","datasource","name","error","errorUpdatedAt","failureCount","errorUpdateCount","isFetched","isFetchedAfterMount","isFetching","isRefetching","isLoadingError","isPaused","isPlaceholderData","isPreviousData","isRefetchError","isStale","MOCK_TRACE_SEARCH_RESULT_QUERY_RESULT_EMPTY"],"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;;CAEC,GACD,OAAO,MAAMA,2BAAsC;IACjDC,cAAc;QACZ;YACEC,iBAAiB;YACjBC,YAAY;YACZC,cAAc;gBACZ,gBAAgB;oBACdC,WAAW;gBACb;gBACA,uBAAuB;oBACrBA,WAAW;oBACXC,YAAY;gBACd;YACF;YACAC,SAAS;YACTC,iBAAiB;YACjBC,eAAe;QACjB;KACD;IACDC,UAAU;QACRC,qBAAqB;IACvB;AACF,EAAE;AAEF,OAAO,MAAMC,iCAA4C;IACvDX,cAAc,EAAE;IAChBS,UAAU;QACRC,qBAAqB;IACvB;AACF,EAAE;AAEF;;;;CAIC,GACD,OAAO,MAAME,wCAAwC;IACnD;QACEC,QAAQ;QACRC,aAAa;QACbC,WAAW;QACXC,WAAW;QACXC,SAAS;QACTC,MAAMnB;QACNoB,eAAe;QACfC,YAAY;YACVC,MAAM;YACNC,MAAM;gBACJC,QAAQ;oBACNF,MAAM;oBACNC,MAAM;wBACJE,OAAO;wBACPC,YAAY;4BACVJ,MAAM;4BACNK,MAAM;wBACR;oBACF;gBACF;YACF;QACF;QACAC,OAAO;QACPC,gBAAgB;QAChBC,cAAc;QACdC,kBAAkB;QAClBC,WAAW;QACXC,qBAAqB;QACrBC,YAAY;QACZC,cAAc;QACdC,gBAAgB;QAChBC,UAAU;QACVC,mBAAmB;QACnBC,gBAAgB;QAChBC,gBAAgB;QAChBC,SAAS;IACX;CACD,CAAC;AAEF,OAAO,MAAMC,8CAA8C;IACzD;QACE5B,QAAQ;QACRC,aAAa;QACbC,WAAW;QACXC,WAAW;QACXC,SAAS;QACTC,MAAMP;QACNQ,eAAe;QACfQ,OAAO;QACPC,gBAAgB;QAChBC,cAAc;QACdC,kBAAkB;QAClBC,WAAW;QACXC,qBAAqB;QACrBC,YAAY;QACZC,cAAc;QACdC,gBAAgB;QAChBC,UAAU;QACVC,mBAAmB;QACnBC,gBAAgB;QAChBC,gBAAgB;QAChBC,SAAS;IACX;CACD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Options object type supported by the TraceTable panel plugin.
|
|
3
|
+
*/
|
|
4
|
+
export interface TraceTableOptions {
|
|
5
|
+
visual?: TraceTableVisualOptions;
|
|
6
|
+
}
|
|
7
|
+
export interface TraceTableVisualOptions {
|
|
8
|
+
palette?: TraceTablePaletteOptions;
|
|
9
|
+
}
|
|
10
|
+
export interface TraceTablePaletteOptions {
|
|
11
|
+
mode: 'auto' | 'categorical';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates the initial/empty options for a TraceTable panel.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createInitialTraceTableOptions(): TraceTableOptions;
|
|
17
|
+
//# sourceMappingURL=trace-table-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace-table-model.d.ts","sourceRoot":"","sources":["../../src/trace-table-model.ts"],"names":[],"mappings":"AAaA;;GAEG;AAEH,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,uBAAuB,CAAC;CAClC;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACpC;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,GAAG,aAAa,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,iBAAiB,CAElE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
/**
|
|
14
|
+
* The Options object type supported by the TraceTable panel plugin.
|
|
15
|
+
*/ // Note: The interface attributes must match cue/schemas/panels/trace-table/trace-table.cue
|
|
16
|
+
/**
|
|
17
|
+
* Creates the initial/empty options for a TraceTable panel.
|
|
18
|
+
*/ export function createInitialTraceTableOptions() {
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=trace-table-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/trace-table-model.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 * The Options object type supported by the TraceTable panel plugin.\n */\n// Note: The interface attributes must match cue/schemas/panels/trace-table/trace-table.cue\nexport interface TraceTableOptions {\n visual?: TraceTableVisualOptions;\n}\n\nexport interface TraceTableVisualOptions {\n palette?: TraceTablePaletteOptions;\n}\n\nexport interface TraceTablePaletteOptions {\n mode: 'auto' | 'categorical';\n}\n\n/**\n * Creates the initial/empty options for a TraceTable panel.\n */\nexport function createInitialTraceTableOptions(): TraceTableOptions {\n return {};\n}\n"],"names":["createInitialTraceTableOptions"],"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,2FAA2F;AAa3F;;CAEC,GACD,OAAO,SAASA;IACd,OAAO,CAAC;AACV"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return a consistent color for (name, error) tuple
|
|
3
|
+
*/
|
|
4
|
+
export declare function getConsistentColor(name: string, error: boolean): string;
|
|
5
|
+
export declare function getConsistentCategoricalColor(name: string, error: boolean, categoricalPalette: string[], errorPalette: string[]): string;
|
|
6
|
+
//# sourceMappingURL=palette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../../src/utils/palette.ts"],"names":[],"mappings":"AAkCA;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAQvE;AAED,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,OAAO,EACd,kBAAkB,EAAE,MAAM,EAAE,EAC5B,YAAY,EAAE,MAAM,EAAE,GACrB,MAAM,CAaR"}
|
|
@@ -0,0 +1,64 @@
|
|
|
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 ColorHash from 'color-hash';
|
|
14
|
+
// Valid hue values are 0 to 360 and can be adjusted to control the generated colors.
|
|
15
|
+
// More info: https://github.com/zenozeng/color-hash#custom-hue
|
|
16
|
+
// Picked min of 20 and max of 360 to exclude common threshold colors (red).
|
|
17
|
+
// Items with "error" in them will always be generated as red.
|
|
18
|
+
const ERROR_HUE_CUTOFF = 20;
|
|
19
|
+
const colorGenerator = new ColorHash({
|
|
20
|
+
hue: {
|
|
21
|
+
min: ERROR_HUE_CUTOFF,
|
|
22
|
+
max: 360
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const redColorGenerator = new ColorHash({
|
|
26
|
+
hue: {
|
|
27
|
+
min: 0,
|
|
28
|
+
max: ERROR_HUE_CUTOFF
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
function computeConsistentColor(name, error) {
|
|
32
|
+
const [hue, saturation, lightness] = error ? redColorGenerator.hsl(name) : colorGenerator.hsl(name);
|
|
33
|
+
const saturationPercent = `${(saturation * 100).toFixed(0)}%`;
|
|
34
|
+
const lightnessPercent = `${(lightness * 100).toFixed(0)}%`;
|
|
35
|
+
return `hsla(${hue.toFixed(2)},${saturationPercent},${lightnessPercent},0.9)`;
|
|
36
|
+
}
|
|
37
|
+
// To check whether a color has already been generated for a given string.
|
|
38
|
+
// TODO: Predefined color aliases will be defined here
|
|
39
|
+
const colorLookup = {};
|
|
40
|
+
/**
|
|
41
|
+
* Return a consistent color for (name, error) tuple
|
|
42
|
+
*/ export function getConsistentColor(name, error) {
|
|
43
|
+
const key = `${name}_____${error}`;
|
|
44
|
+
let value = colorLookup[key];
|
|
45
|
+
if (!value) {
|
|
46
|
+
value = computeConsistentColor(name, error);
|
|
47
|
+
colorLookup[key] = value;
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
export function getConsistentCategoricalColor(name, error, categoricalPalette, errorPalette) {
|
|
52
|
+
const palette = error ? errorPalette : categoricalPalette;
|
|
53
|
+
if (palette.length === 0) {
|
|
54
|
+
console.warn('getConsistentCategoricalColor() called with empty color palette, fallback to #000');
|
|
55
|
+
return '#000';
|
|
56
|
+
}
|
|
57
|
+
let hash = 0;
|
|
58
|
+
for(let i = 0; i < name.length; i++){
|
|
59
|
+
hash = name.charCodeAt(i) + ((hash << 5) - hash);
|
|
60
|
+
}
|
|
61
|
+
return palette[Math.abs(hash) % palette.length] ?? '#000';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=palette.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/palette.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\nimport ColorHash from 'color-hash';\n\n// Valid hue values are 0 to 360 and can be adjusted to control the generated colors.\n// More info: https://github.com/zenozeng/color-hash#custom-hue\n// Picked min of 20 and max of 360 to exclude common threshold colors (red).\n// Items with \"error\" in them will always be generated as red.\nconst ERROR_HUE_CUTOFF = 20;\nconst colorGenerator = new ColorHash({ hue: { min: ERROR_HUE_CUTOFF, max: 360 } });\nconst redColorGenerator = new ColorHash({ hue: { min: 0, max: ERROR_HUE_CUTOFF } });\n\nfunction computeConsistentColor(name: string, error: boolean): string {\n const [hue, saturation, lightness] = error ? redColorGenerator.hsl(name) : colorGenerator.hsl(name);\n const saturationPercent = `${(saturation * 100).toFixed(0)}%`;\n const lightnessPercent = `${(lightness * 100).toFixed(0)}%`;\n return `hsla(${hue.toFixed(2)},${saturationPercent},${lightnessPercent},0.9)`;\n}\n\n// To check whether a color has already been generated for a given string.\n// TODO: Predefined color aliases will be defined here\nconst colorLookup: Record<string, string> = {};\n\n/**\n * Return a consistent color for (name, error) tuple\n */\nexport function getConsistentColor(name: string, error: boolean): string {\n const key = `${name}_____${error}`;\n let value = colorLookup[key];\n if (!value) {\n value = computeConsistentColor(name, error);\n colorLookup[key] = value;\n }\n return value;\n}\n\nexport function getConsistentCategoricalColor(\n name: string,\n error: boolean,\n categoricalPalette: string[],\n errorPalette: string[]\n): string {\n const palette = error ? errorPalette : categoricalPalette;\n if (palette.length === 0) {\n console.warn('getConsistentCategoricalColor() called with empty color palette, fallback to #000');\n return '#000';\n }\n\n let hash = 0;\n for (let i = 0; i < name.length; i++) {\n hash = name.charCodeAt(i) + ((hash << 5) - hash);\n }\n\n return palette[Math.abs(hash) % palette.length] ?? '#000';\n}\n"],"names":["ColorHash","ERROR_HUE_CUTOFF","colorGenerator","hue","min","max","redColorGenerator","computeConsistentColor","name","error","saturation","lightness","hsl","saturationPercent","toFixed","lightnessPercent","colorLookup","getConsistentColor","key","value","getConsistentCategoricalColor","categoricalPalette","errorPalette","palette","length","console","warn","hash","i","charCodeAt","Math","abs"],"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,eAAe,aAAa;AAEnC,qFAAqF;AACrF,+DAA+D;AAC/D,4EAA4E;AAC5E,8DAA8D;AAC9D,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB,IAAIF,UAAU;IAAEG,KAAK;QAAEC,KAAKH;QAAkBI,KAAK;IAAI;AAAE;AAChF,MAAMC,oBAAoB,IAAIN,UAAU;IAAEG,KAAK;QAAEC,KAAK;QAAGC,KAAKJ;IAAiB;AAAE;AAEjF,SAASM,uBAAuBC,IAAY,EAAEC,KAAc;IAC1D,MAAM,CAACN,KAAKO,YAAYC,UAAU,GAAGF,QAAQH,kBAAkBM,GAAG,CAACJ,QAAQN,eAAeU,GAAG,CAACJ;IAC9F,MAAMK,oBAAoB,GAAG,AAACH,CAAAA,aAAa,GAAE,EAAGI,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7D,MAAMC,mBAAmB,GAAG,AAACJ,CAAAA,YAAY,GAAE,EAAGG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3D,OAAO,CAAC,KAAK,EAAEX,IAAIW,OAAO,CAAC,GAAG,CAAC,EAAED,kBAAkB,CAAC,EAAEE,iBAAiB,KAAK,CAAC;AAC/E;AAEA,0EAA0E;AAC1E,sDAAsD;AACtD,MAAMC,cAAsC,CAAC;AAE7C;;CAEC,GACD,OAAO,SAASC,mBAAmBT,IAAY,EAAEC,KAAc;IAC7D,MAAMS,MAAM,GAAGV,KAAK,KAAK,EAAEC,OAAO;IAClC,IAAIU,QAAQH,WAAW,CAACE,IAAI;IAC5B,IAAI,CAACC,OAAO;QACVA,QAAQZ,uBAAuBC,MAAMC;QACrCO,WAAW,CAACE,IAAI,GAAGC;IACrB;IACA,OAAOA;AACT;AAEA,OAAO,SAASC,8BACdZ,IAAY,EACZC,KAAc,EACdY,kBAA4B,EAC5BC,YAAsB;IAEtB,MAAMC,UAAUd,QAAQa,eAAeD;IACvC,IAAIE,QAAQC,MAAM,KAAK,GAAG;QACxBC,QAAQC,IAAI,CAAC;QACb,OAAO;IACT;IAEA,IAAIC,OAAO;IACX,IAAK,IAAIC,IAAI,GAAGA,IAAIpB,KAAKgB,MAAM,EAAEI,IAAK;QACpCD,OAAOnB,KAAKqB,UAAU,CAACD,KAAM,CAAA,AAACD,CAAAA,QAAQ,CAAA,IAAKA,IAAG;IAChD;IAEA,OAAOJ,OAAO,CAACO,KAAKC,GAAG,CAACJ,QAAQJ,QAAQC,MAAM,CAAC,IAAI;AACrD"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PersesChartsTheme } from '@perses-dev/components';
|
|
2
|
+
import { Theme } from '@mui/material';
|
|
3
|
+
export declare function getServiceColor(muiTheme: Theme, chartsTheme: PersesChartsTheme, paletteMode: 'auto' | 'categorical' | undefined, serviceName: string, error?: boolean): string;
|
|
4
|
+
//# sourceMappingURL=utils.d.ts.map
|