From 3e032a5de26eb406031804c818112f1f9bd59e8b Mon Sep 17 00:00:00 2001 From: Andrew Thauer Date: Tue, 28 Jun 2022 19:42:52 -0400 Subject: [PATCH 1/7] refactor: create cost-insights-common isomorphic package This moves most of the cost-insights API types into a separate isomorphic @backstage/plugin-cost-insights-common package. This will allow these types to be used by a a cost-insights backend or other product specific modules. Signed-off-by: Andrew Thauer --- .changeset/afraid-flies-try.md | 7 + plugins/cost-insights-common/.eslintrc.js | 1 + plugins/cost-insights-common/CHANGELOG.md | 1 + plugins/cost-insights-common/README.md | 8 + plugins/cost-insights-common/api-report.md | 185 +++++++++++++++++ plugins/cost-insights-common/package.json | 42 ++++ plugins/cost-insights-common/src/index.ts | 23 +++ .../cost-insights-common/src/setupTests.ts | 17 ++ .../src/types/ChangeStatistic.ts | 24 +++ .../src/types/ChartData.ts} | 0 .../src/types/Cost.ts | 0 .../src/types/Currency.ts | 23 +++ .../src/types/DateAggregation.ts | 0 .../src/types/Duration.ts | 28 +++ .../src/types/Entity.ts | 0 .../src/types/Filters.ts | 0 .../src/types/Group.ts | 0 .../src/types/Maybe.ts | 0 .../src/types/Metric.ts | 0 .../src/types/MetricData.ts | 0 .../src/types/Product.ts | 0 .../src/types/Project.ts | 0 .../src/types/Trendline.ts | 0 .../cost-insights-common/src/types/index.ts | 31 +++ plugins/cost-insights/api-report.md | 193 ++---------------- plugins/cost-insights/package.json | 1 + plugins/cost-insights/src/types/Alert.ts | 9 +- .../src/types/ChangeStatistic.ts | 9 - plugins/cost-insights/src/types/Currency.ts | 8 - plugins/cost-insights/src/types/Duration.ts | 13 -- plugins/cost-insights/src/types/index.ts | 19 +- 31 files changed, 416 insertions(+), 226 deletions(-) create mode 100644 .changeset/afraid-flies-try.md create mode 100644 plugins/cost-insights-common/.eslintrc.js create mode 100644 plugins/cost-insights-common/CHANGELOG.md create mode 100644 plugins/cost-insights-common/README.md create mode 100644 plugins/cost-insights-common/api-report.md create mode 100644 plugins/cost-insights-common/package.json create mode 100644 plugins/cost-insights-common/src/index.ts create mode 100644 plugins/cost-insights-common/src/setupTests.ts create mode 100644 plugins/cost-insights-common/src/types/ChangeStatistic.ts rename plugins/{cost-insights/src/types/ChartData.tsx => cost-insights-common/src/types/ChartData.ts} (100%) rename plugins/{cost-insights => cost-insights-common}/src/types/Cost.ts (100%) create mode 100644 plugins/cost-insights-common/src/types/Currency.ts rename plugins/{cost-insights => cost-insights-common}/src/types/DateAggregation.ts (100%) create mode 100644 plugins/cost-insights-common/src/types/Duration.ts rename plugins/{cost-insights => cost-insights-common}/src/types/Entity.ts (100%) rename plugins/{cost-insights => cost-insights-common}/src/types/Filters.ts (100%) rename plugins/{cost-insights => cost-insights-common}/src/types/Group.ts (100%) rename plugins/{cost-insights => cost-insights-common}/src/types/Maybe.ts (100%) rename plugins/{cost-insights => cost-insights-common}/src/types/Metric.ts (100%) rename plugins/{cost-insights => cost-insights-common}/src/types/MetricData.ts (100%) rename plugins/{cost-insights => cost-insights-common}/src/types/Product.ts (100%) rename plugins/{cost-insights => cost-insights-common}/src/types/Project.ts (100%) rename plugins/{cost-insights => cost-insights-common}/src/types/Trendline.ts (100%) create mode 100644 plugins/cost-insights-common/src/types/index.ts diff --git a/.changeset/afraid-flies-try.md b/.changeset/afraid-flies-try.md new file mode 100644 index 0000000000..15d2e3942c --- /dev/null +++ b/.changeset/afraid-flies-try.md @@ -0,0 +1,7 @@ +--- +'@backstage/plugin-cost-insights': patch +--- + +Move cost-insights data specific API types (non react) into an @backstage/plugin-cost-insights-common +isomorphic package. This allows these types to be shared in any backend packages or other cost-insight +modules. diff --git a/plugins/cost-insights-common/.eslintrc.js b/plugins/cost-insights-common/.eslintrc.js new file mode 100644 index 0000000000..e2a53a6ad2 --- /dev/null +++ b/plugins/cost-insights-common/.eslintrc.js @@ -0,0 +1 @@ +module.exports = require('@backstage/cli/config/eslint-factory')(__dirname); diff --git a/plugins/cost-insights-common/CHANGELOG.md b/plugins/cost-insights-common/CHANGELOG.md new file mode 100644 index 0000000000..d958aaa41b --- /dev/null +++ b/plugins/cost-insights-common/CHANGELOG.md @@ -0,0 +1 @@ +# @backstage/plugin-cost-insights-common diff --git a/plugins/cost-insights-common/README.md b/plugins/cost-insights-common/README.md new file mode 100644 index 0000000000..5140701987 --- /dev/null +++ b/plugins/cost-insights-common/README.md @@ -0,0 +1,8 @@ +# Cost Insights Common + +Shared isomorphic code for the cost-insights plugin. + +## Links + +- [Frontend part of the plugin](https://github.com/backstage/backstage/tree/master/plugins/cost-insights) +- [The Backstage homepage](https://backstage.io) diff --git a/plugins/cost-insights-common/api-report.md b/plugins/cost-insights-common/api-report.md new file mode 100644 index 0000000000..af95e8765b --- /dev/null +++ b/plugins/cost-insights-common/api-report.md @@ -0,0 +1,185 @@ +## API Report File for "@backstage/plugin-cost-insights-common" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +// Warning: (ae-missing-release-tag) "ChangeStatistic" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface ChangeStatistic { + // (undocumented) + amount: number; + // (undocumented) + ratio?: number; +} + +// Warning: (ae-missing-release-tag) "ChartData" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type ChartData = { + date: number; + trend: number; + dailyCost: number; + [key: string]: number; +}; + +// Warning: (ae-missing-release-tag) "Cost" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface Cost { + // (undocumented) + aggregation: DateAggregation[]; + // (undocumented) + change?: ChangeStatistic; + // (undocumented) + groupedCosts?: Record; + // (undocumented) + id: string; + // (undocumented) + trendline?: Trendline; +} + +// Warning: (ae-missing-release-tag) "Currency" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface Currency { + // (undocumented) + kind: string | null; + // (undocumented) + label: string; + // (undocumented) + prefix?: string; + // (undocumented) + rate?: number; + // (undocumented) + unit: string; +} + +// Warning: (ae-missing-release-tag) "DateAggregation" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type DateAggregation = { + date: string; + amount: number; +}; + +// Warning: (ae-missing-release-tag) "Duration" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public +export enum Duration { + // (undocumented) + P30D = 'P30D', + // (undocumented) + P3M = 'P3M', + // (undocumented) + P7D = 'P7D', + // (undocumented) + P90D = 'P90D', +} + +// Warning: (ae-missing-release-tag) "Entity" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface Entity { + // (undocumented) + aggregation: [number, number]; + // (undocumented) + change: ChangeStatistic; + // (undocumented) + entities: Record; + // (undocumented) + id: Maybe; +} + +// Warning: (ae-missing-release-tag) "Group" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type Group = { + id: string; +}; + +// Warning: (ae-missing-release-tag) "Maybe" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type Maybe = T | null; + +// Warning: (ae-missing-release-tag) "Metric" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type Metric = { + kind: string; + name: string; + default: boolean; +}; + +// Warning: (ae-missing-release-tag) "MetricData" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface MetricData { + // (undocumented) + aggregation: DateAggregation[]; + // (undocumented) + change: ChangeStatistic; + // (undocumented) + format: 'number' | 'currency'; + // (undocumented) + id: string; +} + +// Warning: (ae-missing-release-tag) "PageFilters" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface PageFilters { + // (undocumented) + duration: Duration; + // (undocumented) + group: Maybe; + // (undocumented) + metric: string | null; + // (undocumented) + project: Maybe; +} + +// Warning: (ae-missing-release-tag) "Product" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface Product { + // (undocumented) + kind: string; + // (undocumented) + name: string; +} + +// Warning: (ae-missing-release-tag) "ProductFilters" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type ProductFilters = Array; + +// Warning: (ae-missing-release-tag) "ProductPeriod" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface ProductPeriod { + // (undocumented) + duration: Duration; + // (undocumented) + productType: string; +} + +// Warning: (ae-missing-release-tag) "Project" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export interface Project { + // (undocumented) + id: string; + // (undocumented) + name?: string; +} + +// Warning: (ae-missing-release-tag) "Trendline" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export type Trendline = { + slope: number; + intercept: number; +}; +``` diff --git a/plugins/cost-insights-common/package.json b/plugins/cost-insights-common/package.json new file mode 100644 index 0000000000..e950063efb --- /dev/null +++ b/plugins/cost-insights-common/package.json @@ -0,0 +1,42 @@ +{ + "name": "@backstage/plugin-cost-insights-common", + "description": "Common functionalities for the cost-insights plugin", + "version": "0.0.1", + "main": "src/index.ts", + "types": "src/index.ts", + "license": "Apache-2.0", + "private": false, + "publishConfig": { + "access": "public", + "main": "dist/index.cjs.js", + "module": "dist/index.esm.js", + "types": "dist/index.d.ts" + }, + "backstage": { + "role": "common-library" + }, + "homepage": "https://backstage.io", + "repository": { + "type": "git", + "url": "https://github.com/backstage/backstage", + "directory": "plugins/cost-insights-common" + }, + "keywords": [ + "backstage" + ], + "scripts": { + "build": "backstage-cli package build", + "lint": "backstage-cli package lint", + "test": "backstage-cli package test", + "prepack": "backstage-cli package prepack", + "postpack": "backstage-cli package postpack", + "clean": "backstage-cli package clean" + }, + "dependencies": {}, + "devDependencies": { + "@backstage/cli": "^0.18.0-next.1" + }, + "files": [ + "dist" + ] +} diff --git a/plugins/cost-insights-common/src/index.ts b/plugins/cost-insights-common/src/index.ts new file mode 100644 index 0000000000..c3c76ccf17 --- /dev/null +++ b/plugins/cost-insights-common/src/index.ts @@ -0,0 +1,23 @@ +/* + * Copyright 2022 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Provides shared objects useful for interacting with the cost-insights plugin. + * + * @packageDocumentation + */ + +export * from './types'; diff --git a/plugins/cost-insights-common/src/setupTests.ts b/plugins/cost-insights-common/src/setupTests.ts new file mode 100644 index 0000000000..813cdeaae3 --- /dev/null +++ b/plugins/cost-insights-common/src/setupTests.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2022 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export {}; diff --git a/plugins/cost-insights-common/src/types/ChangeStatistic.ts b/plugins/cost-insights-common/src/types/ChangeStatistic.ts new file mode 100644 index 0000000000..079d9bcb07 --- /dev/null +++ b/plugins/cost-insights-common/src/types/ChangeStatistic.ts @@ -0,0 +1,24 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface ChangeStatistic { + // The ratio of change from one duration to another, expressed as: (newSum - oldSum) / oldSum + // If a ratio cannot be calculated - such as when a new or old sum is zero, + // the ratio can be omitted and where applicable, ∞ or -∞ will display based on amount. + ratio?: number; + // The actual USD change between time periods (can be negative if costs decreased) + amount: number; +} diff --git a/plugins/cost-insights/src/types/ChartData.tsx b/plugins/cost-insights-common/src/types/ChartData.ts similarity index 100% rename from plugins/cost-insights/src/types/ChartData.tsx rename to plugins/cost-insights-common/src/types/ChartData.ts diff --git a/plugins/cost-insights/src/types/Cost.ts b/plugins/cost-insights-common/src/types/Cost.ts similarity index 100% rename from plugins/cost-insights/src/types/Cost.ts rename to plugins/cost-insights-common/src/types/Cost.ts diff --git a/plugins/cost-insights-common/src/types/Currency.ts b/plugins/cost-insights-common/src/types/Currency.ts new file mode 100644 index 0000000000..e82f0c9a52 --- /dev/null +++ b/plugins/cost-insights-common/src/types/Currency.ts @@ -0,0 +1,23 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface Currency { + kind: string | null; + label: string; + unit: string; + prefix?: string; + rate?: number; +} diff --git a/plugins/cost-insights/src/types/DateAggregation.ts b/plugins/cost-insights-common/src/types/DateAggregation.ts similarity index 100% rename from plugins/cost-insights/src/types/DateAggregation.ts rename to plugins/cost-insights-common/src/types/DateAggregation.ts diff --git a/plugins/cost-insights-common/src/types/Duration.ts b/plugins/cost-insights-common/src/types/Duration.ts new file mode 100644 index 0000000000..25806a3346 --- /dev/null +++ b/plugins/cost-insights-common/src/types/Duration.ts @@ -0,0 +1,28 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Time periods for cost comparison; slight abuse of ISO 8601 periods. We take P3M to mean + * 'last completed quarter', and P30D/P90D to be '[month|quarter] relative to today'. So if + * it's September 15, P3M represents costs for Q2 and P30D represents August 16 - + * September 15. + */ +export enum Duration { + P7D = 'P7D', + P30D = 'P30D', + P90D = 'P90D', + P3M = 'P3M', +} diff --git a/plugins/cost-insights/src/types/Entity.ts b/plugins/cost-insights-common/src/types/Entity.ts similarity index 100% rename from plugins/cost-insights/src/types/Entity.ts rename to plugins/cost-insights-common/src/types/Entity.ts diff --git a/plugins/cost-insights/src/types/Filters.ts b/plugins/cost-insights-common/src/types/Filters.ts similarity index 100% rename from plugins/cost-insights/src/types/Filters.ts rename to plugins/cost-insights-common/src/types/Filters.ts diff --git a/plugins/cost-insights/src/types/Group.ts b/plugins/cost-insights-common/src/types/Group.ts similarity index 100% rename from plugins/cost-insights/src/types/Group.ts rename to plugins/cost-insights-common/src/types/Group.ts diff --git a/plugins/cost-insights/src/types/Maybe.ts b/plugins/cost-insights-common/src/types/Maybe.ts similarity index 100% rename from plugins/cost-insights/src/types/Maybe.ts rename to plugins/cost-insights-common/src/types/Maybe.ts diff --git a/plugins/cost-insights/src/types/Metric.ts b/plugins/cost-insights-common/src/types/Metric.ts similarity index 100% rename from plugins/cost-insights/src/types/Metric.ts rename to plugins/cost-insights-common/src/types/Metric.ts diff --git a/plugins/cost-insights/src/types/MetricData.ts b/plugins/cost-insights-common/src/types/MetricData.ts similarity index 100% rename from plugins/cost-insights/src/types/MetricData.ts rename to plugins/cost-insights-common/src/types/MetricData.ts diff --git a/plugins/cost-insights/src/types/Product.ts b/plugins/cost-insights-common/src/types/Product.ts similarity index 100% rename from plugins/cost-insights/src/types/Product.ts rename to plugins/cost-insights-common/src/types/Product.ts diff --git a/plugins/cost-insights/src/types/Project.ts b/plugins/cost-insights-common/src/types/Project.ts similarity index 100% rename from plugins/cost-insights/src/types/Project.ts rename to plugins/cost-insights-common/src/types/Project.ts diff --git a/plugins/cost-insights/src/types/Trendline.ts b/plugins/cost-insights-common/src/types/Trendline.ts similarity index 100% rename from plugins/cost-insights/src/types/Trendline.ts rename to plugins/cost-insights-common/src/types/Trendline.ts diff --git a/plugins/cost-insights-common/src/types/index.ts b/plugins/cost-insights-common/src/types/index.ts new file mode 100644 index 0000000000..877ace8f5f --- /dev/null +++ b/plugins/cost-insights-common/src/types/index.ts @@ -0,0 +1,31 @@ +/* + * Copyright 2020 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from './ChangeStatistic'; +export * from './ChartData'; +export * from './Cost'; +export * from './DateAggregation'; +export * from './Duration'; +export * from './Currency'; +export * from './Entity'; +export * from './Filters'; +export * from './Group'; +export * from './Maybe'; +export * from './MetricData'; +export * from './Metric'; +export * from './Product'; +export * from './Project'; +export * from './Trendline'; diff --git a/plugins/cost-insights/api-report.md b/plugins/cost-insights/api-report.md index 75e1315502..8bde5729e7 100644 --- a/plugins/cost-insights/api-report.md +++ b/plugins/cost-insights/api-report.md @@ -9,10 +9,21 @@ import { ApiRef } from '@backstage/core-plugin-api'; import { BackstagePalette } from '@backstage/theme'; import { BackstagePlugin } from '@backstage/core-plugin-api'; import { BackstageTheme } from '@backstage/theme'; +import { ChangeStatistic } from '@backstage/plugin-cost-insights-common'; import { ContentRenderer } from 'recharts'; +import { Cost } from '@backstage/plugin-cost-insights-common'; +import { Currency } from '@backstage/plugin-cost-insights-common'; import { Dispatch } from 'react'; +import { Duration } from '@backstage/plugin-cost-insights-common'; +import { Entity } from '@backstage/plugin-cost-insights-common'; import { ForwardRefExoticComponent } from 'react'; +import { Group } from '@backstage/plugin-cost-insights-common'; +import { Maybe } from '@backstage/plugin-cost-insights-common'; +import { Metric } from '@backstage/plugin-cost-insights-common'; +import { MetricData } from '@backstage/plugin-cost-insights-common'; import { PaletteOptions } from '@material-ui/core/styles/createPalette'; +import { Product } from '@backstage/plugin-cost-insights-common'; +import { Project } from '@backstage/plugin-cost-insights-common'; import { PropsWithChildren } from 'react'; import { ReactNode } from 'react'; import { RechartsFunction } from 'recharts'; @@ -269,16 +280,6 @@ export type BarChartTooltipProps = { actions?: ReactNode; }; -// Warning: (ae-missing-release-tag) "ChangeStatistic" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface ChangeStatistic { - // (undocumented) - amount: number; - // (undocumented) - ratio?: number; -} - // Warning: (ae-missing-release-tag) "ChangeThreshold" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -289,32 +290,6 @@ export enum ChangeThreshold { upper = 0.05, } -// Warning: (ae-missing-release-tag) "ChartData" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type ChartData = { - date: number; - trend: number; - dailyCost: number; - [key: string]: number; -}; - -// Warning: (ae-missing-release-tag) "Cost" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface Cost { - // (undocumented) - aggregation: DateAggregation[]; - // (undocumented) - change?: ChangeStatistic; - // (undocumented) - groupedCosts?: Record; - // (undocumented) - id: string; - // (undocumented) - trendline?: Trendline; -} - // Warning: (ae-missing-release-tag) "CostGrowth" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -423,22 +398,6 @@ export interface CostInsightsThemeOptions extends PaletteOptions { palette: CostInsightsPaletteOptions; } -// Warning: (ae-missing-release-tag) "Currency" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface Currency { - // (undocumented) - kind: string | null; - // (undocumented) - label: string; - // (undocumented) - prefix?: string; - // (undocumented) - rate?: number; - // (undocumented) - unit: string; -} - // Warning: (ae-missing-release-tag) "CurrencyType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -465,52 +424,16 @@ export enum DataKey { Previous = 'previous', } -// Warning: (ae-missing-release-tag) "DateAggregation" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type DateAggregation = { - date: string; - amount: number; -}; - // Warning: (ae-missing-release-tag) "DEFAULT_DATE_FORMAT" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) export const DEFAULT_DATE_FORMAT = 'yyyy-LL-dd'; -// Warning: (ae-missing-release-tag) "Duration" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public -export enum Duration { - // (undocumented) - P30D = 'P30D', - // (undocumented) - P3M = 'P3M', - // (undocumented) - P7D = 'P7D', - // (undocumented) - P90D = 'P90D', -} - // Warning: (ae-missing-release-tag) "EngineerThreshold" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) export const EngineerThreshold = 0.5; -// Warning: (ae-missing-release-tag) "Entity" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface Entity { - // (undocumented) - aggregation: [number, number]; - // (undocumented) - change: ChangeStatistic; - // (undocumented) - entities: Record; - // (undocumented) - id: Maybe; -} - // Warning: (ae-missing-release-tag) "ExampleCostInsightsClient" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -533,13 +456,6 @@ export class ExampleCostInsightsClient implements CostInsightsApi { getUserGroups(userId: string): Promise; } -// Warning: (ae-missing-release-tag) "Group" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type Group = { - id: string; -}; - // Warning: (ae-missing-release-tag) "GrowthType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -602,34 +518,6 @@ export type LegendItemProps = { // @public (undocumented) export type Loading = Record; -// Warning: (ae-missing-release-tag) "Maybe" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type Maybe = T | null; - -// Warning: (ae-missing-release-tag) "Metric" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type Metric = { - kind: string; - name: string; - default: boolean; -}; - -// Warning: (ae-missing-release-tag) "MetricData" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface MetricData { - // (undocumented) - aggregation: DateAggregation[]; - // (undocumented) - change: ChangeStatistic; - // (undocumented) - format: 'number' | 'currency'; - // (undocumented) - id: string; -} - // Warning: (ae-forgotten-export) The symbol "MockConfigProviderProps" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "MockConfigProvider" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -648,35 +536,6 @@ export const MockCurrencyProvider: ({ ...context }: MockCurrencyProviderProps) => JSX.Element; -// Warning: (ae-missing-release-tag) "PageFilters" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface PageFilters { - // (undocumented) - duration: Duration; - // (undocumented) - group: Maybe; - // (undocumented) - metric: string | null; - // (undocumented) - project: Maybe; -} - -// Warning: (ae-missing-release-tag) "Product" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface Product { - // (undocumented) - kind: string; - // (undocumented) - name: string; -} - -// Warning: (ae-missing-release-tag) "ProductFilters" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type ProductFilters = Array; - // Warning: (ae-missing-release-tag) "ProductInsightsOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -687,26 +546,6 @@ export type ProductInsightsOptions = { project: Maybe; }; -// Warning: (ae-missing-release-tag) "ProductPeriod" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface ProductPeriod { - // (undocumented) - duration: Duration; - // (undocumented) - productType: string; -} - -// Warning: (ae-missing-release-tag) "Project" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export interface Project { - // (undocumented) - id: string; - // (undocumented) - name?: string; -} - // Warning: (ae-missing-release-tag) "ProjectGrowthAlert" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public @@ -763,14 +602,6 @@ export type TooltipItem = { value: string; }; -// Warning: (ae-missing-release-tag) "Trendline" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) -export type Trendline = { - slope: number; - intercept: number; -}; - // Warning: (ae-missing-release-tag) "UnlabeledDataflowAlert" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public @@ -817,4 +648,6 @@ export interface UnlabeledDataflowData { // (undocumented) unlabeledCost: number; } + +export * from '@backstage/plugin-cost-insights-common'; ``` diff --git a/plugins/cost-insights/package.json b/plugins/cost-insights/package.json index e2555d961f..4801a2002b 100644 --- a/plugins/cost-insights/package.json +++ b/plugins/cost-insights/package.json @@ -38,6 +38,7 @@ "@backstage/config": "^1.0.1", "@backstage/core-components": "^0.9.6-next.1", "@backstage/core-plugin-api": "^1.0.3", + "@backstage/plugin-cost-insights-common": "^0.0.1", "@backstage/theme": "^0.2.16-next.0", "@material-ui/core": "^4.12.2", "@material-ui/icons": "^4.9.1", diff --git a/plugins/cost-insights/src/types/Alert.ts b/plugins/cost-insights/src/types/Alert.ts index 2f220be0e6..a04becada1 100644 --- a/plugins/cost-insights/src/types/Alert.ts +++ b/plugins/cost-insights/src/types/Alert.ts @@ -13,10 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + import { ForwardRefExoticComponent, RefAttributes } from 'react'; -import { ChangeStatistic } from './ChangeStatistic'; -import { Duration } from './Duration'; -import { Maybe } from './Maybe'; +import { + ChangeStatistic, + Duration, + Maybe, +} from '@backstage/plugin-cost-insights-common'; /** * Generic alert type with required fields for display. The `element` field will be rendered in diff --git a/plugins/cost-insights/src/types/ChangeStatistic.ts b/plugins/cost-insights/src/types/ChangeStatistic.ts index 6e85335a67..8264b23c8d 100644 --- a/plugins/cost-insights/src/types/ChangeStatistic.ts +++ b/plugins/cost-insights/src/types/ChangeStatistic.ts @@ -14,15 +14,6 @@ * limitations under the License. */ -export interface ChangeStatistic { - // The ratio of change from one duration to another, expressed as: (newSum - oldSum) / oldSum - // If a ratio cannot be calculated - such as when a new or old sum is zero, - // the ratio can be omitted and where applicable, ∞ or -∞ will display based on amount. - ratio?: number; - // The actual USD change between time periods (can be negative if costs decreased) - amount: number; -} - export const EngineerThreshold = 0.5; export enum ChangeThreshold { diff --git a/plugins/cost-insights/src/types/Currency.ts b/plugins/cost-insights/src/types/Currency.ts index 5cc5756dfc..0316e8f90e 100644 --- a/plugins/cost-insights/src/types/Currency.ts +++ b/plugins/cost-insights/src/types/Currency.ts @@ -14,14 +14,6 @@ * limitations under the License. */ -export interface Currency { - kind: string | null; - label: string; - unit: string; - prefix?: string; - rate?: number; -} - export enum CurrencyType { USD = 'USD', CarbonOffsetTons = 'CARBON_OFFSET_TONS', diff --git a/plugins/cost-insights/src/types/Duration.ts b/plugins/cost-insights/src/types/Duration.ts index 94297ac00a..c5d9c83f6e 100644 --- a/plugins/cost-insights/src/types/Duration.ts +++ b/plugins/cost-insights/src/types/Duration.ts @@ -14,17 +14,4 @@ * limitations under the License. */ -/** - * Time periods for cost comparison; slight abuse of ISO 8601 periods. We take P3M to mean - * 'last completed quarter', and P30D/P90D to be '[month|quarter] relative to today'. So if - * it's September 15, P3M represents costs for Q2 and P30D represents August 16 - - * September 15. - */ -export enum Duration { - P7D = 'P7D', - P30D = 'P30D', - P90D = 'P90D', - P3M = 'P3M', -} - export const DEFAULT_DATE_FORMAT = 'yyyy-LL-dd'; diff --git a/plugins/cost-insights/src/types/index.ts b/plugins/cost-insights/src/types/index.ts index 5f090cc7eb..b3a06f248d 100644 --- a/plugins/cost-insights/src/types/index.ts +++ b/plugins/cost-insights/src/types/index.ts @@ -14,22 +14,15 @@ * limitations under the License. */ +// @deprecated - use types from `@backstage/plugin-cost-insights-common` instead. +export * from '@backstage/plugin-cost-insights-common'; + +// TODO: Split some of these up into `@backstage/plugin-cost-insights-react` for presentation types +// and `@backstage/plugin-cost-insights-common` for data transfer object types. export * from './Alert'; export * from './ChangeStatistic'; -export * from './ChartData'; -export * from './Cost'; -export * from './DateAggregation'; -export * from './Duration'; export * from './Currency'; -export * from './Entity'; +export * from './Duration'; export * from './Icon'; -export * from './Filters'; -export * from './Group'; export * from './Loading'; -export * from './Maybe'; -export * from './MetricData'; -export * from './Metric'; -export * from './Product'; -export * from './Project'; export * from './Theme'; -export * from './Trendline'; From e6db276347ab532249d455a7bf3d39a0d6b0f724 Mon Sep 17 00:00:00 2001 From: Andrew Thauer Date: Thu, 30 Jun 2022 09:38:41 -0400 Subject: [PATCH 2/7] update api report for cost-insight types Signed-off-by: Andrew Thauer --- plugins/cost-insights-common/api-report.md | 36 +--- .../src/types/ChangeStatistic.ts | 3 + .../src/types/ChartData.ts | 3 + .../cost-insights-common/src/types/Cost.ts | 3 + .../src/types/Currency.ts | 3 + .../src/types/DateAggregation.ts | 3 + .../src/types/Duration.ts | 1 + .../cost-insights-common/src/types/Entity.ts | 192 +++++++++--------- .../cost-insights-common/src/types/Filters.ts | 9 + .../cost-insights-common/src/types/Group.ts | 3 + .../cost-insights-common/src/types/Maybe.ts | 3 + .../cost-insights-common/src/types/Metric.ts | 3 + .../src/types/MetricData.ts | 3 + .../cost-insights-common/src/types/Product.ts | 3 + .../cost-insights-common/src/types/Project.ts | 3 + .../src/types/Trendline.ts | 4 + 16 files changed, 147 insertions(+), 128 deletions(-) diff --git a/plugins/cost-insights-common/api-report.md b/plugins/cost-insights-common/api-report.md index af95e8765b..daf8f5767d 100644 --- a/plugins/cost-insights-common/api-report.md +++ b/plugins/cost-insights-common/api-report.md @@ -3,8 +3,6 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -// Warning: (ae-missing-release-tag) "ChangeStatistic" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export interface ChangeStatistic { // (undocumented) @@ -13,8 +11,6 @@ export interface ChangeStatistic { ratio?: number; } -// Warning: (ae-missing-release-tag) "ChartData" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export type ChartData = { date: number; @@ -23,8 +19,6 @@ export type ChartData = { [key: string]: number; }; -// Warning: (ae-missing-release-tag) "Cost" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export interface Cost { // (undocumented) @@ -39,8 +33,6 @@ export interface Cost { trendline?: Trendline; } -// Warning: (ae-missing-release-tag) "Currency" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export interface Currency { // (undocumented) @@ -55,16 +47,12 @@ export interface Currency { unit: string; } -// Warning: (ae-missing-release-tag) "DateAggregation" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export type DateAggregation = { date: string; amount: number; }; -// Warning: (ae-missing-release-tag) "Duration" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public export enum Duration { // (undocumented) @@ -77,9 +65,7 @@ export enum Duration { P90D = 'P90D', } -// Warning: (ae-missing-release-tag) "Entity" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// -// @public (undocumented) +// @public export interface Entity { // (undocumented) aggregation: [number, number]; @@ -91,20 +77,14 @@ export interface Entity { id: Maybe; } -// Warning: (ae-missing-release-tag) "Group" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export type Group = { id: string; }; -// Warning: (ae-missing-release-tag) "Maybe" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export type Maybe = T | null; -// Warning: (ae-missing-release-tag) "Metric" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export type Metric = { kind: string; @@ -112,8 +92,6 @@ export type Metric = { default: boolean; }; -// Warning: (ae-missing-release-tag) "MetricData" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export interface MetricData { // (undocumented) @@ -126,8 +104,6 @@ export interface MetricData { id: string; } -// Warning: (ae-missing-release-tag) "PageFilters" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export interface PageFilters { // (undocumented) @@ -140,8 +116,6 @@ export interface PageFilters { project: Maybe; } -// Warning: (ae-missing-release-tag) "Product" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export interface Product { // (undocumented) @@ -150,13 +124,9 @@ export interface Product { name: string; } -// Warning: (ae-missing-release-tag) "ProductFilters" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export type ProductFilters = Array; -// Warning: (ae-missing-release-tag) "ProductPeriod" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export interface ProductPeriod { // (undocumented) @@ -165,8 +135,6 @@ export interface ProductPeriod { productType: string; } -// Warning: (ae-missing-release-tag) "Project" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export interface Project { // (undocumented) @@ -175,8 +143,6 @@ export interface Project { name?: string; } -// Warning: (ae-missing-release-tag) "Trendline" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) export type Trendline = { slope: number; diff --git a/plugins/cost-insights-common/src/types/ChangeStatistic.ts b/plugins/cost-insights-common/src/types/ChangeStatistic.ts index 079d9bcb07..29be6e9367 100644 --- a/plugins/cost-insights-common/src/types/ChangeStatistic.ts +++ b/plugins/cost-insights-common/src/types/ChangeStatistic.ts @@ -14,6 +14,9 @@ * limitations under the License. */ +/** + * @public + */ export interface ChangeStatistic { // The ratio of change from one duration to another, expressed as: (newSum - oldSum) / oldSum // If a ratio cannot be calculated - such as when a new or old sum is zero, diff --git a/plugins/cost-insights-common/src/types/ChartData.ts b/plugins/cost-insights-common/src/types/ChartData.ts index 9de8af496d..f4ae204a22 100644 --- a/plugins/cost-insights-common/src/types/ChartData.ts +++ b/plugins/cost-insights-common/src/types/ChartData.ts @@ -14,6 +14,9 @@ * limitations under the License. */ +/** + * @public + */ export type ChartData = { date: number; trend: number; diff --git a/plugins/cost-insights-common/src/types/Cost.ts b/plugins/cost-insights-common/src/types/Cost.ts index 2ae4755bc7..90ccbe17c0 100644 --- a/plugins/cost-insights-common/src/types/Cost.ts +++ b/plugins/cost-insights-common/src/types/Cost.ts @@ -18,6 +18,9 @@ import { DateAggregation } from './DateAggregation'; import { ChangeStatistic } from './ChangeStatistic'; import { Trendline } from './Trendline'; +/** + * @public + */ export interface Cost { id: string; aggregation: DateAggregation[]; diff --git a/plugins/cost-insights-common/src/types/Currency.ts b/plugins/cost-insights-common/src/types/Currency.ts index e82f0c9a52..4bd1490a69 100644 --- a/plugins/cost-insights-common/src/types/Currency.ts +++ b/plugins/cost-insights-common/src/types/Currency.ts @@ -14,6 +14,9 @@ * limitations under the License. */ +/** + * @public + */ export interface Currency { kind: string | null; label: string; diff --git a/plugins/cost-insights-common/src/types/DateAggregation.ts b/plugins/cost-insights-common/src/types/DateAggregation.ts index 72a2514006..4faed85241 100644 --- a/plugins/cost-insights-common/src/types/DateAggregation.ts +++ b/plugins/cost-insights-common/src/types/DateAggregation.ts @@ -14,6 +14,9 @@ * limitations under the License. */ +/** + * @public + */ export type DateAggregation = { date: string; // YYYY-MM-DD amount: number; diff --git a/plugins/cost-insights-common/src/types/Duration.ts b/plugins/cost-insights-common/src/types/Duration.ts index 25806a3346..3a4c7a3a9f 100644 --- a/plugins/cost-insights-common/src/types/Duration.ts +++ b/plugins/cost-insights-common/src/types/Duration.ts @@ -19,6 +19,7 @@ * 'last completed quarter', and P30D/P90D to be '[month|quarter] relative to today'. So if * it's September 15, P3M represents costs for Q2 and P30D represents August 16 - * September 15. + * @public */ export enum Duration { P7D = 'P7D', diff --git a/plugins/cost-insights-common/src/types/Entity.ts b/plugins/cost-insights-common/src/types/Entity.ts index ccfea6667e..9a6d6746aa 100644 --- a/plugins/cost-insights-common/src/types/Entity.ts +++ b/plugins/cost-insights-common/src/types/Entity.ts @@ -17,102 +17,108 @@ import { ChangeStatistic } from './ChangeStatistic'; import { Maybe } from './Maybe'; +/** + * + * An entity is a tree-like structure that represents any unique + * product or service that generates cost over a fixed period of time. + * An entity could be atomic or composite. An atomic entity is indivisible + * and cannot be broken into sub-entities. + * + * A composite entity is divided into sub-entities that account for portions + * of the total cost **over the same time period**. The root entity is + * expected to only have _one_ Record consisting of the sub-entities to display + * in the product panel (keyed by the entity type, such as "service" for + * compute entities). + * + * The root sub-entities may have multiple breakdowns - for example, a + * breakdown of an entity cost by SKU vs deployment environment. The sum + * aggregated cost of each keyed breakdown should equal the sub-entity's cost. + * + * Entities with null ids are considered "unlabeled" - costs without attribution. + * If an entity is a composite, it may only have one (1) null child but may have any number of + * null grandchildren. + * + * @public + * + * @example + * Here's an example composite entity: + * ``` + * const compositeEntity = { + * id: 'product', + * aggregation: [0, 200], + * change: { + * ratio: 2000, + * amount: 200 + * }, + * entities: { + * service: [ + * { + * id: 'service-a', + * aggregation: [0, 100], + * change: { + * ratio: 100, + * amount: 100 + * }, + * entities: {} + * }, + * { + * id: 'service-b', + * aggregation: [0, 100], + * change: { + * ratio: 100, + * amount: 100 + * }, + * entities: { + * SKU: [ + * { + * id: 'service-b-sku-a', + * aggregation: [0, 25], + * change: { + * ratio: 25, + * amount: 25 + * }, + * entities: {} + * }, + * { + * id: null, // Unlabeled cost for service-b + * aggregation: [0, 75], + * change: { + * ratio: 75, + * amount: 75 + * }, + * entities: {} + * }, + * ], + * deployment: [ + * { + * id: 'service-b-env-a', + * aggregation: [0, 50], + * change: { + * ratio: 50, + * amount: 50 + * }, + * entities: {} + * }, + * { + * id: 'service-b-env-b', + * aggregation: [0, 50], + * change: { + * ratio: 50, + * amount: 50 + * }, + * entities: {} + * }, + * ] + * } + * }, + * ] + * } + * } + * ``` + */ export interface Entity { id: Maybe; aggregation: [number, number]; entities: Record; change: ChangeStatistic; } - -/* - An entity is a tree-like structure that represents any unique - product or service that generates cost over a fixed period of time. - An entity could be atomic or composite. An atomic entity is indivisible - and cannot be broken into sub-entities. - - A composite entity is divided into sub-entities that account for portions - of the total cost **over the same time period**. The root entity is - expected to only have _one_ Record consisting of the sub-entities to display - in the product panel (keyed by the entity type, such as "service" for - compute entities). - - The root sub-entities may have multiple breakdowns - for example, a - breakdown of an entity cost by SKU vs deployment environment. The sum - aggregated cost of each keyed breakdown should equal the sub-entity's cost. - - Entities with null ids are considered "unlabeled" - costs without attribution. - If an entity is a composite, it may only have one (1) null child but may have any number of - null grandchildren. - - { - id: 'product', - aggregation: [0, 200], - change: { - ratio: 2000, - amount: 200 - }, - entities: { - service: [ - { - id: 'service-a', - aggregation: [0, 100], - change: { - ratio: 100, - amount: 100 - }, - entities: {} - }, - { - id: 'service-b', - aggregation: [0, 100], - change: { - ratio: 100, - amount: 100 - }, - entities: { - SKU: [ - { - id: 'service-b-sku-a', - aggregation: [0, 25], - change: { - ratio: 25, - amount: 25 - }, - entities: {} - }, - { - id: null, // Unlabeled cost for service-b - aggregation: [0, 75], - change: { - ratio: 75, - amount: 75 - }, - entities: {} - }, - ], - deployment: [ - { - id: 'service-b-env-a', - aggregation: [0, 50], - change: { - ratio: 50, - amount: 50 - }, - entities: {} - }, - { - id: 'service-b-env-b', - aggregation: [0, 50], - change: { - ratio: 50, - amount: 50 - }, - entities: {} - }, - ] - } - }, - ] - } - } -*/ diff --git a/plugins/cost-insights-common/src/types/Filters.ts b/plugins/cost-insights-common/src/types/Filters.ts index 6beef5cacc..67cbb6ce2f 100644 --- a/plugins/cost-insights-common/src/types/Filters.ts +++ b/plugins/cost-insights-common/src/types/Filters.ts @@ -17,6 +17,9 @@ import { Maybe } from './Maybe'; import { Duration } from './Duration'; +/** + * @public + */ export interface PageFilters { group: Maybe; project: Maybe; @@ -24,8 +27,14 @@ export interface PageFilters { metric: string | null; } +/** + * @public + */ export type ProductFilters = Array; +/** + * @public + */ export interface ProductPeriod { duration: Duration; productType: string; diff --git a/plugins/cost-insights-common/src/types/Group.ts b/plugins/cost-insights-common/src/types/Group.ts index 8e0c768924..b34cac083f 100644 --- a/plugins/cost-insights-common/src/types/Group.ts +++ b/plugins/cost-insights-common/src/types/Group.ts @@ -14,6 +14,9 @@ * limitations under the License. */ +/** + * @public + */ export type Group = { id: string; }; diff --git a/plugins/cost-insights-common/src/types/Maybe.ts b/plugins/cost-insights-common/src/types/Maybe.ts index 461c31f6a5..824c64c334 100644 --- a/plugins/cost-insights-common/src/types/Maybe.ts +++ b/plugins/cost-insights-common/src/types/Maybe.ts @@ -14,4 +14,7 @@ * limitations under the License. */ +/** + * @public + */ export type Maybe = T | null; diff --git a/plugins/cost-insights-common/src/types/Metric.ts b/plugins/cost-insights-common/src/types/Metric.ts index 107513b80d..901d40f106 100644 --- a/plugins/cost-insights-common/src/types/Metric.ts +++ b/plugins/cost-insights-common/src/types/Metric.ts @@ -14,6 +14,9 @@ * limitations under the License. */ +/** + * @public + */ export type Metric = { kind: string; name: string; diff --git a/plugins/cost-insights-common/src/types/MetricData.ts b/plugins/cost-insights-common/src/types/MetricData.ts index 225da185f8..56742e76e9 100644 --- a/plugins/cost-insights-common/src/types/MetricData.ts +++ b/plugins/cost-insights-common/src/types/MetricData.ts @@ -17,6 +17,9 @@ import { DateAggregation } from './DateAggregation'; import { ChangeStatistic } from './ChangeStatistic'; +/** + * @public + */ export interface MetricData { id: string; format: 'number' | 'currency'; diff --git a/plugins/cost-insights-common/src/types/Product.ts b/plugins/cost-insights-common/src/types/Product.ts index 9920841223..7ed49c18da 100644 --- a/plugins/cost-insights-common/src/types/Product.ts +++ b/plugins/cost-insights-common/src/types/Product.ts @@ -14,6 +14,9 @@ * limitations under the License. */ +/** + * @public + */ export interface Product { kind: string; name: string; diff --git a/plugins/cost-insights-common/src/types/Project.ts b/plugins/cost-insights-common/src/types/Project.ts index c12a3f1fa2..6cad92ed46 100644 --- a/plugins/cost-insights-common/src/types/Project.ts +++ b/plugins/cost-insights-common/src/types/Project.ts @@ -14,6 +14,9 @@ * limitations under the License. */ +/** + * @public + */ export interface Project { id: string; name?: string; diff --git a/plugins/cost-insights-common/src/types/Trendline.ts b/plugins/cost-insights-common/src/types/Trendline.ts index 64405678f1..3a7e372880 100644 --- a/plugins/cost-insights-common/src/types/Trendline.ts +++ b/plugins/cost-insights-common/src/types/Trendline.ts @@ -13,6 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +/** + * @public + */ export type Trendline = { slope: number; intercept: number; From 81dd5ea9890609131719263a907b32551d8e801d Mon Sep 17 00:00:00 2001 From: Andrew Thauer Date: Thu, 30 Jun 2022 09:44:07 -0400 Subject: [PATCH 3/7] add changeset for new cost-insights-common package Signed-off-by: Andrew Thauer --- .changeset/light-hornets-eat.md | 5 +++++ plugins/cost-insights-common/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/light-hornets-eat.md diff --git a/.changeset/light-hornets-eat.md b/.changeset/light-hornets-eat.md new file mode 100644 index 0000000000..795e51fb67 --- /dev/null +++ b/.changeset/light-hornets-eat.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-cost-insights-common': minor +--- + +Introduces a new isomorphic @backstage/plugin-cost-insight-common package to contain shared types across all other cost insights packages and modules. diff --git a/plugins/cost-insights-common/package.json b/plugins/cost-insights-common/package.json index e950063efb..c15f063fd2 100644 --- a/plugins/cost-insights-common/package.json +++ b/plugins/cost-insights-common/package.json @@ -1,7 +1,7 @@ { "name": "@backstage/plugin-cost-insights-common", "description": "Common functionalities for the cost-insights plugin", - "version": "0.0.1", + "version": "0.0.0", "main": "src/index.ts", "types": "src/index.ts", "license": "Apache-2.0", From c380ea795eb3876a6b50ce602f33dc1065bc578f Mon Sep 17 00:00:00 2001 From: Andrew Thauer Date: Thu, 30 Jun 2022 10:25:59 -0400 Subject: [PATCH 4/7] update cost-insights api docs Signed-off-by: Andrew Thauer --- plugins/cost-insights-common/api-report.md | 2 -- .../src/types/ChangeStatistic.ts | 13 +++++++++---- .../src/types/DateAggregation.ts | 7 ++++++- plugins/cost-insights-common/src/types/Duration.ts | 1 + 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/plugins/cost-insights-common/api-report.md b/plugins/cost-insights-common/api-report.md index daf8f5767d..1f54bece3e 100644 --- a/plugins/cost-insights-common/api-report.md +++ b/plugins/cost-insights-common/api-report.md @@ -5,9 +5,7 @@ ```ts // @public (undocumented) export interface ChangeStatistic { - // (undocumented) amount: number; - // (undocumented) ratio?: number; } diff --git a/plugins/cost-insights-common/src/types/ChangeStatistic.ts b/plugins/cost-insights-common/src/types/ChangeStatistic.ts index 29be6e9367..8d64fb47f9 100644 --- a/plugins/cost-insights-common/src/types/ChangeStatistic.ts +++ b/plugins/cost-insights-common/src/types/ChangeStatistic.ts @@ -18,10 +18,15 @@ * @public */ export interface ChangeStatistic { - // The ratio of change from one duration to another, expressed as: (newSum - oldSum) / oldSum - // If a ratio cannot be calculated - such as when a new or old sum is zero, - // the ratio can be omitted and where applicable, ∞ or -∞ will display based on amount. + /** + * The ratio of change from one duration to another, expressed as: (newSum - oldSum) / oldSum + * If a ratio cannot be calculated - such as when a new or old sum is zero, + * the ratio can be omitted and where applicable, ∞ or -∞ will display based on amount. + */ ratio?: number; - // The actual USD change between time periods (can be negative if costs decreased) + + /** + * The actual USD change between time periods (can be negative if costs decreased) + */ amount: number; } diff --git a/plugins/cost-insights-common/src/types/DateAggregation.ts b/plugins/cost-insights-common/src/types/DateAggregation.ts index 4faed85241..edc867a7bf 100644 --- a/plugins/cost-insights-common/src/types/DateAggregation.ts +++ b/plugins/cost-insights-common/src/types/DateAggregation.ts @@ -18,6 +18,11 @@ * @public */ export type DateAggregation = { - date: string; // YYYY-MM-DD + /** + * The date aggregation as string. + * @example YYYY-MM-DD + */ + date: string; + amount: number; }; diff --git a/plugins/cost-insights-common/src/types/Duration.ts b/plugins/cost-insights-common/src/types/Duration.ts index 3a4c7a3a9f..dbb226df24 100644 --- a/plugins/cost-insights-common/src/types/Duration.ts +++ b/plugins/cost-insights-common/src/types/Duration.ts @@ -19,6 +19,7 @@ * 'last completed quarter', and P30D/P90D to be '[month|quarter] relative to today'. So if * it's September 15, P3M represents costs for Q2 and P30D represents August 16 - * September 15. + * * @public */ export enum Duration { From 66ef0326315b90b75a4b64a971478b1c555ec5c0 Mon Sep 17 00:00:00 2001 From: Andrew Thauer Date: Thu, 30 Jun 2022 14:21:35 -0400 Subject: [PATCH 5/7] move frontend types back into cost-insights Signed-off-by: Andrew Thauer --- .../cost-insights-common/src/types/index.ts | 4 --- plugins/cost-insights/package.json | 2 +- plugins/cost-insights/src/types/Alert.ts | 7 ++--- .../src/types/ChartData.ts | 0 plugins/cost-insights/src/types/Currency.ts | 14 +++++---- .../src/types/CurrencyType.ts} | 14 ++++----- .../src/types/DateFormat.ts} | 15 +--------- plugins/cost-insights/src/types/Duration.ts | 15 +++++++++- .../src/types/Filters.ts | 2 +- plugins/cost-insights/src/types/index.ts | 29 +++++++++++++++++-- 10 files changed, 60 insertions(+), 42 deletions(-) rename plugins/{cost-insights-common => cost-insights}/src/types/ChartData.ts (100%) rename plugins/{cost-insights-common/src/types/Currency.ts => cost-insights/src/types/CurrencyType.ts} (81%) rename plugins/{cost-insights-common/src/types/Duration.ts => cost-insights/src/types/DateFormat.ts} (60%) rename plugins/{cost-insights-common => cost-insights}/src/types/Filters.ts (93%) diff --git a/plugins/cost-insights-common/src/types/index.ts b/plugins/cost-insights-common/src/types/index.ts index 877ace8f5f..86e7af33aa 100644 --- a/plugins/cost-insights-common/src/types/index.ts +++ b/plugins/cost-insights-common/src/types/index.ts @@ -15,13 +15,9 @@ */ export * from './ChangeStatistic'; -export * from './ChartData'; export * from './Cost'; export * from './DateAggregation'; -export * from './Duration'; -export * from './Currency'; export * from './Entity'; -export * from './Filters'; export * from './Group'; export * from './Maybe'; export * from './MetricData'; diff --git a/plugins/cost-insights/package.json b/plugins/cost-insights/package.json index 4801a2002b..d7a04eddbc 100644 --- a/plugins/cost-insights/package.json +++ b/plugins/cost-insights/package.json @@ -38,7 +38,7 @@ "@backstage/config": "^1.0.1", "@backstage/core-components": "^0.9.6-next.1", "@backstage/core-plugin-api": "^1.0.3", - "@backstage/plugin-cost-insights-common": "^0.0.1", + "@backstage/plugin-cost-insights-common": "^0.0.0", "@backstage/theme": "^0.2.16-next.0", "@material-ui/core": "^4.12.2", "@material-ui/icons": "^4.9.1", diff --git a/plugins/cost-insights/src/types/Alert.ts b/plugins/cost-insights/src/types/Alert.ts index a04becada1..483b9a654d 100644 --- a/plugins/cost-insights/src/types/Alert.ts +++ b/plugins/cost-insights/src/types/Alert.ts @@ -15,11 +15,8 @@ */ import { ForwardRefExoticComponent, RefAttributes } from 'react'; -import { - ChangeStatistic, - Duration, - Maybe, -} from '@backstage/plugin-cost-insights-common'; +import { ChangeStatistic, Maybe } from '@backstage/plugin-cost-insights-common'; +import { Duration } from './Duration'; /** * Generic alert type with required fields for display. The `element` field will be rendered in diff --git a/plugins/cost-insights-common/src/types/ChartData.ts b/plugins/cost-insights/src/types/ChartData.ts similarity index 100% rename from plugins/cost-insights-common/src/types/ChartData.ts rename to plugins/cost-insights/src/types/ChartData.ts diff --git a/plugins/cost-insights/src/types/Currency.ts b/plugins/cost-insights/src/types/Currency.ts index 0316e8f90e..4bd1490a69 100644 --- a/plugins/cost-insights/src/types/Currency.ts +++ b/plugins/cost-insights/src/types/Currency.ts @@ -14,9 +14,13 @@ * limitations under the License. */ -export enum CurrencyType { - USD = 'USD', - CarbonOffsetTons = 'CARBON_OFFSET_TONS', - Beers = 'BEERS', - IceCream = 'PINTS_OF_ICE_CREAM', +/** + * @public + */ +export interface Currency { + kind: string | null; + label: string; + unit: string; + prefix?: string; + rate?: number; } diff --git a/plugins/cost-insights-common/src/types/Currency.ts b/plugins/cost-insights/src/types/CurrencyType.ts similarity index 81% rename from plugins/cost-insights-common/src/types/Currency.ts rename to plugins/cost-insights/src/types/CurrencyType.ts index 4bd1490a69..0316e8f90e 100644 --- a/plugins/cost-insights-common/src/types/Currency.ts +++ b/plugins/cost-insights/src/types/CurrencyType.ts @@ -14,13 +14,9 @@ * limitations under the License. */ -/** - * @public - */ -export interface Currency { - kind: string | null; - label: string; - unit: string; - prefix?: string; - rate?: number; +export enum CurrencyType { + USD = 'USD', + CarbonOffsetTons = 'CARBON_OFFSET_TONS', + Beers = 'BEERS', + IceCream = 'PINTS_OF_ICE_CREAM', } diff --git a/plugins/cost-insights-common/src/types/Duration.ts b/plugins/cost-insights/src/types/DateFormat.ts similarity index 60% rename from plugins/cost-insights-common/src/types/Duration.ts rename to plugins/cost-insights/src/types/DateFormat.ts index dbb226df24..c5d9c83f6e 100644 --- a/plugins/cost-insights-common/src/types/Duration.ts +++ b/plugins/cost-insights/src/types/DateFormat.ts @@ -14,17 +14,4 @@ * limitations under the License. */ -/** - * Time periods for cost comparison; slight abuse of ISO 8601 periods. We take P3M to mean - * 'last completed quarter', and P30D/P90D to be '[month|quarter] relative to today'. So if - * it's September 15, P3M represents costs for Q2 and P30D represents August 16 - - * September 15. - * - * @public - */ -export enum Duration { - P7D = 'P7D', - P30D = 'P30D', - P90D = 'P90D', - P3M = 'P3M', -} +export const DEFAULT_DATE_FORMAT = 'yyyy-LL-dd'; diff --git a/plugins/cost-insights/src/types/Duration.ts b/plugins/cost-insights/src/types/Duration.ts index c5d9c83f6e..dbb226df24 100644 --- a/plugins/cost-insights/src/types/Duration.ts +++ b/plugins/cost-insights/src/types/Duration.ts @@ -14,4 +14,17 @@ * limitations under the License. */ -export const DEFAULT_DATE_FORMAT = 'yyyy-LL-dd'; +/** + * Time periods for cost comparison; slight abuse of ISO 8601 periods. We take P3M to mean + * 'last completed quarter', and P30D/P90D to be '[month|quarter] relative to today'. So if + * it's September 15, P3M represents costs for Q2 and P30D represents August 16 - + * September 15. + * + * @public + */ +export enum Duration { + P7D = 'P7D', + P30D = 'P30D', + P90D = 'P90D', + P3M = 'P3M', +} diff --git a/plugins/cost-insights-common/src/types/Filters.ts b/plugins/cost-insights/src/types/Filters.ts similarity index 93% rename from plugins/cost-insights-common/src/types/Filters.ts rename to plugins/cost-insights/src/types/Filters.ts index 67cbb6ce2f..d307243ad0 100644 --- a/plugins/cost-insights-common/src/types/Filters.ts +++ b/plugins/cost-insights/src/types/Filters.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Maybe } from './Maybe'; +import { Maybe } from '@backstage/plugin-cost-insights-common'; import { Duration } from './Duration'; /** diff --git a/plugins/cost-insights/src/types/index.ts b/plugins/cost-insights/src/types/index.ts index b3a06f248d..57711b4eee 100644 --- a/plugins/cost-insights/src/types/index.ts +++ b/plugins/cost-insights/src/types/index.ts @@ -14,15 +14,40 @@ * limitations under the License. */ -// @deprecated - use types from `@backstage/plugin-cost-insights-common` instead. -export * from '@backstage/plugin-cost-insights-common'; +import * as common from '@backstage/plugin-cost-insights-common'; +/** * @deprecated use the same type from @backstage/plugin-cost-insights-common instead */ +export type ChangeStatistic = common.ChangeStatistic; +/** * @deprecated use the same type from @backstage/plugin-cost-insights-common instead */ +export type Cost = common.Cost; +/** * @deprecated use the same type from @backstage/plugin-cost-insights-common instead */ +export type DateAggregation = common.DateAggregation; +/** * @deprecated use the same type from @backstage/plugin-cost-insights-common instead */ +export type Entity = common.Entity; +/** * @deprecated use the same type from @backstage/plugin-cost-insights-common instead */ +export type Group = common.Group; +/** * @deprecated use the same type from @backstage/plugin-cost-insights-common instead */ +export type Maybe = common.Maybe; +/** * @deprecated use the same type from @backstage/plugin-cost-insights-common instead */ +export type Metric = common.Metric; +/** * @deprecated use the same type from @backstage/plugin-cost-insights-common instead */ +export type MetricData = common.MetricData; +/** * @deprecated use the same type from @backstage/plugin-cost-insights-common instead */ +export type Product = common.Product; +/** * @deprecated use the same type from @backstage/plugin-cost-insights-common instead */ +export type Project = common.Project; +/** * @deprecated use the same type from @backstage/plugin-cost-insights-common instead */ +export type Trendline = common.Trendline; // TODO: Split some of these up into `@backstage/plugin-cost-insights-react` for presentation types // and `@backstage/plugin-cost-insights-common` for data transfer object types. export * from './Alert'; export * from './ChangeStatistic'; +export * from './ChartData'; export * from './Currency'; +export * from './CurrencyType'; +export * from './DateFormat'; export * from './Duration'; +export * from './Filters'; export * from './Icon'; export * from './Loading'; export * from './Theme'; From 6f7ef41351a701aa2619dd64fe5390dd2bb54f42 Mon Sep 17 00:00:00 2001 From: Andrew Thauer Date: Thu, 30 Jun 2022 15:38:03 -0400 Subject: [PATCH 6/7] update cost-insights api docs Signed-off-by: Andrew Thauer --- plugins/cost-insights-common/api-report.md | 57 -------- plugins/cost-insights/api-report.md | 153 ++++++++++++++++++--- 2 files changed, 133 insertions(+), 77 deletions(-) diff --git a/plugins/cost-insights-common/api-report.md b/plugins/cost-insights-common/api-report.md index 1f54bece3e..a5f7045854 100644 --- a/plugins/cost-insights-common/api-report.md +++ b/plugins/cost-insights-common/api-report.md @@ -9,14 +9,6 @@ export interface ChangeStatistic { ratio?: number; } -// @public (undocumented) -export type ChartData = { - date: number; - trend: number; - dailyCost: number; - [key: string]: number; -}; - // @public (undocumented) export interface Cost { // (undocumented) @@ -31,38 +23,12 @@ export interface Cost { trendline?: Trendline; } -// @public (undocumented) -export interface Currency { - // (undocumented) - kind: string | null; - // (undocumented) - label: string; - // (undocumented) - prefix?: string; - // (undocumented) - rate?: number; - // (undocumented) - unit: string; -} - // @public (undocumented) export type DateAggregation = { date: string; amount: number; }; -// @public -export enum Duration { - // (undocumented) - P30D = 'P30D', - // (undocumented) - P3M = 'P3M', - // (undocumented) - P7D = 'P7D', - // (undocumented) - P90D = 'P90D', -} - // @public export interface Entity { // (undocumented) @@ -102,18 +68,6 @@ export interface MetricData { id: string; } -// @public (undocumented) -export interface PageFilters { - // (undocumented) - duration: Duration; - // (undocumented) - group: Maybe; - // (undocumented) - metric: string | null; - // (undocumented) - project: Maybe; -} - // @public (undocumented) export interface Product { // (undocumented) @@ -122,17 +76,6 @@ export interface Product { name: string; } -// @public (undocumented) -export type ProductFilters = Array; - -// @public (undocumented) -export interface ProductPeriod { - // (undocumented) - duration: Duration; - // (undocumented) - productType: string; -} - // @public (undocumented) export interface Project { // (undocumented) diff --git a/plugins/cost-insights/api-report.md b/plugins/cost-insights/api-report.md index 8bde5729e7..a646cddeab 100644 --- a/plugins/cost-insights/api-report.md +++ b/plugins/cost-insights/api-report.md @@ -9,21 +9,13 @@ import { ApiRef } from '@backstage/core-plugin-api'; import { BackstagePalette } from '@backstage/theme'; import { BackstagePlugin } from '@backstage/core-plugin-api'; import { BackstageTheme } from '@backstage/theme'; -import { ChangeStatistic } from '@backstage/plugin-cost-insights-common'; +import { ChangeStatistic as ChangeStatistic_2 } from '@backstage/plugin-cost-insights-common'; +import * as common from '@backstage/plugin-cost-insights-common'; import { ContentRenderer } from 'recharts'; -import { Cost } from '@backstage/plugin-cost-insights-common'; -import { Currency } from '@backstage/plugin-cost-insights-common'; import { Dispatch } from 'react'; -import { Duration } from '@backstage/plugin-cost-insights-common'; -import { Entity } from '@backstage/plugin-cost-insights-common'; import { ForwardRefExoticComponent } from 'react'; -import { Group } from '@backstage/plugin-cost-insights-common'; -import { Maybe } from '@backstage/plugin-cost-insights-common'; -import { Metric } from '@backstage/plugin-cost-insights-common'; -import { MetricData } from '@backstage/plugin-cost-insights-common'; +import { Maybe as Maybe_2 } from '@backstage/plugin-cost-insights-common'; import { PaletteOptions } from '@material-ui/core/styles/createPalette'; -import { Product } from '@backstage/plugin-cost-insights-common'; -import { Project } from '@backstage/plugin-cost-insights-common'; import { PropsWithChildren } from 'react'; import { ReactNode } from 'react'; import { RechartsFunction } from 'recharts'; @@ -43,9 +35,9 @@ export type Alert = { status?: AlertStatus; url?: string; buttonText?: string; - SnoozeForm?: Maybe; - AcceptForm?: Maybe; - DismissForm?: Maybe; + SnoozeForm?: Maybe_2; + AcceptForm?: Maybe_2; + DismissForm?: Maybe_2; onSnoozed?(options: AlertOptions): Promise; onAccepted?(options: AlertOptions): Promise; onDismissed?(options: AlertOptions): Promise; @@ -66,9 +58,9 @@ export interface AlertCost { // @public (undocumented) export interface AlertDismissFormData { // (undocumented) - feedback: Maybe; + feedback: Maybe_2; // (undocumented) - other: Maybe; + other: Maybe_2; // (undocumented) reason: AlertDismissReason; } @@ -280,6 +272,12 @@ export type BarChartTooltipProps = { actions?: ReactNode; }; +// Warning: (tsdoc-characters-after-block-tag) The token "@backstage" looks like a TSDoc tag but contains an invalid character "/"; if it is not a tag, use a backslash to escape the "@" +// Warning: (ae-missing-release-tag) "ChangeStatistic" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public @deprecated (undocumented) +export type ChangeStatistic = common.ChangeStatistic; + // Warning: (ae-missing-release-tag) "ChangeThreshold" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -290,6 +288,20 @@ export enum ChangeThreshold { upper = 0.05, } +// @public (undocumented) +export type ChartData = { + date: number; + trend: number; + dailyCost: number; + [key: string]: number; +}; + +// Warning: (tsdoc-characters-after-block-tag) The token "@backstage" looks like a TSDoc tag but contains an invalid character "/"; if it is not a tag, use a backslash to escape the "@" +// Warning: (ae-missing-release-tag) "Cost" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public @deprecated (undocumented) +export type Cost = common.Cost; + // Warning: (ae-missing-release-tag) "CostGrowth" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -398,6 +410,20 @@ export interface CostInsightsThemeOptions extends PaletteOptions { palette: CostInsightsPaletteOptions; } +// @public (undocumented) +export interface Currency { + // (undocumented) + kind: string | null; + // (undocumented) + label: string; + // (undocumented) + prefix?: string; + // (undocumented) + rate?: number; + // (undocumented) + unit: string; +} + // Warning: (ae-missing-release-tag) "CurrencyType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -424,16 +450,40 @@ export enum DataKey { Previous = 'previous', } +// Warning: (tsdoc-characters-after-block-tag) The token "@backstage" looks like a TSDoc tag but contains an invalid character "/"; if it is not a tag, use a backslash to escape the "@" +// Warning: (ae-missing-release-tag) "DateAggregation" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public @deprecated (undocumented) +export type DateAggregation = common.DateAggregation; + // Warning: (ae-missing-release-tag) "DEFAULT_DATE_FORMAT" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) export const DEFAULT_DATE_FORMAT = 'yyyy-LL-dd'; +// @public +export enum Duration { + // (undocumented) + P30D = 'P30D', + // (undocumented) + P3M = 'P3M', + // (undocumented) + P7D = 'P7D', + // (undocumented) + P90D = 'P90D', +} + // Warning: (ae-missing-release-tag) "EngineerThreshold" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) export const EngineerThreshold = 0.5; +// Warning: (tsdoc-characters-after-block-tag) The token "@backstage" looks like a TSDoc tag but contains an invalid character "/"; if it is not a tag, use a backslash to escape the "@" +// Warning: (ae-missing-release-tag) "Entity" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public @deprecated (undocumented) +export type Entity = common.Entity; + // Warning: (ae-missing-release-tag) "ExampleCostInsightsClient" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -456,6 +506,12 @@ export class ExampleCostInsightsClient implements CostInsightsApi { getUserGroups(userId: string): Promise; } +// Warning: (tsdoc-characters-after-block-tag) The token "@backstage" looks like a TSDoc tag but contains an invalid character "/"; if it is not a tag, use a backslash to escape the "@" +// Warning: (ae-missing-release-tag) "Group" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public @deprecated (undocumented) +export type Group = common.Group; + // Warning: (ae-missing-release-tag) "GrowthType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -518,6 +574,24 @@ export type LegendItemProps = { // @public (undocumented) export type Loading = Record; +// Warning: (tsdoc-characters-after-block-tag) The token "@backstage" looks like a TSDoc tag but contains an invalid character "/"; if it is not a tag, use a backslash to escape the "@" +// Warning: (ae-missing-release-tag) "Maybe" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public @deprecated (undocumented) +export type Maybe = common.Maybe; + +// Warning: (tsdoc-characters-after-block-tag) The token "@backstage" looks like a TSDoc tag but contains an invalid character "/"; if it is not a tag, use a backslash to escape the "@" +// Warning: (ae-missing-release-tag) "Metric" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public @deprecated (undocumented) +export type Metric = common.Metric; + +// Warning: (tsdoc-characters-after-block-tag) The token "@backstage" looks like a TSDoc tag but contains an invalid character "/"; if it is not a tag, use a backslash to escape the "@" +// Warning: (ae-missing-release-tag) "MetricData" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public @deprecated (undocumented) +export type MetricData = common.MetricData; + // Warning: (ae-forgotten-export) The symbol "MockConfigProviderProps" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "MockConfigProvider" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -536,6 +610,27 @@ export const MockCurrencyProvider: ({ ...context }: MockCurrencyProviderProps) => JSX.Element; +// @public (undocumented) +export interface PageFilters { + // (undocumented) + duration: Duration; + // (undocumented) + group: Maybe_2; + // (undocumented) + metric: string | null; + // (undocumented) + project: Maybe_2; +} + +// Warning: (tsdoc-characters-after-block-tag) The token "@backstage" looks like a TSDoc tag but contains an invalid character "/"; if it is not a tag, use a backslash to escape the "@" +// Warning: (ae-missing-release-tag) "Product" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public @deprecated (undocumented) +export type Product = common.Product; + +// @public (undocumented) +export type ProductFilters = Array; + // Warning: (ae-missing-release-tag) "ProductInsightsOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -546,6 +641,20 @@ export type ProductInsightsOptions = { project: Maybe; }; +// @public (undocumented) +export interface ProductPeriod { + // (undocumented) + duration: Duration; + // (undocumented) + productType: string; +} + +// Warning: (tsdoc-characters-after-block-tag) The token "@backstage" looks like a TSDoc tag but contains an invalid character "/"; if it is not a tag, use a backslash to escape the "@" +// Warning: (ae-missing-release-tag) "Project" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public @deprecated (undocumented) +export type Project = common.Project; + // Warning: (ae-missing-release-tag) "ProjectGrowthAlert" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public @@ -570,7 +679,7 @@ export interface ProjectGrowthData { // (undocumented) aggregation: [number, number]; // (undocumented) - change: ChangeStatistic; + change: ChangeStatistic_2; // (undocumented) periodEnd: string; // (undocumented) @@ -588,7 +697,7 @@ export interface ResourceData { // (undocumented) current: number; // (undocumented) - name: Maybe; + name: Maybe_2; // (undocumented) previous: number; } @@ -602,6 +711,12 @@ export type TooltipItem = { value: string; }; +// Warning: (tsdoc-characters-after-block-tag) The token "@backstage" looks like a TSDoc tag but contains an invalid character "/"; if it is not a tag, use a backslash to escape the "@" +// Warning: (ae-missing-release-tag) "Trendline" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public @deprecated (undocumented) +export type Trendline = common.Trendline; + // Warning: (ae-missing-release-tag) "UnlabeledDataflowAlert" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public @@ -648,6 +763,4 @@ export interface UnlabeledDataflowData { // (undocumented) unlabeledCost: number; } - -export * from '@backstage/plugin-cost-insights-common'; ``` From 227688347385202304aa004165404fee21770053 Mon Sep 17 00:00:00 2001 From: Andrew Thauer Date: Thu, 30 Jun 2022 16:43:29 -0400 Subject: [PATCH 7/7] fix cost-insight contrib doc refs Signed-off-by: Andrew Thauer --- plugins/cost-insights/contrib/aws-cost-explorer-api.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/cost-insights/contrib/aws-cost-explorer-api.md b/plugins/cost-insights/contrib/aws-cost-explorer-api.md index caa7b72e10..1e3f4e9de6 100644 --- a/plugins/cost-insights/contrib/aws-cost-explorer-api.md +++ b/plugins/cost-insights/contrib/aws-cost-explorer-api.md @@ -77,7 +77,7 @@ We can use the data provided by the Cost Explorer API to implement CostInsightsA ### 1. [getGroupDailyCost](https://github.com/backstage/backstage/blob/master/plugins/cost-insights/src/api/CostInsightsApi.ts#L93) -The `getGroupDailyCost` method is expected to return daily cost aggregations for a given group and interval time frame as a [`Cost`](https://github.com/backstage/backstage/blob/master/plugins/cost-insights/src/types/Cost.ts). +The `getGroupDailyCost` method is expected to return daily cost aggregations for a given group and interval time frame as a [`Cost`](https://github.com/backstage/backstage/blob/master/plugins/cost-insights-common/src/types/Cost.ts). #### Total Daily cost @@ -208,13 +208,13 @@ Sample `groupedCosts` based on the response: ### 2. [getProjectDailyCost](https://github.com/backstage/backstage/blob/master/plugins/cost-insights/src/api/CostInsightsApi.ts#L111) -The `getProjectDailyCost` method is expected to return daily cost aggregations for a given billing entity and interval time frame as a [`Cost`](https://github.com/backstage/backstage/blob/master/plugins/cost-insights/src/types/Cost.ts). +The `getProjectDailyCost` method is expected to return daily cost aggregations for a given billing entity and interval time frame as a [`Cost`](https://github.com/backstage/backstage/blob/master/plugins/cost-insights-common/src/types/Cost.ts). This should be similar to the `getGroupDailyCost` method implementation, but with an updated `LINKED_ACCOUNT` filter to get narrower cost data for a lower-level linked account. ### 3. [getProductInsights](https://github.com/backstage/backstage/blob/master/plugins/cost-insights/src/api/CostInsightsApi.ts#L111) -The `getProductInsights` method is expected to return cost aggregations for a particular cloud product and interval time frame as an [`Entity`](https://github.com/backstage/backstage/blob/master/plugins/cost-insights/src/types/Entity.ts). +The `getProductInsights` method is expected to return cost aggregations for a particular cloud product and interval time frame as an [`Entity`](https://github.com/backstage/backstage/blob/master/plugins/cost-insights-common/src/types/Entity.ts). #### Cloud product cost by resource