@protobase/cli 0.95.15 → 0.96.1
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/dist/doctor/page-shapes.js +20 -1
- package/dist/doctor/view-shapes.js +17 -13
- package/dist/mobile/capacitor-config.js +6 -3
- package/dist/mobile/package.js +1 -1
- package/package.json +8 -8
- package/skills/protobase/references/features/composed-pages.md +2 -0
- package/skills/protobase/references/getting-started.md +2 -2
- package/skills/protobase/references/guides/mobile-app.md +1 -1
- package/skills/protobase/references/reference/blocks.md +30 -1
- package/skills/protobase/references/reference/cli.md +6 -4
- package/skills/protobase/references/reference/layouts.md +40 -0
- package/skills/protobase/references/reference/ui-config.md +2 -1
package/dist/cli/package.js
CHANGED
|
@@ -45,7 +45,25 @@ const chartShapes = (page, node, model) => {
|
|
|
45
45
|
}
|
|
46
46
|
}]];
|
|
47
47
|
};
|
|
48
|
-
|
|
48
|
+
const callShapes = (page, node, models) => {
|
|
49
|
+
const calls = node.props.calls;
|
|
50
|
+
const model = models[calls.resource];
|
|
51
|
+
if (!model) return [];
|
|
52
|
+
const filter = configFilter(model, calls.filter);
|
|
53
|
+
const sort = configSort(model, threadSort(calls.time));
|
|
54
|
+
const params = [...calls.filter?.trim() ? [`filter=${calls.filter}`] : [], ...sort ? [`order_by=${sortText(sort)}`] : []];
|
|
55
|
+
const named = title(node);
|
|
56
|
+
return [{
|
|
57
|
+
resource: model.name,
|
|
58
|
+
request: `GET /${model.name}${params.length > 0 ? `?${params.join("&")}` : ""}`,
|
|
59
|
+
from: `page "${page.name}", <Thread${named ? ` "${named}"` : ""}> calls`,
|
|
60
|
+
query: {
|
|
61
|
+
...filter && { filter },
|
|
62
|
+
...sort && { sort }
|
|
63
|
+
}
|
|
64
|
+
}];
|
|
65
|
+
};
|
|
66
|
+
/** The reads of a composed page: each block that lists records, with its filter and sort, a thread's tool calls, and each chart's grouping. */
|
|
49
67
|
const pageShapes = (page, models, views) => {
|
|
50
68
|
const shapes = [];
|
|
51
69
|
walkTree(page.tree, (node) => {
|
|
@@ -69,6 +87,7 @@ const pageShapes = (page, models, views) => {
|
|
|
69
87
|
...sort && { sort }
|
|
70
88
|
}
|
|
71
89
|
});
|
|
90
|
+
if (node.type === "Thread" && node.props.calls !== void 0) shapes.push(...callShapes(page, node, models));
|
|
72
91
|
});
|
|
73
92
|
return shapes;
|
|
74
93
|
};
|
|
@@ -129,19 +129,23 @@ const recordChartShapes = (item, owner, models) => {
|
|
|
129
129
|
}];
|
|
130
130
|
};
|
|
131
131
|
const threadShapes = (item, owner, models) => {
|
|
132
|
-
const
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
132
|
+
const from = `thread "${item.title}" on the ${owner} record page`;
|
|
133
|
+
const latest = (source) => {
|
|
134
|
+
const target = models[source.resource];
|
|
135
|
+
const field = target?.fields[source.field];
|
|
136
|
+
if (!target || !field || !target.fields[source.time]) return [];
|
|
137
|
+
const sort = configSort(target, threadSort(source.time));
|
|
138
|
+
return [{
|
|
139
|
+
resource: target.name,
|
|
140
|
+
request: request(target.name, `${field.name} = …`, sort),
|
|
141
|
+
from,
|
|
142
|
+
query: {
|
|
143
|
+
filter: compare(field),
|
|
144
|
+
...sort && { sort }
|
|
145
|
+
}
|
|
146
|
+
}];
|
|
147
|
+
};
|
|
148
|
+
return [...latest(item), ...item.calls ? latest(item.calls) : []];
|
|
145
149
|
};
|
|
146
150
|
const displayShapes = (model, view, models) => (view.list?.displays ?? []).flatMap((display) => {
|
|
147
151
|
if (display.kind === "map") {
|
|
@@ -6,6 +6,7 @@ import { capacitorOrigin } from "@protobase/schema/internal";
|
|
|
6
6
|
const protobasePlugin = "@protobase/mobile";
|
|
7
7
|
const keyboardPlugin = "@capacitor/keyboard";
|
|
8
8
|
const liveUpdatePlugin = "@capawesome/capacitor-live-update";
|
|
9
|
+
const splashPlugin = "@capacitor/splash-screen";
|
|
9
10
|
const pushPresentation = [
|
|
10
11
|
"badge",
|
|
11
12
|
"sound",
|
|
@@ -16,9 +17,9 @@ const readyTimeout = 3e4;
|
|
|
16
17
|
* The app's `capacitor.config.json`, every key it sets named here. It never sets `server.url`, the hostname or the
|
|
17
18
|
* schemes (the API's CORS list names Capacitor's default origins). WebView debugging is off in an iOS release by name:
|
|
18
19
|
* Capacitor's prebuilt simulator framework is a Debug build, so its default lists a Release app in Safari's Develop menu.
|
|
19
|
-
* `plugins` configures ProtobaseAuth, the keyboard plugin
|
|
20
|
-
*
|
|
21
|
-
* files, background updates off, a rolled-back bundle blocked and `readyTimeout`, within which the shell must call
|
|
20
|
+
* `plugins` configures ProtobaseAuth, the keyboard plugin, the splash screen, which stays up until the shell hides it,
|
|
21
|
+
* and, with the live updater, what its guard needs: the key releases are signed with, where they come from, the
|
|
22
|
+
* binary's fingerprint, shell version and the order of its own files, background updates off, a rolled-back bundle blocked and `readyTimeout`, within which the shell must call
|
|
22
23
|
* ready() or the app goes back to its own files. CapacitorHttp and CapacitorCookies stay off; the keyboard plugin
|
|
23
24
|
* resizes natively, its default, and fills the space beside the keyboard's rounded corners with the page's background
|
|
24
25
|
* instead of black. With `push`, Capacitor's push plugin is compiled in and shows a push while the app is open, and on
|
|
@@ -38,6 +39,7 @@ const capacitorConfig = ({ appId, appName, fingerprint, shellVersion, plugins, l
|
|
|
38
39
|
...liveUpdate ? [liveUpdatePlugin] : [],
|
|
39
40
|
...push ? [pushPlugin] : [],
|
|
40
41
|
keyboardPlugin,
|
|
42
|
+
splashPlugin,
|
|
41
43
|
protobasePlugin
|
|
42
44
|
],
|
|
43
45
|
plugins: {
|
|
@@ -46,6 +48,7 @@ const capacitorConfig = ({ appId, appName, fingerprint, shellVersion, plugins, l
|
|
|
46
48
|
origin: capacitorOrigin[platform]
|
|
47
49
|
},
|
|
48
50
|
Keyboard: { autoBackdropColor: "dom" },
|
|
51
|
+
SplashScreen: { launchAutoHide: false },
|
|
49
52
|
...push && { PushNotifications: { presentationOptions: pushPresentation } },
|
|
50
53
|
...apnsEnvironment && { ProtobasePush: { environment: apnsEnvironment } },
|
|
51
54
|
...liveUpdate && { LiveUpdate: {
|
package/dist/mobile/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.96.1",
|
|
4
4
|
"description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@better-auth/core": "^1.7.12",
|
|
45
45
|
"@hono/node-server": "^2.1.3",
|
|
46
|
-
"@protobase/config": "0.
|
|
47
|
-
"@protobase/layout": "0.
|
|
48
|
-
"@protobase/query": "0.
|
|
49
|
-
"@protobase/schema": "0.
|
|
50
|
-
"@protobase/server": "0.
|
|
51
|
-
"@protobase/ui": "0.
|
|
52
|
-
"@protobase/workflows": "0.
|
|
46
|
+
"@protobase/config": "0.96.1",
|
|
47
|
+
"@protobase/layout": "0.96.1",
|
|
48
|
+
"@protobase/query": "0.96.1",
|
|
49
|
+
"@protobase/schema": "0.96.1",
|
|
50
|
+
"@protobase/server": "0.96.1",
|
|
51
|
+
"@protobase/ui": "0.96.1",
|
|
52
|
+
"@protobase/workflows": "0.96.1",
|
|
53
53
|
"@react-email/render": "^2.1.0",
|
|
54
54
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
55
55
|
"@sentry/vite-plugin": "^11.10.0",
|
|
@@ -9,6 +9,7 @@ Pages of your own, built from blocks in a JSX layout.
|
|
|
9
9
|
- [Conditions](../reference/layouts.md#conditions): Part of a page shows only while a condition on a record or a count holds.
|
|
10
10
|
- [App addresses](../reference/layouts.md#addresses): Links to lists, records, create forms and pages are typed addresses that can carry filters and prefilled values.
|
|
11
11
|
- [Component fallbacks](../reference/custom-components.md#fallbacks): A custom component declares what a client that cannot draw it shows instead, or nothing, and the web shows it too when the component is missing or throws.
|
|
12
|
+
- [Text form](../reference/layouts.md#text-form): Every layout block renders to Markdown text through one shared function, built up from its children, as the last-resort fallback and for MCP clients and LLMs.
|
|
12
13
|
- [Per-user pages](../reference/layouts.md#access): Each user gets the page without the parts, fields and actions they cannot use.
|
|
13
14
|
- [Layout blocks](../reference/blocks.md#layout): Pages, responsive grids, cards and links.
|
|
14
15
|
- [Tailwind classes](../reference/layouts.md#tailwind-classes) (experimental): Layouts can carry Tailwind classes, on plain elements and on blocks, for pages too custom for blocks.
|
|
@@ -20,6 +21,7 @@ Pages of your own, built from blocks in a JSX layout.
|
|
|
20
21
|
- [Image block](../reference/blocks.md#image): A picture one of the app's API functions draws for the reader, such as a system map, at the size and theme the client asks, refreshed on a timer; a client that draws no images shows its alt text, or nothing.
|
|
21
22
|
- [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.
|
|
22
23
|
- [Conversations](../reference/blocks.md#conversation): A chat declared in the layout: a thread of a resource's messages under each sender's name and time, following new ones as they arrive, and a box that sends one as the signed-in user.
|
|
24
|
+
- [Tool calls in threads](../reference/blocks.md#tool-calls): Conversation threads show tool calls in time order, with a status and an expandable input and result.
|
|
23
25
|
- [Buttons and forms](../reference/blocks.md#behaviour): Buttons for named actions, and create or edit forms in a dialog.
|
|
24
26
|
- [Settings block](../reference/blocks.md#settings): Each person's own settings from a resource with one record per person, saved as they change, with defaults until the first save.
|
|
25
27
|
- [Users block](../reference/blocks.md#users): User management on any page: find users, set roles, block them and invite by email.
|
|
@@ -98,7 +98,7 @@ bun install
|
|
|
98
98
|
|
|
99
99
|
## Run the ERP example
|
|
100
100
|
|
|
101
|
-
`tests/apps/erp` is a sample ERP on a real Postgres database, seeded with three years of history.
|
|
101
|
+
`tests/apps/erp` is a sample ERP on a real Postgres database, seeded with three years of history. `bun run db:up` starts the Postgres container and gives each example its database and a `.env` from its `.env.example`. Without Docker, `POSTGRES_RUNNER=local` in the repository's `.env` runs the machine's own Postgres 18 and PgBouncer as plain processes on the same ports instead, with their data in `.protobase/postgres`; `POSTGRES_BIN` names the folder of `initdb` and `pg_ctl` when they are not on PATH. Supabase's Postgres, which `bun run test:record` needs, runs only in Docker. The databases listen on `127.0.0.1` only, so on Docker Engine 28.0.0 or later other machines on the network cannot reach them, unless the daemon's `allow-direct-routing` option, off by default, lets them reach containers by their own address; an older Docker Engine lets hosts on the same local network segment reach them, so it needs a firewall that blocks them. On Linux with firewalld, Docker Engine 28.2.0 to 28.3.2 lets other hosts reach them again after a firewalld reload, so it needs that firewall too, or an upgrade to 28.3.3 or later. A checkout or worktree on an older base publishes them on every interface again, so rebase it onto `main` before any `docker compose up` or `db:up`.
|
|
102
102
|
|
|
103
103
|
```sh
|
|
104
104
|
bun run db:up && bun run --cwd tests/apps/erp db:migrate && bun run --cwd tests/apps/erp db:seed --scale small # the ERP's tables and Better Auth's
|
|
@@ -131,7 +131,7 @@ bun run --cwd tests/apps/property-portal dev # http://localhost:517
|
|
|
131
131
|
|
|
132
132
|
| Command | Purpose |
|
|
133
133
|
| --- | --- |
|
|
134
|
-
| `bun run db:up` / `bun run db:down` | start or stop the Postgres container; `db:up` also creates the examples' databases and `.env` files |
|
|
134
|
+
| `bun run db:up` / `bun run db:down` | start or stop the Postgres container, or with `POSTGRES_RUNNER=local` in `.env` the local Postgres and PgBouncer processes; `db:up` also creates the examples' databases and `.env` files |
|
|
135
135
|
| `bun run test` | the unit tests and the snapshot tests in `packages/*/tests/` and `tests/` (Vitest projects `unit*` and `snapshot*`): no Postgres server, subprocess or network. A snapshot test replays the SQL recorded for it from Postgres in `<test>.sql.json` |
|
|
136
136
|
| `bun run test:record` | runs the snapshot tests on the Postgres container instead and writes their recordings, after building their templates (`bun run test:db snapshots`); run it when a change makes a snapshot test fail with `stale snapshot` |
|
|
137
137
|
| `bun run test:unit` | only the unit tests, next to the code (Vitest projects `unit`, whose files share their modules, and `unit-isolated`, for those that mock a module or change a global), fully parallel; starting a Postgres client there throws |
|
|
@@ -150,7 +150,7 @@ mobile: {
|
|
|
150
150
|
},
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
-
Build the binary again. Each deploy of the app then reaches it: it downloads the files that changed in the background and runs them at its next start, or when it comes back to the foreground after 5 minutes or more away, on the page it showed and still signed in. It never switches while in use, within 5 minutes of leaving it, or over unsaved changes on the page, and it asks nobody to reload. A release that fails to start goes back to the files the binary carries. Releases come from a server of the same Protobase minor as the binary (below 1.0); a newer minor needs a store release. See [the live updater](../reference/cli.md#the-live-updater).
|
|
153
|
+
Build the binary again. Each deploy of the app then reaches it: it downloads the files that changed in the background and runs them at its next start, or when it comes back to the foreground after 5 minutes or more away, on the page it showed and still signed in, behind its splash screen. Right after someone signs in, it switches before the app opens. It never switches while in use, within 5 minutes of leaving it, or over unsaved changes on the page, and it asks nobody to reload. A release that fails to start goes back to the files the binary carries. Releases come from a server of the same Protobase minor as the binary (below 1.0) and the same native code; a newer minor, or a Protobase release that changes the native code, needs a store release. See [the live updater](../reference/cli.md#the-live-updater).
|
|
154
154
|
|
|
155
155
|
## 8. What the stores accept
|
|
156
156
|
|
|
@@ -501,11 +501,40 @@ The latest messages that match `filter`, oldest first, each under its sender's n
|
|
|
501
501
|
| `text` | The message; shown rendered when the message resource's view marks it [`.markdown()`](ui-config.md#names-and-columns). Required. |
|
|
502
502
|
| `status` | A short line under each message, such as whether it was delivered: a text or enum field, shown with its view's value labels, in red for a value it colours `red`; a message without a value shows none. Left out for a user who cannot read it. Experimental, see [Message status and a working indicator](ui-config.md#message-status-and-a-working-indicator). |
|
|
503
503
|
| `working` | A condition on the record around the thread, as [`Show`](#show) takes, such as `state = 'working'`: while it holds, the thread ends in a working indicator. Left out for a user who cannot read what it names. Experimental. |
|
|
504
|
-
| `
|
|
504
|
+
| `calls` | Tool calls shown between the messages in time order, from a resource of their own; see [Tool calls](#tool-calls). Left out for a user who cannot read their name, time or status. |
|
|
505
|
+
| `limit` | How many of the latest messages it shows at first, and of the latest tool calls, and how many each **Load earlier messages** adds: 1 to 500, the API's largest page; default 50. |
|
|
505
506
|
| `title`, `description`, `actions` | The heading; no card is drawn around the thread, so it can sit in a `Card` with its composer. |
|
|
506
507
|
| `empty` | Text while there are no messages. |
|
|
507
508
|
| `span` | Width in a grid. |
|
|
508
509
|
|
|
510
|
+
#### Tool calls
|
|
511
|
+
|
|
512
|
+
A thread with an assistant in it can show what the assistant did between its messages: each tool call it made, in time order, with the tool's name and its status, which opens to what the tool was called with, what it gave back and why it failed. `calls` names the resource that holds the calls and the fields the thread reads of each:
|
|
513
|
+
|
|
514
|
+
```tsx
|
|
515
|
+
<Thread
|
|
516
|
+
resource="messages"
|
|
517
|
+
filter="chat_id = 1"
|
|
518
|
+
sender="author_id"
|
|
519
|
+
time="sent_at"
|
|
520
|
+
text="body"
|
|
521
|
+
calls={{ resource: 'tool_calls', filter: 'chat_id = 1', name: 'tool', time: 'called_at', status: 'state', input: 'input', result: 'output', error: 'failure' }}
|
|
522
|
+
/>
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
| `calls` key | |
|
|
526
|
+
| --- | --- |
|
|
527
|
+
| `resource`, `filter` | Which calls. `resource` is required. |
|
|
528
|
+
| `name` | The tool's name: a text field. Required. |
|
|
529
|
+
| `time` | When it was called: a date or timestamp field the API can sort by, which places it among the messages. A call at the same time as a message shows after it. Required. |
|
|
530
|
+
| `status` | A text or enum field: `done` shows a check, `running` a spinner and `error` an alert icon in red, each beside the value's label from the view; any other value shows its label without a mark, and a call without a value shows none. Required. |
|
|
531
|
+
| `input`, `result` | What the tool was called with and what it gave back, shown as indented JSON; a text that holds JSON shows as the value it holds. |
|
|
532
|
+
| `error` | Why the call failed: a text field. |
|
|
533
|
+
|
|
534
|
+
Each call is a line under the messages before it, closed at first; a call with an input, result or error opens and closes with a click on its line. The thread reads the latest calls as it reads the latest messages, `limit` at a time, newest first by `time`, so that read needs an index on the filter's field and `time`, which [`protobase doctor`](cli.md#doctor) checks, and **Load earlier messages** loads the earlier calls with the earlier messages, keeping them in time order. A user who cannot read the calls' `name`, `time` or `status` gets the thread without its calls, and one who cannot read `input`, `result` or `error` gets the calls without that part.
|
|
535
|
+
|
|
536
|
+
Clients that cannot draw the calls get their simpler forms from `@protobase/layout`: `threadLines(items)` gives one short line per item, a message as its sender and first line and a call as its name and status, and `threadMarkdown(items, words)` gives the thread as Markdown, for clients that read text, such as an MCP client or a language model: each message under its sender in bold, each call as its name and status with its input and result as JSON and its error in fenced code blocks. <gap>A watch cannot show a thread's tool calls as lines because drawing a thread on a watch is not implemented.</gap> <gap>An MCP client cannot read a thread as Markdown because serving a page's blocks as text is not implemented.</gap>
|
|
537
|
+
|
|
509
538
|
### Composer
|
|
510
539
|
|
|
511
540
|
A text box that grows with its text: Enter or the send button creates a record of `resource` with the text in `field` and the `values`, and Shift+Enter starts a new line. The text stays in the box until the server took it, so a message it refuses is still there to send again, under the reason. It is not shown to a user who may not create a record of `resource` or write its fields.
|
|
@@ -477,20 +477,22 @@ Mobile releases and the live updater are in development.
|
|
|
477
477
|
|
|
478
478
|
With a `mobile` section, the server serves the [mobile app](../guides/mobile-app.md) a newer copy of its files, for its live updater, so the app gets UI changes without a store release. The release is what the server serves the web, composed at startup: every file of `public/`, with the server's own shell where `protobase serve` uses it, and `index.html` naming the API origin, the app's `url` (https, or plain http to `localhost`, `127.0.0.1` or `[::1]`). There is none when the server serves the API alone, has no such `url`, or the bundle names no `native`, and with `PROTOBASE_MOBILE_SIGNING_KEY` none for a bundle that names no build time (one built before Protobase recorded it: build it again). Where `protobase serve` serves its own shell, the release's fingerprint names the `native` of that shell's `protobase.shell.json`, and there is none when it names none.
|
|
479
479
|
|
|
480
|
-
- `GET /api/mobile/release?fingerprint=<native fingerprint>&shell_version=<x.y.z>` answers `{ "bundleId", "url", "required" }`: the release's id, a hash of its files, and its absolute base URL, both `null` when the release does not run on the asking binary, whose native fingerprint must equal the release's. `required` is true when the shell the app runs no longer works with the server's API: below 1.0 another minor, from 1.0 another major. A missing fingerprint or a shell version that is no x.y.z version gets 400.
|
|
480
|
+
- `GET /api/mobile/release?fingerprint=<native fingerprint>&shell_version=<x.y.z>` answers `{ "bundleId", "url", "required" }`: the release's id, a hash of its files, and its absolute base URL, both `null` when the release does not run on the asking binary, whose native fingerprint must equal the release's, or when the update is required, since the binary refuses a release of another shell version. `required` is true when the shell the app runs no longer works with the server's API: below 1.0 another minor, from 1.0 another major. A missing fingerprint or a shell version that is no x.y.z version gets 400.
|
|
481
481
|
- `GET /api/mobile/releases/<bundleId>?href=<file>` serves the release's file `<file>`, such as `assets/index-abc123.js`, and with `href=capawesome-live-update-manifest.json` its manifest, a JSON array of `{ "href", "checksum", "sizeInBytes" }`. Each comes with its sha256 in hex in `X-Checksum` and, with `PROTOBASE_MOBILE_SIGNING_KEY`, its signature in `X-Signature`. Any other file, or another release's id, gets 404.
|
|
482
482
|
- Signed, a release also serves `href=protobase-release.json`, its statement: `{ "payload", "signature" }`, the payload the hex of the JSON `{ "manifest", "order", "appId", "fingerprint", "shellVersion" }` and the signature the hex of its SHA256withRSA over the line `protobase-mobile-release` and the payload. It binds the manifest's sha256 to the release's order, when the bundle was built and then when the server's own shell it serves was built (0 with the bundle's copy), to the app id and native fingerprint of the binaries it runs on, and to the server's Protobase version. Its id is then a hash of the statement and the public key, so the same files built again get another id. A file of the app may not be named like the statement or start with that line.
|
|
483
483
|
- The app, on Android and iOS alike, downloads a release itself and takes it only when its statement is signed with the key the binary pins, names the release's id, this app, this binary and a server its shell works with, and its order is not below the highest it downloaded; then every file must hash to what the manifest lists, under a path inside the release, before any file is written. It follows no redirect and reads no file past the size its manifest lists. It runs a downloaded release only above the running one's order and holding nothing but the files its manifest lists. It never takes a release at or below the order of its own files, which `protobase mobile` records in the binary as the server would order the same bundle with its copy of the shell, so a reinstalled app is not taken below them, and a release built before the binary is not taken. <gap>A phone cannot take a rollback of the bundle or of the server's shell before a later build, because ordering releases by an explicit release number is not implemented.</gap> <gap>An app with no download recorded, such as after a reinstall, cannot refuse a genuine signed release older than the latest but newer than its own files, because a signed answer naming the latest release is not implemented.</gap>
|
|
484
484
|
|
|
485
485
|
#### The live updater
|
|
486
486
|
|
|
487
|
-
An Android or iOS app built with `mobile.publicKey` updates itself from the server it calls. The shell asks `GET /api/mobile/release`
|
|
487
|
+
An Android or iOS app built with `mobile.publicKey` updates itself from the server it calls, and never shows that it does. Launch waits on nothing: the app starts on the release it set next earlier, or its own files. The shell asks `GET /api/mobile/release` in the background each time the app comes back to the foreground and, while someone is signed in, once the app has drawn, every 15 minutes while it is in view and when the server's Protobase version changes under an open page. It downloads a release it does not run, only the files that changed, and runs it at the next cold start. The session stays in the device's cookie store, so the user stays signed in across the switch.
|
|
488
488
|
|
|
489
|
-
-
|
|
489
|
+
- The splash screen stays up from launch until the shell has drawn, and covers each reload into a release until the release has drawn.
|
|
490
|
+
- Right after someone signs in on the app, before it opens, the app takes the server's release and reloads into it, on the same page. Past 20 seconds it opens on the files it runs, and the download goes on for a later start or return.
|
|
491
|
+
- Coming back to the foreground after 5 minutes or more away, the app reloads into a release it downloaded, then returns to the page and scroll position it showed. It does not while a guard holds unsaved changes on the page, or when it was away for less. The app shows no prompt that it was updated: a reload would only start the files it runs again, so it checks for the server's release instead. A push tapped while the app reloads opens its page once the release has drawn.
|
|
490
492
|
|
|
491
493
|
- Once the shell has drawn, it tells the updater the release started. A release that does not within 30 seconds goes back to the app's own files at once and is never taken again.
|
|
492
494
|
- No answer, any status but 200, a body that is not the answer, or an answer naming no release changes nothing: the app keeps the files it runs, and never goes back to its own files because of the answer, which is not signed.
|
|
493
|
-
-
|
|
495
|
+
- A required update offers no release, so the app goes on with the files it runs. <gap>A required update across a Protobase minor below 1.0, or a major, cannot reach a phone by live update because taking a release of another shell version than the binary's is not implemented, so such a fix, a security fix included, reaches it only through a store release.</gap>
|
|
494
496
|
- The binary pins the public key: a new key needs a new store release, and a server whose `PROTOBASE_MOBILE_SIGNING_KEY` is not its private half serves releases the app refuses.
|
|
495
497
|
|
|
496
498
|
A host that serves bundles without running their config, such as a router in front of many apps or a static host, serves the same release from the files it already serves with `@protobase/server/mobile-release`, which loads none of the rest of the server: `protobase serve` composes its own release with the same exports.
|
|
@@ -53,6 +53,46 @@ A custom component declared with a [fallback](custom-components.md#fallbacks) ca
|
|
|
53
53
|
|
|
54
54
|
A client that cannot draw the component, such as one without React, draws the fallback instead, and the checks read it like the rest of the tree.
|
|
55
55
|
|
|
56
|
+
## Text form
|
|
57
|
+
|
|
58
|
+
Every layout block renders to Markdown text through one shared function, `renderText`, built up from its children. It is the last-resort form of a page, for a client that draws no blocks and for MCP clients and LLMs. Each element's text is made from its children's text, already rendered: a container such as `Grid`, `Box` or `Tabs` reads as its children in order with a blank line between them, and text and links run on in one line as they do on the web.
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import { Field, Page, renderText } from '@protobase/layout'
|
|
62
|
+
|
|
63
|
+
renderText(<Page title="Order"><Field name="status" /></Page>, {
|
|
64
|
+
record: { status: 'in_progress' },
|
|
65
|
+
fields: { status: { label: 'Status', valueLabels: { in_progress: 'In progress' } } },
|
|
66
|
+
})
|
|
67
|
+
// # Order
|
|
68
|
+
//
|
|
69
|
+
// **Status**: In progress
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
| Option | |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| `record` | The record around the tree. `Field`, `Stat field`, `Progress`, `Show` conditions and the `{field}`s of addresses read it, through relations as nested objects (`plan.name`); a count a condition names, such as `billing_profiles.count`, is a key of its own. Without it, a field reads as its label alone, a `Show` reads as all it holds, and addresses keep their `{field}`s. |
|
|
75
|
+
| `fields` | Per field path, its `label` and the `valueLabels` its enum values read as; a field without a label reads under its path. |
|
|
76
|
+
| `basePath` | What links start with, such as `https://example.com/admin`. |
|
|
77
|
+
| `forms` | Text forms by block type, over the built-in ones. |
|
|
78
|
+
|
|
79
|
+
A heading reads at its level: a `Page` title as `#`, a `Tab` label as `##`, and the title of a `Card` and of a data block as `###`, the data block's linked to its records' list as it filters them. A field's value reads as its enum label, a list as its items, and JSON as a code block.
|
|
80
|
+
|
|
81
|
+
A text form of your own is a function from its element and its children's text to Markdown. It can use the default as it is (`childrenText`), wrap a built-in form from `textForms`, or rework the children's text, such as a horizontal line between them:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { childrenText, markdown, renderText, textForms, type TextForm } from '@protobase/layout'
|
|
85
|
+
|
|
86
|
+
const ruled: TextForm = ({ children }) => markdown.blocks(children, '\n\n---\n\n')
|
|
87
|
+
const noted: TextForm = (context) => `${textForms.Card!(context)}\n\nUpdated hourly.`
|
|
88
|
+
|
|
89
|
+
renderText(tree, { forms: { Grid: ruled, Card: noted, SeatChart: childrenText } })
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
A custom component reads as its [fallback](custom-components.md#fallbacks) when it declares one, and otherwise as what it holds, unless `forms` names it.
|
|
93
|
+
|
|
94
|
+
<gap>A data block's text form cannot list its records, such as a table's rows, because reading records for the text form is not implemented.</gap> <gap>A field's text form cannot apply its `format`, such as a relative time, because formatting in the text form is not implemented.</gap> <gap>MCP clients cannot read a page's text form because a tool that serves it is not implemented.</gap>
|
|
95
|
+
|
|
56
96
|
## What a layout may hold
|
|
57
97
|
|
|
58
98
|
A prop is a string, a finite number, a boolean, `null`, or an array or plain object of those (elements included). It is JSON in the end, so the rules are checked twice:
|
|
@@ -1204,6 +1204,7 @@ The thread shows the latest messages oldest first, each under its sender's name
|
|
|
1204
1204
|
| `text` | The message, a text field. Required. |
|
|
1205
1205
|
| `status` | A short line under each message, such as whether it was delivered: a text or enum field. See [Message status and a working indicator](#message-status-and-a-working-indicator). |
|
|
1206
1206
|
| `working` | A condition on this record, such as `state = 'working'`, while which the thread ends in a working indicator. |
|
|
1207
|
+
| `calls` | Tool calls shown between the messages in time order: the `resource` that holds them, the filterable relation `field` of it that holds this record's key, and the fields the [Thread block's `calls`](blocks.md#tool-calls) names, `name`, `time`, `status`, `input`, `result` and `error`. A `field` that is no relation to this resource, a field the calls do not have or of the wrong type, or a sensitive one stops the server at startup. |
|
|
1207
1208
|
| `limit` | How many of the latest it shows at first, and how many each **Load earlier messages** adds: 1 to 500, the API's largest page; default 50. |
|
|
1208
1209
|
| `empty` | Text while there are no messages. |
|
|
1209
1210
|
| `help`, `when` | A line under the title, and whether it shows on the form, the read view or both. |
|
|
@@ -1226,7 +1227,7 @@ view<typeof tasks>('tasks').layout((r) => [
|
|
|
1226
1227
|
])
|
|
1227
1228
|
```
|
|
1228
1229
|
|
|
1229
|
-
The messages are read with `field = <this record's key>` as the filter, newest first by `time`, so the user's access applies as on the list. That read needs an index on `(field, time)`, such as `create index on task_messages (task_id, sent_at)`, which [`protobase doctor`](cli.md#doctor) checks. A user who cannot read `field`, `sender`, `time` or `text` gets no thread, and one who may not create a message with `field` and `text` gets no composer. A `field` that is no relation to this resource, a `time` that is no date or timestamp the API can sort by, a `sender` that is no relation or text field, a thread `text` that is no text field, a sensitive field in the thread, or a composer `text` that is no writable text field stops the server at startup. As with a related section, the record page's count of the records that point at it leaves out the messages its thread shows.
|
|
1230
|
+
The messages are read with `field = <this record's key>` as the filter, newest first by `time`, so the user's access applies as on the list. That read needs an index on `(field, time)`, such as `create index on task_messages (task_id, sent_at)`, which [`protobase doctor`](cli.md#doctor) checks. Tool calls are read the same way, by their own `field` and `time`. A user who cannot read `field`, `sender`, `time` or `text` gets no thread, and one who may not create a message with `field` and `text` gets no composer. A `field` that is no relation to this resource, a `time` that is no date or timestamp the API can sort by, a `sender` that is no relation or text field, a thread `text` that is no text field, a sensitive field in the thread, or a composer `text` that is no writable text field stops the server at startup. As with a related section, the record page's count of the records that point at it leaves out the messages and tool calls its thread shows.
|
|
1230
1231
|
|
|
1231
1232
|
#### Message status and a working indicator
|
|
1232
1233
|
|