|
| 1 | +--- |
| 2 | +'@object-ui/react': patch |
| 3 | +'@object-ui/core': patch |
| 4 | +'@object-ui/data-objectstack': patch |
| 5 | +'@object-ui/app-shell': patch |
| 6 | +'@object-ui/plugin-designer': patch |
| 7 | +--- |
| 8 | + |
| 9 | +refactor(react): `AdapterCtx` / `useAdapter` are typed by `DataSource`, and `@object-ui/react` no longer depends on `@object-ui/data-objectstack` |
| 10 | + |
| 11 | +Clause-②: yes (narrowing) |
| 12 | +Metadata-protocol: none |
| 13 | + |
| 14 | +<!-- adr-0087: not-required (runtime-interface-only ui/packages/react/src/context/AppShellContext.tsx#ContextAdapter) No metadata moves: the narrowed type is the one `AdapterCtx` and `useAdapter()` carry, a runtime TypeScript type of a React context, with no Zod schema, spec declaration or stored row behind it, so there is nothing for objectstack migrate meta to rewrite; the compiler names the affected call site. --> |
| 15 | + |
| 16 | +The runtime no longer depends on one adapter, so a bring-your-own backend installs `@object-ui/react` without the ObjectStack adapter, and learns at the type level which `DataSource` members it lacks. |
| 17 | + |
| 18 | +- **`@object-ui/react`**: `AdapterCtx` and `useAdapter()` are typed by the protocol-level `DataSource` from `@object-ui/types`, not by `ObjectStackAdapter`. A new exported extension point, `AdapterContextRegister`, lets a host declare the concrete adapter its provider installs; `useAdapter()` then returns that adapter and an `AdapterCtx.Provider` value is checked against it. `ContextAdapter` names the resolved type. `@object-ui/data-objectstack` moves from `dependencies` to `devDependencies` (one boundary test still reads it). |
| 19 | +- **`@object-ui/core`**: exports `API_ACCESS_DENIED_CODES` and `isApiAccessDeniedError`, the `enable`-block API denial predicate, moved here unchanged so `@object-ui/react` can classify the denial without the adapter. |
| 20 | +- **`@object-ui/data-objectstack`**: re-exports both names from `@object-ui/core`; its published face is unchanged. |
| 21 | +- **`@object-ui/app-shell`**: declares `ObjectStackAdapter` on `AdapterContextRegister`, and the declaration ships in its published types, so a host that mounts `AdapterProvider` keeps today's `useAdapter()` type. |
| 22 | +- **`@object-ui/plugin-designer`**: declares the same adapter for its own pages, which read the ObjectStack client. |
| 23 | + |
| 24 | +**BREAKING** (a type narrowing) for a TypeScript reader of `useAdapter()` / `AdapterCtx` from `@object-ui/react` that reads an `ObjectStackAdapter` member `DataSource` does not declare (`getClient`, `probeAppAccess`, `probeMetaItemAccess`, `getConnectionState`, `onConnectionStateChange`, `clearCache`, `queryDataset`, …) and does not import `@object-ui/app-shell`. Runtime behaviour is unchanged: the context holds the same adapter object as before. |
| 25 | + |
| 26 | +- **Before.** `useAdapter()` returned `ObjectStackAdapter | null` whatever the host installed. |
| 27 | +- **Now.** It returns `DataSource | null` unless the host declares its adapter, and reading `getClient` off it is `error TS2339`. |
| 28 | +- **Fix.** Either declare the adapter your provider installs, once, in your own package: |
| 29 | + |
| 30 | + ```ts |
| 31 | + import type { ObjectStackAdapter } from '@object-ui/data-objectstack'; |
| 32 | + |
| 33 | + declare module '@object-ui/react' { |
| 34 | + interface AdapterContextRegister { |
| 35 | + adapter: ObjectStackAdapter; |
| 36 | + } |
| 37 | + } |
| 38 | + ``` |
| 39 | + |
| 40 | + or narrow at the call site that needs the ObjectStack-only member, and keep reading `DataSource` members everywhere else. |
0 commit comments