mirror of https://github.com/buster-so/buster.git
Move default to individual packages
This commit is contained in:
parent
847ea87dde
commit
043d2654b0
|
@ -15,9 +15,10 @@ export const useUserConfigProvider = () => {
|
|||
const userOrganizations = userResponse?.organizations?.[0];
|
||||
const userRole = userOrganizations?.role;
|
||||
const isUserRegistered =
|
||||
!!userResponse && !!userResponse?.organizations?.[0]?.id && !!userResponse?.user?.name;
|
||||
//&&
|
||||
// !isAnonymousUser;
|
||||
!!userResponse &&
|
||||
!!userResponse?.organizations?.[0]?.id &&
|
||||
!!userResponse?.user?.name &&
|
||||
!isAnonymousUser;
|
||||
|
||||
const isAdmin = checkIfUserIsAdmin(userResponse);
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { z } from 'zod/v4';
|
||||
import { getDefaults } from '../defaultHelpers';
|
||||
|
||||
// Goal line is a line that is drawn on the chart to represent a goal.
|
||||
export const GoalLineSchema = z.object({
|
||||
|
@ -11,7 +12,7 @@ export const GoalLineSchema = z.object({
|
|||
// 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')
|
||||
goalLineColor: z.nullable(z.string()).default('#000000'),
|
||||
});
|
||||
|
||||
export const TrendlineSchema = z.object({
|
||||
|
@ -31,7 +32,7 @@ export const TrendlineSchema = z.object({
|
|||
'polynomial_regression',
|
||||
'min',
|
||||
'max',
|
||||
'median'
|
||||
'median',
|
||||
])
|
||||
.default('linear_regression'),
|
||||
// OPTIONAL: default is #000000, inherit will inherit the color from the line/bar
|
||||
|
@ -47,9 +48,11 @@ export const TrendlineSchema = z.object({
|
|||
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()
|
||||
id: z.string(),
|
||||
});
|
||||
|
||||
export const DEFAULT_TRENDLINE_CONFIG: Required<Trendline> = getDefaults(TrendlineSchema);
|
||||
|
||||
// Export inferred types
|
||||
export type GoalLine = z.infer<typeof GoalLineSchema>;
|
||||
export type Trendline = z.infer<typeof TrendlineSchema>;
|
||||
|
|
|
@ -1,26 +1,24 @@
|
|||
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 { z } from 'zod/v4';
|
||||
import { getDefaults } from '../defaultHelpers';
|
||||
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,
|
||||
|
@ -56,6 +54,10 @@ export const ChartConfigPropsSchema = z.object({
|
|||
...MetricChartPropsSchema.shape,
|
||||
});
|
||||
|
||||
export const DEFAULT_CHART_CONFIG: ChartConfigProps = getDefaults(ChartConfigPropsSchema);
|
||||
|
||||
export const DEFAULT_CHART_CONFIG_ENTRIES = Object.entries(DEFAULT_CHART_CONFIG);
|
||||
|
||||
// Re-export schemas for backward compatibility
|
||||
export {
|
||||
BarChartPropsSchema,
|
||||
|
|
|
@ -1,18 +1,7 @@
|
|||
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 DEFAULT_BAR_ROUNDNESS = 8;
|
||||
export const MIN_DONUT_WIDTH = 15;
|
||||
|
||||
export const DEFAULT_DAY_OF_WEEK_FORMAT = 'ddd';
|
||||
|
@ -22,6 +11,3 @@ 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<Trendline> = getDefaults(TrendlineSchema);
|
||||
export const DEFAULT_METRIC: Required<Metric> = getDefaults(MetricSchema);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { z } from 'zod/v4';
|
||||
import { getDefaults } from '../defaultHelpers';
|
||||
|
||||
export const LineColumnSettingsSchema = z.object({
|
||||
// OPTIONAL: default is 2. This will only apply if the columnVisualization is set to 'line'.
|
||||
|
@ -16,7 +17,7 @@ export const LineColumnSettingsSchema = z.object({
|
|||
.number()
|
||||
.min(0, 'Line symbol size must be at least 0')
|
||||
.max(10, 'Line symbol size must be at most 10')
|
||||
.default(0)
|
||||
.default(0),
|
||||
});
|
||||
|
||||
export const BarColumnSettingsSchema = z.object({
|
||||
|
@ -25,7 +26,7 @@ export const BarColumnSettingsSchema = z.object({
|
|||
.number()
|
||||
.min(0, 'Bar roundness must be at least 0')
|
||||
.max(50, 'Bar roundness must be at most 50')
|
||||
.default(8)
|
||||
.default(8),
|
||||
});
|
||||
|
||||
export const DotColumnSettingsSchema = z.object({
|
||||
|
@ -34,7 +35,7 @@ export const DotColumnSettingsSchema = z.object({
|
|||
.number()
|
||||
.min(1, 'Dot symbol size must be at least 1')
|
||||
.max(50, 'Dot symbol size must be at most 50')
|
||||
.default(10)
|
||||
.default(10),
|
||||
});
|
||||
|
||||
export const ColumnSettingsSchema = z.object({
|
||||
|
@ -67,9 +68,11 @@ export const ColumnSettingsSchema = z.object({
|
|||
.number()
|
||||
.min(0, 'Bar roundness must be at least 0')
|
||||
.max(50, 'Bar roundness must be at most 50')
|
||||
.default(8)
|
||||
.default(8),
|
||||
});
|
||||
|
||||
export const DEFAULT_COLUMN_SETTINGS: ColumnSettings = getDefaults(ColumnSettingsSchema);
|
||||
|
||||
// Export inferred types
|
||||
export type LineColumnSettings = z.infer<typeof LineColumnSettingsSchema>;
|
||||
export type BarColumnSettings = z.infer<typeof BarColumnSettingsSchema>;
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
import { z } from "zod/v4";
|
||||
import { z } from 'zod/v4';
|
||||
import { getDefaults } from '../defaultHelpers';
|
||||
|
||||
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"),
|
||||
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()).default(""),
|
||||
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(","))).default(","),
|
||||
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")
|
||||
z.gte(0, 'Minimum fraction digits must be at least 0'),
|
||||
z.lte(20, 'Minimum fraction digits must be at most 20')
|
||||
)
|
||||
)
|
||||
.default(0),
|
||||
|
@ -27,8 +26,8 @@ export const ColumnLabelFormatSchema = z.object({
|
|||
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")
|
||||
z.gte(0, 'Maximum fraction digits must be at least 0'),
|
||||
z.lte(20, 'Maximum fraction digits must be at most 20')
|
||||
)
|
||||
)
|
||||
.default(2),
|
||||
|
@ -38,19 +37,17 @@ export const ColumnLabelFormatSchema = z.object({
|
|||
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")
|
||||
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()).default(""),
|
||||
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()).default(""),
|
||||
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()]))
|
||||
.default(0),
|
||||
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),
|
||||
|
@ -58,19 +55,17 @@ export const ColumnLabelFormatSchema = z.object({
|
|||
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()).default("USD"),
|
||||
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()]))
|
||||
.default("auto"),
|
||||
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"]))
|
||||
)
|
||||
.optional(z.nullable(z.enum(['day_of_week', 'month_of_year', 'quarter', 'number'])))
|
||||
.default(null),
|
||||
});
|
||||
|
||||
export const DEFAULT_COLUMN_LABEL_FORMAT: ColumnLabelFormat = getDefaults(ColumnLabelFormatSchema);
|
||||
|
||||
// Export inferred types
|
||||
export type ColumnLabelFormat = z.infer<typeof ColumnLabelFormatSchema>;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { z } from 'zod/v4';
|
||||
import { ShareConfigSchema, VerificationStatusSchema } from '../share';
|
||||
import { ChartConfigPropsSchema } from './charts';
|
||||
import { DEFAULT_CHART_CONFIG } from './charts/chatConfig.defaults';
|
||||
import { DEFAULT_CHART_CONFIG } from './charts/chartConfigProps';
|
||||
import { getDefaults } from './defaultHelpers';
|
||||
import { DataMetadataSchema } from './metadata.type';
|
||||
|
||||
export const MetricSchema = z.object({
|
||||
|
@ -50,3 +51,5 @@ export const MetricSchema = z.object({
|
|||
});
|
||||
|
||||
export type Metric = z.infer<typeof MetricSchema>;
|
||||
|
||||
export const DEFAULT_METRIC: Required<Metric> = getDefaults(MetricSchema);
|
||||
|
|
Loading…
Reference in New Issue