From 7f7739735dd2b3bf58b43e2ddfd063ab200cd62f Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 03:32:56 +0000 Subject: [PATCH 1/2] wip(types): refuse series measureFormat by name Claude-Session: https://claude.ai/code/session_01L9qibvWkyWZ5TH7f1iwUVp Co-authored-by: Claude --- ...art-series-aggregate-refusal-11681.test.ts | 55 +++++++++++++++++++ ui/packages/types/src/data-display.ts | 14 +++++ ui/packages/types/src/zod/data-display.zod.ts | 15 +++++ 3 files changed, 84 insertions(+) diff --git a/ui/packages/types/src/__tests__/chart-series-aggregate-refusal-11681.test.ts b/ui/packages/types/src/__tests__/chart-series-aggregate-refusal-11681.test.ts index 31b8a8299fc..0503e84e6f3 100644 --- a/ui/packages/types/src/__tests__/chart-series-aggregate-refusal-11681.test.ts +++ b/ui/packages/types/src/__tests__/chart-series-aggregate-refusal-11681.test.ts @@ -75,3 +75,58 @@ describe('objectui#11681 — the two faces agree: `aggregate` is unwritable on b expect(authored.name).toBe('task_count'); }); }); + +/** + * `measureFormat` on a chart series is renderer-internal too, and refused by + * name in the same posture as `aggregate`: the report and dashboard producers + * fill `{ format, currency, percentScale }` from the dataset answer, and an + * authored carrier on a static chart node would be kept by this NON-STRICT + * object and honoured by the renderer. + */ +describe('an authored series `measureFormat` is refused by name', () => { + const CARRIERS = [ + { format: '0.0%', percentScale: 'whole' }, + { format: '0,0.00', currency: 'CNY' }, + {}, + ]; + + it.each(CARRIERS)('`measureFormat: %j` refuses with one `invalid_type` issue at `measureFormat`, naming the key', (carrier) => { + const issues = issuesOf(ChartDataSeriesSchema, { name: 'amount', measureFormat: carrier }); + expect(issues).toHaveLength(1); + expect(issues![0]).toMatchObject({ code: 'invalid_type', path: 'measureFormat' }); + expect(issues![0].message).toContain('`measureFormat`'); + }); + + it('the chart node carries the refusal to its series path', () => { + expect(issuesOf(ChartSchema, NODE), 'the control node must parse, or the refusal below measures nothing').toBeNull(); + const issues = issuesOf(ChartSchema, { ...NODE, series: [{ name: 'task_count', measureFormat: CARRIERS[0] }] }); + expect(issues?.map((i) => i.path)).toEqual(['series.0.measureFormat']); + }); + + it('a series that authors both internal keys is refused at both, so the `aggregate` refusal stays', () => { + const issues = issuesOf(ChartSchema, { + ...NODE, + series: [{ name: 'task_count', aggregate: 'count', measureFormat: CARRIERS[1] }], + }); + expect(issues?.map((i) => i.path).sort()).toEqual(['series.0.aggregate', 'series.0.measureFormat']); + }); + + it('CONTROL — the authored channel for the axis units, `yAxis[].format`, still parses', () => { + expect(issuesOf(ChartSchema, { ...NODE, yAxis: [{ field: 'task_count', format: '0.0%' }] })).toBeNull(); + }); +}); + +describe('the two faces agree: `measureFormat` is unwritable on both', () => { + it('the zod arm\'s input type is exactly `undefined`, and the TS twin declares `never`', () => { + type ArmInput = z.input['measureFormat']; + const zodArmIsUndefined: Eq = true; + const tsTwinIsNever: Eq = true; + expect(zodArmIsUndefined && tsTwinIsNever).toBe(true); + }); + + it('a typed literal refuses it at the authoring site', () => { + // @ts-expect-error — `measureFormat` is `?: never` on the authoring face. + const authored: ChartDataSeries = { name: 'amount', measureFormat: { format: '0,0.00', currency: 'CNY' } }; + expect(authored.name).toBe('amount'); + }); +}); diff --git a/ui/packages/types/src/data-display.ts b/ui/packages/types/src/data-display.ts index b94af71c990..e158b5c7118 100644 --- a/ui/packages/types/src/data-display.ts +++ b/ui/packages/types/src/data-display.ts @@ -2555,6 +2555,20 @@ export interface ChartDataSeries { * site. Declare the aggregate on the dataset measure instead. */ aggregate?: never; + /** + * NOT A KEY OF THIS SERIES — refused by name, beside {@link aggregate}. + * + * `measureFormat` is the renderer-internal carrier of a dataset measure's + * display facts (`{ format, currency, percentScale }`): the report and + * dashboard producers fill it from the dataset answer's field, and a value + * axis whose series share one prints its ticks in the measure's units. A + * hand-written carrier could contradict the dataset's own facts, so + * `ChartDataSeriesSchema.measureFormat` refuses it by name and this + * `?: never` is a `tsc` error at the authoring site. Write the value axis' + * `format` on the chart (`yAxis: [{ field, format }]`) instead; it takes precedence + * over the carrier. + */ + measureFormat?: never; } /** diff --git a/ui/packages/types/src/zod/data-display.zod.ts b/ui/packages/types/src/zod/data-display.zod.ts index 67be4880e6a..64388266c9f 100644 --- a/ui/packages/types/src/zod/data-display.zod.ts +++ b/ui/packages/types/src/zod/data-display.zod.ts @@ -868,6 +868,21 @@ export const ChartDataSeriesSchema = z.looseObject({ + 'axis ticks for a count. It is not authored: declare the aggregate on the dataset measure, ' + 'and the chart takes it from there. Delete the key.', ), + // INTERNAL-ONLY REFUSAL, the `aggregate` posture. `measureFormat` is the + // renderer-internal carrier of a dataset measure's display facts + // (`{ format, currency, percentScale }`): the report and dashboard producers + // fill it from the dataset answer's field, and a value axis whose series share + // one prints its ticks in the measure's units. Nothing on this face may write + // it — a hand-written carrier can contradict the dataset's own facts — and this + // object is NON-STRICT, so an undeclared key would be kept and handed to the + // renderer. Declared and unwritable, it is refused by name instead. + measureFormat: retirementTombstone( + 'REFUSED — `measureFormat` is the renderer\'s INTERNAL carrier of a dataset measure\'s display ' + + 'facts (`format`, `currency`, `percentScale`), which a report or dashboard chart fills from the ' + + 'dataset answer so its value axis prints in the measure\'s units. It is not authored: to format ' + + 'this chart\'s value axis, write the axis `format` (`yAxis: [{ field: \'total\', format: \'$0,0\' }]`), which ' + + 'takes precedence over the carrier anyway. Delete the key.', + ), // THE SIX KEYS THE RENDERER READS (objectui#7546). Each was undeclared, and // because this object is NON-STRICT the mirror STRIPPED it in silence while // `safeParse` reported success — the card's own measurement: From 58dedb3e8b9fb41ce2b07914c93e6d4503f0134c Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 03:38:46 +0000 Subject: [PATCH 2/2] feat(types)!: ledger entry and changeset for the series measureFormat refusal Claude-Session: https://claude.ai/code/session_01L9qibvWkyWZ5TH7f1iwUVp Co-authored-by: Claude --- ...214-chart-series-measure-format-refused.md | 21 ++++++++++++++ ...t-series-measure-format-carrier-refused.ts | 28 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .changeset/37214-chart-series-measure-format-refused.md create mode 100644 packages/spec/src/migrations/entries/semantic/19.chart-series-measure-format-carrier-refused.ts diff --git a/.changeset/37214-chart-series-measure-format-refused.md b/.changeset/37214-chart-series-measure-format-refused.md new file mode 100644 index 00000000000..10680ed3978 --- /dev/null +++ b/.changeset/37214-chart-series-measure-format-refused.md @@ -0,0 +1,21 @@ +--- +'@object-ui/types': minor +'@objectstack/spec': minor +--- + +feat(types)!: a static chart node's series refuses the renderer-internal `measureFormat` carrier by name + +Clause-②: yes (narrowing) +Metadata-protocol: narrowed + + + +**BREAKING** accept-set narrowing on the static SDUI `chart` node: `ChartDataSeriesSchema` refuses `series[].measureFormat`, and the `ChartDataSeries` TS twin types it `?: never`. + +`measureFormat` (`{ format, currency, percentScale }`) is the chart renderer's internal carrier of a dataset measure's display facts. The report and dashboard chart producers fill it from the dataset answer so a value axis prints the measure's units; it is not meant to be authored. Until now the non-strict series schema refused only its sibling `aggregate` by name, so a hand-written `measureFormat` on a static chart node was kept and honoured, and could claim a currency or a percent scale the data does not have. + +| FROM | TO | +|:--|:--| +| `{ type: 'chart', series: [{ name: 'amount', measureFormat: { format: '0,0.00', currency: 'CNY' } }] }` | delete `measureFormat`; to print the value axis in a unit, write the axis `format` on the chart: `yAxis: [{ field: 'amount', format: '$0,0' }]` | + +The one-line fix: delete `measureFormat` from every authored chart series. The parse now refuses it with one issue at `series.N.measureFormat` naming the key (a series that also writes `aggregate` is refused at both), and a typed `ChartDataSeries` literal that writes it fails `tsc`. Report and dashboard charts are unchanged: their producers keep filling the carrier past this schema. The D3 entry `chart-series-measure-format-carrier-refused` (`@objectstack/spec` migration registry) records the narrowing; there is no D2 conversion, because the carrier has no authored equivalent to rewrite into. diff --git a/packages/spec/src/migrations/entries/semantic/19.chart-series-measure-format-carrier-refused.ts b/packages/spec/src/migrations/entries/semantic/19.chart-series-measure-format-carrier-refused.ts new file mode 100644 index 00000000000..8369ffba01d --- /dev/null +++ b/packages/spec/src/migrations/entries/semantic/19.chart-series-measure-format-carrier-refused.ts @@ -0,0 +1,28 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import type { SemanticMigration } from '../../types.js'; + +// The static chart node's series refuses the renderer-internal `measureFormat` +// carrier by name, in the posture its `aggregate` sibling already has. A D3 +// entry with no D2 conversion: the carrier has no authored equivalent to +// rewrite into, because what it carries is the dataset's own fact. +export const entry: SemanticMigration = { + id: 'chart-series-measure-format-carrier-refused', + surface: 'static SDUI `chart` node series — `series[].measureFormat` (`{ format, currency, percentScale }`) ' + + 'on `@object-ui/types` `ChartDataSeriesSchema` and its TS twin `ChartDataSeries`', + replacement: 'Delete the key. To print a static chart\'s value axis in a unit, write the axis `format` on the ' + + 'chart (`yAxis: [{ field: \'amount\', format: \'$0,0\' }]`), which takes precedence over the carrier. A ' + + 'report or dashboard chart bound to a dataset needs nothing: its producer fills the carrier from the ' + + 'measure the chart plots.', + reason: 'The report and dashboard chart producers hand the chart renderer each series\' `measureFormat`, ' + + 'copied from the dataset answer\'s field, so a value axis over a dataset measure prints the measure\'s ' + + 'units. The key is internal by declaration, but the static chart node\'s series schema is non-strict and ' + + 'refused only `aggregate` by name, so a hand-written `measureFormat` was kept and honoured: an author, or ' + + 'an AI writing page metadata, could claim a currency or a percent scale the data does not have. It is ' + + 'now a `never` key on both faces: the zod mirror refuses it at `series.N.measureFormat`, and a typed ' + + 'literal fails `tsc`.', + acceptanceCriteria: 'No static `chart` node carries `measureFormat` on a series; the parse refuses it with one ' + + 'issue at `series.N.measureFormat` naming the key, and a series that also writes `aggregate` is refused ' + + 'at both keys. A chart whose axis must print a unit declares `yAxis[].format`. Report and dashboard ' + + 'charts keep their axis units unchanged, because their producers fill the carrier past this schema.', +};