|
| 1 | +--- |
| 2 | +"@object-ui/runner": patch |
| 3 | +--- |
| 4 | + |
| 5 | +fix(runner): type-check the package at all, and fix the `DataSource` contract violation that hid behind a broken import (#2917) |
| 6 | + |
| 7 | +`@object-ui/runner` was the worst-covered package in the repo: `build` is |
| 8 | +`vite build` (transpile only), it had no `type-check` script, and — uniquely — |
| 9 | +**no `tsconfig.json` at all**. Nothing had ever type-checked it, despite it being |
| 10 | +a published package. |
| 11 | + |
| 12 | +**It was not broken at runtime.** The two bad imports were `import type`, so they |
| 13 | +were erased before they could fail, and the one value import |
| 14 | +(`emulateBatchTransaction`) does exist. `MockDataSource` is also unreferenced |
| 15 | +anywhere in the repo. So this is a correctness and reference-quality fix, not an |
| 16 | +outage. |
| 17 | + |
| 18 | +**What the missing check actually hid.** `DataSource` and |
| 19 | +`BatchTransactionOperation` were imported from `@object-ui/core`, which does not |
| 20 | +export them — they live in `@object-ui/types`. Because that import never |
| 21 | +resolved, `class MockDataSource implements DataSource` was silently a no-op, and |
| 22 | +three separate commits maintained the class *as if* it were being verified |
| 23 | +(`62b9ab510` added `batchTransaction`, `09d9669c7` made `getObjectSchema` |
| 24 | +required, `5527388b0` added input validation). With the `implements` clause |
| 25 | +inert, a real contract violation survived all three: |
| 26 | + |
| 27 | +```ts |
| 28 | +async find(resource: string, params?: any): Promise<any[]> { return []; } |
| 29 | +``` |
| 30 | + |
| 31 | +`DataSource.find` returns a `QueryResult` envelope, not a bare array. Anyone |
| 32 | +copying this mock as the starting point for their own adapter — which is exactly |
| 33 | +what its doc comment invites — would hand every consumer an array where `.data` |
| 34 | +and `.total` are `undefined`. Now typed as `Promise<QueryResult>` and returning |
| 35 | +`{ data: [], total: 0 }`. |
| 36 | +
|
| 37 | +Also in this change: |
| 38 | +
|
| 39 | +- `packages/runner/tsconfig.json` added, mirroring `apps/console` rather than the |
| 40 | + library packages: `runner` is a Vite app, so it wants `bundler` resolution, |
| 41 | + `allowImportingTsExtensions` (for `./App.tsx`) and `types: ["vite/client"]` |
| 42 | + (for `import.meta.glob` in `MetadataLoader` and the `./index.css` side-effect |
| 43 | + import). Keeping it standalone instead of extending the root config also means |
| 44 | + it never inherits the root `paths`, so workspace deps resolve through built |
| 45 | + `.d.ts` and the TS6059 `rootDir` class of error cannot appear. |
| 46 | +- unused parameters prefixed with `_` (6x in `mockDataSource`), and an unused |
| 47 | + `Circle` icon import dropped from `LayoutRenderer`. |
| 48 | +- `"type-check": "tsc --noEmit"` added, and the package's `DEBT` entry deleted |
| 49 | + from `scripts/check-type-check-coverage.mjs`. Coverage goes 35 -> 36 of 45 and |
| 50 | + outstanding errors 46 -> 32. |
| 51 | +
|
| 52 | +Verified the gate genuinely covers the package now, rather than trusting the |
| 53 | +green: injecting a type error into `runner/src/App.tsx` makes `pnpm type-check` |
| 54 | +fail with `Failed: @object-ui/runner#type-check`, which was impossible before |
| 55 | +this change. |
0 commit comments