@c2l2c/backstage-plugin-dora-metrics 0.4.0 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,97 @@
1
+ export { default as doraMetricsPlugin } from './alpha.js';
2
+ import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
3
+ import { OAuthApi, ConfigApi } from '@backstage/core-plugin-api';
4
+ import React from 'react';
5
+ import '@backstage/frontend-plugin-api';
6
+
7
+ type DoraRating = 'elite' | 'high' | 'medium' | 'low';
8
+ interface PrDetail {
9
+ number: number;
10
+ title: string;
11
+ url: string;
12
+ durationHours: number;
13
+ mergedAt: string;
14
+ author?: string;
15
+ authorAvatar?: string;
16
+ }
17
+ interface DoraMetricValue {
18
+ value: number;
19
+ unit: string;
20
+ rating: DoraRating;
21
+ target: number;
22
+ slowestPRs?: PrDetail[];
23
+ }
24
+ interface DoraEnvironment {
25
+ name: string;
26
+ /**
27
+ * Raw branch pattern as configured — a single branch name, a comma-separated
28
+ * list ("main,master"), or a JavaScript regex string ("^(main|master)$").
29
+ * The client resolves this to a concrete list of branches at query time.
30
+ */
31
+ branch: string;
32
+ isProduction: boolean;
33
+ label: string;
34
+ }
35
+ interface DoraTargets {
36
+ deploymentFrequency: number;
37
+ leadTime: number;
38
+ changeFailureRate: number;
39
+ mttr: number;
40
+ }
41
+ interface DoraMetrics {
42
+ deploymentFrequency: DoraMetricValue;
43
+ leadTime: DoraMetricValue;
44
+ /** null for non-production environments */
45
+ changeFailureRate: DoraMetricValue | null;
46
+ /** null for non-production environments */
47
+ mttr: DoraMetricValue | null;
48
+ /** null for non-production environments */
49
+ numberOfHotfixes: DoraMetricValue | null;
50
+ }
51
+ interface DoraHistoryPoint {
52
+ weekLabel: string;
53
+ bucketMidMs: number;
54
+ deploymentCount: number;
55
+ leadTimeHours: number;
56
+ changeFailureRate?: number;
57
+ mttrHours?: number;
58
+ }
59
+ interface DoraMetricsApi {
60
+ getEnvironments(): DoraEnvironment[];
61
+ getDefaultDays(): number;
62
+ getTargets(): DoraTargets;
63
+ getMetrics(projectSlug: string, env: DoraEnvironment, days: number, targetsOverride?: Partial<DoraTargets>): Promise<DoraMetrics>;
64
+ getHistory(projectSlug: string, env: DoraEnvironment, days: number): Promise<DoraHistoryPoint[]>;
65
+ }
66
+ declare const doraMetricsApiRef: _backstage_core_plugin_api.ApiRef<DoraMetricsApi>;
67
+
68
+ declare class DoraMetricsClient implements DoraMetricsApi {
69
+ private readonly githubAuthApi;
70
+ private readonly configApi;
71
+ constructor(githubAuthApi: OAuthApi, configApi: ConfigApi);
72
+ private getConfig;
73
+ getEnvironments(): DoraEnvironment[];
74
+ getDefaultDays(): number;
75
+ getTargets(): DoraTargets;
76
+ private fetchWithAuth;
77
+ /**
78
+ * Fetch all merged PRs for an environment, resolving branch patterns and
79
+ * deduplicating across multiple branches by PR number.
80
+ */
81
+ private fetchMergedPRs;
82
+ getMetrics(projectSlug: string, env: DoraEnvironment, days: number, targetsOverride?: Partial<DoraTargets>): Promise<DoraMetrics>;
83
+ getHistory(projectSlug: string, env: DoraEnvironment, days: number): Promise<DoraHistoryPoint[]>;
84
+ }
85
+
86
+ declare class MockDoraMetricsClient implements DoraMetricsApi {
87
+ getEnvironments(): DoraEnvironment[];
88
+ getDefaultDays(): number;
89
+ getTargets(): DoraTargets;
90
+ getMetrics(_projectSlug: string, env: DoraEnvironment, _days: number, _targetsOverride?: Partial<DoraTargets>): Promise<DoraMetrics>;
91
+ getHistory(_projectSlug: string, env: DoraEnvironment, _days: number): Promise<DoraHistoryPoint[]>;
92
+ }
93
+
94
+ declare function DoraMetricsContent(): React.JSX.Element | null;
95
+
96
+ export { DoraMetricsClient, DoraMetricsContent, MockDoraMetricsClient, doraMetricsApiRef };
97
+ export type { DoraEnvironment, DoraMetricValue, DoraMetrics, DoraMetricsApi, DoraRating, DoraTargets, PrDetail };
@@ -0,0 +1,6 @@
1
+ export { doraMetricsPlugin } from './plugin.esm.js';
2
+ export { doraMetricsApiRef } from './api/types.esm.js';
3
+ export { DoraMetricsClient } from './api/DoraMetricsClient.esm.js';
4
+ export { MockDoraMetricsClient } from './api/MockDoraMetricsClient.esm.js';
5
+ export { DoraMetricsContent } from './components/DoraMetricsContent.esm.js';
6
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -0,0 +1,11 @@
1
+ import { createFrontendPlugin } from '@backstage/frontend-plugin-api';
2
+ import { doraMetricsEntityContentExtension } from './extensions/entityContent.esm.js';
3
+ import { doraMetricsApiExtension } from './extensions/api.esm.js';
4
+
5
+ const doraMetricsPlugin = createFrontendPlugin({
6
+ pluginId: "dora-metrics",
7
+ extensions: [doraMetricsEntityContentExtension, doraMetricsApiExtension]
8
+ });
9
+
10
+ export { doraMetricsPlugin };
11
+ //# sourceMappingURL=plugin.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.esm.js","sources":["../src/plugin.ts"],"sourcesContent":["import { createFrontendPlugin, type FrontendPlugin } from '@backstage/frontend-plugin-api';\nimport { doraMetricsEntityContentExtension } from './extensions/entityContent';\nimport { doraMetricsApiExtension } from './extensions/api';\n\nexport const doraMetricsPlugin: FrontendPlugin = createFrontendPlugin({\n pluginId: 'dora-metrics',\n extensions: [doraMetricsEntityContentExtension, doraMetricsApiExtension],\n});\n"],"names":[],"mappings":";;;;AAIO,MAAM,oBAAoC,oBAAA,CAAqB;AAAA,EACpE,QAAA,EAAU,cAAA;AAAA,EACV,UAAA,EAAY,CAAC,iCAAA,EAAmC,uBAAuB;AACzE,CAAC;;;;"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@c2l2c/backstage-plugin-dora-metrics",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "A Backstage frontend plugin that displays DORA metrics (Deployment Frequency, Lead Time, Change Failure Rate, MTTR) for catalog entities via the GitHub API.",
5
- "main": "dist/index.cjs.js",
6
- "module": "dist/index.esm.js",
7
- "types": "dist/index.d.ts",
5
+ "main": "./dist/index.esm.js",
6
+ "module": "./dist/index.esm.js",
7
+ "types": "./dist/index.d.ts",
8
8
  "backstage": {
9
9
  "pluginId": "dora-metrics",
10
10
  "role": "frontend-plugin",
@@ -96,5 +96,15 @@
96
96
  },
97
97
  "engines": {
98
98
  "node": ">=20"
99
+ },
100
+ "typesVersions": {
101
+ "*": {
102
+ "alpha": [
103
+ "dist/alpha.d.ts"
104
+ ],
105
+ "package.json": [
106
+ "package.json"
107
+ ]
108
+ }
99
109
  }
100
110
  }