feat(sdk): validate graph page-layout widgets at build time (#22559)

When an app defines a graph widget (aggregate, pie, bar or line chart),
the built manifest can carry the wrong key and the server rejects it at
sync time with a confusing "aggregate field is required" error.

The SDK type already requires
`aggregateFieldMetadataUniversalIdentifier` and renames the raw
`aggregateFieldMetadataId` at compile time. But the manifest build runs
esbuild with no type checking, so a wrong or missing key slips through
and only fails later on the server.

This adds a build-time check that mirrors the server validator, with a
hint pointing at the right key when the raw one was used. It is
non-breaking since correctly authored apps already use the universal
key.

Tests: unit tests on the validator, plus a real graph widget added to
the rich-app fixture so the integration and e2e suites cover the happy
path.
This commit is contained in:
Charles Bochet
2026-07-08 16:25:47 +02:00
committed by GitHub
parent ad74f75e6a
commit d746909184
6 changed files with 223 additions and 3 deletions
@@ -181,6 +181,8 @@ export type {
ChartFilter,
UniversalChartFilter,
} from './page-layout/chart-filter.type';
export type { GraphWidgetConfigurationType } from './page-layout/graph-widget-configuration-type';
export { GRAPH_WIDGET_CONFIGURATION_TYPES } from './page-layout/graph-widget-configuration-type';
export type { GridPosition } from './page-layout/grid-position.type';
export type {
AggregateChartConfiguration,
@@ -0,0 +1,11 @@
import { type PageLayoutWidgetConfiguration } from './page-layout-widget-configuration.type';
export const GRAPH_WIDGET_CONFIGURATION_TYPES = [
'AGGREGATE_CHART',
'PIE_CHART',
'BAR_CHART',
'LINE_CHART',
] as const satisfies readonly PageLayoutWidgetConfiguration['configurationType'][];
export type GraphWidgetConfigurationType =
(typeof GRAPH_WIDGET_CONFIGURATION_TYPES)[number];