From 66ef0326315b90b75a4b64a971478b1c555ec5c0 Mon Sep 17 00:00:00 2001 From: Andrew Thauer Date: Thu, 30 Jun 2022 14:21:35 -0400 Subject: [PATCH] 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';