Repository navigation
feat(appkit-ui): add typed databaseApi client for DatabasePlugin routes - #608
Conversation
📦 Bundle size reportCompared against
|
| dist | raw | gzip |
|---|---|---|
| JS (runtime) | 1.2 MB (+86 B) | 447 KB (+9 B) |
| Type declarations | 455 KB | 165 KB (+2 B) |
| Source maps | 2.5 MB (+20 B) | 837 KB (+13 B) |
| Other | 11 KB | 3.7 KB |
| Total | 4.1 MB (+106 B) | 1.4 MB (+24 B) |
Per-entry composition (own code — deps external (as shipped))
| Entry | Initial (gz) | Lazy (gz) | Total (gz) | node_modules (min) | Own code (min) |
|---|---|---|---|---|---|
. |
102 KB (-1 B) | 2.5 KB (-1 B) | 105 KB (-2 B) | external | 331 KB |
./beta |
98 KB | 484 B | 99 KB | external | 297 KB |
./testing |
42 KB | 32 KB (+3 B) | 74 KB (+3 B) | external | 215 KB |
./tsdown |
520 B | 0 B | 520 B | external | 813 B |
./type-generator |
23 KB | 0 B | 23 KB | external | 66 KB |
Chunks:
| Entry | Chunk | Load | Size (gz) |
|---|---|---|---|
. |
index.js |
initial | 97 KB |
. |
utils.js |
initial | 4.6 KB |
. |
remote-tunnel-manager.js |
lazy | 2.5 KB |
./beta |
beta.js |
initial | 81 KB |
./beta |
stream-manager.js |
initial | 5.9 KB |
./beta |
service-context.js |
initial | 4.2 KB |
./beta |
databricks.js |
initial | 3.3 KB |
./beta |
wide-event-emitter.js |
initial | 3.2 KB |
./beta |
client.js |
initial | 594 B |
./beta |
index.js |
initial | 20 B |
./beta |
supervisor-api.js |
lazy | 192 B |
./beta |
databricks.js |
lazy | 178 B |
./beta |
index.js |
lazy | 114 B |
./testing |
manifest.js |
initial | 29 KB |
./testing |
index.js |
initial | 10 KB |
./testing |
wide-event-emitter.js |
initial | 2.9 KB |
./testing |
index.js |
lazy | 28 KB |
./testing |
remote-tunnel-manager.js |
lazy | 2.5 KB |
./testing |
utils.js |
lazy | 1.8 KB |
./tsdown |
index.js |
initial | 520 B |
./type-generator |
index.js |
initial | 23 KB |
@databricks/appkit-ui
npm tarball (packed): 369 KB (-5 B) — gzipped download (dist + bin; excludes release-only docs/NOTICE).
| dist | raw | gzip |
|---|---|---|
| JS (runtime) | 406 KB | 137 KB |
| Type declarations | 247 KB | 90 KB (-1 B) |
| Source maps | 798 KB | 264 KB |
| CSS | 16 KB | 3.2 KB |
| Total | 1.4 MB | 494 KB (-1 B) |
Per-entry composition (consumer bundle — deps bundled, peerDeps external)
| Entry | Initial (gz) | Lazy (gz) | Total (gz) | node_modules (min) | Own code (min) |
|---|---|---|---|---|---|
./js |
5.3 KB | 49 KB | 55 KB | 208 KB | 14 KB |
./js/beta |
2.1 KB | 0 B | 2.1 KB | 0 B | 4.9 KB |
./react |
432 KB | 49 KB | 481 KB | 1.3 MB | 177 KB |
./react/beta |
1.0 KB | 0 B | 1.0 KB | 0 B | 1.9 KB |
Chunks:
| Entry | Chunk | Load | Size (gz) |
|---|---|---|---|
./js |
index.js |
initial | 5.2 KB |
./js |
chunk |
initial | 120 B |
./js |
apache-arrow |
lazy | 49 KB |
./js/beta |
beta.js |
initial | 2.1 KB |
./react |
index.js |
initial | 430 KB |
./react |
tslib |
initial | 2.1 KB |
./react |
apache-arrow |
lazy | 49 KB |
./react/beta |
beta.js |
initial | 1.0 KB |
🤖 AppKit PR bot🔬 Run evalsStart an eval for this PR from the evals-monitor app: Go to Evals Monitor → 📦 Try this PR's app templateScaffolds a new app from this PR's SDK build. Run it in any folder (requires the GitHub CLI — gh run download 37657551065 -R databricks/appkit -n appkit-template-0.85.0-pr.62035b9-stack-database-hooks-01-client-608 -D appkit-pr-608 \
&& unzip -o "appkit-pr-608/appkit-template-0.85.0-pr.62035b9-stack-database-hooks-01-client-608.zip" -d "appkit-pr-608" \
&& databricks apps init --template "appkit-pr-608"The template pins |
73e8abb to
d9c15c5
Compare
Generate an HTTP-safe `api` facet per entity from the same column capability predicates the server uses to compile its CRUD contract, and bind the generated entries into both @databricks/appkit and @databricks/appkit-ui/js/beta. The status-to-category table and the list/record query encoder move to `shared` so both sides agree on them. `databaseApi.list` resolves routes from the boot payload, fails locally with NOT_EXPOSED for routes the server has not published, and throws a typed DatabaseApiError. The playground's BoardExplorer lists boards and notes through it, and CI type-checks the database components against the built appkit-ui declarations. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: ditadi <victordperd@gmail.com>
Complete the typed browser client with the detail route and the three write routes. `get`, `update`, and `remove` substitute the encoded id into the published `:id` route and exist only for entities with a public key. Writes send a JSON body with bigint values as decimal strings and resolve with the public row the server answers with; `remove` expects a 204. Create and update values reject private, generated, and undeclared fields at compile time, including fields a spread carries in, and JSON columns accept any object value. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: ditadi <victordperd@gmail.com>
Add a "Browser client (beta)" section to the database plugin page: setup through the generated database.d.ts, the five databaseApi calls and their routes, the accepted parameters and values, and the DatabaseApiError codes. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: ditadi <victordperd@gmail.com>
Signed-off-by: ditadi <victordperd@gmail.com>
Signed-off-by: ditadi <victordperd@gmail.com>
Signed-off-by: ditadi <victordperd@gmail.com>
Signed-off-by: ditadi <victordperd@gmail.com>
Signed-off-by: ditadi <victordperd@gmail.com>
Acknowledge the new typed database client: the packed tarball grows by 19,271 bytes (5.4%). The js/beta consumer entry is 2,113 gzip bytes with no bundled dependencies. Generated from a clean build. The 5% and 10 KiB budget gates are unchanged. Signed-off-by: ditadi <victordperd@gmail.com>
d513e09 to
de99f54
Compare
atilafassina
left a comment
There was a problem hiding this comment.
Re-reviewed at de99f54 against main. The earlier findings are addressed: non-finite numbers are rejected on writes, dynamic select arrays now type as Partial, and boolean/JSON primary keys no longer publish routes. Empty where and empty update still compile but now fail with a clear INVALID_REQUEST. Database tests (355) and the appkit-ui and shared typechecks pass.
Why the change
Browser code that calls the
/api/databaseroutesDatabasePlugingenerates had to hand-write URLs, query encoding, and row types, so this addsdatabaseApi, a typed client (beta) that gets its types from the same generateddatabase.d.tsthe server uses.Special things to note
database.d.tsnow also augments@databricks/appkit-ui/js/beta, even in apps that don't install appkit-ui. Those apps rely onskipLibCheck, as they already do foranalytics.d.ts, and a generator test covers that case. Apps pick up the newapifacet the next time they regenerate types.typecheck:databasestep. It type-checks the playground's database components against appkit-ui's builtdistdeclarations, which proves the generated types reach them; the playground client has no other typecheck.Interface.PluginManifest.mdthat CI's generated-docs check needs. The change is identical in both PRs, so they merge cleanly in either order.Change outline
There is still one schema and one generated file. Each entry gains an
apifacet that describes what the HTTP routes accept, and the same entries are bound into both packages (playgroundnotesshown):author_emailis private, so it appears in the trusted facets but in noapifacet. The route compiler and the type generator now read that rule from one function, so the browser types can't drift from what the server accepts:sharedholds what both sides must agree on, andappkit-uiadds the client on top of it:The new public surface. Private columns, undeclared keys, keyed calls on keyless tables, and
limiton to-one includes are all compile errors:Every call goes through the same path:
The playground's
BoardExplorerloads its board and note lists throughdatabaseApi.list. The database plugin docs gain a "Browser client (beta)" section.This pull request and its description were written by Isaac.