diff --git a/apps/web/src/api/asset_interfaces/metric/charts/chartConfigProps.ts b/apps/web/src/api/asset_interfaces/metric/charts/chartConfigProps.ts deleted file mode 100644 index 2db1873bd..000000000 --- a/apps/web/src/api/asset_interfaces/metric/charts/chartConfigProps.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { z } from 'zod/v4'; -import { GoalLineSchema, TrendlineSchema } from './annotationInterfaces'; -import { ColumnSettingsSchema } from './columnInterfaces'; -import { IColumnLabelFormatSchema } from './columnLabelInterfaces'; -import { ChartTypeSchema } from './enum'; -import { ShowLegendHeadlineSchema } from './etcInterfaces'; -import { - CategoryAxisStyleConfigSchema, - XAxisConfigSchema, - Y2AxisConfigSchema, - YAxisConfigSchema -} from './tickInterfaces'; -import { DEFAULT_CHART_THEME } from './configColors'; -import { BarChartPropsSchema } from './barChartProps'; -import { LineChartPropsSchema } from './lineChartProps'; -import { ScatterChartPropsSchema } from './scatterChartProps'; -import { PieChartPropsSchema } from './pieChartProps'; -import { TableChartPropsSchema } from './tableChartProps'; -import { ComboChartPropsSchema } from './comboChartProps'; -import { MetricChartPropsSchema, DerivedMetricTitleSchema } from './metricChartProps'; - -export const BusterChartConfigPropsSchema = z.object({ - selectedChartType: ChartTypeSchema, - // COLUMN SETTINGS - // OPTIONAL because the defaults will be determined by the UI - columnSettings: z.record(z.string(), z.optional(ColumnSettingsSchema)).default({}), - columnLabelFormats: z.record(z.string(), z.optional(IColumnLabelFormatSchema)).default({}), - // OPTIONAL: default is the buster color palette - colors: z.array(z.string()).default(DEFAULT_CHART_THEME), - // OPTIONAL: default is null and will be true if there are multiple Y axes or if a category axis is used - showLegend: z.nullable(z.boolean()).default(null), - // OPTIONAL: default: true - gridLines: z.boolean().default(true), - // OPTIONAL - showLegendHeadline: ShowLegendHeadlineSchema, - // OPTIONAL: default is no goal lines - goalLines: z.array(GoalLineSchema).default([]), - // OPTIONAL: default is no trendlines - trendlines: z.array(TrendlineSchema).default([]), - // OPTIONAL: default is false - disableTooltip: z.boolean().default(false), - // Spread the shape properties from all schemas - ...YAxisConfigSchema.shape, - ...XAxisConfigSchema.shape, - ...CategoryAxisStyleConfigSchema.shape, - ...Y2AxisConfigSchema.shape, - ...BarChartPropsSchema.shape, - ...LineChartPropsSchema.shape, - ...ScatterChartPropsSchema.shape, - ...PieChartPropsSchema.shape, - ...TableChartPropsSchema.shape, - ...ComboChartPropsSchema.shape, - ...MetricChartPropsSchema.shape -}); - -// Re-export schemas for backward compatibility -export { - BarChartPropsSchema, - LineChartPropsSchema, - ScatterChartPropsSchema, - PieChartPropsSchema, - TableChartPropsSchema, - ComboChartPropsSchema, - MetricChartPropsSchema, - DerivedMetricTitleSchema -}; - -// Export original types for backward compatibility -export type BusterChartConfigProps = z.infer; -export type DerivedMetricTitle = z.infer; -export type MetricChartProps = z.infer; -export type BarChartProps = z.infer; -export type LineChartProps = z.infer; -export type ScatterChartProps = z.infer; -export type PieChartProps = z.infer; -export type TableChartProps = z.infer; -export type ComboChartProps = z.infer; diff --git a/apps/web/src/api/asset_interfaces/metric/charts/chatConfig.defaults.ts b/apps/web/src/api/asset_interfaces/metric/charts/chatConfig.defaults.ts deleted file mode 100644 index b21b04420..000000000 --- a/apps/web/src/api/asset_interfaces/metric/charts/chatConfig.defaults.ts +++ /dev/null @@ -1,125 +0,0 @@ -import { DEFAULT_CHART_THEME } from './configColors'; -import { BusterChartConfigPropsSchema, type BusterChartConfigProps } from './chartConfigProps'; -import { z } from 'zod/v4'; - -/** - * Extracts all default values from a Zod schema. - * This function creates a partial version of the schema where all fields are optional, - * then parses an empty object to get all the default values. - */ -function getDefaults>(schema: T): z.infer { - // Create a partial version of the schema where all fields are optional - const partialSchema = schema.partial(); - - // Parse an empty object through the partial schema - // This will apply all default values without throwing on missing required fields - const defaults = partialSchema.parse({}); - - // Now try to parse the defaults through the original schema - // This ensures we get the correct type and validates the defaults - try { - return schema.parse(defaults); - } catch { - // If the original schema fails (missing required fields without defaults), - // return what we have as a partial - return defaults as z.infer; - } -} - -/** - * Alternative implementation that only returns fields with explicit defaults. - * This is useful when you want to know which fields have defaults vs which are undefined. - */ -function getDefaultsPartial>(schema: T): Partial> { - // Make all fields optional and parse an empty object - const partialSchema = schema.partial(); - return partialSchema.parse({}) as Partial>; -} - -export const DEFAULT_CHART_CONFIG: BusterChartConfigProps = getDefaults( - BusterChartConfigPropsSchema -); - -// export const DEFAULT_CHART_CONFIG: BusterChartConfigProps = { -// colors: DEFAULT_CHART_THEME, -// selectedChartType: 'table', -// yAxisShowAxisLabel: true, -// yAxisShowAxisTitle: true, -// yAxisAxisTitle: null, -// yAxisStartAxisAtZero: null, -// yAxisScaleType: 'linear', -// y2AxisShowAxisLabel: true, -// y2AxisAxisTitle: null, -// y2AxisShowAxisTitle: true, -// y2AxisStartAxisAtZero: true, -// y2AxisScaleType: 'linear', -// xAxisTimeInterval: null, -// xAxisShowAxisLabel: true, -// xAxisShowAxisTitle: true, -// xAxisAxisTitle: null, -// xAxisLabelRotation: 'auto', -// xAxisDataZoom: false, -// categoryAxisTitle: null, -// showLegend: null, -// gridLines: true, -// goalLines: [], -// trendlines: [], -// showLegendHeadline: false, -// disableTooltip: false, -// barAndLineAxis: { -// x: [], -// y: [], -// category: [], -// tooltip: null -// }, -// scatterAxis: { -// x: [], -// y: [], -// size: [], -// tooltip: null -// }, -// comboChartAxis: { -// x: [], -// y: [], -// y2: [], -// tooltip: null -// }, -// pieChartAxis: { -// x: [], -// y: [], -// tooltip: null -// }, -// //LINE -// lineGroupType: null, -// //SCATTER -// scatterDotSize: [3, 15], -// //BAR -// barSortBy: [], -// barLayout: 'vertical', -// barGroupType: 'group', -// barShowTotalAtTop: false, -// //PIE -// pieShowInnerLabel: true, -// pieInnerLabelAggregate: 'sum', -// pieInnerLabelTitle: 'Total', -// pieLabelPosition: null, -// pieDonutWidth: 40, -// pieMinimumSlicePercentage: 0, -// pieDisplayLabelAs: 'number', -// pieSortBy: 'value', -// //METRIC -// metricColumnId: '', -// metricValueAggregate: 'sum', -// metricHeader: null, -// metricSubHeader: null, -// metricValueLabel: null, -// //TABLE -// tableColumnOrder: null, -// tableColumnWidths: null, -// tableHeaderBackgroundColor: null, -// tableHeaderFontColor: null, -// tableColumnFontColor: null, -// //MUST LOOP THROUGH ALL COLUMNS -// columnSettings: {}, -// columnLabelFormats: {} -// }; diff --git a/apps/web/src/api/asset_interfaces/metric/charts/columnLabelInterfaces.ts b/apps/web/src/api/asset_interfaces/metric/charts/columnLabelInterfaces.ts deleted file mode 100644 index 134d81b9d..000000000 --- a/apps/web/src/api/asset_interfaces/metric/charts/columnLabelInterfaces.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { z } from 'zod/v4'; - -export const IColumnLabelFormatSchema = z.object({ - columnType: z.enum(['number', 'text', 'date'] as const), - style: z.enum(['currency', 'percent', 'number', 'date', 'string']), - // All other properties from ColumnLabelFormat - // OPTIONAL: if this is not specifically requested by the user, then you should ignore this and the columnId will be used and formatted - displayName: z.optional(z.string()), - // OPTIONAL: default is ','. You should add this style if the column type requires a unique separator style. This will only apply if the format is set to 'number'. - numberSeparatorStyle: z.optional(z.nullable(z.literal(','))), - // OPTIONAL: default is 0. This is essentially used to set a minimum number of decimal places. This will only apply if the format is set to 'number'. - minimumFractionDigits: z.optional( - z - .number() - .check( - z.gte(0, 'Minimum fraction digits must be at least 0'), - z.lte(20, 'Minimum fraction digits must be at most 20') - ) - ), - // OPTIONAL: default is 2. This is essentially used to set a maximum number of decimal places. This will only apply if the format is set to 'number'. - maximumFractionDigits: z.optional( - z - .number() - .check( - z.gte(0, 'Maximum fraction digits must be at least 0'), - z.lte(20, 'Maximum fraction digits must be at most 20') - ) - ), - // OPTIONAL: default is 1. This will only apply if the format is set to 'number', 'currency', or 'percent'. - multiplier: z.optional( - z - .number() - .check( - z.gte(0.001, 'Multiplier must be at least 0.001'), - z.lte(1000000, 'Multiplier must be at most 1,000,000') - ) - ), - // OPTIONAL: default is ''. This sets a prefix to go in front of each value found within the column. This will only apply if the format is set to 'number' or 'percent'. - prefix: z.optional(z.string()), - // OPTIONAL: default is ''. This sets a suffix to go after each value found within the column. This will only apply if the format is set to 'number' or 'percent'. - suffix: z.optional(z.string()), - // OPTIONAL: default is 0. This will only apply if the format is set to 'number'. This will replace missing data with the specified value. - replaceMissingDataWith: z.optional(z.union([z.literal(0), z.null(), z.string()])), - useRelativeTime: z.optional(z.boolean()), - isUTC: z.optional(z.boolean()), - makeLabelHumanReadable: z.optional(z.boolean()), - // DO NOT SHARE WITH LLM - compactNumbers: z.optional(z.boolean()), - // Currency-specific properties - // OPTIONAL: default is 'USD'. This will only apply if the format is set to 'currency'. It should be the ISO 4217 currency code. - currency: z.optional(z.string()), - // Date-specific properties - // OPTIONAL: default is 'LL'. This will only apply if the format is set to 'date'. This will convert the date to the specified format. This MUST BE IN dayjs format. If you determine that a column type is a date column, you should specify it's date format here. - dateFormat: z.optional(z.union([z.literal('auto'), z.string()])), - // OPTIONAL: default is null. This will only apply if the format is set to 'number'. This will convert the number to a specified date unit. For example, if month_of_year is selected, then the number 0 will be converted to January. - convertNumberTo: z.optional( - z.nullable(z.enum(['day_of_week', 'month_of_year', 'quarter', 'number'])) - ) -}); - -// Create ColumnLabelFormatSchema by extending IColumnLabelFormatSchema with optional columnType and style -export const ColumnLabelFormatSchema = IColumnLabelFormatSchema.extend({ - columnType: z.optional(z.enum(['number', 'text', 'date'] as const)), - style: z.optional(z.enum(['currency', 'percent', 'number', 'date', 'string'])) -}); - -// Export inferred types -export type ColumnLabelFormat = z.infer; -export type IColumnLabelFormat = z.infer; diff --git a/apps/web/src/api/asset_interfaces/metric/charts/index.ts b/apps/web/src/api/asset_interfaces/metric/charts/index.ts index 96dedee78..957860982 100644 --- a/apps/web/src/api/asset_interfaces/metric/charts/index.ts +++ b/apps/web/src/api/asset_interfaces/metric/charts/index.ts @@ -1,10 +1 @@ -export * from './annotationInterfaces'; -export * from './axisInterfaces'; -export * from './chartBaseInterfaces'; -export * from './chartConfigProps'; -export * from './columnInterfaces'; -export * from './columnLabelInterfaces'; -export * from './enum'; -export * from './etcInterfaces'; export * from './interfaces'; -export * from './tickInterfaces'; diff --git a/apps/web/src/api/asset_interfaces/metric/charts/interfaces.ts b/apps/web/src/api/asset_interfaces/metric/charts/interfaces.ts index 291e52d31..215ea7a2b 100644 --- a/apps/web/src/api/asset_interfaces/metric/charts/interfaces.ts +++ b/apps/web/src/api/asset_interfaces/metric/charts/interfaces.ts @@ -1,6 +1,5 @@ import type { Chart, ChartType, DefaultDataPoint } from 'chart.js'; -import type { ColumnMetaData } from '../interfaces'; -import type { BusterChartConfigProps } from './chartConfigProps'; +import type { ColumnMetaData, ChartConfigProps } from '@buster/server-shared/metrics'; export type BusterChartProps = { data: Record[] | null; @@ -15,7 +14,7 @@ export type BusterChartProps = { readOnly?: boolean; onInitialAnimationEnd?: () => void; onChartMounted?: (chart?: ChartJSOrUndefined) => void; -} & BusterChartConfigProps; +} & ChartConfigProps; type ChartJSOrUndefined< TType extends ChartType = ChartType, diff --git a/apps/web/src/api/asset_interfaces/metric/charts/pieChartProps.ts b/apps/web/src/api/asset_interfaces/metric/charts/pieChartProps.ts deleted file mode 100644 index 856f6e9f1..000000000 --- a/apps/web/src/api/asset_interfaces/metric/charts/pieChartProps.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { z } from 'zod/v4'; -import { PieChartAxisSchema } from './axisInterfaces'; -import { PieSortBySchema } from './etcInterfaces'; - -export const PieChartPropsSchema = z.object({ - // OPTIONAL: default: value - pieSortBy: PieSortBySchema, - // Required for Pie - pieChartAxis: PieChartAxisSchema, - // OPTIONAL: default: number - pieDisplayLabelAs: z.enum(['percent', 'number']).default('number'), - // OPTIONAL: default true if donut width is set. If the data contains a percentage, set this as false. - pieShowInnerLabel: z.boolean().default(true), - // OPTIONAL: default: sum - pieInnerLabelAggregate: z - .enum(['sum', 'average', 'median', 'max', 'min', 'count']) - .default('sum'), - // OPTIONAL: default is null and will be the name of the pieInnerLabelAggregate - pieInnerLabelTitle: z.string().optional(), - // OPTIONAL: default: outside - pieLabelPosition: z.nullable(z.enum(['inside', 'outside', 'none'])).default(null), - // OPTIONAL: default: 55 | range 0-65 | range represents percent size of the donut hole. If user asks for a pie this should be 0 - pieDonutWidth: z - .number() - .min(0, 'Donut width must be at least 0') - .max(65, 'Donut width must be at most 65') - .default(40), - // OPTIONAL: default: 2.5 | range 0-100 | If there are items that are less than this percentage of the pie, they combine to form a single slice. - pieMinimumSlicePercentage: z - .number() - .min(0, 'Minimum slice percentage must be at least 0') - .max(100, 'Minimum slice percentage must be at most 100') - .default(0) -}); - -export type PieChartProps = z.infer; diff --git a/apps/web/src/api/asset_interfaces/metric/charts/tickInterfaces.ts b/apps/web/src/api/asset_interfaces/metric/charts/tickInterfaces.ts deleted file mode 100644 index cb10f4e1b..000000000 --- a/apps/web/src/api/asset_interfaces/metric/charts/tickInterfaces.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { z } from 'zod/v4'; - -/** - * Configuration options for the Y-axis of a chart. - */ -export const YAxisConfigSchema = z.object({ - // Whether to show the axis label. Defaults to true. - yAxisShowAxisLabel: z.boolean().default(true), - // Whether to show the axis title. Defaults to true. - yAxisShowAxisTitle: z.boolean().default(true), - // The title of the Y-axis. @default null - Uses the name of the first column plotted on the Y-axis - yAxisAxisTitle: z.nullable(z.string()).default(null), - // Whether to start the axis at zero. Defaults to null. - yAxisStartAxisAtZero: z.nullable(z.boolean()).default(null), - // The scale type for the Y-axis. @default "linear" - yAxisScaleType: z.enum(['log', 'linear']).default('linear') -}); - -//The y2 (or right axis) Y-axis is used for secondary Y-axes in a combo chart. -/** - * Configuration options for the secondary Y-axis (Y2) in a combo chart. - */ -export const Y2AxisConfigSchema = z.object({ - // Whether to show the axis label. Defaults to true. - y2AxisShowAxisLabel: z.boolean().default(true), - // Whether to show the axis title. Defaults to true. - y2AxisShowAxisTitle: z.boolean().default(true), - // The title of the secondary Y-axis. @default null - Uses the name of the first column plotted on the Y2-axis - y2AxisAxisTitle: z.nullable(z.string()).default(null), - // Whether to start the axis at zero. Defaults to true. - y2AxisStartAxisAtZero: z.boolean().default(true), - // The scale type for the secondary Y-axis. @default "linear" - y2AxisScaleType: z.enum(['log', 'linear']).default('linear') -}); - -/** - * Configuration options for the X-axis of a chart. - */ -export const XAxisConfigSchema = z.object({ - // The time interval for the X-axis. Only applies to combo and line charts. @default null - xAxisTimeInterval: z.nullable(z.enum(['day', 'week', 'month', 'quarter', 'year'])).default(null), - // Whether to show the axis label. Defaults to true. - xAxisShowAxisLabel: z.boolean().default(true), - // Whether to show the axis title. Defaults to true. - xAxisShowAxisTitle: z.boolean().default(true), - // The title of the X-axis. @default null - Uses a concatenation of all X columns applied to the axis - xAxisAxisTitle: z.nullable(z.string()).default(null), - // The rotation angle for the X-axis labels. @default "auto" - xAxisLabelRotation: z - .union([z.literal(0), z.literal(45), z.literal(90), z.literal('auto')]) - .default('auto'), - // Whether to enable data zooming on the X-axis. Should only be set to true by the user. @default false - xAxisDataZoom: z.boolean().default(false) -}); - -//The category axis works differently than the other axes. It is used to color and group the data. -/** - * Configuration options for styling the category axis. - * The category axis is used to color and group the data. - */ -export const CategoryAxisStyleConfigSchema = z.object({ - // The title of the category axis. @default null - categoryAxisTitle: z.nullable(z.string()).default(null) -}); - -// Export inferred types -export type YAxisConfig = z.infer; -export type Y2AxisConfig = z.infer; -export type XAxisConfig = z.infer; -export type CategoryAxisStyleConfig = z.infer; diff --git a/apps/web/src/api/asset_interfaces/metric/defaults.ts b/apps/web/src/api/asset_interfaces/metric/defaults.ts deleted file mode 100644 index 57ff8b3e2..000000000 --- a/apps/web/src/api/asset_interfaces/metric/defaults.ts +++ /dev/null @@ -1,187 +0,0 @@ -import { ShareRole } from '../share/shareInterfaces'; -import { VerificationStatus } from '../share/verificationInterfaces'; -import { type ColumnLabelFormat, type ColumnSettings } from './charts'; -import { DEFAULT_CHART_THEME } from './charts/configColors'; -import type { ColumnMetaData } from './interfaces'; -import type { IBusterMetric, IBusterMetricChartConfig } from './requireInterfaces'; - -export const DEFAULT_CHART_CONFIG: IBusterMetricChartConfig = { - colors: DEFAULT_CHART_THEME, - selectedChartType: 'table', - yAxisShowAxisLabel: true, - yAxisShowAxisTitle: true, - yAxisAxisTitle: null, - yAxisStartAxisAtZero: null, - yAxisScaleType: 'linear', - y2AxisShowAxisLabel: true, - y2AxisAxisTitle: null, - y2AxisShowAxisTitle: true, - y2AxisStartAxisAtZero: true, - y2AxisScaleType: 'linear', - xAxisTimeInterval: null, - xAxisShowAxisLabel: true, - xAxisShowAxisTitle: true, - xAxisAxisTitle: null, - xAxisLabelRotation: 'auto', - xAxisDataZoom: false, - categoryAxisTitle: null, - showLegend: null, - gridLines: true, - goalLines: [], - trendlines: [], - showLegendHeadline: false, - disableTooltip: false, - barAndLineAxis: { - x: [], - y: [], - category: [], - tooltip: null - }, - scatterAxis: { - x: [], - y: [], - category: [], - size: [], - tooltip: null - }, - comboChartAxis: { - x: [], - y: [], - y2: [], - category: [], - tooltip: null - }, - pieChartAxis: { - x: [], - y: [], - tooltip: null - }, - //LINE - lineGroupType: null, - //SCATTER - scatterDotSize: [3, 15], - //BAR - barSortBy: [], - barLayout: 'vertical', - barGroupType: 'group', - barShowTotalAtTop: false, - //PIE - pieShowInnerLabel: true, - pieInnerLabelAggregate: 'sum', - pieInnerLabelTitle: 'Total', - pieLabelPosition: null, - pieDonutWidth: 40, - pieMinimumSlicePercentage: 0, - pieDisplayLabelAs: 'number', - pieSortBy: 'value', - //METRIC - metricColumnId: '', - metricValueAggregate: 'sum', - metricHeader: null, - metricSubHeader: null, - metricValueLabel: null, - //TABLE - tableColumnOrder: null, - tableColumnWidths: null, - tableHeaderBackgroundColor: null, - tableHeaderFontColor: null, - tableColumnFontColor: null, - //MUST LOOP THROUGH ALL COLUMNS - columnSettings: {}, - columnLabelFormats: {} -}; - -export const DEFAULT_COLUMN_SETTINGS: Required = { - showDataLabels: false, - columnVisualization: 'bar', - lineWidth: 2, - lineStyle: 'line', - lineType: 'normal', - lineSymbolSize: 0, - barRoundness: 8, - showDataLabelsAsPercentage: false -}; - -export const DEFAULT_COLUMN_LABEL_FORMAT: Required = { - style: 'string', - compactNumbers: false, - columnType: 'text', - displayName: '', - numberSeparatorStyle: ',', - minimumFractionDigits: 0, - maximumFractionDigits: 2, - currency: 'USD', - convertNumberTo: null, - dateFormat: 'auto', - useRelativeTime: false, - isUTC: false, - multiplier: 1, - prefix: '', - suffix: '', - replaceMissingDataWith: 0, - makeLabelHumanReadable: true -}; - -export const ENABLED_DOTS_ON_LINE = 3.5; -export const DEFAULT_CHART_CONFIG_ENTRIES = Object.entries(DEFAULT_CHART_CONFIG); -export const DEFAULT_BAR_ROUNDNESS = DEFAULT_COLUMN_SETTINGS.barRoundness; -export const MIN_DONUT_WIDTH = 15; - -export const DEFAULT_DAY_OF_WEEK_FORMAT = 'ddd'; -export const DEFAULT_DATE_FORMAT_DAY_OF_WEEK = 'dddd'; -export const DEFAULT_DATE_FORMAT_MONTH_OF_YEAR = 'MMMM'; -export const DEFAULT_DATE_FORMAT_QUARTER = 'YYYY [Q]Q'; - -export const ENABLED_DOTS_ON_LINE_SIZE = 4; -export const DEFAULT_COLUMN_METADATA: ColumnMetaData[] = []; - -export const DEFAULT_IBUSTER_METRIC: Required = { - id: 'DEFAULT_ID', - type: 'metric', - name: '', - version_number: 1, - description: '', - time_frame: '', - sql: null, - dataset_id: '', - dataset_name: null, - error: null, - data_metadata: null, - status: VerificationStatus.NOT_REQUESTED, - evaluation_score: 'Moderate', - evaluation_summary: '', - file_name: '', - file: '', - data_source_id: '', - created_at: '', - updated_at: '', - sent_by_id: '', - sent_by_name: '', - permission: ShareRole.CAN_VIEW, - sent_by_avatar_url: null, - dashboards: [], - collections: [], - chart_config: DEFAULT_CHART_CONFIG, - individual_permissions: null, - public_expiry_date: null, - public_enabled_by: null, - publicly_accessible: false, - public_password: null, - versions: [] -}; - -export const DEFAULT_TRENDLINE_CONFIG: Required = { - id: 'DEFAULT_ID', - columnId: '', - show: true, - showTrendlineLabel: false, - trendlineLabel: null, - type: 'linear_regression', - trendLineColor: '#FF0000', - trendlineLabelPositionOffset: 85, - projection: true, - lineStyle: 'solid', - polynomialOrder: 2, - aggregateAllCategories: true, - offset: 0 -}; diff --git a/apps/web/src/api/asset_interfaces/metric/index.ts b/apps/web/src/api/asset_interfaces/metric/index.ts index 19fceeb0a..731ebdbf6 100644 --- a/apps/web/src/api/asset_interfaces/metric/index.ts +++ b/apps/web/src/api/asset_interfaces/metric/index.ts @@ -1,6 +1,4 @@ export * from './charts'; -export * from './defaults'; export * from './interfaces'; export * from './listInterfaces'; export * from './metricDataInterfaces'; -export * from './requireInterfaces'; diff --git a/apps/web/src/api/asset_interfaces/metric/interfaces.ts b/apps/web/src/api/asset_interfaces/metric/interfaces.ts index 2e70b88a7..0c4bf6552 100644 --- a/apps/web/src/api/asset_interfaces/metric/interfaces.ts +++ b/apps/web/src/api/asset_interfaces/metric/interfaces.ts @@ -1,88 +1,3 @@ -import type { BusterShare, VerificationStatus } from '../share'; -import type { BusterChartConfigProps } from './charts'; +import type { Metric } from '@buster/server-shared/metrics'; -export type BusterMetric = { - id: string; - type: 'metric'; - name: string; - version_number: number; - description: string | null; - file_name: string; - time_frame: string; - dataset_id: string; - data_source_id: string; - dataset_name: string | null; - error: string | null; - chart_config?: BusterChartConfigProps; - data_metadata: DataMetadata; - status: VerificationStatus; - evaluation_score: 'Moderate' | 'High' | 'Low'; - evaluation_summary: string; - file: string; //yaml file - created_at: string; - updated_at: string; - sent_by_id: string; - sent_by_name: string; - sent_by_avatar_url: string | null; - sql: string | null; - dashboards: { - id: string; - name: string; - }[]; - collections: { - id: string; - name: string; - }[]; - versions: { - version_number: number; - updated_at: string; - }[]; -} & BusterShare; - -export type DataMetadata = { - column_count: number; - column_metadata: ColumnMetaData[]; - row_count: number; -} | null; - -export type ColumnMetaData = { - name: string; - min_value: number | string; - max_value: number | string; - unique_values: number; - simple_type: 'text' | 'number' | 'date'; - type: - | 'text' - | 'float' - | 'integer' - | 'date' - | 'float8' - | 'timestamp' - | 'timestamptz' - | 'bool' - | 'date' - | 'time' - | 'boolean' - | 'json' - | 'jsonb' - | 'int8' - | 'int4' - | 'int2' - | 'decimal' - | 'char' - | 'character varying' - | 'character' - | 'varchar' - | 'text' - | 'number' - | 'numeric' - | 'tinytext' - | 'mediumtext' - | 'longtext' - | 'nchar' - | 'nvarchat' - | 'ntext' - | 'float4'; -}; - -export type IDataResult = Record[] | null; +export type BusterMetric = Metric; diff --git a/apps/web/src/api/asset_interfaces/metric/listInterfaces.ts b/apps/web/src/api/asset_interfaces/metric/listInterfaces.ts index ca69b417e..23f4e219d 100644 --- a/apps/web/src/api/asset_interfaces/metric/listInterfaces.ts +++ b/apps/web/src/api/asset_interfaces/metric/listInterfaces.ts @@ -1,15 +1,3 @@ -import type { VerificationStatus } from '../share'; +import type { MetricListItem } from '@buster/server-shared/metrics'; -export type BusterMetricListItem = { - id: string; - name: string; - last_edited: string; - dataset_name: string; - dataset_uuid: string; - created_by_id: string; - created_by_name: string; - created_by_email: string; - created_by_avatar: string; - status: VerificationStatus; - is_shared: boolean; -}; +export type BusterMetricListItem = MetricListItem; diff --git a/apps/web/src/api/asset_interfaces/metric/metricDataInterfaces.ts b/apps/web/src/api/asset_interfaces/metric/metricDataInterfaces.ts index 54f342144..260e81d6a 100644 --- a/apps/web/src/api/asset_interfaces/metric/metricDataInterfaces.ts +++ b/apps/web/src/api/asset_interfaces/metric/metricDataInterfaces.ts @@ -1,14 +1,14 @@ -import type { DataMetadata, IDataResult } from './interfaces'; +import type { DataMetadata, DataResult } from '@buster/server-shared/metrics'; export type BusterMetricData = { - data: IDataResult | null; + data: DataResult | null; data_metadata: DataMetadata; metricId: string; }; -export type IBusterMetricData = { - data: IDataResult | null; - dataFromRerun?: IDataResult; //this is actually only used in the UI. maybe move this to ? +export type BusterMetricDataExtended = { + data: DataResult | null; + dataFromRerun?: DataResult; //this is actually only used in the UI. maybe move this to ? data_metadata: DataMetadata; runRunDataMetadata?: DataMetadata; metricId: string; diff --git a/apps/web/src/api/asset_interfaces/metric/requireInterfaces.ts b/apps/web/src/api/asset_interfaces/metric/requireInterfaces.ts deleted file mode 100644 index 7eba474c7..000000000 --- a/apps/web/src/api/asset_interfaces/metric/requireInterfaces.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { BusterChartConfigProps, ColumnSettings, IColumnLabelFormat } from './charts'; -import type { BusterMetric } from './interfaces'; - -export type IBusterMetricChartConfig = Required< - Omit -> & { - columnLabelFormats: Record>; - columnSettings: Required>>; -}; - -export interface IBusterMetric extends Required { - chart_config: IBusterMetricChartConfig; -} diff --git a/apps/web/src/api/buster_rest/metrics/getMetricQueryRequests.ts b/apps/web/src/api/buster_rest/metrics/getMetricQueryRequests.ts index c539865eb..27d1956cc 100644 --- a/apps/web/src/api/buster_rest/metrics/getMetricQueryRequests.ts +++ b/apps/web/src/api/buster_rest/metrics/getMetricQueryRequests.ts @@ -6,9 +6,9 @@ import { } from '@tanstack/react-query'; import last from 'lodash/last'; import type { + BusterMetric, BusterMetricData, - IBusterMetric, - IBusterMetricData + BusterMetricDataExtended } from '@/api/asset_interfaces/metric'; import { metricsQueryKeys } from '@/api/query_keys/metric'; import { useBusterAssetsContextSelector } from '@/context/Assets/BusterAssetsProvider'; @@ -19,7 +19,7 @@ import type { RustApiError } from '../errors'; import { useGetMetricVersionNumber, useMetricQueryStore } from './metricQueryStore'; import { getMetric, getMetricData } from './requests'; -export const useGetMetric = ( +export const useGetMetric = ( { id, versionNumber: versionNumberProp @@ -27,7 +27,7 @@ export const useGetMetric = ( id: string | undefined; versionNumber?: number | null; //if null it will not use a params from the query params }, - params?: Omit, 'queryKey' | 'queryFn'> + params?: Omit, 'queryKey' | 'queryFn'> ) => { const queryClient = useQueryClient(); const setOriginalMetric = useOriginalMetricStore((x) => x.setOriginalMetric); @@ -108,7 +108,7 @@ export const usePrefetchGetMetricClient = () => { ); }; -export const useGetMetricData = ( +export const useGetMetricData = ( { id, versionNumber: versionNumberProp diff --git a/apps/web/src/api/buster_rest/metrics/requests.ts b/apps/web/src/api/buster_rest/metrics/requests.ts index 870d1ea7b..7df23c86e 100644 --- a/apps/web/src/api/buster_rest/metrics/requests.ts +++ b/apps/web/src/api/buster_rest/metrics/requests.ts @@ -1,9 +1,9 @@ import type { - BusterChartConfigProps, BusterMetric, BusterMetricData, BusterMetricListItem } from '@/api/asset_interfaces/metric'; +import type { ChartConfigProps } from '@buster/server-shared/metrics'; import type { VerificationStatus } from '@/api/asset_interfaces/share'; import type { ShareDeleteRequest, @@ -72,7 +72,7 @@ export const updateMetric = async (params: { /** SQL query associated with the metric */ sql?: string; /** chart_config to update */ - chart_config?: BusterChartConfigProps; + chart_config?: ChartConfigProps; /** file in yaml format to update */ file?: string; /** update the version number of the metric - default is true */ diff --git a/apps/web/src/api/buster_rest/metrics/updateMetricQueryRequests.ts b/apps/web/src/api/buster_rest/metrics/updateMetricQueryRequests.ts index 3c54614d7..94d61ee8c 100644 --- a/apps/web/src/api/buster_rest/metrics/updateMetricQueryRequests.ts +++ b/apps/web/src/api/buster_rest/metrics/updateMetricQueryRequests.ts @@ -1,6 +1,6 @@ import { useMutation, useQueryClient } from '@tanstack/react-query'; import { create } from 'mutative'; -import type { IBusterMetric } from '@/api/asset_interfaces/metric'; +import type { BusterMetric } from '@/api/asset_interfaces/metric'; import { collectionQueryKeys } from '@/api/query_keys/collection'; import { metricsQueryKeys } from '@/api/query_keys/metric'; import { useOriginalMetricStore } from '@/context/Metrics/useOriginalMetricStore'; @@ -225,9 +225,9 @@ export const useShareMetric = () => { variables.id, selectedVersionNumber ).queryKey; - queryClient.setQueryData(queryKey, (previousData: IBusterMetric | undefined) => { + queryClient.setQueryData(queryKey, (previousData: BusterMetric | undefined) => { if (!previousData) return previousData; - return create(previousData, (draft: IBusterMetric) => { + return create(previousData, (draft: BusterMetric) => { draft.individual_permissions = [ ...variables.params, ...(draft.individual_permissions || []) @@ -260,9 +260,9 @@ export const useUnshareMetric = () => { variables.id, selectedVersionNumber ).queryKey; - queryClient.setQueryData(queryKey, (previousData: IBusterMetric | undefined) => { + queryClient.setQueryData(queryKey, (previousData: BusterMetric | undefined) => { if (!previousData) return previousData; - return create(previousData, (draft: IBusterMetric) => { + return create(previousData, (draft: BusterMetric) => { draft.individual_permissions = draft.individual_permissions?.filter((t) => !variables.data.includes(t.email)) || []; }); @@ -293,9 +293,9 @@ export const useUpdateMetricShare = () => { variables.id, selectedVersionNumber ).queryKey; - queryClient.setQueryData(queryKey, (previousData: IBusterMetric | undefined) => { + queryClient.setQueryData(queryKey, (previousData: BusterMetric | undefined) => { if (!previousData) return previousData; - return create(previousData, (draft: IBusterMetric) => { + return create(previousData, (draft: BusterMetric) => { draft.individual_permissions = draft.individual_permissions?.map((t) => { const found = variables.params.users?.find((v) => v.email === t.email); @@ -330,7 +330,7 @@ export const useUpdateMetric = (params: { const { selectedVersionNumber } = useGetMetricVersionNumber(); const saveMetricToServer = useMemoizedFn( - async (newMetric: IBusterMetric, prevMetric: IBusterMetric) => { + async (newMetric: BusterMetric, prevMetric: BusterMetric) => { const changedValues = prepareMetricUpdateMetric(newMetric, prevMetric); if (changedValues) { await saveMetric({ ...changedValues, update_version: updateVersion }); @@ -342,7 +342,7 @@ export const useUpdateMetric = (params: { ({ id: metricId, ...newMetricPartial - }: Omit, 'status'> & { id: string }) => { + }: Omit, 'status'> & { id: string }) => { const options = metricsQueryKeys.metricsGetMetric(metricId, selectedVersionNumber); const prevMetric = getOriginalMetric(metricId); const newMetric = create(prevMetric, (draft) => { @@ -358,7 +358,7 @@ export const useUpdateMetric = (params: { ); const mutationFn = useMemoizedFn( - async (newMetricPartial: Omit, 'status'> & { id: string }) => { + async (newMetricPartial: Omit, 'status'> & { id: string }) => { const { newMetric, prevMetric } = combineAndSaveMetric(newMetricPartial); if (newMetric && prevMetric && saveToServer) { @@ -389,13 +389,13 @@ export const useBulkUpdateMetricVerificationStatus = () => { onMutate: (variables) => { for (const metric of variables) { const latestVersionNumber = getLatestMetricVersion(metric.id); - const foundMetric = queryClient.getQueryData( + const foundMetric = queryClient.getQueryData( metricsQueryKeys.metricsGetMetric(metric.id, latestVersionNumber).queryKey ); if (foundMetric) { queryClient.setQueryData( metricsQueryKeys.metricsGetMetric(metric.id, latestVersionNumber).queryKey, - create(foundMetric, (draft: IBusterMetric) => { + create(foundMetric, (draft: BusterMetric) => { draft.status = metric.status; }) ); diff --git a/apps/web/src/api/query_keys/metric.ts b/apps/web/src/api/query_keys/metric.ts index 0ef0d7f4a..d412a39f8 100644 --- a/apps/web/src/api/query_keys/metric.ts +++ b/apps/web/src/api/query_keys/metric.ts @@ -1,13 +1,13 @@ import { queryOptions } from '@tanstack/react-query'; import type { BusterMetricListItem, - IBusterMetric, - IBusterMetricData + BusterMetric, + BusterMetricDataExtended } from '@/api/asset_interfaces/metric'; import type { listMetrics } from '../buster_rest/metrics'; export const metricsGetMetric = (metricId: string, version_number: number | null) => { - return queryOptions({ + return queryOptions({ queryKey: ['metrics', 'get', metricId, version_number || 'INITIAL'] as const, staleTime: 60 * 1000 }); @@ -27,7 +27,7 @@ export const metricsGetList = ( }); export const metricsGetData = (id: string, version_number: number) => - queryOptions({ + queryOptions({ queryKey: ['metrics', 'data', id, version_number || 'INITIAL'] as const, staleTime: 3 * 60 * 60 * 1000 // 3 hours, }); diff --git a/apps/web/src/components/features/ShareMenu/helpers.ts b/apps/web/src/components/features/ShareMenu/helpers.ts index aa976391b..0234f3324 100644 --- a/apps/web/src/components/features/ShareMenu/helpers.ts +++ b/apps/web/src/components/features/ShareMenu/helpers.ts @@ -2,11 +2,11 @@ import type { BusterCollection, BusterDashboardResponse, BusterShare, - IBusterMetric + BusterMetric } from '@/api/asset_interfaces'; export const getShareAssetConfig = ( - message: IBusterMetric | BusterDashboardResponse | BusterCollection | null + message: BusterMetric | BusterDashboardResponse | BusterCollection | null ): BusterShare | null => { if (!message) return null; diff --git a/apps/web/src/components/ui/charts/BusterChartJS/hooks/useBusterChartJSLegend/useBusterChartJSLegend.ts b/apps/web/src/components/ui/charts/BusterChartJS/hooks/useBusterChartJSLegend/useBusterChartJSLegend.ts index fbe98a2c7..c6ce39a91 100644 --- a/apps/web/src/components/ui/charts/BusterChartJS/hooks/useBusterChartJSLegend/useBusterChartJSLegend.ts +++ b/apps/web/src/components/ui/charts/BusterChartJS/hooks/useBusterChartJSLegend/useBusterChartJSLegend.ts @@ -2,7 +2,7 @@ import type React from 'react'; import { useEffect, useMemo, useState, useTransition } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces/metric'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces/metric'; import type { BusterChartProps, ChartEncodes, @@ -28,7 +28,7 @@ interface UseBusterChartJSLegendProps { selectedChartType: ChartType; chartMounted: boolean; selectedAxis: ChartEncodes | undefined; - showLegendHeadline: IBusterMetricChartConfig['showLegendHeadline'] | undefined; + showLegendHeadline: BusterMetricChartConfig['showLegendHeadline'] | undefined; columnLabelFormats: NonNullable; loading: boolean; lineGroupType: BusterChartProps['lineGroupType']; diff --git a/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/axisHooks/useY2AxisTitle.ts b/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/axisHooks/useY2AxisTitle.ts index 54ec9b861..c5cb95dda 100644 --- a/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/axisHooks/useY2AxisTitle.ts +++ b/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/axisHooks/useY2AxisTitle.ts @@ -1,5 +1,5 @@ import { useMemo } from 'react'; -import type { BusterChartConfigProps } from '@/api/asset_interfaces/metric/charts'; +import type { ChartConfigProps } from '@buster/server-shared/metrics'; import { formatLabel } from '@/lib/columnFormatter'; import { AXIS_TITLE_SEPARATOR } from '../../../../commonHelpers/axisHelper'; import { truncateWithEllipsis } from '../../../../commonHelpers/titleHelpers'; @@ -12,10 +12,10 @@ export const useY2AxisTitle = ({ y2AxisShowAxisTitle }: { y2Axis: string[]; - columnLabelFormats: NonNullable; + columnLabelFormats: NonNullable; isSupportedChartForAxisTitles: boolean; - y2AxisAxisTitle: BusterChartConfigProps['y2AxisAxisTitle']; - y2AxisShowAxisTitle: BusterChartConfigProps['y2AxisShowAxisTitle']; + y2AxisAxisTitle: ChartConfigProps['y2AxisAxisTitle']; + y2AxisShowAxisTitle: ChartConfigProps['y2AxisShowAxisTitle']; }) => { const y2AxisColumnLabelFormats = useMemo(() => { return y2Axis.map((y) => columnLabelFormats[y]); diff --git a/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/useInteractions.ts b/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/useInteractions.ts index 02c612f60..b5628d788 100644 --- a/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/useInteractions.ts +++ b/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/useInteractions.ts @@ -1,11 +1,11 @@ import type { CoreInteractionOptions } from 'chart.js'; import { useMemo } from 'react'; import type { DeepPartial } from 'utility-types'; // Add this import -import type { BusterChartConfigProps } from '@/api/asset_interfaces/metric/charts'; +import type { ChartConfigProps } from '@buster/server-shared/metrics'; interface UseInteractionsProps { - selectedChartType: BusterChartConfigProps['selectedChartType']; - barLayout: BusterChartConfigProps['barLayout']; + selectedChartType: ChartConfigProps['selectedChartType']; + barLayout: ChartConfigProps['barLayout']; } export const useInteractions = ({ selectedChartType, barLayout }: UseInteractionsProps) => { diff --git a/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/useTooltipOptions.ts/barAndLineTooltipHelper.ts b/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/useTooltipOptions.ts/barAndLineTooltipHelper.ts index 65e8539ce..010b327fa 100644 --- a/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/useTooltipOptions.ts/barAndLineTooltipHelper.ts +++ b/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/useTooltipOptions.ts/barAndLineTooltipHelper.ts @@ -1,5 +1,5 @@ import type { Chart, ChartTypeRegistry, TooltipItem } from 'chart.js'; -import type { BusterChartConfigProps } from '@/api/asset_interfaces/metric/charts'; +import type { ChartConfigProps } from '@buster/server-shared/metrics'; import { formatLabel } from '@/lib'; import type { ITooltipItem } from '../../../../BusterChartTooltip/interfaces'; import { getPercentage } from './helpers'; @@ -7,7 +7,7 @@ import { getPercentage } from './helpers'; export const barAndLineTooltipHelper = ( dataPoints: TooltipItem[], chart: Chart, - columnLabelFormats: NonNullable, + columnLabelFormats: NonNullable, keyToUsePercentage: string[], hasMultipleShownDatasets: boolean, percentageMode: undefined | 'stacked' diff --git a/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/useTooltipOptions.ts/scatterTooltipHelper.ts b/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/useTooltipOptions.ts/scatterTooltipHelper.ts index 2fa47316b..9e7088200 100644 --- a/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/useTooltipOptions.ts/scatterTooltipHelper.ts +++ b/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/useTooltipOptions.ts/scatterTooltipHelper.ts @@ -1,11 +1,11 @@ import type { ChartTypeRegistry, TooltipItem } from 'chart.js'; -import type { BusterChartConfigProps } from '@/api/asset_interfaces/metric/charts'; +import type { ChartConfigProps } from '@buster/server-shared/metrics'; import { formatLabel } from '@/lib/columnFormatter'; import type { ITooltipItem } from '../../../../BusterChartTooltip/interfaces'; export const scatterTooltipHelper = ( dataPoints: TooltipItem[], - columnLabelFormats: NonNullable + columnLabelFormats: NonNullable ): ITooltipItem[] => { return dataPoints.slice(0, 1).flatMap((dataPoint) => { const dataPointDataset = dataPoint.dataset; diff --git a/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/useY2Axis.ts b/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/useY2Axis.ts index f7238be67..ed5b46338 100644 --- a/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/useY2Axis.ts +++ b/apps/web/src/components/ui/charts/BusterChartJS/hooks/useOptions/useY2Axis.ts @@ -1,18 +1,19 @@ import type { Scale, ScaleChartOptions } from 'chart.js'; import { useMemo } from 'react'; import type { DeepPartial } from 'utility-types'; -import { DEFAULT_CHART_CONFIG, DEFAULT_COLUMN_LABEL_FORMAT } from '@/api/asset_interfaces/metric'; -import { - type BusterChartConfigProps, - type BusterChartProps, - type ChartEncodes, - ChartType, - type ComboChartAxis, - type IColumnLabelFormat -} from '@/api/asset_interfaces/metric/charts'; import { useMemoizedFn } from '@/hooks'; import { formatYAxisLabel, yAxisSimilar } from '../../../commonHelpers'; import { useY2AxisTitle } from './axisHooks/useY2AxisTitle'; +import { + DEFAULT_CHART_CONFIG, + DEFAULT_COLUMN_LABEL_FORMAT, + type ChartConfigProps, + type ChartEncodes, + type ChartType, + type ColumnLabelFormat, + type ComboChartAxis +} from '@buster/server-shared/metrics'; +import type { BusterChartProps } from '@/api/asset_interfaces'; export const useY2Axis = ({ columnLabelFormats, @@ -24,7 +25,7 @@ export const useY2Axis = ({ y2AxisStartAxisAtZero, y2AxisScaleType }: { - columnLabelFormats: NonNullable; + columnLabelFormats: NonNullable; selectedAxis: ChartEncodes; selectedChartType: ChartType; y2AxisAxisTitle: BusterChartProps['y2AxisAxisTitle']; @@ -64,10 +65,10 @@ export const useY2Axis = ({ return y2AxisScaleType === 'log' ? 'logarithmic' : 'linear'; }, [y2AxisScaleType, isSupportedType]); - const y2AxisColumnFormats: Record = useMemo(() => { + const y2AxisColumnFormats: Record = useMemo(() => { if (!isSupportedType) return {}; - return y2AxisKeys.reduce>((acc, y) => { + return y2AxisKeys.reduce>((acc, y) => { acc[y] = columnLabelFormats[y] || DEFAULT_COLUMN_LABEL_FORMAT; return acc; }, {}); diff --git a/apps/web/src/components/ui/charts/BusterChartLegend/legendHeadlineHelpers.ts b/apps/web/src/components/ui/charts/BusterChartLegend/legendHeadlineHelpers.ts index 4b54911c6..b78353728 100644 --- a/apps/web/src/components/ui/charts/BusterChartLegend/legendHeadlineHelpers.ts +++ b/apps/web/src/components/ui/charts/BusterChartLegend/legendHeadlineHelpers.ts @@ -1,4 +1,4 @@ -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces/metric'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces/metric'; import type { BusterChartProps, ShowLegendHeadline } from '@/api/asset_interfaces/metric/charts'; import { formatLabel } from '@/lib/columnFormatter'; import { ArrayOperations } from '@/lib/math'; @@ -11,7 +11,7 @@ export const addLegendHeadlines = ( showLegendHeadline: ShowLegendHeadline, columnMetadata: NonNullable, columnLabelFormats: NonNullable, - selectedChartType: IBusterMetricChartConfig['selectedChartType'], + selectedChartType: BusterMetricChartConfig['selectedChartType'], xAxisKeys: string[] ) => { const isScatterChart = selectedChartType === 'scatter'; diff --git a/apps/web/src/components/ui/charts/TableChart/BusterTableChart.tsx b/apps/web/src/components/ui/charts/TableChart/BusterTableChart.tsx index e88641bda..f4ac15efc 100644 --- a/apps/web/src/components/ui/charts/TableChart/BusterTableChart.tsx +++ b/apps/web/src/components/ui/charts/TableChart/BusterTableChart.tsx @@ -3,7 +3,7 @@ import React, { useCallback } from 'react'; import { type BusterChartPropsBase, DEFAULT_CHART_CONFIG, - type IBusterMetricChartConfig + type BusterMetricChartConfig } from '@/api/asset_interfaces/metric'; import { AppDataGrid } from '@/components/ui/table/AppDataGrid'; import { useUpdateMetricChart } from '@/context/Metrics'; @@ -30,7 +30,7 @@ const BusterTableChartBase: React.FC = ({ }) => { const { onUpdateMetricChartConfig, onInitializeTableColumnWidths } = useUpdateMetricChart(); - const onChangeConfig = useMemoizedFn((config: Partial) => { + const onChangeConfig = useMemoizedFn((config: Partial) => { if (readOnly) return; onUpdateMetricChartConfig({ chartConfig: config }); if ( @@ -42,7 +42,7 @@ const BusterTableChartBase: React.FC = ({ }); const onUpdateTableColumnOrder = useMemoizedFn((columns: string[]) => { - const config: Partial = { + const config: Partial = { tableColumnOrder: columns }; @@ -51,7 +51,7 @@ const BusterTableChartBase: React.FC = ({ const onUpdateTableColumnSize = useMemoizedFn((columns: { key: string; size: number }[]) => { if (readOnly) return; - const config: Partial = { + const config: Partial = { tableColumnWidths: columns.reduce>((acc, { key, size }) => { acc[key] = Number(size.toFixed(1)); return acc; diff --git a/apps/web/src/components/ui/charts/commonHelpers/pieLabelHelpers.ts b/apps/web/src/components/ui/charts/commonHelpers/pieLabelHelpers.ts index 1fbcd1e55..7ec5ad8af 100644 --- a/apps/web/src/components/ui/charts/commonHelpers/pieLabelHelpers.ts +++ b/apps/web/src/components/ui/charts/commonHelpers/pieLabelHelpers.ts @@ -1,7 +1,7 @@ -import type { BusterChartConfigProps } from '@/api/asset_interfaces/metric/charts'; +import type { ChartConfigProps } from '@buster/server-shared/metrics'; export const InnerLabelTitleRecord: Record< - NonNullable, + NonNullable, string > = { sum: 'Total', @@ -13,8 +13,8 @@ export const InnerLabelTitleRecord: Record< }; export const getPieInnerLabelTitle = ( - pieInnerLabelTitle: BusterChartConfigProps['pieInnerLabelTitle'], - pieInnerLabelAggregate: BusterChartConfigProps['pieInnerLabelAggregate'] = 'sum' + pieInnerLabelTitle: ChartConfigProps['pieInnerLabelTitle'], + pieInnerLabelAggregate: ChartConfigProps['pieInnerLabelAggregate'] = 'sum' ) => { return pieInnerLabelTitle ?? InnerLabelTitleRecord[pieInnerLabelAggregate]; }; diff --git a/apps/web/src/context/Assets/HydrationBoundaryAssetStore.tsx b/apps/web/src/context/Assets/HydrationBoundaryAssetStore.tsx index e34d7cb10..2a552f82c 100644 --- a/apps/web/src/context/Assets/HydrationBoundaryAssetStore.tsx +++ b/apps/web/src/context/Assets/HydrationBoundaryAssetStore.tsx @@ -1,13 +1,13 @@ 'use client'; import type { BusterDashboardResponse } from '@/api/asset_interfaces/dashboard'; -import type { IBusterMetric } from '@/api/asset_interfaces/metric'; +import type { BusterMetric } from '@/api/asset_interfaces/metric'; import { HydrationBoundaryDashboardStore } from '../Dashboards/useOriginalDashboardStore'; import { HydrationBoundaryMetricStore } from '../Metrics/useOriginalMetricStore'; export const HydrationBoundaryAssetStore: React.FC<{ children: React.ReactNode; - asset: IBusterMetric | BusterDashboardResponse | undefined; + asset: BusterMetric | BusterDashboardResponse | undefined; }> = ({ children, asset }) => { if (!asset) return <>{children}; diff --git a/apps/web/src/context/Metrics/useGetMetricMemoized.ts b/apps/web/src/context/Metrics/useGetMetricMemoized.ts index 2db11e5f4..07d991e03 100644 --- a/apps/web/src/context/Metrics/useGetMetricMemoized.ts +++ b/apps/web/src/context/Metrics/useGetMetricMemoized.ts @@ -1,5 +1,5 @@ import { useQueryClient } from '@tanstack/react-query'; -import type { IBusterMetric, IBusterMetricData } from '@/api/asset_interfaces/metric'; +import type { BusterMetric, BusterMetricDataExtended } from '@/api/asset_interfaces/metric'; import { useGetMetricVersionNumber } from '@/api/buster_rest/metrics'; import { queryKeys } from '@/api/query_keys'; import { useMemoizedFn } from '@/hooks'; @@ -9,7 +9,7 @@ export const useGetMetricMemoized = () => { const queryClient = useQueryClient(); const { selectedVersionNumber } = useGetMetricVersionNumber(); const getMetricMemoized = useMemoizedFn( - (metricId: string, versionNumberProp?: number): IBusterMetric => { + (metricId: string, versionNumberProp?: number): BusterMetric => { const options = queryKeys.metricsGetMetric( metricId, versionNumberProp || selectedVersionNumber @@ -25,7 +25,7 @@ export const useGetMetricDataMemoized = () => { const queryClient = useQueryClient(); const { selectedVersionNumber, latestVersionNumber } = useGetMetricVersionNumber(); const getMetricDataMemoized = useMemoizedFn( - (metricId: string, versionNumberProp?: number): IBusterMetricData | undefined => { + (metricId: string, versionNumberProp?: number): BusterMetricDataExtended | undefined => { const versionNumber = versionNumberProp ?? selectedVersionNumber ?? latestVersionNumber; if (versionNumber == null) return undefined; const options = queryKeys.metricsGetData(metricId, versionNumber); diff --git a/apps/web/src/context/Metrics/useOriginalMetricStore.test.tsx b/apps/web/src/context/Metrics/useOriginalMetricStore.test.tsx index 23c5064d1..9eb6cdde8 100644 --- a/apps/web/src/context/Metrics/useOriginalMetricStore.test.tsx +++ b/apps/web/src/context/Metrics/useOriginalMetricStore.test.tsx @@ -1,6 +1,6 @@ import { act, renderHook } from '@testing-library/react'; import { beforeEach, describe, expect, it } from 'vitest'; -import type { IBusterMetric } from '@/api/asset_interfaces/metric'; +import type { BusterMetric } from '@/api/asset_interfaces/metric'; import { DEFAULT_CHART_CONFIG } from '@/api/asset_interfaces/metric/defaults'; import { VerificationStatus } from '@/api/asset_interfaces/share'; import { ShareRole } from '@/api/asset_interfaces/share/shareInterfaces'; @@ -13,7 +13,7 @@ describe('useOriginalMetricStore', () => { }); it('should correctly set and get a metric', () => { - const mockMetric: IBusterMetric = { + const mockMetric: BusterMetric = { id: 'test-metric-1', type: 'metric' as const, name: 'Test Metric', diff --git a/apps/web/src/context/Metrics/useOriginalMetricStore.tsx b/apps/web/src/context/Metrics/useOriginalMetricStore.tsx index 63b80af4b..346da8128 100644 --- a/apps/web/src/context/Metrics/useOriginalMetricStore.tsx +++ b/apps/web/src/context/Metrics/useOriginalMetricStore.tsx @@ -1,27 +1,27 @@ 'use client'; import { create } from 'zustand'; -import type { IBusterMetric } from '@/api/asset_interfaces/metric'; +import type { BusterMetric } from '@/api/asset_interfaces/metric'; import { useMount } from '@/hooks'; type OriginalMetricStore = { - originalMetrics: Record; - bulkAddOriginalMetrics: (metrics: Record) => void; - setOriginalMetric: (metric: IBusterMetric) => void; - getOriginalMetric: (metricId: string | undefined) => IBusterMetric | undefined; + originalMetrics: Record; + bulkAddOriginalMetrics: (metrics: Record) => void; + setOriginalMetric: (metric: BusterMetric) => void; + getOriginalMetric: (metricId: string | undefined) => BusterMetric | undefined; removeOriginalMetric: (metricId: string) => void; }; export const useOriginalMetricStore = create((set, get) => ({ originalMetrics: {}, - bulkAddOriginalMetrics: (metrics: Record) => + bulkAddOriginalMetrics: (metrics: Record) => set((prev) => ({ originalMetrics: { ...prev.originalMetrics, ...metrics } })), - setOriginalMetric: (metric: IBusterMetric) => + setOriginalMetric: (metric: BusterMetric) => set((state) => ({ originalMetrics: { ...state.originalMetrics, diff --git a/apps/web/src/context/Metrics/useUpdateMetricChart.ts b/apps/web/src/context/Metrics/useUpdateMetricChart.ts index c7478c43a..be45ae456 100644 --- a/apps/web/src/context/Metrics/useUpdateMetricChart.ts +++ b/apps/web/src/context/Metrics/useUpdateMetricChart.ts @@ -5,7 +5,7 @@ import { useState } from 'react'; import { type ColumnSettings, DEFAULT_CHART_CONFIG, - type IBusterMetricChartConfig, + type BusterMetricChartConfig, type IColumnLabelFormat } from '@/api/asset_interfaces/metric'; import { useUpdateMetric } from '@/api/buster_rest/metrics'; @@ -39,7 +39,7 @@ export const useUpdateMetricChart = (props?: { metricId?: string; chatId?: strin chartConfig, ignoreUndoRedo }: { - chartConfig: Partial; + chartConfig: Partial; ignoreUndoRedo?: boolean; }) => { const currentMetric = getMetricMemoized(metricId); @@ -52,7 +52,7 @@ export const useUpdateMetricChart = (props?: { metricId?: string; chatId?: strin // }); } - const newChartConfig: IBusterMetricChartConfig = { + const newChartConfig: BusterMetricChartConfig = { ...DEFAULT_CHART_CONFIG, ...currentMetric.chart_config, ...chartConfig @@ -129,10 +129,10 @@ export const useUpdateMetricChart = (props?: { metricId?: string; chatId?: strin }); const onInitializeTableColumnWidths = useMemoizedFn( - (tableColumnWidths: IBusterMetricChartConfig['tableColumnWidths']) => { + (tableColumnWidths: BusterMetricChartConfig['tableColumnWidths']) => { const originalMetric = getOriginalMetric(metricId); if (originalMetric) { - const newChartConfig: IBusterMetricChartConfig = { + const newChartConfig: BusterMetricChartConfig = { ...DEFAULT_CHART_CONFIG, ...originalMetric.chart_config, tableColumnWidths diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricChartEvaluation.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricChartEvaluation.tsx index 4ba1cf1f9..3ed552581 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricChartEvaluation.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricChartEvaluation.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import type { IBusterMetric } from '@/api/asset_interfaces/metric'; +import type { BusterMetric } from '@/api/asset_interfaces/metric'; import { Button, type ButtonProps } from '@/components/ui/buttons'; import { CircleCheck, @@ -9,7 +9,7 @@ import { import { Popover } from '@/components/ui/popover/Popover'; export const MetricChartEvaluation: React.FC<{ - evaluationScore: IBusterMetric['evaluation_score'] | undefined; + evaluationScore: BusterMetric['evaluation_score'] | undefined; evaluationSummary: string | undefined; }> = React.memo(({ evaluationScore, evaluationSummary }) => { const text = useMemo(() => { diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/MetricStylingAppSegment.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/MetricStylingAppSegment.tsx index 6b3f4f391..13fc0f47c 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/MetricStylingAppSegment.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/MetricStylingAppSegment.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { AppSegmented, type SegmentedItem } from '@/components/ui/segmented'; import { useMemoizedFn } from '@/hooks'; import { cn } from '@/lib/utils'; @@ -8,7 +8,7 @@ import { MetricStylingAppSegments } from './config'; export const MetricStylingAppSegment: React.FC<{ segment: MetricStylingAppSegments; setSegment: (segment: MetricStylingAppSegments) => void; - selectedChartType: IBusterMetricChartConfig['selectedChartType']; + selectedChartType: BusterMetricChartConfig['selectedChartType']; className?: string; }> = React.memo(({ segment, setSegment, selectedChartType, className = '' }) => { const isTable = selectedChartType === 'table'; diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppColors/ColorsApp/ColorsApp.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppColors/ColorsApp/ColorsApp.tsx index aa1ccb44e..12554d756 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppColors/ColorsApp/ColorsApp.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppColors/ColorsApp/ColorsApp.tsx @@ -1,6 +1,6 @@ import isEqual from 'lodash/isEqual'; import React, { useMemo, useState } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { useMemoizedFn } from '@/hooks'; import type { IColorTheme } from '../Common'; import { ThemeList } from '../Common/ThemeList'; @@ -8,8 +8,8 @@ import { ColorStyleSegments } from './ColorStyleSegments'; import { COLORFUL_THEMES, ColorAppSegments, MONOCHROME_THEMES } from './config'; export const ColorsApp: React.FC<{ - colors: IBusterMetricChartConfig['colors']; - onUpdateChartConfig: (chartConfig: Partial) => void; + colors: BusterMetricChartConfig['colors']; + onUpdateChartConfig: (chartConfig: Partial) => void; }> = ({ colors, onUpdateChartConfig }) => { const initialSelectedSegment = useMemo(() => { const isFromColorfulThemes = COLORFUL_THEMES.some((theme) => isEqual(theme.colors, colors)); @@ -44,7 +44,7 @@ export const ColorsApp: React.FC<{ const ColorPicker: React.FC<{ selectedSegmentColors: IColorTheme[]; - colors: IBusterMetricChartConfig['colors']; + colors: BusterMetricChartConfig['colors']; onChangeColorTheme: (theme: IColorTheme) => void; }> = React.memo(({ selectedSegmentColors, colors, onChangeColorTheme }) => { const themes = useMemo(() => { diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppColors/ColorsApp/config.ts b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppColors/ColorsApp/config.ts index 584b9f1c6..9af4145b7 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppColors/ColorsApp/config.ts +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppColors/ColorsApp/config.ts @@ -1,4 +1,3 @@ -import { DEFAULT_CHART_THEME } from '@/api/asset_interfaces/metric/charts/configColors'; import { BLUE_THEME, BLUE_TO_ORANGE_GRADIENT, diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppColors/PaletteApp/PaletteApp.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppColors/PaletteApp/PaletteApp.tsx index 4ce323e14..dcb85e350 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppColors/PaletteApp/PaletteApp.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppColors/PaletteApp/PaletteApp.tsx @@ -1,9 +1,9 @@ import React from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { Text } from '@/components/ui/typography'; export const PaletteApp: React.FC<{ - colors: IBusterMetricChartConfig['colors']; + colors: BusterMetricChartConfig['colors']; }> = React.memo(({ colors }) => { return (
diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppColors/StylingAppColors.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppColors/StylingAppColors.tsx index 74cf213d2..c04870bb7 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppColors/StylingAppColors.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppColors/StylingAppColors.tsx @@ -1,6 +1,6 @@ import { AnimatePresence, motion } from 'framer-motion'; import React, { useState } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { useUpdateMetricChart } from '@/context/Metrics'; import { useMemoizedFn } from '@/hooks'; import { cn } from '@/lib/classMerge'; @@ -11,13 +11,13 @@ import { PaletteApp } from './PaletteApp'; export const StylingAppColors: React.FC<{ className: string; - colors: IBusterMetricChartConfig['colors']; + colors: BusterMetricChartConfig['colors']; }> = React.memo(({ className, colors }) => { const [selectedTab, setSelectedTab] = useState(StylingAppColorsTab.Colors); const { onUpdateMetricChartConfig } = useUpdateMetricChart(); - const onUpdateChartConfig = useMemoizedFn((chartConfig: Partial) => { + const onUpdateChartConfig = useMemoizedFn((chartConfig: Partial) => { onUpdateMetricChartConfig({ chartConfig }); }); diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditBarAxisSorting.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditBarAxisSorting.tsx index fff933d2c..f0ce10ef7 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditBarAxisSorting.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditBarAxisSorting.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { BarSortBy } from '@/api/asset_interfaces/metric/charts'; import { BarChartSortNoneIcon } from '@/components/ui/icons/customIcons/BarChart_NoSort'; import { BarChartSortAscIcon } from '@/components/ui/icons/customIcons/BarChartSortAscIcon'; @@ -27,8 +27,8 @@ const options: SegmentedItem[] = [ ]; export const EditBarSorting: React.FC<{ - barSortBy: IBusterMetricChartConfig['barSortBy']; - onUpdateChartConfig: (v: Partial) => void; + barSortBy: BusterMetricChartConfig['barSortBy']; + onUpdateChartConfig: (v: Partial) => void; }> = React.memo(({ barSortBy, onUpdateChartConfig }) => { const selectedOption = useMemo(() => { return ( diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditBarRoundnessGlobal.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditBarRoundnessGlobal.tsx index 98c2c4c66..52877cad0 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditBarRoundnessGlobal.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditBarRoundnessGlobal.tsx @@ -1,12 +1,12 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { ColumnSettings } from '@/api/asset_interfaces/metric/charts'; import { useMemoizedFn } from '@/hooks'; import { EditBarRoundness } from '../StylingAppVisualize/SelectAxis/SelectAxisColumnContent/EditBarRoundness'; export const EditBarRoundnessGlobal: React.FC<{ - columnSettings: IBusterMetricChartConfig['columnSettings']; - onUpdateChartConfig: (chartConfig: Partial) => void; + columnSettings: BusterMetricChartConfig['columnSettings']; + onUpdateChartConfig: (chartConfig: Partial) => void; }> = React.memo(({ columnSettings, onUpdateChartConfig }) => { const mostPermissiveBarRoundness = useMemo(() => { return Object.values(columnSettings).reduce((acc, curr) => { @@ -15,9 +15,9 @@ export const EditBarRoundnessGlobal: React.FC<{ }, []); const onUpdateBarRoundness = useMemoizedFn((v: Partial) => { - const newColumnSettings: IBusterMetricChartConfig['columnSettings'] = Object.keys( + const newColumnSettings: BusterMetricChartConfig['columnSettings'] = Object.keys( columnSettings - ).reduce((acc, curr) => { + ).reduce((acc, curr) => { acc[curr] = { ...columnSettings[curr], ...v }; return acc; }, {}); diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditDotsOnLineGlobal.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditDotsOnLineGlobal.tsx index 2d00f30b1..0414e4f7a 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditDotsOnLineGlobal.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditDotsOnLineGlobal.tsx @@ -1,13 +1,13 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { ENABLED_DOTS_ON_LINE } from '@/api/asset_interfaces'; import { Switch } from '@/components/ui/switch'; import { useMemoizedFn } from '@/hooks'; import { LabelAndInput } from '../Common'; export const EditDotsOnLineGlobal: React.FC<{ - columnSettings: IBusterMetricChartConfig['columnSettings']; - onUpdateChartConfig: (config: Partial) => void; + columnSettings: BusterMetricChartConfig['columnSettings']; + onUpdateChartConfig: (config: Partial) => void; }> = React.memo(({ columnSettings, onUpdateChartConfig }) => { const allDotsOnLine = useMemo(() => { return Object.values(columnSettings).some((column) => column.lineSymbolSize > 0); @@ -15,12 +15,13 @@ export const EditDotsOnLineGlobal: React.FC<{ const onChangeAllSmooth = useMemoizedFn((value: boolean) => { onUpdateChartConfig({ - columnSettings: Object.keys(columnSettings).reduce< - IBusterMetricChartConfig['columnSettings'] - >((acc, curr) => { - acc[curr] = { ...columnSettings[curr], lineSymbolSize: value ? ENABLED_DOTS_ON_LINE : 0 }; - return acc; - }, {}) + columnSettings: Object.keys(columnSettings).reduce( + (acc, curr) => { + acc[curr] = { ...columnSettings[curr], lineSymbolSize: value ? ENABLED_DOTS_ON_LINE : 0 }; + return acc; + }, + {} + ) }); }); diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditGridLines.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditGridLines.tsx index bcf508b36..4e3826bc9 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditGridLines.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditGridLines.tsx @@ -1,11 +1,11 @@ import React from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { Switch } from '@/components/ui/switch'; import { LabelAndInput } from '../Common'; export const EditGridLines: React.FC<{ - gridLines: IBusterMetricChartConfig['gridLines']; - onUpdateChartConfig: (chartConfig: Partial) => void; + gridLines: BusterMetricChartConfig['gridLines']; + onUpdateChartConfig: (chartConfig: Partial) => void; }> = React.memo(({ gridLines, onUpdateChartConfig }) => { return ( diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieAppearance.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieAppearance.tsx index b355af8eb..732f9cbe8 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieAppearance.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieAppearance.tsx @@ -1,7 +1,7 @@ import React, { useMemo, useState } from 'react'; import { DEFAULT_CHART_CONFIG, - type IBusterMetricChartConfig, + type BusterMetricChartConfig, MIN_DONUT_WIDTH } from '@/api/asset_interfaces'; import { AppSegmented, type SegmentedItem } from '@/components/ui/segmented'; @@ -23,9 +23,9 @@ export const EditPieAppearance = React.memo( onUpdateChartConfig, pieChartAxis }: { - pieDonutWidth: IBusterMetricChartConfig['pieDonutWidth']; - onUpdateChartConfig: (config: Partial) => void; - pieChartAxis: IBusterMetricChartConfig['pieChartAxis']; + pieDonutWidth: BusterMetricChartConfig['pieDonutWidth']; + onUpdateChartConfig: (config: Partial) => void; + pieChartAxis: BusterMetricChartConfig['pieChartAxis']; }) => { const [showDonutWidthSelector, setShowDonutWidthSelector] = useState(pieDonutWidth > 0); const [value, setValue] = useState(pieDonutWidth); diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieInnerLabel.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieInnerLabel.tsx index 9fa906d96..c6d491abc 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieInnerLabel.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieInnerLabel.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { Input } from '@/components/ui/inputs'; import { Select, type SelectItem } from '@/components/ui/select'; import { LabelAndInput } from '../Common'; @@ -10,9 +10,9 @@ export const EditPieInnerLabel = React.memo( pieInnerLabelTitle, onUpdateChartConfig }: { - pieInnerLabelAggregate: IBusterMetricChartConfig['pieInnerLabelAggregate']; - pieInnerLabelTitle: IBusterMetricChartConfig['pieInnerLabelTitle']; - onUpdateChartConfig: (config: Partial) => void; + pieInnerLabelAggregate: BusterMetricChartConfig['pieInnerLabelAggregate']; + pieInnerLabelTitle: BusterMetricChartConfig['pieInnerLabelTitle']; + onUpdateChartConfig: (config: Partial) => void; }) => { return ( <> @@ -31,7 +31,7 @@ export const EditPieInnerLabel = React.memo( ); EditPieInnerLabel.displayName = 'EditPieInnerLabel'; -const options: SelectItem[] = [ +const options: SelectItem[] = [ { label: 'Sum', value: 'sum' }, { label: 'Average', value: 'average' }, { label: 'Median', value: 'median' }, @@ -41,8 +41,8 @@ const options: SelectItem[] ]; const EditPieInnerLabelAggregate: React.FC<{ - pieInnerLabelAggregate: IBusterMetricChartConfig['pieInnerLabelAggregate']; - onUpdateChartConfig: (config: Partial) => void; + pieInnerLabelAggregate: BusterMetricChartConfig['pieInnerLabelAggregate']; + onUpdateChartConfig: (config: Partial) => void; }> = ({ pieInnerLabelAggregate, onUpdateChartConfig }) => { const selectedOption = useMemo(() => { return options.find((option) => option.value === pieInnerLabelAggregate) || options[0]; @@ -56,7 +56,7 @@ const EditPieInnerLabelAggregate: React.FC<{ onChange={(value) => { const label = options.find((option) => option.value === value)?.label; onUpdateChartConfig({ - pieInnerLabelAggregate: value as IBusterMetricChartConfig['pieInnerLabelAggregate'], + pieInnerLabelAggregate: value as BusterMetricChartConfig['pieInnerLabelAggregate'], pieInnerLabelTitle: label as string }); }} @@ -66,8 +66,8 @@ const EditPieInnerLabelAggregate: React.FC<{ }; const EditPieInnerLabelTitle: React.FC<{ - pieInnerLabelTitle: IBusterMetricChartConfig['pieInnerLabelTitle']; - onUpdateChartConfig: (config: Partial) => void; + pieInnerLabelTitle: BusterMetricChartConfig['pieInnerLabelTitle']; + onUpdateChartConfig: (config: Partial) => void; }> = ({ pieInnerLabelTitle, onUpdateChartConfig }) => { return ( diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieLabelLocation.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieLabelLocation.tsx index f2a691902..de3e9d472 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieLabelLocation.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieLabelLocation.tsx @@ -1,11 +1,11 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { Select, type SelectItem } from '@/components/ui/select'; import { Switch } from '@/components/ui/switch'; import { useMemoizedFn } from '@/hooks'; import { LabelAndInput } from '../Common'; -const options: SelectItem>[] = [ +const options: SelectItem>[] = [ { label: 'Outside', value: 'outside' }, { label: 'Inside', value: 'inside' } ]; @@ -15,15 +15,15 @@ export const EditPieLabelLocation = React.memo( pieLabelPosition, onUpdateChartConfig }: { - pieLabelPosition: IBusterMetricChartConfig['pieLabelPosition']; - onUpdateChartConfig: (config: Partial) => void; + pieLabelPosition: BusterMetricChartConfig['pieLabelPosition']; + onUpdateChartConfig: (config: Partial) => void; }) => { const selectedLabelPosition = useMemo(() => { return options.find((option) => option.value === pieLabelPosition)?.value || 'outside'; }, [pieLabelPosition]); const hideLabel = pieLabelPosition === 'none' || !pieLabelPosition; - const onChangeSelect = useMemoizedFn((value: IBusterMetricChartConfig['pieLabelPosition']) => { + const onChangeSelect = useMemoizedFn((value: BusterMetricChartConfig['pieLabelPosition']) => { onUpdateChartConfig({ pieLabelPosition: value }); }); diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieMinimumSlicePercentage.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieMinimumSlicePercentage.tsx index 1fbc19816..58bfe3b38 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieMinimumSlicePercentage.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieMinimumSlicePercentage.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { SliderWithInputNumber } from '@/components/ui/slider'; import { useMemoizedFn } from '@/hooks'; import { LabelAndInput } from '../Common'; @@ -9,8 +9,8 @@ export const EditPieMinimumSlicePercentage = React.memo( pieMinimumSlicePercentage: initialValue, onUpdateChartConfig }: { - pieMinimumSlicePercentage: IBusterMetricChartConfig['pieMinimumSlicePercentage']; - onUpdateChartConfig: (config: Partial) => void; + pieMinimumSlicePercentage: BusterMetricChartConfig['pieMinimumSlicePercentage']; + onUpdateChartConfig: (config: Partial) => void; }) => { const [pieMinimumSlicePercentage, setIntermediateValue] = useState(initialValue); diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieShowInnerLabel.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieShowInnerLabel.tsx index 7a16d6900..215b75e4b 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieShowInnerLabel.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieShowInnerLabel.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { Switch } from '@/components/ui/switch'; import { LabelAndInput } from '../Common'; @@ -8,8 +8,8 @@ export const EditPieShowInnerLabel = React.memo( pieShowInnerLabel, onUpdateChartConfig }: { - pieShowInnerLabel: IBusterMetricChartConfig['pieShowInnerLabel']; - onUpdateChartConfig: (config: Partial) => void; + pieShowInnerLabel: BusterMetricChartConfig['pieShowInnerLabel']; + onUpdateChartConfig: (config: Partial) => void; }) => { return ( diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieSorting.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieSorting.tsx index 8230b0126..5a652d2b7 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieSorting.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditPieSorting.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { PieSortBy } from '@/api/asset_interfaces/metric/charts'; import { Empty, SortAlphaAscending, SortNumAscending } from '@/components/ui/icons'; import { AppSegmented, type SegmentedItem } from '@/components/ui/segmented'; @@ -25,8 +25,8 @@ const options: SegmentedItem | 'none'>[] = [ ]; export const EditPieSorting: React.FC<{ - pieSortBy: IBusterMetricChartConfig['pieSortBy']; - onUpdateChartConfig: (v: Partial) => void; + pieSortBy: BusterMetricChartConfig['pieSortBy']; + onUpdateChartConfig: (v: Partial) => void; }> = React.memo(({ pieSortBy, onUpdateChartConfig }) => { const selectedOption = useMemo(() => { return ( diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditReplaceMissingValuesWithGlobal.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditReplaceMissingValuesWithGlobal.tsx index 23a7612f4..84e671dcd 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditReplaceMissingValuesWithGlobal.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditReplaceMissingValuesWithGlobal.tsx @@ -1,12 +1,12 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { IColumnLabelFormat } from '@/api/asset_interfaces/metric/charts'; import { useMemoizedFn } from '@/hooks'; import { EditReplaceMissingData } from '../StylingAppVisualize/SelectAxis/SelectAxisColumnContent/EditReplaceMissingData'; export const EditReplaceMissingValuesWithGlobal: React.FC<{ - columnLabelFormats: IBusterMetricChartConfig['columnLabelFormats']; - onUpdateChartConfig: (config: Partial) => void; + columnLabelFormats: BusterMetricChartConfig['columnLabelFormats']; + onUpdateChartConfig: (config: Partial) => void; }> = React.memo(({ columnLabelFormats, onUpdateChartConfig }) => { const mostPermissiveMissingWith = useMemo(() => { return Object.values(columnLabelFormats).some( @@ -17,9 +17,9 @@ export const EditReplaceMissingValuesWithGlobal: React.FC<{ }, [columnLabelFormats]); const onUpdateColumnLabel = useMemoizedFn((config: Partial) => { - const newColumnLabelFormats: IBusterMetricChartConfig['columnLabelFormats'] = Object.entries( + const newColumnLabelFormats: BusterMetricChartConfig['columnLabelFormats'] = Object.entries( columnLabelFormats - ).reduce((acc, [key, value]) => { + ).reduce((acc, [key, value]) => { acc[key] = { ...value, ...config }; return acc; }, {}); diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditScatterDotSize.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditScatterDotSize.tsx index 169f524c9..ff5d4ac9f 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditScatterDotSize.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditScatterDotSize.tsx @@ -1,15 +1,15 @@ import isEmpty from 'lodash/isEmpty'; import React from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { ChartEncodes, ScatterAxis } from '@/api/asset_interfaces/metric/charts'; import { Slider } from '@/components/ui/slider'; import { useMemoizedFn } from '@/hooks'; import { LabelAndInput } from '../Common'; export const EditScatterDotSize: React.FC<{ - scatterDotSize: IBusterMetricChartConfig['scatterDotSize']; + scatterDotSize: BusterMetricChartConfig['scatterDotSize']; selectedAxis: ChartEncodes; - onUpdateChartConfig: (config: Partial) => void; + onUpdateChartConfig: (config: Partial) => void; }> = React.memo(({ scatterDotSize, selectedAxis, onUpdateChartConfig }) => { const hasSize = !isEmpty((selectedAxis as ScatterAxis).size); const defaultValue = hasSize ? scatterDotSize : scatterDotSize[0]; diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditShowGoalLine.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditShowGoalLine.tsx index 7fd95115a..96e99d6e4 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditShowGoalLine.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditShowGoalLine.tsx @@ -1,7 +1,7 @@ import { AnimatePresence, motion } from 'framer-motion'; import React, { useState } from 'react'; import { v4 as uuidv4 } from 'uuid'; -import type { ColumnMetaData, IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { ColumnMetaData, BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { ChartEncodes, GoalLine } from '@/api/asset_interfaces/metric/charts'; import { Button } from '@/components/ui/buttons'; import { ColorPicker } from '@/components/ui/color-picker'; @@ -18,8 +18,8 @@ interface LoopGoalLine extends GoalLine { } export const EditGoalLine: React.FC<{ - goalLines: IBusterMetricChartConfig['goalLines']; - onUpdateChartConfig: (config: Partial) => void; + goalLines: BusterMetricChartConfig['goalLines']; + onUpdateChartConfig: (config: Partial) => void; columnMetadata: ColumnMetaData[] | undefined; selectedAxis: ChartEncodes; }> = React.memo(({ goalLines, onUpdateChartConfig, columnMetadata, selectedAxis }) => { diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditShowHeadline.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditShowHeadline.tsx index c1390e978..1596cfa4e 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditShowHeadline.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditShowHeadline.tsx @@ -1,11 +1,11 @@ import first from 'lodash/first'; import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { Select, type SelectItem } from '@/components/ui/select'; import { useMemoizedFn } from '@/hooks'; import { LabelAndInput } from '../Common'; -const options: SelectItem[] = [ +const options: SelectItem[] = [ { label: 'None', value: 'false' }, { label: 'Total', value: 'total' }, { label: 'Average', value: 'average' }, @@ -21,11 +21,11 @@ const pieOptions: SelectItem<'false' | 'current'>[] = [ ]; export const EditShowHeadline: React.FC<{ - showLegendHeadline: IBusterMetricChartConfig['showLegendHeadline']; - onUpdateChartConfig: (config: Partial) => void; - lineGroupType: IBusterMetricChartConfig['lineGroupType']; - barGroupType: IBusterMetricChartConfig['barGroupType']; - selectedChartType: IBusterMetricChartConfig['selectedChartType']; + showLegendHeadline: BusterMetricChartConfig['showLegendHeadline']; + onUpdateChartConfig: (config: Partial) => void; + lineGroupType: BusterMetricChartConfig['lineGroupType']; + barGroupType: BusterMetricChartConfig['barGroupType']; + selectedChartType: BusterMetricChartConfig['selectedChartType']; }> = React.memo( ({ showLegendHeadline, onUpdateChartConfig, lineGroupType, barGroupType, selectedChartType }) => { const isStackPercentage = @@ -56,7 +56,7 @@ export const EditShowHeadline: React.FC<{ onUpdateChartConfig({ showLegend: true, - showLegendHeadline: transformedValue as IBusterMetricChartConfig['showLegendHeadline'] + showLegendHeadline: transformedValue as BusterMetricChartConfig['showLegendHeadline'] }); }); diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditShowLabelPieAsPercentage.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditShowLabelPieAsPercentage.tsx index 1a3d19472..35ae98c78 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditShowLabelPieAsPercentage.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditShowLabelPieAsPercentage.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { AppSegmented, type SegmentedItem } from '@/components/ui/segmented'; import { useMemoizedFn } from '@/hooks'; import { LabelAndInput } from '../Common'; @@ -14,8 +14,8 @@ export const EditShowLabelPieAsPercentage = React.memo( pieDisplayLabelAs, onUpdateChartConfig }: { - pieDisplayLabelAs: IBusterMetricChartConfig['pieDisplayLabelAs']; - onUpdateChartConfig: (config: Partial) => void; + pieDisplayLabelAs: BusterMetricChartConfig['pieDisplayLabelAs']; + onUpdateChartConfig: (config: Partial) => void; }) => { const selectedValue = useMemo(() => { return options.find((option) => option.value === pieDisplayLabelAs)?.value || 'number'; diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditShowLegend.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditShowLegend.tsx index 9ee242591..cb36d0e9c 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditShowLegend.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditShowLegend.tsx @@ -1,15 +1,15 @@ import React from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { ChartEncodes, ScatterAxis } from '@/api/asset_interfaces/metric/charts'; import { useLegendAutoShow } from '@/components/ui/charts/BusterChartLegend'; import { Switch } from '@/components/ui/switch'; import { LabelAndInput } from '../Common'; export const EditShowLegend: React.FC<{ - showLegend: IBusterMetricChartConfig['showLegend']; - selectedChartType: IBusterMetricChartConfig['selectedChartType']; + showLegend: BusterMetricChartConfig['showLegend']; + selectedChartType: BusterMetricChartConfig['selectedChartType']; selectedAxis: ChartEncodes; - onUpdateChartConfig: (chartConfig: Partial) => void; + onUpdateChartConfig: (chartConfig: Partial) => void; }> = React.memo( ({ showLegend: showLegendProp, selectedAxis, selectedChartType, onUpdateChartConfig }) => { const categoryAxisColumnNames = (selectedAxis as ScatterAxis)?.category; diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditSmoothLinesGlobal.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditSmoothLinesGlobal.tsx index bf8e644f6..1b4000ad9 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditSmoothLinesGlobal.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditSmoothLinesGlobal.tsx @@ -1,12 +1,12 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { Switch } from '@/components/ui/switch'; import { useMemoizedFn } from '@/hooks'; import { LabelAndInput } from '../Common'; export const EditSmoothLinesGlobal: React.FC<{ - columnSettings: IBusterMetricChartConfig['columnSettings']; - onUpdateChartConfig: (config: Partial) => void; + columnSettings: BusterMetricChartConfig['columnSettings']; + onUpdateChartConfig: (config: Partial) => void; }> = React.memo(({ columnSettings, onUpdateChartConfig }) => { const allSmooth = useMemo(() => { return Object.values(columnSettings).every((column) => column.lineType === 'smooth'); @@ -14,12 +14,13 @@ export const EditSmoothLinesGlobal: React.FC<{ const onChangeAllSmooth = useMemoizedFn((value: boolean) => { onUpdateChartConfig({ - columnSettings: Object.keys(columnSettings).reduce< - IBusterMetricChartConfig['columnSettings'] - >((acc, curr) => { - acc[curr] = { ...columnSettings[curr], lineType: value ? 'smooth' : 'normal' }; - return acc; - }, {}) + columnSettings: Object.keys(columnSettings).reduce( + (acc, curr) => { + acc[curr] = { ...columnSettings[curr], lineType: value ? 'smooth' : 'normal' }; + return acc; + }, + {} + ) }); }); diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditTrendline/EditTrendline.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditTrendline/EditTrendline.tsx index 1f1f15f1b..3cce1bdec 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditTrendline/EditTrendline.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditTrendline/EditTrendline.tsx @@ -3,7 +3,7 @@ import isEqual from 'lodash/isEqual'; import React, { useEffect, useMemo, useState } from 'react'; import { v4 as uuidv4 } from 'uuid'; import type { ColumnMetaData } from '@/api/asset_interfaces'; -import { DEFAULT_TRENDLINE_CONFIG, type IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import { DEFAULT_TRENDLINE_CONFIG, type BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { ChartEncodes, ScatterAxis, Trendline } from '@/api/asset_interfaces/metric/charts'; import { Button } from '@/components/ui/buttons'; import { JOIN_CHARACTER } from '@/components/ui/charts/commonHelpers'; @@ -30,13 +30,13 @@ export interface LoopTrendline extends Trendline { } export const EditTrendline: React.FC<{ - trendlines: IBusterMetricChartConfig['trendlines']; + trendlines: BusterMetricChartConfig['trendlines']; colors: string[]; - onUpdateChartConfig: (chartConfig: Partial) => void; + onUpdateChartConfig: (chartConfig: Partial) => void; selectedAxis: ChartEncodes; columnMetadata: ColumnMetaData[]; - columnLabelFormats: IBusterMetricChartConfig['columnLabelFormats']; - selectedChartType: IBusterMetricChartConfig['selectedChartType']; + columnLabelFormats: BusterMetricChartConfig['columnLabelFormats']; + selectedChartType: BusterMetricChartConfig['selectedChartType']; }> = React.memo( ({ trendlines, @@ -189,12 +189,12 @@ const EditTrendlineItem: React.FC<{ trend: LoopTrendline; isNewTrend: boolean; columnMetadata: ColumnMetaData[]; - columnLabelFormats: IBusterMetricChartConfig['columnLabelFormats']; + columnLabelFormats: BusterMetricChartConfig['columnLabelFormats']; yAxisEncodes: string[]; xAxisEncodes: string[]; categoryEncodes: string[] | null | undefined; colors: string[]; - selectedChartType: IBusterMetricChartConfig['selectedChartType']; + selectedChartType: BusterMetricChartConfig['selectedChartType']; onUpdateExistingTrendline: (trend: LoopTrendline) => void; onDeleteTrendline: (id: string) => void; }> = React.memo( @@ -254,8 +254,8 @@ const TrendlineItemContent: React.FC<{ xAxisEncodes: string[]; colors: string[]; categoryEncodes: string[] | null | undefined; - columnLabelFormats: IBusterMetricChartConfig['columnLabelFormats']; - selectedChartType: IBusterMetricChartConfig['selectedChartType']; + columnLabelFormats: BusterMetricChartConfig['columnLabelFormats']; + selectedChartType: BusterMetricChartConfig['selectedChartType']; onUpdateExistingTrendline: (trend: LoopTrendline) => void; }> = React.memo( ({ diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditTrendline/EditTrendlineColumnId.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditTrendline/EditTrendlineColumnId.tsx index 7b7f8d103..3838210cc 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditTrendline/EditTrendlineColumnId.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditTrendline/EditTrendlineColumnId.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import type { ColumnMetaData, IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { ColumnMetaData, BusterMetricChartConfig } from '@/api/asset_interfaces'; import { Select, type SelectItem } from '@/components/ui/select'; import { formatLabel } from '@/lib'; import { LabelAndInput } from '../../Common'; @@ -15,7 +15,7 @@ export const TrendlineColumnId = React.memo( }: { trend: LoopTrendline; columnMetadata: ColumnMetaData[]; - columnLabelFormats: IBusterMetricChartConfig['columnLabelFormats']; + columnLabelFormats: BusterMetricChartConfig['columnLabelFormats']; onUpdateExistingTrendline: (trend: LoopTrendline) => void; yAxisEncodes: string[]; }) => { diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditTrendline/EditTrendlineOption.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditTrendline/EditTrendlineOption.tsx index a7f77ef06..f843e3f96 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditTrendline/EditTrendlineOption.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditTrendline/EditTrendlineOption.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { ChartType, Trendline } from '@/api/asset_interfaces/metric/charts'; import { TriangleWarning } from '@/components/ui/icons'; import { Select, type SelectItem } from '@/components/ui/select'; @@ -22,7 +22,7 @@ export const EditTrendlineOption = React.memo( onUpdateExistingTrendline: (trend: LoopTrendline) => void; yAxisEncodes: string[]; xAxisEncodes: string[]; - columnLabelFormats: IBusterMetricChartConfig['columnLabelFormats']; + columnLabelFormats: BusterMetricChartConfig['columnLabelFormats']; selectedChartType: ChartType; }) => { const { type } = trend; diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditYAxisScaleGlobal.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditYAxisScaleGlobal.tsx index e7f7ec83c..769da4627 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditYAxisScaleGlobal.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/EditYAxisScaleGlobal.tsx @@ -1,18 +1,18 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { useMemoizedFn } from '@/hooks'; import { EditAxisScale } from '../StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/EditAxisScale'; export const EditYAxisScaleGlobal: React.FC<{ - yAxisScaleType: IBusterMetricChartConfig['yAxisScaleType']; - y2AxisScaleType: IBusterMetricChartConfig['y2AxisScaleType']; - onUpdateChartConfig: (config: Partial) => void; + yAxisScaleType: BusterMetricChartConfig['yAxisScaleType']; + y2AxisScaleType: BusterMetricChartConfig['y2AxisScaleType']; + onUpdateChartConfig: (config: Partial) => void; }> = React.memo(({ yAxisScaleType, y2AxisScaleType, onUpdateChartConfig }) => { const mostPermissiveScale = useMemo(() => { return yAxisScaleType === y2AxisScaleType ? yAxisScaleType : 'linear'; }, [yAxisScaleType, y2AxisScaleType]); - const onChangeAxisScale = useMemoizedFn((value: IBusterMetricChartConfig['yAxisScaleType']) => { + const onChangeAxisScale = useMemoizedFn((value: BusterMetricChartConfig['yAxisScaleType']) => { onUpdateChartConfig({ yAxisScaleType: value, y2AxisScaleType: value diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/StylingAppStyling.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/StylingAppStyling.tsx index 456383be2..1d843282e 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/StylingAppStyling.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/StylingAppStyling.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces/metric'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces/metric'; import { type BarAndLineAxis, ChartType } from '@/api/asset_interfaces/metric/charts'; import { Separator } from '@/components/ui/seperator'; import { useUpdateMetricChart } from '@/context/Metrics'; @@ -78,16 +78,16 @@ export const StylingAppStyling: React.FC< const { onUpdateMetricChartConfig } = useUpdateMetricChart(); const onUpdateDataLabel = useMemoizedFn((v: boolean) => { - const newColumnSettings: IBusterMetricChartConfig['columnSettings'] = Object.keys( + const newColumnSettings: BusterMetricChartConfig['columnSettings'] = Object.keys( columnSettings - ).reduce((acc, curr) => { + ).reduce((acc, curr) => { acc[curr] = { ...columnSettings[curr], showDataLabels: v }; return acc; }, {}); onUpdateChartConfig({ columnSettings: newColumnSettings }); }); - const onUpdateChartConfig = useMemoizedFn((chartConfig: Partial) => { + const onUpdateChartConfig = useMemoizedFn((chartConfig: Partial) => { onUpdateMetricChartConfig({ chartConfig }); }); @@ -185,9 +185,9 @@ export const StylingAppStyling: React.FC< const GlobalSettings: React.FC< { className: string; - columnSettings: IBusterMetricChartConfig['columnSettings']; - yAxisShowAxisTitle: IBusterMetricChartConfig['yAxisShowAxisTitle']; - yAxisShowAxisLabel: IBusterMetricChartConfig['yAxisShowAxisLabel']; + columnSettings: BusterMetricChartConfig['columnSettings']; + yAxisShowAxisTitle: BusterMetricChartConfig['yAxisShowAxisTitle']; + yAxisShowAxisLabel: BusterMetricChartConfig['yAxisShowAxisLabel']; } & Parameters[0] & Parameters[0] & Omit[0], 'hideYAxis'> & @@ -294,9 +294,9 @@ const GlobalSettings: React.FC< const ChartSpecificSettings: React.FC< { className: string; - columnSettings: IBusterMetricChartConfig['columnSettings']; - selectedChartType: IBusterMetricChartConfig['selectedChartType']; - columnLabelFormats: IBusterMetricChartConfig['columnLabelFormats']; + columnSettings: BusterMetricChartConfig['columnSettings']; + selectedChartType: BusterMetricChartConfig['selectedChartType']; + columnLabelFormats: BusterMetricChartConfig['columnLabelFormats']; } & Parameters[0] & Parameters[0] & Parameters[0] & @@ -567,7 +567,7 @@ const EtcSettings: React.FC< const PieSettings: React.FC< { className: string; - pieDonutWidth: IBusterMetricChartConfig['pieDonutWidth']; + pieDonutWidth: BusterMetricChartConfig['pieDonutWidth']; } & Parameters[0] & Parameters[0] > = React.memo( diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/StylingAppStylingNotSupported.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/StylingAppStylingNotSupported.tsx index d92f8735e..958c0dfdd 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/StylingAppStylingNotSupported.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppStyling/StylingAppStylingNotSupported.tsx @@ -1,10 +1,10 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { ChartType } from '@/api/asset_interfaces/metric/charts'; import { Text } from '@/components/ui/typography'; export const StylingAppStylingNotSupported = React.memo( - ({ selectedChartType }: { selectedChartType: IBusterMetricChartConfig['selectedChartType'] }) => { + ({ selectedChartType }: { selectedChartType: BusterMetricChartConfig['selectedChartType'] }) => { const title = useMemo(() => { if (selectedChartType === 'table') { return 'Styling for tables charts is coming soon'; diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxis.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxis.tsx index 2b1aef860..3004444b0 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxis.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxis.tsx @@ -1,6 +1,6 @@ import isEmpty from 'lodash/isEmpty'; import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { CategoryAxisStyleConfig, ChartEncodes, @@ -46,7 +46,7 @@ export const SelectAxis: React.FC< return Object.assign(acc, { [axis]: zone.items }); }, {} as ChartEncodes); - const newChartConfig: Partial = { + const newChartConfig: Partial = { [selectedAxisToEdit]: newChartEncodes }; diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnContent/EditDisplayAs.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnContent/EditDisplayAs.tsx index 688049681..941f5efd8 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnContent/EditDisplayAs.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnContent/EditDisplayAs.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { ChartType, type ColumnSettings } from '@/api/asset_interfaces/metric/charts'; import { ChartBarAxisX, ChartLine, ChartScatter } from '@/components/ui/icons'; import { AppSegmented, type SegmentedItem } from '@/components/ui/segmented'; @@ -40,7 +40,7 @@ const options = [ export const EditDisplayAs: React.FC<{ columnVisualization: Required['columnVisualization']; onUpdateColumnSettingConfig: (columnSettings: Partial) => void; - selectedChartType: IBusterMetricChartConfig['selectedChartType']; + selectedChartType: BusterMetricChartConfig['selectedChartType']; }> = React.memo(({ columnVisualization, onUpdateColumnSettingConfig, selectedChartType }) => { const selectedOption = useMemo(() => { if (selectedChartType === 'bar') return 'bar'; diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnContent/SelectAxisDropdownContent.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnContent/SelectAxisDropdownContent.tsx index 598744445..480b28b85 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnContent/SelectAxisDropdownContent.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnContent/SelectAxisDropdownContent.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { type ChartEncodes, type ColumnSettings } from '@/api/asset_interfaces/metric/charts'; import type { IColumnLabelFormat } from '@/api/asset_interfaces/metric/charts/columnLabelInterfaces'; import { useGetCurrencies } from '@/api/buster_rest/currency'; @@ -28,14 +28,14 @@ import { EditSuffix } from './EditSuffix'; import { EditTitle } from './EditTitle'; export const SelectAxisDropdownContent: React.FC<{ - columnSetting: IBusterMetricChartConfig['columnSettings'][string]; + columnSetting: BusterMetricChartConfig['columnSettings'][string]; columnLabelFormat: IColumnLabelFormat; selectedAxis: ChartEncodes | null; id: string; className?: string; - selectedChartType: IBusterMetricChartConfig['selectedChartType']; - barGroupType: IBusterMetricChartConfig['barGroupType']; - lineGroupType: IBusterMetricChartConfig['lineGroupType']; + selectedChartType: BusterMetricChartConfig['selectedChartType']; + barGroupType: BusterMetricChartConfig['barGroupType']; + lineGroupType: BusterMetricChartConfig['lineGroupType']; zoneId: SelectAxisContainerId; hideTitle?: boolean; classNames?: { @@ -115,13 +115,13 @@ const ColumnSettingComponent: React.FC<{ formattedTitle: string; onUpdateColumnConfig: (columnLabelFormat: Partial) => void; onUpdateColumnSettingConfig: (columnSetting: Partial) => void; - selectedChartType: IBusterMetricChartConfig['selectedChartType']; + selectedChartType: BusterMetricChartConfig['selectedChartType']; selectedAxis: ChartEncodes | null; - columnSetting: IBusterMetricChartConfig['columnSettings'][string]; + columnSetting: BusterMetricChartConfig['columnSettings'][string]; columnLabelFormat: IColumnLabelFormat; zoneId: SelectAxisContainerId; - lineGroupType: IBusterMetricChartConfig['lineGroupType']; - barGroupType: IBusterMetricChartConfig['barGroupType']; + lineGroupType: BusterMetricChartConfig['lineGroupType']; + barGroupType: BusterMetricChartConfig['barGroupType']; rowCount: number; }> = ({ formattedTitle, @@ -274,7 +274,7 @@ const LabelSettings: React.FC<{ onUpdateColumnConfig: (columnLabelFormat: Partial) => void; id: string; zoneId: SelectAxisContainerId; - selectedChartType: IBusterMetricChartConfig['selectedChartType']; + selectedChartType: BusterMetricChartConfig['selectedChartType']; }> = ({ columnLabelFormat, onUpdateColumnConfig, diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnPopover.stories.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnPopover.stories.tsx index 8d7c1975a..972ee0b98 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnPopover.stories.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnPopover.stories.tsx @@ -1,13 +1,13 @@ import type { Meta, StoryObj } from '@storybook/react'; import { HttpResponse, http } from 'msw'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; -import { type IColumnLabelFormat } from '@/api/asset_interfaces/metric/charts'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { Button } from '@/components/ui/buttons/Button'; import { SelectAxisContainerId } from './config'; import { SelectAxisColumnPopover, type SelectAxisColumnPopoverProps } from './SelectAxisColumnPopover'; +import type { ColumnLabelFormat } from '@buster/server-shared/metrics'; const meta: Meta = { title: 'Controllers/EditMetricController/SelectAxisColumnPopover', @@ -60,7 +60,7 @@ const mockProps: SelectAxisColumnPopoverProps = { replaceMissingDataWith: null, makeLabelHumanReadable: true, compactNumbers: false - } satisfies IColumnLabelFormat, + } satisfies ColumnLabelFormat, columnSetting: { showDataLabels: false, showDataLabelsAsPercentage: false, @@ -70,7 +70,7 @@ const mockProps: SelectAxisColumnPopoverProps = { lineType: 'normal' as const, lineSymbolSize: 0, barRoundness: 8 - } satisfies IBusterMetricChartConfig['columnSettings'][string], + } satisfies BusterMetricChartConfig['columnSettings'][string], id: 'test-id', selectedChartType: 'bar', barGroupType: 'group', diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnPopover.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnPopover.tsx index 931e5e179..4a9f8b888 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnPopover.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisColumnPopover.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { ChartEncodes, IColumnLabelFormat } from '@/api/asset_interfaces/metric/charts'; import { Popover } from '@/components/ui/popover/Popover'; import type { SelectAxisContainerId } from './config'; @@ -7,12 +7,12 @@ import { SelectAxisDropdownContent } from './SelectAxisColumnContent'; export interface SelectAxisColumnPopoverProps { columnLabelFormat: IColumnLabelFormat; - columnSetting: IBusterMetricChartConfig['columnSettings'][string]; + columnSetting: BusterMetricChartConfig['columnSettings'][string]; children: React.ReactNode; id: string; - selectedChartType: IBusterMetricChartConfig['selectedChartType']; - barGroupType: IBusterMetricChartConfig['barGroupType']; - lineGroupType: IBusterMetricChartConfig['lineGroupType']; + selectedChartType: BusterMetricChartConfig['selectedChartType']; + barGroupType: BusterMetricChartConfig['barGroupType']; + lineGroupType: BusterMetricChartConfig['lineGroupType']; zoneId: SelectAxisContainerId; selectedAxis: ChartEncodes | null; rowCount: number; diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisItemAvailableContainer.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisItemAvailableContainer.tsx index 4deb159a3..2cbc9f333 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisItemAvailableContainer.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisItemAvailableContainer.tsx @@ -1,7 +1,7 @@ import type { DraggableAttributes } from '@dnd-kit/core'; import type { SyntheticListenerMap } from '@dnd-kit/core/dist/hooks/utilities'; import React from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { ChartEncodes, IColumnLabelFormat } from '@/api/asset_interfaces/metric/charts'; import { Button } from '@/components/ui/buttons'; import { DotsVertical } from '@/components/ui/icons'; @@ -59,10 +59,10 @@ export const SelectAxisItemAvailableContainer = React.memo( const ThreeDotMenu: React.FC<{ isDragging?: boolean; columnLabelFormat: IColumnLabelFormat; - columnSetting: IBusterMetricChartConfig['columnSettings'][string]; - selectedChartType: IBusterMetricChartConfig['selectedChartType']; - barGroupType: IBusterMetricChartConfig['barGroupType']; - lineGroupType: IBusterMetricChartConfig['lineGroupType']; + columnSetting: BusterMetricChartConfig['columnSettings'][string]; + selectedChartType: BusterMetricChartConfig['selectedChartType']; + barGroupType: BusterMetricChartConfig['barGroupType']; + lineGroupType: BusterMetricChartConfig['lineGroupType']; zoneId: SelectAxisContainerId; selectedAxis: ChartEncodes | null; id: string; diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisItemContainer.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisItemContainer.tsx index fc3f585c2..8ed47b12c 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisItemContainer.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisItemContainer.tsx @@ -1,7 +1,6 @@ import type { DraggableAttributes } from '@dnd-kit/core'; import type { SyntheticListenerMap } from '@dnd-kit/core/dist/hooks/utilities'; import React, { useMemo } from 'react'; -import type { ChartEncodes, IColumnLabelFormat } from '@/api/asset_interfaces/metric/charts'; import { ErrorBoundary } from '@/components/ui/error'; import { useUpdateMetricChart } from '@/context/Metrics'; import { useMemoizedFn } from '@/hooks'; @@ -10,6 +9,7 @@ import { chartTypeToAxis, type SelectAxisContainerId, zoneIdToAxis } from './con import { SelectAxisDropdownContent } from './SelectAxisColumnContent'; import { SelectAxisItemLabel } from './SelectAxisItemLabel'; import { useSelectAxisContextSelector } from './useSelectAxisContext'; +import type { ChartEncodes, ColumnLabelFormat } from '@buster/server-shared/metrics'; interface SelectAxisItemContainerProps { id: string; @@ -25,7 +25,7 @@ interface SelectAxisItemContainerProps { export const SelectAxisItemContainer = React.memo( React.forwardRef( ({ id, zoneId, isPlaceholder, ...draggingProps }, ref) => { - const columnLabelFormat: undefined | IColumnLabelFormat = useSelectAxisContextSelector( + const columnLabelFormat: undefined | ColumnLabelFormat = useSelectAxisContextSelector( (x) => x.columnLabelFormats[id] ); const selectedAxis = useSelectAxisContextSelector((x) => x.selectedAxis); diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/CategoryAxisSettingContent.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/CategoryAxisSettingContent.tsx index 0b4a7f661..14b37b0f7 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/CategoryAxisSettingContent.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/CategoryAxisSettingContent.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { useUpdateMetricChart } from '@/context/Metrics'; import { useMemoizedFn } from '@/hooks'; import { useSelectAxisContextSelector } from '../useSelectAxisContext'; @@ -18,7 +18,7 @@ export const CategoryAxisSettingContent: React.FC = React.memo(() => { contextOnUpdateMetricChartConfig({ chartConfig: { categoryAxisTitle: value } }); }); - const onUpdateChartConfig = useMemoizedFn((chartConfig: Partial) => { + const onUpdateChartConfig = useMemoizedFn((chartConfig: Partial) => { contextOnUpdateMetricChartConfig({ chartConfig }); }); diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/EditAxisLabelRotation.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/EditAxisLabelRotation.tsx index ac717828a..e89113a47 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/EditAxisLabelRotation.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/EditAxisLabelRotation.tsx @@ -1,10 +1,10 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { AppSegmented, type SegmentedItem } from '@/components/ui/segmented'; import { useMemoizedFn } from '@/hooks'; import { LabelAndInput } from '../../../Common/LabelAndInput'; -const options: SegmentedItem[] = [ +const options: SegmentedItem[] = [ { label: 'Auto', value: 'auto' }, { label: '0°', value: 0 }, { label: '45°', value: 45 }, @@ -12,17 +12,17 @@ const options: SegmentedItem[] = ]; export const EditAxisLabelRotation: React.FC<{ - xAxisLabelRotation: IBusterMetricChartConfig['xAxisLabelRotation']; - onChangeLabelRotation: (value: IBusterMetricChartConfig['xAxisLabelRotation']) => void; + xAxisLabelRotation: BusterMetricChartConfig['xAxisLabelRotation']; + onChangeLabelRotation: (value: BusterMetricChartConfig['xAxisLabelRotation']) => void; }> = React.memo(({ xAxisLabelRotation, onChangeLabelRotation }) => { - const selectedOption: IBusterMetricChartConfig['xAxisLabelRotation'] = useMemo(() => { + const selectedOption: BusterMetricChartConfig['xAxisLabelRotation'] = useMemo(() => { return ( options.find((option) => option.value === xAxisLabelRotation)?.value ?? options[0]?.value ); }, [xAxisLabelRotation]); const onChange = useMemoizedFn((value: SegmentedItem) => { - onChangeLabelRotation(value.value as IBusterMetricChartConfig['xAxisLabelRotation']); + onChangeLabelRotation(value.value as BusterMetricChartConfig['xAxisLabelRotation']); }); return ( diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/EditAxisScale.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/EditAxisScale.tsx index c649f8ac0..3f1e986dc 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/EditAxisScale.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/EditAxisScale.tsx @@ -1,18 +1,16 @@ import React from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { Select } from '@/components/ui/select'; import { LabelAndInput } from '../../../Common/LabelAndInput'; -const options: { label: string; value: IBusterMetricChartConfig['yAxisScaleType'] }[] = [ +const options: { label: string; value: BusterMetricChartConfig['yAxisScaleType'] }[] = [ { label: 'Linear', value: 'linear' }, { label: 'Logarithmic', value: 'log' } ]; export const EditAxisScale: React.FC<{ - scaleType: - | IBusterMetricChartConfig['yAxisScaleType'] - | IBusterMetricChartConfig['y2AxisScaleType']; - onChangeAxisScale: (value: IBusterMetricChartConfig['yAxisScaleType']) => void; + scaleType: BusterMetricChartConfig['yAxisScaleType'] | BusterMetricChartConfig['y2AxisScaleType']; + onChangeAxisScale: (value: BusterMetricChartConfig['yAxisScaleType']) => void; }> = React.memo(({ scaleType, onChangeAxisScale }) => { return ( diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/EditGrouping.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/EditGrouping.tsx index 52ab3ef2a..52e5bab31 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/EditGrouping.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/EditGrouping.tsx @@ -1,28 +1,28 @@ import React, { useMemo, useState } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { Select, type SelectItem } from '@/components/ui/select'; import { Switch } from '@/components/ui/switch'; import { useMemoizedFn } from '@/hooks'; import { LabelAndInput } from '../../../Common/LabelAndInput'; -const barGroupingOptions: SelectItem>[] = [ +const barGroupingOptions: SelectItem>[] = [ { label: 'Grouped', value: 'group' }, { label: 'Stacked', value: 'stack' } ]; const lineGroupingOptions: SelectItem< - NonNullable | 'default' + NonNullable | 'default' >[] = [ { label: 'Default', value: 'default' }, { label: 'Stacked', value: 'stack' } ]; export const EditGrouping: React.FC<{ - selectedChartType: IBusterMetricChartConfig['selectedChartType']; - onUpdateChartConfig: (value: Partial) => void; - lineGroupType: IBusterMetricChartConfig['lineGroupType']; - barGroupType: IBusterMetricChartConfig['barGroupType']; - barShowTotalAtTop: IBusterMetricChartConfig['barShowTotalAtTop']; + selectedChartType: BusterMetricChartConfig['selectedChartType']; + onUpdateChartConfig: (value: Partial) => void; + lineGroupType: BusterMetricChartConfig['lineGroupType']; + barGroupType: BusterMetricChartConfig['barGroupType']; + barShowTotalAtTop: BusterMetricChartConfig['barShowTotalAtTop']; }> = React.memo( ({ selectedChartType, onUpdateChartConfig, lineGroupType, barGroupType, barShowTotalAtTop }) => { const isBarChart = selectedChartType === 'bar'; @@ -30,9 +30,7 @@ export const EditGrouping: React.FC<{ isBarChart ? barGroupType === 'stack' : lineGroupType === 'stack' ); const [value, setValue] = useState< - | IBusterMetricChartConfig['lineGroupType'] - | 'default' - | IBusterMetricChartConfig['barGroupType'] + BusterMetricChartConfig['lineGroupType'] | 'default' | BusterMetricChartConfig['barGroupType'] >(isBarChart ? barGroupType : lineGroupType); const showTotal = useMemo(() => { @@ -62,21 +60,21 @@ export const EditGrouping: React.FC<{ const onChangeGroupType = useMemoizedFn( ( - value: IBusterMetricChartConfig['lineGroupType'] | IBusterMetricChartConfig['barGroupType'] + value: BusterMetricChartConfig['lineGroupType'] | BusterMetricChartConfig['barGroupType'] ) => { if (selectedChartType === 'bar') { - const barGroupType = value as IBusterMetricChartConfig['barGroupType']; + const barGroupType = value as BusterMetricChartConfig['barGroupType']; onUpdateChartConfig({ barGroupType }); } else { - const lineGroupType = value as IBusterMetricChartConfig['lineGroupType']; + const lineGroupType = value as BusterMetricChartConfig['lineGroupType']; onUpdateChartConfig({ lineGroupType }); } } ); const onChangeGrouping = (value: string) => { - setValue(value as IBusterMetricChartConfig['barGroupType']); - onChangeGroupType(value as IBusterMetricChartConfig['barGroupType']); + setValue(value as BusterMetricChartConfig['barGroupType']); + onChangeGroupType(value as BusterMetricChartConfig['barGroupType']); }; return ( diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/EditShowAxisTitle.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/EditShowAxisTitle.tsx index ac0d3f445..8cc721a36 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/EditShowAxisTitle.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/EditShowAxisTitle.tsx @@ -1,14 +1,12 @@ import React, { useState } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { Input } from '@/components/ui/inputs'; import { Switch } from '@/components/ui/switch'; import { useMemoizedFn } from '@/hooks'; import { LabelAndInput } from '../../../Common/LabelAndInput'; export const EditShowAxisTitle: React.FC<{ - axisTitle: - | IBusterMetricChartConfig['xAxisAxisTitle'] - | IBusterMetricChartConfig['yAxisAxisTitle']; + axisTitle: BusterMetricChartConfig['xAxisAxisTitle'] | BusterMetricChartConfig['yAxisAxisTitle']; showAxisTitle: boolean; formattedColumnTitle: string; onChangeAxisTitle: (value: string | null) => void; @@ -64,9 +62,9 @@ const EditToggleAxisTitle: React.FC<{ export const EditAxisTitle: React.FC<{ label?: string; axisTitle: - | IBusterMetricChartConfig['xAxisAxisTitle'] - | IBusterMetricChartConfig['yAxisAxisTitle'] - | IBusterMetricChartConfig['categoryAxisTitle']; + | BusterMetricChartConfig['xAxisAxisTitle'] + | BusterMetricChartConfig['yAxisAxisTitle'] + | BusterMetricChartConfig['categoryAxisTitle']; onChangeTitle: (v: string | null) => void; formattedColumnTitle: string; }> = ({ axisTitle, onChangeTitle, formattedColumnTitle, label = 'Axis title' }) => { diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/XAxisSettingContent.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/XAxisSettingContent.tsx index 8f4a1fe02..dfc029e6d 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/XAxisSettingContent.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/XAxisSettingContent.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { ColumnLabelFormat } from '@/api/asset_interfaces/metric/charts'; import { AXIS_TITLE_SEPARATOR } from '@/components/ui/charts/commonHelpers/axisHelper'; import { useUpdateMetricChart } from '@/context/Metrics'; @@ -60,7 +60,7 @@ export const XAxisSettingContent: React.FC = React.memo(() => { }); const onChangeLabelRotation = useMemoizedFn( - (xAxisLabelRotation: IBusterMetricChartConfig['xAxisLabelRotation']) => { + (xAxisLabelRotation: BusterMetricChartConfig['xAxisLabelRotation']) => { onUpdateMetricChartConfig({ chartConfig: { xAxisLabelRotation diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/Y2AxisSettingContent.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/Y2AxisSettingContent.tsx index e5a29d79d..9db42ec93 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/Y2AxisSettingContent.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/Y2AxisSettingContent.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { ColumnLabelFormat, ComboChartAxis } from '@/api/asset_interfaces/metric/charts'; import { AXIS_TITLE_SEPARATOR } from '@/components/ui/charts/commonHelpers/axisHelper'; import { useUpdateMetricChart } from '@/context/Metrics'; @@ -52,7 +52,7 @@ export const Y2AxisSettingContent: React.FC = React.memo(() => { }); const onChangeAxisScale = useMemoizedFn( - (y2AxisScaleType: IBusterMetricChartConfig['y2AxisScaleType']) => { + (y2AxisScaleType: BusterMetricChartConfig['y2AxisScaleType']) => { onUpdateMetricChartConfig({ chartConfig: { y2AxisScaleType diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/YAxisSettingContent.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/YAxisSettingContent.tsx index cfccccb6a..72e25c08a 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/YAxisSettingContent.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/SelectAxisSettingsContent/YAxisSettingContent.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { ColumnLabelFormat } from '@/api/asset_interfaces/metric/charts'; import { AXIS_TITLE_SEPARATOR } from '@/components/ui/charts/commonHelpers/axisHelper'; import { useUpdateMetricChart } from '@/context/Metrics'; @@ -52,7 +52,7 @@ export const YAxisSettingContent: React.FC = React.memo(() => { }); const onChangeAxisScale = useMemoizedFn( - (yAxisScaleType: IBusterMetricChartConfig['yAxisScaleType']) => { + (yAxisScaleType: BusterMetricChartConfig['yAxisScaleType']) => { onUpdateMetricChartConfig({ chartConfig: { yAxisScaleType diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/helper.ts b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/helper.ts index 4b4639738..0fa7c1a0f 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/helper.ts +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/helper.ts @@ -1,5 +1,5 @@ import isEmpty from 'lodash/isEmpty'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { ChartType } from '@/api/asset_interfaces/metric/charts'; import { SelectAxisContainerId } from './config'; import type { DropZone } from './SelectAxisDragContainer/interfaces'; @@ -60,11 +60,11 @@ const makeY2AxisDropZone = (y2Items: string[] | null | undefined): DropZone => makeDropZone(SelectAxisContainerId.Y2Axis, y2Items ?? EMPTY_ARRAY); export const chartTypeToDropZones: Record< - IBusterMetricChartConfig['selectedChartType'], + BusterMetricChartConfig['selectedChartType'], (selectedAxis: Parameters[0]['selectedAxis']) => DropZone[] > = { ['bar']: (selectedAxis) => { - const _selectedAxis = selectedAxis as IBusterMetricChartConfig['barAndLineAxis']; + const _selectedAxis = selectedAxis as BusterMetricChartConfig['barAndLineAxis']; return [ makeXAxisDropZone(_selectedAxis.x), makeYAxisDropZone(_selectedAxis.y), @@ -73,7 +73,7 @@ export const chartTypeToDropZones: Record< ]; }, ['line']: (selectedAxis) => { - const _selectedAxis = selectedAxis as IBusterMetricChartConfig['barAndLineAxis']; + const _selectedAxis = selectedAxis as BusterMetricChartConfig['barAndLineAxis']; return [ makeXAxisDropZone(_selectedAxis.x), makeYAxisDropZone(_selectedAxis.y), @@ -82,7 +82,7 @@ export const chartTypeToDropZones: Record< ]; }, ['scatter']: (selectedAxis) => { - const _selectedAxis = selectedAxis as IBusterMetricChartConfig['scatterAxis']; + const _selectedAxis = selectedAxis as BusterMetricChartConfig['scatterAxis']; return [ makeXAxisDropZone(_selectedAxis.x), makeYAxisDropZone(_selectedAxis.y), @@ -92,7 +92,7 @@ export const chartTypeToDropZones: Record< ]; }, ['pie']: (selectedAxis) => { - const _selectedAxis = selectedAxis as IBusterMetricChartConfig['pieChartAxis']; + const _selectedAxis = selectedAxis as BusterMetricChartConfig['pieChartAxis']; return [ makeXAxisDropZone(_selectedAxis.x), makeYAxisDropZone(_selectedAxis.y), @@ -100,7 +100,7 @@ export const chartTypeToDropZones: Record< ]; }, ['combo']: (selectedAxis) => { - const _selectedAxis = selectedAxis as IBusterMetricChartConfig['comboChartAxis']; + const _selectedAxis = selectedAxis as BusterMetricChartConfig['comboChartAxis']; return [ makeXAxisDropZone(_selectedAxis.x), makeYComboAxisDropZone(_selectedAxis.y), @@ -122,12 +122,12 @@ export const getChartTypeDropZones = ({ chartType, selectedAxis }: { - chartType: IBusterMetricChartConfig['selectedChartType']; + chartType: BusterMetricChartConfig['selectedChartType']; selectedAxis: - | IBusterMetricChartConfig['comboChartAxis'] - | IBusterMetricChartConfig['pieChartAxis'] - | IBusterMetricChartConfig['scatterAxis'] - | IBusterMetricChartConfig['barAndLineAxis']; + | BusterMetricChartConfig['comboChartAxis'] + | BusterMetricChartConfig['pieChartAxis'] + | BusterMetricChartConfig['scatterAxis'] + | BusterMetricChartConfig['barAndLineAxis']; }): DropZone[] => { return chartTypeToDropZones[chartType](selectedAxis); }; diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/useSelectAxisContext.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/useSelectAxisContext.tsx index 29eff6dd8..dcca9c96c 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/useSelectAxisContext.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/SelectAxis/useSelectAxisContext.tsx @@ -1,7 +1,7 @@ import type React from 'react'; import type { PropsWithChildren } from 'react'; import { createContext, useContextSelector } from 'use-context-selector'; -import type { ColumnMetaData, IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { ColumnMetaData, BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { CategoryAxisStyleConfig, ChartEncodes, @@ -16,19 +16,19 @@ export interface ISelectAxisContext Required>, Required { selectedAxis: ChartEncodes | null; - columnLabelFormats: IBusterMetricChartConfig['columnLabelFormats']; + columnLabelFormats: BusterMetricChartConfig['columnLabelFormats']; columnMetadata: ColumnMetaData[]; - columnSettings: IBusterMetricChartConfig['columnSettings']; - selectedChartType: IBusterMetricChartConfig['selectedChartType']; - lineGroupType: IBusterMetricChartConfig['lineGroupType']; - barGroupType: IBusterMetricChartConfig['barGroupType']; - showLegend: IBusterMetricChartConfig['showLegend']; - showLegendHeadline: IBusterMetricChartConfig['showLegendHeadline']; - gridLines: IBusterMetricChartConfig['gridLines']; - goalLines: IBusterMetricChartConfig['goalLines']; - trendlines: IBusterMetricChartConfig['trendlines']; - barShowTotalAtTop: IBusterMetricChartConfig['barShowTotalAtTop']; - disableTooltip: IBusterMetricChartConfig['disableTooltip']; + columnSettings: BusterMetricChartConfig['columnSettings']; + selectedChartType: BusterMetricChartConfig['selectedChartType']; + lineGroupType: BusterMetricChartConfig['lineGroupType']; + barGroupType: BusterMetricChartConfig['barGroupType']; + showLegend: BusterMetricChartConfig['showLegend']; + showLegendHeadline: BusterMetricChartConfig['showLegendHeadline']; + gridLines: BusterMetricChartConfig['gridLines']; + goalLines: BusterMetricChartConfig['goalLines']; + trendlines: BusterMetricChartConfig['trendlines']; + barShowTotalAtTop: BusterMetricChartConfig['barShowTotalAtTop']; + disableTooltip: BusterMetricChartConfig['disableTooltip']; rowCount: number; } diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingAppVisualize.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingAppVisualize.tsx index 463fcc882..700aa00e7 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingAppVisualize.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingAppVisualize.tsx @@ -1,5 +1,5 @@ import type React from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { type CategoryAxisStyleConfig, type ChartEncodes, @@ -17,11 +17,11 @@ import { StylingMetric } from './StylingMetric'; export const StylingAppVisualize: React.FC< { - barLayout: IBusterMetricChartConfig['barLayout']; + barLayout: BusterMetricChartConfig['barLayout']; selectedAxis: ChartEncodes; className?: string; colors: string[]; - disableTooltip: IBusterMetricChartConfig['disableTooltip']; + disableTooltip: BusterMetricChartConfig['disableTooltip']; } & Required & Required & Required & diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/EditHeaderTitle.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/EditHeaderTitle.tsx index 84b88e102..bb061f752 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/EditHeaderTitle.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/EditHeaderTitle.tsx @@ -1,16 +1,15 @@ import React, { useEffect, useRef } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { Input } from '@/components/ui/inputs'; import { LabelAndInput } from '../../Common'; export const EditHeaderTitle: React.FC<{ value: string | undefined; type: 'header' | 'subHeader'; - onUpdateChartConfig: (chartConfig: Partial) => void; + onUpdateChartConfig: (chartConfig: Partial) => void; }> = React.memo(({ value, onUpdateChartConfig, type }) => { const inputRef = useRef(null); - const key: keyof IBusterMetricChartConfig = - type === 'header' ? 'metricHeader' : 'metricSubHeader'; + const key: keyof BusterMetricChartConfig = type === 'header' ? 'metricHeader' : 'metricSubHeader'; const title = type === 'header' ? 'Header' : 'Sub-header'; const placeholder = type === 'header' ? 'Enter header' : 'Enter sub-header'; diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/EditMetricField.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/EditMetricField.tsx index 5ead08b6a..c9682e41b 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/EditMetricField.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/EditMetricField.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { DEFAULT_COLUMN_SETTINGS } from '@/api/asset_interfaces'; import { ChartType, type DerivedMetricTitle } from '@/api/asset_interfaces/metric/charts'; import { Button } from '@/components/ui/buttons'; @@ -15,15 +15,15 @@ import type { createColumnFieldOptions } from './helpers'; export const EditMetricField: React.FC<{ label?: string; - columnId: IBusterMetricChartConfig['metricColumnId']; - columnLabelFormats: IBusterMetricChartConfig['columnLabelFormats']; + columnId: BusterMetricChartConfig['metricColumnId']; + columnLabelFormats: BusterMetricChartConfig['columnLabelFormats']; columnFieldOptions: ReturnType; rowCount: number; onUpdateMetricField: (config: { metricColumnId: string; metricValueAggregate?: DerivedMetricTitle['aggregate']; }) => void; - onUpdateChartConfig: (chartConfig: Partial) => void; + onUpdateChartConfig: (chartConfig: Partial) => void; }> = React.memo( ({ columnId, @@ -82,9 +82,9 @@ export const EditMetricField: React.FC<{ EditMetricField.displayName = 'EditMetricField'; const StylingPopover: React.FC<{ - metricColumnId: IBusterMetricChartConfig['metricColumnId']; - columnLabelFormat: IBusterMetricChartConfig['columnLabelFormats'][string]; - onUpdateChartConfig: (chartConfig: Partial) => void; + metricColumnId: BusterMetricChartConfig['metricColumnId']; + columnLabelFormat: BusterMetricChartConfig['columnLabelFormats'][string]; + onUpdateChartConfig: (chartConfig: Partial) => void; rowCount: number; }> = React.memo(({ metricColumnId, columnLabelFormat, rowCount }) => { return ( diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/EditMetricHeaderType.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/EditMetricHeaderType.tsx index f94771a78..1d1fa5f04 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/EditMetricHeaderType.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/EditMetricHeaderType.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { Select, type SelectItem } from '@/components/ui/select'; import { useMemoizedFn } from '@/hooks'; import { LabelAndInput } from '../../Common'; @@ -26,11 +26,11 @@ const allOptions: SelectItem<'custom' | 'columnTitle' | 'columnValue' | 'none'>[ const onlyCustomOptions = [allOptions[0], allOptions[1]]; export const EditMetricHeader: React.FC<{ - header: IBusterMetricChartConfig['metricHeader'] | IBusterMetricChartConfig['metricSubHeader']; + header: BusterMetricChartConfig['metricHeader'] | BusterMetricChartConfig['metricSubHeader']; type: 'header' | 'subHeader'; firstColumnId: string; hideDerivedMetricOption: boolean; - onUpdateChartConfig: (chartConfig: Partial) => void; + onUpdateChartConfig: (chartConfig: Partial) => void; }> = React.memo(({ header, type, firstColumnId, hideDerivedMetricOption, onUpdateChartConfig }) => { const selectedOption = useMemo(() => { if (header === null) return 'none'; diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/EditMetricType.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/EditMetricType.tsx index 1c497aa8f..0632d7093 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/EditMetricType.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/EditMetricType.tsx @@ -1,6 +1,6 @@ import last from 'lodash/last'; import React, { useMemo } from 'react'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { ColumnLabelFormat } from '@/api/asset_interfaces/metric/charts'; import type { SelectItem } from '@/components/ui/select'; import { Select } from '@/components/ui/select'; @@ -8,7 +8,7 @@ import { useMemoizedFn } from '@/hooks'; import { isNumericColumnStyle, isNumericColumnType } from '@/lib'; import { LabelAndInput } from '../../Common'; -export const AGGREGATE_OPTIONS: SelectItem[] = [ +export const AGGREGATE_OPTIONS: SelectItem[] = [ { label: 'Sum', value: 'sum' }, { label: 'Average', value: 'average' }, { label: 'Median', value: 'median' }, @@ -19,9 +19,9 @@ export const AGGREGATE_OPTIONS: SelectItem void; + onUpdateAggregate: (aggregate: BusterMetricChartConfig['metricValueAggregate']) => void; columnLabelFormat: ColumnLabelFormat | undefined; }> = React.memo(({ aggregate, onUpdateAggregate, columnId, columnLabelFormat }) => { const isNumberColumn = columnLabelFormat?.columnType @@ -38,7 +38,7 @@ export const EditMetricAggregate: React.FC<{ }, [aggregate, disableOptions]); const onUpdateMetricValueAggregate = useMemoizedFn((value: string) => { - onUpdateAggregate(value as IBusterMetricChartConfig['metricValueAggregate']); + onUpdateAggregate(value as BusterMetricChartConfig['metricValueAggregate']); }); return ( diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/StylingMetric.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/StylingMetric.tsx index 11a113fb5..d5d0f4019 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/StylingMetric.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/StylingMetric.tsx @@ -1,5 +1,5 @@ import React, { useMemo } from 'react'; -import type { ColumnMetaData, IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { ColumnMetaData, BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { DerivedMetricTitle } from '@/api/asset_interfaces/metric/charts'; import { Separator } from '@/components/ui/seperator'; import { useUpdateMetricChart } from '@/context/Metrics'; @@ -12,12 +12,12 @@ import { createColumnFieldOptions } from './helpers'; export const StylingMetric: React.FC<{ className?: string; - columnLabelFormats: IBusterMetricChartConfig['columnLabelFormats']; - metricHeader: IBusterMetricChartConfig['metricHeader']; - metricSubHeader: IBusterMetricChartConfig['metricSubHeader']; + columnLabelFormats: BusterMetricChartConfig['columnLabelFormats']; + metricHeader: BusterMetricChartConfig['metricHeader']; + metricSubHeader: BusterMetricChartConfig['metricSubHeader']; rowCount: number; - metricValueAggregate: IBusterMetricChartConfig['metricValueAggregate']; - metricColumnId: IBusterMetricChartConfig['metricColumnId']; + metricValueAggregate: BusterMetricChartConfig['metricValueAggregate']; + metricColumnId: BusterMetricChartConfig['metricColumnId']; columnMetadata: ColumnMetaData[]; }> = ({ className, @@ -31,7 +31,7 @@ export const StylingMetric: React.FC<{ }) => { const { onUpdateMetricChartConfig } = useUpdateMetricChart(); - const onUpdateChartConfig = useMemoizedFn((chartConfig: Partial) => { + const onUpdateChartConfig = useMemoizedFn((chartConfig: Partial) => { onUpdateMetricChartConfig({ chartConfig }); }); @@ -82,12 +82,12 @@ export const StylingMetric: React.FC<{ }; const PrimaryMetricStyling: React.FC<{ - metricColumnId: IBusterMetricChartConfig['metricColumnId']; - metricValueAggregate: IBusterMetricChartConfig['metricValueAggregate']; + metricColumnId: BusterMetricChartConfig['metricColumnId']; + metricValueAggregate: BusterMetricChartConfig['metricValueAggregate']; columnFieldOptions: ReturnType; - columnLabelFormats: IBusterMetricChartConfig['columnLabelFormats']; + columnLabelFormats: BusterMetricChartConfig['columnLabelFormats']; rowCount: number; - onUpdateChartConfig: (chartConfig: Partial) => void; + onUpdateChartConfig: (chartConfig: Partial) => void; }> = ({ metricColumnId, columnLabelFormats, @@ -104,7 +104,7 @@ const PrimaryMetricStyling: React.FC<{ metricColumnId: string; metricValueAggregate?: DerivedMetricTitle['aggregate']; }) => { - const newConfig: Partial = { + const newConfig: Partial = { metricColumnId }; if (metricValueAggregate) { @@ -116,7 +116,7 @@ const PrimaryMetricStyling: React.FC<{ ); const onUpdateAggregate = useMemoizedFn( - (aggregate: IBusterMetricChartConfig['metricValueAggregate']) => { + (aggregate: BusterMetricChartConfig['metricValueAggregate']) => { onUpdateChartConfig({ metricValueAggregate: aggregate }); } ); @@ -142,12 +142,12 @@ const PrimaryMetricStyling: React.FC<{ }; const HeaderMetricStyling: React.FC<{ - header: IBusterMetricChartConfig['metricHeader'] | IBusterMetricChartConfig['metricSubHeader']; + header: BusterMetricChartConfig['metricHeader'] | BusterMetricChartConfig['metricSubHeader']; columnFieldOptions: ReturnType; rowCount: number; - columnLabelFormats: IBusterMetricChartConfig['columnLabelFormats']; + columnLabelFormats: BusterMetricChartConfig['columnLabelFormats']; type: 'header' | 'subHeader'; - onUpdateChartConfig: (chartConfig: Partial) => void; + onUpdateChartConfig: (chartConfig: Partial) => void; }> = ({ header, type, columnFieldOptions, rowCount, columnLabelFormats, onUpdateChartConfig }) => { const isStringHeader = typeof header === 'string'; const isObjectHeader = typeof header === 'object'; @@ -187,7 +187,7 @@ const HeaderMetricStyling: React.FC<{ ); const onUpdateAggregate = useMemoizedFn( - (aggregate: IBusterMetricChartConfig['metricValueAggregate']) => { + (aggregate: BusterMetricChartConfig['metricValueAggregate']) => { const key = type === 'header' ? 'metricHeader' : 'metricSubHeader'; const newConfig: DerivedMetricTitle = { columnId: (header as DerivedMetricTitle)?.columnId, diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/helpers.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/helpers.tsx index e39356891..63a4babec 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/helpers.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricEditController/MetricStylingApp/StylingAppVisualize/StylingMetric/helpers.tsx @@ -1,11 +1,11 @@ -import type { ColumnMetaData, IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { ColumnMetaData, BusterMetricChartConfig } from '@/api/asset_interfaces'; import type { SelectItem } from '@/components/ui/select'; import { formatLabel } from '@/lib'; import { ColumnTypeIcon } from '../SelectAxis/config'; export const createColumnFieldOptions = ( columnMetadata: ColumnMetaData[], - columnLabelFormats: IBusterMetricChartConfig['columnLabelFormats'], + columnLabelFormats: BusterMetricChartConfig['columnLabelFormats'], iconClass: string ): SelectItem[] => { return columnMetadata.map>((column) => { diff --git a/apps/web/src/controllers/MetricController/MetricViewChart/MetricViewChartContent.tsx b/apps/web/src/controllers/MetricController/MetricViewChart/MetricViewChartContent.tsx index 660a279b4..b49f21a6c 100644 --- a/apps/web/src/controllers/MetricController/MetricViewChart/MetricViewChartContent.tsx +++ b/apps/web/src/controllers/MetricController/MetricViewChart/MetricViewChartContent.tsx @@ -1,13 +1,13 @@ import React, { useMemo } from 'react'; -import type { BusterMetricData, DataMetadata, IBusterMetric } from '@/api/asset_interfaces/metric'; -import { ChartType } from '@/api/asset_interfaces/metric/charts'; +import type { BusterMetricData, BusterMetric } from '@/api/asset_interfaces/metric'; +import type { DataMetadata } from '@buster/server-shared/metrics'; import { BusterChart } from '@/components/ui/charts'; import { cn } from '@/lib/classMerge'; import { METRIC_CHART_CONTAINER_ID } from './config'; interface MetricViewChartContentProps { className?: string; - chartConfig: IBusterMetric['chart_config']; + chartConfig: BusterMetric['chart_config']; metricData: BusterMetricData['data']; dataMetadata: DataMetadata | undefined; fetchedData: boolean; diff --git a/apps/web/src/controllers/MetricController/MetricViewSQL/useMetricRunSQL/helpers.ts b/apps/web/src/controllers/MetricController/MetricViewSQL/useMetricRunSQL/helpers.ts index 5d6b2e4cd..11f1a81ab 100644 --- a/apps/web/src/controllers/MetricController/MetricViewSQL/useMetricRunSQL/helpers.ts +++ b/apps/web/src/controllers/MetricController/MetricViewSQL/useMetricRunSQL/helpers.ts @@ -1,7 +1,7 @@ import type { ColumnMetaData, - IBusterMetric, - IBusterMetricChartConfig + BusterMetric, + BusterMetricChartConfig } from '@/api/asset_interfaces/metric'; import type { BusterChartConfigProps, @@ -57,9 +57,9 @@ export const didColumnDataChange = ( * @returns A new chart configuration suitable for the changed SQL data */ export const simplifyChatConfigForSQLChange = ( - chartConfig: IBusterMetricChartConfig, - data_metadata: IBusterMetric['data_metadata'] -): IBusterMetricChartConfig => { + chartConfig: BusterMetricChartConfig, + data_metadata: BusterMetric['data_metadata'] +): BusterMetricChartConfig => { // Create a new mapping of column name to format settings // This preserves existing format settings only when the column type hasn't changed const columnLabelFormats = data_metadata?.column_metadata?.reduce< diff --git a/apps/web/src/controllers/MetricController/MetricViewSQL/useMetricRunSQL/useMetricRunSQL.ts b/apps/web/src/controllers/MetricController/MetricViewSQL/useMetricRunSQL/useMetricRunSQL.ts index d30189786..d540cc731 100644 --- a/apps/web/src/controllers/MetricController/MetricViewSQL/useMetricRunSQL/useMetricRunSQL.ts +++ b/apps/web/src/controllers/MetricController/MetricViewSQL/useMetricRunSQL/useMetricRunSQL.ts @@ -1,6 +1,7 @@ import { useQueryClient } from '@tanstack/react-query'; import { useRef } from 'react'; -import type { BusterMetricData, IBusterMetricChartConfig } from '@/api/asset_interfaces/metric'; +import type { ChartConfigProps } from '@buster/server-shared/metrics'; +import type { BusterMetricData } from '@/api/asset_interfaces/metric'; import type { RunSQLResponse } from '@/api/asset_interfaces/sql'; import { useRunSQL as useRunSQLQuery } from '@/api/buster_rest'; import { useGetLatestMetricVersionMemoized, useUpdateMetric } from '@/api/buster_rest/metrics'; @@ -38,7 +39,7 @@ export const useMetricRunSQL = () => { const getLatestMetricVersion = useGetLatestMetricVersionMemoized(); const originalConfigs = useRef<{ - chartConfig: IBusterMetricChartConfig; + chartConfig: ChartConfigProps; sql: string; data: BusterMetricData['data']; dataMetadata: BusterMetricData['data_metadata']; @@ -88,7 +89,7 @@ export const useMetricRunSQL = () => { const newColumnData = data_metadata?.column_metadata; const didDataMetadataChange = didColumnDataChange(oldColumnData, newColumnData); - const totallyDefaultChartConfig: IBusterMetricChartConfig = didDataMetadataChange + const totallyDefaultChartConfig: ChartConfigProps = didDataMetadataChange ? simplifyChatConfigForSQLChange(metricMessage.chart_config, data_metadata) : metricMessage.chart_config; diff --git a/apps/web/src/lib/columnFormatter.ts b/apps/web/src/lib/columnFormatter.ts index 1c0c3a131..6272823ff 100644 --- a/apps/web/src/lib/columnFormatter.ts +++ b/apps/web/src/lib/columnFormatter.ts @@ -1,10 +1,10 @@ +import type { ColumnLabelFormat } from '@buster/server-shared/metrics'; import { - type ColumnLabelFormat, DEFAULT_COLUMN_LABEL_FORMAT, DEFAULT_DATE_FORMAT_DAY_OF_WEEK, DEFAULT_DATE_FORMAT_MONTH_OF_YEAR, DEFAULT_DATE_FORMAT_QUARTER -} from '@/api/asset_interfaces/metric'; +} from '@buster/server-shared/metrics'; import { formatDate } from './date'; import { formatNumber, roundNumber } from './numbers'; import { makeHumanReadble } from './text'; diff --git a/apps/web/src/lib/imageGeneration.tsx b/apps/web/src/lib/imageGeneration.tsx index 7d4269c7f..da38b67d1 100644 --- a/apps/web/src/lib/imageGeneration.tsx +++ b/apps/web/src/lib/imageGeneration.tsx @@ -1,12 +1,12 @@ import type React from 'react'; import { useEffect, useRef } from 'react'; import { createRoot } from 'react-dom/client'; -import type { BusterMetricData, IBusterMetric } from '@/api/asset_interfaces/metric'; +import type { BusterMetricData, BusterMetric } from '@/api/asset_interfaces/metric'; import { downloadImageData, exportElementToImage } from './exportUtils'; import { timeout } from './timeout'; export const generateChartDownloadImage = async ( - message: IBusterMetric, + message: BusterMetric, messageData: NonNullable, isDark = false ) => { @@ -61,7 +61,7 @@ export const generateChartDownloadImage = async ( export const generateChartPreviewImage = async ( message: { - chart_config: IBusterMetric['chart_config']; + chart_config: BusterMetric['chart_config']; } | null, messageData: BusterMetricData, isDark = true @@ -77,7 +77,7 @@ export const generateChartPreviewImage = async ( const container = ( @@ -149,7 +149,7 @@ const ChartPreviewImage = ({ message, messageData }: { - message: IBusterMetric; + message: BusterMetric; messageData: BusterMetricData; }) => { const data = messageData?.data || []; @@ -174,7 +174,7 @@ const ChartPreviewImage = ({ export const PreviewImageReactComponent: React.FC<{ message: { - chart_config: IBusterMetric['chart_config']; + chart_config: BusterMetric['chart_config']; } | null; messageData: BusterMetricData; isDark: boolean; @@ -210,7 +210,7 @@ export const PreviewImageReactComponent: React.FC<{ }`}> {BusterLogo} {hasData && message?.chart_config ? ( - + ) : (
| undefined, columnsMetaData: ColumnMetaData[] | undefined -): IBusterMetricChartConfig['columnLabelFormats'] => { +): BusterMetricChartConfig['columnLabelFormats'] => { if (!columnsMetaData) return {}; return columnsMetaData.reduce( @@ -25,7 +25,7 @@ export const createDefaultColumnLabelFormats = ( }); return acc; }, - {} as IBusterMetricChartConfig['columnLabelFormats'] + {} as BusterMetricChartConfig['columnLabelFormats'] ); }; diff --git a/apps/web/src/lib/metrics/messageAutoChartHandler/createDefaultColumnSettings.ts b/apps/web/src/lib/metrics/messageAutoChartHandler/createDefaultColumnSettings.ts index aa2c20cc1..520a3a22d 100644 --- a/apps/web/src/lib/metrics/messageAutoChartHandler/createDefaultColumnSettings.ts +++ b/apps/web/src/lib/metrics/messageAutoChartHandler/createDefaultColumnSettings.ts @@ -2,17 +2,17 @@ import { create } from 'mutative'; import { type ColumnMetaData, DEFAULT_COLUMN_SETTINGS, - type IBusterMetricChartConfig + type BusterMetricChartConfig } from '@/api/asset_interfaces/metric'; import type { ColumnSettings } from '@/api/asset_interfaces/metric/charts'; export const createDefaultColumnSettings = ( existingColumnSettings: Record | undefined, columnsMetaData: ColumnMetaData[] | undefined -): IBusterMetricChartConfig['columnSettings'] => { +): BusterMetricChartConfig['columnSettings'] => { if (!columnsMetaData) return {}; - return create({} as IBusterMetricChartConfig['columnSettings'], (draft) => { + return create({} as BusterMetricChartConfig['columnSettings'], (draft) => { for (const column of columnsMetaData) { draft[column.name] = create(DEFAULT_COLUMN_SETTINGS, (settingsDraft) => { if (existingColumnSettings?.[column.name]) { diff --git a/apps/web/src/lib/metrics/messageAutoChartHandler/messageAutoChartHandler.ts b/apps/web/src/lib/metrics/messageAutoChartHandler/messageAutoChartHandler.ts index 03ac40718..ab11f037b 100644 --- a/apps/web/src/lib/metrics/messageAutoChartHandler/messageAutoChartHandler.ts +++ b/apps/web/src/lib/metrics/messageAutoChartHandler/messageAutoChartHandler.ts @@ -1,13 +1,12 @@ import isEmpty from 'lodash/isEmpty'; import { create } from 'mutative'; +import { type BusterMetric, type BusterMetricChartConfig } from '@/api/asset_interfaces/metric'; import { - type BusterMetric, - type DataMetadata, DEFAULT_CHART_CONFIG, DEFAULT_CHART_CONFIG_ENTRIES, - type IBusterMetricChartConfig -} from '@/api/asset_interfaces/metric'; -import type { BusterChartConfigProps } from '@/api/asset_interfaces/metric/charts'; + type ChartConfigProps, + type DataMetadata +} from '@buster/server-shared/metrics'; import { createDefaultBarAndLineAxis, createDefaultPieAxis, @@ -18,27 +17,27 @@ import { createDefaultColumnSettings } from './createDefaultColumnSettings'; const keySpecificHandlers: Partial< Record< - keyof IBusterMetricChartConfig, + keyof BusterMetricChartConfig, ( value: unknown, dataMetadata: DataMetadata | undefined, - pieChartAxis: IBusterMetricChartConfig['pieChartAxis'] | undefined + pieChartAxis: BusterMetricChartConfig['pieChartAxis'] | undefined ) => unknown > > = { colors: (value: unknown) => { - const colors = value as IBusterMetricChartConfig['colors']; + const colors = value as BusterMetricChartConfig['colors']; if (isEmpty(colors)) return DEFAULT_CHART_CONFIG.colors; if (colors.length >= 3) return colors; //we need at least 3 colors for the chart icons return Array.from({ length: 3 }, (_, index) => colors[index % colors.length]); }, scatterDotSize: (value: unknown) => { - const scatterDotSize = value as IBusterMetricChartConfig['scatterDotSize']; + const scatterDotSize = value as BusterMetricChartConfig['scatterDotSize']; if (isEmpty(scatterDotSize)) return DEFAULT_CHART_CONFIG.scatterDotSize; return scatterDotSize; }, barAndLineAxis: (value: unknown, dataMetadata) => { - const barAndLineAxis = value as IBusterMetricChartConfig['barAndLineAxis']; + const barAndLineAxis = value as BusterMetricChartConfig['barAndLineAxis']; if (isEmpty(barAndLineAxis)) { return createDefaultBarAndLineAxis(dataMetadata?.column_metadata); } @@ -50,7 +49,7 @@ const keySpecificHandlers: Partial< }; }, pieChartAxis: (value: unknown, dataMetadata) => { - const pieChartAxis = value as IBusterMetricChartConfig['pieChartAxis']; + const pieChartAxis = value as BusterMetricChartConfig['pieChartAxis']; if (isEmpty(pieChartAxis)) return createDefaultPieAxis(dataMetadata?.column_metadata); return { x: pieChartAxis.x || DEFAULT_CHART_CONFIG.pieChartAxis.x, @@ -59,7 +58,7 @@ const keySpecificHandlers: Partial< }; }, scatterAxis: (value: unknown, dataMetadata) => { - const scatterAxis = value as IBusterMetricChartConfig['scatterAxis']; + const scatterAxis = value as BusterMetricChartConfig['scatterAxis']; if (isEmpty(scatterAxis)) return createDefaultScatterAxis(dataMetadata?.column_metadata); return { x: scatterAxis.x || DEFAULT_CHART_CONFIG.scatterAxis.x, @@ -70,7 +69,7 @@ const keySpecificHandlers: Partial< }; }, comboChartAxis: (value: unknown, dataMetadata) => { - const comboChartAxis = value as IBusterMetricChartConfig['comboChartAxis']; + const comboChartAxis = value as BusterMetricChartConfig['comboChartAxis']; if (isEmpty(comboChartAxis)) return createDefaultBarAndLineAxis(dataMetadata?.column_metadata); return { x: comboChartAxis.x || DEFAULT_CHART_CONFIG.comboChartAxis.x, @@ -81,7 +80,7 @@ const keySpecificHandlers: Partial< }; }, metricColumnId: (value: unknown, dataMetadata) => { - const metricColumnId = value as IBusterMetricChartConfig['metricColumnId']; + const metricColumnId = value as BusterMetricChartConfig['metricColumnId']; if (isEmpty(metricColumnId)) { const firstNumberColumn = dataMetadata?.column_metadata?.find( (m) => m.simple_type === 'number' @@ -91,25 +90,25 @@ const keySpecificHandlers: Partial< return metricColumnId; }, metricHeader: (value: unknown) => { - const metricHeader = value as IBusterMetricChartConfig['metricHeader']; + const metricHeader = value as BusterMetricChartConfig['metricHeader']; if (isEmpty(metricHeader)) return DEFAULT_CHART_CONFIG.metricHeader; return metricHeader; }, metricSubHeader: (value: unknown) => { - const metricSubHeader = value as IBusterMetricChartConfig['metricSubHeader']; + const metricSubHeader = value as BusterMetricChartConfig['metricSubHeader']; if (isEmpty(metricSubHeader)) return DEFAULT_CHART_CONFIG.metricSubHeader; return metricSubHeader; }, columnLabelFormats: (value: unknown, dataMetadata) => { - const columnLabelFormats = value as IBusterMetricChartConfig['columnLabelFormats']; + const columnLabelFormats = value as BusterMetricChartConfig['columnLabelFormats']; return createDefaultColumnLabelFormats(columnLabelFormats, dataMetadata?.column_metadata); }, columnSettings: (value: unknown, dataMetadata) => { - const columnSettings = value as IBusterMetricChartConfig['columnSettings']; + const columnSettings = value as BusterMetricChartConfig['columnSettings']; return createDefaultColumnSettings(columnSettings, dataMetadata?.column_metadata); }, pieLabelPosition: (value: unknown, dataMetadata, pieChartAxis) => { - const pieLabelPosition = value as IBusterMetricChartConfig['pieLabelPosition']; + const pieLabelPosition = value as BusterMetricChartConfig['pieLabelPosition']; // if (isEmpty(pieLabelPosition)) { // const firstPieColumn = pieChartAxis?.x?.[0]; // const firstPieColumnMetaData = dataMetadata?.column_metadata?.find( @@ -124,14 +123,14 @@ const keySpecificHandlers: Partial< export const createDefaultChartConfig = ( message: Pick -): IBusterMetricChartConfig => { - const chartConfig: BusterChartConfigProps | undefined = message.chart_config; +): BusterMetricChartConfig => { + const chartConfig: ChartConfigProps | undefined = message.chart_config; const dataMetadata = message.data_metadata; const pieChartAxis = chartConfig?.pieChartAxis; const newChartConfig = create(DEFAULT_CHART_CONFIG, (draft) => { for (const [_key, defaultValue] of DEFAULT_CHART_CONFIG_ENTRIES) { - const key = _key as keyof IBusterMetricChartConfig; + const key = _key as keyof BusterMetricChartConfig; const chartConfigValue = chartConfig?.[key]; const handler = keySpecificHandlers[key]; diff --git a/apps/web/src/lib/metrics/resolve.ts b/apps/web/src/lib/metrics/resolve.ts index 930f0174c..d065d901b 100644 --- a/apps/web/src/lib/metrics/resolve.ts +++ b/apps/web/src/lib/metrics/resolve.ts @@ -1,9 +1,9 @@ -import { DEFAULT_IBUSTER_METRIC, type IBusterMetric } from '@/api/asset_interfaces/metric'; +import { DEFAULT_IBUSTER_METRIC, type BusterMetric } from '@/api/asset_interfaces/metric'; export const resolveEmptyMetric = ( - metric: IBusterMetric | undefined, + metric: BusterMetric | undefined, metricId: string -): IBusterMetric => { +): BusterMetric => { if (!metric || !metric?.id) { return { ...DEFAULT_IBUSTER_METRIC, ...metric, id: metricId }; } diff --git a/apps/web/src/lib/metrics/saveToServerHelpers.ts b/apps/web/src/lib/metrics/saveToServerHelpers.ts index 0b8783e4b..2b4eeadca 100644 --- a/apps/web/src/lib/metrics/saveToServerHelpers.ts +++ b/apps/web/src/lib/metrics/saveToServerHelpers.ts @@ -1,10 +1,10 @@ import isEqual from 'lodash/isEqual'; -import type { DataMetadata, IBusterMetric } from '@/api/asset_interfaces/metric'; +import type { DataMetadata, BusterMetric } from '@/api/asset_interfaces/metric'; import { DEFAULT_CHART_CONFIG_ENTRIES, DEFAULT_COLUMN_LABEL_FORMAT, DEFAULT_COLUMN_SETTINGS, - type IBusterMetricChartConfig + type BusterMetricChartConfig } from '@/api/asset_interfaces/metric'; import type { BarAndLineAxis, @@ -23,15 +23,15 @@ const DEFAULT_COLUMN_SETTINGS_ENTRIES = Object.entries(DEFAULT_COLUMN_SETTINGS); const DEFAULT_COLUMN_LABEL_FORMATS_ENTRIES = Object.entries(DEFAULT_COLUMN_LABEL_FORMAT); export const getChangedTopLevelMessageValues = ( - newMetric: IBusterMetric, - oldMetric: IBusterMetric + newMetric: BusterMetric, + oldMetric: BusterMetric ) => { const changes = getChangedValues(oldMetric, newMetric, ['name', 'status', 'sql', 'file']); return changes; }; const keySpecificHandlers: Partial< - Record unknown> + Record unknown> > = { barAndLineAxis: (value: unknown) => value as BarAndLineAxis, scatterAxis: (value: unknown) => value as ScatterAxis, @@ -97,14 +97,14 @@ const keySpecificHandlers: Partial< } }; -export const getChangesFromDefaultChartConfig = (newMetric: IBusterMetric) => { +export const getChangesFromDefaultChartConfig = (newMetric: BusterMetric) => { const chartConfig = newMetric.chart_config; if (!chartConfig) return {} as BusterChartConfigProps; - const diff: Partial = {}; + const diff: Partial = {}; for (const [_key, defaultValue] of DEFAULT_CHART_CONFIG_ENTRIES) { - const key = _key as keyof IBusterMetricChartConfig; + const key = _key as keyof BusterMetricChartConfig; const chartConfigValue = chartConfig[key]; const handler = keySpecificHandlers[key]; @@ -127,7 +127,7 @@ export const getChangesFromDefaultChartConfig = (newMetric: IBusterMetric) => { }; export const combineChangeFromDefaultChartConfig = ( - newMetric: IBusterMetric, + newMetric: BusterMetric, dataMetadata: DataMetadata ) => { const chartConfig = createDefaultChartConfig({ @@ -138,8 +138,8 @@ export const combineChangeFromDefaultChartConfig = ( }; export const prepareMetricUpdateMetric = ( - newMetric: IBusterMetric, - prevMetric: IBusterMetric + newMetric: BusterMetric, + prevMetric: BusterMetric ): Parameters[0] | null => { const changedTopLevelValues = getChangedTopLevelMessageValues( newMetric, diff --git a/apps/web/src/lib/metrics/selectedChartType/chartIcon.types.ts b/apps/web/src/lib/metrics/selectedChartType/chartIcon.types.ts index 32be2b742..c3c0ec8a0 100644 --- a/apps/web/src/lib/metrics/selectedChartType/chartIcon.types.ts +++ b/apps/web/src/lib/metrics/selectedChartType/chartIcon.types.ts @@ -2,16 +2,16 @@ import { ChartEncodes, ChartType, ColumnMetaData, - IBusterMetricChartConfig + BusterMetricChartConfig } from '@/api/asset_interfaces/metric'; export interface SelectChartTypeProps { selectedChartType: ChartType; - lineGroupType: IBusterMetricChartConfig['lineGroupType']; - barGroupType: IBusterMetricChartConfig['barGroupType']; - barLayout: IBusterMetricChartConfig['barLayout']; + lineGroupType: BusterMetricChartConfig['lineGroupType']; + barGroupType: BusterMetricChartConfig['barGroupType']; + barLayout: BusterMetricChartConfig['barLayout']; colors: string[]; columnMetadata: ColumnMetaData[]; - columnSettings: IBusterMetricChartConfig['columnSettings']; + columnSettings: BusterMetricChartConfig['columnSettings']; selectedAxis: ChartEncodes; } diff --git a/apps/web/src/lib/metrics/selectedChartType/selectedChartTypeMethods.ts b/apps/web/src/lib/metrics/selectedChartType/selectedChartTypeMethods.ts index 7d0ec6608..79ccac205 100644 --- a/apps/web/src/lib/metrics/selectedChartType/selectedChartTypeMethods.ts +++ b/apps/web/src/lib/metrics/selectedChartType/selectedChartTypeMethods.ts @@ -1,5 +1,5 @@ import omit from 'lodash/omit'; -import type { IBusterMetricChartConfig } from '@/api/asset_interfaces'; +import type { BusterMetricChartConfig } from '@/api/asset_interfaces'; import { ChartType } from '@/api/asset_interfaces/metric/charts'; import { CHART_ICON_LIST, ChartIconType, DETERMINE_SELECTED_CHART_TYPE_ORDER } from './config'; import type { SelectChartTypeProps } from './chartIcon.types'; @@ -37,7 +37,7 @@ export const getSelectedChartTypeConfig = ( const chartTypeMethod: Record< ChartIconType, - () => Partial & { + () => Partial & { hasAreaStyle?: boolean; } > = { @@ -130,14 +130,14 @@ export const disableTypeMethod: Record< export const selectedChartTypeMethod = ( chartIconType: ChartIconType, - columnSettings: IBusterMetricChartConfig['columnSettings'] -): Partial => { + columnSettings: BusterMetricChartConfig['columnSettings'] +): Partial => { const fullRes = chartTypeMethod[chartIconType](); const hasAreaStyle = !!fullRes.hasAreaStyle; const resOmitted = omit(fullRes, 'hasAreaStyle'); if (resOmitted.selectedChartType === 'line') { - const newColumnSettings: IBusterMetricChartConfig['columnSettings'] = Object.fromEntries( + const newColumnSettings: BusterMetricChartConfig['columnSettings'] = Object.fromEntries( Object.entries(columnSettings).map(([key, value]) => [ key, { diff --git a/apps/web/src/lib/metrics/upgradeToIMetric.ts b/apps/web/src/lib/metrics/upgradeToIMetric.ts index bfff26388..eede8a294 100644 --- a/apps/web/src/lib/metrics/upgradeToIMetric.ts +++ b/apps/web/src/lib/metrics/upgradeToIMetric.ts @@ -1,10 +1,10 @@ -import type { BusterMetric, IBusterMetric } from '@/api/asset_interfaces/metric'; +import type { BusterMetric, BusterMetric } from '@/api/asset_interfaces/metric'; import { createDefaultChartConfig } from './messageAutoChartHandler'; export const upgradeMetricToIMetric = ( metric: BusterMetric, - oldMetric: IBusterMetric | null | undefined -): IBusterMetric => { + oldMetric: BusterMetric | null | undefined +): BusterMetric => { const chart_config = createDefaultChartConfig(metric); return { ...oldMetric, diff --git a/apps/web/src/mocks/metric.ts b/apps/web/src/mocks/metric.ts index 0c9bb9d75..db4b879a7 100644 --- a/apps/web/src/mocks/metric.ts +++ b/apps/web/src/mocks/metric.ts @@ -1,12 +1,12 @@ import { type BusterMetricListItem, ChartType, - type DataMetadata, DEFAULT_CHART_CONFIG, - type IBusterMetric, - type IBusterMetricChartConfig + type BusterMetric, + type BusterMetricChartConfig } from '@/api/asset_interfaces/metric'; import { ShareRole, VerificationStatus } from '@/api/asset_interfaces/share'; +import type { DataMetadata } from '@buster/server-shared/metrics'; // Utility functions for predictable mock data generation const CHART_TYPES: ChartType[] = ['bar', 'table', 'line', 'pie', 'scatter', 'metric']; @@ -62,7 +62,7 @@ const generatePredictableEmail = (id: string): string => { return `${name}.${hash % 100}@${domain}`; }; -const createMockChartConfig = (id: string): IBusterMetricChartConfig => { +const createMockChartConfig = (id: string): BusterMetricChartConfig => { const hash = Array.from(id).reduce((acc, char) => acc + char.charCodeAt(0), 0); const chartType: ChartType = CHART_TYPES[hash % CHART_TYPES.length]; @@ -126,7 +126,7 @@ const dataMetadata: DataMetadata = { row_count: 10 }; -export const createMockMetric = (id: string): IBusterMetric => { +export const createMockMetric = (id: string): BusterMetric => { const chart_config = createMockChartConfig(id); return { diff --git a/apps/web/src/mocks/metricData.ts b/apps/web/src/mocks/metricData.ts index 50c271df8..c8e097ef0 100644 --- a/apps/web/src/mocks/metricData.ts +++ b/apps/web/src/mocks/metricData.ts @@ -1,4 +1,5 @@ -import type { BusterMetricData, DataMetadata } from '@/api/asset_interfaces/metric'; +import type { BusterMetricData } from '@/api/asset_interfaces/metric'; +import type { DataMetadata } from '@buster/server-shared/metrics'; const PRODUCTS = [ 'Laptop', diff --git a/packages/server-shared/package.json b/packages/server-shared/package.json index 5f293d309..12432e822 100644 --- a/packages/server-shared/package.json +++ b/packages/server-shared/package.json @@ -19,6 +19,18 @@ "types": "./dist/chats/index.d.ts", "default": "./dist/chats/index.js" }, + "./metrics": { + "types": "./dist/metrics/index.d.ts", + "default": "./dist/metrics/index.js" + }, + "./share": { + "types": "./dist/share/index.d.ts", + "default": "./dist/share/index.js" + }, + "./dashboards": { + "types": "./dist/dashboards/index.d.ts", + "default": "./dist/dashboards/index.js" + }, "./currency": { "types": "./dist/currency/index.d.ts", "default": "./dist/currency/index.js" diff --git a/packages/server-shared/src/chats/chat-errors.types.ts b/packages/server-shared/src/chats/chat-errors.types.ts index fef549287..622db945a 100644 --- a/packages/server-shared/src/chats/chat-errors.types.ts +++ b/packages/server-shared/src/chats/chat-errors.types.ts @@ -1,4 +1,4 @@ -import { z } from 'zod'; +import { z } from 'zod/v4'; /** * Error codes for chat operations @@ -35,7 +35,7 @@ export type ChatErrorCode = (typeof ChatErrorCode)[keyof typeof ChatErrorCode]; export const ChatErrorResponseSchema = z.object({ code: z.string(), message: z.string(), - details: z.record(z.unknown()).optional(), + details: z.record(z.string(), z.any()).optional(), }); export type ChatErrorResponse = z.infer; diff --git a/packages/server-shared/src/chats/chat-message.types.ts b/packages/server-shared/src/chats/chat-message.types.ts index 6b769ed6f..159203e3b 100644 --- a/packages/server-shared/src/chats/chat-message.types.ts +++ b/packages/server-shared/src/chats/chat-message.types.ts @@ -1,4 +1,4 @@ -import { z } from 'zod'; +import { z } from 'zod/v4'; // Message role for chat messages const MessageRoleSchema = z.enum(['user', 'assistant']); @@ -130,7 +130,7 @@ export const ReasoningMessageSchema = z // Chat message schema export const ChatMessageSchema = z.object({ - id: z.string().uuid(), + id: z.string(), request_message: ChatUserMessageSchema, response_messages: z.record(z.string(), ResponseMessageSchema), response_message_ids: z.array(z.string()), diff --git a/packages/server-shared/src/chats/chat.types.ts b/packages/server-shared/src/chats/chat.types.ts index 437c85ed7..b0d237ac4 100644 --- a/packages/server-shared/src/chats/chat.types.ts +++ b/packages/server-shared/src/chats/chat.types.ts @@ -1,4 +1,4 @@ -import { z } from 'zod'; +import { z } from 'zod/v4'; import { ChatMessageSchema } from './chat-message.types'; const AssetType = z.enum(['metric_file', 'dashboard_file']); @@ -15,7 +15,7 @@ export const BusterShareIndividualSchema = z.object({ // Main ChatWithMessages schema export const ChatWithMessagesSchema = z.object({ - id: z.string().uuid(), + id: z.string(), title: z.string(), is_favorited: z.boolean(), message_ids: z.array(z.string()), @@ -38,13 +38,13 @@ export const ChatWithMessagesSchema = z.object({ export const ChatCreateRequestSchema = z .object({ prompt: z.string().optional(), - chat_id: z.string().uuid().optional(), - message_id: z.string().uuid().optional(), - asset_id: z.string().uuid().optional(), + chat_id: z.string().optional(), + message_id: z.string().optional(), + asset_id: z.string().optional(), asset_type: AssetType.optional(), // Legacy fields for backward compatibility - metric_id: z.string().uuid().optional(), - dashboard_id: z.string().uuid().optional(), + metric_id: z.string().optional(), + dashboard_id: z.string().optional(), }) .refine((data) => !data.asset_id || data.asset_type, { message: 'asset_type must be provided when asset_id is specified', @@ -54,9 +54,9 @@ export const ChatCreateRequestSchema = z // Handler request schema (internal - without legacy fields) export const ChatCreateHandlerRequestSchema = z.object({ prompt: z.string().optional(), - chat_id: z.string().uuid().optional(), - message_id: z.string().uuid().optional(), - asset_id: z.string().uuid().optional(), + chat_id: z.string().optional(), + message_id: z.string().optional(), + asset_id: z.string().optional(), asset_type: AssetType.optional(), }); diff --git a/packages/server-shared/src/currency/currency.types.ts b/packages/server-shared/src/currency/currency.types.ts index 1b6f1ca94..415ce8814 100644 --- a/packages/server-shared/src/currency/currency.types.ts +++ b/packages/server-shared/src/currency/currency.types.ts @@ -1,4 +1,4 @@ -import { z } from 'zod'; +import { z } from 'zod/v4'; export const CurrencySchema = z.object({ code: z.string(), diff --git a/packages/server-shared/src/dashboards/dashboard-response.types.ts b/packages/server-shared/src/dashboards/dashboard-response.types.ts index 0ed17d2fd..cda2898f3 100644 --- a/packages/server-shared/src/dashboards/dashboard-response.types.ts +++ b/packages/server-shared/src/dashboards/dashboard-response.types.ts @@ -1,4 +1,4 @@ -import type { Metric } from '../metric'; +import type { Metric } from '../metrics'; import type { ShareConfig, ShareRole } from '../share'; import type { Dashboard } from './dashboard.types'; diff --git a/packages/server-shared/src/metric/charts/annotationInterfaces.ts b/packages/server-shared/src/metric/charts/annotationInterfaces.ts deleted file mode 100644 index 382be7550..000000000 --- a/packages/server-shared/src/metric/charts/annotationInterfaces.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { z } from 'zod/v4'; - -// Goal line is a line that is drawn on the chart to represent a goal. -export const GoalLineSchema = z.object({ - // OPTIONAL: default is false. this should only be used if the user explicitly requests a goal line - show: z.boolean().default(false), - // OPTIONAL: default is null. it should remain null until the user specifies what the goal line value should be. - value: z.nullable(z.number()).default(null), - // OPTIONAL: default is true. - showGoalLineLabel: z.boolean().default(true), - // OPTIONAL: if showGoalLineLabel is true, this will be the label. default is "Goal". - goalLineLabel: z.nullable(z.string()).default('Goal'), - // OPTIONAL: default is #000000 - goalLineColor: z.nullable(z.string()).default('#000000') -}); - -export const TrendlineSchema = z.object({ - // OPTIONAL: default is true. this should only be used if the user explicitly requests a trendline - show: z.boolean().default(true), - // OPTIONAL: default is true - showTrendlineLabel: z.boolean().default(true), - // OPTIONAL: if showTrendlineLabel is true, this will be the label - trendlineLabel: z.nullable(z.string()).default(null), - // default is linear trend - type: z - .enum([ - 'average', - 'linear_regression', - 'logarithmic_regression', - 'exponential_regression', - 'polynomial_regression', - 'min', - 'max', - 'median' - ]) - .default('linear_regression'), - // OPTIONAL: default is #000000, inherit will inherit the color from the line/bar - trendLineColor: z.union([z.nullable(z.string()), z.literal('inherit')]).default('#000000'), - columnId: z.string(), - // OPTIONAL: default is 0.85. Goes from 0 to 100. This is where the label will be placed on the trendline. - trendlineLabelPositionOffset: z.number().min(0).max(100).default(85), - // OPTIONAL: default is false. if true, the trendline will be projected to the end of the chart. - projection: z.boolean().default(false), - lineStyle: z.enum(['solid', 'dotted', 'dashed', 'dashdot']).default('solid'), - // OPTIONAL: default is 0. if true, the label will be offset vertically from the trendline. - offset: z.number().default(0), - polynomialOrder: z.number().default(2), - // OPTIONAL: default is true. if true, the trendline will be calculated for all categories. if false, the trendline will be calculated for the category specified in the columnId. - aggregateAllCategories: z.boolean().default(true), - id: z.string() -}); - -// Export inferred types -export type GoalLine = z.infer; -export type Trendline = z.infer; diff --git a/packages/server-shared/src/metric/charts/axisInterfaces.ts b/packages/server-shared/src/metric/charts/axisInterfaces.ts deleted file mode 100644 index be60cd6cc..000000000 --- a/packages/server-shared/src/metric/charts/axisInterfaces.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { z } from 'zod/v4'; - -export const BarAndLineAxisSchema = z - .object({ - // the column ids to use for the x axis. If multiple column ids are provided, they will be grouped together and summed. The LLM should NEVER set multiple x axis columns. Only the user can set this. - x: z.array(z.string()).default([]), - // the column ids to use for the y axis. - y: z.array(z.string()).default([]), - // the column ids to use for the category axis. If multiple column ids are provided, they will be grouped together. THE LLM SHOULD NEVER SET MULTIPLE CATEGORY COLUMNS. ONLY THE USER CAN SET THIS. - category: z.array(z.string()).default([]), - // if null the y axis will automatically be used, the y axis will be used for the tooltip. - tooltip: z.nullable(z.array(z.string())).default(null).optional() - }) - .default({ - x: [], - y: [], - category: [], - tooltip: null - }); - -export const ScatterAxisSchema = z - .object({ - // the column ids to use for the x axis. If multiple column ids are provided, they will be grouped together and summed. The LLM should NEVER set multiple x axis columns. Only the user can set this. - x: z.array(z.string()).default([]), - // the column ids to use for the y axis. If multiple column ids are provided, they will be grouped together and summed. The LLM should NEVER set multiple x axis columns. Only the user can set this. - y: z.array(z.string()).default([]), - // the column ids to use for the category axis. If multiple column ids are provided, they will be grouped together. THE LLM SHOULD NEVER SET MULTIPLE CATEGORY COLUMNS. ONLY THE USER CAN SET THIS. - category: z.array(z.string()).default([]), - // the column id to use for the size range of the dots. ONLY one column id should be provided. - size: z.tuple([z.string()]).or(z.array(z.string()).length(0)).default([]), - // if null the y axis will automatically be used, the y axis will be used for the tooltip. - tooltip: z.nullable(z.array(z.string())).default(null) - }) - .default({ - x: [], - y: [], - size: [], - category: [], - tooltip: null - }); - -export const ComboChartAxisSchema = z - .object({ - // the column ids to use for the x axis. If multiple column ids are provided, they will be grouped together and summed. The LLM should NEVER set multiple x axis columns. Only the user can set this. - x: z.array(z.string()).default([]), - // the column ids to use for the y axis. If multiple column ids are provided, they will be grouped together and summed. The LLM should NEVER set multiple y axis columns. Only the user can set this. - y: z.array(z.string()).default([]), - // the column ids to use for the right y axis. If multiple column ids are provided, they will be grouped together and summed. The LLM should NEVER set multiple y axis columns. Only the user can set this. - y2: z.array(z.string()).default([]), - // the column ids to use for the category axis. If multiple column ids are provided, they will be grouped together. THE LLM SHOULD NEVER SET MULTIPLE CATEGORY COLUMNS. ONLY THE USER CAN SET THIS. - category: z.array(z.string()).default([]), - // if null the y axis will automatically be used, the y axis will be used for the tooltip. - tooltip: z.nullable(z.array(z.string())).default(null).optional() - }) - .default({ - x: [], - y: [], - y2: [], - category: [], - tooltip: null - }); - -export const PieChartAxisSchema = z - .object({ - // the column ids to use for the x axis. If multiple column ids are provided, they will be grouped together and summed. The LLM should NEVER set multiple x axis columns. Only the user can set this. - x: z.array(z.string()).default([]), - // the column ids to use for the y axis. If multiple column ids are provided, they will appear as rings. The LLM should NEVER set multiple y axis columns. Only the user can set this. - y: z.array(z.string()).default([]), - // if null the y axis will automatically be used, the y axis will be used for the tooltip. - tooltip: z.nullable(z.array(z.string())).default(null) - }) - .default({ - x: [], - y: [], - tooltip: null - }); - -export const ChartEncodesSchema = z.union([ - BarAndLineAxisSchema, - ScatterAxisSchema, - PieChartAxisSchema, - ComboChartAxisSchema -]); - -// Export inferred types -export type BarAndLineAxis = z.infer; -export type ScatterAxis = z.infer; -export type ComboChartAxis = z.infer; -export type PieChartAxis = z.infer; -export type ChartEncodes = z.infer; diff --git a/packages/server-shared/src/metric/charts/barChartProps.ts b/packages/server-shared/src/metric/charts/barChartProps.ts deleted file mode 100644 index 81d88d7c8..000000000 --- a/packages/server-shared/src/metric/charts/barChartProps.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { z } from 'zod/v4'; -import { BarAndLineAxisSchema } from './axisInterfaces'; -import { BarSortBySchema } from './etcInterfaces'; - -export const BarChartPropsSchema = z.object({ - // Required for Bar - barAndLineAxis: BarAndLineAxisSchema, - // OPTIONAL: default: vertical (column chart) - barLayout: z.enum(['horizontal', 'vertical']).default('vertical'), - // OPTIONAL - barSortBy: BarSortBySchema, - // OPTIONAL: default is group. This will only apply if the columnVisualization is set to 'bar'. - barGroupType: z.nullable(z.enum(['stack', 'group', 'percentage-stack'])).default('group'), - // OPTIONAL: default is false. This will only apply if is is stacked and there is either a category or multiple y axis applie to the series. - barShowTotalAtTop: z.boolean().default(false) -}); - -export type BarChartProps = z.infer; diff --git a/packages/server-shared/src/metric/charts/chartBaseInterfaces.ts b/packages/server-shared/src/metric/charts/chartBaseInterfaces.ts deleted file mode 100644 index 38f254eca..000000000 --- a/packages/server-shared/src/metric/charts/chartBaseInterfaces.ts +++ /dev/null @@ -1,10 +0,0 @@ -//ONLY USED IN COMPONENTS -export type BusterChartPropsBase = { - onMounted: () => void; - onInitialAnimationEnd: () => void; - className?: string; - animate?: boolean; - data: Record[]; - isDarkMode?: boolean; - readOnly?: boolean; -}; diff --git a/packages/server-shared/src/metric/charts/chatConfig.defaults.test.ts b/packages/server-shared/src/metric/charts/chatConfig.defaults.test.ts deleted file mode 100644 index a972228a6..000000000 --- a/packages/server-shared/src/metric/charts/chatConfig.defaults.test.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { describe, it, expect } from 'vitest'; -import { DEFAULT_CHART_CONFIG } from './chatConfig.defaults'; -import { BusterChartConfigPropsSchema } from './chartConfigProps'; -import { DEFAULT_CHART_THEME } from './configColors'; - -describe('DEFAULT_CHART_CONFIG', () => { - it('should conform to BusterChartConfigPropsSchema and have expected default values', () => { - // Verify that DEFAULT_CHART_CONFIG is valid according to the schema - const parseResult = BusterChartConfigPropsSchema.safeParse(DEFAULT_CHART_CONFIG); - expect(parseResult.success).toBe(true); - - if (parseResult.success) { - const config = parseResult.data; - - // Test key default values - expect(config.colors).toEqual(DEFAULT_CHART_THEME); - expect(config.gridLines).toBe(true); - expect(config.showLegendHeadline).toBe(false); - expect(config.disableTooltip).toBe(false); - expect(config.goalLines).toEqual([]); - expect(config.trendlines).toEqual([]); - expect(config.columnSettings).toEqual({}); - expect(config.columnLabelFormats).toEqual({}); - expect(config.showLegend).toBeNull(); - expect(config.barLayout).toBe('vertical'); - expect(config.barSortBy).toEqual([]); - expect(config.barGroupType).toBe('group'); - expect(config.barShowTotalAtTop).toBe(false); - expect(config.lineGroupType).toBeNull(); - expect(config.scatterAxis).toEqual({ - x: [], - y: [], - category: [], - size: [], - tooltip: null - }); - expect(config.pieChartAxis).toEqual({ - x: [], - y: [], - tooltip: null - }); - - // Verify the config is a complete object with all required properties - expect(typeof config).toBe('object'); - expect(config).not.toBeNull(); - - // Verify it has a selectedChartType (required field) - expect(config.selectedChartType).toBeDefined(); - } - }); -}); diff --git a/packages/server-shared/src/metric/charts/columnInterfaces.ts b/packages/server-shared/src/metric/charts/columnInterfaces.ts deleted file mode 100644 index 668620df8..000000000 --- a/packages/server-shared/src/metric/charts/columnInterfaces.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { z } from 'zod/v4'; - -export const LineColumnSettingsSchema = z.object({ - // OPTIONAL: default is 2. This will only apply if the columnVisualization is set to 'line'. - lineWidth: z - .number() - .min(1, 'Line width must be at least 1') - .max(20, 'Line width must be at most 20') - .default(2), - // OPTIONAL: default is area. This will only apply if the columnVisualization is set to 'line' and it is a combo chart. - lineStyle: z.enum(['area', 'line']).default('line'), - // OPTIONAL: default is normal. This will only apply if the columnVisualization is set to 'line'. - lineType: z.enum(['normal', 'smooth', 'step']).default('normal'), - // OPTIONAL: default is 0. The range is 0-10. If a user requests this, we recommend setting it at 2px to start. This will only apply if the columnVisualization is set to 'line'. The UI calls this "Dots on Line". - lineSymbolSize: z - .number() - .min(0, 'Line symbol size must be at least 0') - .max(10, 'Line symbol size must be at most 10') - .default(0) -}); - -export const BarColumnSettingsSchema = z.object({ - // OPTIONAL: default is 8. This will only apply if the columnVisualization is set to 'bar'. The value represents the roundness of the bar. 0 is square, 50 is circular. - barRoundness: z - .number() - .min(0, 'Bar roundness must be at least 0') - .max(50, 'Bar roundness must be at most 50') - .default(8) -}); - -export const DotColumnSettingsSchema = z.object({ - // OPTIONAL: default is 10. This will only apply if the columnVisualization is set to 'dot'. This represents the size range of the dots in pixels. - lineSymbolSize: z - .number() - .min(1, 'Dot symbol size must be at least 1') - .max(50, 'Dot symbol size must be at most 50') - .default(10) -}); - -export const ColumnSettingsSchema = z.object({ - // OPTIONAL: default is false - showDataLabels: z.boolean().default(false), - // OPTIONAL: default is false - showDataLabelsAsPercentage: z.boolean().default(false), - // OPTIONAL: default is null. These can be applied to any number column. If this is set to null, then the yAxisColumnVisualization will be inherited from the chart level. - columnVisualization: z.enum(['bar', 'line', 'dot']).default('bar'), - // LineColumnSettings properties - // OPTIONAL: default is 2. This will only apply if the columnVisualization is set to 'line'. - lineWidth: z - .number() - .min(1, 'Line width must be at least 1') - .max(20, 'Line width must be at most 20') - .default(2), - // OPTIONAL: default is area. This will only apply if the columnVisualization is set to 'line' and it is a combo chart. - lineStyle: z.enum(['area', 'line']).default('line'), - // OPTIONAL: default is normal. This will only apply if the columnVisualization is set to 'line'. - lineType: z.enum(['normal', 'smooth', 'step']).default('normal'), - // OPTIONAL: default varies by visualization type - 0 for 'line' (Dots on Line), 10 for 'dot' (dot size in pixels) - lineSymbolSize: z - .number() - .min(0, 'Symbol size must be at least 0') - .max(50, 'Symbol size must be at most 50') - .default(0), - // BarColumnSettings properties - // OPTIONAL: default is 8. This will only apply if the columnVisualization is set to 'bar'. The value represents the roundness of the bar. 0 is square, 50 is circular. - barRoundness: z - .number() - .min(0, 'Bar roundness must be at least 0') - .max(50, 'Bar roundness must be at most 50') - .default(8) -}); - -// Export inferred types -export type LineColumnSettings = z.infer; -export type BarColumnSettings = z.infer; -export type DotColumnSettings = z.infer; -export type ColumnSettings = z.infer; diff --git a/packages/server-shared/src/metric/charts/comboChartProps.ts b/packages/server-shared/src/metric/charts/comboChartProps.ts deleted file mode 100644 index a31492696..000000000 --- a/packages/server-shared/src/metric/charts/comboChartProps.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { z } from 'zod/v4'; -import { ComboChartAxisSchema } from './axisInterfaces'; - -export const ComboChartPropsSchema = z.object({ - // Required for Combo - comboChartAxis: ComboChartAxisSchema -}); - -export type ComboChartProps = z.infer; diff --git a/packages/server-shared/src/metric/charts/configColors.ts b/packages/server-shared/src/metric/charts/configColors.ts deleted file mode 100644 index d0a08000c..000000000 --- a/packages/server-shared/src/metric/charts/configColors.ts +++ /dev/null @@ -1,12 +0,0 @@ -export const DEFAULT_CHART_THEME = [ - '#B399FD', - '#FC8497', - '#FBBC30', - '#279EFF', - '#E83562', - '#41F8FF', - '#F3864F', - '#C82184', - '#31FCB4', - '#E83562' -]; diff --git a/packages/server-shared/src/metric/charts/enum.ts b/packages/server-shared/src/metric/charts/enum.ts deleted file mode 100644 index a1a7e04fc..000000000 --- a/packages/server-shared/src/metric/charts/enum.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { z } from 'zod/v4'; - -export const ChartTypeSchema = z - .enum(['line', 'bar', 'scatter', 'pie', 'metric', 'table', 'combo']) - .default('table'); - -export type ChartType = z.infer; - -export const ChartTypePlottableSchema = z.enum(['line', 'bar', 'scatter', 'pie', 'combo']); -export type ChartTypePlottable = z.infer; - -export const SimplifiedColumnTypeSchema = z.enum(['number', 'text', 'date']).default('text'); - -export type SimplifiedColumnType = z.infer; diff --git a/packages/server-shared/src/metric/charts/etcInterfaces.ts b/packages/server-shared/src/metric/charts/etcInterfaces.ts deleted file mode 100644 index 1191c16b0..000000000 --- a/packages/server-shared/src/metric/charts/etcInterfaces.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { z } from 'zod/v4'; - -// OPTIONAL: default is no sorting (none). The first item in the array will be the primary sort. The second item will be the secondary sort. This will only apply if the X axis type is not a date. -export const BarSortBySchema = z.array(z.enum(['asc', 'desc', 'none'])).default([]); - -// OPTIONAL: default: value -export const PieSortBySchema = z.union([z.enum(['value', 'key']), z.null()]).default('value'); - -// current is used for line charts with -export const ShowLegendHeadlineSchema = z - .union([z.literal(false), z.enum(['current', 'average', 'total', 'median', 'min', 'max'])]) - .default(false); - -// Export inferred types -export type BarSortBy = z.infer; -export type PieSortBy = z.infer; -export type ShowLegendHeadline = z.infer; diff --git a/packages/server-shared/src/metric/charts/lineChartProps.test.ts b/packages/server-shared/src/metric/charts/lineChartProps.test.ts deleted file mode 100644 index 519c80822..000000000 --- a/packages/server-shared/src/metric/charts/lineChartProps.test.ts +++ /dev/null @@ -1,112 +0,0 @@ -import { describe, it, expect } from 'vitest'; -import { LineChartPropsSchema, type LineChartProps } from './lineChartProps'; - -describe('LineChartPropsSchema', () => { - describe('valid inputs', () => { - it('should accept "stack" as lineGroupType', () => { - const input = { lineGroupType: 'stack' }; - const result = LineChartPropsSchema.parse(input); - expect(result.lineGroupType).toBe('stack'); - }); - - it('should accept "percentage-stack" as lineGroupType', () => { - const input = { lineGroupType: 'percentage-stack' }; - const result = LineChartPropsSchema.parse(input); - expect(result.lineGroupType).toBe('percentage-stack'); - }); - - it('should accept null as lineGroupType', () => { - const input = { lineGroupType: null }; - const result = LineChartPropsSchema.parse(input); - expect(result.lineGroupType).toBe(null); - }); - - it('should accept empty object and use default null value', () => { - const input = {}; - const result = LineChartPropsSchema.parse(input); - expect(result.lineGroupType).toBe(null); - }); - - it('should accept undefined and use default null value', () => { - const input = { lineGroupType: null }; - const result = LineChartPropsSchema.parse(input); - expect(result.lineGroupType).toBe(null); - }); - }); - - describe('invalid inputs', () => { - it('should reject invalid string values', () => { - const input = { lineGroupType: 'invalid-value' }; - expect(() => LineChartPropsSchema.parse(input)).toThrow(); - }); - - it('should reject numeric values', () => { - const input = { lineGroupType: 123 }; - expect(() => LineChartPropsSchema.parse(input)).toThrow(); - }); - - it('should reject boolean values', () => { - const input = { lineGroupType: true }; - expect(() => LineChartPropsSchema.parse(input)).toThrow(); - }); - - it('should reject array values', () => { - const input = { lineGroupType: ['stack'] }; - expect(() => LineChartPropsSchema.parse(input)).toThrow(); - }); - - it('should reject object values', () => { - const input = { lineGroupType: { type: 'stack' } }; - expect(() => LineChartPropsSchema.parse(input)).toThrow(); - }); - }); - - describe('safe parsing', () => { - it('should return success for valid input', () => { - const input = { lineGroupType: 'stack' }; - const result = LineChartPropsSchema.safeParse(input); - expect(result.success).toBe(true); - if (result.success) { - expect(result.data.lineGroupType).toBe('stack'); - } - }); - - it('should return error for invalid input', () => { - const input = { lineGroupType: 'invalid' }; - const result = LineChartPropsSchema.safeParse(input); - expect(result.success).toBe(false); - }); - }); - - describe('type inference', () => { - it('should correctly infer LineChartProps type', () => { - const validData: LineChartProps = { - lineGroupType: 'stack' - }; - expect(LineChartPropsSchema.parse(validData)).toEqual(validData); - - const validDataWithNull: LineChartProps = { - lineGroupType: null - }; - expect(LineChartPropsSchema.parse(validDataWithNull)).toEqual(validDataWithNull); - - const validDataWithPercentage: LineChartProps = { - lineGroupType: 'percentage-stack' - }; - expect(LineChartPropsSchema.parse(validDataWithPercentage)).toEqual(validDataWithPercentage); - }); - }); - - describe('default behavior', () => { - it('should use null as default when property is omitted', () => { - const result = LineChartPropsSchema.parse({}); - expect(result).toEqual({ lineGroupType: null }); - }); - - it('should preserve explicitly set null values', () => { - const input = { lineGroupType: null }; - const result = LineChartPropsSchema.parse(input); - expect(result).toEqual({ lineGroupType: null }); - }); - }); -}); diff --git a/packages/server-shared/src/metric/charts/lineChartProps.ts b/packages/server-shared/src/metric/charts/lineChartProps.ts deleted file mode 100644 index a8dde719a..000000000 --- a/packages/server-shared/src/metric/charts/lineChartProps.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { z } from 'zod/v4'; - -export const LineChartPropsSchema = z.object({ - // OPTIONAL: default is null. This will only apply if the columnVisualization is set to 'line'. If this is set to stack it will stack the lines on top of each other. The UI has this labeled as "Show as %" - lineGroupType: z.enum(['stack', 'percentage-stack']).nullable().default(null) -}); - -export type LineChartProps = z.infer; diff --git a/packages/server-shared/src/metric/charts/metricChartProps.ts b/packages/server-shared/src/metric/charts/metricChartProps.ts deleted file mode 100644 index 6a252e2c7..000000000 --- a/packages/server-shared/src/metric/charts/metricChartProps.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { z } from 'zod/v4'; - -export const DerivedMetricTitleSchema = z.object({ - // which column to use. - columnId: z.string(), - // whether to display to use the key or the value in the chart - useValue: z.boolean(), - // OPTIONAL: default is sum - aggregate: z.enum(['sum', 'average', 'median', 'max', 'min', 'count', 'first']).default('sum') -}); - -export const MetricChartPropsSchema = z.object({ - // the column id to use for the value. - metricColumnId: z.string().default(''), - // OPTIONAL: default: sum - metricValueAggregate: z - .enum(['sum', 'average', 'median', 'max', 'min', 'count', 'first']) - .default('sum'), - // OPTIONAL: if undefined, the column id will be used and formatted - metricHeader: z.nullable(z.union([z.string(), DerivedMetricTitleSchema])).default(null), - // OPTIONAL: default is '' - metricSubHeader: z.nullable(z.union([z.string(), DerivedMetricTitleSchema])).default(null), - // OPTIONAL: default is null. If null then the metricColumnId will be used in conjunction with the metricValueAggregate. If not null, then the metricValueLabel will be used. - metricValueLabel: z.nullable(z.string()).default(null) -}); - -export type DerivedMetricTitle = z.infer; -export type MetricChartProps = z.infer; diff --git a/packages/server-shared/src/metric/charts/scatterChartProps.ts b/packages/server-shared/src/metric/charts/scatterChartProps.ts deleted file mode 100644 index 74c74ca64..000000000 --- a/packages/server-shared/src/metric/charts/scatterChartProps.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { z } from 'zod/v4'; -import { ScatterAxisSchema } from './axisInterfaces'; - -export const ScatterChartPropsSchema = z.object({ - // Required for Scatter - scatterAxis: ScatterAxisSchema, - scatterDotSize: z.tuple([z.number(), z.number()]).default([3, 15]) -}); - -export type ScatterChartProps = z.infer; diff --git a/packages/server-shared/src/metric/charts/tableChartProps.ts b/packages/server-shared/src/metric/charts/tableChartProps.ts deleted file mode 100644 index 8f3e0961f..000000000 --- a/packages/server-shared/src/metric/charts/tableChartProps.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { z } from 'zod/v4'; - -export const TableChartPropsSchema = z.object({ - tableColumnOrder: z.nullable(z.array(z.string())).default(null), - tableColumnWidths: z.nullable(z.record(z.string(), z.number())).default(null), - tableHeaderBackgroundColor: z.nullable(z.string()).default(null), - tableHeaderFontColor: z.nullable(z.string()).default(null), - tableColumnFontColor: z.nullable(z.string()).default(null) -}); - -export type TableChartProps = z.infer; diff --git a/apps/web/src/api/asset_interfaces/metric/charts/annotationInterfaces.ts b/packages/server-shared/src/metrics/charts/annotationInterfaces.ts similarity index 100% rename from apps/web/src/api/asset_interfaces/metric/charts/annotationInterfaces.ts rename to packages/server-shared/src/metrics/charts/annotationInterfaces.ts diff --git a/apps/web/src/api/asset_interfaces/metric/charts/axisInterfaces.ts b/packages/server-shared/src/metrics/charts/axisInterfaces.ts similarity index 100% rename from apps/web/src/api/asset_interfaces/metric/charts/axisInterfaces.ts rename to packages/server-shared/src/metrics/charts/axisInterfaces.ts diff --git a/apps/web/src/api/asset_interfaces/metric/charts/barChartProps.ts b/packages/server-shared/src/metrics/charts/barChartProps.ts similarity index 100% rename from apps/web/src/api/asset_interfaces/metric/charts/barChartProps.ts rename to packages/server-shared/src/metrics/charts/barChartProps.ts diff --git a/apps/web/src/api/asset_interfaces/metric/charts/chartBaseInterfaces.ts b/packages/server-shared/src/metrics/charts/chartBaseInterfaces.ts similarity index 100% rename from apps/web/src/api/asset_interfaces/metric/charts/chartBaseInterfaces.ts rename to packages/server-shared/src/metrics/charts/chartBaseInterfaces.ts diff --git a/packages/server-shared/src/metric/charts/chartConfigProps.ts b/packages/server-shared/src/metrics/charts/chartConfigProps.ts similarity index 68% rename from packages/server-shared/src/metric/charts/chartConfigProps.ts rename to packages/server-shared/src/metrics/charts/chartConfigProps.ts index 64a408902..0d2949cb1 100644 --- a/packages/server-shared/src/metric/charts/chartConfigProps.ts +++ b/packages/server-shared/src/metrics/charts/chartConfigProps.ts @@ -1,30 +1,37 @@ -import { z } from 'zod/v4'; -import { GoalLineSchema, TrendlineSchema } from './annotationInterfaces'; -import { BarChartPropsSchema } from './barChartProps'; -import { ColumnSettingsSchema } from './columnInterfaces'; -import { IColumnLabelFormatSchema } from './columnLabelInterfaces'; -import { ComboChartPropsSchema } from './comboChartProps'; -import { DEFAULT_CHART_THEME } from './configColors'; -import { ChartTypeSchema } from './enum'; -import { ShowLegendHeadlineSchema } from './etcInterfaces'; -import { LineChartPropsSchema } from './lineChartProps'; -import { DerivedMetricTitleSchema, MetricChartPropsSchema } from './metricChartProps'; -import { PieChartPropsSchema } from './pieChartProps'; -import { ScatterChartPropsSchema } from './scatterChartProps'; -import { TableChartPropsSchema } from './tableChartProps'; +import { z } from "zod/v4"; +import { GoalLineSchema, TrendlineSchema } from "./annotationInterfaces"; +import { BarChartPropsSchema } from "./barChartProps"; +import { ColumnSettingsSchema } from "./columnInterfaces"; +import { ColumnLabelFormatSchema } from "./columnLabelInterfaces"; +import { ComboChartPropsSchema } from "./comboChartProps"; +import { DEFAULT_CHART_THEME } from "./configColors"; +import { ChartTypeSchema } from "./enum"; +import { ShowLegendHeadlineSchema } from "./etcInterfaces"; +import { LineChartPropsSchema } from "./lineChartProps"; +import { + DerivedMetricTitleSchema, + MetricChartPropsSchema, +} from "./metricChartProps"; +import { PieChartPropsSchema } from "./pieChartProps"; +import { ScatterChartPropsSchema } from "./scatterChartProps"; +import { TableChartPropsSchema } from "./tableChartProps"; import { CategoryAxisStyleConfigSchema, XAxisConfigSchema, Y2AxisConfigSchema, YAxisConfigSchema, -} from './tickInterfaces'; +} from "./tickInterfaces"; export const ChartConfigPropsSchema = z.object({ selectedChartType: ChartTypeSchema, // COLUMN SETTINGS // OPTIONAL because the defaults will be determined by the UI - columnSettings: z.record(z.string(), z.optional(ColumnSettingsSchema)).default({}), - columnLabelFormats: z.record(z.string(), z.optional(IColumnLabelFormatSchema)).default({}), + columnSettings: z + .record(z.string(), z.optional(ColumnSettingsSchema)) + .default({}), + columnLabelFormats: z + .record(z.string(), z.optional(ColumnLabelFormatSchema)) + .default({}), // OPTIONAL: default is the buster color palette colors: z.array(z.string()).default(DEFAULT_CHART_THEME), // OPTIONAL: default is null and will be true if there are multiple Y axes or if a category axis is used diff --git a/apps/web/src/api/asset_interfaces/metric/charts/chatConfig.defaults.test.ts b/packages/server-shared/src/metrics/charts/chatConfig.defaults.test.ts similarity index 100% rename from apps/web/src/api/asset_interfaces/metric/charts/chatConfig.defaults.test.ts rename to packages/server-shared/src/metrics/charts/chatConfig.defaults.test.ts diff --git a/packages/server-shared/src/metrics/charts/chatConfig.defaults.ts b/packages/server-shared/src/metrics/charts/chatConfig.defaults.ts new file mode 100644 index 000000000..75ca8b612 --- /dev/null +++ b/packages/server-shared/src/metrics/charts/chatConfig.defaults.ts @@ -0,0 +1,27 @@ +import type { ColumnMetaData } from '../metadata.type'; +import { type Metric, MetricSchema } from '../metric.types'; +import { type Trendline, TrendlineSchema } from './annotationInterfaces'; +import { type ChartConfigProps, ChartConfigPropsSchema } from './chartConfigProps'; +import { type ColumnSettings, ColumnSettingsSchema } from './columnInterfaces'; +import { type ColumnLabelFormat, ColumnLabelFormatSchema } from './columnLabelInterfaces'; +import { getDefaults } from './defaultHelpers'; + +export const DEFAULT_CHART_CONFIG: ChartConfigProps = getDefaults(ChartConfigPropsSchema); +export const DEFAULT_COLUMN_SETTINGS: ColumnSettings = getDefaults(ColumnSettingsSchema); +export const DEFAULT_COLUMN_LABEL_FORMAT: ColumnLabelFormat = getDefaults(ColumnLabelFormatSchema); + +export const ENABLED_DOTS_ON_LINE = 3.5; +export const DEFAULT_CHART_CONFIG_ENTRIES = Object.entries(DEFAULT_CHART_CONFIG); +export const DEFAULT_BAR_ROUNDNESS = DEFAULT_COLUMN_SETTINGS.barRoundness; +export const MIN_DONUT_WIDTH = 15; + +export const DEFAULT_DAY_OF_WEEK_FORMAT = 'ddd'; +export const DEFAULT_DATE_FORMAT_DAY_OF_WEEK = 'dddd'; +export const DEFAULT_DATE_FORMAT_MONTH_OF_YEAR = 'MMMM'; +export const DEFAULT_DATE_FORMAT_QUARTER = 'YYYY [Q]Q'; + +export const ENABLED_DOTS_ON_LINE_SIZE = 4; +export const DEFAULT_COLUMN_METADATA: ColumnMetaData[] = []; + +export const DEFAULT_TRENDLINE_CONFIG: Required = getDefaults(TrendlineSchema); +export const DEFAULT_METRIC: Required = getDefaults(MetricSchema); diff --git a/apps/web/src/api/asset_interfaces/metric/charts/columnInterfaces.ts b/packages/server-shared/src/metrics/charts/columnInterfaces.ts similarity index 100% rename from apps/web/src/api/asset_interfaces/metric/charts/columnInterfaces.ts rename to packages/server-shared/src/metrics/charts/columnInterfaces.ts diff --git a/packages/server-shared/src/metric/charts/columnLabelInterfaces.ts b/packages/server-shared/src/metrics/charts/columnLabelInterfaces.ts similarity index 52% rename from packages/server-shared/src/metric/charts/columnLabelInterfaces.ts rename to packages/server-shared/src/metrics/charts/columnLabelInterfaces.ts index 134d81b9d..d0d2381cf 100644 --- a/packages/server-shared/src/metric/charts/columnLabelInterfaces.ts +++ b/packages/server-shared/src/metrics/charts/columnLabelInterfaces.ts @@ -1,69 +1,76 @@ -import { z } from 'zod/v4'; +import { z } from "zod/v4"; -export const IColumnLabelFormatSchema = z.object({ - columnType: z.enum(['number', 'text', 'date'] as const), - style: z.enum(['currency', 'percent', 'number', 'date', 'string']), +export const ColumnLabelFormatSchema = z.object({ + columnType: z.enum(["number", "text", "date"] as const).default("text"), + style: z + .enum(["currency", "percent", "number", "date", "string"]) + .default("string"), // All other properties from ColumnLabelFormat // OPTIONAL: if this is not specifically requested by the user, then you should ignore this and the columnId will be used and formatted - displayName: z.optional(z.string()), + displayName: z.optional(z.string()).default(""), // OPTIONAL: default is ','. You should add this style if the column type requires a unique separator style. This will only apply if the format is set to 'number'. - numberSeparatorStyle: z.optional(z.nullable(z.literal(','))), + numberSeparatorStyle: z.optional(z.nullable(z.literal(","))).default(","), // OPTIONAL: default is 0. This is essentially used to set a minimum number of decimal places. This will only apply if the format is set to 'number'. - minimumFractionDigits: z.optional( - z - .number() - .check( - z.gte(0, 'Minimum fraction digits must be at least 0'), - z.lte(20, 'Minimum fraction digits must be at most 20') - ) - ), + minimumFractionDigits: z + .optional( + z + .number() + .check( + z.gte(0, "Minimum fraction digits must be at least 0"), + z.lte(20, "Minimum fraction digits must be at most 20") + ) + ) + .default(0), // OPTIONAL: default is 2. This is essentially used to set a maximum number of decimal places. This will only apply if the format is set to 'number'. - maximumFractionDigits: z.optional( - z - .number() - .check( - z.gte(0, 'Maximum fraction digits must be at least 0'), - z.lte(20, 'Maximum fraction digits must be at most 20') - ) - ), + maximumFractionDigits: z + .optional( + z + .number() + .check( + z.gte(0, "Maximum fraction digits must be at least 0"), + z.lte(20, "Maximum fraction digits must be at most 20") + ) + ) + .default(2), // OPTIONAL: default is 1. This will only apply if the format is set to 'number', 'currency', or 'percent'. - multiplier: z.optional( - z - .number() - .check( - z.gte(0.001, 'Multiplier must be at least 0.001'), - z.lte(1000000, 'Multiplier must be at most 1,000,000') - ) - ), + multiplier: z + .optional( + z + .number() + .check( + z.gte(0.001, "Multiplier must be at least 0.001"), + z.lte(1000000, "Multiplier must be at most 1,000,000") + ) + ) + .default(1), // OPTIONAL: default is ''. This sets a prefix to go in front of each value found within the column. This will only apply if the format is set to 'number' or 'percent'. - prefix: z.optional(z.string()), + prefix: z.optional(z.string()).default(""), // OPTIONAL: default is ''. This sets a suffix to go after each value found within the column. This will only apply if the format is set to 'number' or 'percent'. - suffix: z.optional(z.string()), + suffix: z.optional(z.string()).default(""), // OPTIONAL: default is 0. This will only apply if the format is set to 'number'. This will replace missing data with the specified value. - replaceMissingDataWith: z.optional(z.union([z.literal(0), z.null(), z.string()])), - useRelativeTime: z.optional(z.boolean()), - isUTC: z.optional(z.boolean()), - makeLabelHumanReadable: z.optional(z.boolean()), + replaceMissingDataWith: z + .optional(z.union([z.literal(0), z.null(), z.string()])) + .default(0), + useRelativeTime: z.optional(z.boolean()).default(false), + isUTC: z.optional(z.boolean()).default(true), + makeLabelHumanReadable: z.optional(z.boolean()).default(true), // DO NOT SHARE WITH LLM - compactNumbers: z.optional(z.boolean()), + compactNumbers: z.optional(z.boolean()).default(false), // Currency-specific properties // OPTIONAL: default is 'USD'. This will only apply if the format is set to 'currency'. It should be the ISO 4217 currency code. - currency: z.optional(z.string()), + currency: z.optional(z.string()).default("USD"), // Date-specific properties // OPTIONAL: default is 'LL'. This will only apply if the format is set to 'date'. This will convert the date to the specified format. This MUST BE IN dayjs format. If you determine that a column type is a date column, you should specify it's date format here. - dateFormat: z.optional(z.union([z.literal('auto'), z.string()])), + dateFormat: z + .optional(z.union([z.literal("auto"), z.string()])) + .default("auto"), // OPTIONAL: default is null. This will only apply if the format is set to 'number'. This will convert the number to a specified date unit. For example, if month_of_year is selected, then the number 0 will be converted to January. - convertNumberTo: z.optional( - z.nullable(z.enum(['day_of_week', 'month_of_year', 'quarter', 'number'])) - ) -}); - -// Create ColumnLabelFormatSchema by extending IColumnLabelFormatSchema with optional columnType and style -export const ColumnLabelFormatSchema = IColumnLabelFormatSchema.extend({ - columnType: z.optional(z.enum(['number', 'text', 'date'] as const)), - style: z.optional(z.enum(['currency', 'percent', 'number', 'date', 'string'])) + convertNumberTo: z + .optional( + z.nullable(z.enum(["day_of_week", "month_of_year", "quarter", "number"])) + ) + .default(null), }); // Export inferred types export type ColumnLabelFormat = z.infer; -export type IColumnLabelFormat = z.infer; diff --git a/apps/web/src/api/asset_interfaces/metric/charts/comboChartProps.ts b/packages/server-shared/src/metrics/charts/comboChartProps.ts similarity index 100% rename from apps/web/src/api/asset_interfaces/metric/charts/comboChartProps.ts rename to packages/server-shared/src/metrics/charts/comboChartProps.ts diff --git a/apps/web/src/api/asset_interfaces/metric/charts/configColors.ts b/packages/server-shared/src/metrics/charts/configColors.ts similarity index 100% rename from apps/web/src/api/asset_interfaces/metric/charts/configColors.ts rename to packages/server-shared/src/metrics/charts/configColors.ts diff --git a/packages/server-shared/src/metric/charts/chatConfig.defaults.ts b/packages/server-shared/src/metrics/charts/defaultHelpers.ts similarity index 80% rename from packages/server-shared/src/metric/charts/chatConfig.defaults.ts rename to packages/server-shared/src/metrics/charts/defaultHelpers.ts index fdf4377ae..f281cb0ed 100644 --- a/packages/server-shared/src/metric/charts/chatConfig.defaults.ts +++ b/packages/server-shared/src/metrics/charts/defaultHelpers.ts @@ -1,13 +1,11 @@ import type { z } from 'zod/v4'; -import { type ChartConfigProps, ChartConfigPropsSchema } from './chartConfigProps'; -import { DEFAULT_CHART_THEME } from './configColors'; /** * Extracts all default values from a Zod schema. * This function creates a partial version of the schema where all fields are optional, * then parses an empty object to get all the default values. */ -function getDefaults>(schema: T): z.infer { +export function getDefaults>(schema: T): z.infer { // Create a partial version of the schema where all fields are optional const partialSchema = schema.partial(); @@ -37,5 +35,3 @@ export function getDefaultsPartial>( const partialSchema = schema.partial(); return partialSchema.parse({}) as Partial>; } - -export const DEFAULT_CHART_CONFIG: ChartConfigProps = getDefaults(ChartConfigPropsSchema); diff --git a/apps/web/src/api/asset_interfaces/metric/charts/enum.ts b/packages/server-shared/src/metrics/charts/enum.ts similarity index 100% rename from apps/web/src/api/asset_interfaces/metric/charts/enum.ts rename to packages/server-shared/src/metrics/charts/enum.ts diff --git a/apps/web/src/api/asset_interfaces/metric/charts/etcInterfaces.ts b/packages/server-shared/src/metrics/charts/etcInterfaces.ts similarity index 100% rename from apps/web/src/api/asset_interfaces/metric/charts/etcInterfaces.ts rename to packages/server-shared/src/metrics/charts/etcInterfaces.ts diff --git a/packages/server-shared/src/metric/charts/index.ts b/packages/server-shared/src/metrics/charts/index.ts similarity index 89% rename from packages/server-shared/src/metric/charts/index.ts rename to packages/server-shared/src/metrics/charts/index.ts index 5cf584ee7..15b4bfb89 100644 --- a/packages/server-shared/src/metric/charts/index.ts +++ b/packages/server-shared/src/metrics/charts/index.ts @@ -7,3 +7,4 @@ export * from './columnLabelInterfaces'; export * from './enum'; export * from './etcInterfaces'; export * from './tickInterfaces'; +export * from './chatConfig.defaults'; diff --git a/apps/web/src/api/asset_interfaces/metric/charts/lineChartProps.test.ts b/packages/server-shared/src/metrics/charts/lineChartProps.test.ts similarity index 100% rename from apps/web/src/api/asset_interfaces/metric/charts/lineChartProps.test.ts rename to packages/server-shared/src/metrics/charts/lineChartProps.test.ts diff --git a/apps/web/src/api/asset_interfaces/metric/charts/lineChartProps.ts b/packages/server-shared/src/metrics/charts/lineChartProps.ts similarity index 100% rename from apps/web/src/api/asset_interfaces/metric/charts/lineChartProps.ts rename to packages/server-shared/src/metrics/charts/lineChartProps.ts diff --git a/apps/web/src/api/asset_interfaces/metric/charts/metricChartProps.ts b/packages/server-shared/src/metrics/charts/metricChartProps.ts similarity index 100% rename from apps/web/src/api/asset_interfaces/metric/charts/metricChartProps.ts rename to packages/server-shared/src/metrics/charts/metricChartProps.ts diff --git a/packages/server-shared/src/metric/charts/pieChartProps.ts b/packages/server-shared/src/metrics/charts/pieChartProps.ts similarity index 56% rename from packages/server-shared/src/metric/charts/pieChartProps.ts rename to packages/server-shared/src/metrics/charts/pieChartProps.ts index 856f6e9f1..9116dff2c 100644 --- a/packages/server-shared/src/metric/charts/pieChartProps.ts +++ b/packages/server-shared/src/metrics/charts/pieChartProps.ts @@ -1,6 +1,6 @@ -import { z } from 'zod/v4'; -import { PieChartAxisSchema } from './axisInterfaces'; -import { PieSortBySchema } from './etcInterfaces'; +import { z } from "zod/v4"; +import { PieChartAxisSchema } from "./axisInterfaces"; +import { PieSortBySchema } from "./etcInterfaces"; export const PieChartPropsSchema = z.object({ // OPTIONAL: default: value @@ -8,29 +8,31 @@ export const PieChartPropsSchema = z.object({ // Required for Pie pieChartAxis: PieChartAxisSchema, // OPTIONAL: default: number - pieDisplayLabelAs: z.enum(['percent', 'number']).default('number'), + pieDisplayLabelAs: z.enum(["percent", "number"]).default("number"), // OPTIONAL: default true if donut width is set. If the data contains a percentage, set this as false. pieShowInnerLabel: z.boolean().default(true), // OPTIONAL: default: sum pieInnerLabelAggregate: z - .enum(['sum', 'average', 'median', 'max', 'min', 'count']) - .default('sum'), + .enum(["sum", "average", "median", "max", "min", "count"]) + .default("sum"), // OPTIONAL: default is null and will be the name of the pieInnerLabelAggregate - pieInnerLabelTitle: z.string().optional(), - // OPTIONAL: default: outside - pieLabelPosition: z.nullable(z.enum(['inside', 'outside', 'none'])).default(null), + pieInnerLabelTitle: z.string().nullable().default(null), + // OPTIONAL: default: none + pieLabelPosition: z + .nullable(z.enum(["inside", "outside", "none"])) + .default("none"), // OPTIONAL: default: 55 | range 0-65 | range represents percent size of the donut hole. If user asks for a pie this should be 0 pieDonutWidth: z .number() - .min(0, 'Donut width must be at least 0') - .max(65, 'Donut width must be at most 65') + .min(0, "Donut width must be at least 0") + .max(65, "Donut width must be at most 65") .default(40), // OPTIONAL: default: 2.5 | range 0-100 | If there are items that are less than this percentage of the pie, they combine to form a single slice. pieMinimumSlicePercentage: z .number() - .min(0, 'Minimum slice percentage must be at least 0') - .max(100, 'Minimum slice percentage must be at most 100') - .default(0) + .min(0, "Minimum slice percentage must be at least 0") + .max(100, "Minimum slice percentage must be at most 100") + .default(0), }); export type PieChartProps = z.infer; diff --git a/apps/web/src/api/asset_interfaces/metric/charts/scatterChartProps.ts b/packages/server-shared/src/metrics/charts/scatterChartProps.ts similarity index 100% rename from apps/web/src/api/asset_interfaces/metric/charts/scatterChartProps.ts rename to packages/server-shared/src/metrics/charts/scatterChartProps.ts diff --git a/apps/web/src/api/asset_interfaces/metric/charts/tableChartProps.ts b/packages/server-shared/src/metrics/charts/tableChartProps.ts similarity index 100% rename from apps/web/src/api/asset_interfaces/metric/charts/tableChartProps.ts rename to packages/server-shared/src/metrics/charts/tableChartProps.ts diff --git a/packages/server-shared/src/metric/charts/tickInterfaces.ts b/packages/server-shared/src/metrics/charts/tickInterfaces.ts similarity index 92% rename from packages/server-shared/src/metric/charts/tickInterfaces.ts rename to packages/server-shared/src/metrics/charts/tickInterfaces.ts index cb10f4e1b..9bd30473b 100644 --- a/packages/server-shared/src/metric/charts/tickInterfaces.ts +++ b/packages/server-shared/src/metrics/charts/tickInterfaces.ts @@ -13,7 +13,7 @@ export const YAxisConfigSchema = z.object({ // Whether to start the axis at zero. Defaults to null. yAxisStartAxisAtZero: z.nullable(z.boolean()).default(null), // The scale type for the Y-axis. @default "linear" - yAxisScaleType: z.enum(['log', 'linear']).default('linear') + yAxisScaleType: z.enum(['log', 'linear']).default('linear'), }); //The y2 (or right axis) Y-axis is used for secondary Y-axes in a combo chart. @@ -30,7 +30,7 @@ export const Y2AxisConfigSchema = z.object({ // Whether to start the axis at zero. Defaults to true. y2AxisStartAxisAtZero: z.boolean().default(true), // The scale type for the secondary Y-axis. @default "linear" - y2AxisScaleType: z.enum(['log', 'linear']).default('linear') + y2AxisScaleType: z.enum(['log', 'linear']).default('linear'), }); /** @@ -50,7 +50,7 @@ export const XAxisConfigSchema = z.object({ .union([z.literal(0), z.literal(45), z.literal(90), z.literal('auto')]) .default('auto'), // Whether to enable data zooming on the X-axis. Should only be set to true by the user. @default false - xAxisDataZoom: z.boolean().default(false) + xAxisDataZoom: z.boolean().default(false), }); //The category axis works differently than the other axes. It is used to color and group the data. @@ -60,7 +60,7 @@ export const XAxisConfigSchema = z.object({ */ export const CategoryAxisStyleConfigSchema = z.object({ // The title of the category axis. @default null - categoryAxisTitle: z.nullable(z.string()).default(null) + categoryAxisTitle: z.nullable(z.string()).default(null), }); // Export inferred types diff --git a/packages/server-shared/src/metric/index.ts b/packages/server-shared/src/metrics/index.ts similarity index 70% rename from packages/server-shared/src/metric/index.ts rename to packages/server-shared/src/metrics/index.ts index b251b32df..3eb3420e8 100644 --- a/packages/server-shared/src/metric/index.ts +++ b/packages/server-shared/src/metrics/index.ts @@ -1,3 +1,4 @@ export * from './metric.types'; export * from './metadata.type'; export * from './charts'; +export * from './metrics-list.types'; diff --git a/packages/server-shared/src/metric/metadata.type.ts b/packages/server-shared/src/metrics/metadata.type.ts similarity index 83% rename from packages/server-shared/src/metric/metadata.type.ts rename to packages/server-shared/src/metrics/metadata.type.ts index de89a043d..34dcd58af 100644 --- a/packages/server-shared/src/metric/metadata.type.ts +++ b/packages/server-shared/src/metrics/metadata.type.ts @@ -1,4 +1,4 @@ -import { z } from 'zod'; +import { z } from 'zod/v4'; export const ColumnMetaDataSchema = z.object({ name: z.string(), @@ -47,5 +47,10 @@ export const DataMetadataSchema = z }) .nullable(); +export const DataResultSchema = z.array( + z.record(z.string(), z.union([z.number(), z.string(), z.null()])) +); + +export type DataResult = z.infer; export type ColumnMetaData = z.infer; export type DataMetadata = z.infer; diff --git a/packages/server-shared/src/metric/metric.types.ts b/packages/server-shared/src/metrics/metric.types.ts similarity index 86% rename from packages/server-shared/src/metric/metric.types.ts rename to packages/server-shared/src/metrics/metric.types.ts index cadc8f508..3375b39d0 100644 --- a/packages/server-shared/src/metric/metric.types.ts +++ b/packages/server-shared/src/metrics/metric.types.ts @@ -1,11 +1,9 @@ -import { z } from 'zod'; +import { z } from 'zod/v4'; import { ShareConfigSchema, VerificationStatusSchema } from '../share'; -import { type ChartConfigProps, ChartConfigPropsSchema } from './charts'; +import { ChartConfigPropsSchema } from './charts'; import { DEFAULT_CHART_CONFIG } from './charts/chatConfig.defaults'; import { DataMetadataSchema } from './metadata.type'; -ChartConfigPropsSchema.optional(); - export const MetricSchema = z.object({ id: z.string(), type: z.literal('metric'), @@ -18,7 +16,7 @@ export const MetricSchema = z.object({ data_source_id: z.string(), dataset_name: z.string().nullable(), error: z.string().nullable(), - chart_config: z.custom().default(DEFAULT_CHART_CONFIG), + chart_config: ChartConfigPropsSchema.default(DEFAULT_CHART_CONFIG), data_metadata: DataMetadataSchema, status: VerificationStatusSchema, evaluation_score: z.enum(['Moderate', 'High', 'Low']), diff --git a/packages/server-shared/src/metrics/metrics-list.types.ts b/packages/server-shared/src/metrics/metrics-list.types.ts new file mode 100644 index 000000000..2166728c8 --- /dev/null +++ b/packages/server-shared/src/metrics/metrics-list.types.ts @@ -0,0 +1,18 @@ +import { z } from 'zod/v4'; +import { VerificationStatusSchema } from '../share'; + +export const MetricListItemSchema = z.object({ + id: z.string(), + name: z.string(), + last_edited: z.string(), + dataset_name: z.string(), + dataset_uuid: z.string(), + created_by_id: z.string(), + created_by_name: z.string(), + created_by_email: z.string(), + created_by_avatar: z.string(), + status: VerificationStatusSchema, + is_shared: z.boolean(), +}); + +export type MetricListItem = z.infer; diff --git a/packages/server-shared/src/share/shareInterfaces.ts b/packages/server-shared/src/share/shareInterfaces.ts index 5dfdfd67d..15e9eee25 100644 --- a/packages/server-shared/src/share/shareInterfaces.ts +++ b/packages/server-shared/src/share/shareInterfaces.ts @@ -1,4 +1,4 @@ -import { z } from 'zod'; +import { z } from 'zod/v4'; export const ShareRoleSchema = z.enum([ 'owner', //owner of the asset diff --git a/packages/server-shared/src/share/verificationInterfaces.ts b/packages/server-shared/src/share/verificationInterfaces.ts index 249e7ad87..851d2993d 100644 --- a/packages/server-shared/src/share/verificationInterfaces.ts +++ b/packages/server-shared/src/share/verificationInterfaces.ts @@ -1,4 +1,4 @@ -import { z } from 'zod'; +import { z } from 'zod/v4'; export const VerificationStatusSchema = z.enum([ 'notRequested',