cost-insights

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-08-19 15:37:12 +02:00
parent 3195aafd94
commit 249a3b47df
26 changed files with 222 additions and 260 deletions
+68 -193
View File
@@ -25,8 +25,6 @@ import { SetStateAction } from 'react';
import { TooltipProps } from 'recharts';
import { TypographyProps } from '@material-ui/core';
// Warning: (ae-missing-release-tag) "Alert" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export type Alert = {
title: string | JSX.Element;
@@ -43,8 +41,6 @@ export type Alert = {
onDismissed?(options: AlertOptions): Promise<Alert[]>;
};
// Warning: (ae-missing-release-tag) "AlertCost" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface AlertCost {
// (undocumented)
@@ -53,8 +49,6 @@ export interface AlertCost {
id: string;
}
// Warning: (ae-missing-release-tag) "AlertDismissFormData" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface AlertDismissFormData {
// (undocumented)
@@ -65,8 +59,6 @@ export interface AlertDismissFormData {
reason: AlertDismissReason;
}
// Warning: (ae-missing-release-tag) "AlertDismissOption" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface AlertDismissOption {
// (undocumented)
@@ -75,13 +67,9 @@ export interface AlertDismissOption {
reason: string;
}
// Warning: (ae-missing-release-tag) "AlertDismissOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const AlertDismissOptions: AlertDismissOption[];
// Warning: (ae-missing-release-tag) "AlertDismissReason" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export enum AlertDismissReason {
// (undocumented)
@@ -98,8 +86,6 @@ export enum AlertDismissReason {
Seasonal = 'seasonal',
}
// Warning: (ae-missing-release-tag) "AlertForm" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type AlertForm<
A extends Alert = any,
@@ -108,8 +94,6 @@ export type AlertForm<
AlertFormProps<A, Data> & RefAttributes<HTMLFormElement>
>;
// Warning: (ae-missing-release-tag) "AlertFormProps" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type AlertFormProps<A extends Alert, FormData = {}> = {
alert: A;
@@ -117,8 +101,6 @@ export type AlertFormProps<A extends Alert, FormData = {}> = {
disableSubmit: (isDisabled: boolean) => void;
};
// Warning: (ae-missing-release-tag) "AlertOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface AlertOptions<T = any> {
// (undocumented)
@@ -127,29 +109,21 @@ export interface AlertOptions<T = any> {
group: string;
}
// Warning: (ae-missing-release-tag) "AlertSnoozeFormData" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
export interface AlertSnoozeFormData {
// (undocumented)
intervals: string;
}
// Warning: (ae-missing-release-tag) "AlertSnoozeOption" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type AlertSnoozeOption = {
label: string;
duration: Duration;
};
// Warning: (ae-missing-release-tag) "AlertSnoozeOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const AlertSnoozeOptions: AlertSnoozeOption[];
// Warning: (ae-missing-release-tag) "AlertStatus" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export enum AlertStatus {
// (undocumented)
@@ -160,36 +134,17 @@ export enum AlertStatus {
Snoozed = 'snoozed',
}
// Warning: (ae-missing-release-tag) "BarChart" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const BarChart: ({
resources,
responsive,
displayAmount,
options,
tooltip,
onClick,
onMouseMove,
}: BarChartProps) => JSX.Element;
export const BarChart: (props: BarChartProps) => JSX.Element;
// Warning: (ae-missing-release-tag) "BarChartData" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public
// @public @deprecated (undocumented)
export interface BarChartData extends BarChartOptions {}
// Warning: (ae-missing-release-tag) "BarChartLegend" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const BarChartLegend: ({
costStart,
costEnd,
options,
children,
}: PropsWithChildren<BarChartLegendProps>) => JSX.Element;
export const BarChartLegend: (
props: PropsWithChildren<BarChartLegendProps>,
) => JSX.Element;
// Warning: (ae-missing-release-tag) "BarChartLegendOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type BarChartLegendOptions = {
previousName: string;
@@ -199,8 +154,6 @@ export type BarChartLegendOptions = {
hideMarker?: boolean;
};
// Warning: (ae-missing-release-tag) "BarChartLegendProps" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type BarChartLegendProps = {
costStart: number;
@@ -208,8 +161,6 @@ export type BarChartLegendProps = {
options?: Partial<BarChartLegendOptions>;
};
// Warning: (ae-missing-release-tag) "BarChartOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface BarChartOptions {
// (undocumented)
@@ -222,8 +173,6 @@ export interface BarChartOptions {
previousName: string;
}
// Warning: (ae-missing-release-tag) "BarChartProps" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type BarChartProps = {
resources: ResourceData[];
@@ -235,34 +184,21 @@ export type BarChartProps = {
onMouseMove?: RechartsFunction;
};
// Warning: (ae-missing-release-tag) "BarChartTooltip" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const BarChartTooltip: ({
title,
content,
subtitle,
topRight,
actions,
children,
}: PropsWithChildren<BarChartTooltipProps>) => JSX.Element;
export const BarChartTooltip: (
props: PropsWithChildren<BarChartTooltipProps>,
) => JSX.Element;
// Warning: (ae-missing-release-tag) "BarChartTooltipItem" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const BarChartTooltipItem: ({
item,
}: BarChartTooltipItemProps) => JSX.Element;
export const BarChartTooltipItem: (
props: BarChartTooltipItemProps,
) => JSX.Element;
// Warning: (ae-missing-release-tag) "BarChartTooltipItemProps" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type BarChartTooltipItemProps = {
item: TooltipItem;
};
// Warning: (ae-missing-release-tag) "BarChartTooltipProps" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type BarChartTooltipProps = {
title: string;
@@ -272,13 +208,9 @@ 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 @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)
export enum ChangeThreshold {
// (undocumented)
@@ -295,28 +227,26 @@ 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 type ConfigContextProps = {
metrics: Metric[];
products: Product[];
icons: Icon[];
engineerCost: number;
currencies: Currency[];
};
// @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)
export const CostGrowth: ({ change, duration }: CostGrowthProps) => JSX.Element;
export const CostGrowth: (props: CostGrowthProps) => JSX.Element;
// Warning: (ae-missing-release-tag) "CostGrowthIndicator" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const CostGrowthIndicator: ({
change,
formatter,
className,
...props
}: CostGrowthIndicatorProps) => JSX.Element;
export const CostGrowthIndicator: (
props: CostGrowthIndicatorProps,
) => JSX.Element;
// Warning: (ae-missing-release-tag) "CostGrowthIndicatorProps" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type CostGrowthIndicatorProps = TypographyProps & {
change: ChangeStatistic;
@@ -328,16 +258,12 @@ export type CostGrowthIndicatorProps = TypographyProps & {
) => Maybe<string>;
};
// Warning: (ae-missing-release-tag) "CostGrowthProps" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type CostGrowthProps = {
change: ChangeStatistic;
duration: Duration;
};
// Warning: (ae-missing-release-tag) "CostInsightsApi" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type CostInsightsApi = {
getLastCompleteBillingDate(): Promise<string>;
@@ -350,36 +276,36 @@ export type CostInsightsApi = {
getAlerts(group: string): Promise<Alert[]>;
};
// Warning: (ae-missing-release-tag) "costInsightsApiRef" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const costInsightsApiRef: ApiRef<CostInsightsApi>;
// Warning: (ae-missing-release-tag) "CostInsightsLabelDataflowInstructionsPage" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const CostInsightsLabelDataflowInstructionsPage: () => JSX.Element;
// Warning: (ae-missing-release-tag) "CostInsightsPage" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const CostInsightsPage: () => JSX.Element;
// Warning: (ae-forgotten-export) The symbol "CostInsightsPaletteAdditions" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "CostInsightsPalette" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type CostInsightsPalette = BackstagePalette &
CostInsightsPaletteAdditions;
// Warning: (ae-missing-release-tag) "CostInsightsPaletteOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type CostInsightsPaletteAdditions = {
blue: string;
lightBlue: string;
darkBlue: string;
magenta: string;
yellow: string;
tooltip: CostInsightsTooltipOptions;
navigationText: string;
alertBackground: string;
dataViz: string[];
};
// @public (undocumented)
export type CostInsightsPaletteOptions = PaletteOptions &
CostInsightsPaletteAdditions;
// Warning: (ae-missing-release-tag) "costInsightsPlugin" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
const costInsightsPlugin: BackstagePlugin<
{
@@ -393,27 +319,27 @@ const costInsightsPlugin: BackstagePlugin<
export { costInsightsPlugin };
export { costInsightsPlugin as plugin };
// Warning: (ae-missing-release-tag) "CostInsightsProjectGrowthInstructionsPage" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const CostInsightsProjectGrowthInstructionsPage: () => JSX.Element;
// Warning: (ae-missing-release-tag) "CostInsightsTheme" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface CostInsightsTheme extends BackstageTheme {
// (undocumented)
palette: CostInsightsPalette;
}
// Warning: (ae-missing-release-tag) "CostInsightsThemeOptions" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface CostInsightsThemeOptions extends PaletteOptions {
// (undocumented)
palette: CostInsightsPaletteOptions;
}
// @public (undocumented)
export type CostInsightsTooltipOptions = {
background: string;
color: string;
};
// @public (undocumented)
export interface Currency {
// (undocumented)
@@ -428,8 +354,12 @@ export interface Currency {
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)
export type CurrencyContextProps = {
currency: Currency;
setCurrency: Dispatch<SetStateAction<Currency>>;
};
// @public (undocumented)
export enum CurrencyType {
// (undocumented)
@@ -442,8 +372,6 @@ export enum CurrencyType {
USD = 'USD',
}
// Warning: (ae-missing-release-tag) "DataKey" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export enum DataKey {
// (undocumented)
@@ -454,13 +382,9 @@ 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 @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';
@@ -476,18 +400,12 @@ export enum Duration {
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 @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)
export class ExampleCostInsightsClient implements CostInsightsApi {
// (undocumented)
@@ -508,13 +426,9 @@ export class ExampleCostInsightsClient implements CostInsightsApi {
getUserGroups(userId: string): Promise<Group[]>;
}
// 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)
export enum GrowthType {
// (undocumented)
@@ -525,16 +439,12 @@ export enum GrowthType {
Savings = 1,
}
// Warning: (ae-missing-release-tag) "Icon" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type Icon = {
kind: string;
component: JSX.Element;
};
// Warning: (ae-missing-release-tag) "IconType" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export enum IconType {
// (undocumented)
@@ -551,18 +461,11 @@ export enum IconType {
Storage = 'storage',
}
// Warning: (ae-missing-release-tag) "LegendItem" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const LegendItem: ({
title,
tooltipText,
markerColor,
children,
}: PropsWithChildren<LegendItemProps>) => JSX.Element;
export const LegendItem: (
props: PropsWithChildren<LegendItemProps>,
) => JSX.Element;
// Warning: (ae-missing-release-tag) "LegendItemProps" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type LegendItemProps = {
title: string;
@@ -570,43 +473,37 @@ export type LegendItemProps = {
markerColor?: string;
};
// Warning: (ae-missing-release-tag) "Loading" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type Loading = Record<string, boolean>;
// 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<T> = common.Maybe<T>;
// 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: (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)
//
// @public (undocumented)
export const MockConfigProvider: ({
children,
...context
}: MockConfigProviderProps) => JSX.Element;
export const MockConfigProvider: (
props: MockConfigProviderProps,
) => JSX.Element;
// Warning: (ae-forgotten-export) The symbol "MockCurrencyProviderProps" needs to be exported by the entry point index.d.ts
// Warning: (ae-missing-release-tag) "MockCurrencyProvider" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const MockCurrencyProvider: ({
children,
...context
}: MockCurrencyProviderProps) => JSX.Element;
export type MockConfigProviderProps = PropsWithChildren<
Partial<ConfigContextProps>
>;
// @public (undocumented)
export const MockCurrencyProvider: (
props: MockCurrencyProviderProps,
) => JSX.Element;
// @public (undocumented)
export type MockCurrencyProviderProps = PropsWithChildren<
Partial<CurrencyContextProps>
>;
// @public (undocumented)
export interface PageFilters {
@@ -620,16 +517,12 @@ export interface PageFilters {
project: Maybe_2<string>;
}
// 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<ProductPeriod>;
// 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)
export type ProductInsightsOptions = {
product: string;
@@ -646,13 +539,9 @@ 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 @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
export class ProjectGrowthAlert implements Alert {
constructor(data: ProjectGrowthData);
@@ -668,8 +557,6 @@ export class ProjectGrowthAlert implements Alert {
get url(): string;
}
// Warning: (ae-missing-release-tag) "ProjectGrowthData" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface ProjectGrowthData {
// (undocumented)
@@ -686,8 +573,6 @@ export interface ProjectGrowthData {
project: string;
}
// Warning: (ae-missing-release-tag) "ResourceData" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface ResourceData {
// (undocumented)
@@ -698,8 +583,6 @@ export interface ResourceData {
previous: number;
}
// Warning: (ae-missing-release-tag) "TooltipItem" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export type TooltipItem = {
fill: string;
@@ -707,13 +590,9 @@ 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 @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
export class UnlabeledDataflowAlert implements Alert {
constructor(data: UnlabeledDataflowData);
@@ -731,8 +610,6 @@ export class UnlabeledDataflowAlert implements Alert {
get url(): string;
}
// Warning: (ae-missing-release-tag) "UnlabeledDataflowAlertProject" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface UnlabeledDataflowAlertProject {
// (undocumented)
@@ -743,8 +620,6 @@ export interface UnlabeledDataflowAlertProject {
unlabeledCost: number;
}
// Warning: (ae-missing-release-tag) "UnlabeledDataflowData" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export interface UnlabeledDataflowData {
// (undocumented)
@@ -22,8 +22,9 @@ import { Alert, ProjectGrowthData } from '../types';
* The alert below is an example of an Alert implementation; the CostInsightsApi permits returning
* any implementation of the Alert type, so adopters can create their own. The CostInsightsApi
* fetches alert data from the backend, then creates Alert classes with the data.
*
* @public
*/
export class ProjectGrowthAlert implements Alert {
data: ProjectGrowthData;
@@ -22,8 +22,9 @@ import { Alert, AlertStatus, UnlabeledDataflowData } from '../types';
* The alert below is an example of an Alert implementation; the CostInsightsApi permits returning
* any implementation of the Alert type, so adopters can create their own. The CostInsightsApi
* fetches alert data from the backend, then creates Alert classes with the data.
*
* @public
*/
export class UnlabeledDataflowAlert implements Alert {
data: UnlabeledDataflowData;
status?: AlertStatus;
@@ -25,6 +25,7 @@ import {
} from '../types';
import { createApiRef } from '@backstage/core-plugin-api';
/** @public */
export type ProductInsightsOptions = {
/**
* The product from the cost-insights configuration in app-config.yaml
@@ -47,6 +48,7 @@ export type ProductInsightsOptions = {
project: Maybe<string>;
};
/** @public */
export type CostInsightsApi = {
/**
* Get the most current date for which billing data is complete, in YYYY-MM-DD format. This helps
@@ -146,6 +148,7 @@ export type CostInsightsApi = {
getAlerts(group: string): Promise<Alert[]>;
};
/** @public */
export const costInsightsApiRef = createApiRef<CostInsightsApi>({
id: 'plugin.costinsights.service',
});
@@ -61,6 +61,7 @@ export const defaultTooltip: ContentRenderer<RechartsTooltipProps> = ({
);
};
/** @public */
export type BarChartProps = {
resources: ResourceData[];
responsive?: boolean;
@@ -71,15 +72,18 @@ export type BarChartProps = {
onMouseMove?: RechartsFunction;
};
export const BarChart = ({
resources,
responsive = true,
displayAmount = 6,
options = {},
tooltip = defaultTooltip,
onClick,
onMouseMove,
}: BarChartProps) => {
/** @public */
export const BarChart = (props: BarChartProps) => {
const {
resources,
responsive = true,
displayAmount = 6,
options = {},
tooltip = defaultTooltip,
onClick,
onMouseMove,
} = props;
const theme = useTheme<CostInsightsTheme>();
const styles = useBarChartStyles(theme);
const [activeChart, setActiveChart] = useState(false);
@@ -21,6 +21,7 @@ import { currencyFormatter } from '../../utils/formatters';
import { CostInsightsTheme } from '../../types';
import { useBarChartLayoutStyles as useStyles } from '../../utils/styles';
/** @public */
export type BarChartLegendOptions = {
previousName: string;
previousFill: string;
@@ -29,18 +30,19 @@ export type BarChartLegendOptions = {
hideMarker?: boolean;
};
/** @public */
export type BarChartLegendProps = {
costStart: number;
costEnd: number;
options?: Partial<BarChartLegendOptions>;
};
export const BarChartLegend = ({
costStart,
costEnd,
options = {},
children,
}: PropsWithChildren<BarChartLegendProps>) => {
/** @public */
export const BarChartLegend = (
props: PropsWithChildren<BarChartLegendProps>,
) => {
const { costStart, costEnd, options = {}, children } = props;
const theme = useTheme<CostInsightsTheme>();
const classes = useStyles();
@@ -19,6 +19,7 @@ import classnames from 'classnames';
import { Box, Divider, Typography } from '@material-ui/core';
import { useTooltipStyles as useStyles } from '../../utils/styles';
/** @public */
export type BarChartTooltipProps = {
title: string;
content?: ReactNode | string;
@@ -27,14 +28,12 @@ export type BarChartTooltipProps = {
actions?: ReactNode;
};
export const BarChartTooltip = ({
title,
content,
subtitle,
topRight,
actions,
children,
}: PropsWithChildren<BarChartTooltipProps>) => {
/** @public */
export const BarChartTooltip = (
props: PropsWithChildren<BarChartTooltipProps>,
) => {
const { title, content, subtitle, topRight, actions, children } = props;
const classes = useStyles();
const titleClassName = classnames(classes.truncate, {
[classes.maxWidth]: topRight === undefined,
@@ -19,18 +19,24 @@ import { Box, Typography } from '@material-ui/core';
import LensIcon from '@material-ui/icons/Lens';
import { useTooltipStyles as useStyles } from '../../utils/styles';
/** @public */
export type TooltipItem = {
fill: string;
label: string;
value: string;
};
/** @public */
export type BarChartTooltipItemProps = {
item: TooltipItem;
};
export const BarChartTooltipItem = ({ item }: BarChartTooltipItemProps) => {
/** @public */
export const BarChartTooltipItem = (props: BarChartTooltipItemProps) => {
const { item } = props;
const classes = useStyles();
return (
<Box
display="flex"
@@ -31,12 +31,16 @@ import { indefiniteArticleOf } from '../../utils/grammar';
import { useConfig, useCurrency } from '../../hooks';
import { notEmpty } from '../../utils/assert';
/** @public */
export type CostGrowthProps = {
change: ChangeStatistic;
duration: Duration;
};
export const CostGrowth = ({ change, duration }: CostGrowthProps) => {
/** @public */
export const CostGrowth = (props: CostGrowthProps) => {
const { change, duration } = props;
const styles = useStyles();
const { engineerCost } = useConfig();
const [currency] = useCurrency();
@@ -23,6 +23,7 @@ import { growthOf } from '../../utils/change';
import { ChangeStatistic, GrowthType, Maybe } from '../../types';
import { useCostGrowthStyles as useStyles } from '../../utils/styles';
/** @public */
export type CostGrowthIndicatorProps = TypographyProps & {
change: ChangeStatistic;
formatter?: (
@@ -31,12 +32,10 @@ export type CostGrowthIndicatorProps = TypographyProps & {
) => Maybe<string>;
};
export const CostGrowthIndicator = ({
change,
formatter,
className,
...props
}: CostGrowthIndicatorProps) => {
/** @public */
export const CostGrowthIndicator = (props: CostGrowthIndicatorProps) => {
const { change, formatter, className, ...extraProps } = props;
const classes = useStyles();
const growth = growthOf(change);
@@ -46,7 +45,7 @@ export const CostGrowthIndicator = ({
});
return (
<Typography className={classNames} component="span" {...props}>
<Typography className={classNames} component="span" {...extraProps}>
{formatter ? formatter(change, { absolute: true }) : change.ratio}
{growth === GrowthType.Excess && <ArrowDropUp aria-label="excess" />}
{growth === GrowthType.Savings && <ArrowDropDown aria-label="savings" />}
@@ -20,19 +20,19 @@ import LensIcon from '@material-ui/icons/Lens';
import HelpOutlineOutlinedIcon from '@material-ui/icons/HelpOutlineOutlined';
import { useCostGrowthLegendStyles } from '../../utils/styles';
/** @public */
export type LegendItemProps = {
title: string;
tooltipText?: string;
markerColor?: string;
};
export const LegendItem = ({
title,
tooltipText,
markerColor,
children,
}: PropsWithChildren<LegendItemProps>) => {
/** @public */
export const LegendItem = (props: PropsWithChildren<LegendItemProps>) => {
const { title, tooltipText, markerColor, children } = props;
const classes = useCostGrowthLegendStyles();
return (
<Box display="flex" flexDirection="column">
<Box
@@ -39,6 +39,7 @@ import {
trendlineOf,
} from '../testUtils';
/** @public */
export class ExampleCostInsightsClient implements CostInsightsApi {
private request(_: any, res: any): Promise<any> {
return new Promise(resolve => setTimeout(resolve, 0, res));
@@ -58,6 +58,7 @@ import { configApiRef, useApi } from '@backstage/core-plugin-api';
* rate: 3.5
*/
/** @public */
export type ConfigContextProps = {
metrics: Metric[];
products: Product[];
@@ -23,6 +23,7 @@ import React, {
import { Currency } from '../types';
import { useConfig } from './useConfig';
/** @public */
export type CurrencyContextProps = {
currency: Currency;
setCurrency: Dispatch<SetStateAction<Currency>>;
+5
View File
@@ -38,8 +38,13 @@ export {
LegendItem,
} from './components';
export { MockConfigProvider, MockCurrencyProvider } from './testUtils';
export type {
MockConfigProviderProps,
MockCurrencyProviderProps,
} from './testUtils';
export * from './api';
export * from './alerts';
export type { ConfigContextProps, CurrencyContextProps } from './hooks';
export * from './types';
export type {
+4
View File
@@ -32,6 +32,7 @@ export const unlabeledDataflowAlertRef = createRouteRef({
id: 'cost-insights:labeling-jobs',
});
/** @public */
export const costInsightsPlugin = createPlugin({
id: 'cost-insights',
featureFlags: [{ name: 'cost-insights-currencies' }],
@@ -42,6 +43,7 @@ export const costInsightsPlugin = createPlugin({
},
});
/** @public */
export const CostInsightsPage = costInsightsPlugin.provide(
createRoutableExtension({
name: 'CostInsightsPage',
@@ -51,6 +53,7 @@ export const CostInsightsPage = costInsightsPlugin.provide(
}),
);
/** @public */
export const CostInsightsProjectGrowthInstructionsPage =
costInsightsPlugin.provide(
createRoutableExtension({
@@ -63,6 +66,7 @@ export const CostInsightsProjectGrowthInstructionsPage =
}),
);
/** @public */
export const CostInsightsLabelDataflowInstructionsPage =
costInsightsPlugin.provide(
createRoutableExtension({
@@ -27,12 +27,11 @@ import {
import { ScrollContext, ScrollContextProps } from '../hooks/useScroll';
import { Group, Duration } from '../types';
type PartialPropsWithChildren<T> = PropsWithChildren<Partial<T>>;
export const MockGroups: Group[] = [{ id: 'tech' }, { id: 'mock-group' }];
export type MockFilterProviderProps =
PartialPropsWithChildren<FilterContextProps>;
export type MockFilterProviderProps = PropsWithChildren<
Partial<FilterContextProps>
>;
export const MockFilterProvider = ({
children,
@@ -56,8 +55,9 @@ export const MockFilterProvider = ({
);
};
export type MockLoadingProviderProps =
PartialPropsWithChildren<LoadingContextProps>;
export type MockLoadingProviderProps = PropsWithChildren<
Partial<LoadingContextProps>
>;
export const MockLoadingProvider = ({
children,
@@ -75,13 +75,15 @@ export const MockLoadingProvider = ({
);
};
export type MockConfigProviderProps =
PartialPropsWithChildren<ConfigContextProps>;
/** @public */
export type MockConfigProviderProps = PropsWithChildren<
Partial<ConfigContextProps>
>;
/** @public */
export const MockConfigProvider = (props: MockConfigProviderProps) => {
const { children, ...context } = props;
export const MockConfigProvider = ({
children,
...context
}: MockConfigProviderProps) => {
const defaultContext: ConfigContextProps = {
metrics: [],
products: [],
@@ -89,6 +91,7 @@ export const MockConfigProvider = ({
engineerCost: 0,
currencies: [],
};
return (
<ConfigContext.Provider value={{ ...defaultContext, ...context }}>
{children}
@@ -96,13 +99,15 @@ export const MockConfigProvider = ({
);
};
export type MockCurrencyProviderProps =
PartialPropsWithChildren<CurrencyContextProps>;
/** @public */
export type MockCurrencyProviderProps = PropsWithChildren<
Partial<CurrencyContextProps>
>;
/** @public */
export const MockCurrencyProvider = (props: MockCurrencyProviderProps) => {
const { children, ...context } = props;
export const MockCurrencyProvider = ({
children,
...context
}: MockCurrencyProviderProps) => {
const defaultContext: CurrencyContextProps = {
currency: {
kind: null,
@@ -111,6 +116,7 @@ export const MockCurrencyProvider = ({
},
setCurrency: jest.fn(),
};
return (
<CurrencyContext.Provider value={{ ...defaultContext, ...context }}>
{children}
@@ -118,8 +124,9 @@ export const MockCurrencyProvider = ({
);
};
export type MockBillingDateProviderProps =
PartialPropsWithChildren<BillingDateContextProps>;
export type MockBillingDateProviderProps = PropsWithChildren<
Partial<BillingDateContextProps>
>;
export const MockBillingDateProvider = ({
children,
@@ -149,8 +156,9 @@ export const MockScrollProvider = ({ children }: MockScrollProviderProps) => {
);
};
export type MockGroupsProviderProps =
PartialPropsWithChildren<GroupsContextProps>;
export type MockGroupsProviderProps = PropsWithChildren<
Partial<GroupsContextProps>
>;
export const MockGroupsProvider = ({
children,
+25 -2
View File
@@ -31,8 +31,9 @@ import { Duration } from './Duration';
* React.forwardRef. See https://reactjs.org/docs/forwarding-refs
*
* Errors thrown within hooks will generate a snackbar error notification.
*
* @public
*/
export type Alert = {
title: string | JSX.Element;
subtitle: string | JSX.Element;
@@ -48,6 +49,7 @@ export type Alert = {
onDismissed?(options: AlertOptions): Promise<Alert[]>;
};
/** @public */
export type AlertForm<
A extends Alert = any,
Data = any,
@@ -55,6 +57,7 @@ export type AlertForm<
AlertFormProps<A, Data> & RefAttributes<HTMLFormElement>
>;
/** @public */
export interface AlertOptions<T = any> {
data: T;
group: string;
@@ -69,11 +72,14 @@ export interface AlertOptions<T = any> {
* inclusive of the last day.
*
* https://en.wikipedia.org/wiki/ISO_8601#Repeating_intervals
*
* @public
*/
export interface AlertSnoozeFormData {
intervals: string;
}
/** @public */
export interface AlertDismissFormData {
other: Maybe<string>;
reason: AlertDismissReason;
@@ -81,23 +87,27 @@ export interface AlertDismissFormData {
}
// TODO: Convert enum to literal
/** @public */
export enum AlertStatus {
Snoozed = 'snoozed',
Accepted = 'accepted',
Dismissed = 'dismissed',
}
/** @public */
export type AlertFormProps<A extends Alert, FormData = {}> = {
alert: A;
onSubmit: (data: FormData) => void;
disableSubmit: (isDisabled: boolean) => void;
};
/** @public */
export interface AlertDismissOption {
label: string;
reason: string;
}
/** @public */
export enum AlertDismissReason {
Other = 'other',
Resolved = 'resolved',
@@ -107,6 +117,7 @@ export enum AlertDismissReason {
NotApplicable = 'not-applicable',
}
/** @public */
export const AlertDismissOptions: AlertDismissOption[] = [
{
reason: AlertDismissReason.Resolved,
@@ -134,11 +145,13 @@ export const AlertDismissOptions: AlertDismissOption[] = [
},
];
/** @public */
export type AlertSnoozeOption = {
label: string;
duration: Duration;
};
/** @public */
export const AlertSnoozeOptions: AlertSnoozeOption[] = [
{
duration: Duration.P7D,
@@ -154,17 +167,20 @@ export const AlertSnoozeOptions: AlertSnoozeOption[] = [
},
];
/** @public */
export interface AlertCost {
id: string;
aggregation: [number, number];
}
/** @public */
export interface ResourceData {
previous: number;
current: number;
name: Maybe<string>;
}
/** @public */
export interface BarChartOptions {
previousFill: string;
currentFill: string;
@@ -172,15 +188,20 @@ export interface BarChartOptions {
currentName: string;
}
/** deprecated use BarChartOptions instead */
/**
* @public
* @deprecated use BarChartOptions instead
*/
export interface BarChartData extends BarChartOptions {}
/** @public */
export enum DataKey {
Previous = 'previous',
Current = 'current',
Name = 'name',
}
/** @public */
export interface ProjectGrowthData {
project: string;
periodStart: string;
@@ -190,6 +211,7 @@ export interface ProjectGrowthData {
products: Array<AlertCost>;
}
/** @public */
export interface UnlabeledDataflowData {
periodStart: string;
periodEnd: string;
@@ -198,6 +220,7 @@ export interface UnlabeledDataflowData {
labeledCost: number;
}
/** @public */
export interface UnlabeledDataflowAlertProject {
id: string;
unlabeledCost: number;
@@ -14,13 +14,16 @@
* limitations under the License.
*/
/** @public */
export const EngineerThreshold = 0.5;
/** @public */
export enum ChangeThreshold {
upper = 0.05,
lower = -0.05,
}
/** @public */
export enum GrowthType {
Negligible,
Savings,
@@ -14,6 +14,7 @@
* limitations under the License.
*/
/** @public */
export enum CurrencyType {
USD = 'USD',
CarbonOffsetTons = 'CARBON_OFFSET_TONS',
@@ -14,4 +14,5 @@
* limitations under the License.
*/
/** @public */
export const DEFAULT_DATE_FORMAT = 'yyyy-LL-dd';
+2
View File
@@ -14,11 +14,13 @@
* limitations under the License.
*/
/** @public */
export type Icon = {
kind: string;
component: JSX.Element;
};
/** @public */
export enum IconType {
Compute = 'compute',
Data = 'data',
@@ -14,4 +14,5 @@
* limitations under the License.
*/
/** @public */
export type Loading = Record<string, boolean>;
+9 -2
View File
@@ -13,15 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { BackstagePalette, BackstageTheme } from '@backstage/theme';
import { PaletteOptions } from '@material-ui/core/styles/createPalette';
type CostInsightsTooltipOptions = {
/** @public */
export type CostInsightsTooltipOptions = {
background: string;
color: string;
};
type CostInsightsPaletteAdditions = {
/** @public */
export type CostInsightsPaletteAdditions = {
blue: string;
lightBlue: string;
darkBlue: string;
@@ -33,16 +36,20 @@ type CostInsightsPaletteAdditions = {
dataViz: string[];
};
/** @public */
export type CostInsightsPalette = BackstagePalette &
CostInsightsPaletteAdditions;
/** @public */
export type CostInsightsPaletteOptions = PaletteOptions &
CostInsightsPaletteAdditions;
/** @public */
export interface CostInsightsThemeOptions extends PaletteOptions {
palette: CostInsightsPaletteOptions;
}
/** @public */
export interface CostInsightsTheme extends BackstageTheme {
palette: CostInsightsPalette;
}
+11
View File
@@ -35,45 +35,56 @@ import * as common from '@backstage/plugin-cost-insights-common';
/**
* @deprecated use the same type from `@backstage/plugin-cost-insights-common` instead
* @public
*/
export type ChangeStatistic = common.ChangeStatistic;
/**
* @deprecated use the same type from `@backstage/plugin-cost-insights-common` instead
* @public
*/
export type Cost = common.Cost;
/**
* @deprecated use the same type from `@backstage/plugin-cost-insights-common` instead
* @public
*/
export type DateAggregation = common.DateAggregation;
/**
* @deprecated use the same type from `@backstage/plugin-cost-insights-common` instead
* @public
*/
export type Entity = common.Entity;
/**
* @deprecated use the same type from `@backstage/plugin-cost-insights-common` instead
* @public
*/
export type Group = common.Group;
/**
* @deprecated use the same type from `@backstage/plugin-cost-insights-common` instead
* @public
*/
export type Maybe<T> = common.Maybe<T>;
/**
* @deprecated use the same type from `@backstage/plugin-cost-insights-common` instead
* @public
*/
export type Metric = common.Metric;
/**
* @deprecated use the same type from `@backstage/plugin-cost-insights-common` instead
* @public
*/
export type MetricData = common.MetricData;
/**
* @deprecated use the same type from `@backstage/plugin-cost-insights-common` instead
* @public
*/
export type Product = common.Product;
/**
* @deprecated use the same type from `@backstage/plugin-cost-insights-common` instead
* @public
*/
export type Project = common.Project;
/**
* @deprecated use the same type from `@backstage/plugin-cost-insights-common` instead
* @public
*/
export type Trendline = common.Trendline;
-1
View File
@@ -201,7 +201,6 @@ const ALLOW_WARNINGS = [
'packages/core-components',
'plugins/catalog',
'plugins/catalog-import',
'plugins/cost-insights',
'plugins/git-release-manager',
'plugins/github-pull-requests-board',
'plugins/jenkins',