@allurereport/web-commons 3.0.0-beta.20 → 3.0.0-beta.22
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/charts/accessors/coverageDiffTreeMapAccessor.d.ts +16 -0
- package/dist/charts/accessors/coverageDiffTreeMapAccessor.js +183 -0
- package/dist/charts/accessors/problemsDistributionHeatMap.d.ts +2 -0
- package/dist/charts/accessors/problemsDistributionHeatMap.js +65 -0
- package/dist/charts/accessors/severityTrendAccessor.d.ts +3 -0
- package/dist/charts/accessors/severityTrendAccessor.js +21 -0
- package/dist/charts/accessors/statusBySeverityBarAccessor.d.ts +3 -0
- package/dist/charts/accessors/statusBySeverityBarAccessor.js +34 -0
- package/dist/charts/accessors/statusChangeTrendBarAccessor.d.ts +4 -0
- package/dist/charts/accessors/statusChangeTrendBarAccessor.js +94 -0
- package/dist/charts/accessors/statusTrendAccessor.d.ts +3 -0
- package/dist/charts/accessors/statusTrendAccessor.js +19 -0
- package/dist/charts/accessors/statusTrendBarAccessor.d.ts +5 -0
- package/dist/charts/accessors/statusTrendBarAccessor.js +64 -0
- package/dist/charts/accessors/successRateDistributionTreeMapAccessor.d.ts +14 -0
- package/dist/charts/accessors/successRateDistributionTreeMapAccessor.js +110 -0
- package/dist/charts/accessors/utils/behavior.d.ts +5 -0
- package/dist/charts/accessors/utils/behavior.js +4 -0
- package/dist/charts/bar/generateBarChartDurationsByLayer.d.ts +2 -0
- package/dist/charts/bar/generateBarChartDurationsByLayer.js +123 -0
- package/dist/charts/bar/generateBarChartFbsuAgePyramid.d.ts +2 -0
- package/dist/charts/bar/generateBarChartFbsuAgePyramid.js +66 -0
- package/dist/charts/bar/generateStabilityRateDistribution.d.ts +2 -0
- package/dist/charts/bar/generateStabilityRateDistribution.js +42 -0
- package/dist/charts/bar.d.ts +3 -0
- package/dist/charts/bar.js +58 -0
- package/dist/charts/chart-utils.d.ts +8 -0
- package/dist/charts/chart-utils.js +22 -0
- package/dist/charts/colors.d.ts +3 -1
- package/dist/charts/colors.js +26 -0
- package/dist/charts/comingSoon.d.ts +2 -0
- package/dist/charts/comingSoon.js +7 -0
- package/dist/charts/d3pie.d.ts +7 -0
- package/dist/charts/d3pie.js +34 -0
- package/dist/charts/funnel/generateTestingPyramidChart.d.ts +2 -0
- package/dist/charts/funnel/generateTestingPyramidChart.js +53 -0
- package/dist/charts/funnel/index.d.ts +2 -0
- package/dist/charts/funnel/index.js +9 -0
- package/dist/charts/generators.d.ts +10 -0
- package/dist/charts/generators.js +75 -0
- package/dist/charts/heatMap.d.ts +3 -0
- package/dist/charts/heatMap.js +9 -0
- package/dist/charts/index.d.ts +9 -0
- package/dist/charts/index.js +9 -0
- package/dist/charts/line.d.ts +6 -0
- package/dist/charts/line.js +140 -0
- package/dist/charts/pie.d.ts +6 -0
- package/dist/charts/pie.js +10 -0
- package/dist/charts/treeMap.d.ts +6 -0
- package/dist/charts/treeMap.js +88 -0
- package/dist/charts/types.d.ts +47 -4
- package/dist/charts/utils.d.ts +18 -12
- package/dist/charts/utils.js +73 -11
- package/dist/sanitize.d.ts +1 -15
- package/dist/sanitize.js +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { ChartDataType, ChartMode, DEFAULT_CHART_HISTORY_LIMIT } from "@allurereport/charts-api";
|
|
2
|
+
import { severityTrendDataAccessor } from "./accessors/severityTrendAccessor.js";
|
|
3
|
+
import { statusTrendDataAccessor } from "./accessors/statusTrendAccessor.js";
|
|
4
|
+
import { createEmptySeries, normalizeStatistic } from "./chart-utils.js";
|
|
5
|
+
export const calculatePercentValues = (stats, executionId, itemType) => {
|
|
6
|
+
const points = {};
|
|
7
|
+
const series = createEmptySeries(itemType);
|
|
8
|
+
const values = Object.values(stats);
|
|
9
|
+
const total = values.reduce((sum, value) => sum + value, 0);
|
|
10
|
+
if (total === 0) {
|
|
11
|
+
return { points, series };
|
|
12
|
+
}
|
|
13
|
+
itemType.forEach((item) => {
|
|
14
|
+
const pointId = `${executionId}-${item}`;
|
|
15
|
+
const value = stats[item] ?? 0;
|
|
16
|
+
points[pointId] = {
|
|
17
|
+
x: executionId,
|
|
18
|
+
y: value / total,
|
|
19
|
+
};
|
|
20
|
+
series[item].push(pointId);
|
|
21
|
+
});
|
|
22
|
+
return { points, series };
|
|
23
|
+
};
|
|
24
|
+
const calculateRawValues = (stats, executionId, itemType) => {
|
|
25
|
+
const points = {};
|
|
26
|
+
const series = createEmptySeries(itemType);
|
|
27
|
+
itemType.forEach((item) => {
|
|
28
|
+
const pointId = `${executionId}-${item}`;
|
|
29
|
+
const value = stats[item] ?? 0;
|
|
30
|
+
points[pointId] = {
|
|
31
|
+
x: executionId,
|
|
32
|
+
y: value,
|
|
33
|
+
};
|
|
34
|
+
series[item].push(pointId);
|
|
35
|
+
});
|
|
36
|
+
return { points, series };
|
|
37
|
+
};
|
|
38
|
+
export const getTrendDataGeneric = (stats, reportName, executionOrder, itemType, chartOptions) => {
|
|
39
|
+
const { type, dataType, title, mode = ChartMode.Raw, metadata = {} } = chartOptions;
|
|
40
|
+
const { executionIdAccessor, executionNameAccessor } = metadata;
|
|
41
|
+
const executionId = executionIdAccessor ? executionIdAccessor(executionOrder) : `execution-${executionOrder}`;
|
|
42
|
+
const { points, series } = mode === ChartMode.Percent
|
|
43
|
+
? calculatePercentValues(stats, executionId, itemType)
|
|
44
|
+
: calculateRawValues(stats, executionId, itemType);
|
|
45
|
+
const slices = {};
|
|
46
|
+
const pointsAsArray = Object.values(points);
|
|
47
|
+
const pointsCount = pointsAsArray.length;
|
|
48
|
+
const values = pointsAsArray.map((point) => point.y);
|
|
49
|
+
const min = pointsCount ? Math.min(...values) : 0;
|
|
50
|
+
const max = pointsCount ? Math.max(...values) : 0;
|
|
51
|
+
if (pointsCount > 0) {
|
|
52
|
+
const executionName = executionNameAccessor ? executionNameAccessor(executionOrder) : reportName;
|
|
53
|
+
slices[executionId] = {
|
|
54
|
+
min,
|
|
55
|
+
max,
|
|
56
|
+
metadata: {
|
|
57
|
+
executionId,
|
|
58
|
+
executionName,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
type,
|
|
64
|
+
dataType,
|
|
65
|
+
mode,
|
|
66
|
+
title,
|
|
67
|
+
points,
|
|
68
|
+
slices,
|
|
69
|
+
series,
|
|
70
|
+
min,
|
|
71
|
+
max,
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export const mergeTrendDataGeneric = (trendData, trendDataPart, itemType) => {
|
|
75
|
+
return {
|
|
76
|
+
...trendData,
|
|
77
|
+
points: {
|
|
78
|
+
...trendData.points,
|
|
79
|
+
...trendDataPart.points,
|
|
80
|
+
},
|
|
81
|
+
slices: {
|
|
82
|
+
...trendData.slices,
|
|
83
|
+
...trendDataPart.slices,
|
|
84
|
+
},
|
|
85
|
+
series: Object.entries(trendDataPart.series).reduce((series, [group, pointIds]) => {
|
|
86
|
+
if (Array.isArray(pointIds)) {
|
|
87
|
+
return {
|
|
88
|
+
...series,
|
|
89
|
+
[group]: [...(trendData.series?.[group] || []), ...pointIds],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return series;
|
|
93
|
+
}, trendData.series || createEmptySeries(itemType)),
|
|
94
|
+
min: Math.min(trendData.min ?? Infinity, trendDataPart.min),
|
|
95
|
+
max: Math.max(trendData.max ?? -Infinity, trendDataPart.max),
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
export const generateTrendChartGeneric = (options, storeData, dataAccessor, reportName) => {
|
|
99
|
+
const { limit } = options;
|
|
100
|
+
const historyLimit = limit && limit > 0 ? Math.max(0, limit - 1) : undefined;
|
|
101
|
+
const { historyDataPoints } = storeData;
|
|
102
|
+
const currentData = dataAccessor.getCurrentData(storeData);
|
|
103
|
+
const limitedHistoryPoints = historyLimit !== undefined ? historyDataPoints.slice(-historyLimit) : historyDataPoints;
|
|
104
|
+
const firstOriginalIndex = historyLimit !== undefined ? Math.max(0, historyDataPoints.length - historyLimit) : 0;
|
|
105
|
+
const convertedHistoryPoints = limitedHistoryPoints.map((point, index) => {
|
|
106
|
+
const originalIndex = firstOriginalIndex + index;
|
|
107
|
+
return {
|
|
108
|
+
name: point.name,
|
|
109
|
+
originalIndex,
|
|
110
|
+
statistic: dataAccessor.getHistoricalData(point),
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
const allValues = dataAccessor.getAllValues();
|
|
114
|
+
const currentTrendData = getTrendDataGeneric(normalizeStatistic(currentData, allValues), reportName, historyDataPoints.length + 1, allValues, options);
|
|
115
|
+
const historicalTrendData = convertedHistoryPoints.reduce((acc, historyPoint) => {
|
|
116
|
+
const trendDataPart = getTrendDataGeneric(normalizeStatistic(historyPoint.statistic, allValues), historyPoint.name, historyPoint.originalIndex + 1, allValues, options);
|
|
117
|
+
return mergeTrendDataGeneric(acc, trendDataPart, allValues);
|
|
118
|
+
}, {
|
|
119
|
+
type: options.type,
|
|
120
|
+
dataType: options.dataType,
|
|
121
|
+
mode: options.mode,
|
|
122
|
+
title: options.title,
|
|
123
|
+
points: {},
|
|
124
|
+
slices: {},
|
|
125
|
+
series: createEmptySeries(allValues),
|
|
126
|
+
min: Infinity,
|
|
127
|
+
max: -Infinity,
|
|
128
|
+
});
|
|
129
|
+
return mergeTrendDataGeneric(historicalTrendData, currentTrendData, allValues);
|
|
130
|
+
};
|
|
131
|
+
export const generateTrendChart = (options, storeData, reportName) => {
|
|
132
|
+
const newOptions = { limit: DEFAULT_CHART_HISTORY_LIMIT, ...options };
|
|
133
|
+
const { dataType } = newOptions;
|
|
134
|
+
if (dataType === ChartDataType.Status) {
|
|
135
|
+
return generateTrendChartGeneric(newOptions, storeData, statusTrendDataAccessor, reportName);
|
|
136
|
+
}
|
|
137
|
+
else if (dataType === ChartDataType.Severity) {
|
|
138
|
+
return generateTrendChartGeneric(newOptions, storeData, severityTrendDataAccessor, reportName);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PieChartData, PieChartOptions } from "@allurereport/charts-api";
|
|
2
|
+
import type { Statistic } from "@allurereport/core-api";
|
|
3
|
+
export declare const getPieChartData: (stats: Statistic, chartOptions: PieChartOptions) => PieChartData;
|
|
4
|
+
export declare const generatePieChart: (options: PieChartOptions, stores: {
|
|
5
|
+
statistic: Statistic;
|
|
6
|
+
}) => PieChartData;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getPieChartValues } from "./d3pie.js";
|
|
2
|
+
export const getPieChartData = (stats, chartOptions) => ({
|
|
3
|
+
type: chartOptions.type,
|
|
4
|
+
title: chartOptions?.title,
|
|
5
|
+
...getPieChartValues(stats),
|
|
6
|
+
});
|
|
7
|
+
export const generatePieChart = (options, stores) => {
|
|
8
|
+
const { statistic } = stores;
|
|
9
|
+
return getPieChartData(statistic, options);
|
|
10
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AllureChartsStoreData, TreeMapChartData, TreeMapChartOptions, TreeMapDataAccessor, TreeMapNode } from "@allurereport/charts-api";
|
|
2
|
+
import type { TreeData, TreeGroup, TreeLeaf, WithChildren } from "@allurereport/core-api";
|
|
3
|
+
export declare const convertTreeDataToTreeMapNode: <T extends TreeMapNode, L, G>(treeData: TreeData<L, G>, transform: (treeDataNode: TreeLeaf<L> | TreeGroup<G>, isGroup: boolean, parentNode?: TreeGroup<G>) => T, transformRoot?: (root: WithChildren) => T) => T;
|
|
4
|
+
export declare const transformTreeMapNode: <T extends TreeMapNode>(tree: T, transform: (node: T) => T) => T;
|
|
5
|
+
export declare const generateTreeMapChartGeneric: <T extends TreeMapNode>(options: TreeMapChartOptions, storeData: AllureChartsStoreData, dataAccessor: TreeMapDataAccessor<T>) => TreeMapChartData | undefined;
|
|
6
|
+
export declare const generateTreeMapChart: (options: TreeMapChartOptions, storeData: AllureChartsStoreData) => TreeMapChartData | undefined;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { TreeMapChartType } from "@allurereport/charts-api";
|
|
2
|
+
import { coverageDiffTreeMapAccessor } from "./accessors/coverageDiffTreeMapAccessor.js";
|
|
3
|
+
import { successRateDistributionTreeMapAccessor } from "./accessors/successRateDistributionTreeMapAccessor.js";
|
|
4
|
+
export const convertTreeDataToTreeMapNode = (treeData, transform, transformRoot = () => ({
|
|
5
|
+
id: "root",
|
|
6
|
+
value: undefined,
|
|
7
|
+
})) => {
|
|
8
|
+
const { root, leavesById, groupsById } = treeData;
|
|
9
|
+
const convertNode = (nodeId, parentGroup, isGroup) => {
|
|
10
|
+
const node = isGroup ? groupsById[nodeId] : leavesById[nodeId];
|
|
11
|
+
if (!node) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const treeMapNode = transform(node, isGroup, parentGroup);
|
|
15
|
+
if (isGroup) {
|
|
16
|
+
const group = node;
|
|
17
|
+
const children = [];
|
|
18
|
+
if (group.groups) {
|
|
19
|
+
group.groups.forEach((groupId) => {
|
|
20
|
+
const childNode = convertNode(groupId, group, true);
|
|
21
|
+
if (childNode) {
|
|
22
|
+
children.push(childNode);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (group.leaves) {
|
|
27
|
+
group.leaves.forEach((leafId) => {
|
|
28
|
+
const childNode = convertNode(leafId, group, false);
|
|
29
|
+
if (childNode) {
|
|
30
|
+
children.push(childNode);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (children.length === 0) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
treeMapNode.children = children;
|
|
38
|
+
}
|
|
39
|
+
return treeMapNode;
|
|
40
|
+
};
|
|
41
|
+
const rootChildren = [];
|
|
42
|
+
if (root.groups) {
|
|
43
|
+
root.groups.forEach((groupId) => {
|
|
44
|
+
const childNode = convertNode(groupId, root, true);
|
|
45
|
+
if (childNode) {
|
|
46
|
+
rootChildren.push(childNode);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (root.leaves) {
|
|
51
|
+
root.leaves.forEach((leafId) => {
|
|
52
|
+
const childNode = convertNode(leafId, root, false);
|
|
53
|
+
if (childNode) {
|
|
54
|
+
rootChildren.push(childNode);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
children: rootChildren.length > 0 ? rootChildren : undefined,
|
|
60
|
+
...transformRoot(root),
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export const transformTreeMapNode = (tree, transform) => {
|
|
64
|
+
const transformedNode = transform(tree);
|
|
65
|
+
if (transformedNode.children) {
|
|
66
|
+
const transformedChildren = transformedNode.children.map((child) => transformTreeMapNode(child, transform));
|
|
67
|
+
return {
|
|
68
|
+
...transformedNode,
|
|
69
|
+
children: transformedChildren,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return transformedNode;
|
|
73
|
+
};
|
|
74
|
+
export const generateTreeMapChartGeneric = (options, storeData, dataAccessor) => ({
|
|
75
|
+
type: options.type,
|
|
76
|
+
dataType: options.dataType,
|
|
77
|
+
title: options.title,
|
|
78
|
+
treeMap: dataAccessor.getTreeMap(storeData),
|
|
79
|
+
});
|
|
80
|
+
export const generateTreeMapChart = (options, storeData) => {
|
|
81
|
+
const { dataType } = options;
|
|
82
|
+
if (dataType === TreeMapChartType.SuccessRateDistribution) {
|
|
83
|
+
return generateTreeMapChartGeneric(options, storeData, successRateDistributionTreeMapAccessor);
|
|
84
|
+
}
|
|
85
|
+
else if (dataType === TreeMapChartType.CoverageDiff) {
|
|
86
|
+
return generateTreeMapChartGeneric(options, storeData, coverageDiffTreeMapAccessor);
|
|
87
|
+
}
|
|
88
|
+
};
|
package/dist/charts/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BarChartType, BarGroup, BarGroupMode, BaseTrendSliceMetadata, ChartDataType, ChartId, ChartMode, ChartType, HeatMapSerie, PieSlice, TreeMapChartType, TreeMapNode, TrendPointId, TrendSlice, TrendSliceId } from "@allurereport/
|
|
1
|
+
import type { BarChartType, BarGroup, BarGroupMode, BaseTrendSliceMetadata, ChartDataType, ChartId, ChartMode, ChartType, FunnelChartType, HeatMapSerie, PieSlice, TreeMapChartType, TreeMapNode, TrendPointId, TrendSlice, TrendSliceId } from "@allurereport/charts-api";
|
|
2
2
|
export type TreeMapTooltipAccessor = <T>(node: T) => string[];
|
|
3
3
|
export interface Point {
|
|
4
4
|
x: Date | string | number;
|
|
@@ -51,7 +51,12 @@ export interface ResponseHeatMapChartData {
|
|
|
51
51
|
title?: string;
|
|
52
52
|
data: HeatMapSerie[];
|
|
53
53
|
}
|
|
54
|
-
export type ChartsResponse<SeriesType extends string = string, Metadata extends BaseTrendSliceMetadata = BaseTrendSliceMetadata> =
|
|
54
|
+
export type ChartsResponse<SeriesType extends string = string, Metadata extends BaseTrendSliceMetadata = BaseTrendSliceMetadata> = {
|
|
55
|
+
general: Record<ChartId, ResponseTrendChartData<SeriesType, Metadata> | ResponsePieChartData | ResponseBarChartData | ResponseComingSoonChartData | ResponseTreeMapChartData | ResponseHeatMapChartData>;
|
|
56
|
+
byEnv: {
|
|
57
|
+
[env: string]: Record<ChartId, ResponseTrendChartData<SeriesType, Metadata> | ResponsePieChartData | ResponseBarChartData | ResponseComingSoonChartData | ResponseTreeMapChartData | ResponseHeatMapChartData>;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
55
60
|
export interface UITrendChartData<Metadata extends BaseTrendSliceMetadata = BaseTrendSliceMetadata> {
|
|
56
61
|
type: ChartType.Trend;
|
|
57
62
|
dataType: ChartDataType;
|
|
@@ -65,6 +70,19 @@ export interface UITrendChartData<Metadata extends BaseTrendSliceMetadata = Base
|
|
|
65
70
|
export type UIPieChartData = ResponsePieChartData;
|
|
66
71
|
export interface UIBarChartData extends ResponseBarChartData {
|
|
67
72
|
colors: Record<string, string>;
|
|
73
|
+
xAxisConfig?: {
|
|
74
|
+
legend?: string;
|
|
75
|
+
enabled?: boolean;
|
|
76
|
+
format?: string;
|
|
77
|
+
};
|
|
78
|
+
yAxisConfig?: {
|
|
79
|
+
legend?: string;
|
|
80
|
+
enabled?: boolean;
|
|
81
|
+
format?: string;
|
|
82
|
+
domain?: number[];
|
|
83
|
+
};
|
|
84
|
+
layout?: "horizontal" | "vertical";
|
|
85
|
+
threshold?: number;
|
|
68
86
|
}
|
|
69
87
|
export type UIComingSoonChartData = ResponseComingSoonChartData;
|
|
70
88
|
export interface UITreeMapChartData extends ResponseTreeMapChartData {
|
|
@@ -76,7 +94,32 @@ export interface UITreeMapChartData extends ResponseTreeMapChartData {
|
|
|
76
94
|
export interface UIHeatMapChartData extends ResponseHeatMapChartData {
|
|
77
95
|
colors: (value: number, domain?: number[]) => string;
|
|
78
96
|
}
|
|
79
|
-
export
|
|
80
|
-
|
|
97
|
+
export interface UITestingPyramidChartData extends ResponseTestingPyramidChartData {
|
|
98
|
+
}
|
|
99
|
+
export interface ResponseTestingPyramidChartData {
|
|
100
|
+
type: ChartType.Funnel;
|
|
101
|
+
dataType: FunnelChartType;
|
|
102
|
+
title?: string;
|
|
103
|
+
data: {
|
|
104
|
+
layer: string;
|
|
105
|
+
testCount: number;
|
|
106
|
+
successRate: number;
|
|
107
|
+
percentage: number;
|
|
108
|
+
}[];
|
|
109
|
+
}
|
|
110
|
+
export type ChartData<SeriesType extends string = string, Metadata extends BaseTrendSliceMetadata = BaseTrendSliceMetadata> = ResponseTrendChartData<SeriesType, Metadata> | ResponsePieChartData | ResponseBarChartData | ResponseComingSoonChartData | ResponseTreeMapChartData | ResponseHeatMapChartData | ResponseTestingPyramidChartData;
|
|
111
|
+
export type UIChartData<Metadata extends BaseTrendSliceMetadata = BaseTrendSliceMetadata> = UITrendChartData<Metadata> | UIPieChartData | UIBarChartData | UIComingSoonChartData | UITreeMapChartData | UIHeatMapChartData | UITestingPyramidChartData;
|
|
81
112
|
export type ChartsData<SeriesType extends string = string, Metadata extends BaseTrendSliceMetadata = BaseTrendSliceMetadata> = Record<ChartId, ChartData<SeriesType, Metadata>>;
|
|
113
|
+
export type ChartsDataWithEnvs<SeriesType extends string = string, Metadata extends BaseTrendSliceMetadata = BaseTrendSliceMetadata> = {
|
|
114
|
+
general: Record<ChartId, ChartData<SeriesType, Metadata>>;
|
|
115
|
+
byEnv: {
|
|
116
|
+
[env: string]: Record<ChartId, ChartData<SeriesType, Metadata>>;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
82
119
|
export type UIChartsData<Metadata extends BaseTrendSliceMetadata = BaseTrendSliceMetadata> = Record<ChartId, UIChartData<Metadata>>;
|
|
120
|
+
export type UIChartsDataWithEnvs<Metadata extends BaseTrendSliceMetadata = BaseTrendSliceMetadata> = {
|
|
121
|
+
general: UIChartsData<Metadata>;
|
|
122
|
+
byEnv: {
|
|
123
|
+
[env: string]: UIChartsData<Metadata>;
|
|
124
|
+
};
|
|
125
|
+
};
|
package/dist/charts/utils.d.ts
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
import type { ChartId
|
|
2
|
-
import type {
|
|
1
|
+
import type { ChartId } from "@allurereport/charts-api";
|
|
2
|
+
import type { SeverityLevel, TestStatus } from "@allurereport/core-api";
|
|
3
|
+
import type { ChartsData, ChartsDataWithEnvs, ResponseBarChartData, ResponseHeatMapChartData, ResponseTestingPyramidChartData, ResponseTreeMapChartData, ResponseTrendChartData, TreeMapTooltipAccessor, UIBarChartData, UIChartData, UIChartsDataWithEnvs, UIHeatMapChartData, UITestingPyramidChartData, UITreeMapChartData, UITrendChartData } from "./types.js";
|
|
3
4
|
export declare const createTrendChartDataGeneric: <T extends TestStatus | SeverityLevel>(getChart: () => ResponseTrendChartData | undefined, getGroups: () => readonly T[], getColor: (group: T) => string) => UITrendChartData | undefined;
|
|
4
5
|
export declare const createBarChartDataGeneric: <T extends string>(getChart: () => ResponseBarChartData | undefined, getColors: () => Record<T, string>) => UIBarChartData | undefined;
|
|
5
6
|
export declare const createTreeMapChartDataGeneric: (getChart: () => ResponseTreeMapChartData | undefined, colors: (value: number, domain?: number[]) => string, formatLegend?: (value: number) => string, legendDomain?: number[], tooltipRows?: TreeMapTooltipAccessor) => UITreeMapChartData | undefined;
|
|
6
7
|
export declare const createHeatMapChartDataGeneric: (getChart: () => ResponseHeatMapChartData | undefined, colors: (value: number, domain?: number[]) => string) => UIHeatMapChartData | undefined;
|
|
7
|
-
export declare const createStatusTrendChartData: (chartId: ChartId, res:
|
|
8
|
-
export declare const createSeverityTrendChartData: (chartId: ChartId, res:
|
|
9
|
-
export declare const createStatusBySeverityBarChartData: (chartId: ChartId, res:
|
|
10
|
-
export declare const createStatusTrendBarChartData: (chartId: ChartId, res:
|
|
11
|
-
export declare const createStatusChangeTrendBarChartData: (chartId: ChartId, res:
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
14
|
-
export declare const
|
|
8
|
+
export declare const createStatusTrendChartData: (chartId: ChartId, res: ChartsData) => UITrendChartData | undefined;
|
|
9
|
+
export declare const createSeverityTrendChartData: (chartId: ChartId, res: ChartsData) => UITrendChartData | undefined;
|
|
10
|
+
export declare const createStatusBySeverityBarChartData: (chartId: ChartId, res: ChartsData) => UIBarChartData | undefined;
|
|
11
|
+
export declare const createStatusTrendBarChartData: (chartId: ChartId, res: ChartsData) => UIBarChartData | undefined;
|
|
12
|
+
export declare const createStatusChangeTrendBarChartData: (chartId: ChartId, res: ChartsData) => UIBarChartData | undefined;
|
|
13
|
+
export declare const createDurationsByLayerBarChartData: (chartId: ChartId, res: ChartsData) => UIBarChartData | undefined;
|
|
14
|
+
export declare const createFbsuAgePyramidBarChartData: (chartId: ChartId, res: ChartsData) => UIBarChartData | undefined;
|
|
15
|
+
export declare const createStabilityRateDistributionBarChartData: (chartId: ChartId, res: ChartsData) => UIBarChartData | undefined;
|
|
16
|
+
export declare const createSuccessRateDistributionTreeMapChartData: (chartId: ChartId, res: ChartsData) => UITreeMapChartData | undefined;
|
|
17
|
+
export declare const createCoverageDiffTreeMapChartData: (chartId: ChartId, res: ChartsData) => UITreeMapChartData | undefined;
|
|
18
|
+
export declare const createProblemsDistributionHeatMapChartData: (chartId: ChartId, res: ChartsData) => UIHeatMapChartData | undefined;
|
|
15
19
|
export declare const createaTrendChartData: (chartId: string, chartData: ResponseTrendChartData, res: ChartsData) => UITrendChartData | undefined;
|
|
16
20
|
export declare const createBarChartData: (chartId: string, chartData: ResponseBarChartData, res: ChartsData) => UIBarChartData | undefined;
|
|
17
|
-
export declare const createTreeMapChartData: (chartId: ChartId, chartData: ResponseTreeMapChartData, res:
|
|
18
|
-
export declare const
|
|
21
|
+
export declare const createTreeMapChartData: (chartId: ChartId, chartData: ResponseTreeMapChartData, res: ChartsData) => UITreeMapChartData | undefined;
|
|
22
|
+
export declare const createFunnelChartData: (chartId: string, chartData: ResponseTestingPyramidChartData) => UITestingPyramidChartData | undefined;
|
|
23
|
+
export declare const createHeatMapChartData: (chartId: ChartId, res: ChartsData) => UIHeatMapChartData | undefined;
|
|
19
24
|
export declare const createCharts: (res: ChartsData) => Record<ChartId, UIChartData>;
|
|
25
|
+
export declare const createChartsWithEnvs: (res: ChartsDataWithEnvs) => UIChartsDataWithEnvs;
|
package/dist/charts/utils.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { BarChartType, ChartDataType, ChartType,
|
|
1
|
+
import { BarChartType, ChartDataType, ChartType, FunnelChartType, TreeMapChartType } from "@allurereport/charts-api";
|
|
2
|
+
import { severityLevels, statusesList } from "@allurereport/core-api";
|
|
2
3
|
import { interpolateRgb } from "d3-interpolate";
|
|
3
4
|
import { scaleLinear } from "d3-scale";
|
|
4
|
-
import { resolveCSSVarColor, severityColors, statusChangeColors, statusColors } from "./colors.js";
|
|
5
|
+
import { generateLayerColors, resolveCSSVarColor, severityColors, statusChangeColors, statusColors } from "./colors.js";
|
|
5
6
|
export const createTrendChartDataGeneric = (getChart, getGroups, getColor) => {
|
|
6
7
|
const chart = getChart();
|
|
7
8
|
if (!chart) {
|
|
@@ -73,6 +74,37 @@ export const createSeverityTrendChartData = (chartId, res) => createTrendChartDa
|
|
|
73
74
|
export const createStatusBySeverityBarChartData = (chartId, res) => createBarChartDataGeneric(() => res[chartId], () => statusColors);
|
|
74
75
|
export const createStatusTrendBarChartData = (chartId, res) => createBarChartDataGeneric(() => res[chartId], () => statusColors);
|
|
75
76
|
export const createStatusChangeTrendBarChartData = (chartId, res) => createBarChartDataGeneric(() => res[chartId], () => statusChangeColors);
|
|
77
|
+
export const createDurationsByLayerBarChartData = (chartId, res) => {
|
|
78
|
+
const chart = res[chartId];
|
|
79
|
+
if (!chart) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
const layerNames = chart.keys;
|
|
83
|
+
return {
|
|
84
|
+
...chart,
|
|
85
|
+
colors: generateLayerColors(layerNames),
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
export const createFbsuAgePyramidBarChartData = (chartId, res) => {
|
|
89
|
+
const chart = res[chartId];
|
|
90
|
+
if (!chart) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
...chart,
|
|
95
|
+
colors: statusColors,
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
export const createStabilityRateDistributionBarChartData = (chartId, res) => {
|
|
99
|
+
const chart = res[chartId];
|
|
100
|
+
if (!chart) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
...chart,
|
|
105
|
+
colors: {},
|
|
106
|
+
};
|
|
107
|
+
};
|
|
76
108
|
export const createSuccessRateDistributionTreeMapChartData = (chartId, res) => {
|
|
77
109
|
const chartColorDomain = [0, 1];
|
|
78
110
|
return createTreeMapChartDataGeneric(() => res[chartId], (value, domain = chartColorDomain) => {
|
|
@@ -132,14 +164,19 @@ export const createaTrendChartData = (chartId, chartData, res) => {
|
|
|
132
164
|
}
|
|
133
165
|
};
|
|
134
166
|
export const createBarChartData = (chartId, chartData, res) => {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
167
|
+
switch (chartData.dataType) {
|
|
168
|
+
case BarChartType.StatusBySeverity:
|
|
169
|
+
return createStatusBySeverityBarChartData(chartId, res);
|
|
170
|
+
case BarChartType.StatusTrend:
|
|
171
|
+
return createStatusTrendBarChartData(chartId, res);
|
|
172
|
+
case BarChartType.StatusChangeTrend:
|
|
173
|
+
return createStatusChangeTrendBarChartData(chartId, res);
|
|
174
|
+
case BarChartType.DurationsByLayer:
|
|
175
|
+
return createDurationsByLayerBarChartData(chartId, res);
|
|
176
|
+
case BarChartType.FbsuAgePyramid:
|
|
177
|
+
return createFbsuAgePyramidBarChartData(chartId, res);
|
|
178
|
+
case BarChartType.StabilityRateDistribution:
|
|
179
|
+
return createStabilityRateDistributionBarChartData(chartId, res);
|
|
143
180
|
}
|
|
144
181
|
};
|
|
145
182
|
export const createTreeMapChartData = (chartId, chartData, res) => {
|
|
@@ -150,6 +187,12 @@ export const createTreeMapChartData = (chartId, chartData, res) => {
|
|
|
150
187
|
return createCoverageDiffTreeMapChartData(chartId, res);
|
|
151
188
|
}
|
|
152
189
|
};
|
|
190
|
+
export const createFunnelChartData = (chartId, chartData) => {
|
|
191
|
+
switch (chartData.dataType) {
|
|
192
|
+
case FunnelChartType.TestingPyramid:
|
|
193
|
+
return chartData;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
153
196
|
export const createHeatMapChartData = (chartId, res) => {
|
|
154
197
|
return createProblemsDistributionHeatMapChartData(chartId, res);
|
|
155
198
|
};
|
|
@@ -179,9 +222,28 @@ export const createCharts = (res) => {
|
|
|
179
222
|
acc[chartId] = chartData;
|
|
180
223
|
}
|
|
181
224
|
}
|
|
225
|
+
else if (chart.type === ChartType.Funnel) {
|
|
226
|
+
const chartData = createFunnelChartData(chartId, chart);
|
|
227
|
+
if (chartData) {
|
|
228
|
+
acc[chartId] = chartData;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
182
231
|
else if ([ChartType.Pie, ChartType.ComingSoon].includes(chart.type)) {
|
|
183
|
-
acc
|
|
232
|
+
return acc;
|
|
184
233
|
}
|
|
185
234
|
return acc;
|
|
186
235
|
}, {});
|
|
187
236
|
};
|
|
237
|
+
export const createChartsWithEnvs = (res) => {
|
|
238
|
+
if (!("general" in res) && !("byEnv" in res)) {
|
|
239
|
+
return { general: createCharts(res), byEnv: {} };
|
|
240
|
+
}
|
|
241
|
+
const result = {
|
|
242
|
+
general: createCharts(res.general),
|
|
243
|
+
byEnv: {},
|
|
244
|
+
};
|
|
245
|
+
for (const [env, chartData] of Object.entries(res.byEnv)) {
|
|
246
|
+
result.byEnv[env] = createCharts(chartData);
|
|
247
|
+
}
|
|
248
|
+
return result;
|
|
249
|
+
};
|
package/dist/sanitize.d.ts
CHANGED
|
@@ -1,15 +1 @@
|
|
|
1
|
-
export declare const sanitize:
|
|
2
|
-
(dirty: string | Node, cfg: import("dompurify").Config & {
|
|
3
|
-
RETURN_TRUSTED_TYPE: true;
|
|
4
|
-
}): import("trusted-types/lib/index.js").TrustedHTML;
|
|
5
|
-
(dirty: Node, cfg: import("dompurify").Config & {
|
|
6
|
-
IN_PLACE: true;
|
|
7
|
-
}): Node;
|
|
8
|
-
(dirty: string | Node, cfg: import("dompurify").Config & {
|
|
9
|
-
RETURN_DOM: true;
|
|
10
|
-
}): Node;
|
|
11
|
-
(dirty: string | Node, cfg: import("dompurify").Config & {
|
|
12
|
-
RETURN_DOM_FRAGMENT: true;
|
|
13
|
-
}): DocumentFragment;
|
|
14
|
-
(dirty: string | Node, cfg?: import("dompurify").Config): string;
|
|
15
|
-
};
|
|
1
|
+
export declare const sanitize: (html: string, config?: Record<string, any>) => string;
|
package/dist/sanitize.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import DOMPurify from "dompurify";
|
|
2
|
-
export const sanitize = DOMPurify.sanitize
|
|
2
|
+
export const sanitize = (html, config) => DOMPurify.sanitize(html, config);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allurereport/web-commons",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.22",
|
|
4
4
|
"description": "Collection of utilities used across the web Allure reports",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"allure",
|
|
@@ -23,16 +23,20 @@
|
|
|
23
23
|
"clean": "rimraf ./dist"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@allurereport/
|
|
26
|
+
"@allurereport/charts-api": "3.0.0-beta.22",
|
|
27
|
+
"@allurereport/core-api": "3.0.0-beta.22",
|
|
28
|
+
"@allurereport/plugin-api": "3.0.0-beta.22",
|
|
27
29
|
"ansi-to-html": "^0.7.2",
|
|
28
30
|
"d3-interpolate": "^3.0.1",
|
|
29
31
|
"d3-scale": "^4.0.2",
|
|
32
|
+
"d3-shape": "^3.2.0",
|
|
30
33
|
"dompurify": "^3.2.6"
|
|
31
34
|
},
|
|
32
35
|
"devDependencies": {
|
|
33
36
|
"@stylistic/eslint-plugin": "^2.6.1",
|
|
34
37
|
"@types/d3-interpolate": "^3.0.4",
|
|
35
38
|
"@types/d3-scale": "^4.0.9",
|
|
39
|
+
"@types/d3-shape": "^3.1.6",
|
|
36
40
|
"@types/eslint": "^8.56.11",
|
|
37
41
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
38
42
|
"@typescript-eslint/parser": "^8.0.0",
|