@protobase/cli 0.55.5 → 0.55.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.55.5";
2
+ var version = "0.55.7";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.55.5",
3
+ "version": "0.55.7",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -42,12 +42,12 @@
42
42
  "dependencies": {
43
43
  "@better-auth/core": "^1.7.12",
44
44
  "@hono/node-server": "^2.1.3",
45
- "@protobase/config": "0.55.5",
46
- "@protobase/layout": "0.55.5",
47
- "@protobase/query": "0.55.5",
48
- "@protobase/schema": "0.55.5",
49
- "@protobase/server": "0.55.5",
50
- "@protobase/ui": "0.55.5",
45
+ "@protobase/config": "0.55.7",
46
+ "@protobase/layout": "0.55.7",
47
+ "@protobase/query": "0.55.7",
48
+ "@protobase/schema": "0.55.7",
49
+ "@protobase/server": "0.55.7",
50
+ "@protobase/ui": "0.55.7",
51
51
  "@react-email/render": "^2.1.0",
52
52
  "@scalar/hono-api-reference": "^0.12.10",
53
53
  "@tailwindcss/vite": "^4.3.3",
@@ -5,6 +5,7 @@
5
5
  The page of one record, with its sections, related records, galleries, charts and editing.
6
6
 
7
7
  - [Record page layout](../reference/ui-config.md#the-record-page): Sections, a summary sidebar, related tables, maps, charts, galleries, history, comments and your own components.
8
+ - [Full-area record pages](../reference/ui-config.md#full-area-record-pages) (beta): A view draws its record pages with a component of its own that fills the area beside the sidebar and under the top bar, such as a chat channel, and links to the standard page.
8
9
  - [Read view and edit](../reference/ui-config.md#read-view-and-edit): A record opens as a read-only fact sheet or a form, and Edit opens the form at its own address.
9
10
  - [Unsaved edits](../reference/ui-config.md#editing-a-record): Unsaved changes to a record stay in the browser and can be resumed, and leaving a form, a dialog or a comment with changes asks first.
10
11
  - [Record forms](../reference/ui-config.md#editing-a-record): Relations are picked from a list that narrows as you type, numbers are read as the browser's language writes them, and a refused save says under each field what is wrong.
@@ -165,7 +165,7 @@ export const operations = resource('operations')
165
165
  - **`update` follows the parent's own parents**, so with VMs under `.parent((r) => r.folder_id, 'update')` an operation needs update on the VM's folder too. A write that would put a record under itself, or under a cycle already in the data, is refused. A `read` parent is followed only as far as reading it does (below).
166
166
  - **`read` also narrows every read.** With `.parent((r) => r.channel_id, 'read')`, a caller reads only the messages of channels they read: lists, `:search` and `:seek`, their counts, facets, charts and aggregates, a get (`404` outside, as for a row filter), relation labels, history, comments and reveals, through `/api/v1`, its batches and MCP, and the deliveries of a [subscription](webhooks.md#subscription) that runs as a role. The parent is read with the caller's own tenant, row filter and soft delete there, and its own `read` parents, so a channel whose members are listed in a `member_ids` JSON field with the read rule `where.or(where.eq('kind', 'public'), where.has('member_ids', ctx.user.id))` keeps its messages to its members, and taking someone off `member_ids` hides them on the next read. A message with a null `channel_id` names no channel and stays visible under its own rules, so a message with two nullable parents, `channel_id` or `direct_message_id`, keeps to the one it names.
167
167
  - **One indexed subquery.** The narrowing is `channel_id in (select id from channels where <the caller's channel filter>)` ANDed into the child's query (`channel_id is null or ...` for a nullable relation), so the [scan guard](api.md#safety) needs an index on `channel_id` and indexes serving the columns of the parent's row filter, such as a GIN index on `member_ids`, and `protobase doctor` names a missing index on the relation.
168
- - **A parent whose read rule reads the record hides its children.** Such a rule is no filter a query can hold, so a caller whose read rule on the parent needs the record, or who cannot read the parent resource, reads only the children with a null relation. <gap>A child under a parent whose read rule reads the record cannot be read because checking the parent per record is not implemented.</gap> Make the parent's read rule return a row filter instead. A resource that is its own parent, such as a folder tree, is checked one level up: a folder needs its parent folder readable. <gap>A record of a tree cannot keep to every ancestor because a transitive parent check is not implemented.</gap>
168
+ - **A parent whose read rule reads the record hides its children.** Such a rule is no filter a query can hold, so a caller whose read rule on the parent needs the record, or who cannot read the parent resource, reads only the children with a null relation. <gap>A child under a parent whose read rule reads the record cannot be read because checking the parent per record is not implemented.</gap> Make the parent's read rule return a row filter instead. A resource that is its own parent, such as a folder tree, is checked one level up: a folder needs its parent folder readable, and that folder is read with its other `read` parents too. So a reply under `.parent((r) => r.thread_id, 'read')` and `.parent((r) => r.channel_id, 'read')` whose `channel_id` is null keeps to the channel of the message it answers. <gap>A record of a tree cannot keep to every ancestor because a transitive parent check is not implemented.</gap>
169
169
  - **Across organizations, the session's own only.** <gap>A list across organizations cannot read a resource with a `read` parent beyond the session's own organization because resolving the parent in each organization is not implemented.</gap> The server warns at startup and lists the session's organization alone.
170
170
  - **Several parents** are each checked with their own access, also two of one resource, such as a transfer that reads its `source_vm_id` and updates its `target_vm_id`.
171
171
  - **The parent is locked until the write commits** (`FOR NO KEY UPDATE`), so a VM handed to someone else or deleted at the same moment is waited for and checked again. That is the cost: writes of records under one parent, and through an `update` parent under one ancestor, run one after another. The server's database role needs `UPDATE` on the parent's table to take the lock. Two writes that lock the same records in opposite orders, such as two batches writing under VM A then B and B then A, can deadlock: Postgres rolls one back, which answers `409` and writes nothing, and the client sends it again.
@@ -140,6 +140,29 @@ export const CustomerRepairs = ({ limit }: { limit: number }) => {
140
140
 
141
141
  A list that should stay live polls: `useList('repairs', { refetchInterval: 5000 })` refetches every 5 seconds. It is TanStack Query's `refetchInterval`, so it also takes `false` to stop, or a function of the query, and pauses while the tab is in the background.
142
142
 
143
+ ## Full-area record pages
144
+
145
+ A view can make a component the whole record page with [`.record({ component })`](ui-config.md#full-area-record-pages). It gets the record from `useLayoutRecord()`, as a record section does, and fills the area beside the sidebar and under the top bar, where the page does not scroll: a list in it scrolls in a box of its own with `min-h-0 flex-1 overflow-y-auto`, and what follows the list stays at the bottom. It links to the record's standard page, which keeps the form, the related records, Edit and Delete:
146
+
147
+ ```tsx
148
+ // components/channel-chat.tsx, exported from protobase.ui.tsx: export { ChannelChat } from './components/channel-chat'
149
+ import { AppLink, useLayoutRecord } from '@protobase/ui'
150
+
151
+ export const ChannelChat = () => {
152
+ const { model, key, record } = useLayoutRecord()!
153
+ return (
154
+ <section className="flex min-h-0 flex-col">
155
+ <header className="flex justify-between border-b px-4 py-2">
156
+ {String(record.name)}
157
+ <AppLink to={{ kind: 'record', resource: model.name, key, standard: true }}>Details</AppLink>
158
+ </header>
159
+ <ol className="min-h-0 flex-1 overflow-y-auto">{/* the messages */}</ol>
160
+ {/* the composer */}
161
+ </section>
162
+ )
163
+ }
164
+ ```
165
+
143
166
  ## Record cards
144
167
 
145
168
  A cards display can draw each card's content with a component, declared in the view with `d.cards(fields, { card })`. The card stays a link to the record, with the display's frame; the component draws what is inside it from `row`, the record with the fields the display names, so name every field the card shows:
@@ -105,7 +105,7 @@ Every place in the app has an address, and the app writes and reads them in one
105
105
  | Address | Is |
106
106
  | --- | --- |
107
107
  | `{ kind: 'list', resource, filter?, orderBy?, display? }` | A resource's list, with the filter, order and [display](ui-config.md#list-displays) the list page would show. |
108
- | `{ kind: 'record', resource, key, edit?, open?, tab? }` | One record; `key` is its value, or its parts for a composite key. `edit: true` is its form (`?edit=true`), on a view whose record page opens as a [read view or locked](ui-config.md#read-view-and-edit). `open` lists the titles of the record page's collapsed [groups](ui-config.md#groups) that are open (`?open=<title>`, once per group), and `tab` the title of the [tab](ui-config.md#tabs) it shows (`?tab=<title>`). |
108
+ | `{ kind: 'record', resource, key, edit?, open?, tab?, standard? }` | One record; `key` is its value, or its parts for a composite key. `edit: true` is its form (`?edit=true`), on a view whose record page opens as a [read view or locked](ui-config.md#read-view-and-edit). `open` lists the titles of the record page's collapsed [groups](ui-config.md#groups) that are open (`?open=<title>`, once per group), and `tab` the title of the [tab](ui-config.md#tabs) it shows (`?tab=<title>`). `standard: true` is its standard page (`?standard=true`), on a view whose record page is a [component of the app's own](ui-config.md#full-area-record-pages). |
109
109
  | `{ kind: 'create', resource, values? }` | The form for a new record, with `values` filled in by field name, as text: `{ kind: 'create', resource: 'notes', values: { listing_id: '{id}' } }` on a listing's page starts a note about that listing. A relation shows the name of the record it points at. The values are a start the person can change, not a rule: what they may write is still up to the access rules. A view with a [create page](ui-config.md#create-pages) shows that page here instead, with the values in the address. |
110
110
  | `{ kind: 'page', page, tab? }` | A composed page; `tab` the name of one of its [tabs](blocks.md#tabs-and-tab) (`/<page>/<tab>`), the first when omitted. |
111
111
 
@@ -647,6 +647,18 @@ Without a layout the record page shows one section with every field the user may
647
647
 
648
648
  A record opened from a list, by its row or its card, shows the fields the list loaded at once, with placeholders for the others, and takes input once the whole record has loaded; actions, custom components, maps and galleries wait for it. What the page shows is read again whenever the browser tab or window regains focus, as are the lists, unless the record has unsaved changes, which keep the version they were made to.
649
649
 
650
+ ### Full-area record pages
651
+
652
+ `.record({ component })` makes the record page at `/<resource>/<key>` a [custom component](custom-components.md#full-area-record-pages) of the app's own, for a record that is used rather than filled in, such as a chat channel. The component fills the content area, at full width beside the sidebar and down to the bottom bar on a phone, and the page does not scroll, so the component scrolls its own parts, such as messages above a box that stays at the bottom. The sidebar, the top bar with its breadcrumb naming the record, the bottom bar and a right panel stay; the heading, Save, the action rail, the sections, the related records and the Details card are not drawn. A record that does not exist, or that the user may not read, shows the record page's usual notice, and the component is never drawn.
653
+
654
+ ```ts
655
+ export const ChannelChat = component('ChannelChat')
656
+
657
+ view<typeof channels>('channels').record({ component: ChannelChat })
658
+ ```
659
+
660
+ The standard record page, with the layout's sections, the related records, Edit and Delete, stays at the record's address with `?standard=true` (`{ kind: 'record', resource, key, standard: true }`), which the component links to. Links to the record, from relations, search and notifications, open the component's page. Without the component, from a plugin that is off for instance, and when it throws, the standard page shows instead. <gap>A full-area record component cannot take props from the view because props for `.record` are not implemented.</gap>
661
+
650
662
  ### Read view and edit
651
663
 
652
664
  `.recordMode(mode)` says how the record page opens to a user who may change the record: