@protobase/cli 0.99.5 → 0.99.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.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.99.5";
2
+ var version = "0.99.6";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.99.5",
3
+ "version": "0.99.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": {
@@ -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.99.5",
47
- "@protobase/layout": "0.99.5",
48
- "@protobase/query": "0.99.5",
49
- "@protobase/schema": "0.99.5",
50
- "@protobase/server": "0.99.5",
51
- "@protobase/ui": "0.99.5",
52
- "@protobase/workflows": "0.99.5",
46
+ "@protobase/config": "0.99.6",
47
+ "@protobase/layout": "0.99.6",
48
+ "@protobase/query": "0.99.6",
49
+ "@protobase/schema": "0.99.6",
50
+ "@protobase/server": "0.99.6",
51
+ "@protobase/ui": "0.99.6",
52
+ "@protobase/workflows": "0.99.6",
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,7 @@ 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
- - [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; custom components that fetch their own data are outside the plan.
22
+ - [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, counts and related lists starts at once when it opens, and a data block's [text form](../reference/layouts.md#a-pages-text-with-its-records) lists its records; tables, threads, charts and custom components that fetch their own data still load on their own.
23
23
  - [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
24
  - [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, or an outside https link a field holds. On mobile width the button sits under the row's first cell.
25
25
  - [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.
@@ -73,9 +73,9 @@ renderText(<Page title="Order"><Field source="status" /></Page>, {
73
73
  | --- | --- |
74
74
  | `record` | The record around the tree. `Field`, the [field components](#field-values), `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. The `{{path}}`s of props read it too. Without it, a field reads as its label alone, a condition as holding (a `Show` reads as its children, a `Switch` as its first `Match`), a prop's `{{path}}`s as empty, and addresses keep their `{{field}}`s. |
75
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
- | `records` | Per `ReferenceManyField`, `ReferenceArrayField` or `ReferenceField` element and the record around it, the records it holds, which you loaded; its `RecordsIterator` then reads as its children once per record, in that record, and an empty list as its `empty`. Without it, the block reads as a link to its records. An `ArrayField` reads its items from the record around it. For a `Table` with `select`, the row chosen, whose record its children read; without it they read as nothing. |
76
+ | `records` | Per `ReferenceManyField`, `ReferenceArrayField` or `ReferenceField` element and the record around it, the records it holds, which you loaded; its `RecordsIterator` then reads as its children once per record, in that record, and an empty list as its `empty`. Without it, the block reads as a link to its records. An `ArrayField` reads its items from the record around it. For a `RecordCard`, its record, which its children read; for a `CardRow`, its records, its children once per record. For a `Table` with `select`, the row chosen, whose record its children read; without it they read as nothing. It gets the element, the record around it and the element's place in the tree, the pointer the [read plan](#how-a-page-reads-its-data) names its block by. |
77
77
  | `params` | The [page parameters](#page-parameters) the page's address holds, such as `{ window: '30d' }`, which `@params` and the `SelectInput`s read, each held to its choices. |
78
- | `tables` | Per `Table` element, the records it shows and its columns (`{ columns: [{ name, label, title?, badge?, valueLabels? }], rows }`), which you loaded; the table then reads as its heading and a Markdown table. Without it, a table reads as its heading. |
78
+ | `tables` | Per `Table` element, its place in the tree, the record around it and the records of the list around it (which a table without `resource` shows), the records it shows and its columns (`{ columns: [{ name, label, title?, badge?, valueLabels? }], rows }`), which you loaded; the table then reads as its heading and a Markdown table. Without it, a table reads as its heading. |
79
79
  | `locale` | The reader's locale, such as `nl-NL`, in which [field components](#field-values) without `locales` format numbers and dates; the runtime's default when omitted. |
80
80
  | `basePath` | What links start with, such as `https://example.com/admin`. |
81
81
  | `forms` | Text forms by block type, over the built-in ones. |
@@ -95,7 +95,23 @@ renderText(tree, { forms: { Grid: ruled, Card: noted, SeatChart: childrenText }
95
95
 
96
96
  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.
97
97
 
98
- <gap>A data block's text form cannot read its records itself, such as a table's rows, because reading records for the text form is not implemented.</gap> A `Thread` holding the elements of [`threadItemNodes`](blocks.md#tool-calls) reads as its messages and calls. <gap>A data block other than a `Table`, a `Thread` or a list block cannot list records you pass because its text form for records 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>
98
+ ### A page's text with its records
99
+
100
+ `pageText` reads a page's records itself: it starts every read of the page's [read plan](#how-a-page-reads-its-data) at once through the `read` you give it, which makes one read as the reader, such as a list or an `:aggregate` of the API, and once they are all back renders the text form with them. A `RecordCard` reads as its record, its header `actions` too, a `CardRow` as its records, a `Table` as a Markdown table of its rows, one without `resource` of the list around it, and a related list as its records, each nested list under its own record. The record you pass as `record` is the page's own, whose key fills `{{@root.…}}`. A read that fails leaves its block as it reads without records, a link to them.
101
+
102
+ ```ts
103
+ import { pageText } from '@protobase/layout'
104
+
105
+ const text = await pageText(page.tree, page.reads, {
106
+ read: async (read) => ({ rows: (await client.list(read.resource, { filter: read.filter, orderBy: read.orderBy, pageSize: read.pageSize, fields: read.fields, limitPer: read.limitPer })).items }),
107
+ labels: { workers: { name: { label: 'Name' } } },
108
+ params: { window: '30d' },
109
+ })
110
+ ```
111
+
112
+ It takes the options of `renderText` but `records` and `tables`, and `labels`: per resource, its fields' labels and value labels, which its tables' headers and cells read. A count's `read` gives `{ rows: [], total }`, and a count per record around it, an `:aggregate`, its groups as rows `{ value, count }`.
113
+
114
+ <gap>A `Stat` count, a `Chart`, a `RecordCards`, a `RecordRow` or a `Thread` cannot read its records in `pageText` because their text forms for planned records are not implemented.</gap> <gap>A path in the text form cannot read a record further out than the nearest, such as `../id`, because a stack of records in the text form is not implemented.</gap> A `Thread` holding the elements of [`threadItemNodes`](blocks.md#tool-calls) reads as its messages and calls. <gap>A data block other than a `Table`, a `RecordCard`, a `CardRow`, a `Thread` or a list block cannot list records you pass because its text form for records 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>
99
115
 
100
116
  ## What a layout may hold
101
117
 
@@ -115,7 +131,7 @@ A `RecordCard` (its first match), a `ReferenceField`, each card of a `CardRow` a
115
131
  ## Related records
116
132
 
117
133
  :::caution[Beta]
118
- The build plans every list's read beside the page's other reads, as [how a page reads its data](#how-a-page-reads-its-data) says. Coming soon: the web starts those reads at page load; until then each list block reads its records once the record around it has drawn.
134
+ A list's next pages, with `pagination="more"`, are a read of the list's own. A `Table` inside a list's records still reads once it draws, as [how a page reads its data](#how-a-page-reads-its-data) says.
119
135
  :::
120
136
 
121
137
  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.
@@ -143,10 +159,10 @@ Each entry is a record of the stack while its children draw, so `Field`, `Show`,
143
159
  ## How a page reads its data
144
160
 
145
161
  :::caution[Beta]
146
- The build plans a page's reads and `/api/meta` sends the plan; the web does not run it yet.
162
+ On the web, a `Table`, `Thread`, `Chart`, `RecordCards` and `RecordRow` still read once they draw, as the marked limits below say.
147
163
  :::
148
164
 
149
- 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 can start together at page load and none waits for another's rows. There is no combined page query. `/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.
165
+ 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.
150
166
 
151
167
  - **One read per block.** `Stat`, `RecordCard`, `Table`, `CardRow`, `RecordRow`, `RecordCards`, `Thread`, `Chart`, `ReferenceManyField`, `ReferenceArrayField` and `ReferenceField` each make one list, count or `:aggregate` read. A `Thread`'s tool calls, the row a `Table`'s `select` chose and each `<resource>.count` a condition names are reads of their own. A block under `Show` or `Match` is read anyway: the condition decides only what is drawn.
152
168
  - **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.
@@ -155,11 +171,13 @@ The build compiles each page into a read plan: one ordinary API read per data bl
155
171
  - **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.
156
172
  - **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.
157
173
 
158
- 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) and `etag`. `compileReadPlan(tree, { models })` makes the same plan from a tree of your own.
174
+ 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 `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.
175
+
176
+ 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.
159
177
 
160
178
  A [custom component](custom-components.md#reads) is planned when it declares its reads. 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.
161
179
 
162
- <gap>A page cannot start its planned reads at page load because running the read plan on the web is not implemented; each block still reads once it draws.</gap> <gap>A `Chart` cannot sit inside a repeated record because grouping a chart per record is not implemented.</gap>
180
+ <gap>A `Table`, `Thread`, `Chart`, `RecordCards` or `RecordRow` cannot start its read when the page opens because drawing those blocks from their planned read is not implemented; each still reads once it draws, under a `Show` or `Match` once its condition holds.</gap> <gap>A read without an ETag cannot read only its fields from the database because skipping ETags in the list API is not implemented; it still sends only its fields.</gap> <gap>A `Chart` cannot sit inside a repeated record because grouping a chart per record is not implemented.</gap>
163
181
 
164
182
  ## Field values
165
183
 
@@ -205,7 +223,7 @@ In the [text form](#text-form) each one reads as its formatted value, a `UrlFiel
205
223
  ## Paths and scopes
206
224
 
207
225
  :::caution[Beta]
208
- A path cannot read `@root` yet, and a block inside a card or under a condition reads its records only once it draws, as the marked limits below say.
226
+ A path cannot read `@root` yet, as the marked limit below says.
209
227
  :::
210
228
 
211
229
  A `RecordCard`, a `ReferenceField`, each card of a `CardRow` and each entry of a [`RecordsIterator`](#related-records) put their record on a stack of records: an element inside both a task's `RecordCard` and a `CardRow` of its claims sits in a claim, inside the task. A bare name is looked up in the innermost record, then in each record further out, then in the page's own record; the [compatibility page](../features/compatibility.md#template-paths) says which template syntax this follows:
@@ -236,8 +254,6 @@ The build checks every path where it sits:
236
254
  - **Reads that would wait.** A per-row value in a filter in any other place than a top-level `AND` equality (with `>=`, inside `OR` or `NOT`, a second one), `@index`, `@first`, `@last` or `this` in a filter, key or values, and any placeholder in `resource`, `sort`, `columns` or `limit` fail with "this would wait for the parent's rows": each block's records are one read of their own, and none may wait for another's rows.
237
255
  - **Shadowing.** A bare name that more than one record around it has reads the nearest, and the build warns which it read and how to write the others: `"id" resolves to task_claims; write ../id for the one of tasks`. `protobase build --strict` fails on it instead. `this.`, `./`, `../` and `@` paths never warn.
238
256
 
239
- <gap>A block inside a `CardRow` or `RecordCard` cannot read its records at page load, beside the records around it, because running the [read plan](#how-a-page-reads-its-data) on the web is not implemented; it reads once the card around it draws.</gap> <gap>A block under a `Show` or `Match` cannot read its records before its condition holds because running the read plan on the web is not implemented.</gap>
240
-
241
257
  ## Page parameters
242
258
 
243
259
  :::caution[Beta]
@@ -262,7 +278,7 @@ A `Table` with `select` chooses one of its rows: each row links to the page with
262
278
 
263
279
  In the [text form](#text-form), a `SelectInput` reads as its label and its choice's name, `**Window**: Last 30 days`, from the `params` you pass, and a `select` table's children as the row `records` gives for it.
264
280
 
265
- <gap>A block reads a page parameter only once it draws, not at page load, because running the [read plan](#how-a-page-reads-its-data) on the web is not implemented.</gap> <gap>A data block other than a `Table`, or a list display such as a map, cannot take `select` because choosing a row there is not implemented.</gap>
281
+ <gap>A data block other than a `Table`, or a list display such as a map, cannot take `select` because choosing a row there is not implemented.</gap>
266
282
 
267
283
  ## Conditions
268
284