@protobase/cli 0.99.1 → 0.99.2

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.1";
2
+ var version = "0.99.2";
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.1",
3
+ "version": "0.99.2",
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.1",
47
- "@protobase/layout": "0.99.1",
48
- "@protobase/query": "0.99.1",
49
- "@protobase/schema": "0.99.1",
50
- "@protobase/server": "0.99.1",
51
- "@protobase/ui": "0.99.1",
52
- "@protobase/workflows": "0.99.1",
46
+ "@protobase/config": "0.99.2",
47
+ "@protobase/layout": "0.99.2",
48
+ "@protobase/query": "0.99.2",
49
+ "@protobase/schema": "0.99.2",
50
+ "@protobase/server": "0.99.2",
51
+ "@protobase/ui": "0.99.2",
52
+ "@protobase/workflows": "0.99.2",
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",
@@ -16,7 +16,7 @@ Apps written for other systems that keep working on Protobase, and moving their
16
16
 
17
17
  ## Template paths
18
18
 
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.
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](../reference/layouts.md#page-parameters), which a `SelectInput` sets; and a name no record around it has fails the build instead of drawing empty.
20
20
 
21
21
  ## react-admin
22
22
 
@@ -25,4 +25,5 @@ Apps written for other systems that keep working on Protobase, and moving their
25
25
  - [Page size of related records](../reference/layouts.md#related-records) (beta): 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.
26
26
  - [Items of an ArrayField](../reference/layouts.md#related-records) (beta): A text item of an `ArrayField` is read as `this`. An `ArrayField` takes no `filter`, `sort` or `perPage` yet.
27
27
  - [RecordsIterator without functions](../reference/layouts.md#related-records) (beta): `RecordsIterator` takes no `render`, `data`, `total` or `isPending`, as a layout holds no functions and the list around it gives the rest.
28
+ - [SelectInput in the address](../reference/layouts.md#page-parameters) (beta): `SelectInput` takes react-admin's `source`, `choices` as `{ id, name }`, `label` and `defaultValue`, and writes its choice into the page's address as `?<source>=<id>`, read as `@params.<source>`, instead of into a form.
28
29
  - [Links of a ReferenceField](../reference/layouts.md#related-records) (beta): A `ReferenceField` links to the record's page for both `edit` and `show`, as a record has one page.
@@ -6,6 +6,7 @@ Pages of your own, built from blocks in a JSX layout.
6
6
 
7
7
  - [Composed pages](../reference/layouts.md#setup): Pages built from a JSX layout, with their own address, sidebar entry and role limits, reading the API under the same access rules as the lists.
8
8
  - [Layout checks](../reference/layouts.md#what-a-layout-may-hold): The build refuses a layout with code, unknown props or unknown fields, and names the file and place.
9
+ - [Page parameters](../reference/layouts.md#page-parameters) (beta): A page holds a choice in its address with `SelectInput`, reads it in its layout, and shows the details of a row chosen in a table.
9
10
  - [Conditions](../reference/layouts.md#conditions): Part of a page shows only while a condition on a record or a count holds.
10
11
  - [Paths and scopes](../reference/layouts.md#paths-and-scopes) (beta): Layout values resolve through the records around them with paths relative to those records, such as `../name`, `this.name` and `@index`; typos and reads that would wait on other reads fail the build, and `Show`, `Switch` and `Match` choose what is drawn.
11
12
  - [Field values and expanding lines](../reference/layouts.md#field-values) (beta): Layouts show a record's values inline in text and links with react-admin's field components, such as `DateField` and `NumberField`, and a line that opens to show more with `Details` and `Summary`.
@@ -245,6 +245,7 @@ The first records of a list, drawn the way the resource's list page draws them:
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). |
246
246
  | `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. |
247
247
  | `display` | The display it opens in, such as `cards`; default the list's. |
248
+ | `select` | The [page parameter](layouts.md#page-parameters) a row's choice sets, such as `claim`: each row links to the page with its key there (`?claim=11`) instead of to its record, whose page its menu still opens, and the table's children draw under it inside the chosen row, or nothing while none is chosen. With it, the table shows no other display. |
248
249
  | `title`, `description`, `actions` | The heading. |
249
250
  | `empty` | Text when nothing matches; default "Nothing here yet.". |
250
251
  | `span` | Width in a grid. |
@@ -682,6 +683,21 @@ A button that opens a form in a dialog. `create` makes a record of `resource`; `
682
683
  <ModalForm mode="create" label="Add lead" resource="companies" fields={['name', 'city', 'country_code', 'email']} values={{ status: 'lead' }} />
683
684
  ```
684
685
 
686
+ ### SelectInput
687
+
688
+ A choice of a [page parameter](layouts.md#page-parameters), as react-admin's [`SelectInput`](https://marmelab.com/react-admin/SelectInput.html) takes it, written into the page's address instead of a form: a select whose choices are each a link to the page with that choice, `?<source>=<id>`, the default leaving it out. The layout reads it as `@params.<source>`.
689
+
690
+ | Prop | |
691
+ | --- | --- |
692
+ | `source` | The parameter's name, such as `window`. Required. |
693
+ | `choices` | `{ id, name }` objects: `id` the value the address holds, text or a number, `name` what the select shows. Without them, it shows the address's value as text, which no read may take. |
694
+ | `label` | Shown beside the select; default the `source`. |
695
+ | `defaultValue` | The choice's `id` while the address names none of the choices. |
696
+
697
+ ```tsx
698
+ <SelectInput source="window" label="Window" defaultValue="7d" choices={[{ id: '7d', name: 'Last 7 days' }, { id: '30d', name: 'Last 30 days' }]} />
699
+ ```
700
+
685
701
  ### Show
686
702
 
687
703
  Its children while [`when`](layouts.md#conditions) holds, else its `fallback`, as SolidJS's [`<Show>`](https://docs.solidjs.com/reference/components/show). Its text form is what it draws.
@@ -73,7 +73,8 @@ 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
+ | `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. |
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. |
77
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
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. |
79
80
  | `basePath` | What links start with, such as `https://example.com/admin`. |
@@ -185,7 +186,7 @@ In the [text form](#text-form) each one reads as its formatted value, a `UrlFiel
185
186
  ## Paths and scopes
186
187
 
187
188
  :::caution[Beta]
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.
189
+ 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.
189
190
  :::
190
191
 
191
192
  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:
@@ -198,7 +199,7 @@ A `RecordCard`, a `ReferenceField`, each card of a `CardRow` and each entry of a
198
199
  | `this.id`, `./id` | The nearest record only. |
199
200
  | `@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. |
200
201
  | `@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> |
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> |
202
+ | `@params.window` | The [page parameter](#page-parameters) `window`, which a `SelectInput source="window"` on the page sets. |
202
203
 
203
204
  `Field source`, a field component's `source`, `Stat field`, `Progress`, and the names in a [condition](#conditions) take a path. A string prop takes `{{path}}` placeholders in double braces, filled with the path's value where the element draws, and empty when it has none:
204
205
 
@@ -212,12 +213,38 @@ A placeholder quoted on its own in a filter or condition, `title = '{{title}}'`,
212
213
  The build checks every path where it sits:
213
214
 
214
215
  - **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.
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.
216
+ - **Bad roots.** `../` past the outermost record, `@root` on a page without a record, `@index` outside a `CardRow` or `RecordsIterator`, and `@params.x` without a `SelectInput source="x"` on the page fail.
216
217
  - **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.
217
218
  - **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.
218
219
 
219
220
  <gap>A block inside a `CardRow` or `RecordCard` cannot read its records at page load, beside the records around it, because planning a page's reads 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 planning a page's reads is not implemented.</gap>
220
221
 
222
+ ## Page parameters
223
+
224
+ :::caution[Beta]
225
+ A page parameter holds one value, from a fixed list of choices.
226
+ :::
227
+
228
+ A page holds a choice in its own address: `SelectInput` draws a select whose choices each link to the page with that choice in the query, `/claims?window=30d`, and the layout reads the choice as `@params.window`. Reloading or sharing the address keeps it, and the browser's Back goes to the choice before. It takes the props of [react-admin's `SelectInput`](https://marmelab.com/react-admin/SelectInput.html): `source` names the parameter, `choices` lists `{ id, name }` objects, `label` is shown beside it, and `defaultValue` holds while the address names none of the choices. It writes into the page's address, not into a form.
229
+
230
+ ```tsx
231
+ <Page title="Claims">
232
+ <SelectInput source="window" label="Window" defaultValue="7d" choices={[{ id: '7d', name: 'Last 7 days' }, { id: '30d', name: 'Last 30 days' }]} />
233
+ <Table resource="task_claims" title="Claims of the last {{@params.window}}" filter="claimed_at >= now() - {{@params.window}}" select="claim">
234
+ <Field source="status" />
235
+ <ReferenceField source="worker_id" reference="workers" />
236
+ </Table>
237
+ </Page>
238
+ ```
239
+
240
+ A value in the address that is none of the choices reads as `defaultValue`, and as empty without one. A filter that reads `@params` is checked once for each choice, and for the empty value when there is no `defaultValue`, so a choice that makes the filter invalid fails the build: `filter with window = "soon": …`. A `SelectInput` without `choices` shows the value its address gives as text; a `filter`, `recordKey` or `values` cannot read it, which fails the build, as any text in the address would reach the read.
241
+
242
+ A `Table` with `select` chooses one of its rows: each row links to the page with its key in the parameter `select` names, `?claim=11`, and the table's children draw under it inside that row's record, as inside a `RecordCard`. While no row is chosen they draw nothing, and Back clears the choice. A table with `select` shows its rows as a table, never in another display. Each parameter name is used once on a page, by one `SelectInput` or one `select`.
243
+
244
+ 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.
245
+
246
+ <gap>A block reads a page parameter only once it draws, not at page load, because planning a page's reads 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>
247
+
221
248
  ## Conditions
222
249
 
223
250
  `<Show when="...">` keeps its children while the condition holds, and draws its `fallback` while it does not; `<Switch>` draws the first of its `<Match when="...">` that holds, or its `fallback`, as [SolidJS's](https://docs.solidjs.com/reference/components/show) `Show`, `Switch` and `Match` do. A condition is AIP-160 over named values:
@@ -304,7 +331,7 @@ Every place in the app has an address, and the app writes and reads them in one
304
331
  | `{ kind: 'list', resource, filter?, orderBy?, display? }` | A resource's list, with the filter, order and [display](ui-config.md#list-displays) the list page would show. |
305
332
  | `{ kind: 'record', resource, key, edit?, open?, tab?, standard?, version?, run?, panel?, file? }` | One record; `key` is its value, or its parts for a composite key. `edit: true` is its form (`?edit=true`), on a view whose record page opens as a [read view or locked](ui-config.md#read-view-and-edit). `open` lists the titles of the record page's collapsed [groups](ui-config.md#groups) that are open (`?open=<title>`, once per group), and `tab` the title of the [tab](ui-config.md#tabs) it shows (`?tab=<title>`). `standard: true` is its standard page (`?standard=true`), on a view whose record page is a [component of the app's own](ui-config.md#full-area-record-pages) or [opens another](ui-config.md#a-record-page-that-opens-another). On a workflow, `version` is the saved version its graph shows, read-only (`?version=<number>`), and `run` the run shown on it (`?run=<id>`); see [The workflow's page](workflows.md#the-workflows-page). `panel` is the panel a [focus page](ui-config.md#focus-pages) opens with, by a name its surface knows (`?panel=<name>`). `file` names a file field whose file opens in the [viewer](files.md#viewers) for its type (`?file=<field>`). |
306
333
  | `{ kind: 'create', resource, values? }` | The form for a new record, with `values` filled in by field name, as text: `{ kind: 'create', resource: 'notes', values: { listing_id: '{{id}}' } }` on a listing's page starts a note about that listing. A relation shows the name of the record it points at. The values are a start the person can change, not a rule: what they may write is still up to the access rules. A view with a [create page](ui-config.md#create-pages) shows that page here instead, with the values in the address. |
307
- | `{ kind: 'page', page, tab? }` | A composed page; `tab` the name of one of its [tabs](blocks.md#tabs-and-tab) (`/<page>/<tab>`), the first when omitted. |
334
+ | `{ kind: 'page', page, tab?, params? }` | A composed page; `tab` the name of one of its [tabs](blocks.md#tabs-and-tab) (`/<page>/<tab>`), the first when omitted, and `params` its [page parameters](#page-parameters) by name (`?window=30d`). |
308
335
 
309
336
  The resources, pages and fields an address names are checked when the server starts, like every other name.
310
337