@protobase/cli 0.41.0 → 0.42.0
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.
- package/dist/cli/package.js +1 -1
- package/package.json +6 -6
- package/skills/protobase/references/features/ai.md +2 -1
- package/skills/protobase/references/features/composed-pages.md +1 -1
- package/skills/protobase/references/features/list-displays.md +2 -2
- package/skills/protobase/references/features/lists.md +5 -5
- package/skills/protobase/references/features/record-pages.md +6 -4
- package/skills/protobase/references/features/your-own-code.md +1 -0
- package/skills/protobase/references/guides/api-functions.md +2 -1
- package/skills/protobase/references/guides/table-to-admin.md +1 -1
- package/skills/protobase/references/reference/assistant.md +1 -1
- package/skills/protobase/references/reference/cli.md +1 -1
- package/skills/protobase/references/reference/client.md +1 -1
- package/skills/protobase/references/reference/layouts.md +1 -1
- package/skills/protobase/references/reference/mcp.md +20 -7
- package/skills/protobase/references/reference/ui-config.md +22 -10
package/dist/cli/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
4
4
|
"description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"@better-auth/core": "^1.7.12",
|
|
37
37
|
"@hono/node-server": "^2.1.3",
|
|
38
38
|
"@hono/vite-dev-server": "^0.26.1",
|
|
39
|
-
"@protobase/layout": "0.
|
|
40
|
-
"@protobase/query": "0.
|
|
41
|
-
"@protobase/schema": "0.
|
|
42
|
-
"@protobase/server": "0.
|
|
43
|
-
"@protobase/ui": "0.
|
|
39
|
+
"@protobase/layout": "0.42.0",
|
|
40
|
+
"@protobase/query": "0.42.0",
|
|
41
|
+
"@protobase/schema": "0.42.0",
|
|
42
|
+
"@protobase/server": "0.42.0",
|
|
43
|
+
"@protobase/ui": "0.42.0",
|
|
44
44
|
"@react-email/render": "^2.1.0",
|
|
45
45
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
46
46
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -10,5 +10,6 @@ Fields and actions filled by a model, the assistant beside the admin, and MCP.
|
|
|
10
10
|
- [Choice of model](../reference/assistant.md#which-backend): The assistant runs on OpenRouter or any OpenAI-compatible endpoint, also a local one.
|
|
11
11
|
- [Assistant tools](../reference/assistant.md#the-apps-own-tools): Your own tools for the assistant, acting on records as the user.
|
|
12
12
|
- [MCP server](../reference/mcp.md#the-tools): AI clients connect to the app over MCP as the signed-in person, and list, find and read records within that person's access.
|
|
13
|
-
- [MCP writes](../reference/mcp.md#writes): When turned on, for every resource or only those you list, AI clients create and
|
|
13
|
+
- [MCP writes](../reference/mcp.md#writes): When turned on, for every resource or only those you list, AI clients create, update and delete records after the person approves each write.
|
|
14
|
+
- [MCP writes without approval](../reference/mcp.md#writes-without-approval): Roles you name, such as service accounts, write over MCP without being asked to approve each write; everyone else is still asked.
|
|
14
15
|
- [Connected apps](../reference/auth.md#oauth-for-mcp-clients): People allow an AI client to sign in, and disconnect it later.
|
|
@@ -13,6 +13,6 @@ Pages of your own, built from blocks in a JSX layout.
|
|
|
13
13
|
- [Data blocks](../reference/blocks.md#data): Counts, tables, single records, rows of cards, field values and progress bars.
|
|
14
14
|
- [Record rows](../reference/blocks.md#recordrow): A sideways row of cards for a filter, favorites or saved searches, with a count and new-record marks.
|
|
15
15
|
- [Record cards](../reference/blocks.md#recordcards): Full-width cards with fields and buttons, stacked or in a carousel.
|
|
16
|
-
- [Chart block](../reference/blocks.md#chart): Counts, sums or averages by value or by date, as bars, lines or a donut.
|
|
16
|
+
- [Chart block](../reference/blocks.md#chart): Counts, sums or averages by value or by date, as bars, lines or a donut, and over time split by a second field.
|
|
17
17
|
- [Buttons and forms](../reference/blocks.md#behaviour): Buttons for named actions, and create or edit forms in a dialog.
|
|
18
18
|
- [Users block](../reference/blocks.md#users): User management on any page: find users, set roles, block them and invite by email.
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
Show a list as cards, a map, a board, a calendar or a timeline, and reorder records by hand.
|
|
6
6
|
|
|
7
7
|
- [List displays](../reference/ui-config.md#list-displays): Besides a table, a list shows as cards, a map, a board, a calendar, a timeline or your own component, picked with a switch.
|
|
8
|
-
- [Cards](../reference/ui-config.md#list-displays): Records as cards with an image, title, subtitle, amount, badge and
|
|
8
|
+
- [Cards](../reference/ui-config.md#list-displays): Records as cards with an image, title, subtitle, amount, badge, meta icons, a footer line and flags, or drawn by your own card component.
|
|
9
9
|
- [Card photos](../reference/ui-config.md#card-photos): Cards step through a record's photos by swiping or with arrows.
|
|
10
|
-
- [Boards](../reference/ui-config.md#boards): Records in columns by status, with counts.
|
|
10
|
+
- [Boards](../reference/ui-config.md#boards): Records in columns by status, with counts. Where the list allows it, cards are dragged between columns by mouse, touch or keyboard.
|
|
11
11
|
- [Calendars](../reference/ui-config.md#calendars): Records by date in a month or week grid. Dragging an event to another day reschedules it.
|
|
12
12
|
- [Timelines](../reference/ui-config.md#timelines): Each record is a bar from start to end over a week, month or quarter, optionally in lanes. Dragging a bar moves its dates.
|
|
13
13
|
- [Maps](../reference/ui-config.md#maps): Records on a map with clustered counts, and a pin on the record page. Rough locations show as an area, and extra layers such as aerial photos can be switched on.
|
|
@@ -8,20 +8,20 @@ The list page of each resource, with its columns, filters, charts, search, expor
|
|
|
8
8
|
- [Field display hints](../reference/ui-config.md#names-and-columns): Labels, help lines, badges, codes, percentages, currencies, units, decimals and relative times such as "5 minutes ago".
|
|
9
9
|
- [Email, phone and web links](../reference/ui-config.md#names-and-columns): Fields marked as email, phone or URL show as links and are edited with the matching phone keyboard and browser autofill.
|
|
10
10
|
- [Markdown and long text](../reference/ui-config.md#names-and-columns): Long text is edited in a box that grows with it. Markdown fields have Write and Preview and show rendered on the record page.
|
|
11
|
-
- [Enum labels and colours](../reference/ui-config.md#names-and-columns): Enum values get readable labels and badge colours that show everywhere the value appears.
|
|
11
|
+
- [Enum labels and colours](../reference/ui-config.md#names-and-columns): Enum values get readable labels and badge colours that show everywhere the value appears, and badges can be drawn as arrows, as on a rating scale.
|
|
12
12
|
- [Pinned title column](../reference/ui-config.md#names-and-columns): Columns size to their content, and on desktop the title column stays in place while the table scrolls sideways.
|
|
13
|
-
- Pinned columns: A column's menu pins it to the left edge of the table, and
|
|
13
|
+
- [Pinned columns](../reference/ui-config.md#names-and-columns): A column's menu pins it to the left edge of the table, and the browser keeps the pins for each list.
|
|
14
14
|
- [Related records as dots](../reference/ui-config.md#related-records-in-a-list): A list column or card shows linked records as coloured status dots, with the record's card on hover.
|
|
15
15
|
- [Editing in the list](../reference/ui-config.md#editing-in-the-list): Chosen columns are edited in their cells, as in a spreadsheet, with keyboard navigation. Each change saves at once and is refused if someone else changed the record first.
|
|
16
16
|
- [Filters](../reference/ui-config.md#filters-and-the-chart): Value menus with counts, date presets, range sliders with histograms, toggles and flags. Less used filters wait under More filters.
|
|
17
|
-
- [Filters beside the list](../reference/client.md#the-admin-app): A list
|
|
17
|
+
- [Filters beside the list](../reference/client.md#the-admin-app): A list opened with `?layout=panel` shows its filters in a panel beside the table instead of a bar above it.
|
|
18
18
|
- [Default filter](../reference/ui-config.md#a-filter-the-list-opens-with): A list can open with a filter applied, shown as chips users can clear or change.
|
|
19
19
|
- [More than one list](../reference/ui-config.md#more-than-one-list): One resource can have several lists, each with its own sidebar entry, columns, filters and chart.
|
|
20
|
-
- [List charts](../reference/ui-config.md#filters-and-the-chart): A chart above a list shows records
|
|
20
|
+
- [List charts](../reference/ui-config.md#filters-and-the-chart): A chart above a list shows records per day or week, or per value, and follows the list's filters. Clicking a value filters the list to it.
|
|
21
21
|
- [Shareable list addresses](../reference/client.md#the-admin-app): Filters, sort, display and saved search are kept in the address, so a list can be bookmarked and shared.
|
|
22
22
|
- [Empty states](../reference/ui-config.md#filters-and-the-chart): An empty list says why it is empty and offers Clear search, Clear filters or New.
|
|
23
23
|
- [Long lists](../reference/ui-config.md#list-displays): Lists of any length scroll at once, drawing only the rows in view, and Back returns to the same place.
|
|
24
|
-
- [Saved searches](../reference/ui-config.md#saved-searches): Users save a filtered list as a named
|
|
24
|
+
- [Saved searches](../reference/ui-config.md#saved-searches): Users save a filtered list as a search, named if they like, update it later with a preview of what changes, and see which records are new since they last looked.
|
|
25
25
|
- [Favorites](../reference/ui-config.md#favorites): A heart on each card saves the record to the user's favorites, which a list page can show.
|
|
26
26
|
- [Sign-in prompts](../reference/ui-config.md#sign-in-prompts): Visitors who are not signed in see what signing in gives them, in place of a list or when they press favorite or save search.
|
|
27
27
|
- [Export to Excel and CSV](../reference/ui-config.md#exports): Any list, or the selected rows, is saved as an Excel or CSV file with the columns the user picks.
|
|
@@ -6,15 +6,17 @@ The page of one record, with its sections, related records, galleries, charts an
|
|
|
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
8
|
- [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
|
-
- [Unsaved edits](../reference/ui-config.md#
|
|
9
|
+
- [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
|
+
- [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.
|
|
10
11
|
- [Save feedback](../reference/ui-config.md#the-record-page): A view shows saving on the Save button instead of in a toast.
|
|
11
|
-
- Save conflicts: When someone else changed a record while you edited it, Save shows their value beside yours for each field you both changed, and you keep yours or take theirs.
|
|
12
|
+
- [Save conflicts](../reference/ui-config.md#editing-a-record): When someone else changed a record while you edited it, Save shows their value beside yours for each field you both changed, and you keep yours or take theirs.
|
|
12
13
|
- [Groups and tabs](../reference/ui-config.md#groups): Parts of a record page sit under headings that open on click, or in tabs, and the open ones are kept in the address.
|
|
13
14
|
- [Key facts](../reference/ui-config.md#key-facts): A section shows its values side by side with icons.
|
|
15
|
+
- [Help while editing](../reference/ui-config.md#help-while-editing): Help lines meant for whoever changes a record show only on its form.
|
|
14
16
|
- [Conditional sections](../reference/ui-config.md#form-and-read-view): Sections and fields show only while editing, only while reading, or only when a condition on the record holds.
|
|
15
17
|
- [Galleries](../reference/ui-config.md#galleries): A record's photos show as tiles that open a full-screen lightbox, with keyboard and swipe navigation.
|
|
16
|
-
- [Related records](../reference/ui-config.md#related-records): Every record page shows how many records point at it, and can list related records as a table, another display or cards with buttons.
|
|
18
|
+
- [Related records](../reference/ui-config.md#related-records): Every record page shows how many records point at it, and can list related records, also through a join resource, as a table, another display or cards with buttons.
|
|
17
19
|
- Record lines: Lines that belong to a record, with a position and a quantity, such as those of an invoice, show as a table with totals on its page. You drag them into a new order, and Save writes the record and the order together.
|
|
18
20
|
- [Charts of samples](../reference/ui-config.md#charts-of-related-records): A record page graphs numeric samples over the last hour, day or week, such as a server's CPU use.
|
|
19
21
|
- [Fresh data on return](../reference/ui-config.md#the-record-page): Records and lists reload when the browser tab is focused again, keeping unsaved edits.
|
|
20
|
-
- Safe deletes: Deleting asks first, offers a review when the record changed since it was opened, and
|
|
22
|
+
- [Safe deletes](../reference/ui-config.md#deleting-a-record): Deleting asks first, or offers Undo for a soft delete, offers a review when the record changed since it was opened, and names the records that still point at it.
|
|
@@ -11,6 +11,7 @@ React components, field types, pages and handlers of your own, loaded as plugins
|
|
|
11
11
|
- [Custom field types](../reference/plugins.md#field-types): Register how a kind of value is shown and edited, and pick it per field in a view.
|
|
12
12
|
- [Custom create pages](../reference/custom-components.md#create-pages): Replace a resource's create form with your own page, such as a booking flow.
|
|
13
13
|
- [Form parts](../reference/custom-components.md#form-parts): Build your own forms from the app's fields, pickers, switches, buttons and dialogs.
|
|
14
|
+
- [Assistant parts](../reference/assistant.md#in-the-ui): The assistant's panel, chat messages, composer and action cards for your own components, with a frameless action card for a page that is already framed.
|
|
14
15
|
- [Action handlers](../reference/custom-components.md#action-handlers): Your own code for a named action, with the record, the API client and the action's inputs.
|
|
15
16
|
- [Shell slots](../reference/custom-components.md#shell-slots): Your own components in the top bar, in a panel beside every page, or as the sidebar logo.
|
|
16
17
|
- [Plugins](../reference/plugins.md#how-a-plugin-stays-working): Your React code is a plugin that the app loads at start and that keeps working across Protobase releases without changes.
|
|
@@ -47,7 +47,7 @@ The second argument of a handler (`c.env` in a [Hono app](#hono-apps)):
|
|
|
47
47
|
| | |
|
|
48
48
|
| --- | --- |
|
|
49
49
|
| `session` | The caller: `{ user: { id, roles }, tenant? }`, from the app's `authenticate`. |
|
|
50
|
-
| `records` | The app's resources, acting as the caller: `list`, `get`, `create`, `update`, `delete`. |
|
|
50
|
+
| `records` | The app's resources, acting as the caller: `list`, `get`, `create`, `update`, `delete`, `softDeleteField`. |
|
|
51
51
|
| `db` | The Kysely instance itself. It skips every access rule, row filter and tenant scope. |
|
|
52
52
|
| `caller()` | Resolves to `{ session, records }`. Public functions use it to ask for a caller when they need one. |
|
|
53
53
|
| `acceptWebSocket(events)` | Answers a WebSocket upgrade with a socket; return its response. See [WebSockets](#websockets). |
|
|
@@ -88,6 +88,7 @@ export default defineFunction({ roles: ['mechanic', 'desk'] }, async (request, {
|
|
|
88
88
|
| `create(resource, data)` | `{ record, etag }` of the new record. |
|
|
89
89
|
| `update(resource, key, data, { etag }?)` | With `etag`, it fails with `412` when the record changed after it was read. |
|
|
90
90
|
| `delete(resource, key, { etag }?)` | `{ record, etag }` of the record as it was. It is a soft delete when the resource has one. |
|
|
91
|
+
| `softDeleteField(resource)` | The field a delete sets when the resource has a soft delete, or `undefined` when a delete removes the record. |
|
|
91
92
|
|
|
92
93
|
A refusal or a missing record rejects with the problem the REST API would answer, such as `403`, `404` or `412`. Left uncaught, that problem becomes the function's response. Each call is its own transaction. Use the [batch endpoint](../reference/api.md#batch-writes) when several writes must succeed or fail together.
|
|
93
94
|
|
|
@@ -129,7 +129,7 @@ export const repairsView = named
|
|
|
129
129
|
.chart((r) => ({ field: r.booked_on, range: '30d', granularity: 'day' }))
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
-
From here on each step starts from the view of the step before (`named` is step 2's), so the file shows only what changes; in a project it is one view in one `ui.ts`. Each widget writes into the list's `?filter=`, so "ready and unpaid" is a link someone can send. The chart above the list, a daily graph, counts repairs per day, following the same filters; [UI config](../reference/ui-config.md#charts-graphs-records-per-day-
|
|
132
|
+
From here on each step starts from the view of the step before (`named` is step 2's), so the file shows only what changes; in a project it is one view in one `ui.ts`. Each widget writes into the list's `?filter=`, so "ready and unpaid" is a link someone can send. The chart above the list, a daily graph, counts repairs per day, following the same filters; [UI config](../reference/ui-config.md#charts-graphs-records-per-day-or-week-or-per-value-above-a-list) has its ranges and granularities. In the story, switch on "Paid" and watch the list drop to six.
|
|
133
133
|
|
|
134
134
|
## 4. The repair card
|
|
135
135
|
|
|
@@ -68,7 +68,7 @@ Making the query role needs `CREATEROLE` once, for the role that applies the mig
|
|
|
68
68
|
|
|
69
69
|
`options.assistant.tools` adds tools of the app's own, which the built-in backend offers after its two. A tool is `defineTool({ name, description, parameters, run })` from `@protobase/server`: `parameters` is the JSON Schema of its arguments, and `run(args, context)` returns the text the model reads. A name must be 1 to 64 letters, digits, `_` or `-`, and a name taken twice stops the server at startup. A backend elsewhere has its own tools, so the option does nothing there. A tool's `annotations` are MCP's tool hints (`readOnlyHint`, `destructiveHint`, ...), which the dock ignores; the same tools can be offered over the app's [MCP endpoint](mcp.md#building-on-it).
|
|
70
70
|
|
|
71
|
-
`context` holds the user's `session`, `show(part)` to add a part to the answer, `approve(request)` for an approval card, `conversation` (the dock's, absent over MCP), `resources()` (the resources the user may read, restricted to their fields, with their views), and `records`: `list(resource, params)` with the REST API's list parameters, `get(resource, key)`, `create(resource, data)
|
|
71
|
+
`context` holds the user's `session`, `show(part)` to add a part to the answer, `approve(request)` for an approval card, `conversation` (the dock's, absent over MCP), `resources()` (the resources the user may read, restricted to their fields, with their views), and `records`: `list(resource, params)` with the REST API's list parameters, `get(resource, key)`, `create(resource, data)`, `update(resource, key, data, { etag? })` (without an ETag it updates any version), `delete(resource, key, { etag? })` (soft on a resource with `.softDelete()`) and `softDeleteField(resource)` (the field a delete sets, or `undefined` when a delete removes the record) on the app's resources **as the user**, through their access rules, tenant scope, validation and write hooks, as in the REST API. Each answers `{ record, etag }`; a refusal or a missing record rejects with an `HttpProblem`, whose `detail` a tool can return to the model as text.
|
|
72
72
|
|
|
73
73
|
A tool with a [widget](#widget-parts) creates or finds what it is about, shows a widget with its id, and returns the id and the state at that moment:
|
|
74
74
|
|
|
@@ -82,7 +82,7 @@ protobase doctor <connection string | --env VAR> [--config <dir>]
|
|
|
82
82
|
Imports `config/index.ts` and the views of `config/*/ui.ts`, as the config module has them by convention, and checks every exported resource against the database:
|
|
83
83
|
|
|
84
84
|
- error: missing table or column, field type that does not fit the column (a file field needs a text column), table without a usable key, configured key not backed by a unique index
|
|
85
|
-
- error: a read the [scan guard](api.md#safety) refuses, because no index serves a column it filters, sorts, searches or counts by. Doctor reads each table's indexes from the catalog, as the server does, and judges with the scan guard's own rule every read the API takes and the app makes: a filter on each `.filterable()` field, a sort by each `.sortable()` one, `search()` over the search fields, a role's own records (`.owner()`) and the names a relation shows; each view's list in its order, its filter widgets and their counts, its map and card photos, its related sections, its recent records and a saved search's new records; and each block of a [composed page](layouts.md) that lists records. Each error is an index to add, with every request that needs it and where it comes from:
|
|
85
|
+
- error: a read the [scan guard](api.md#safety) refuses, because no index serves a column it filters, sorts, searches or counts by. Doctor reads each table's indexes from the catalog, as the server does, and judges with the scan guard's own rule every read the API takes and the app makes: a filter on each `.filterable()` field, a sort by each `.sortable()` one, `search()` over the search fields, a role's own records (`.owner()`) and the names a relation shows; each view's list in its order and with the filter it opens with, its filter widgets and their counts, its chart, its map, board, calendar and timeline, its card photos, its order by hand, its related sections, galleries and charts, its named lists, its recent records and a saved search's new records; and each block of a [composed page](layouts.md) that lists records, and each `Chart` block's grouped and split fields. Each error is an index to add, with every request that needs it and where it comes from:
|
|
86
86
|
|
|
87
87
|
```
|
|
88
88
|
error agencies: no index serves the column "name", so the API refuses:
|
|
@@ -23,7 +23,7 @@ With an absolute `baseUrl`, such as another app's `https://desk.example.com/api/
|
|
|
23
23
|
|
|
24
24
|
## The admin app
|
|
25
25
|
|
|
26
|
-
`<App baseUrl="/api/v1" />` renders the shell from `/api/meta` (beside the API, so `createClient` derives it from `baseUrl`) and routes `/:page` ([composed pages](layouts.md)), `/:resource` (list) and `/:resource/:key` (record); it opens on the first page, or the first resource. Its own pages sit under `/-/`, which no page or resource name takes: `/-/account` (the user's passkeys and two-factor authentication) and `/-/sign-in-policy` (admins: the policy, and the log of staff sign-ins). Before the shell, it signs in on its sign-in route, `/-/sign-in`, with the methods the server offers and asks for what the [sign-in policy](auth.md#sign-in-policy) requires. Someone signed out goes there from any page, with that page in `?next=`, and signing in comes back to it; each step (a forgotten password, an emailed code, making an account) adds `?step=`, so the browser's Back returns to the step before; `?staff-sign-in` opens the [staff sign-in](auth.md#staff-sign-in) page instead, and a staff session gets a banner above the shell. `createAuthSession` from `@protobase/client` is that session (`signIn`, `signInWithCode`, `signInWithPasskey`, `verifyTwoFactor`, `account`, `signInPolicy`, `staff`). `ui` takes the project's [custom components and action handlers](custom-components.md). The list state lives in the URL: `?filter=` (AIP-160), `?order_by=`, `?layout=panel`, `?calendar=month,2026-10-01`, the month or week a [calendar](ui-config.md#calendars) shows, `?timeline=quarter,2026-10-01`, the week, month or quarter a [timeline](ui-config.md#timelines) shows, and `?saved_search=`, the [saved search](ui-config.md#saved-searches) the list was opened from. Views come from `examples/*/config/*/ui.ts`. The sidebar's recent-record groups and the user menu are configured there too: see [Sidebar](sidebar.md), [User menu](user-menu.md) and [Bottom bar](bottom-bar.md).
|
|
26
|
+
`<App baseUrl="/api/v1" />` renders the shell from `/api/meta` (beside the API, so `createClient` derives it from `baseUrl`) and routes `/:page` ([composed pages](layouts.md)), `/:resource` (list) and `/:resource/:key` (record); it opens on the first page, or the first resource. Its own pages sit under `/-/`, which no page or resource name takes: `/-/account` (the user's passkeys and two-factor authentication) and `/-/sign-in-policy` (admins: the policy, and the log of staff sign-ins). Before the shell, it signs in on its sign-in route, `/-/sign-in`, with the methods the server offers and asks for what the [sign-in policy](auth.md#sign-in-policy) requires. Someone signed out goes there from any page, with that page in `?next=`, and signing in comes back to it; each step (a forgotten password, an emailed code, making an account) adds `?step=`, so the browser's Back returns to the step before; `?staff-sign-in` opens the [staff sign-in](auth.md#staff-sign-in) page instead, and a staff session gets a banner above the shell. `createAuthSession` from `@protobase/client` is that session (`signIn`, `signInWithCode`, `signInWithPasskey`, `verifyTwoFactor`, `account`, `signInPolicy`, `staff`). `ui` takes the project's [custom components and action handlers](custom-components.md). The list state lives in the URL: `?list=`, a [named list](ui-config.md#more-than-one-list), `?filter=` (AIP-160), `?order_by=`, `?display=`, the [display](ui-config.md#list-displays) it shows, `?layout=panel`, the filters in a panel beside the table on a desktop instead of a bar above it, `?map=52.37,4.89,12`, where a [map](ui-config.md#maps) looks, `?calendar=month,2026-10-01`, the month or week a [calendar](ui-config.md#calendars) shows, `?timeline=quarter,2026-10-01`, the week, month or quarter a [timeline](ui-config.md#timelines) shows, and `?saved_search=`, the [saved search](ui-config.md#saved-searches) the list was opened from. Views come from `examples/*/config/*/ui.ts`. The sidebar's recent-record groups and the user menu are configured there too: see [Sidebar](sidebar.md), [User menu](user-menu.md) and [Bottom bar](bottom-bar.md).
|
|
27
27
|
|
|
28
28
|
## Global search
|
|
29
29
|
|
|
@@ -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? }` | 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). |
|
|
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>`). |
|
|
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 }` | A composed page. |
|
|
111
111
|
|
|
@@ -53,7 +53,7 @@ It runs one `SELECT` in a read-only transaction, as the app's database role, **o
|
|
|
53
53
|
|
|
54
54
|
### Writes
|
|
55
55
|
|
|
56
|
-
`createAdmin`'s `options.mcp.writes` also offers
|
|
56
|
+
`createAdmin`'s `options.mcp.writes` also offers three tools that change records, to everyone signed in:
|
|
57
57
|
|
|
58
58
|
```ts
|
|
59
59
|
createAdmin({ ..., auth, options: { mcp: { writes: true } } })
|
|
@@ -62,11 +62,12 @@ createAdmin({ ..., auth, options: { mcp: { writes: true } } })
|
|
|
62
62
|
| Tool | What it does |
|
|
63
63
|
| --- | --- |
|
|
64
64
|
| `create_record` | Creates a record of a resource from `data`, field names to values, and returns it with its ETag. |
|
|
65
|
-
| `update_record` | Changes the fields in `data` of one record by its key, and returns it with its new ETag. With the `etag` that `get_record` gave, it fails when someone changed the record since. |
|
|
65
|
+
| `update_record` | Changes the fields in `data` of one record by its key, and returns it with its new ETag. With the `etag` that `get_record` gave, it fails when someone changed the record since. It does not set the field a soft delete sets: a delete goes through `delete_record`. |
|
|
66
|
+
| `delete_record` | Deletes one record by its key and the `etag` that `get_record` gave, and fails when someone changed the record since. A resource with a [soft delete](data-config.md) keeps the record, deleted; any other loses it for good. |
|
|
66
67
|
|
|
67
68
|
Each write goes through the REST API as the person: their role's access rules, `validate`, write hooks, events and webhooks apply, so the client can do only what the person may do in the app.
|
|
68
69
|
|
|
69
|
-
Before each write the client asks the person to approve it, showing the resource and the data, through MCP's form elicitation. Nothing is written until they approve, and declining writes nothing. A client's own setting that always allows a tool is not this approval. A client that cannot ask, one without form elicitation or one on the 2025 protocol, gets each write refused with a message saying so.
|
|
70
|
+
Before each write the client asks the person to approve it, showing the resource and the data, or for a delete the resource, the key and whether the record can be restored, through MCP's form elicitation. For a resource without a soft delete, the approval says plainly that the delete cannot be undone. Nothing is written until they approve, and declining writes nothing. A client's own setting that always allows a tool is not this approval. A client that cannot ask, one without form elicitation or one on the 2025 protocol, gets each write refused with a message saying so.
|
|
70
71
|
|
|
71
72
|
To offer the writes on some resources only, list them:
|
|
72
73
|
|
|
@@ -76,7 +77,19 @@ createAdmin({ ..., auth, options: { mcp: { writes: { resources: ['tasks'] } } }
|
|
|
76
77
|
|
|
77
78
|
The write tools then name those resources in their descriptions, and refuse a write to any other before asking, with `{ "error": "forbidden", "message": ... }` saying which resources they write; nothing is written. A name the app has no resource for stops the server at startup. The list only narrows the writes: the person's access rules still apply on the listed resources.
|
|
78
79
|
|
|
79
|
-
|
|
80
|
+
#### Writes without approval
|
|
81
|
+
|
|
82
|
+
An app that runs service accounts over MCP, such as a backend job or an agent with no person present, names their roles in `options.mcp.writes`:
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
createAdmin({ ..., auth, options: { mcp: { writes: { resources: ['tasks'], rolesWithoutApproval: ['service'] } } } })
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
A user with one of those roles creates, updates and deletes records over MCP without the approval step: the client is never asked, so a client that cannot ask writes too. Their role's access rules and the listed resources still limit every write as before, so a job with no person present can keep the app's data over MCP and do nothing there it could not do through the REST API. Everyone else is still asked before each write.
|
|
89
|
+
|
|
90
|
+
No role is exempt unless named. The roles are checked against the signed-in user, not against the client, and a user holding several is exempt when any of them is named. A name that is not one of the app's roles, or is `anonymous`, stops the server at startup. Naming a role a person signs in with lets any client that person allows write as them unasked.
|
|
91
|
+
|
|
92
|
+
A deleted record cannot be restored over MCP, and there is no SQL that writes.
|
|
80
93
|
|
|
81
94
|
## Browsers and hosts
|
|
82
95
|
|
|
@@ -89,9 +102,9 @@ The endpoint serves each request on its own, without an MCP session: a `GET` or
|
|
|
89
102
|
`@protobase/server` exports the pieces the endpoint is made of, for an MCP server of your own with tools of your own:
|
|
90
103
|
|
|
91
104
|
- `mcpHandler({ authenticate, resource, scope, server })`: the endpoint as a fetch handler. It checks the host, admits a valid token (`mcpGate`) and serves the request with the server that `server(session)` builds for its caller.
|
|
92
|
-
- `mcpServer({ info, tools, context, report })`: an MCP server offering [assistant tools](assistant.md#the-apps-own-tools), each with its JSON Schema and its `annotations`, MCP's tool hints. `context` is the tools' context without `approve`: each call gets its own, which asks the client's user
|
|
93
|
-
- `mcpTools({ db, sql, writes })`: the default tools for a session; `writes` is `true`, `false` or `{ resources }`.
|
|
94
|
-
- `writeRecordTools({ resources })`, or `createRecordTool(...)` and `
|
|
105
|
+
- `mcpServer({ info, tools, context, report, rolesWithoutApproval })`: an MCP server offering [assistant tools](assistant.md#the-apps-own-tools), each with its JSON Schema and its `annotations`, MCP's tool hints. `context` is the tools' context without `approve`: each call gets its own, which asks the client's user, or approves at once when the session's user holds one of `rolesWithoutApproval`.
|
|
106
|
+
- `mcpTools({ db, sql, writes })`: the default tools for a session; `writes` is `true`, `false` or `{ resources, rolesWithoutApproval }`.
|
|
107
|
+
- `writeRecordTools({ resources })`, or `createRecordTool(...)`, `updateRecordTool(...)` and `deleteRecordTool(...)`: the write tools alone, on the listed resources or, without `resources`, on any.
|
|
95
108
|
- `mcpGate({ authenticate, resource, scope })`: the token check alone, answering 401 or 403 with a challenge that names the resource's metadata.
|
|
96
109
|
- `mcpToolContext(...)`, `mcpRoutes(app, { path, handler })` and `sessionOf(authInfo)`: the tools' context as the app builds it, the routes with open CORS, and the session a request was admitted with.
|
|
97
110
|
|
|
@@ -70,8 +70,8 @@ Field hints:
|
|
|
70
70
|
| `.label(text)` | Instead of the name in words (`customer_id` would be "Customer" anyway). |
|
|
71
71
|
| `.help(text, { when? })` | A line under the field on the record page and in forms. `when: 'editing'` shows it only while the record is edited; see [Help while editing](#help-while-editing). |
|
|
72
72
|
| `.format(format)` | `badge` shows statuses as coloured badges, `code` sets identifiers in monospace, `percent` adds a % sign. On a text field, `email`, `phone` and `url` show the value as a link that writes to it (`mailto:`), calls it (`tel:`, its digits and a leading +) or opens it in a new tab (only an `http` or `https` address; anything else stays text), on the record page, in its sidebar and in the list's cells but the title's, which links to the record; forms edit it in an email, phone or web address input, which brings up the keyboard for it on a mobile screen and offers the browser's autofill. Another field type with one of them stops the server at startup. `relative` on a timestamp shows it as "5 minutes ago" or "in 2 hours" in lists and on the record page, with the exact time on hover; `absolute` and `compact` are accepted and carried in `/meta` for apps that render their own lists, and the admin does not use them yet. |
|
|
73
|
-
| `.multiline()` | A text of several lines, such as a description: forms edit it in a box that grows with the text, so the page scrolls rather than the box, and the record page, a page's field blocks and a card's subtitle keep its line breaks (a card shows the first three lines). On the record page and the create form it takes the whole width of its section. Only a text field takes it; the list's table shows the text on one line. |
|
|
74
|
-
| `.markdown()` | Markdown, such as a task's notes: forms edit its source in a box that grows with it, with a Write and Preview switch above it, and store it exactly as typed. The record page
|
|
73
|
+
| `.multiline()` | A text of several lines, such as a description: forms edit it in a box that grows with the text, so the page scrolls rather than the box, and the record page's sections, a page's field blocks and a card's subtitle keep its line breaks (a card shows the first three lines); the record's sidebar shows it on one line. On the record page and the create form it takes the whole width of its section. Only a text field takes it; the list's table shows the text on one line. |
|
|
74
|
+
| `.markdown()` | Markdown, such as a task's notes: forms edit its source in a box that grows with it, with a Write and Preview switch above it, and store it exactly as typed. The record page's sections and a page's field blocks show it rendered as GitHub does, line breaks kept; raw HTML shows as text, links and images keep only http(s), mailto, tel and relative addresses, and links open in a new tab. A card's subtitle shows its first three lines rendered, its links as text; the list's table, the record's sidebar and a card's other lines show its text on one line without the marks. On the record page and the create form it takes the whole width of its section. Only a text field takes it, and the renderer loads with the first markdown shown. |
|
|
75
75
|
| `.prefix(text)`, `.suffix(text)`, `.decimals(n)` | Money and measures: `€` and `2` show `€1,234.50`, `.suffix(' m²')` shows `120 m²`. They show wherever the number does: records, cards, table cells, forms and the range filter. |
|
|
76
76
|
| `.icon(name)` | An icon before the value on a card's meta row: one of the names [actions](layouts.md#named-actions) take, such as `bed`, `calendar` or `cpu`, and above the value in a section of [key facts](#key-facts). Nowhere else shows it. |
|
|
77
77
|
| `.valueLabels({ value: text })` | How an enum's values read: `r.method.valueLabels({ ideal: 'iDEAL' })`. Only the enum's values are accepted. A value without a label shows as stored (`direct_debit`), so label every value that should read as words. |
|
|
@@ -80,7 +80,7 @@ Field hints:
|
|
|
80
80
|
|
|
81
81
|
An enum's value labels show everywhere the admin shows its values: badges, select options, list and related-table cells, filter options and chips, record titles, the sidebar and search results. They are part of the view in `/api/meta`, so an app with its own screens can show them too, and [`enumLabel(value, labels)`](https://docs.protobase.net/api/schema/functions/enumlabel/) from `@protobase/schema` reads a value the same way. A label for a value the enum does not have stops the server at startup, so renaming a value cannot leave a stale label behind.
|
|
82
82
|
|
|
83
|
-
The table's columns take their width from the first rows it shows, and keep it while it scrolls, filters and sorts: the `.title` column gets the largest share, other text a share as long as its values, and short values such as enums, booleans, numbers, amounts and dates their own width whole. A value cut short shows whole when hovered. On a desktop the title column is pinned to the left by default, with the column before it when it is the second, so it stays in view when the table scrolls sideways; the column menu unpins it, and the choice is kept. Embedded lists and a page's `Table` blocks size their columns the same way.
|
|
83
|
+
The table's columns take their width from the first rows it shows, and keep it while it scrolls, filters and sorts: the `.title` column gets the largest share, other text a share as long as its values, and short values such as enums, booleans, numbers, amounts and dates their own width whole. A value cut short shows whole when hovered. On a desktop the title column is pinned to the left by default, with the column before it when it is the second, so it stays in view when the table scrolls sideways; the column menu unpins it, and pins any other column to the left edge, and the choice is kept in the browser for that list. The row menu stays at the table's right edge as it scrolls sideways. Embedded lists and a page's `Table` blocks size their columns the same way.
|
|
84
84
|
|
|
85
85
|
### Related records in a list
|
|
86
86
|
|
|
@@ -331,9 +331,9 @@ A list without rows says why, in the table, the cards and the phone's List alike
|
|
|
331
331
|
|
|
332
332
|
Every widget takes `secondary: true` (e.g. `w.facets(r.agent, { secondary: true })`): it waits behind the bar's **More filters** menu until it is picked there, and shows in the bar whenever it is set, such as from the address. The panel layout and the phone's filter sheet show every filter.
|
|
333
333
|
|
|
334
|
-
### Charts (graphs): records per day
|
|
334
|
+
### Charts (graphs): records per day or week, or per value, above a list
|
|
335
335
|
|
|
336
|
-
A list can show a graph of how many of its records fall on each
|
|
336
|
+
A list can show a graph of how many of its records fall on each day or week, such as a daily graph of new listings. `.chart((r) => ({ field, range, granularity }))` draws the list's records per day over a date or timestamp field as bars above the list, following its filters, headed by their total and how much the second half of the bars differs from the first. `range` is how far back it reaches: `7d`, `30d`, `90d`, `1y` or `all`. A **Day** and **Week** switch changes the bars, and **Week** shows the last 12 weeks whatever the range; `granularity: 'week'` opens it on weeks. `hour` and `month` are accepted and show days. Its bars do not filter the list.
|
|
337
337
|
|
|
338
338
|
It can show the list's records per value of a field instead, such as orders per status or revenue per customer: `.chart((r) => ({ groupBy: r.status, type: 'donut' }))`. `groupBy` is a filterable field that is no date, such as an enum, a boolean or a relation, with an index that serves it; `type` is `bar` (the default, the largest first) or `donut`; `sum: r.total` or `average: r.total` adds up a numeric field instead of counting (a donut takes no average); `limit` is how many values it shows, 10 by default. Each value links to the list filtered to it, and follows the list's filters, its own terms on `groupBy` included. A date, file or JSON `groupBy`, or a `sum` of a field that is no number, stops the server at startup, and a user who cannot read one of its fields sees no chart. A page shows the same with the [`Chart`](blocks.md#chart) block.
|
|
339
339
|
|
|
@@ -383,7 +383,7 @@ export const repairsView = daily
|
|
|
383
383
|
| `d.timeline({ start, end?, group?, title? }, { name?, label?, icon? })` | A Gantt-style timeline: each record a row with a bar from its date or timestamp field `start` to `end`, or on its start day alone, over a week, a month or a quarter, in lanes by the values of `group`. Each bar is a link to its record showing `title` (default: the view's `.title`). Dragging a bar along its row, or moving it with the keyboard, saves the record with `start` and `end` moved by the same days. Named `timeline` unless `name` says otherwise. See [Timelines](#timelines). |
|
|
384
384
|
| `d.custom(Component, { name, label, fields, props?, icon? })` | The rows drawn by a [custom component](custom-components.md#list-displays). `fields` are the fields it shows, loaded with the names of the records relations point at; `props` are plain data, with `r.field` where it takes a field. |
|
|
385
385
|
|
|
386
|
-
With displays, the list page has a switch at the right of its title: the table first, then each display by its `label`, with its `icon` (`table`, `cards`, `kanban`, `board`, `list`, `calendar` or `
|
|
386
|
+
With displays, the list page has a switch at the right of its title: the table first, then each display by its `label`, with its `icon` (`table`, `cards`, `kanban`, `board`, `list`, `calendar`, `timeline` or `map`). Below the `md` breakpoint (768px) the switch is a menu of the same choices. The choice is in the address, `/repairs?display=cards`, so a reload, a bookmark or a shared link opens the same display; `default` names the display `/repairs` opens in, the table when it is left out. On a phone, below Tailwind's `sm` breakpoint (640px), a list with a cards display opens in it instead: the `default` when that is a cards display, else the first. A list without one opens in a built-in **List** there: a row per record with its `.title`, the first enum column as a badge on its right, and the next two columns but booleans on a muted line below, at `?display=rows`. The display menu offers the table beside it. A `?display=` in the address wins on any screen. A display without column headers has a sort menu over the sortable fields it shows, beside the filters, or below `md` in the filters sheet, whose button sits left of the search box. Selecting rows, deleting them in bulk and the row menu stay on the table, which every list keeps.
|
|
387
387
|
|
|
388
388
|
The table, the cards, a board, a calendar and a timeline scroll with the page, which is as tall as all their rows, with the browser's own scrolling: only the rows and cards in view are drawn and loaded, so a list of any length scrolls at once. Coming back to the table or the cards, by Back or by a link to the same list, shows the same rows at the same height, after a reload too; another sort or filter starts at the top. The table's header stays below the top bar while the page scrolls. Every card is as tall as the tallest one drawn at that width. A custom display scrolls with the page as well, as every other page of the app does; the map fills the screen between the top bar and a phone's bottom bar instead, and does not scroll. Where scrollbars take room, as on Windows, the page keeps room for one even while it fits, so the cards keep their width as the scrollbar comes and goes.
|
|
389
389
|
|
|
@@ -599,7 +599,7 @@ export const repairsView = filtered
|
|
|
599
599
|
| `l.section(title, fields, { help?, helpWhen?, presentation?, when? })` | A titled group of fields in the main column, editable where the user may write. `presentation: 'facts'` shows them on the read view as a row of [key facts](#key-facts). |
|
|
600
600
|
| `l.group(title, items, { collapsed?, when? })` | A heading over sections and related tables, closed until opened with `collapsed: true`. `when` also takes a [condition](#form-and-read-view). See [Groups](#groups). |
|
|
601
601
|
| `l.tab(title, items)` | A tab holding main-column items; a view's tabs show as one strip on the read view and the form. See [Tabs](#tabs). |
|
|
602
|
-
| `l.sidebar(fields, { when? })` | A summary card beside it, read-only. `when` also takes a [condition](#form-and-read-view). |
|
|
602
|
+
| `l.sidebar(fields, { when? })` | A summary card beside it, read-only, each value on one line, cut off with an ellipsis when it does not fit and shown whole on hover. `when` also takes a [condition](#form-and-read-view). |
|
|
603
603
|
| `l.related(title, { ... })` | A table or cards of the records of another resource that point at this one, in the main column. See [Related records](#related-records). |
|
|
604
604
|
| `l.custom(Component, { title?, props?, sidebar?, when? })` | A [custom component](custom-components.md#record-sections) where it is listed: in the main column under `title`, or with `sidebar: true` as a sidebar card. |
|
|
605
605
|
| `l.map(title, { latitude, longitude, zoom?, sidebar?, when? })` | A map with a pin at the record's position, in the main column or with `sidebar: true` as a sidebar card. See [Maps](#maps). |
|
|
@@ -706,11 +706,23 @@ view<typeof listings>('listings')
|
|
|
706
706
|
|
|
707
707
|
The read view shows the gallery; the form shows the cover photo's field and the table of photos to manage instead. The create form still offers every field the user may set: one only in items or fields meant for reading lands in its last section. A gallery's photo details leave out what the photo's own view shows only while editing. Lists, cards and filters show a field either way.
|
|
708
708
|
|
|
709
|
-
|
|
709
|
+
### Editing a record
|
|
710
|
+
|
|
711
|
+
The record's form and the create form edit each field as its type asks, under its label, with its help line and its error tied to the input for screen readers.
|
|
712
|
+
|
|
713
|
+
- **Relations.** A relation the user may change is picked from a list that opens under its box: typing narrows it, by the other resource's search fields, or else by its title, scrolling loads more, the arrow keys and Enter choose, and Escape closes it. On the record's form a link beside the box opens the chosen record. A relation the user may not change stays a link.
|
|
714
|
+
- **Numbers.** On a phone, an integer field brings up a number keyboard and a decimal field a decimal one. A number field reads a number as the browser's language writes it: in Dutch or German `12,50` is 12.50 and `1.234` is 1234, with the point taken as a decimal one too when the number cannot be grouped (`12.50`); in English `1,234.5` is 1234.5.
|
|
715
|
+
- **A refused save.** When the server turns a save down, each field it names says what is wrong under it, in the words of its label, such as "Country is required" or "Enter a date", the toast, or with `.saveFeedback('button')` a banner over the form, says how many fields to check, and the first of them takes the focus, on its own tab when the page has [tabs](#tabs). A [`.validate()`](data-config.md#resource) rule's message shows as the rule words it.
|
|
716
|
+
- **Save conflicts.** When someone else saved the record after it was opened, Save writes nothing over their change: the form takes in the record as it is now, keeps your changes, and each field you both changed shows the value saved in the meantime, with **Keep mine** and **Use theirs**. The next Save writes what you kept.
|
|
717
|
+
- **Leaving.** Leaving a page with changes not yet saved, by a link, a reload or closing the tab, asks first. The record's form keeps its changes in the browser, so they come back when the record opens again; the create page, a [`ModalForm`](blocks.md#modalform) and a comment being written lose theirs, and the question says so.
|
|
718
|
+
|
|
719
|
+
### Deleting a record
|
|
720
|
+
|
|
721
|
+
**Delete**, in the action rail of a user who may delete the record, asks first. A resource with a [soft delete](data-config.md#resource) deletes at once instead, and the toast offers **Undo**, which brings the record back. When someone saved the record after it was opened, the delete stops and says so, with **Review changes**, which shows the record as it is now, and **Delete anyway**. When other records still point at it, the delete is refused and the toast names them, such as "Orders still point at this company.", with a link to their list filtered on this record when the user may read it. Deleting a list's selected rows asks once, deletes only the rows that did not change since the list loaded, and lists each record it kept and why.
|
|
710
722
|
|
|
711
723
|
### Galleries
|
|
712
724
|
|
|
713
|
-
`l.gallery(title, { image?, photos? })` shows a record's photos as tiles in the main column: one large
|
|
725
|
+
`l.gallery(title, { image?, photos? })` shows a record's photos as tiles in the main column: one large and up to four smaller beside it, the last counting the photos not drawn ("+12"). On a mobile screen it draws the large one with the number of photos. A tile opens a lightbox at its photo, at full size over the page, with a counter, arrows and the left and right keys to step through them all, stopping at the first and the last, a sideways swipe on a touch screen, and Escape or the close button to return. `image` is a file field of the record, shown first; `photos` names the records holding the further photos, as a cards display's [`photos`](#card-photos) does: those of `resource` whose relation `field` points at the record, in `sort` order, each shown by its file field `image`. A photo that is also the record's `image` is shown once, and files that are no image are left out. A record without photos has no gallery.
|
|
714
726
|
|
|
715
727
|
```ts
|
|
716
728
|
.layout((r) => [
|
|
@@ -732,7 +744,7 @@ The photos are read with the list API under the user's own access, up to 500, so
|
|
|
732
744
|
])
|
|
733
745
|
```
|
|
734
746
|
|
|
735
|
-
The map is drawn with [MapLibre](https://maplibre.org) from the style the server names: `createAdmin`'s `options.maps.style`, else `PROTOBASE_MAP_STYLE_URL`, an http(s) URL of a MapLibre style. The style's sources may be [PMTiles](https://docs.protomaps.com/pmtiles/) archives (`pmtiles://https://...`), so the tiles can be one file on a bucket of your own. The tiles, sprites and fonts are fetched by the browser, so their host must answer the app's origins with CORS, and an archive with range requests. Without a style there is no map, nor is there one for a record whose fields hold no position or for a user who may not read them. MapLibre loads with the first map drawn, so a page without one does not load it.
|
|
747
|
+
The map is drawn with [MapLibre](https://maplibre.org) from the style the server names: `createAdmin`'s `options.maps.style`, else `PROTOBASE_MAP_STYLE_URL`, an http(s) URL of a MapLibre style; `options.maps: false` turns maps off whatever the variable says, and a style that is no http(s) URL stops the server at startup. The style's sources may be [PMTiles](https://docs.protomaps.com/pmtiles/) archives (`pmtiles://https://...`), so the tiles can be one file on a bucket of your own. The tiles, sprites and fonts are fetched by the browser, so their host must answer the app's origins with CORS, and an archive with range requests. Without a style there is no map, nor is there one for a record whose fields hold no position or for a user who may not read them. MapLibre loads with the first map drawn, so a page without one does not load it.
|
|
736
748
|
|
|
737
749
|
A map display takes two number fields that are `.filterable()`, since it asks for the records inside its view with a filter on them, and the server refuses to start otherwise; an index on them, such as `(latitude, longitude)`, lets Postgres find those records. The filter and search of the list narrow what it shows. Where it looks is in the address, `/listings?display=map&map=52.37,4.89,12` (latitude, longitude, zoom), so Back, a reload or a shared link opens the same view; without one it fits every matching record. When none is in view, **Show all** fits them again.
|
|
738
750
|
|