@protobase/cli 0.99.0 → 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.0";
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.0",
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.0",
47
- "@protobase/layout": "0.99.0",
48
- "@protobase/query": "0.99.0",
49
- "@protobase/schema": "0.99.0",
50
- "@protobase/server": "0.99.0",
51
- "@protobase/ui": "0.99.0",
52
- "@protobase/workflows": "0.99.0",
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,13 +16,14 @@ 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
 
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.
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: `sort` is the key descending, and a `ReferenceManyField`'s `source` is `id` and its `perPage` 25.
24
24
  - [Text filters on related records](../reference/layouts.md#related-records) (beta): `filter` and `sort` also take AIP-160 and AIP-132 text, since an object cannot say `OR`.
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`.
@@ -9,6 +9,7 @@ The API every resource gets, with filters, writes, errors and the typed client.
9
9
  - [Filters](../reference/api.md#filters): AIP-160 filters and ordering, with word search across a resource's search fields, lists of values and relative dates.
10
10
  - [Lists under a record](../reference/api.md#lists-under-a-record): `/objectives/40/tasks` lists what belongs to one record, by a relation or a declared link, after reading that record as the caller would.
11
11
  - [Filtering through related records](../reference/api.md#filtering-through-related-records): A list asks for the records that belong to another with a subfilter, such as an objective's tasks, in one read under the caller's access, instead of sending a list of keys. The filter can keep to one page of those records, with their sort, limit and page token, and follow a JSON list of keys they hold.
12
+ - [First rows per value](../reference/api.md#first-rows-per-value) (beta): A list can return the first n records per value of a field, such as the latest three comments of each task, in one read.
12
13
  - [Counts, facets and charts](../reference/api.md#routes): Endpoints for value counts, grouped sums and averages, records over time, histograms and paging to any row.
13
14
  - [Map queries](../reference/api.md#maps): The records inside a map's view, or counts per area when there are many.
14
15
  - [Related names and photos](../reference/api.md#related-names): A list response can carry the names of related records and each record's first photos.
@@ -33,7 +33,7 @@ Under `/api/v1`:
33
33
 
34
34
  | Route | |
35
35
  | --- | --- |
36
- | `GET /{resource}` | list: `filter`, `order_by`, `page_size` (50, max 500), `page_token`, `fields`, `labels`, `photos`, `photos_order_by`, `count=exact` |
36
+ | `GET /{resource}` | list: `filter`, `order_by`, `page_size` (50, max 500), `page_token`, `fields`, `labels`, `photos`, `photos_order_by`, `count=exact`, [`limit_per`](#first-rows-per-value) |
37
37
  | `POST /{resource}:search` | same parameters as a JSON body (`fields` and `labels` arrays), for long filters |
38
38
  | `GET /{parent}/{key}/{resource}` | the list of `resource` that belongs to one record, see [Lists under a record](#lists-under-a-record) |
39
39
  | `GET /{resource}/{key}` | one record, with `ETag`; composite keys are `part,part`, each part percent-encoded |
@@ -48,7 +48,7 @@ Under `/api/v1`:
48
48
  | `POST /{resource}/{key}:undelete` | restores a soft-deleted record ([AIP-164](https://google.aip.dev/164)); `If-Match` optional; `409` when not deleted, `400` on hard-delete resources |
49
49
  | `POST /api/v1:batchWrite` | many writes in one transaction, see [Batch writes](#batch-writes) |
50
50
  | `GET /{resource}:facets?field=&filter=&limit=&label=` | `{ field, facets: [{ value, count }] }`, the `limit` most frequent values (100 by default, at most 1,000), never all of them; with `label`, a relation's facets carry the related record's name as `label`, as in [Related names](#related-names) |
51
- | `GET /{resource}:aggregate?group_by=&sum=&average=&maximum=&filter=` | `{ group_by, groups: [{ value, count, sum }] }`: the records the whole filter finds, per value of `group_by`, each with its count and, with `sum`, `average` or `maximum` (one of them), that of a numeric field, `null` when no record of the group has one. Values come largest first, the first `limit` (100 by default, at most 1,000), with `label` as in `:facets`. A date or timestamp `group_by` is bucketed like `:series` instead (`granularity` `minute`, `5_minutes`, `15_minutes` or `hour` to `year`, `range` or `from` and `to`, `time_zone`), empty buckets included, and each `value` is the bucket's start; the response adds `granularity` and `time_zone`. With `split_by` (a filterable field of values), a date `group_by` also splits each bucket: the response adds `split_by` and `splits` (the `split_limit` largest values over the range, 8 by default and at most 100, ranked by the sum, else by count; `split_label` names a relation's values), and each group lists its `splits` with their count and sum, average or maximum. Unlike `:facets`, the filter's terms on `group_by` apply too, so the groups add up to what the filter finds |
51
+ | `GET /{resource}:aggregate?group_by=&sum=&average=&maximum=&filter=` | `{ group_by, groups: [{ value, count, sum }] }`: the records the whole filter finds, per value of `group_by`, each with its count and, with `sum`, `average` or `maximum` (one of them), that of a numeric field, `null` when no record of the group has one. Values come largest first, the first `limit` (100 by default, at most 1,000), with `label` as in `:facets`. A date or timestamp `group_by` is bucketed like `:series` instead (`granularity` `minute`, `5_minutes`, `15_minutes` or `hour` to `year`, `range` or `from` and `to`, `time_zone`), empty buckets included, and each `value` is the bucket's start; the response adds `granularity` and `time_zone`. With `split_by` (a filterable field of values), a date `group_by` also splits each bucket: the response adds `split_by` and `splits` (the `split_limit` largest values over the range, 8 by default and at most 100, ranked by the sum, else by count; `split_label` names a relation's values), and each group lists its `splits` with their count and sum, average or maximum. Unlike `:facets`, the filter's terms on `group_by` apply too, so the groups add up to what the filter finds. A values `group_by` takes [`limit_per=<field>:<n>`](#first-rows-per-value): the first `n` groups per value of `field`, each with that value as `per`, by `per`, with `limit` capping all groups together; a date `group_by` refuses it |
52
52
  | `GET /{resource}:series?field=&range=&granularity=&time_zone=&filter=` | `range` is `1h`, `24h`, `7d`, `30d`, `90d`, `1y`, `all`, or `from` and `to` (ISO); `granularity` `minute`, `5_minutes`, `15_minutes`, `hour`, `day` (the default), `week` or `month`. Buckets of minutes start on the clock's multiples of them |
53
53
  | `GET /{resource}:histogram?field=&buckets=&filter=` | equal-width buckets of a numeric field |
54
54
  | `GET /{resource}:map?latitude=&longitude=&zoom=&filter=&order_by=&fields=&labels=&photos=&photos_order_by=` | the records in a map's view, the bounding box being in `filter` (`lat >= 51.9 AND lat <= 52.1 AND lng >= 4.2 AND lng <= 4.5`), as `{ items, buckets, total_size }`; see [Maps](#maps) |
@@ -64,6 +64,24 @@ Every response carries `X-Meta-Version`, the hash of the models, the Protobase v
64
64
 
65
65
  A list returns `{ items, next_page_token, total_size_estimate }`, the estimate being the planner's, which reads no rows. `count=exact` adds `total_size`, counted through the indexes but no further than 10,000 matches: above that `total_size` is left out and the estimate stands. `next_page_token` is `""` on the last page, and a token only continues the `filter` and `order_by` it came from: with others the request fails with `400 invalid-cursor`. Items use field names, dates as ISO 8601 text, 64-bit integers and decimals as strings.
66
66
 
67
+ ### First rows per value
68
+
69
+ :::caution[Beta]
70
+ <gap>A list with `limit_per` cannot continue on a next page because paging per value is not implemented.</gap> It takes no `page_token`.
71
+ :::
72
+
73
+ `limit_per=<field>:<n>` keeps, for each value of `field` among the records the filter finds, the first `n` records in the list's `order_by`, such as the latest three comments of each task on a page in one read:
74
+
75
+ ```
76
+ GET /api/v1/comments?filter=related(task_id, tasks.id, (state = "open"), "created_at desc", 20)&order_by=created_at desc&limit_per=task_id:3
77
+ ```
78
+
79
+ - `field` is a filterable field that is not JSON, `n` a whole number from 1 to 500. The items come per value of `field`, in its order, and in `order_by` within each value; records whose `field` is null are left out. `page_size` caps the items over all values together.
80
+ - The records are read as any list reads them, under the caller's tenant, access and filter, a [`related()`](#filtering-through-related-records) term included, so only the values that filter keeps appear. `total_size_estimate` and `total_size` count what the filter finds, not what `limit_per` keeps.
81
+ - `next_page_token` is always `""`. `limit_per` with a `page_token` or on `:seek` is a `400` `invalid-parameter` that names the conflict.
82
+ - The [scan guard](#safety) needs a btree index on `field` with the first field of `order_by` under it, such as `create index on comments (task_id, created_at)`.
83
+ - On [`:aggregate`](#routes), `limit_per` groups by `field` as well as `group_by` and keeps, for each value of `field`, the first `n` groups in the aggregate's order; each group carries that value as `per`.
84
+
67
85
  ### Record history
68
86
 
69
87
  `GET /{resource}/{key}:history` answers `{ items, next_page_token }` for a resource with `.history()`, and `404` for one without. It needs what a get needs, a soft-deleted record included. Each item is `{ id, at, operation, changed, before?, after?, actor, database_role }`: `before` and `after` hold only the fields the caller may read, never a sensitive or file field, `changed` names the changed fields the caller may read, and an update of only other fields is left out. `actor` is `{ id, name? }` for a write through the API, the name when the project's Better Auth knows the user, and `null` otherwise; `database_role` is the role that wrote. See [Record history](history.md).
@@ -249,8 +267,9 @@ The API sends no CORS headers until it has something to allow: other websites in
249
267
 
250
268
  - Every request runs in a transaction with `SET LOCAL statement_timeout` (`statementTimeoutMs`, default 1 s), so a slow query fails where it runs instead of holding a connection that other requests wait for. List, search, get, histogram, series, map and seek transactions are read-only. A query that runs longer is stopped: a `504` `statement-timeout` that names the request, its limit and the ways out, such as `GET /api/v1/orders ran a query longer than 1 s, so the database stopped it. Make the query faster, such as with an index or a narrower filter, or move the work into a function or job with longQueries: true, whose queries may run up to 30 s.` It goes to the app's error hook (`hooks/error.ts`, `createAdmin`'s `options.onUnhandledError`) and the [error tracker](#error-reporting) like a `500`. A read that needs longer has no way to opt out: give it an index, or move it into a [function](../guides/api-functions.md#long-queries) or [job](jobs.md) with `longQueries`.
251
269
  - Under `protobase dev` and `serve`, a request waits at most 2 seconds for a free database connection. When every connection stays busy that long, it is a `503` `connections-busy` with `Retry-After: 1` that names the request, reported the same way, rather than a request that hangs behind slow ones. A request that finds room for a new connection waits up to 30 seconds for it to open, such as while a database that scaled to zero wakes.
252
- - **Scan guard**: a list, `:search`, `:seek`, `:map` page, card photos, `:facets` and `:aggregate` read only columns an index serves, so they stay cheap however many rows match. The server reads each table's valid indexes from the catalog once, then checks every column the caller's filter, the role's row filter, the sort's first field, a facet's or an aggregate's grouped field a [`read` parent](access.md#records-that-belong-to-another)'s relation read and a [`related()`](#filtering-through-related-records) term's `field`, the columns of the parent's own row filter against the parent's table, and the subfilter's columns and `key` of a term against its resource's table:
270
+ - **Scan guard**: a list, `:search`, `:seek`, `:map` page, card photos, `:facets` and `:aggregate` read only columns an index serves, so they stay cheap however many rows match. The server reads each table's valid indexes from the catalog once, then checks every column the caller's filter, the role's row filter, the sort's first field, a facet's or an aggregate's grouped field, the field of [`limit_per`](#first-rows-per-value), a [`read` parent](access.md#records-that-belong-to-another)'s relation read and a [`related()`](#filtering-through-related-records) term's `field`, the columns of the parent's own row filter against the parent's table, and the subfilter's columns and `key` of a term against its resource's table:
253
271
  - Comparisons, `in`, null checks, sorts and facets need a btree index with the column as a key, every key before it pinned by the query: by `=` or `in` in the filter (outside `OR` and `NOT`), by the tenant or by soft delete. `(for_sale, status, published_at desc)` serves `for_sale = true AND status = "available"` sorted by `published_at desc`, but not `status` alone. `=` on text may use a pg_trgm index instead.
272
+ - `limit_per` reads each value's records in the sort's order, so it needs one btree index with its field as a key and the sort's first field under it, `(task_id, created_at)` for `limit_per=task_id:3&order_by=created_at desc`; without an `order_by`, an index on its field alone.
254
273
  - Patterns (`name = "*port*"`), `regex()`, `similar()` and `search()` need a pg_trgm (GIN or GiST) index on each column they read, a `digitsEnd` search field one on its digits; JSON `field:value` needs a GIN index.
255
274
  - A partial index counts for nothing, and a resource on a plain view or a foreign table, which has no indexes of its own, is not checked.
256
275
 
@@ -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`. |
@@ -137,7 +138,7 @@ A record's related records repeat under it as a list: a `ReferenceManyField` hol
137
138
  </RecordCard>
138
139
  ```
139
140
 
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
+ 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, its `source`; a `ReferenceManyField`'s is `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
 
142
143
  <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>
143
144
 
@@ -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