@protobase/cli 0.26.7 → 0.26.9
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/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.9",
|
|
4
4
|
"description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@hono/node-server": "^2.1.3",
|
|
37
37
|
"@hono/vite-dev-server": "^0.26.1",
|
|
38
|
-
"@protobase/layout": "0.26.
|
|
39
|
-
"@protobase/query": "0.26.
|
|
40
|
-
"@protobase/schema": "0.26.
|
|
41
|
-
"@protobase/server": "0.26.
|
|
42
|
-
"@protobase/ui": "0.26.
|
|
38
|
+
"@protobase/layout": "0.26.9",
|
|
39
|
+
"@protobase/query": "0.26.9",
|
|
40
|
+
"@protobase/schema": "0.26.9",
|
|
41
|
+
"@protobase/server": "0.26.9",
|
|
42
|
+
"@protobase/ui": "0.26.9",
|
|
43
43
|
"@react-email/render": "^2.1.0",
|
|
44
44
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
45
45
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -79,14 +79,14 @@ Record pages take the same conditions in the `when` of `l.section`, `l.related`
|
|
|
79
79
|
|
|
80
80
|
| Builder | Does |
|
|
81
81
|
| --- | --- |
|
|
82
|
-
| `a.update(name, { label, set, confirm?, icon?, inputs? })` | Updates the record with `set`, with its ETag; not offered on a record that holds those values already, unless it asks for `inputs`, whose answers it writes where `set` says `'{name}'`. |
|
|
82
|
+
| `a.update(name, { label, set, confirm?, icon?, bulk?, inputs? })` | Updates the record with `set`, with its ETag; not offered on a record that holds those values already, unless it asks for `inputs`, whose answers it writes where `set` says `'{name}'`. |
|
|
83
83
|
| `a.remove(name, { label, confirm?, icon? })` | Deletes the record (soft delete when the resource has one). |
|
|
84
84
|
| `a.link(name, { label, to, icon? })` | Goes `to` an [address](#addresses) in the app, with `{field}` in its key, filter, order or create values replaced by the record's value. |
|
|
85
85
|
| `a.link(name, { label, href, icon? })` | Opens an `href` that leaves the app (`https:`, `mailto:`), with `{field}` replaced by the record's value (percent-encoded); an `https:` or `http:` link opens in a new tab without the referrer. An `href` that is only a field, `'{website}'`, opens the URL the record holds, as it is: see [links to a record's URL](#links-to-a-records-url). A path in the app is refused when the config loads: give it as `to`. |
|
|
86
86
|
| `a.ai(name, { label, prompt, writes, confirm?, icon? })` | Has the model write the field `writes` of the record from `prompt`, `{field}` replaced by the record's values, as the user, on the server; see [AI fields and actions](ai.md#ai-actions)). |
|
|
87
87
|
| `a.action(name, { label, confirm?, icon?, bulk?, inputs? })` | Runs the handler the app registers under `name` in [`protobase.ui.tsx`](custom-components.md#action-handlers)), after asking for its [`inputs`](ui-config.md#actions-that-ask-for-input)) in a dialog when it has some. |
|
|
88
88
|
|
|
89
|
-
`icon` is one of `ban`, `bath`, `bed`, `bell`, `bookmark`, `calendar`, `door-open`, `external-link`, `file-text`, `heart`, `house`, `key`, `land-plot`, `leaf`, `ruler`, `send`, `tag` or `
|
|
89
|
+
`icon` is one of `archive`, `arrow-right-left`, `ban`, `bath`, `bed`, `bell`, `bookmark`, `calendar`, `camera`, `copy`, `cpu`, `door-open`, `download`, `external-link`, `file-text`, `hard-drive`, `heart`, `house`, `key`, `land-plot`, `leaf`, `memory`, `network`, `play`, `plug`, `power`, `restart`, `ruler`, `send`, `server`, `stop`, `tag`, `terminal`, `upload`, `wallet` or `wrench`; another name shows a lightning bolt. With `confirm` the button asks first. Every builder also takes `when`, `otherwise` and `reason`, which limit the action to the records it [applies to](ui-config.md#where-an-action-applies)), and `variant: 'danger'`, which draws it in red. The button is disabled, with the reason as its tooltip, when the user may not update or delete the record (or, for an AI action, the field it writes), when an `a.action` has no handler, or when an update, delete or AI action has no record. After an action, everything shown of that resource reloads. The record page's action rail runs the same actions the same way.
|
|
90
90
|
|
|
91
91
|
### Links to a record's URL
|
|
92
92
|
|
|
@@ -31,18 +31,19 @@ The transaction sets the role with `SET LOCAL ROLE` and the token's claims in `r
|
|
|
31
31
|
|
|
32
32
|
- Filters: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `like`, `ilike`, `match`, `imatch`, `in`, `is`, `isdistinct`, `fts`, `plfts`, `phfts`, `wfts` with a language, `cs`, `cd`, `ov`, `sl`, `sr`, `nxr`, `nxl`, `adj`, `any` and `all` modifiers, `not.`, and `or`, `and`, `not.or` and `not.and` trees, on columns and JSON paths (`meta->>kind`).
|
|
33
33
|
- `select` with columns, aliases (`key:id`), casts (`priority::text`) and JSON paths.
|
|
34
|
+
- Embedded rows of related tables, through their foreign keys: `select('*, author:profiles(name), comments(*)')`. A many-to-one or one-to-one embed is an object or `null`, a one-to-many one an array. A hint picks the foreign key when several relate the tables, by its name or column (`profiles!sender_id(name)`), and `!inner` keeps only the rows with a related row. Filters, `order`, `limit` and `offset` take the embed's name or alias as a prefix (`comments.likes=gte.2`, `comments.order=id.desc`), as supabase-js's `referencedTable` option sends them. The embedded tables' RLS policies apply too. Only tables `/rest/v1` serves are embedded.
|
|
34
35
|
- `order`, `limit`, `offset` and the `Range` header. A read returns at most 1000 rows, Supabase's default.
|
|
35
36
|
- `Prefer: count=exact|planned|estimated`, with the count in `Content-Range` and `206` for part of the rows.
|
|
36
37
|
- `Prefer: return=minimal|representation`, `resolution=merge-duplicates|ignore-duplicates`, `missing=default`, and `on_conflict` and `columns`.
|
|
37
38
|
- `.single()` and `.maybeSingle()`, through `Accept: application/vnd.pgrst.object+json`.
|
|
38
39
|
- `rpc/<function>` by POST and by GET, which runs read-only. A function returning rows takes `select`, filters, `order`, a range and a count.
|
|
39
40
|
|
|
40
|
-
Not yet:
|
|
41
|
+
Not yet: many-to-many embeds through a junction table, spreads (`...profiles(name)`), computed relationships, embeds in a function's rows, ordering by an embedded column, CSV, other schemas, aggregates and `tx=rollback`.
|
|
41
42
|
|
|
42
43
|
## Scan guard
|
|
43
44
|
|
|
44
|
-
As on the [REST API](api.md#safety)), a filter or a sort reads only columns an index serves: a btree index for comparisons, `in`, `is` and sorts, a pg_trgm index for patterns and regular expressions, a GIN index for text search and `cs`, `cd` and `ov` (or GiST), and a GiST index for the range operators. A JSON path needs an index on that expression. Any other read is `400` with code `expensive-query` and the statement that adds the index as its `hint`. Functions are not judged.
|
|
45
|
+
As on the [REST API](api.md#safety)), a filter or a sort reads only columns an index serves: a btree index for comparisons, `in`, `is` and sorts, a pg_trgm index for patterns and regular expressions, a GIN index for text search and `cs`, `cd` and `ov` (or GiST), and a GiST index for the range operators. A JSON path needs an index on that expression. An embed's filters and order are judged on the embedded table, and so are the columns it joins on, so a one-to-many embed needs an index on the foreign key's columns. Any other read is `400` with code `expensive-query` and the statement that adds the index as its `hint`. Functions are not judged.
|
|
45
46
|
|
|
46
47
|
## Errors
|
|
47
48
|
|
|
48
|
-
Errors come back as PostgREST sends them, `{ code, details, hint, message }`. A database error keeps its Postgres code, message, detail and hint, with PostgREST's status: an RLS refusal (`42501`) is `401` for `anon` and `403` for others, a duplicate (`23505`) `409`, a function that writes called by GET (`25006`) `405`. `.single()` on no or several rows is `406` `PGRST116`, an unknown table `404` `PGRST205`, an unknown function `404` `PGRST202`, and a missing or wrong key or token `401` `PGRST301`.
|
|
49
|
+
Errors come back as PostgREST sends them, `{ code, details, hint, message }`. A database error keeps its Postgres code, message, detail and hint, with PostgREST's status: an RLS refusal (`42501`) is `401` for `anon` and `403` for others, a duplicate (`23505`) `409`, a function that writes called by GET (`25006`) `405`. `.single()` on no or several rows is `406` `PGRST116`, an unknown table `404` `PGRST205`, an unknown function `404` `PGRST202`, an embed without a relationship `400` `PGRST200` and one with several `300` `PGRST201`, and a missing or wrong key or token `401` `PGRST301`.
|
|
@@ -73,7 +73,7 @@ Field hints:
|
|
|
73
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
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, a page's field blocks and the sidebar 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 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
|
-
| `.icon(name)` | An icon before the value on a card's meta row:
|
|
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. |
|
|
78
78
|
| `.valueColors({ value: '#hex' })`, `.badgeShape('arrow')` | An enum's badges filled with a colour per value (the text turns white or black, whichever reads), and drawn as arrows pointing right, as on a rating scale. The property portal's energy label: `r.energy_label.format('badge').valueColors({ a: '#00a651', g: '#ed1c24' }).badgeShape('arrow')`. Only the enum's values are accepted. |
|
|
79
79
|
| `.widget(name, props?)` | Shows and edits the field with a [field type](plugins.md#field-types)) of the project or a plugin, such as `r.status.widget('steps')` or `r.score.widget('rating', { max: 5 })`; `props` are plain data. Without it, or on a storage type it does not show, the field shows as it would without the hint. |
|
|
@@ -385,7 +385,7 @@ export const repairsView = daily
|
|
|
385
385
|
|
|
386
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 `timeline`). 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
|
-
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,
|
|
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
|
|
|
390
390
|
Display names are checked when the config loads: unique, not `table`, and `default` names one. Their fields are checked when the server starts, and may not be [sensitive](data-config.md#sensitive-fields)). In `/api/meta`, a user's displays lose the fields they cannot read, and a custom display whose `props` name one is left out; the list then opens in the table when its default display went.
|
|
391
391
|
|
|
@@ -991,3 +991,27 @@ Each takes `label`, and optionally `help`, a `default`, `optional: true` to allo
|
|
|
991
991
|
An empty answer is `null`. Before the handler runs, the dialog refuses a required answer left empty, a number that is none, a date that is not `YYYY-MM-DD` and a text longer than `max`, each under its input. When the handler throws an `ActionInputError` from `@protobase/ui`, such as `new ActionInputError({ email: 'No user has this address' })`, or an API error, such as a [function's](../guides/api-functions.md)) answer, whose errors name an input as their `field`, each message shows under its input and the dialog stays open; another error shows above the inputs. When it resolves, the dialog closes and the action ends as any other: everything shown of the resource reloads and a toast says it is done.
|
|
992
992
|
|
|
993
993
|
A custom input's component gets the answer as `value` (`null` when empty), `onChange`, `invalid` while its answer is refused, the input's `props` and the `input` itself (`ActionInputProps`), as a [field type's](custom-components.md#field-types)) editor does. Without that component the button is disabled, with the reason as its tooltip. In `/api/meta`, a user who cannot read the resource of a choice does not get the action.
|
|
994
|
+
|
|
995
|
+
### Where an action applies
|
|
996
|
+
|
|
997
|
+
`when` limits an action to the records it applies to, with the same [AIP-160](https://google.aip.dev/160) conditions a section's [`when`](#form-and-read-view) takes, over the record's own fields: `status = 'running'`, `status != 'stopped' AND locked = false`. On a record it does not hold for, the button is left out, or, with `otherwise: 'disable'`, shown disabled with `reason` as its tooltip. `variant: 'danger'` draws the button in red, as Delete is, and its question's button too:
|
|
998
|
+
|
|
999
|
+
```ts
|
|
1000
|
+
.actions((a) => [
|
|
1001
|
+
a.update('start', { label: 'Start', icon: 'play', when: "status = 'stopped'", set: { status: 'starting' }, bulk: true }),
|
|
1002
|
+
a.action('reboot', { label: 'Reboot', icon: 'restart', when: "status = 'running'", bulk: true }),
|
|
1003
|
+
a.action('force_off', {
|
|
1004
|
+
label: 'Force off',
|
|
1005
|
+
icon: 'power',
|
|
1006
|
+
when: "status = 'running'",
|
|
1007
|
+
otherwise: 'disable',
|
|
1008
|
+
reason: 'The VM is not running',
|
|
1009
|
+
variant: 'danger',
|
|
1010
|
+
confirm: 'The VM loses what it has not saved.',
|
|
1011
|
+
}),
|
|
1012
|
+
])
|
|
1013
|
+
```
|
|
1014
|
+
|
|
1015
|
+
Besides the record page, the list's row menu offers each named action without `inputs` on the rows it applies to, disabled where it is disabled on the record page, and in red when it is a delete or a danger action; a link is a link there, and is left out where `when` does not hold. An `a.update` or `a.action` with `bulk` and no `inputs` is also offered for the selected rows, as **Start (2)**, while one of them applies: it asks its `confirm` once, runs on each row it applies to, one after another, and its toast says how many it ran on, skipped and failed on. An `a.action`'s handler is called once per row.
|
|
1016
|
+
|
|
1017
|
+
A condition reads only the record's own fields, so the list decides it for each row from the row itself: `protobase build` refuses one that names a relation's field (`host_id.name`), counts records (`hosts.count`) or names a field the resource does not have, a disabled button without a `reason`, and a `reason` or `otherwise` without `when`. In `/api/meta`, a user who cannot read a field the condition reads does not get the action. The condition only decides what the buttons show: the resource's [access rules](access.md)) decide what the API lets the user do.
|