Baptiste Devessier
2025-12-10 10:31:36 +01:00
committed by GitHub
parent 7b98804ec1
commit fd54a2af5c
55 changed files with 774 additions and 110 deletions
@@ -0,0 +1,25 @@
import { type PageLayoutWidget } from '@/page-layout/types/PageLayoutWidget';
import { assertIsDefinedOrThrow } from 'twenty-shared/utils';
import { type PieChartConfiguration } from '~/generated/graphql';
type AssertPieChartWidgetOrThrow = (
widget: PageLayoutWidget,
) => asserts widget is PageLayoutWidget & {
objectMetadataId: string;
configuration: PieChartConfiguration;
};
export const assertPieChartWidgetOrThrow: AssertPieChartWidgetOrThrow = (
widget: PageLayoutWidget,
) => {
assertIsDefinedOrThrow(
widget.objectMetadataId,
new Error('Widget objectMetadataId is required'),
);
if (widget.configuration?.__typename !== 'PieChartConfiguration') {
throw new Error(
`Expected PieChartConfiguration but got ${widget.configuration?.__typename}`,
);
}
};