@allurereport/charts-api 3.0.0-beta.21

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/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Charts API
2
+
3
+ [<img src="https://allurereport.org/public/img/allure-report.svg" height="85px" alt="Allure Report logo" align="right" />](https://allurereport.org "Allure Report")
4
+
5
+ - Learn more about Allure Report at https://allurereport.org
6
+ - 📚 [Documentation](https://allurereport.org/docs/) – discover official documentation for Allure Report
7
+ - ❓ [Questions and Support](https://github.com/orgs/allure-framework/discussions/categories/questions-support) – get help from the team and community
8
+ - 📢 [Official announcements](https://github.com/orgs/allure-framework/discussions/categories/announcements) – be in touch with the latest updates
9
+ - 💬 [General Discussion ](https://github.com/orgs/allure-framework/discussions/categories/general-discussion) – engage in casual conversations, share insights and ideas with the community
10
+
11
+ ---
12
+
13
+ ## Overview
14
+
15
+ The interfaces in the package describe the entities used for building Allure Charts.
16
+
17
+ ## Install
18
+
19
+ Use your favorite package manager to install the package:
20
+
21
+ ```shell
22
+ npm add @allurereport/charts-api
23
+ yarn add @allurereport/charts-api
24
+ pnpm add @allurereport/charts-api
25
+ ```
@@ -0,0 +1,10 @@
1
+ export declare const DEFAULT_CHART_HISTORY_LIMIT = 10;
2
+ export declare const defaultChartsConfig: ({
3
+ type: string;
4
+ title: string;
5
+ dataType?: undefined;
6
+ } | {
7
+ type: string;
8
+ dataType: string;
9
+ title: string;
10
+ })[];
@@ -0,0 +1,66 @@
1
+ export const DEFAULT_CHART_HISTORY_LIMIT = 10;
2
+ export const defaultChartsConfig = [
3
+ {
4
+ type: "pie",
5
+ title: "Current status",
6
+ },
7
+ {
8
+ type: "trend",
9
+ dataType: "status",
10
+ title: "Status dynamics",
11
+ },
12
+ {
13
+ type: "bar",
14
+ dataType: "statusBySeverity",
15
+ title: "Test result severities",
16
+ },
17
+ {
18
+ type: "bar",
19
+ dataType: "statusTrend",
20
+ title: "Status change dynamics",
21
+ },
22
+ {
23
+ type: "bar",
24
+ dataType: "statusChangeTrend",
25
+ title: "Test base growth dynamics",
26
+ },
27
+ {
28
+ type: "treemap",
29
+ dataType: "coverageDiff",
30
+ title: "Coverage diff map",
31
+ },
32
+ {
33
+ type: "treemap",
34
+ dataType: "successRateDistribution",
35
+ title: "Success rate distribution",
36
+ },
37
+ {
38
+ type: "heatmap",
39
+ title: "Problems distribution by environment",
40
+ },
41
+ {
42
+ type: "bar",
43
+ dataType: "stabilityRateDistribution",
44
+ title: "Stability rate distribution",
45
+ },
46
+ {
47
+ type: "bar",
48
+ dataType: "durationsByLayer",
49
+ title: "Durations by layer histogram",
50
+ },
51
+ {
52
+ type: "bar",
53
+ dataType: "performanceTrend",
54
+ title: "Performance dynamics",
55
+ },
56
+ {
57
+ type: "bar",
58
+ dataType: "fbsuAgePyramid",
59
+ title: "FBSU age pyramid",
60
+ },
61
+ {
62
+ type: "funnel",
63
+ dataType: "testingPyramid",
64
+ title: "Testing pyramid",
65
+ },
66
+ ];
@@ -0,0 +1,2 @@
1
+ export * from "./constants.js";
2
+ export * from "./types.js";
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./constants.js";
2
+ export * from "./types.js";
@@ -0,0 +1,214 @@
1
+ import type { HistoryDataPoint, SeverityLevel, Statistic, TestResult, TestStatus } from "@allurereport/core-api";
2
+ export declare enum ChartType {
3
+ Trend = "trend",
4
+ Pie = "pie",
5
+ TreeMap = "treemap",
6
+ HeatMap = "heatmap",
7
+ Bar = "bar",
8
+ Funnel = "funnel",
9
+ ComingSoon = "coming-soon"
10
+ }
11
+ export declare enum ChartDataType {
12
+ Status = "status",
13
+ Severity = "severity"
14
+ }
15
+ export declare enum BarChartType {
16
+ StatusBySeverity = "statusBySeverity",
17
+ StatusTrend = "statusTrend",
18
+ StatusChangeTrend = "statusChangeTrend",
19
+ DurationsByLayer = "durationsByLayer",
20
+ FbsuAgePyramid = "fbsuAgePyramid",
21
+ StabilityRateDistribution = "stabilityRateDistribution"
22
+ }
23
+ export declare enum TreeMapChartType {
24
+ SuccessRateDistribution = "successRateDistribution",
25
+ CoverageDiff = "coverageDiff"
26
+ }
27
+ export declare enum ChartMode {
28
+ Raw = "raw",
29
+ Percent = "percent",
30
+ Diverging = "diverging"
31
+ }
32
+ export type ChartId = string;
33
+ export type TrendPointId = string;
34
+ export type TrendSliceId = string;
35
+ export type BaseMetadata = Record<string, unknown>;
36
+ export interface BaseTrendSliceMetadata extends BaseMetadata {
37
+ executionId: string;
38
+ executionName?: string;
39
+ }
40
+ export interface TrendPoint {
41
+ x: string;
42
+ y: number;
43
+ }
44
+ export type TrendSliceMetadata<Metadata extends BaseMetadata> = BaseTrendSliceMetadata & Metadata;
45
+ export interface TrendSlice<Metadata extends BaseTrendSliceMetadata = BaseTrendSliceMetadata> {
46
+ min: number;
47
+ max: number;
48
+ metadata: TrendSliceMetadata<Metadata>;
49
+ }
50
+ export interface BasePieSlice {
51
+ status: TestStatus;
52
+ count: number;
53
+ }
54
+ export interface PieSlice extends BasePieSlice {
55
+ d: string | null;
56
+ }
57
+ export type PieChartValues = {
58
+ percentage: number;
59
+ slices: PieSlice[];
60
+ };
61
+ export type BarGroupValues<T extends string = string> = Record<T, number>;
62
+ export type BarGroup<G extends string, T extends string = string> = {
63
+ groupId: G;
64
+ } & BarGroupValues<T>;
65
+ export declare enum BarGroupMode {
66
+ Grouped = "grouped",
67
+ Stacked = "stacked"
68
+ }
69
+ export type NewKey<T extends string> = `new${Capitalize<T>}`;
70
+ export type RemovedKey<T extends string> = `removed${Capitalize<T>}`;
71
+ export type TreeMapNode<T extends Record<string, any> = {}> = T & {
72
+ id: string;
73
+ value?: number;
74
+ colorValue?: number;
75
+ children?: TreeMapNode<T>[];
76
+ };
77
+ export type HeatMapPoint = {
78
+ x: string;
79
+ y?: number;
80
+ };
81
+ export type HeatMapSerie<T extends Record<string, any> = Record<string, any>> = {
82
+ id: string;
83
+ data: HeatMapPoint[];
84
+ } & T;
85
+ export type ExecutionIdFn = (executionOrder: number) => string;
86
+ export type ExecutionNameFn = (executionOrder: number) => string;
87
+ export type TrendMetadataFnOverrides = {
88
+ executionIdAccessor?: ExecutionIdFn;
89
+ executionNameAccessor?: ExecutionNameFn;
90
+ };
91
+ export type TrendDataType = TestStatus | SeverityLevel;
92
+ export type TrendStats<T extends TrendDataType> = Record<T, number>;
93
+ export type TrendCalculationResult<T extends TrendDataType> = {
94
+ points: Record<TrendPointId, TrendPoint>;
95
+ series: Record<T, TrendPointId[]>;
96
+ };
97
+ export interface GenericTrendChartData<SeriesType extends string, Metadata extends BaseTrendSliceMetadata = BaseTrendSliceMetadata> {
98
+ type: ChartType.Trend;
99
+ dataType: ChartDataType;
100
+ mode: ChartMode;
101
+ title?: string;
102
+ points: Record<TrendPointId, TrendPoint>;
103
+ slices: Record<TrendSliceId, TrendSlice<Metadata>>;
104
+ series: Record<SeriesType, TrendPointId[]>;
105
+ min: number;
106
+ max: number;
107
+ }
108
+ export type StatusTrendChartData = GenericTrendChartData<TestStatus>;
109
+ export type SeverityTrendChartData = GenericTrendChartData<SeverityLevel>;
110
+ export type TrendChartData = StatusTrendChartData | SeverityTrendChartData;
111
+ export interface BarChartData {
112
+ type: ChartType.Bar;
113
+ dataType: BarChartType;
114
+ mode: ChartMode;
115
+ title?: string;
116
+ data: BarGroup<string, string>[];
117
+ keys: readonly string[];
118
+ indexBy: string;
119
+ groupMode: BarGroupMode;
120
+ xAxisConfig?: {
121
+ legend?: string;
122
+ enabled?: boolean;
123
+ format?: string;
124
+ domain?: number[];
125
+ tickValues?: number | number[];
126
+ };
127
+ yAxisConfig?: {
128
+ legend?: string;
129
+ enabled?: boolean;
130
+ format?: string;
131
+ tickValues?: number | number[];
132
+ domain?: number[];
133
+ };
134
+ layout?: "horizontal" | "vertical";
135
+ threshold?: number;
136
+ }
137
+ export interface TreeMapChartData {
138
+ type: ChartType.TreeMap;
139
+ dataType: TreeMapChartType;
140
+ title?: string;
141
+ treeMap: TreeMapNode;
142
+ }
143
+ export interface HeatMapChartData<T extends Record<string, any> = {}> {
144
+ type: ChartType.HeatMap;
145
+ title?: string;
146
+ data: HeatMapSerie<T>[];
147
+ }
148
+ export interface PieChartData {
149
+ type: ChartType.Pie;
150
+ title?: string;
151
+ slices: PieSlice[];
152
+ percentage: number;
153
+ }
154
+ export interface ComingSoonChartData {
155
+ type: ChartType.ComingSoon;
156
+ title?: string;
157
+ }
158
+ export type GeneratedChartData = TrendChartData | PieChartData | BarChartData | ComingSoonChartData | TreeMapChartData | HeatMapChartData;
159
+ export type GeneratedChartsData = Record<ChartId, GeneratedChartData>;
160
+ export type TrendChartOptions = {
161
+ type: ChartType.Trend;
162
+ dataType: ChartDataType;
163
+ mode?: ChartMode;
164
+ title?: string;
165
+ limit?: number;
166
+ metadata?: TrendMetadataFnOverrides;
167
+ };
168
+ export type PieChartOptions = {
169
+ type: ChartType.Pie;
170
+ title?: string;
171
+ };
172
+ export type BarChartOptions = {
173
+ type: ChartType.Bar;
174
+ dataType: BarChartType;
175
+ mode?: ChartMode;
176
+ title?: string;
177
+ limit?: number;
178
+ threshold?: number;
179
+ };
180
+ export type TreeMapChartOptions = {
181
+ type: ChartType.TreeMap;
182
+ dataType: TreeMapChartType;
183
+ title?: string;
184
+ };
185
+ export type HeatMapChartOptions = {
186
+ type: ChartType.HeatMap;
187
+ title?: string;
188
+ };
189
+ export type ComingSoonChartOptions = {
190
+ type: ChartType.ComingSoon;
191
+ title?: string;
192
+ };
193
+ export type ChartOptions = TrendChartOptions | PieChartOptions | BarChartOptions | ComingSoonChartOptions | TreeMapChartOptions | HeatMapChartOptions;
194
+ export interface AllureChartsStoreData {
195
+ historyDataPoints: HistoryDataPoint[];
196
+ testResults: TestResult[];
197
+ statistic: Statistic;
198
+ }
199
+ export interface TrendDataAccessor<T extends TrendDataType> {
200
+ getCurrentData: (storeData: AllureChartsStoreData) => TrendStats<T>;
201
+ getHistoricalData: (historyPoint: HistoryDataPoint) => TrendStats<T>;
202
+ getAllValues: () => readonly T[];
203
+ }
204
+ export interface BarDataAccessor<G extends string, T extends string> {
205
+ getItems: (storeData: AllureChartsStoreData, limitedHistoryDataPoints: HistoryDataPoint[], isFullHistory: boolean) => BarGroup<G, T>[];
206
+ getGroupKeys: () => readonly T[];
207
+ getGroupMode: () => BarGroupMode;
208
+ }
209
+ export interface TreeMapDataAccessor<T extends TreeMapNode> {
210
+ getTreeMap: (storeData: AllureChartsStoreData) => T;
211
+ }
212
+ export interface HeatMapDataAccessor<T extends Record<string, unknown> = {}> {
213
+ getHeatMap: (storeData: AllureChartsStoreData) => HeatMapSerie<T>[];
214
+ }
package/dist/types.js ADDED
@@ -0,0 +1,40 @@
1
+ export var ChartType;
2
+ (function (ChartType) {
3
+ ChartType["Trend"] = "trend";
4
+ ChartType["Pie"] = "pie";
5
+ ChartType["TreeMap"] = "treemap";
6
+ ChartType["HeatMap"] = "heatmap";
7
+ ChartType["Bar"] = "bar";
8
+ ChartType["Funnel"] = "funnel";
9
+ ChartType["ComingSoon"] = "coming-soon";
10
+ })(ChartType || (ChartType = {}));
11
+ export var ChartDataType;
12
+ (function (ChartDataType) {
13
+ ChartDataType["Status"] = "status";
14
+ ChartDataType["Severity"] = "severity";
15
+ })(ChartDataType || (ChartDataType = {}));
16
+ export var BarChartType;
17
+ (function (BarChartType) {
18
+ BarChartType["StatusBySeverity"] = "statusBySeverity";
19
+ BarChartType["StatusTrend"] = "statusTrend";
20
+ BarChartType["StatusChangeTrend"] = "statusChangeTrend";
21
+ BarChartType["DurationsByLayer"] = "durationsByLayer";
22
+ BarChartType["FbsuAgePyramid"] = "fbsuAgePyramid";
23
+ BarChartType["StabilityRateDistribution"] = "stabilityRateDistribution";
24
+ })(BarChartType || (BarChartType = {}));
25
+ export var TreeMapChartType;
26
+ (function (TreeMapChartType) {
27
+ TreeMapChartType["SuccessRateDistribution"] = "successRateDistribution";
28
+ TreeMapChartType["CoverageDiff"] = "coverageDiff";
29
+ })(TreeMapChartType || (TreeMapChartType = {}));
30
+ export var ChartMode;
31
+ (function (ChartMode) {
32
+ ChartMode["Raw"] = "raw";
33
+ ChartMode["Percent"] = "percent";
34
+ ChartMode["Diverging"] = "diverging";
35
+ })(ChartMode || (ChartMode = {}));
36
+ export var BarGroupMode;
37
+ (function (BarGroupMode) {
38
+ BarGroupMode["Grouped"] = "grouped";
39
+ BarGroupMode["Stacked"] = "stacked";
40
+ })(BarGroupMode || (BarGroupMode = {}));
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@allurereport/charts-api",
3
+ "version": "3.0.0-beta.21",
4
+ "description": "Allure Charts API",
5
+ "keywords": [
6
+ "allure",
7
+ "testing",
8
+ "charts"
9
+ ],
10
+ "repository": "https://github.com/allure-framework/allure3",
11
+ "license": "Apache-2.0",
12
+ "author": "Qameta Software",
13
+ "type": "module",
14
+ "exports": {
15
+ ".": "./dist/index.js"
16
+ },
17
+ "main": "./dist/index.js",
18
+ "module": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "scripts": {
24
+ "build": "run clean && tsc --project ./tsconfig.json",
25
+ "clean": "rimraf ./dist",
26
+ "eslint": "eslint ./src/**/*.{js,jsx,ts,tsx}",
27
+ "eslint:format": "eslint --fix ./src/**/*.{js,jsx,ts,tsx}"
28
+ },
29
+ "dependencies": {
30
+ "@allurereport/core-api": "3.0.0-beta.21",
31
+ "@allurereport/plugin-api": "3.0.0-beta.21",
32
+ "d3-shape": "^3.2.0"
33
+ },
34
+ "devDependencies": {
35
+ "@stylistic/eslint-plugin": "^2.6.1",
36
+ "@types/d3-shape": "^3.1.6",
37
+ "@types/eslint": "^8.56.11",
38
+ "@types/mime-types": "^2.1.4",
39
+ "@types/node": "^20.17.9",
40
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
41
+ "@typescript-eslint/parser": "^8.0.0",
42
+ "@vitest/runner": "^2.1.9",
43
+ "allure-vitest": "^3.3.3",
44
+ "eslint": "^8.57.0",
45
+ "eslint-config-prettier": "^9.1.0",
46
+ "eslint-plugin-import": "^2.29.1",
47
+ "eslint-plugin-jsdoc": "^50.0.0",
48
+ "eslint-plugin-n": "^17.10.1",
49
+ "eslint-plugin-no-null": "^1.0.2",
50
+ "eslint-plugin-prefer-arrow": "^1.2.3",
51
+ "rimraf": "^6.0.1",
52
+ "ts-node": "^10.9.2",
53
+ "tslib": "^2.7.0",
54
+ "typescript": "^5.6.3"
55
+ }
56
+ }