@protobase/cli 0.100.11 → 0.100.13
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
CHANGED
|
@@ -38,7 +38,7 @@ const relatedShapes = (term, models, from) => {
|
|
|
38
38
|
const title = (page, read) => {
|
|
39
39
|
const node = elementAt(page.tree, read.block);
|
|
40
40
|
const named = node && (text(node.props.title) ?? text(node.props.label));
|
|
41
|
-
const part = read.part === "calls" ? " calls" : read.part === "chosen" ? " chosen row" : read.part === "condition" ? " condition" : "";
|
|
41
|
+
const part = read.part === "calls" ? " calls" : read.part === "chosen" ? " chosen row" : read.part === "condition" ? " condition" : read.part === "total" ? " total" : "";
|
|
42
42
|
return `page "${page.name}", <${node?.type ?? "Page"}${named ? ` "${named}"` : ""}>${part}`;
|
|
43
43
|
};
|
|
44
44
|
const readSort = (page, read, model, view) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.100.
|
|
3
|
+
"version": "0.100.13",
|
|
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.100.
|
|
47
|
-
"@protobase/layout": "0.100.
|
|
48
|
-
"@protobase/query": "0.100.
|
|
49
|
-
"@protobase/schema": "0.100.
|
|
50
|
-
"@protobase/server": "0.100.
|
|
51
|
-
"@protobase/ui": "0.100.
|
|
52
|
-
"@protobase/workflows": "0.100.
|
|
46
|
+
"@protobase/config": "0.100.13",
|
|
47
|
+
"@protobase/layout": "0.100.13",
|
|
48
|
+
"@protobase/query": "0.100.13",
|
|
49
|
+
"@protobase/schema": "0.100.13",
|
|
50
|
+
"@protobase/server": "0.100.13",
|
|
51
|
+
"@protobase/ui": "0.100.13",
|
|
52
|
+
"@protobase/workflows": "0.100.13",
|
|
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",
|
|
@@ -19,7 +19,8 @@ Pages of your own, built from blocks in a JSX layout.
|
|
|
19
19
|
- [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.
|
|
20
20
|
- [Data blocks](../reference/blocks.md#data): Counts, tables, single records, rows of cards, field values and progress bars.
|
|
21
21
|
- [Related records](../reference/layouts.md#related-records) (beta): Layouts repeat over a record's related records, the records a JSON list of keys points at and the items of a JSON list with `ReferenceManyField`, `ReferenceArrayField`, `ArrayField`, `RecordsIterator` and `ReferenceField`, nested as deep as needed, and a table draws such a list.
|
|
22
|
-
- [
|
|
22
|
+
- [Actions in a list](../reference/layouts.md#actions-in-a-list) (beta): An action placed in a list of related records runs on every record of that list, with one confirmation that counts them.
|
|
23
|
+
- [Read plans](../reference/layouts.md#how-a-page-reads-its-data) (beta): The build plans one read per data block ahead of time, derives the fields each read needs, and checks every nested read's indexes. Every read of a page's records, card rows, record rows, tables, threads, charts, counts, related lists and the custom components that declare their reads starts at once when it opens, those inside the records of another block included, and a data block's [text form](../reference/layouts.md#a-pages-text-with-its-records) lists its records; record rows of favorites or saved searches, record rows inside the records of another block, and custom components that fetch their own data, still load on their own.
|
|
23
24
|
- [Table columns on a phone](../reference/blocks.md#columns-on-a-phone): Table blocks choose which columns show at mobile width by priority, with a sensible default, and fall back to a Markdown table.
|
|
24
25
|
- [Row buttons](../reference/blocks.md#row-buttons) (experimental): A table's rows carry a button labelled by a field of the row, such as its next step; the row decides where it goes: a record tab a field names, a list with a filter built from its fields, a list whose resource and filter its fields hold, or an outside https link a field holds. On mobile width the button sits under the row's first cell.
|
|
25
26
|
- [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.
|
|
@@ -714,12 +714,12 @@ A text box that grows with its text: Enter or the send button creates a record o
|
|
|
714
714
|
|
|
715
715
|
### Action
|
|
716
716
|
|
|
717
|
-
A button for a [named action](layouts.md#named-actions) of the view, on the record around it.
|
|
717
|
+
A button for a [named action](layouts.md#named-actions) of the view, on the record around it, or, directly in a `ReferenceManyField` or `ReferenceArrayField`, on every record of that list ([actions in a list](layouts.md#actions-in-a-list)).
|
|
718
718
|
|
|
719
719
|
| Prop | |
|
|
720
720
|
| --- | --- |
|
|
721
721
|
| `name` | The action's name in the view. Required. |
|
|
722
|
-
| `resource` | Outside a record: the resource whose view declares it. |
|
|
722
|
+
| `resource` | Outside a record and a list: the resource whose view declares it. |
|
|
723
723
|
| `label` | Default: the action's label. |
|
|
724
724
|
| `variant` | `primary`, `secondary` (default), `danger` or `ghost`. |
|
|
725
725
|
|
|
@@ -133,7 +133,7 @@ A `RecordCard` (its first match), a `ReferenceField`, each card of a `CardRow` a
|
|
|
133
133
|
## Related records
|
|
134
134
|
|
|
135
135
|
:::caution[Beta]
|
|
136
|
-
A list's next pages, with `pagination="more"`, are a read of the list's own.
|
|
136
|
+
A list's next pages, with `pagination="more"`, are a read of the list's own.
|
|
137
137
|
:::
|
|
138
138
|
|
|
139
139
|
A record's related records repeat under it as a list: a `ReferenceManyField` holds the records of another resource that point at it, a `ReferenceArrayField` the records whose keys a JSON field of it lists, and an `ArrayField` the items of a JSON list it holds. A `RecordsIterator` inside one draws its children once for each entry, with nothing around them, and a `Table` without `resource` draws the list as a table. A `ReferenceField` draws the one record a field points at. They take the names, props and defaults of the [react-admin](../features/compatibility.md#react-admin) components of the same names.
|
|
@@ -161,25 +161,25 @@ Each entry is a record of the stack while its children draw, so `Field`, `Show`,
|
|
|
161
161
|
## How a page reads its data
|
|
162
162
|
|
|
163
163
|
:::caution[Beta]
|
|
164
|
-
On the web, a `RecordRow` of a view with `listOf` or `searchesOf`,
|
|
164
|
+
On the web, a `RecordRow` of a view with `listOf` or `searchesOf`, or one inside the records of another block, still reads once it draws, as the marked limits below say.
|
|
165
165
|
:::
|
|
166
166
|
|
|
167
167
|
The build compiles each page into a read plan: one ordinary API read per data block, each known before any record is read, so all of them start together when the page opens and none waits for another's rows. There is no combined page query: each read is a request of its own. `/api/meta` sends each user the plan of the page as they see it, so it holds no read of a resource they cannot read and no field they cannot read.
|
|
168
168
|
|
|
169
|
-
- **One read per block.** `Stat`, `RecordCard`, `Table`, `CardRow`, `RecordRow`, `RecordCards`, `Thread`, `Chart`, `Timeline`, `ReferenceManyField`, `ReferenceArrayField` and `ReferenceField` each make one list, count or `:aggregate` read. A `Thread`'s tool calls, the row a `Table`'s or the bar a `Timeline`'s `select` chose
|
|
169
|
+
- **One read per block.** `Stat`, `RecordCard`, `Table`, `CardRow`, `RecordRow`, `RecordCards`, `Thread`, `Chart`, `Timeline`, `ReferenceManyField`, `ReferenceArrayField` and `ReferenceField` each make one list, count or `:aggregate` read. A `Thread`'s tool calls, the row a `Table`'s or the bar a `Timeline`'s `select` chose, each `<resource>.count` a condition names and the total per record of a `Table` or `RecordCards` inside the records of another (`#total`) are reads of their own. A block under `Show` or `Match` is read anyway: the condition decides only what is drawn.
|
|
170
170
|
- **Fields are derived.** You never write `fields`. Each read asks for its key and every field drawn in its scope: by `Field`s, [field components](#field-values), `{{path}}`s, conditions and table columns, and the fields a nested list ties itself by. A block whose view decides what it draws, such as a `Table` without `columns` or a `RecordRow`, reads every field. So does a read whose records an `Action` or an edit form changes, since it asks for each record's ETag and an ETag covers the whole record. The other reads ask for no ETag (`etag=false`), so the database reads only their fields.
|
|
171
171
|
- **A nested read carries the read around it.** A block inside the records of another ties itself to them by a field: a `ReferenceManyField`'s `target`, a `ReferenceField`'s or `ReferenceArrayField`'s `source`, or `task_id = {{id}}` as a top-level `AND` term of a filter. Its read takes that as a [`related()`](api.md#filtering-through-related-records) term holding the outer read's own filter, order and page size, such as `related(task_id, tasks.id, (status = "open"), "id desc", 10)`, never the values of records read first. A `ReferenceArrayField` ties itself by the JSON list of keys the same way, `related(id, tasks.waits, …)`. Terms nest for a list two levels deep.
|
|
172
172
|
- **Per record, in one read.** Inside a repeated record, such as a `CardRow` or a `RecordsIterator`, a list reads its `perPage` (or `limit`) for each record with [`limit_per`](api.md#first-rows-per-value), and a `Stat` count is one `:aggregate` grouped by the field it ties itself by. Each nested read holds at most 500 records in all, the API's largest page, and the build warns when the records around it times its page are more, as some records would show fewer. A `ReferenceArrayField` there reads one page for all the records around it, of up to `perPage` records for each of them, since one record can sit in several lists. A `RecordRow` there needs a `limit`.
|
|
173
173
|
- **The page's own record.** A field of it that the address does not hold, `{{@root.project_id}}`, becomes `related()` on that record by its key, so the page's record is not read first. Page parameters and the page record's key stay `{{…}}` slots in the plan, which the address fills.
|
|
174
174
|
- **Indexes.** [`protobase doctor`](cli.md#doctor) judges every planned read with the scan guard's rule, the outer reads its `related()` terms carry included, so it reports a nested read's missing index before the API refuses the read.
|
|
175
175
|
|
|
176
|
-
When a page opens, the web starts every read of its plan at once, with the page's parameters filled in, whatever a condition says and however deep a block sits. A `RecordCard`, `CardRow`, `Stat`, `ReferenceManyField`, `ReferenceArrayField` and `ReferenceField` then draw from their read and read nothing themselves; one inside the records of another takes the rows of its own record out of its read, by the field it ties itself by. Inside a record the plan did not read, such as one of a list's later pages, it reads its rows itself. A `Table`, `Thread`, `Chart` and `RecordCards`, the row a `select` chose, a `Thread`'s tool calls and each `<resource>.count` a condition names start in the same wave with the very request their block makes, labels, photos and totals included, so the block finds it loading or loaded once it draws and nothing is read twice. A `Show` or `Match` decides only what is drawn: switching what it shows starts no new read. A change to a resource, live or the page's own, reads again exactly the reads of that resource, and a nested read also when the records around it change.
|
|
176
|
+
When a page opens, the web starts every read of its plan at once, with the page's parameters filled in, whatever a condition says and however deep a block sits. A `RecordCard`, `CardRow`, `Stat`, `ReferenceManyField`, `ReferenceArrayField` and `ReferenceField` then draw from their read and read nothing themselves; one inside the records of another takes the rows of its own record out of its read, by the field it ties itself by. Inside a record the plan did not read, such as one of a list's later pages, it reads its rows itself. A `Table`, `Thread`, `Chart` and `RecordCards`, the row a `select` chose, a `Thread`'s tool calls and each `<resource>.count` a condition names start in the same wave with the very request their block makes, labels, photos and totals included, so the block finds it loading or loaded once it draws and nothing is read twice. A `Table`, `Thread` or `RecordCards` inside the records of another draws its first rows from its planned read in the same way, its own record's out of all: that read asks for the names of the records its relations point at and its cards' photos, as the block's own read would, and beside it a count gives each record its total, so a table says "The first 10 of 37." for each record. Only what comes after, such as a thread's earlier messages or a table sorted by one of its headers, the block reads itself. A `Show` or `Match` decides only what is drawn: switching what it shows starts no new read. A change to a resource, live or the page's own, reads again exactly the reads of that resource, and a nested read also when the records around it change.
|
|
177
177
|
|
|
178
178
|
Each read in the plan (`page.reads.reads`) names its block by a JSON Pointer into the page's tree, such as `/children/0/children/2`, which `elementAt(tree, pointer)` finds. It gives the read's `resource`, its `kind` (`list`, `count` or `aggregate`), `filter`, `orderBy`, `pageSize`, `limitPer`, `groupBy`, `fields` (absent for every field), `etag`, and for a read inside the records of another its `split`: the `field` its rows hold the value `source`, a path, reads where the block draws, and the `parent` read, by `planReadId(read)`. `compileReadPlan(tree, { models })` makes the same plan from a tree of your own. `runReadPlan(plan, read, { params })` starts every read at once through `read` and gives each outcome by `planReadId`, and `plannedRows(read, rows, scope)` the rows of one record around a block.
|
|
179
179
|
|
|
180
180
|
A [custom component](custom-components.md#reads) is planned when it declares its reads: the page starts them with the others, each of several a part of its own named by its resource prop (`/children/0#edges`), and the component draws from them. One that declares none is outside the plan (`page.reads.outside`): whatever it reads, it reads by itself once it draws, and `protobase doctor` lists it.
|
|
181
181
|
|
|
182
|
-
<gap>A `RecordRow` of a view with `listOf` or `searchesOf` cannot start its read when the page opens because starting the user's saved records or searches ahead of it is not implemented, so it reads once it draws, under a `Show` or `Match` once its condition holds.</gap> <gap>A `
|
|
182
|
+
<gap>A `RecordRow` of a view with `listOf` or `searchesOf` cannot start its read when the page opens because starting the user's saved records or searches ahead of it is not implemented, so it reads once it draws, under a `Show` or `Match` once its condition holds.</gap> <gap>A `RecordRow` inside the records of another block cannot start its read when the page opens because a planned first page per record is not implemented, so it reads once it draws.</gap> <gap>A `Chart` cannot sit inside a repeated record because grouping a chart per record is not implemented.</gap> <gap>A `Table` or `RecordCards` tied by a JSON list of keys cannot show every record its total when the lists around it hold more than 500 keys in all because paging a total's groups is not implemented.</gap>
|
|
183
183
|
|
|
184
184
|
## Field values
|
|
185
185
|
|
|
@@ -312,6 +312,27 @@ Record pages take the same conditions in the `when` of `l.section`, `l.related`
|
|
|
312
312
|
|
|
313
313
|
`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`, `history`, `house`, `key`, `land-plot`, `leaf`, `memory`, `network`, `play`, `plug`, `plus`, `power`, `restart`, `ruler`, `send`, `server`, `stop`, `table`, `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; there an `a.link` is a real link that looks like the rail's buttons, which the browser can preview, copy or open in a new tab, while a disabled one is a disabled button with its reason. <gap>An `<Action>` block for an `a.link` cannot be opened in a new tab or copied as a link because drawing link actions as links is not implemented for the block.</gap>
|
|
314
314
|
|
|
315
|
+
### Actions in a list
|
|
316
|
+
|
|
317
|
+
:::caution[Beta]
|
|
318
|
+
It runs only on the records the list has loaded, up to its `perPage` and any pages read with `pagination="more"`, and its dialog shows no progress, as for [signing several records off](blocks.md#signing-several-records-off).
|
|
319
|
+
:::
|
|
320
|
+
|
|
321
|
+
Where an `Action` sits decides what it runs on. Directly in a `ReferenceManyField` or `ReferenceArrayField`, outside its `RecordsIterator`, it runs on every record of that list; inside the `RecordsIterator`, it runs on the one record of its entry:
|
|
322
|
+
|
|
323
|
+
```tsx
|
|
324
|
+
<ReferenceManyField reference="approvals" target="release_id">
|
|
325
|
+
<Action name="approve" />
|
|
326
|
+
<RecordsIterator>
|
|
327
|
+
<Card title="{{title}}"><Action name="approve" /></Card>
|
|
328
|
+
</RecordsIterator>
|
|
329
|
+
</ReferenceManyField>
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
The list's button counts the records the action applies to, such as **Approve (3)**, and runs as a [selection in a list](blocks.md#signing-several-records-off) does, whether or not the action has `bulk`: it asks its question or inputs once, a checklist shows each box once however many records hold it, and a record the person may not change is refused and named while the others run. It is not offered when the list holds no record the action applies to, and an `a.link` is not offered there. An `Action` with `resource` naming another resource keeps working as outside the list. In the [text form](#text-form), the list's action reads as its label with the count, `Approve (3)`.
|
|
333
|
+
|
|
334
|
+
<gap>An `Action` in a list cannot run on records past the pages the list has loaded because reading the rest of a list for an action is not implemented.</gap>
|
|
335
|
+
|
|
315
336
|
### Links to a record's URL
|
|
316
337
|
|
|
317
338
|
A link whose `href` is a single `{{field}}` opens the address that field holds, such as the page a listing came from:
|