|
| 1 | +--- |
| 2 | +'@object-ui/react': minor |
| 3 | +'@object-ui/components': minor |
| 4 | +'@object-ui/fields': minor |
| 5 | +'@object-ui/plugin-list': minor |
| 6 | +'@object-ui/plugin-calendar': minor |
| 7 | +'@object-ui/plugin-gantt': minor |
| 8 | +'@object-ui/plugin-kanban': minor |
| 9 | +'@object-ui/plugin-charts': minor |
| 10 | +'@object-ui/plugin-dashboard': minor |
| 11 | +'@object-ui/plugin-detail': minor |
| 12 | +--- |
| 13 | + |
| 14 | +**BREAKING** — `SchemaRendererProvider`'s `dataSource` prop, and the context |
| 15 | +type every `useSchemaContext()` consumer reads back, are the published |
| 16 | +`DataSource` contract instead of `any`. |
| 17 | + |
| 18 | +**FROM** `dataSource={anything}` **TO** `dataSource={adapter}` — a `DataSource` |
| 19 | +from `@object-ui/types`, or `null` / `undefined` when the host has no adapter |
| 20 | +bound. |
| 21 | + |
| 22 | +```ts |
| 23 | +// before — compiled, and failed at runtime on the first find() |
| 24 | +<SchemaRendererProvider dataSource={'not-an-adapter'}> |
| 25 | +// before — compiled, and no reader can do anything with it |
| 26 | +<SchemaRendererProvider dataSource={{}}> |
| 27 | +// after |
| 28 | +<SchemaRendererProvider dataSource={adapter}> // a DataSource |
| 29 | +<SchemaRendererProvider dataSource={undefined}> // "I have no adapter" |
| 30 | +``` |
| 31 | + |
| 32 | +Both sites are typed `DataSource | null | undefined` — the spelling |
| 33 | +`useSettledSchema` in this same package already used. The two absences are part |
| 34 | +of the contract, not a weakening of it: a Studio preview, a `kind:'react'` page |
| 35 | +rendered before the host's adapter connects, and a widget probe driving |
| 36 | +`apiFetch` alone all render with nothing bound, and every reader in the tree |
| 37 | +already guards for it. What the union refuses is everything that is not an |
| 38 | +adapter: a string, an empty object, a plain data bag, a partial adapter missing |
| 39 | +a required member. |
| 40 | + |
| 41 | +The measured cost, both halves, because the two `any`s have different blast |
| 42 | +radii (measured separately on `origin/main`, whole-repo type-check over the 33 |
| 43 | +packages that depend on `@object-ui/react`): |
| 44 | + |
| 45 | +- the **context type** — the `any` that reaches every `useSchemaContext()` |
| 46 | + reader — reds **7 diagnostics at 7 sites in 4 packages**, all of them |
| 47 | + production code or a mocked module factory. |
| 48 | +- the **provider prop** — the injection points — reds **52 diagnostics at 27 |
| 49 | + sites in 11 packages**, all but one of them test doubles. |
| 50 | + |
| 51 | +That ordering is the reverse of the prediction on the card: the context `any` |
| 52 | +was expected to be the expensive one because it infects the whole tree, and it |
| 53 | +is the cheap one, because every reader in the tree already guarded and none of |
| 54 | +them ever reached past `find` / `getObjectSchema`. The prop is the expensive |
| 55 | +one, because the injection points are overwhelmingly test doubles that were |
| 56 | +never complete adapters. The full accounting is on objectui#7912. |
| 57 | + |
| 58 | +Two runtime behaviours change, both in the "no adapter" direction and both |
| 59 | +strictly closer to what the surrounding code already intended: |
| 60 | + |
| 61 | +- `@object-ui/components`' `kind:'react'` page passed an empty object as its |
| 62 | + "no adapter yet" stand-in. An empty object is TRUTHY, so it walked past every |
| 63 | + `if (!dataSource)` guard written to catch exactly that state and failed later, |
| 64 | + at the call. It now passes the absent adapter itself, so the guard fires where |
| 65 | + it was meant to. The module-constant identity that stand-in existed for is |
| 66 | + preserved: `null` is a primitive, so the provider's memo is unaffected. |
| 67 | +- `@object-ui/plugin-calendar`, `@object-ui/plugin-gantt` and |
| 68 | + `@object-ui/plugin-kanban` collapse a `null` adapter from the context to |
| 69 | + `undefined` before handing it to their widget, whose prop declares the single |
| 70 | + spelling `dataSource?: DataSource`. |
| 71 | + |
| 72 | +Nothing else moves at runtime: no value flowing through this key changes, and |
| 73 | +no data path is touched. A TypeScript consumer outside this repo that handed |
| 74 | +this prop something other than an adapter now gets a compile error naming the |
| 75 | +key (TS2322 / TS2739 / TS2740), which is why the FROM/TO is spelled out above. |
| 76 | + |
| 77 | +Five `as any` reads of this context in `@object-ui/fields` are gone — they were |
| 78 | +redundant the moment the seam became honest — and `LookupField`'s local |
| 79 | +re-declaration of the imported context as a `Context` of `any`, which laundered |
| 80 | +its `dataSource` read while looking typed, is gone with them. Both directions of |
| 81 | +the contract are pinned against the real compiler in |
| 82 | +`SchemaRendererContext.dataSourceType.pin.test.ts`, and the card's planted |
| 83 | +documentation probe (a bare string in `packages/react/README.md`'s provider |
| 84 | +example) now fails `pnpm check:doc-snippets`, where it used to exit 0 with zero |
| 85 | +diagnostics. |
| 86 | + |
| 87 | +objectui#7912. |
0 commit comments