Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit 0c95d3d

Browse files
feat(types): four zod mirrors declare members their TypeScript twins declared, and pagination retires page (objectui#6152, round 3) (#11229)
Refs #6152 Clause-②: yes (narrowing). The diff widens and narrows at once. A declared-but-unmirrored key gains its mirror, so `@object-ui/types/zod` accepts what the TypeScript face already invited. `page` → `currentPage` retires one spelling (refused at the key on both faces, which is the narrowing) under the startup no-gradualism rule, and is priced in the changeset. Arm corrected from `(widening)` per the contract record `5914849079`. Round 3 of objectui#6152, dispatched under claim `5912572626` (the `domain:devx` seat 2, session `session_01TdiauJaVCHuj45EzZGUxHh`, on the maintainer's direct order). ⛔ Draft for the director seat's contract review. Do not mark it ready, and do not enable auto-merge. The card stays open: `ObjectGridSchema` and the spec-derived pairs are not this round's. ## What changed 1. **Ruling (a): `ObjectFormSchema.open` and `submitHandler` go to `RuntimeOnlyDeclared` by NAME.** The shape pin widens from the `on*` spelling to that spelling plus a new `RuntimeOnlyNamedAllowList`, one row per key, each row carrying its reason as a string-literal type. Three pins hold the list: a non-callback key without a row is red, a row whose key has left the ledger (or that names a callback) is red, and a row without a reason is red. Each pin also has a synthetic recognition case. The comparison is unchanged: `assertionUnmirroredMatchesLedger` still reconciles one measurement against the union of both ledgers. Neither key is mirrored, and neither declaration moved. 2. **Ruling (b): `PaginationSchema.currentPage` is mirrored, and `page` retires at once.** `page` becomes `?: never` on the interface and `retirementTombstone()` on the mirror, whose message says to rename it to `currentPage`. The `pagination` renderer drops its `page` fallback. 3. **Mirrored, each key measured READ first:** all eight `FormSchema` layout keys, `ReportComponentSchema.conditionalFormatting`, and six `DetailViewSchema` configuration keys. The nested entries (`fieldTabs`, `fieldPanes`, `sectionGroups`, `highlightFields`, the formatting rules) use module-private schemas that restate their TypeScript element types member for member. One exception is stated in its docblock: `sectionGroups[].sections` is `z.array(z.any())`. Binding `DetailViewSectionSchema` there would import that pair's own `KnownDrift` rows as a new drifted key, and growing `KnownDrift` is never the remedy. This is the same exception round 1 took for `sections[].fields`. 4. **Ledger figures are re-derived by the file's own pins.** Two pairs are now runtime-only and nothing else, so the cross-ledger sentence states a difference again. It is now spelled to hold at any difference, and its pin reads all three figures. The containment leg that the objectui#7804 slice added is deleted, not inverted, and the comment next to it says why. 5. **One changeset** (`@object-ui/types` and `@object-ui/components`, both `minor`; the break is spelled out). Also, three dated correction notes are appended to pending changesets that this change made false (see Deviations). ## Ledger totals, before → after (read by the file's own pins, not by hand) | ledger | before (`52bf34824`) | after | | --- | --- | --- | | `UnmirroredDeclared` | 12 entries / 62 keys: 4 / 16 spec-derived, 8 / 46 local | **9 / 44**: 3 / 14 spec-derived, 6 / 30 local | | `RuntimeOnlyDeclared` | 3 / 7 | **4 / 9** | | cross-ledger | 3 of the 3 are in `UnmirroredDeclared`; the union is 12 | 2 of the 4; the union is **11** = 9 + 2 runtime-only-only | | `KnownDrift`, `WiderThanDeclared`, `MirroredUndeclared` | 49 / 87 · 3 / 3 / 3 · unchanged | unchanged | H1 held: 12 / 62 with the 4 / 16 and 8 / 46 split on `main`. One correction to the dispatch: `ObjectGridSchema` carries **11** keys, not 14, because objectui#11068 closed three. ## Per-key table The read census is a type-checker walk over every package's sources. It covers property access, element access, `in`, destructures, and object-literal producers, all resolved to the interface member through root symbols, plus a separate list of untyped (`any`) reads. Its controls fired on every pair (for example `PaginationSchema.totalPages` 1 read, `DetailViewSchema.objectName` 45). The authored census covers 493 tracked JSON files, 352 Markdown JSON fences, and 3118 TS/TSX files that carry a string-literal `type`. | pair · key | read site or producer | action | | --- | --- | --- | | `object-form` · `open` | read by `ObjectForm` (`open: schema.open`, drawer and modal variants); written only by in-code hosts: `AppContent`, `useActionModal`, `ObjectManager`, `FieldDesigner`, the `byo-backend-console` example; 0 documents | `RuntimeOnlyDeclared`, allow-list row + reason | | `object-form` · `submitHandler` | `ObjectForm` calls `await schema.submitHandler(writePayload)`; supplied only by `MasterDetailForm`; 0 documents | `RuntimeOnlyDeclared`, allow-list row + reason | | `pagination` · `currentPage` | pagination renderer (`schema.currentPage`); authored 3 times (two catalog documents, the site playground) | mirrored | | `pagination` · `page` | read only as the fallback limb of `schema.currentPage` or `schema.page`; authored 0 times | retired on both faces; the read is dropped | | `form` · `fieldTabs`, `defaultFieldTab`, `fieldTabsPosition` | `renderers/form/form.tsx` (`schema.fieldTabs`, `schema.defaultFieldTab`, `schema.fieldTabsPosition`) | mirrored | | `form` · `fieldPanes`, `fieldPanesOrientation`, `fieldPanesResizable` | `renderers/form/form.tsx` (`schema.fieldPanes`, `schema.fieldPanesOrientation`, `schema.fieldPanesResizable`) | mirrored | | `form` · `fieldContainerClass`, `mobileStickyActions` | `renderers/form/form.tsx`; also produced by `ObjectForm` when it builds a `form` node | mirrored | | `report` · `conditionalFormatting` | `ReportViewer` evaluates the rules per cell on the report a `report-viewer` node carries | mirrored | | `detail-view` · `primaryField`, `summaryFields`, `autoTabs`, `sectionGroups`, `highlightFields` | `DetailView` (`schema.*`) | mirrored | | `detail-view` · `defaultTab` | `DetailView`, through its own `(schema as any).defaultTab` cast at the one read site | mirrored | **Stays in the ledger, each with its route written on its entry:** | pair · key | measured | route | | --- | --- | --- | | `report` · `chartConfig` | 0 reads, 0 documents | narrowing candidate (objectui#6170 family rule; owes the inertness probe) — reported, not narrowed | | `report` · `reportType` | 0 reads; one in-code producer (the spec-report converter) | narrowing candidate — reported, not narrowed | | `detail-view` · `activities`, `comments`, `history` | read; they carry host-fetched runtime data; 0 documents | the round-1 "class (b)" classification question | | `detail-view` · `recordNavigation` | read; its value carries a REQUIRED callback (`onNavigate`) | needs a ruling; ⛔ a callback is not mirrored | | `detail-view` · `autoDiscoverRelated` | 0 reads (typed or untyped), 0 documents | narrowing candidate — reported, not narrowed | | `label` · `content` | read as the THIRD limb of `text`, `label`, `content`; authored once (a test) | canonical-spelling ruling, ⛔ not a mirror | ## `page` census (pagination nodes only) | | before | after | | --- | --- | --- | | renderer read sites of `page` | 1 (the fallback limb in `renderers/basic/pagination.tsx`) | 0 | | corpus documents authoring `page` | 0 (JSON 0, Markdown fences 0, TS object literals 0) | 0 | | documents authoring `currentPage` (control) | 3 | 3 | So no corpus document needed correcting. The data-table's own `page` key (`DataTableSchema.page`) is a different member and is untouched. ## Verification Heavy runs went through the shared verify lock. Each exit code was captured before any pipe. - **`@object-ui/types`** at the final head `1371bca`: `type-check` (`tsc --noEmit`, `tsconfig.examples.json`, `tsconfig.test.json`) exit 0, no diagnostics; `vitest run packages/types/` gives 290 files / 6941 tests passed. `build` exit 0 ("dist completeness: 1 package(s) complete"). - **Consumers.** This set is derived from what moved. `@object-ui/components` owns the pagination and form renderers and the `page` TypeScript change. `@object-ui/plugin-detail` and `@object-ui/plugin-report` own the readers. `@object-ui/plugin-form` produces two of the form keys. The zod-face validators cover the schema-catalog corpus, app-shell previews and the CLI. Their dependency closure was built first. `type-check` exit 0 for components, plugin-detail, plugin-report and plugin-form. Tests: components 341 files passed + 1 skipped (four shards); plugin-detail 225 + 1 skipped; plugin-report 24; plugin-form 153; `examples/schema-catalog/test/` + app-shell `previews/` 122; `packages/cli/src/__tests__/` 23; `block-config-schema-parity-8216` 15 tests passed. - **Reverse verification.** Each prediction was written before its run. `ablation-replace` did the mutations, and each restore was proven by blob == HEAD and an empty `git diff HEAD`. - A1: the four zod mirrors were restored to base. The new pin file went 53 failed / 6 passed, exactly as predicted. - A2: the allow-list row `open` was renamed. `tsc -p tsconfig.test.json` exit 2 with exactly two TS2344, at `assertionRuntimeOnlyIsCallbackShapedOrNamed` and `assertionNamedAllowListRowsAreFiled`. The comparison stayed green, as predicted: the list is not in the comparison. - A3: `page: 2` was written onto a `PaginationSchema` inside components. Its `tsc --noEmit` exit 2 with one TS2322, so the consumer reads the rebuilt `page?: never`. A first A3 attempt was refused by the tool before any run: the replacement contained the anchor. - **Gates**, all exit 0: `check-changeset-presence`, `check-changeset-no-major`, `check-changeset-fixed`, `check:changeset-claims` (report-only; every named paragraph read, see Deviations), `check:pending-changeset-literals`, `check-changeset-overwrite` (report-only; case 2, frontmatter unchanged), `check:control-bytes`, `check:new-line-citations` (0 new), `check:handler-key-reads`, `check:element-data-source-declaration`, `check:spec-symbols`, `check:test-path-roots`, `check:unreferenced-sources`, `check-type-check-coverage`, and `check-governed-queue-guard --test` (NOT GOVERNED over the 12 paths). - **Lint, narrowed and proven.** `eslint --no-inline-config --format json` ran over the 8 touched TS files; the JSON has 8 entries and none of them is an ignore notice. It found 0 errors. The 3 warnings sit on untouched lines. `eslint.config.js` enables no type-aware linting (empty `parserOptions`), so this diff cannot move a verdict in an untouched file. The repo-wide `pnpm lint` belongs to CI. ## Deviations (declared) The claim's file surface does not name three pending changesets. Commits `b3c93e0` and `3b77588` append a dated **Correction, 2026-09-30** note to each, in the maintainer's append-only shape (numstat `2 0` each; frontmatter and every existing line unchanged): - `.changeset/6152-object-form-unmirrored-members.md` said the routes of `open` and `submitHandler` are open; - `.changeset/6150-undeclared-but-consumed-keys.md` and `.changeset/7804-tree-view-handler-slot.md` said the two unmirrored ledgers are in a containment relation. Each became false with this change. The seat is asked to widen the claim's file surface to these three paths. ## Not this round (the round-4 worklist) - `data-display.zod.ts#DataTableSchema`, 17 keys, cut at the pair boundary by the size guard. Every key is read in `renderers/complex/data-table.tsx` (mostly by destructure), 15 of them are produced by `ObjectGrid`'s in-code `dataTableSchema`, and almost no document authors any of them. So they fall under the round-1 "class (b)" question too. - `complex.zod.ts#ChatbotSchema` and `#ChatbotFloatingSchema`. `displayMode`'s runtime tombstone was deliberately withheld by objectui#7654 (stored designer documents carry it, and `chatbot-display-mode-retired.test.ts` pins that as a tripwire). `floatingConfig` needs a `FloatingChatbotConfig` mirror, with its own tripwire. `requestBody` is read by all three registrations and is mirrorable. - `ObjectGridSchema` (11) and the spec-derived pairs, excluded by the claim. ## Acceptance notes - `examples/schema-catalog/.../components-basic-pagination/with-item-count.json` authors `pageSize` and `totalItems`, which neither face declares and nothing reads. The tolerant face keeps them and the strict face refuses them, measured. It is reported, not changed here. - `.changeset/6639-objectgrid-title-mirrored.md` says what "121" "now means". That went stale before this round, and it is not corrected here. - The `DetailViewSchema` mirror's `onNavigate` docblock calls the nested `recordNavigation.onNavigate` "authorable where it lives". A function is not authorable; this is prose only, and noted. Session: `https://claude.ai/code/session_01TdiauJaVCHuj45EzZGUxHh` --- _Generated by [Claude Code](https://claude.ai/code/session_01TdiauJaVCHuj45EzZGUxHh)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent c021b35 commit 0c95d3d

12 files changed

Lines changed: 753 additions & 100 deletions

‎.changeset/6150-undeclared-but-consumed-keys.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,5 @@ already untrue at that branch's base, and both cards that made it untrue are
102102
closed. It is corrected here, rather than left to objectui#6150's owner, because
103103
this note and theirs publish VERBATIM into the same CHANGELOG — a reader would
104104
have met three paragraphs contradicting each other in one release.
105+
106+
**Correction, 2026-09-30 (objectui#6152, round 3).** The amended `TreeViewSchema` bullet above says `RuntimeOnlyDeclared` is a subset of `UnmirroredDeclared` and that the union of the two equals `UnmirroredDeclared` itself. That was true when the amendment was written, and it no longer is: objectui#6152 round 3 left two pairs, `object-form` and `form`, recorded only as runtime-only. Both ledgers are test instruments in `zod-mirror-parity.test.ts`, and no published surface depends on either relation; the file's header states the current figures and pins them.

‎.changeset/6152-object-form-unmirrored-members.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,5 @@ Two members of the same TypeScript type are deliberately not mirrored:
4444
- `open` is a boolean that only in-code hosts set.
4545

4646
Their routes are open on objectui#6152. No TypeScript declaration changed.
47+
48+
**Correction, 2026-09-30 (objectui#6152, round 3).** The paragraph above says the routes of `open` and `submitHandler` are open on objectui#6152. That was true when this change was written, and it no longer is: round 3 settled both. Each stays declared on the TypeScript type and unmirrored, as a runtime slot a host fills in code, so the published faces do not change for either key: `safeValidateSchema` still keeps an authored value at either key unexamined, and the strict authoring face still refuses both.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
'@object-ui/types': minor
3+
'@object-ui/components': minor
4+
---
5+
6+
feat(types): four zod mirrors declare members their TypeScript twins already declared, and `pagination` retires its `page` spelling (objectui#6152, round 3)
7+
8+
Four node types in `@object-ui/types` declared members that their zod mirrors in
9+
`@object-ui/types/zod` had never heard of. Each member below is read by the node's renderer. The two
10+
published faces answered differently for each one:
11+
12+
- the tolerant validator (`AnyComponentSchema`, `safeValidateSchema`) kept any value at those keys
13+
without examining it, so a wrong-typed value parsed green;
14+
- the strict authoring face (`StrictAnyComponentSchema`) refused the keys outright, although the
15+
published TypeScript type invites them.
16+
17+
The mirrors now declare each member, shaped as the TypeScript type declares it:
18+
19+
- `form`: `fieldTabs`, `defaultFieldTab`, `fieldTabsPosition`, `fieldPanes`,
20+
`fieldPanesOrientation`, `fieldPanesResizable`, `fieldContainerClass`, `mobileStickyActions`. A
21+
tab or pane entry is judged member by member.
22+
- `detail-view`: `primaryField`, `summaryFields`, `autoTabs`, `defaultTab`, `sectionGroups`,
23+
`highlightFields`. A section inside a section group is not judged on that key, which is the
24+
same policy as the `object-form` mirror's section `fields`.
25+
- `report`: `conditionalFormatting`, so a `report-viewer` node's `report` judges its rules too.
26+
- `pagination`: `currentPage`.
27+
28+
What an author sees change:
29+
30+
- **Strict authoring face.** A document using any of these keys is no longer refused for them. The
31+
catalog's basic pagination example, for example, now parses strict.
32+
- **Tolerant face (breaking for invalid documents).** A value of the wrong type at one of these keys
33+
is now refused at the key, where it used to be kept unexamined. Examples are an unknown
34+
`fieldTabsPosition`, a `fieldTabs` entry without `key`, a `highlightFields` entry with an unknown
35+
`type`, or a formatting rule with an unknown `operator`.
36+
37+
**`page` on a `pagination` node is retired (breaking).** It was a second spelling of `currentPage`,
38+
read only as a fallback behind it, and no document in this repository authored it. It is retired
39+
at once, with no alias window:
40+
41+
- `PaginationSchema.page` is now `?: never` on the TypeScript type, so writing it is a `tsc` error;
42+
- both zod faces refuse it by name, and the refusal says to rename the key to `currentPage`;
43+
- the `pagination` renderer in `@object-ui/components` no longer reads it, so a node that still
44+
carries only `page` renders page 1.
45+
46+
Rename `page` to `currentPage` on any `pagination` node. `@object-ui/types` and
47+
`@object-ui/components` are in the fixed release group, so this ships as a minor bump, per the
48+
repository's version policy.
49+
50+
Two `object-form` members stay declared and unmirrored on purpose, and no published surface
51+
changes for them: `open` (dialog state that only in-code hosts set) and `submitHandler` (a function
52+
slot; objectui#6182 rules handlers runtime-only). Several other declared members of these node types
53+
are also still unmirrored, each for a stated reason recorded on objectui#6152. No other TypeScript
54+
declaration changed.

‎.changeset/7804-tree-view-handler-slot.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,5 @@ The pair moves from `zod-mirror-parity.test.ts`'s `RuntimeOnlyDeclared` to its
5252
hold — so the two unmirrored ledgers are now in a containment relation, and the
5353
cross-ledger figure that recorded their difference states the containment
5454
instead.
55+
56+
**Correction, 2026-09-30 (objectui#6152, round 3).** The paragraph above says the two unmirrored ledgers are now in a containment relation. That was true when this change was written, and it no longer is: objectui#6152 round 3 left two pairs, `object-form` and `form`, recorded only in `RuntimeOnlyDeclared`, so the cross-ledger figure in `zod-mirror-parity.test.ts` states a difference again. The move this entry describes, `TreeViewSchema.onNodeClick` into `KnownDrift`, is unaffected.

‎packages/components/src/renderers/basic/pagination.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ ComponentRegistry.register('pagination',
2121
...paginationProps
2222
} = props;
2323

24-
const currentPage = schema.currentPage || schema.page || 1;
24+
// `currentPage` is the one spelling (objectui#6152): the `page` fallback this
25+
// read used to carry is retired on both faces of `@object-ui/types`.
26+
const currentPage = schema.currentPage || 1;
2527
const totalPages = schema.totalPages || 1;
2628

2729
const handlePageChange = (page: number, e: React.MouseEvent) => {
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*
8+
* objectui#6152 round 3 — the declared-but-unmirrored keys this round closed on
9+
* four pairs, and the `page` spelling it retired.
10+
*
11+
* ## What moved
12+
*
13+
* `UnmirroredDeclared` in `zod-mirror-parity.test.ts` recorded keys the
14+
* TypeScript face invites an author to write and the zod mirror had never heard
15+
* of. Two faces paid for each one:
16+
*
17+
* - the TOLERANT face (`BaseSchema` is `.passthrough()`) kept any value at the
18+
* key unexamined, so a wrong-typed value parsed green;
19+
* - the STRICT authoring face (`StrictAnyComponentSchema`, derived from the
20+
* mirrors) refused the key outright although `tsc` accepted it.
21+
*
22+
* Each key below was measured READ before it was mirrored (a type-checker census
23+
* over every package's sources; the readings are in objectui#6152's round-3
24+
* report). This file pins the result, not the census:
25+
*
26+
* - a VALID value parses on BOTH faces (the strict leg is the one that moved:
27+
* refused, now accepted);
28+
* - a WRONG-TYPED value is refused AT THE KEY on the tolerant face (the leg that
29+
* moved the other way: kept unexamined, now refused).
30+
*
31+
* `PaginationSchema.page` is the other half of the pagination row: a second
32+
* spelling of `currentPage`, RETIRED on both faces in the same change, so it is
33+
* refused by name on the mirror and is a `tsc` error on the interface.
34+
*/
35+
import { describe, it, expect } from 'vitest';
36+
import { readFileSync } from 'node:fs';
37+
import { fileURLToPath } from 'node:url';
38+
import { dirname, join } from 'node:path';
39+
40+
import type { PaginationSchema as TsPaginationSchema } from '../navigation';
41+
import { PaginationSchema as PaginationMirror } from '../zod/navigation.zod.js';
42+
import { FormSchema as FormMirror } from '../zod/form.zod.js';
43+
import { ReportComponentSchema as ReportMirror } from '../zod/reports.zod.js';
44+
import { DetailViewSchema as DetailViewMirror } from '../zod/views.zod.js';
45+
import { AnyComponentSchema, StrictAnyComponentSchema } from '../zod/index.zod.js';
46+
47+
const HERE = dirname(fileURLToPath(import.meta.url));
48+
const REPO_ROOT = join(HERE, '..', '..', '..', '..');
49+
50+
type Row = { key: string; valid: unknown; wrong: unknown };
51+
type Pair = {
52+
name: string;
53+
mirror: { shape: Record<string, unknown>; safeParse: (v: unknown) => { success: boolean; error?: { issues: Array<{ path: PropertyKey[] }> } } };
54+
base: Record<string, unknown>;
55+
rows: Row[];
56+
};
57+
58+
const PAIRS: Pair[] = [
59+
{
60+
name: 'pagination',
61+
mirror: PaginationMirror as unknown as Pair['mirror'],
62+
base: { type: 'pagination', totalPages: 10 },
63+
rows: [{ key: 'currentPage', valid: 3, wrong: 'three' }],
64+
},
65+
{
66+
name: 'form',
67+
mirror: FormMirror as unknown as Pair['mirror'],
68+
base: { type: 'form', fields: [{ name: 'first_name', label: 'First name' }, { name: 'last_name', label: 'Last name' }] },
69+
rows: [
70+
{ key: 'mobileStickyActions', valid: true, wrong: 'yes' },
71+
{ key: 'fieldContainerClass', valid: 'grid grid-cols-2 gap-4', wrong: 2 },
72+
{
73+
key: 'fieldTabs',
74+
valid: [
75+
{ key: 'a', label: 'A', fields: ['first_name'] },
76+
{ key: 'b', fields: ['last_name'], containerClass: 'space-y-2', visibleWhen: { dialect: 'cel', source: 'record.kind == "b2b"' } },
77+
],
78+
wrong: [{ label: 'no key', fields: ['first_name'] }],
79+
},
80+
{ key: 'defaultFieldTab', valid: 'b', wrong: 2 },
81+
{ key: 'fieldTabsPosition', valid: 'left', wrong: 'middle' },
82+
{
83+
key: 'fieldPanes',
84+
valid: [
85+
{ key: 'left', fields: ['first_name'], defaultSize: 40, minSize: 20 },
86+
{ key: 'right', fields: ['last_name'] },
87+
],
88+
wrong: [{ key: 'left', fields: 'first_name' }],
89+
},
90+
{ key: 'fieldPanesOrientation', valid: 'vertical', wrong: 'diagonal' },
91+
{ key: 'fieldPanesResizable', valid: false, wrong: 'false' },
92+
],
93+
},
94+
{
95+
name: 'report',
96+
mirror: ReportMirror as unknown as Pair['mirror'],
97+
base: { type: 'report', title: 'Pipeline' },
98+
rows: [
99+
{
100+
key: 'conditionalFormatting',
101+
valid: [{ field: 'amount', operator: 'greater_than', value: 1000, backgroundColor: '#fee2e2', textColor: '#991b1b' }],
102+
wrong: [{ field: 'amount', operator: 'between', value: 1000 }],
103+
},
104+
],
105+
},
106+
{
107+
name: 'detail-view',
108+
mirror: DetailViewMirror as unknown as Pair['mirror'],
109+
base: { type: 'detail-view', objectName: 'account' },
110+
rows: [
111+
{ key: 'primaryField', valid: 'name', wrong: 7 },
112+
{ key: 'summaryFields', valid: ['status', 'owner'], wrong: 'status' },
113+
{ key: 'autoTabs', valid: true, wrong: 'on' },
114+
{ key: 'defaultTab', valid: 'activity', wrong: 1 },
115+
{
116+
key: 'sectionGroups',
117+
valid: [{ title: 'Company', collapsible: true, defaultCollapsed: false, sections: [{ title: 'Basics', fields: [{ name: 'name' }] }] }],
118+
wrong: [{ description: 'no title', sections: [] }],
119+
},
120+
{
121+
key: 'highlightFields',
122+
valid: [{ name: 'industry', label: 'Industry', type: 'select', icon: 'Factory', readonly: true }],
123+
wrong: [{ name: 'industry', label: 'Industry', type: 'hologram' }],
124+
},
125+
],
126+
},
127+
];
128+
129+
const ROWS = PAIRS.flatMap((pair) => pair.rows.map((row) => ({ ...row, pair })));
130+
131+
describe('objectui#6152 round 3 — declared keys the mirrors now declare', () => {
132+
it.each(PAIRS)('CONTROL: the minimal `$name` document parses on both faces', ({ base }) => {
133+
expect(AnyComponentSchema.safeParse(base).success).toBe(true);
134+
const strict = StrictAnyComponentSchema.safeParse(base);
135+
expect(strict.success, JSON.stringify(strict.error?.issues)).toBe(true);
136+
});
137+
138+
it.each(ROWS)('`$pair.name`.`$key` is a member of the mirror', ({ key, pair }) => {
139+
expect(key in pair.mirror.shape).toBe(true);
140+
});
141+
142+
it.each(ROWS)('an authored `$pair.name`.`$key` parses on the strict face and the tolerant face', ({ key, valid, pair }) => {
143+
const doc = { ...pair.base, [key]: valid };
144+
const strict = StrictAnyComponentSchema.safeParse(doc);
145+
expect(strict.success, JSON.stringify(strict.error?.issues)).toBe(true);
146+
const tolerant = AnyComponentSchema.safeParse(doc);
147+
expect(tolerant.success, JSON.stringify(tolerant.error?.issues)).toBe(true);
148+
});
149+
150+
it.each(ROWS)('a wrong-typed `$pair.name`.`$key` is refused at the key on the tolerant face', ({ key, wrong, pair }) => {
151+
const parsed = pair.mirror.safeParse({ ...pair.base, [key]: wrong });
152+
expect(parsed.success).toBe(false);
153+
const issues = parsed.error?.issues ?? [];
154+
expect(issues.length).toBeGreaterThan(0);
155+
for (const issue of issues) expect(issue.path[0]).toBe(key);
156+
});
157+
158+
it('a `report-viewer` node judges the rules on the report it carries — the reader `ReportViewer` evaluates', () => {
159+
const rules = [{ field: 'amount', operator: 'less_than', value: 0, textColor: '#b91c1c' }];
160+
const doc = { type: 'report-viewer', report: { type: 'report', title: 'Pipeline', conditionalFormatting: rules } };
161+
const strict = StrictAnyComponentSchema.safeParse(doc);
162+
expect(strict.success, JSON.stringify(strict.error?.issues)).toBe(true);
163+
const wrong = AnyComponentSchema.safeParse({ ...doc, report: { ...doc.report, conditionalFormatting: [{ ...rules[0], operator: 'between' }] } });
164+
expect(wrong.success).toBe(false);
165+
});
166+
167+
it('the catalog pagination document objectui#5250 M3 charged with `currentPage` now parses on the strict face', () => {
168+
const doc = JSON.parse(readFileSync(join(REPO_ROOT, 'examples/schema-catalog/src/schemas/components-basic-pagination/basic-pagination.json'), 'utf8'));
169+
// Non-vacuity: the document really authors the key this row is about.
170+
expect(doc).toMatchObject({ type: 'pagination', currentPage: 1 });
171+
const strict = StrictAnyComponentSchema.safeParse(doc);
172+
expect(strict.success, JSON.stringify(strict.error?.issues)).toBe(true);
173+
});
174+
});
175+
176+
describe('objectui#6152 round 3 — `page` is a RETIRED second spelling of `currentPage`', () => {
177+
const BASE = { type: 'pagination', totalPages: 10 } as const;
178+
179+
it('stays a member of the mirror, so an authored value is refused by name rather than kept', () => {
180+
expect('page' in PaginationMirror.shape).toBe(true);
181+
});
182+
183+
it.each([
184+
['the mirror', (v: unknown) => PaginationMirror.safeParse(v)],
185+
['the tolerant face', (v: unknown) => AnyComponentSchema.safeParse(v)],
186+
['the strict face', (v: unknown) => StrictAnyComponentSchema.safeParse(v)],
187+
] as const)('an authored `page` is refused at the key on %s, and the refusal names `currentPage`', (_face, parse) => {
188+
const parsed = parse({ ...BASE, page: 2 });
189+
expect(parsed.success).toBe(false);
190+
const atPage = (parsed.error?.issues ?? []).filter((issue) => issue.path[0] === 'page');
191+
expect(atPage.length, JSON.stringify(parsed.error?.issues)).toBeGreaterThan(0);
192+
expect(atPage.some((issue) => issue.message.includes('`currentPage`')), JSON.stringify(atPage)).toBe(true);
193+
});
194+
195+
it('is a `tsc` error on the interface, while `currentPage` is the live spelling', () => {
196+
// The directive is real enforcement: this package type-checks its tests
197+
// (`tsconfig.test.json`), so re-declaring `page` fails on the unused directive.
198+
// @ts-expect-error `page` is RETIRED (objectui#6152) — rename the key to `currentPage`
199+
const retired: TsPaginationSchema = { type: 'pagination', totalPages: 10, page: 2 };
200+
const live: TsPaginationSchema = { type: 'pagination', totalPages: 10, currentPage: 2 };
201+
expect(retired.type).toBe('pagination');
202+
expect(live.currentPage).toBe(2);
203+
});
204+
});

0 commit comments

Comments
 (0)