@protobase/cli 0.88.2 → 0.89.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/migration/parts.js +2 -2
- package/package.json +8 -8
- package/skills/protobase/references/features/composed-pages.md +1 -0
- package/skills/protobase/references/features/record-pages.md +1 -1
- package/skills/protobase/references/reference/blocks.md +17 -0
- package/skills/protobase/references/reference/derived.md +9 -4
- package/skills/protobase/references/reference/ui-config.md +2 -1
package/dist/cli/package.js
CHANGED
package/dist/migration/parts.js
CHANGED
|
@@ -31,11 +31,11 @@ const migrationParts = (project) => {
|
|
|
31
31
|
title: "The role the assistant's read-only queries run as, which reads only the resources' tables",
|
|
32
32
|
sql: () => queryRunnerMigration(project.db, project.models, project.authTables)
|
|
33
33
|
}] : [],
|
|
34
|
-
|
|
34
|
+
{
|
|
35
35
|
name: "derived",
|
|
36
36
|
title: "The state of the resources' derived values and what they read",
|
|
37
37
|
sql: () => derivedMigration(project.db, project.models)
|
|
38
|
-
}
|
|
38
|
+
},
|
|
39
39
|
...comments ? [{
|
|
40
40
|
name: "comments",
|
|
41
41
|
title: "The comments table of the resources with comments",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.89.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.89.1",
|
|
47
|
+
"@protobase/layout": "0.89.1",
|
|
48
|
+
"@protobase/query": "0.89.1",
|
|
49
|
+
"@protobase/schema": "0.89.1",
|
|
50
|
+
"@protobase/server": "0.89.1",
|
|
51
|
+
"@protobase/ui": "0.89.1",
|
|
52
|
+
"@protobase/workflows": "0.89.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",
|
|
@@ -13,6 +13,7 @@ Pages of your own, built from blocks in a JSX layout.
|
|
|
13
13
|
- [Layout blocks](../reference/blocks.md#layout): Pages, responsive grids, cards and links.
|
|
14
14
|
- [Full-width pages](../reference/blocks.md#page): A page fills the whole area beside the sidebar instead of a centred column, for a dashboard with many blocks.
|
|
15
15
|
- [Data blocks](../reference/blocks.md#data): Counts, tables, single records, rows of cards, field values and progress bars.
|
|
16
|
+
- [Row buttons](../reference/blocks.md#row-buttons): A table's rows carry a button to an address their fields name, such as a task's tab, labelled by a field of the row, such as its next step.
|
|
16
17
|
- [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.
|
|
17
18
|
- [Record cards](../reference/blocks.md#recordcards): Full-width cards with fields and buttons, stacked or in a carousel.
|
|
18
19
|
- [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.
|
|
@@ -25,7 +25,7 @@ The page of one record, with its sections, related records, galleries, charts an
|
|
|
25
25
|
- [Help while editing](../reference/ui-config.md#help-while-editing): Help lines meant for whoever changes a record show only on its form.
|
|
26
26
|
- [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.
|
|
27
27
|
- [Galleries](../reference/ui-config.md#galleries): A record's photos show as tiles that open a full-screen lightbox, with keyboard and swipe navigation.
|
|
28
|
-
- [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.
|
|
28
|
+
- [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, each row or card with a button to an address its fields name.
|
|
29
29
|
- [Record lines](../reference/ui-config.md#record-lines): The related table a record's view marks as its lines, such as an invoice's, shows all of them on its page, where you edit, add, remove and reorder them, and Save writes the record and its lines together.
|
|
30
30
|
- [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.
|
|
31
31
|
- [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.
|
|
@@ -207,6 +207,7 @@ The first records of a list, drawn the way the resource's list page draws them:
|
|
|
207
207
|
| --- | --- |
|
|
208
208
|
| `resource`, `filter`, `sort` | Which records, in which order. `resource` is required; `sort` defaults to the list's. |
|
|
209
209
|
| `columns` | Field names for the table; default the view's list columns. |
|
|
210
|
+
| `button` | A [button on each row](#row-buttons) to an address the row's fields name. |
|
|
210
211
|
| `limit` | How many records it shows; default 10. It has no pages: the rest are in the list. Before 0.13 this was `pageSize`, rows per page; rename it. |
|
|
211
212
|
| `display` | The display it opens in, such as `cards`; default the list's. |
|
|
212
213
|
| `title`, `description`, `actions` | The heading. |
|
|
@@ -217,6 +218,22 @@ The first records of a list, drawn the way the resource's list page draws them:
|
|
|
217
218
|
<Table title="Overdue invoices" resource="invoices" filter="status = 'overdue'" sort="issued_at" columns={['number', 'company_id', 'due_at', 'total']} limit={5} empty="Nothing is overdue." />
|
|
218
219
|
```
|
|
219
220
|
|
|
221
|
+
#### Row buttons
|
|
222
|
+
|
|
223
|
+
`button: { label, to }` adds a last column with a button on each row: a link, drawn as a button, to `to`, an [address](layouts.md#addresses) in the app, such as a record on one of its [tabs](ui-config.md#tabs). `{field}` in the address or the label is replaced by the row's value, the label's as the record page shows it (an enum value by its label), so each row can name its own next step. A row with no value for a field the button names shows no button. The button is checked when the config loads, and `/meta` gives it, on the block or the related section, to callers who can read the fields it names and follow its address, and leaves it out for the others. A [related section](ui-config.md#related-records) takes the same `button`, on its table's rows or its cards.
|
|
224
|
+
|
|
225
|
+
```tsx
|
|
226
|
+
<Table
|
|
227
|
+
title="Waiting on you"
|
|
228
|
+
resource="holds"
|
|
229
|
+
filter="state = 'open'"
|
|
230
|
+
columns={['reason', 'task_id']}
|
|
231
|
+
button={{ label: '{verb}', to: { kind: 'record', resource: 'tasks', key: '{task_id}', tab: 'Review' } }}
|
|
232
|
+
/>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
<gap>A row button cannot show when the table switches to a list display such as cards because drawing it on a display is not implemented.</gap>
|
|
236
|
+
|
|
220
237
|
### RecordCard
|
|
221
238
|
|
|
222
239
|
One record and what is inside it: the one `recordKey` names (the key as the record's URL has it), else the first that matches `filter` in `sort` order. Its children and its heading `actions` work on that record.
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
A TypeScript function's result kept current by itself, recomputed when what it read changes or when a time rule flips.
|
|
6
6
|
|
|
7
7
|
:::caution[Experimental]
|
|
8
|
-
Derived values may change in any release. They cannot fill a list of rows in another resource yet, cannot see the reads inside a database function or view they call, show `recalculating` rather than `stale` after a failed run, and their status cannot be read through the REST API; [Limits](#limits) has the detail.
|
|
8
|
+
Derived values may change in any release. They cannot fill a list of rows in another resource yet, cannot see the reads inside a database function or view they call, show `recalculating` rather than `stale` after a failed run, keep what an earlier version of their function computed until a record changes, keep their last result, or none before a first one, while what they read changes during every run, and their status cannot be read through the REST API; [Limits](#limits) has the detail.
|
|
9
9
|
:::
|
|
10
10
|
|
|
11
11
|
A **derived value** is worked out from other records for each record of a resource, such as a verdict on an objective from its tasks. You write a small TypeScript function that reads records and the clock; Protobase records what it read, computes it again when a change touches that or when a time check flips, and stores the result. No timer is involved, and a value that did not change is not written. It works on any Postgres, with no extension.
|
|
@@ -52,7 +52,7 @@ The function gets the record's key as its URL has it, and returns the value as J
|
|
|
52
52
|
|
|
53
53
|
| | |
|
|
54
54
|
| --- | --- |
|
|
55
|
-
| `db` | The app's database. Each query sent through it is analysed, raw SQL included
|
|
55
|
+
| `db` | The app's database, in a read-only transaction, so a write throws before it happens, and so does opening a transaction of its own. Each query sent through it is analysed, raw SQL included. |
|
|
56
56
|
| `clock` | The time; see [The clock](#the-clock). |
|
|
57
57
|
| `depends(resource, where?)` | Names a dependency itself: every record of the resource, or those whose fields hold these values, such as `depends('tasks', { status: ['open', 'late'] })`. |
|
|
58
58
|
| `signal` | Aborted when the run times out or the worker shuts down. |
|
|
@@ -61,7 +61,7 @@ The function gets the record's key as its URL has it, and returns the value as J
|
|
|
61
61
|
|
|
62
62
|
Each query the function sends is parsed with Postgres's own parser, however it was built. For each table it reads, Protobase keeps the query's conditions on that table: comparisons of its columns with constants and parameters, `IN`, `= ANY`, `BETWEEN` and null tests, joined with `AND`, `OR` and `NOT`, with the conditions of inner joins, and of an outer join's `ON` for its optional side. The condition is the dependency, so a new row that comes to match is caught as well as a row that leaves it. A part it cannot work out, such as a function call or a column of another table, counts as matching every row: a query it cannot read at all reads the whole table. Nested queries, `WITH` queries and both sides of a `UNION` count too. An update counts only when it changes a column the query used.
|
|
63
63
|
|
|
64
|
-
A table that is no resource of `reads` or the record's own stops the run with an error naming it: add its resource to `reads`,
|
|
64
|
+
A table that is no resource of `reads` or the record's own stops the run with an error naming it: add its resource to `reads`. `depends()` takes only those resources too; with `track: false`, the dependencies it names are the only ones, for a function whose queries say less than it knows.
|
|
65
65
|
|
|
66
66
|
## The clock
|
|
67
67
|
|
|
@@ -77,9 +77,11 @@ Each check that has not flipped yet records the moment it will; the value is com
|
|
|
77
77
|
|
|
78
78
|
- **A new record** is computed once it is created, and a value declared for records that exist already computes each of them once, from the migration that adds it.
|
|
79
79
|
- **A change** that touches a recorded read, through the API or not, marks the value stale in the dispatch of [captured changes](events.md#how-changes-are-captured), and its run waits a second, so a burst of changes runs it once.
|
|
80
|
-
- **A change that lands while the function runs**
|
|
80
|
+
- **A change that lands while the function runs** and touches one of the reads that run made drops its result, and the value is computed again after the same second's wait; a change to what it did not read leaves the result kept.
|
|
81
|
+
- **Two runs of one record at once**, such as a change's and a time check's: only the one that started last keeps its result.
|
|
81
82
|
- **The value is written only when it differs**, so an unchanged value raises no event, live update or notification.
|
|
82
83
|
- A deleted record's value is dropped.
|
|
84
|
+
- A value no longer declared loses its state at the next migration, so declaring it again computes every record again.
|
|
83
85
|
|
|
84
86
|
Runs are `derived.compute` jobs, four at a time per worker, retried like any [job](jobs.md) when the function throws.
|
|
85
87
|
|
|
@@ -91,6 +93,7 @@ Runs are `derived.compute` jobs, four at a time per worker, retried like any [jo
|
|
|
91
93
|
| --- | --- |
|
|
92
94
|
| `derived.values` | A row per record and value: `status` (`current`, `stale` or `recalculating`), `value` as JSON, `computed_at`, and `flips_at`, the clock's next flip. |
|
|
93
95
|
| `derived.reads` | What each record's value read: the resource, the condition, and the fields it used. |
|
|
96
|
+
| `derived.pending` | The changes that landed while a record's run was under way, weighed against that run's reads when it ends. |
|
|
94
97
|
| `derived.declared` | The values whose records the migrations have computed once. |
|
|
95
98
|
|
|
96
99
|
## Limits
|
|
@@ -98,6 +101,8 @@ Runs are `derived.compute` jobs, four at a time per worker, retried like any [jo
|
|
|
98
101
|
- <gap>A derived value cannot fill a list of rows in another resource, such as one row per item that needs attention, because syncing a set of rows is not implemented.</gap>
|
|
99
102
|
- <gap>A derived value cannot see the reads inside a database function or view it calls, because reading their definitions is not implemented.</gap> Name them with `depends()`.
|
|
100
103
|
- <gap>A derived value whose function threw cannot show `stale` until its retry runs, because marking a failed run is not implemented; it shows `recalculating` meanwhile.</gap>
|
|
104
|
+
- <gap>A derived value cannot recompute the records it holds when its function changes, because tracking the function's code is not implemented; each record takes the new function at its next change or clock flip.</gap>
|
|
105
|
+
- <gap>A derived value cannot keep a result while a change touching what it read lands during every run, because bounding how often a run yields is not implemented; it keeps its last value meanwhile, and a record never computed has none.</gap>
|
|
101
106
|
- <gap>A derived value's status cannot be read through the REST API, because serving `derived.values` as a resource is not implemented.</gap>
|
|
102
107
|
|
|
103
108
|
## Reusing the detection
|
|
@@ -953,6 +953,7 @@ Without any configuration, the record page's rail has a **Related records** card
|
|
|
953
953
|
| `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. |
|
|
954
954
|
| `presentation` | `'cards'` shows the records as [cards](#related-records-as-cards) instead of the table or display. |
|
|
955
955
|
| `actions` | Named actions of `resource`'s view, by name, as buttons on each card; only with `presentation: 'cards'`. |
|
|
956
|
+
| `button` | `{ label, to }`: a [button on each row](blocks.md#row-buttons), or each card, to an address the row's fields name, such as `{ label: '{verb}', to: { kind: 'record', resource: 'tasks', key: '{task_id}', tab: 'Review' } }`; a row without a value for a field it names shows none. Not with `lines`. |
|
|
956
957
|
| `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. |
|
|
957
958
|
| `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. |
|
|
958
959
|
| `display` | The display of `resource`'s list it opens in, and View all opens, such as `cards`; default the list's. |
|
|
@@ -1012,7 +1013,7 @@ Every name is checked when the config loads. In `/meta` a caller who cannot read
|
|
|
1012
1013
|
|
|
1013
1014
|
#### Related records as cards
|
|
1014
1015
|
|
|
1015
|
-
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), leaving out a field the record has no value for,
|
|
1016
|
+
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), leaving out a field the record has no value for, a button for each of `actions`, and `button` before them. 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.
|
|
1016
1017
|
|
|
1017
1018
|
```ts
|
|
1018
1019
|
l.related('Waiting on you', {
|