@protobase/cli 0.25.4 → 0.25.6
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 +1 -1
- package/package.json +6 -6
- package/skills/protobase/references/reference/api.md +1 -1
- package/skills/protobase/references/reference/data-config.md +1 -1
- package/skills/protobase/references/reference/layouts.md +1 -1
- package/skills/protobase/references/reference/ui-config.md +38 -4
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.6",
|
|
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.25.
|
|
39
|
-
"@protobase/query": "0.25.
|
|
40
|
-
"@protobase/schema": "0.25.
|
|
41
|
-
"@protobase/server": "0.25.
|
|
42
|
-
"@protobase/ui": "0.25.
|
|
38
|
+
"@protobase/layout": "0.25.6",
|
|
39
|
+
"@protobase/query": "0.25.6",
|
|
40
|
+
"@protobase/schema": "0.25.6",
|
|
41
|
+
"@protobase/server": "0.25.6",
|
|
42
|
+
"@protobase/ui": "0.25.6",
|
|
43
43
|
"@react-email/render": "^2.1.0",
|
|
44
44
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
45
45
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -172,7 +172,7 @@ The rules behind these steps are described under [Access](#access).
|
|
|
172
172
|
|
|
173
173
|
- **Keys** are the URL text (`a,b` when composite), a number, a list of parts, or a reference.
|
|
174
174
|
- **`$ref`**: `ref: 'invoice'` on a create names the record; later operations use `{ "$ref": "invoice" }` as a key, a key part, or a value in `data` (it stands for that record's key, or with `{ "$ref": "invoice", "field": "number" }` a readable field's value). A ref must come after its create.
|
|
175
|
-
- **`reorder`** sets `field` to `start`, `start` + 1, ... in the order of `keys`, so a long list sends only the stretch that moved, and writes only the records whose value changes, each as an ordinary update (so each needs its `etags` entry, and hooks see each). To work with a non-deferrable unique index such as `(invoice_id, position)`, the changing records are first moved out of the range in use, in the same transaction and without touching their ETags: above the highest value of the column, or, when a check constraint refuses that (checked with a savepoint), below the lowest one. Then they get their final values, which collide with nothing. The field must be an integer the caller may write; the keys must all exist and be visible to the caller.
|
|
175
|
+
- **`reorder`** sets `field` to `start`, `start` + 1, ... in the order of `keys`, so a long list sends only the stretch that moved, and writes only the records whose value changes, each as an ordinary update (so each needs its `etags` entry, and hooks see each). To work with a non-deferrable unique index such as `(invoice_id, position)`, the changing records are first moved out of the range in use, in the same transaction and without touching their ETags: above the highest value of the column, or, when a check constraint refuses that (checked with a savepoint), below the lowest one. Then they get their final values, which collide with nothing. The field must be an integer the caller may write; the keys must all exist and be visible to the caller. When it is the resource's [position with `after`](ui-config.md#ranked-after-what-they-depend-on)), a reorder that puts a record at or above a record it depends on, or one of those at or below it, fails with `409` and the type `ranks-above-dependency`, naming both keys in `record` and `dependsOn`; pairs out of order before it do not count.
|
|
176
176
|
- **Result**: `{ results: [...] }`, one entry per operation in order: `create` and `update` give `record` and `etag`, `delete` gives `deleted: true`, `reorder` gives `records` (every key in order, with its etag).
|
|
177
177
|
- **Failure**: nothing is written. The problem is the failing operation's own (`400`, `403`, `404`, `409`, `412`, `428`, ...) with `operation` (its index), `op` and `resource` added. A stale ETag anywhere is a `412` for the whole batch.
|
|
178
178
|
|
|
@@ -62,7 +62,7 @@ export const repairs = resource('repairs')
|
|
|
62
62
|
| `.tenant((r) => r.organization_id)` | The column that separates tenants: every query is limited to the caller's tenant, creates set it, and a request body may not. |
|
|
63
63
|
| `.owner((r) => r.owner_id)` | The field holding the owning user's id, which `.own` capabilities filter on (see [Access](#access)). |
|
|
64
64
|
| `.search((r) => [r.number, r.name])` | The fields that `search("...")` and bare words in a filter match, and what the admin's [global search](client.md#global-search)) looks in. Every word of the text must appear in one of them, ignoring case, and part of a word is enough: `port` finds "Portfolio". `r.phone.digitsEnd()` matches only the end of a field's digits instead, ignoring spaces, `+` and dashes, and only words written like phone numbers: `9623`, `47069623` and `+31 6 47069623` find "+31 6 47069623", `4706` and `+316` do not. Each field needs a pg_trgm index (`using gin (name gin_trgm_ops)`), a `digitsEnd` one on `regexp_replace(phone, '[^0-9]', '', 'g')`, or the API refuses the search. |
|
|
65
|
-
| `.position((r) => r.position, { within? })` | The integer field holding the records' order by hand, 1 the first, which a list's **Reorder** button changes by dragging; with `within: (r) => r.invoice_id`, a filterable relation, each parent's records have an order of their own, sorted in its related section. The field must be sortable. See [Reordering by hand](ui-config.md#reordering-by-hand)). |
|
|
65
|
+
| `.position((r) => r.position, { within?, after? })` | The integer field holding the records' order by hand, 1 the first, which a list's **Reorder** button changes by dragging; with `within: (r) => r.invoice_id`, a filterable relation, each parent's records have an order of their own, sorted in its related section; with `after`, a record never ranks above the records it depends on. The field must be sortable. See [Reordering by hand](ui-config.md#reordering-by-hand)) and [Ranked after what they depend on](ui-config.md#ranked-after-what-they-depend-on)). |
|
|
66
66
|
| `.validate((record) => issues)` | A rule over the whole record, run after the field checks on every create and update. It returns `[{ field, message }]` or `undefined`; issues answer `400` with the field named. |
|
|
67
67
|
| `.access({ ... })` | Rules per operation. See [Access](#access). |
|
|
68
68
|
| `.events((e, r) => [...])` | What changes of its records mean, such as `orders.created`, captured in the database for every write. See [Events](events.md)). |
|
|
@@ -86,7 +86,7 @@ Record pages take the same conditions in the `when` of `l.section`, `l.related`
|
|
|
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 `bath`, `bed`, `bell`, `bookmark`, `calendar`, `door-open`, `external-link`, `file-text`, `heart`, `house`, `key`, `land-plot`, `leaf`, `ruler`, `send`, `tag` or `wallet`; another name shows a lightning bolt. With `confirm` the button asks first. 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.
|
|
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 `wallet`; another name shows a lightning bolt. With `confirm` the button asks first. 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
|
|
|
@@ -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: `bath`, `bed`, `bell`, `bookmark`, `calendar`, `door-open`, `external-link`, `file-text`, `heart`, `house`, `key`, `land-plot`, `leaf`, `ruler`, `send`, `tag` or `wallet`, as for [actions](layouts.md#named-actions)), and above the value in a section of [key facts](#key-facts). Nowhere else shows it. |
|
|
76
|
+
| `.icon(name)` | An icon before the value on a card's meta row: `ban`, `bath`, `bed`, `bell`, `bookmark`, `calendar`, `door-open`, `external-link`, `file-text`, `heart`, `house`, `key`, `land-plot`, `leaf`, `ruler`, `send`, `tag` or `wallet`, as for [actions](layouts.md#named-actions)), 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. |
|
|
@@ -236,6 +236,20 @@ export default defineUi({
|
|
|
236
236
|
|
|
237
237
|
The list names it with `drag: { rank: true, rule: 'afterWhatItWaitsFor' }`. A drop the rule refuses lands in the first place below that it allows, and a warning says where with the rule's reason; with no such place the row stays where it was, with the same warning. The rule only guides the drag: the server's access rules and `validate` still decide what is saved. A list naming a rule the UI config does not register says so in place of its rows.
|
|
238
238
|
|
|
239
|
+
#### Ranked after what they depend on
|
|
240
|
+
|
|
241
|
+
Some records wait for others, such as a task blocked by another task. With `after`, the resource's position keeps each record below the records it depends on, through a join resource, for as long as they match `while`:
|
|
242
|
+
|
|
243
|
+
```ts
|
|
244
|
+
.position((r) => r.position, {
|
|
245
|
+
after: { resource: 'task_dependencies', field: 'task_id', key: 'depends_on_id', filter: 'type = "blocked-by"', while: 'status != "done"' },
|
|
246
|
+
})
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
`field` and `key` are filterable relations of the join resource to the ranked one: `field` holds the record that waits, `key` the record it waits for. `filter` narrows the join records and `while` the records waited for, both optional. The ranked resource needs a key of one field; the config is checked when it loads.
|
|
250
|
+
|
|
251
|
+
The server's [`reorder`](api.md#batch-writes)) refuses an order that puts a record at or above a pending record it depends on, or one of those at or below it. Pairs already out of order, such as a dependency added after the ranking, do not block other moves. The list's `drag: { rank: true }` follows it on the table and the board without another option. Before it saves a drop, it reads the record's dependencies through the list API, so the join resource's `field` and `key` need an index. A card or row dropped above a record it depends on lands in the first place below that keeps the order, and a warning names that record by its title. On a board the ranks are those of every column, so a card whose dependency in another column ranks above its whole column takes the last place, with a rank just above that dependency. With no such place, it stays where it was, with the same warning.
|
|
252
|
+
|
|
239
253
|
#### Board drops
|
|
240
254
|
|
|
241
255
|
Some boards are by a field that cannot be written, such as a status the database computes from other records. A board drop, in `protobase.ui.tsx` under `boardDrops`, says which columns take a card and what a drop on each writes instead: by the column's value, a function that gets the card's record as listed, its key and ETag, the column's value as `to`, and the API `client`. It resolves a function that undoes the write, or nothing when it cannot be undone:
|
|
@@ -586,7 +600,7 @@ export const repairsView = filtered
|
|
|
586
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). |
|
|
587
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). |
|
|
588
602
|
| `l.sidebar(fields, { when? })` | A summary card beside it, read-only. `when` also takes a [condition](#form-and-read-view). |
|
|
589
|
-
| `l.related(title, { ... })` | A table of the records of another resource that point at this one, in the main column. See [Related records](#related-records). |
|
|
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). |
|
|
590
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. |
|
|
591
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). |
|
|
592
606
|
| `l.gallery(title, { image?, photos?, when? })` | The record's photos as tiles, opening a lightbox. See [Galleries](#galleries). |
|
|
@@ -786,10 +800,12 @@ Without any configuration, the record page's rail has a **Related records** card
|
|
|
786
800
|
| `from` | A field of this record whose value `field` must hold, instead of this record's key, such as the task of a question, to list the task's links: `{ resource: 'task_links', field: 'task_id', from: 'task_id' }`. Same type as `field` (a relation to the same resource), not sensitive, and not with `through`. A record with no value lists nothing. |
|
|
787
801
|
| `through` | `{ resource, field, key?, filter? }`: the join records whose `field` (a filterable relation) holds this record's key; their `key` values (default their primary key) pick the listed records. All of them are read. |
|
|
788
802
|
| `filter`, `sort` | AIP-160 and AIP-132 on `resource`, as in the list API. `filter` narrows the listed records, `through.filter` the join records. |
|
|
789
|
-
| `columns` | Fields of `resource`, through relations too (`unit_id.property_id`); default the view's list columns without `field`. The first links to the record a row opens. |
|
|
803
|
+
| `columns` | Fields of `resource`, through relations too (`unit_id.property_id`); default the view's list columns without `field`. The first links to the record a row opens. With `presentation: 'cards'`, the fields each card shows. |
|
|
804
|
+
| `presentation` | `'cards'` shows the records as [cards](#related-records-as-cards) instead of the table or display. |
|
|
805
|
+
| `actions` | Named actions of `resource`'s view, by name, as buttons on each card; only with `presentation: 'cards'`. |
|
|
790
806
|
| `open` | The relation of `resource` whose record a row opens, for rows that link this record to another. By default the one relation in `resource`'s primary key besides `field`, when there is exactly one (a join resource such as `task_dependencies` keyed on `[task_id, type, depends_on_id]`); otherwise rows open their own records. The row's menu then has **Open** for the other record and **Edit** for the link itself. |
|
|
791
807
|
| `limit` | How many records it shows, 1 to 100; default 10. When there are more, the section says so beside View all, such as "The first 10 of 37.". Before 0.13 this was `pageSize`, rows per page; rename it. |
|
|
792
|
-
| `display` | The display of `resource`'s list it opens in, such as `cards`; default the list's. |
|
|
808
|
+
| `display` | The display of `resource`'s list it opens in, and View all opens, such as `cards`; default the list's. |
|
|
793
809
|
| `help`, `empty` | A line under the title, and the text when nothing matches (default "Nothing here yet."). |
|
|
794
810
|
| `hideEmpty` | `true` leaves the section off the page while it has no records. |
|
|
795
811
|
|
|
@@ -843,6 +859,24 @@ When `resource` is ordered by hand within the record on the page (`.position(...
|
|
|
843
859
|
|
|
844
860
|
Every name is checked when the config loads. In `/meta` a caller who cannot read a resource the section names, or a field its filter or sort uses, does not get the section, and columns they cannot read are left out; the rows come from the list API with the caller's token, so row filters apply as everywhere else.
|
|
845
861
|
|
|
862
|
+
#### Related records as cards
|
|
863
|
+
|
|
864
|
+
With `presentation: 'cards'` the section shows each record as a card, the cards stacked full width so a long value has room: the record's title, a link to its page, then each of `columns` under its label as the record page shows it (a markdown field rendered, a relation by its name), and a button for each of `actions`. A value taller than a few lines is cut short with **Show more**, which shows it all. The buttons run the actions as the record page does: one with `confirm` asks first, one with [inputs](#actions-that-ask-for-input) opens its dialog (a sheet on a phone), and an `a.action` runs the app's handler; a card leaves out an action the user does not get and disables one they cannot run on that record. After an action the section loads again, so a record it no longer matches leaves it, and with `hideEmpty` the section goes once nothing matches.
|
|
865
|
+
|
|
866
|
+
```ts
|
|
867
|
+
l.related('Waiting on you', {
|
|
868
|
+
resource: 'task_preconditions',
|
|
869
|
+
field: 'task_id',
|
|
870
|
+
filter: 'state = "waiting"',
|
|
871
|
+
presentation: 'cards',
|
|
872
|
+
columns: ['plan'],
|
|
873
|
+
actions: ['approve', 'request_changes'],
|
|
874
|
+
hideEmpty: true,
|
|
875
|
+
})
|
|
876
|
+
```
|
|
877
|
+
|
|
878
|
+
An action that `actions` names must be a named action of `resource`'s view. The cards have no display switch or **Reorder**; View all opens the list as a table section would.
|
|
879
|
+
|
|
846
880
|
## Actions and views per role
|
|
847
881
|
|
|
848
882
|
```ts title="docs-examples/bike-shop/step-5.ts"
|