@protobase/cli 0.98.0 → 0.98.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.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.98.0";
2
+ var version = "0.98.1";
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.98.0",
3
+ "version": "0.98.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.98.0",
47
- "@protobase/layout": "0.98.0",
48
- "@protobase/query": "0.98.0",
49
- "@protobase/schema": "0.98.0",
50
- "@protobase/server": "0.98.0",
51
- "@protobase/ui": "0.98.0",
52
- "@protobase/workflows": "0.98.0",
46
+ "@protobase/config": "0.98.1",
47
+ "@protobase/layout": "0.98.1",
48
+ "@protobase/query": "0.98.1",
49
+ "@protobase/schema": "0.98.1",
50
+ "@protobase/server": "0.98.1",
51
+ "@protobase/ui": "0.98.1",
52
+ "@protobase/workflows": "0.98.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",
@@ -17,3 +17,7 @@ Apps written for other systems that keep working on Protobase, and moving their
17
17
  ## Template paths
18
18
 
19
19
  - [Paths and scopes](../reference/layouts.md#paths-and-scopes) (beta): Layout paths follow Mustache's context-stack lookup and Handlebars' path grammar: `../`, `this`, `./`, `@root`, `@index`, `@first` and `@last`, though `@root` cannot be read yet. Protobase differs in three ways: a placeholder is escaped for the string it lands in, such as a filter's quoted value, rather than for HTML; `@params` names a page parameter, which the build accepts but a path cannot read yet; and a name no record around it has fails the build instead of drawing empty.
20
+
21
+ ## react-admin
22
+
23
+ - [Related records](../reference/layouts.md#related-records) (beta): Layouts take react-admin's `ReferenceManyField`, `ReferenceArrayField`, `ArrayField`, `RecordsIterator` and `ReferenceField` with their names, props and defaults: `source` is `id`, `sort` the key descending, and a `ReferenceManyField`'s `perPage` 25. Protobase differs in five ways: `filter` and `sort` also take AIP-160 and AIP-132 text, since an object cannot say `OR`; a list reads at most 500 records, the API's largest page, which is also a `ReferenceArrayField`'s `perPage` where react-admin's is 1000; a text item of an `ArrayField` is read as `this`; `RecordsIterator` takes no `render`, `data`, `total` or `isPending`, as a layout holds no functions and the list around it gives the rest; and a `ReferenceField` links to the record's page for both `edit` and `show`, as a record has one page. An `ArrayField` takes no `filter`, `sort` or `perPage` yet.
@@ -17,6 +17,7 @@ Pages of your own, built from blocks in a JSX layout.
17
17
  - [Tailwind classes](../reference/layouts.md#tailwind-classes) (experimental): Layouts can carry Tailwind classes, on plain elements and on blocks, for pages too custom for blocks.
18
18
  - [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.
19
19
  - [Data blocks](../reference/blocks.md#data): Counts, tables, single records, rows of cards, field values and progress bars.
20
+ - [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.
20
21
  - [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.
21
22
  - [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.
22
23
  - [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.
@@ -4,7 +4,7 @@
4
4
 
5
5
  Every built-in layout block, its props and what it does, with examples from the ERP's sales overview.
6
6
 
7
- Blocks are imported from `@protobase/layout`. Every block also takes [`className`](layouts.md#tailwind-classes), Tailwind classes for its outer element. "Record" below means the record of the `RecordCard` or `CardRow` card around a block (see [Data](layouts.md#data)); `filter` is AIP-160 and `sort` AIP-132, as in the list API. The ERP example's sales overview uses `Page`, `Grid`, `Card`, `Stat`, `Table`, `RecordCard`, `CardRow`, `Field`, `Chart`, `Action`, `ModalForm` and `Show`; of the others, the property portal's home uses `RecordRow`, and the [Users page](auth.md#users-page) `Users`:
7
+ Blocks are imported from `@protobase/layout`. Every block also takes [`className`](layouts.md#tailwind-classes), Tailwind classes for its outer element. "Record" below means the record of the `RecordCard`, `CardRow` card or `RecordsIterator` entry around a block (see [Data](layouts.md#data)); `filter` is AIP-160 and `sort` AIP-132, as in the list API. The ERP example's sales overview uses `Page`, `Grid`, `Card`, `Stat`, `Table`, `RecordCard`, `CardRow`, `Field`, `Chart`, `Action`, `ModalForm` and `Show`; of the others, the property portal's home uses `RecordRow`, and the [Users page](auth.md#users-page) `Users`:
8
8
 
9
9
  ```tsx title="tests/apps/erp/config/overview/page.tsx"
10
10
  /** @jsxImportSource @protobase/layout */
@@ -239,7 +239,7 @@ The first records of a list, drawn the way the resource's list page draws them:
239
239
 
240
240
  | Prop | |
241
241
  | --- | --- |
242
- | `resource`, `filter`, `sort` | Which records, in which order. `resource` is required; `sort` defaults to the list's. |
242
+ | `resource`, `filter`, `sort` | Which records, in which order; `sort` defaults to the list's. Without `resource`, inside a [`ReferenceManyField`](#referencemanyfield) or `ReferenceArrayField`, it draws that list's records and reads none of its own, so it takes no `filter`, `sort`, `limit`, `display` or `bulk`. |
243
243
  | `columns` | Field names for the table, or `{ name, priority }` for a column that matters on a phone, 1 the most important; default the view's list columns. See [Columns on a phone](#columns-on-a-phone). |
244
244
  | `button` | A [button on each row](#row-buttons) to an address the row's fields name, or to the outside page a field holds; a list of these gives each row the first whose fields it holds. |
245
245
  | `bulk` | `true`: rows can be selected, and the view's `bulk` actions run on the selected rows, as on the list page; see [signing several records off](#signing-several-records-off). |
@@ -509,6 +509,76 @@ Counts, sums or averages of the records that match `filter`, per value of a fiel
509
509
 
510
510
  Each value takes its colour from the view's `valueColors`, else an enum value's place among its values, from the [chart tokens](theme.md#tokens). A chart whose field the user cannot read is left out of their page, and a field it cannot group or add up stops the server at startup.
511
511
 
512
+ ## Related records
513
+
514
+ The blocks that repeat over a record's related records, as [related records](layouts.md#related-records) explains, with the names, props and defaults of react-admin's components. `ReferenceManyField`, `ReferenceArrayField` and `ArrayField` hold a list and draw nothing of their own; a `RecordsIterator` or a `Table` without `resource` inside one draws it. Each sits inside a record, whose field it reads.
515
+
516
+ ### ReferenceManyField
517
+
518
+ The records of `reference` whose `target` holds the record's `source`, as [react-admin's ReferenceManyField](https://marmelab.com/react-admin/ReferenceManyField.html).
519
+
520
+ | Prop | |
521
+ | --- | --- |
522
+ | `reference` | The resource it reads. Required. |
523
+ | `target` | The field of `reference` that points at the record. Required. |
524
+ | `source` | The field of the record it matches; default `id`, of the nearest record. A [path](layouts.md#paths-and-scopes), such as `../id`. |
525
+ | `filter` | More conditions, as AIP-160 text or react-admin's `{ field: value }`, its fields ANDed. |
526
+ | `sort` | AIP-132 text, or react-admin's `{ field, order: 'ASC' \| 'DESC' }`; default the key, descending. |
527
+ | `perPage` | How many records it reads, at most 500; default 25. |
528
+ | `pagination` | `more`: a **Load more** button reads the next `perPage` records into the same list. |
529
+ | `empty` | Text instead of the children when no record matches. |
530
+
531
+ ```tsx
532
+ <ReferenceManyField reference="task_claims" target="task_id" filter={{ status: 'open' }} sort={{ field: 'claimed_at', order: 'DESC' }} pagination="more">
533
+ <Table title="Open claims" columns={['worker_id', 'claimed_at']} />
534
+ </ReferenceManyField>
535
+ ```
536
+
537
+ ### ReferenceArrayField
538
+
539
+ The records of `reference` whose keys the record's `source`, a JSON list of keys, holds, as [react-admin's ReferenceArrayField](https://marmelab.com/react-admin/ReferenceArrayField.html).
540
+
541
+ | Prop | |
542
+ | --- | --- |
543
+ | `source` | A JSON field of the record holding the keys. Required. |
544
+ | `reference` | The resource the keys belong to. Required. |
545
+ | `filter`, `sort` | As `ReferenceManyField`'s. |
546
+ | `perPage` | How many records it reads; default and at most 500, the API's largest page. |
547
+ | `empty` | Text instead of the children when no record matches. |
548
+
549
+ ### ArrayField
550
+
551
+ The items of the record's `source`, a JSON list, as [react-admin's ArrayField](https://marmelab.com/react-admin/ArrayField.html). An object item is read by its keys, and a text item as `this`: `<Field source="this" />`.
552
+
553
+ | Prop | |
554
+ | --- | --- |
555
+ | `source` | A JSON field of the record. Required. |
556
+
557
+ <gap>An `ArrayField` cannot filter, sort or page its items because react-admin's `filter`, `sort` and `perPage` on it are not implemented.</gap>
558
+
559
+ ### RecordsIterator
560
+
561
+ Its children once per entry of the list around it, each inside that record or item, with nothing drawn around them, as [react-admin's RecordsIterator](https://marmelab.com/react-admin/RecordsIterator.html). It takes no props.
562
+
563
+ ```tsx
564
+ <ArrayField source="labels">
565
+ <RecordsIterator>
566
+ <Field source="this" label={false} />
567
+ </RecordsIterator>
568
+ </ArrayField>
569
+ ```
570
+
571
+ ### ReferenceField
572
+
573
+ The record of `reference` the record's `source` points at, as [react-admin's ReferenceField](https://marmelab.com/react-admin/ReferenceField.html): its children inside that record, or without children its title, as a link to the record's page.
574
+
575
+ | Prop | |
576
+ | --- | --- |
577
+ | `source` | The field holding the key, such as a relation. Required. |
578
+ | `reference` | The resource it points at. Required. |
579
+ | `link` | `edit` (default) or `show` links to the record's page, `false` does not. |
580
+ | `empty` | Text when the field holds no key. |
581
+
512
582
  ## Conversation
513
583
 
514
584
  A chat declared in the layout like any other block: a `Thread` lists the messages of a resource and a `Composer` beneath it sends one, so [`/meta`](api.md#meta-and-openapi-per-caller) describes the conversation and every client can draw it, with no component of the app's own. On a record page, [`l.thread` and `l.composer`](ui-config.md#conversations) hold the conversation of that record.
@@ -73,6 +73,7 @@ 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. |
76
77
  | `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. |
77
78
  | `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. |
78
79
  | `basePath` | What links start with, such as `https://example.com/admin`. |
@@ -93,7 +94,7 @@ renderText(tree, { forms: { Grid: ruled, Card: noted, SeatChart: childrenText }
93
94
 
94
95
  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.
95
96
 
96
- <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` or a `Thread` 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>
97
+ <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>
97
98
 
98
99
  ## What a layout may hold
99
100
 
@@ -106,14 +107,44 @@ Behaviour comes from [named actions](#named-actions); React code from [custom co
106
107
 
107
108
  ## Data
108
109
 
109
- `Stat`, `RecordCard`, `Table`, `CardRow`, `RecordRow`, `RecordCards` and `Thread` read records of a `resource`. `filter` is AIP-160 and `sort` AIP-132, exactly as the list API's `filter` and `order_by`, so a filter that works in the list's URL works here. `Thread` takes no `sort`: it orders its messages by its `time` field, newest first.
110
+ `Stat`, `RecordCard`, `Table`, `CardRow`, `RecordRow`, `RecordCards` and `Thread` read records of a `resource`. `filter` is AIP-160 and `sort` AIP-132, exactly as the list API's `filter` and `order_by`, so a filter that works in the list's URL works here. `Thread` takes no `sort`: it orders its messages by its `time` field, newest first. `ReferenceManyField`, `ReferenceArrayField` and `ReferenceField` read records of their `reference` that the record around them points to or is pointed at by: see [related records](#related-records).
110
111
 
111
- A `RecordCard` (its first match) and each card of a `CardRow` hold a **record**. Inside one, `Field`, `Progress`, `Stat field`, `Show`, `Action` and `ModalForm mode="edit"` work on that record, and a `RecordCard`'s header `actions` do too. A field name may follow relations: `company_id.city` is the city of the record's company, fetched like the record page fetches it and cached.
112
+ A `RecordCard` (its first match), a `ReferenceField`, each card of a `CardRow` and each entry of a `RecordsIterator` hold a **record**. Inside one, `Field`, `Progress`, `Stat field`, `Show`, `Action` and `ModalForm mode="edit"` work on that record, and a `RecordCard`'s header `actions` do too. A field name may follow relations: `company_id.city` is the city of the record's company, fetched like the record page fetches it and cached.
113
+
114
+ ## Related records
115
+
116
+ :::caution[Beta]
117
+ Each list block reads its records once the record around it has drawn. Coming soon: reads planned at build, so every list's read starts at page load.
118
+ :::
119
+
120
+ 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.
121
+
122
+ ```tsx
123
+ <RecordCard resource="tasks" recordKey="7">
124
+ <ArrayField source="labels">
125
+ <RecordsIterator><Field source="this" label={false} /></RecordsIterator>
126
+ </ArrayField>
127
+ <ReferenceManyField reference="task_claims" target="task_id" sort={{ field: 'claimed_at', order: 'DESC' }}>
128
+ <RecordsIterator>
129
+ <Card title="Claim {{@index}}">
130
+ <ReferenceField source="worker_id" reference="workers" />
131
+ <ReferenceManyField reference="claim_steps" target="claim_id" empty="No steps yet">
132
+ <RecordsIterator><Field source="name" /></RecordsIterator>
133
+ </ReferenceManyField>
134
+ </Card>
135
+ </RecordsIterator>
136
+ </ReferenceManyField>
137
+ </RecordCard>
138
+ ```
139
+
140
+ Each entry is a record of the stack while its children draw, so `Field`, `Show`, `{{path}}` placeholders and nested lists inside it read it, and `@index`, `@first` and `@last` count its place in the list. A text item of an `ArrayField`, such as a label, is read as `this`; an object item by its keys, which no model describes, so the build does not check them, and it warns when an item's key could shadow a field of a record further out. A list ties itself to the record around it by a field of that record: `source`, `id` of the nearest record by default. `filter` and `sort` take AIP-160 and AIP-132 text, or the objects react-admin writes: `{ status: 'open' }` is `status = "open"`, its fields ANDed, and `{ field: 'claimed_at', order: 'DESC' }` is `claimed_at desc`. Without `sort`, a list is in its key's order, descending, as react-admin's is. `pagination="more"` adds a button that reads the next `perPage` records into the same list. The [blocks reference](blocks.md#related-records) lists every prop.
141
+
142
+ <gap>A list block cannot read its records at page load, beside the records around it, because planning a page's reads is not implemented; each reads once the record around it has drawn.</gap> <gap>A `ReferenceArrayField` cannot read its records through a `related()` filter because array fields in `related()` are not implemented; it reads them by their keys with `in()`.</gap>
112
143
 
113
144
  ## Field values
114
145
 
115
146
  :::caution[Beta]
116
- React-admin's `ReferenceField`, a related record's value, is not built yet, and these components may still change.
147
+ A [`ReferenceField`](#related-records), a related record, cannot sit in a line of text yet, and these components may still change.
117
148
  :::
118
149
 
119
150
  The field components show one value of the record around them inside a line of text: in a `Text`, a `Link` or a `Summary`, beside words and links. They are [react-admin's field components](https://marmelab.com/react-admin/Fields.html), with the same names, props and defaults, so a layout reads as a react-admin page does. `source` is a [path](#paths-and-scopes), and a `source` no record around it has fails the build with the closest field, as any path does.
@@ -145,7 +176,7 @@ The field components show one value of the record around them inside a line of t
145
176
  - `TextField` and `ChipField` show an enum value by its label from the view, where react-admin shows the stored value.
146
177
  - Props that take code in react-admin, such as `transform`, `render` or icons, are not taken: a layout holds data only.
147
178
 
148
- <gap>A layout cannot show a related record's value inline with react-admin's `ReferenceField` because `ReferenceField` is not implemented.</gap>
179
+ <gap>A layout cannot show a related record's value inside a line of text with a `ReferenceField` because drawing a `ReferenceField` inline is not implemented; it stands on its own, as [related records](#related-records) show.</gap>
149
180
 
150
181
  In the [text form](#text-form) each one reads as its formatted value, a `UrlField` as a Markdown link, and a `BooleanField` as Yes or No.
151
182
 
@@ -157,7 +188,7 @@ In the [text form](#text-form) each one reads as its formatted value, a `UrlFiel
157
188
  A path cannot read `@root` or `@params` yet, and a block inside a card or under a condition reads its records only once it draws, as the marked limits below say.
158
189
  :::
159
190
 
160
- A `RecordCard` and each card of a `CardRow` 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:
191
+ 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:
161
192
 
162
193
  | Path | Reads |
163
194
  | --- | --- |
@@ -165,7 +196,7 @@ A `RecordCard` and each card of a `CardRow` put their record on a stack of recor
165
196
  | `meta.size` | `meta` as above, then `size` from that value only: when it has none, the path is empty, and no record further out is tried. |
166
197
  | `../id`, `../../id` | The record one, or two, out from the nearest. |
167
198
  | `this.id`, `./id` | The nearest record only. |
168
- | `@index`, `@first`, `@last` | The card's place among a `CardRow`'s cards, from 0, and whether it is the first or the last. |
199
+ | `@index`, `@first`, `@last` | The card's place among a `CardRow`'s cards, or the entry's among a `RecordsIterator`'s, from 0, and whether it is the first or the last. |
169
200
  | `@root.id` | The page's own record. <gap>A path cannot read `@root` because pages with a record of their own are not implemented.</gap> |
170
201
  | `@params.window` | The page parameter `window`. <gap>A path cannot read `@params` because the input that sets a page parameter is not implemented.</gap> |
171
202
 
@@ -181,7 +212,7 @@ A placeholder quoted on its own in a filter or condition, `title = '{{title}}'`,
181
212
  The build checks every path where it sits:
182
213
 
183
214
  - **Typos.** A name no record around it has fails, naming every record searched and the closest field: `"claimd_at" is no field of task_claims, tasks; did you mean claimed_at?`. A name the build accepts that has no value in a record draws empty.
184
- - **Bad roots.** `../` past the outermost record, `@root` on a page without a record, `@index` outside a `CardRow`, and `@params.x` without an input setting `x` fail.
215
+ - **Bad roots.** `../` past the outermost record, `@root` on a page without a record, `@index` outside a `CardRow` or `RecordsIterator`, and `@params.x` without an input setting `x` fail.
185
216
  - **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.
186
217
  - **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.
187
218