@backstage-community/plugin-cost-insights-common 0.1.3
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/CHANGELOG.md +43 -0
- package/README.md +8 -0
- package/dist/index.cjs.js +3 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +202 -0
- package/dist/index.esm.js +2 -0
- package/dist/index.esm.js.map +1 -0
- package/package.json +42 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# @backstage-community/plugin-cost-insights-common
|
|
2
|
+
|
|
3
|
+
## 0.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 193a2a3: Migrated from the [backstage/backstage](https://github.com/backstage/backstage) monorepo.
|
|
8
|
+
|
|
9
|
+
## 0.1.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 406b786a2a2c: Mark package as being free of side effects, allowing more optimized Webpack builds.
|
|
14
|
+
|
|
15
|
+
## 0.1.2-next.0
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 406b786a2a2c: Mark package as being free of side effects, allowing more optimized Webpack builds.
|
|
20
|
+
|
|
21
|
+
## 0.1.1
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- daf4b33e34: Add name property to Group
|
|
26
|
+
|
|
27
|
+
## 0.1.1-next.0
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- daf4b33e34: Add name property to Group
|
|
32
|
+
|
|
33
|
+
## 0.1.0
|
|
34
|
+
|
|
35
|
+
### Minor Changes
|
|
36
|
+
|
|
37
|
+
- 81dd5ea989: Introduces a new isomorphic @backstage/plugin-cost-insight-common package to contain shared types across all other cost insights packages and modules.
|
|
38
|
+
|
|
39
|
+
## 0.1.0-next.0
|
|
40
|
+
|
|
41
|
+
### Minor Changes
|
|
42
|
+
|
|
43
|
+
- 81dd5ea989: Introduces a new isomorphic @backstage/plugin-cost-insight-common package to contain shared types across all other cost insights packages and modules.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
*/
|
|
4
|
+
interface ChangeStatistic {
|
|
5
|
+
/**
|
|
6
|
+
* The ratio of change from one duration to another, expressed as: (newSum - oldSum) / oldSum
|
|
7
|
+
* If a ratio cannot be calculated - such as when a new or old sum is zero,
|
|
8
|
+
* the ratio can be omitted and where applicable, ∞ or -∞ will display based on amount.
|
|
9
|
+
*/
|
|
10
|
+
ratio?: number;
|
|
11
|
+
/**
|
|
12
|
+
* The actual USD change between time periods (can be negative if costs decreased)
|
|
13
|
+
*/
|
|
14
|
+
amount: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
type DateAggregation = {
|
|
21
|
+
/**
|
|
22
|
+
* The date aggregation as string.
|
|
23
|
+
* @example YYYY-MM-DD
|
|
24
|
+
*/
|
|
25
|
+
date: string;
|
|
26
|
+
amount: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
type Trendline = {
|
|
33
|
+
slope: number;
|
|
34
|
+
intercept: number;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @public
|
|
39
|
+
*/
|
|
40
|
+
interface Cost {
|
|
41
|
+
id: string;
|
|
42
|
+
aggregation: DateAggregation[];
|
|
43
|
+
change?: ChangeStatistic;
|
|
44
|
+
trendline?: Trendline;
|
|
45
|
+
groupedCosts?: Record<string, Cost[]>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
type Maybe<T> = T | null;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* An entity is a tree-like structure that represents any unique
|
|
56
|
+
* product or service that generates cost over a fixed period of time.
|
|
57
|
+
* An entity could be atomic or composite. An atomic entity is indivisible
|
|
58
|
+
* and cannot be broken into sub-entities.
|
|
59
|
+
*
|
|
60
|
+
* A composite entity is divided into sub-entities that account for portions
|
|
61
|
+
* of the total cost **over the same time period**. The root entity is
|
|
62
|
+
* expected to only have _one_ Record consisting of the sub-entities to display
|
|
63
|
+
* in the product panel (keyed by the entity type, such as "service" for
|
|
64
|
+
* compute entities).
|
|
65
|
+
*
|
|
66
|
+
* The root sub-entities may have multiple breakdowns - for example, a
|
|
67
|
+
* breakdown of an entity cost by SKU vs deployment environment. The sum
|
|
68
|
+
* aggregated cost of each keyed breakdown should equal the sub-entity's cost.
|
|
69
|
+
*
|
|
70
|
+
* Entities with null ids are considered "unlabeled" - costs without attribution.
|
|
71
|
+
* If an entity is a composite, it may only have one (1) null child but may have any number of
|
|
72
|
+
* null grandchildren.
|
|
73
|
+
*
|
|
74
|
+
* @public
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* Here's an example composite entity:
|
|
78
|
+
* ```
|
|
79
|
+
* const compositeEntity = {
|
|
80
|
+
* id: 'product',
|
|
81
|
+
* aggregation: [0, 200],
|
|
82
|
+
* change: {
|
|
83
|
+
* ratio: 2000,
|
|
84
|
+
* amount: 200
|
|
85
|
+
* },
|
|
86
|
+
* entities: {
|
|
87
|
+
* service: [
|
|
88
|
+
* {
|
|
89
|
+
* id: 'service-a',
|
|
90
|
+
* aggregation: [0, 100],
|
|
91
|
+
* change: {
|
|
92
|
+
* ratio: 100,
|
|
93
|
+
* amount: 100
|
|
94
|
+
* },
|
|
95
|
+
* entities: {}
|
|
96
|
+
* },
|
|
97
|
+
* {
|
|
98
|
+
* id: 'service-b',
|
|
99
|
+
* aggregation: [0, 100],
|
|
100
|
+
* change: {
|
|
101
|
+
* ratio: 100,
|
|
102
|
+
* amount: 100
|
|
103
|
+
* },
|
|
104
|
+
* entities: {
|
|
105
|
+
* SKU: [
|
|
106
|
+
* {
|
|
107
|
+
* id: 'service-b-sku-a',
|
|
108
|
+
* aggregation: [0, 25],
|
|
109
|
+
* change: {
|
|
110
|
+
* ratio: 25,
|
|
111
|
+
* amount: 25
|
|
112
|
+
* },
|
|
113
|
+
* entities: {}
|
|
114
|
+
* },
|
|
115
|
+
* {
|
|
116
|
+
* id: null, // Unlabeled cost for service-b
|
|
117
|
+
* aggregation: [0, 75],
|
|
118
|
+
* change: {
|
|
119
|
+
* ratio: 75,
|
|
120
|
+
* amount: 75
|
|
121
|
+
* },
|
|
122
|
+
* entities: {}
|
|
123
|
+
* },
|
|
124
|
+
* ],
|
|
125
|
+
* deployment: [
|
|
126
|
+
* {
|
|
127
|
+
* id: 'service-b-env-a',
|
|
128
|
+
* aggregation: [0, 50],
|
|
129
|
+
* change: {
|
|
130
|
+
* ratio: 50,
|
|
131
|
+
* amount: 50
|
|
132
|
+
* },
|
|
133
|
+
* entities: {}
|
|
134
|
+
* },
|
|
135
|
+
* {
|
|
136
|
+
* id: 'service-b-env-b',
|
|
137
|
+
* aggregation: [0, 50],
|
|
138
|
+
* change: {
|
|
139
|
+
* ratio: 50,
|
|
140
|
+
* amount: 50
|
|
141
|
+
* },
|
|
142
|
+
* entities: {}
|
|
143
|
+
* },
|
|
144
|
+
* ]
|
|
145
|
+
* }
|
|
146
|
+
* },
|
|
147
|
+
* ]
|
|
148
|
+
* }
|
|
149
|
+
* }
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
interface Entity {
|
|
153
|
+
id: Maybe<string>;
|
|
154
|
+
aggregation: [number, number];
|
|
155
|
+
entities: Record<string, Entity[]>;
|
|
156
|
+
change: ChangeStatistic;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @public
|
|
161
|
+
*/
|
|
162
|
+
type Group = {
|
|
163
|
+
id: string;
|
|
164
|
+
name?: string;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @public
|
|
169
|
+
*/
|
|
170
|
+
interface MetricData {
|
|
171
|
+
id: string;
|
|
172
|
+
format: 'number' | 'currency';
|
|
173
|
+
aggregation: DateAggregation[];
|
|
174
|
+
change: ChangeStatistic;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @public
|
|
179
|
+
*/
|
|
180
|
+
type Metric = {
|
|
181
|
+
kind: string;
|
|
182
|
+
name: string;
|
|
183
|
+
default: boolean;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @public
|
|
188
|
+
*/
|
|
189
|
+
interface Product {
|
|
190
|
+
kind: string;
|
|
191
|
+
name: string;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* @public
|
|
196
|
+
*/
|
|
197
|
+
interface Project {
|
|
198
|
+
id: string;
|
|
199
|
+
name?: string;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export type { ChangeStatistic, Cost, DateAggregation, Entity, Group, Maybe, Metric, MetricData, Product, Project, Trendline };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@backstage-community/plugin-cost-insights-common",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Common functionalities for the cost-insights plugin",
|
|
5
|
+
"backstage": {
|
|
6
|
+
"role": "common-library"
|
|
7
|
+
},
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public",
|
|
10
|
+
"main": "dist/index.cjs.js",
|
|
11
|
+
"module": "dist/index.esm.js",
|
|
12
|
+
"types": "dist/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"backstage"
|
|
16
|
+
],
|
|
17
|
+
"homepage": "https://backstage.io",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/backstage/community-plugins",
|
|
21
|
+
"directory": "workspaces/cost-insights/plugins/cost-insights-common"
|
|
22
|
+
},
|
|
23
|
+
"license": "Apache-2.0",
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"main": "dist/index.cjs.js",
|
|
26
|
+
"types": "dist/index.d.ts",
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "backstage-cli package build",
|
|
32
|
+
"clean": "backstage-cli package clean",
|
|
33
|
+
"lint": "backstage-cli package lint",
|
|
34
|
+
"prepack": "backstage-cli package prepack",
|
|
35
|
+
"postpack": "backstage-cli package postpack",
|
|
36
|
+
"test": "backstage-cli package test"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@backstage/cli": "^0.26.3"
|
|
40
|
+
},
|
|
41
|
+
"module": "dist/index.esm.js"
|
|
42
|
+
}
|