@protobase/cli 0.100.25 → 0.101.0

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.
@@ -12,6 +12,17 @@ const what = (expression) => {
12
12
  if (ts.isClassExpression(inner)) return "a class";
13
13
  if (ts.isNewExpression(inner)) return `a new ${inner.expression.getText()}`;
14
14
  };
15
+ const recordChildBlocks = /* @__PURE__ */ new Set([
16
+ "RecordCard",
17
+ "CardRow",
18
+ "ReferenceField",
19
+ "RecordsIterator"
20
+ ]);
21
+ const unwrapped = (expression) => ts.isParenthesizedExpression(expression) ? expression.expression : expression;
22
+ const isExpressionArrow = (expression) => {
23
+ const inner = unwrapped(expression);
24
+ return ts.isArrowFunction(inner) && !ts.isBlock(inner.body);
25
+ };
15
26
  const isHookCall = (node) => ts.isCallExpression(node) && /^use[A-Z]/.test(ts.isPropertyAccessExpression(node.expression) ? node.expression.name.text : node.expression.getText());
16
27
  /** Every place in a layout file where JSX gets a value that cannot be static, and every hook call. */
17
28
  const layoutProblems = (code, file) => {
@@ -23,12 +34,12 @@ const layoutProblems = (code, file) => {
23
34
  };
24
35
  const visit = (node) => {
25
36
  if (ts.isJsxAttribute(node) && node.initializer && ts.isJsxExpression(node.initializer) && node.initializer.expression) {
26
- const kind = what(node.initializer.expression);
27
- if (kind) problems.push(`${at(node)}: <${elementName(node)} ${node.name.getText()}> is ${kind}; layout props must be static data. Use <Action name="..."> for behaviour, or a custom component for React code.`);
37
+ const kind = node.name.getText() === "filter" && isExpressionArrow(node.initializer.expression) ? void 0 : what(node.initializer.expression);
38
+ if (kind) problems.push(`${at(node)}: <${elementName(node)} ${node.name.getText()}> is ${kind}; layout props must be static data, a filter may be one arrow of the builder. Use <Action name="..."> for behaviour, or a custom component for React code.`);
28
39
  }
29
40
  if (ts.isJsxExpression(node) && node.expression && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent))) {
30
- const kind = what(node.expression);
31
- if (kind) problems.push(`${at(node)}: a child of <${ts.isJsxElement(node.parent) ? node.parent.openingElement.tagName.getText() : ""}> is ${kind}; layout children must be elements or text.`);
41
+ const kind = ts.isJsxElement(node.parent) && recordChildBlocks.has(node.parent.openingElement.tagName.getText().replace(/<.*$/, "")) && isExpressionArrow(node.expression) ? void 0 : what(node.expression);
42
+ if (kind) problems.push(`${at(node)}: a child of <${ts.isJsxElement(node.parent) ? node.parent.openingElement.tagName.getText() : ""}> is ${kind}; layout children must be elements or text, or for a ${[...recordChildBlocks].join(", ")} one arrow of its record.`);
32
43
  }
33
44
  if (isHookCall(node)) problems.push(`${at(node)}: ${node.expression.getText()}() is a hook; layouts have no state. Put stateful UI in a custom component.`);
34
45
  ts.forEachChild(node, visit);
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.100.25";
2
+ var version = "0.101.0";
3
3
  //#endregion
4
4
  export { version };
@@ -10,7 +10,7 @@ import { configExports, createAdmin } from "@protobase/server";
10
10
  * beside the config's resources (see `readUserTables`). `report` is what the admin does with an unhandled error.
11
11
  */
12
12
  const projectAdmin = (project, db, ui, reporter, upgradeWebSocket, userTables) => {
13
- const { resources, views, pages, userMenu, bottomBars, subscriptions } = configExports(project.config);
13
+ const { resources, views, pages, translations, userMenu, bottomBars, subscriptions } = configExports(project.config);
14
14
  const unhandled = project.options?.onUnhandledError ?? ((error) => console.error(error));
15
15
  const report = (error, request) => {
16
16
  reporter?.report(error, request);
@@ -21,6 +21,7 @@ const projectAdmin = (project, db, ui, reporter, upgradeWebSocket, userTables) =
21
21
  views,
22
22
  ...userTables && { userTables },
23
23
  pages,
24
+ ...translations && { translations },
24
25
  ...userMenu && { userMenu },
25
26
  bottomBars,
26
27
  db,
@@ -48,10 +48,30 @@ const cliTypePaths = (ownDir = cliDir) => Object.fromEntries(typedPackages.flatM
48
48
  const dir = findPackageDirSync(name, ownDir) ?? findPackageDirSync(name, uiPackageDir);
49
49
  return dir ? packagePaths(name, dir).map(([id, file]) => [id, [file]]) : [];
50
50
  }));
51
+ /** The declarations that register the project's config module, which typed layouts read their resources and texts from. */
52
+ const registerFile = path.join(protobaseFolder, "register.d.ts");
53
+ const register = [
54
+ "// Written by protobase: the project's config module, which layout(), recordLayout() and <Trans> read the app's",
55
+ "// resources, fields and texts from. Wrap a typed layout in page() or a view; a layout exported bare refers to itself.",
56
+ "import type * as app from '../config/index'",
57
+ "",
58
+ "declare module '@protobase/layout' {",
59
+ " interface Register {",
60
+ " app: typeof app",
61
+ " }",
62
+ "}",
63
+ ""
64
+ ].join("\n");
65
+ const writeChanged = async (file, content) => {
66
+ if (existsSync(file) && readFileSync(file, "utf8") === content) return;
67
+ await writeFile(file, content);
68
+ };
51
69
  /**
52
70
  * Writes `.protobase/tsconfig.json` in `projectDir`, which the project's tsconfig.json extends: in a bundled project
53
71
  * its `paths` give the @protobase packages and those the serve runtime supplies the types of the CLI that builds the
54
- * app, with nothing installed; a locked project's installed packages type themselves, so it holds no paths. The
72
+ * app, with nothing installed; a locked project's installed packages type themselves, so it holds no paths. With a
73
+ * `config/index.ts` it also writes `.protobase/register.d.ts`, which types the layouts by the app's resources and texts,
74
+ * and includes it beside the project's files; a project tsconfig.json with an `include` of its own lists it there. The
55
75
  * folder ignores itself in git, since the paths are this machine's. An unchanged file is left alone: Vite reloads every
56
76
  * module on any write to a tsconfig.json, so another command rewriting it would rebuild a running dev server's API.
57
77
  */
@@ -61,10 +81,13 @@ const writeProjectTypes = async (projectDir) => {
61
81
  const ignore = path.join(folder, ".gitignore");
62
82
  if (!existsSync(ignore)) await writeFile(ignore, "*\n");
63
83
  const compilerOptions = projectPackages(projectDir).mode === "bundled" ? { paths: cliTypePaths() } : {};
64
- const file = path.join(projectDir, typesFile);
65
- const content = `${JSON.stringify({ compilerOptions }, null, 2)}\n`;
66
- if (existsSync(file) && readFileSync(file, "utf8") === content) return;
67
- await writeFile(file, content);
84
+ const registered = existsSync(path.join(projectDir, "config", "index.ts"));
85
+ if (registered) await writeChanged(path.join(projectDir, registerFile), register);
86
+ const include = registered ? { include: ["../**/*", "register.d.ts"] } : {};
87
+ await writeChanged(path.join(projectDir, typesFile), `${JSON.stringify({
88
+ compilerOptions,
89
+ ...include
90
+ }, null, 2)}\n`);
68
91
  };
69
92
  //#endregion
70
- export { cliTypePaths, typesFile, writeProjectTypes };
93
+ export { cliTypePaths, registerFile, typesFile, writeProjectTypes };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.100.25",
3
+ "version": "0.101.0",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -43,13 +43,13 @@
43
43
  "dependencies": {
44
44
  "@better-auth/core": "^1.7.12",
45
45
  "@hono/node-server": "^2.1.3",
46
- "@protobase/config": "0.100.25",
47
- "@protobase/layout": "0.100.25",
48
- "@protobase/query": "0.100.25",
49
- "@protobase/schema": "0.100.25",
50
- "@protobase/server": "0.100.25",
51
- "@protobase/ui": "0.100.25",
52
- "@protobase/workflows": "0.100.25",
46
+ "@protobase/config": "0.101.0",
47
+ "@protobase/layout": "0.101.0",
48
+ "@protobase/query": "0.101.0",
49
+ "@protobase/schema": "0.101.0",
50
+ "@protobase/server": "0.101.0",
51
+ "@protobase/ui": "0.101.0",
52
+ "@protobase/workflows": "0.101.0",
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",
@@ -26,7 +26,7 @@ Apps written for other systems that keep working on Protobase, and moving their
26
26
  ## react-admin
27
27
 
28
28
  - [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.
29
- - [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`.
29
+ - [Filters and sorts on related records](../reference/layouts.md#related-records) (beta): `filter` is AIP-160 text or the condition builder's arrow, since an object cannot say `OR`, and `sort` a list of fields, `['claimed_at desc']`; react-admin's `{ field: value }` and `{ field, order }` objects are not taken.
30
30
  - [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.
31
31
  - [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.
32
32
  - [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.
@@ -7,7 +7,9 @@ Pages of your own, built from blocks in a JSX layout.
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
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.
10
- - [Conditions](../reference/layouts.md#conditions): Part of a page shows only while a condition on a record or a count holds.
10
+ - [Conditions](../reference/layouts.md#conditions): Part of a page shows only while a condition on a record, a count or the time, `now() + 7d`, holds.
11
+ - [Typed layouts](../reference/layouts.md#typed-layouts) (beta): `layout()` and `recordLayout()` write a page's tree with the record and the app's tables in hand, so TypeScript checks every resource, column, sort and field against the app, and record blocks take a function of their record.
12
+ - [The condition builder](../reference/layouts.md#the-condition-builder) (beta): A filter is an arrow, `(f) => f.status.eq('open').and(f.due_at.lt(now().plus('7d')))`, and a condition the same builder's, written as AIP-160 for you.
11
13
  - [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.
12
14
  - [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`.
13
15
  - [App addresses](../reference/layouts.md#addresses): Links to lists, records, create forms and pages are typed addresses that can carry filters and prefilled values.
@@ -11,6 +11,7 @@ The app's colours, name, icon, language and installation.
11
11
  - [Logo and favicon](../reference/theme.md#logo-and-favicon): Your own favicon or logo replaces Protobase's.
12
12
  - [Named icons](../reference/layouts.md#named-actions): Actions, key facts and card meta show an icon picked by name from a set, such as `play`, `bed` or `cpu`.
13
13
  - [English and Dutch](../reference/languages.md): The built-in screens come in English and Dutch, with numbers and dates written to match.
14
+ - [The app's own texts](../reference/languages.md#your-own-texts) (beta): Pages and labels come in each language the app has translations for, ICU messages shown with `<Trans>`, in the reader's language, and the server refuses to start on a missing text.
14
15
  - [Installable app](../reference/installable-app.md): The admin installs as an app on phones and computers, and says when the server cannot be reached.
15
16
  - [Start from the last pages seen](../reference/installable-app.md#starting-from-the-last-pages-seen): Someone signed in opens the app on what it showed last time, muted with a spinner by the title until it is refreshed in the background.
16
17
 
@@ -161,7 +161,7 @@ export const billing = page(
161
161
  <CardRow
162
162
  title="Payment methods"
163
163
  resource="payment_methods"
164
- sort="is_default desc, id"
164
+ sort={['is_default desc', 'id']}
165
165
  actions={<ModalForm mode="create" label="Add card" resource="payment_methods" fields={['brand', 'last4', 'expires']} />}
166
166
  >
167
167
  <Field source="brand" label={false} />
@@ -178,7 +178,7 @@ export const billing = page(
178
178
  )
179
179
  ```
180
180
 
181
- The cards sit side by side in a `CardRow`, the default card first (`sort="is_default desc, id"`). Two `Show` blocks split the card on its own `is_default` field: the default card says so, the others get "Make default" and "Remove". Those are again view actions, `a.update('makeDefault', ...)` and `a.remove('remove', ...)` in the views above.
181
+ The cards sit side by side in a `CardRow`, the default card first (`sort={['is_default desc', 'id']}`). Two `Show` blocks split the card on its own `is_default` field: the default card says so, the others get "Make default" and "Remove". Those are again view actions, `a.update('makeDefault', ...)` and `a.remove('remove', ...)` in the views above.
182
182
 
183
183
  Making a card the default unsets the others in the database (a trigger or a write hook); the row reloads after every action, so the order follows. "Add card" is a `ModalForm mode="create"` in the row's header. In the story, make the Mastercard the default, remove the Visa and add a card.
184
184
 
@@ -226,7 +226,7 @@ export const billing = page(
226
226
  <CardRow
227
227
  title="Payment methods"
228
228
  resource="payment_methods"
229
- sort="is_default desc, id"
229
+ sort={['is_default desc', 'id']}
230
230
  actions={<ModalForm mode="create" label="Add card" resource="payment_methods" fields={['brand', 'last4', 'expires']} />}
231
231
  >
232
232
  <Field source="brand" label={false} />
@@ -239,10 +239,10 @@ export const billing = page(
239
239
  </Show>
240
240
  </CardRow>
241
241
  <Grid columns={3}>
242
- <Table title="Invoices" resource="invoices" sort="issued_at desc" limit={5} span={2} />
242
+ <Table title="Invoices" resource="invoices" sort={['issued_at desc']} limit={5} span={2} />
243
243
  <Grid columns={1}>
244
244
  <Stat label="Open invoices" resource="invoices" filter="status = 'open'" />
245
- <RecordCard title="Latest invoice" resource="invoices" sort="issued_at desc" actions={<Action name="download" />}>
245
+ <RecordCard title="Latest invoice" resource="invoices" sort={['issued_at desc']} actions={<Action name="download" />}>
246
246
  <Grid columns={2}>
247
247
  <Field source="number" />
248
248
  <Field source="total" />
@@ -59,15 +59,15 @@ export const overview = page(
59
59
  <Stat label="Open leads" resource="companies" filter="status = 'lead'" />
60
60
  </Grid>
61
61
  <Grid columns={2}>
62
- <Table title="Overdue invoices" resource="invoices" filter="status = 'overdue'" sort="issued_at" columns={['number', 'company_id', 'due_at', 'total']} limit={2} empty="Nothing is overdue." />
63
- <Table title="Latest orders" resource="orders" sort="created_at desc" columns={['number', 'company_id', 'status', 'total']} limit={5} />
62
+ <Table title="Overdue invoices" resource="invoices" filter="status = 'overdue'" sort={['issued_at']} columns={['number', 'company_id', 'due_at', 'total']} limit={2} empty="Nothing is overdue." />
63
+ <Table title="Latest orders" resource="orders" sort={['created_at desc']} columns={['number', 'company_id', 'status', 'total']} limit={5} />
64
64
  </Grid>
65
65
  </Page>,
66
66
  { nav: { group: 'Sales', order: 0 }, icon: 'layout-dashboard' },
67
67
  )
68
68
  ```
69
69
 
70
- A `Table` takes the same `resource`, `filter` and `sort` (AIP-132, like `?order_by=`), plus the `columns` to show and a `limit`. Relations such as `company_id` show the company's name, a row opens the record, and **View all** opens the list with the same filter and order. Try it on the overdue invoices: there are three, and the table shows two.
70
+ A `Table` takes the same `resource`, `filter` and `sort` (a list of fields, like `?order_by=` one entry at a time), plus the `columns` to show and a `limit`. Relations such as `company_id` show the company's name, a row opens the record, and **View all** opens the list with the same filter and order. Try it on the overdue invoices: there are three, and the table shows two.
71
71
 
72
72
  ## 3. One order to chase
73
73
 
@@ -90,7 +90,7 @@ export const overview = page(
90
90
  title="Biggest unpaid delivery"
91
91
  resource="orders"
92
92
  filter="status = 'delivered' AND paid = false"
93
- sort="total desc"
93
+ sort={['total desc']}
94
94
  empty="Every delivered order is paid."
95
95
  actions={<Action name="markPaid" variant="primary" />}
96
96
  >
@@ -103,8 +103,8 @@ export const overview = page(
103
103
  <Show when="company_id.status = 'dormant'">The customer has gone quiet: call before sending a reminder.</Show>
104
104
  </RecordCard>
105
105
  <Grid columns={2}>
106
- <Table title="Overdue invoices" resource="invoices" filter="status = 'overdue'" sort="issued_at" columns={['number', 'company_id', 'due_at', 'total']} limit={2} empty="Nothing is overdue." />
107
- <Table title="Latest orders" resource="orders" sort="created_at desc" columns={['number', 'company_id', 'status', 'total']} limit={5} />
106
+ <Table title="Overdue invoices" resource="invoices" filter="status = 'overdue'" sort={['issued_at']} columns={['number', 'company_id', 'due_at', 'total']} limit={2} empty="Nothing is overdue." />
107
+ <Table title="Latest orders" resource="orders" sort={['created_at desc']} columns={['number', 'company_id', 'status', 'total']} limit={5} />
108
108
  </Grid>
109
109
  </Page>,
110
110
  { nav: { group: 'Sales', order: 0 }, icon: 'layout-dashboard' },
@@ -187,7 +187,7 @@ export const overview = page(
187
187
  title="Biggest unpaid delivery"
188
188
  resource="orders"
189
189
  filter="status = 'delivered' AND paid = false"
190
- sort="total desc"
190
+ sort={['total desc']}
191
191
  empty="Every delivered order is paid."
192
192
  actions={<Action name="markPaid" variant="primary" />}
193
193
  >
@@ -200,15 +200,15 @@ export const overview = page(
200
200
  <Show when="company_id.status = 'dormant'">The customer has gone quiet: call before sending a reminder.</Show>
201
201
  </RecordCard>
202
202
  <Grid columns={2}>
203
- <Table title="Overdue invoices" resource="invoices" filter="status = 'overdue'" sort="issued_at" columns={['number', 'company_id', 'due_at', 'total']} limit={2} empty="Nothing is overdue." />
204
- <Table title="Latest orders" resource="orders" sort="created_at desc" columns={['number', 'company_id', 'status', 'total']} limit={5} />
203
+ <Table title="Overdue invoices" resource="invoices" filter="status = 'overdue'" sort={['issued_at']} columns={['number', 'company_id', 'due_at', 'total']} limit={2} empty="Nothing is overdue." />
204
+ <Table title="Latest orders" resource="orders" sort={['created_at desc']} columns={['number', 'company_id', 'status', 'total']} limit={5} />
205
205
  </Grid>
206
206
  <CardRow
207
207
  title="New leads"
208
208
  description="Companies that have not ordered yet."
209
209
  resource="companies"
210
210
  filter="status = 'lead'"
211
- sort="created_at desc"
211
+ sort={['created_at desc']}
212
212
  actions={<ModalForm mode="create" label="Add lead" resource="companies" fields={['name', 'city', 'email']} values={{ status: 'lead' }} />}
213
213
  >
214
214
  <Field source="name" label={false} />
@@ -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`, `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`:
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, as in the list API, or the [builder's arrow](layouts.md#the-condition-builder), and `sort` a list of fields, each with `asc` or `desc` if it likes, as the list API's `order_by`. 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 */
@@ -31,7 +31,7 @@ export const salesOverview = page(
31
31
  title="Biggest unpaid delivery"
32
32
  resource="orders"
33
33
  filter="status = 'delivered' AND paid = false"
34
- sort="total desc"
34
+ sort={['total desc']}
35
35
  empty="Every delivered order is paid."
36
36
  actions={<Action name="markPaid" variant="primary" />}
37
37
  >
@@ -47,7 +47,7 @@ export const salesOverview = page(
47
47
  title="Oldest overdue invoice"
48
48
  resource="invoices"
49
49
  filter="status = 'overdue'"
50
- sort="issued_at"
50
+ sort={['issued_at']}
51
51
  empty="Nothing is overdue."
52
52
  actions={[<Action name="send" label="Send reminder" />, <Action name="recordPayment" variant="primary" />]}
53
53
  >
@@ -67,15 +67,15 @@ export const salesOverview = page(
67
67
  <Chart title="Revenue by customer" description="Orders not cancelled." resource="orders" groupBy="company_id" sum="total" filter="status != 'cancelled'" limit={5} />
68
68
  </Grid>
69
69
  <Grid columns={2}>
70
- <Table title="Overdue invoices" resource="invoices" filter="status = 'overdue'" sort="issued_at" columns={['number', 'company_id', 'due_at', 'total']} limit={5} empty="Nothing is overdue." />
71
- <Table title="Latest orders" resource="orders" sort="created_at desc" columns={['number', 'company_id', 'status', 'total']} limit={5} />
70
+ <Table title="Overdue invoices" resource="invoices" filter="status = 'overdue'" sort={['issued_at']} columns={['number', 'company_id', 'due_at', 'total']} limit={5} empty="Nothing is overdue." />
71
+ <Table title="Latest orders" resource="orders" sort={['created_at desc']} columns={['number', 'company_id', 'status', 'total']} limit={5} />
72
72
  </Grid>
73
73
  <CardRow
74
74
  title="New leads"
75
75
  description="Companies that have not ordered yet."
76
76
  resource="companies"
77
77
  filter="status = 'lead'"
78
- sort="created_at desc"
78
+ sort={['created_at desc']}
79
79
  limit={8}
80
80
  actions={<ModalForm mode="create" label="Add lead" resource="companies" fields={['name', 'city', 'country_code', 'email']} values={{ status: 'lead' }} />}
81
81
  >
@@ -165,7 +165,7 @@ Plain elements for a page too custom for the blocks, drawn by their [Tailwind cl
165
165
  | `Box` | An element of its own, such as a panel or a banner. No look of its own. |
166
166
  | `Row` | Its children side by side: `flex`. |
167
167
  | `Column` | Its children one under another: `flex flex-col`. |
168
- | `Text` | Text, `Link`s, `Text as="span"`s and [field components](#field-components) in it, nothing else, run as one line. `as` makes it `p` (the default), `span`, or a heading `h1` to `h4`. |
168
+ | `Text` | Text, `Link`s, `Trans`es, inline `Text`s and [field components](#field-components) in it, nothing else, run as one line. `as` makes it `p` (the default), `span`, `strong`, `em`, or a heading `h1` to `h4`; `span`, `strong` and `em` run inline. |
169
169
 
170
170
  ```tsx
171
171
  <Row className="items-center gap-3">
@@ -174,6 +174,20 @@ Plain elements for a page too custom for the blocks, drawn by their [Tailwind cl
174
174
  </Row>
175
175
  ```
176
176
 
177
+ ### Trans
178
+
179
+ One of the app's own texts in the reader's language, as react-i18next's `<Trans>`: as a child, it runs inline as text does, and as a `title`, `description`, `label` or `empty` it reads as that prop's text. See [Texts in the reader's language](layouts.md#texts-in-the-readers-language).
180
+
181
+ | Prop | |
182
+ | --- | --- |
183
+ | `i18nKey` | The message's key in the app's [translations](languages.md#your-own-texts), such as `today.open`. Required. |
184
+ | `values` | What the message formats by name, `{ count: 2, name: '{{owner}}' }`: text, numbers, booleans and placeholders. |
185
+ | `components` | The element each tag of the message draws, `{ b: <Text as="strong" /> }`, with the tag's text inside it. As a prop's text, tags read as their text alone. |
186
+
187
+ ```tsx
188
+ <Trans i18nKey="today.owner" values={{ name: '{{owner}}' }} components={{ b: <Text as="strong" /> }} />
189
+ ```
190
+
177
191
  ### Details and Summary
178
192
 
179
193
  A line that opens to show the rest and closes again, drawn as HTML's [`<details>` and `<summary>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details), so the browser opens and closes it with no script. A `Details` takes one `Summary`, as its first child; the `Summary` is one line, holding what a `Text` holds. See [Field values](layouts.md#field-values).
@@ -251,7 +265,7 @@ The first records of a list, drawn the way the resource's list page draws them:
251
265
  | `span` | Width in a grid. |
252
266
 
253
267
  ```tsx
254
- <Table title="Overdue invoices" resource="invoices" filter="status = 'overdue'" sort="issued_at" columns={['number', 'company_id', 'due_at', 'total']} limit={5} empty="Nothing is overdue." />
268
+ <Table title="Overdue invoices" resource="invoices" filter="status = 'overdue'" sort={['issued_at']} columns={['number', 'company_id', 'due_at', 'total']} limit={5} empty="Nothing is overdue." />
255
269
  ```
256
270
 
257
271
  #### Columns on a phone
@@ -349,7 +363,7 @@ One record and what is inside it: the one `recordKey` names (the key as the reco
349
363
  | `span` | Width in a grid. |
350
364
 
351
365
  ```tsx
352
- <RecordCard title="Biggest unpaid delivery" resource="orders" filter="status = 'delivered' AND paid = false" sort="total desc" actions={<Action name="markPaid" variant="primary" />}>
366
+ <RecordCard title="Biggest unpaid delivery" resource="orders" filter="status = 'delivered' AND paid = false" sort={['total desc']} actions={<Action name="markPaid" variant="primary" />}>
353
367
  <Field source="number" />
354
368
  <Field source="company_id.city" label="City" />
355
369
  </RecordCard>
@@ -383,7 +397,7 @@ It follows the resource's view as its list page does. Of a resource whose view h
383
397
  | `span` | Width in a grid. |
384
398
 
385
399
  ```tsx
386
- <RecordRow title="For rent" resource="listings" filter="for_rent = true AND status = 'available'" sort="published_at desc" />
400
+ <RecordRow title="For rent" resource="listings" filter="for_rent = true AND status = 'available'" sort={['published_at desc']} />
387
401
  ```
388
402
 
389
403
  ### RecordCards
@@ -582,14 +596,14 @@ The records of `reference` whose `target` holds the record's `source`, as [react
582
596
  | `reference` | The resource it reads. Required. |
583
597
  | `target` | The field of `reference` that points at the record. Required. |
584
598
  | `source` | The field of the record it matches; default `id`, of the nearest record. A [path](layouts.md#paths-and-scopes), such as `../id`. |
585
- | `filter` | More conditions, as AIP-160 text or react-admin's `{ field: value }`, its fields ANDed. |
586
- | `sort` | AIP-132 text, or react-admin's `{ field, order: 'ASC' \| 'DESC' }`; default the key, descending. |
599
+ | `filter` | More conditions, as AIP-160 text or the [builder's arrow](layouts.md#the-condition-builder), ANDed with the target's. |
600
+ | `sort` | A list of fields, each with `asc` or `desc` if it likes, `['claimed_at desc']`; default the key, descending. |
587
601
  | `perPage` | How many records it reads, at most 500; default 25. |
588
602
  | `pagination` | `more`: a **Load more** button reads the next `perPage` records into the same list. |
589
603
  | `empty` | Text instead of the children when no record matches. |
590
604
 
591
605
  ```tsx
592
- <ReferenceManyField reference="task_claims" target="task_id" filter={{ status: 'open' }} sort={{ field: 'claimed_at', order: 'DESC' }} pagination="more">
606
+ <ReferenceManyField reference="task_claims" target="task_id" filter="status = 'open'" sort={['claimed_at desc']} pagination="more">
593
607
  <Table title="Open claims" columns={['worker_id', 'claimed_at']} />
594
608
  </ReferenceManyField>
595
609
  ```
@@ -359,11 +359,13 @@ docker run --rm -p 127.0.0.1:8787:8787 -e DATABASE_URL -e PROTOBASE_URL -e PROTO
359
359
  ## `types`
360
360
 
361
361
  ```sh
362
- protobase types # writes .protobase/tsconfig.json; dev, build and every command that loads the config write it too
362
+ protobase types # writes .protobase/tsconfig.json and register.d.ts; dev, build and every command that loads the config write them too
363
363
  ```
364
364
 
365
365
  Writes `.protobase/tsconfig.json`, which the project's `tsconfig.json` extends (`"extends": "./.protobase/tsconfig.json"`). In a bundled project its `paths` point each `@protobase` package and each package the serve runtime supplies, by name and by each of its exports (`@protobase/layout/jsx-runtime`, `kysely`, `zod`, ...), at the declarations of the CLI that builds the app, so the editor and `tsc` see the version that runs with nothing installed. There is no catch-all, so a package the project imports and lacks still fails as missing. React carries no types of its own, so the project keeps `@types/react`, as it keeps `@types/node`. A locked project's installed packages type themselves, so its file holds no `paths`. A `paths` of the project's own `tsconfig.json` replaces the generated one, as `extends` does with any option.
366
366
 
367
+ With a `config/index.ts`, it also writes `.protobase/register.d.ts`, which registers that module's type with `@protobase/layout`, so [typed layouts](layouts.md#typed-layouts) and `<Trans>` check the app's resource names, fields and text keys, and the generated `tsconfig.json` includes it beside the project's own files (`"include": ["../**/*", "register.d.ts"]`). A project `tsconfig.json` with an `include` of its own replaces that one, so it lists `.protobase/register.d.ts` there too.
368
+
367
369
  `.protobase/` ignores itself in git: the paths are this machine's. Write the file again after installing another CLI; `dev` and `build` do it on every run.
368
370
 
369
371
  ## `run`
@@ -2,9 +2,9 @@
2
2
 
3
3
  # Languages
4
4
 
5
- The admin app's built-in screens come in English and Dutch, chosen by the app or by each user's browser, with numbers and dates written to match.
5
+ The admin app's built-in screens come in English and Dutch, chosen by the app or by each user's browser, with numbers and dates written to match, and the app's own texts in any language it has translations for.
6
6
 
7
- The admin app's own texts and its numbers and dates come in English and Dutch. The texts you write yourself, such as resource names, labels and enum value labels, show as you write them, in any language.
7
+ The admin app's own texts and its numbers and dates come in English and Dutch. The texts you write yourself, such as resource names, labels and enum value labels, show as you write them, in any language, unless the app's [translations](#your-own-texts) give them in the reader's.
8
8
 
9
9
  ## Choosing the language
10
10
 
@@ -22,6 +22,40 @@ The value is `'en'` or `'nl'`, and the server refuses to start with any other va
22
22
 
23
23
  Numbers, amounts and dates use the conventions of the language: English as written in Britain (`6 Oct 2026`, `€1,234.56`), and Dutch as written in the Netherlands (`6 okt 2026`, `€ 1.234,56`). Typing a decimal number in a form uses the same decimal mark. Times show in the viewer's time zone in both languages.
24
24
 
25
+ ## Your own texts
26
+
27
+ The app's own texts, its pages' and its labels, come in every language it has translations for: one JSON file per language, its messages ICU, as `intl-messageformat` reads them, exported from `config/index.ts` with `translations`:
28
+
29
+ ```ts title="config/index.ts"
30
+ import { translations } from '@protobase/layout'
31
+ import en from './texts/en.json'
32
+ import nl from './texts/nl.json'
33
+
34
+ export const texts = translations({ en, nl })
35
+ ```
36
+
37
+ ```json title="config/texts/nl.json"
38
+ {
39
+ "today": {
40
+ "title": "Vandaag",
41
+ "open": "{count, plural, one {# open taak} other {# open taken}}",
42
+ "owner": "Van <b>{name}</b>"
43
+ },
44
+ "resources": {
45
+ "tasks": {
46
+ "names": { "singular": "Taak", "plural": "Taken" },
47
+ "fields": { "status": { "label": "Staat", "values": { "done": "Klaar" } } }
48
+ }
49
+ }
50
+ }
51
+ ```
52
+
53
+ A layout shows a message with [`<Trans i18nKey="today.open" values={{ count: 2 }} />`](layouts.md#texts-in-the-readers-language), and a page whose `title` is one is named by it in the sidebar too. A view's labels take their key from where they sit, under `resources.<resource>`: `names.singular` and `names.plural`, `help`, `fields.<field>.label`, `.help` and `.values.<value>`, `layout.<index>.title`, `.help` and `.empty` (a tab's items under `layout.<index>.items.<index>`), and `actions.<action>.label` and `.confirm`. A label the translations leave out shows as the view writes it.
54
+
55
+ Each reader gets the app's own `locale` when it sets one the translations have, else the first of their browser's languages the translations have, by its tag or its language (`nl-BE` reads `nl`), else English, else the first language. A language is any BCP 47 tag, such as `de` or `pt-BR`, while the built-in screens stay in English or Dutch. `/meta` serves the reader's language and only the messages their pages name, as `texts: { locale, messages }`, with the page titles and labels already in it.
56
+
57
+ The config fails to load when a message is not ICU or a language lacks a key another has, and the server refuses to start when a layout names a key no language has, leaves out a value its message formats in some language, or has a tag with no element in `components`, naming the page or view.
58
+
25
59
  ## What is translated
26
60
 
27
61
  Every built-in screen is translated: the shell with its sidebar, top bar, search, notification bell, profile menu and bottom bar; the list page with all its displays (table, cards, board, calendar, timeline and map), filters, search, sort, imports and exports; the record page with its actions, related lists, history, comments, gallery, saving, conflicts and deleting; the create page and composed pages; saved searches and favorites; the sign-in, sign-up and two-factor screens, the account and sign-in policy pages, and the organization, people and invitation pages; public forms; the assistant's dock and a record's [lines](ui-config.md#record-lines); the notice naming a plugin that is off and why; and the messages, toasts and confirmations around them. The parts `@protobase/ui` gives your own components, such as the [form parts](custom-components.md#form-parts), the [chat parts](custom-components.md#chat-parts) and the markdown editor, come in the app's language too. So are counts, relative times ("5 minutes ago"), yes, no and the other values the app writes itself, and the notices shown while the app loads.
@@ -119,14 +119,14 @@ It takes the options of `renderText` but `records`, `tables` and `planned`, and
119
119
 
120
120
  A prop is a string, a finite number, a boolean, `null`, or an array or plain object of those (elements included). It is JSON in the end, so the rules are checked twice:
121
121
 
122
- - **At build time.** `protobase build` and `protobase dev` read every file with the `@jsxImportSource @protobase/layout` comment and refuse a function, class or `new` value in a prop or child, and any call to a hook (`useState`, ...), with the file, line and column. No project code runs for this.
122
+ - **At build time.** `protobase build` and `protobase dev` read every file with the `@jsxImportSource @protobase/layout` comment and refuse a function, class or `new` value in a prop or child, and any call to a hook (`useState`, ...), with the file, line and column. Two arrows are data and pass: a [filter's arrow](#the-condition-builder) and a record block's child arrow in a [typed layout](#typed-layouts), each one expression, never a body of statements. No project code runs for this.
123
123
  - **When the config loads.** The JSX runtime refuses anything else that is not plain data (a function in a variable, a `Date`, a `Map`, `NaN`), `page()` checks every element's props against its block (unknown, missing and mistyped props, children where none are allowed, elements that need a record outside one), and `createAdmin` checks every resource, field, filter, sort, action and condition against the models. Each problem names its place, such as `Page "overview": <Page> › <Table resource="invoices">: unknown column "amount" on invoices`.
124
124
 
125
125
  Behaviour comes from [named actions](#named-actions); React code from [custom components](custom-components.md).
126
126
 
127
127
  ## Data
128
128
 
129
- `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).
129
+ `Stat`, `RecordCard`, `Table`, `CardRow`, `RecordRow`, `RecordCards` and `Thread` read records of a `resource`. `filter` is AIP-160, exactly as the list API's `filter`, so a filter that works in the list's URL works here, or [the builder's arrow](#the-condition-builder), `filter={(f) => f.status.eq('open')}`, which writes that text. `sort` is a list of fields, each with `asc` or `desc` if it likes, `sort={['due_at', 'total desc']}`, the list API's `order_by` one entry at a time. `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).
130
130
 
131
131
  A `RecordCard` (its first match), a `ReferenceField`, each card of a `CardRow` and each entry of a `RecordsIterator` hold a **record**. Inside one, `Field`, `Diff`, `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.
132
132
 
@@ -143,7 +143,7 @@ A record's related records repeat under it as a list: a `ReferenceManyField` hol
143
143
  <ArrayField source="labels">
144
144
  <RecordsIterator><Field source="this" label={false} /></RecordsIterator>
145
145
  </ArrayField>
146
- <ReferenceManyField reference="task_claims" target="task_id" sort={{ field: 'claimed_at', order: 'DESC' }}>
146
+ <ReferenceManyField reference="task_claims" target="task_id" sort={['claimed_at desc']}>
147
147
  <RecordsIterator>
148
148
  <Card title="Claim {{@index}}">
149
149
  <ReferenceField source="worker_id" reference="workers" />
@@ -156,7 +156,70 @@ A record's related records repeat under it as a list: a `ReferenceManyField` hol
156
156
  </RecordCard>
157
157
  ```
158
158
 
159
- 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. A `ReferenceManyField`'s and a `ReferenceArrayField`'s `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`, such a list is in its key's order, descending, as react-admin's is. A `ReferenceManyField`'s `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.
159
+ 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. A `ReferenceManyField`'s and a `ReferenceArrayField`'s `filter` and `sort` are a data block's: AIP-160 text or the builder's arrow, and a list of fields. react-admin's objects are not taken: write `filter={{ status: 'open' }}` as `filter="status = 'open'"` and `sort={{ field: 'claimed_at', order: 'DESC' }}` as `sort={['claimed_at desc']}`. Without `sort`, such a list is in its key's order, descending, as react-admin's is. A `ReferenceManyField`'s `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.
160
+
161
+ ## Typed layouts
162
+
163
+ A layout written as a function of what it reads is typed by the app's resources: `layout()` draws a composed page's tree, and `recordLayout(resource, ...)` a record page's. Each runs its function once, as the config loads, and gives the same tree the JSX would, so the server checks, plans and serves it as any other.
164
+
165
+ ```tsx
166
+ /** @jsxImportSource @protobase/layout */
167
+ import { Card, Page, Show, Table, Text, layout, now, page, recordLayout, RecordsIterator, ReferenceManyField } from '@protobase/layout'
168
+ import { l, view } from '@protobase/schema'
169
+
170
+ export const today = page('today', layout(({ resources }) => (
171
+ <Page title="Today">
172
+ <Show when={resources.invoices.count.gt(0)}>
173
+ <Table resource="invoices" filter={(f) => f.status.eq('open').and(f.due_at.lt(now().plus('7d')))} sort={['due_at asc']} columns={['number', 'due_at', 'total']} />
174
+ </Show>
175
+ </Page>
176
+ )))
177
+
178
+ export const tasksView = view<typeof tasks>('tasks').layout(() => [
179
+ l.blocks(recordLayout('tasks', ({ data }) => (
180
+ <ReferenceManyField reference="task_runs" target="task_id">
181
+ <RecordsIterator<'task_runs'>>{(run) => <Card title={`${run.outcome} of ${data.title}`} />}</RecordsIterator>
182
+ </ReferenceManyField>
183
+ ))),
184
+ ])
185
+ ```
186
+
187
+ | | |
188
+ | --- | --- |
189
+ | `data` | The record page's record, in `recordLayout` only: `data.title` is the placeholder `{{title}}`, so `` `Runs of ${data.title}` `` is `Runs of {{title}}`. |
190
+ | `resources` | `resources.invoices.count` is how many `invoices` the user can see, for a [condition](#conditions). |
191
+ | A record block's child | A `RecordCard`, a `CardRow`, a `ReferenceField` or a `RecordsIterator` takes a function of its record as its children, `(run) => ...`. Inside it `run.outcome` is `{{outcome}}`, the page's record is `{{@root.title}}`, and a record further out is `{{../outcome}}`. |
192
+
193
+ With `.protobase/register.d.ts`, which `protobase types`, `dev` and `build` write from `config/index.ts` (see [`types`](cli.md#types)), TypeScript checks the names against the app: `resource` against its resources, `columns`, `fields`, `sort` and the filter's fields against the resource's fields, `data` against the record's fields, and a [`<Trans>`](#texts-in-the-readers-language)'s key against its texts. Without the file, any name type-checks and the server checks them as it starts. Export a typed layout inside `page()` or a view, as above: a tree exported bare, `export const tree = layout(...)`, refers to its own type through the register, and TypeScript gives up on it.
194
+
195
+ ### The condition builder
196
+
197
+ A filter's arrow and a typed layout's `when` write AIP-160 with one builder. A field compares with `eq`, `ne`, `lt`, `le`, `gt`, `ge`, `in([...])`, `contains(value)` and `isNull()`, and conditions join with `.and(...)`, `.or(...)` and `not(...)`, bracketed where AND and OR mix:
198
+
199
+ | Builder | AIP-160 |
200
+ | --- | --- |
201
+ | `f.status.eq('open')` | `status = "open"` |
202
+ | `f.total.gt(100).and(f.paid.eq(false))` | `total > 100 AND paid = false` |
203
+ | `f.a.eq(1).and(f.b.eq(2).or(f.c.eq(3)))` | `a = 1 AND (b = 2 OR c = 3)` |
204
+ | `not(f.status.in(['done', 'held']))` | `NOT in(status, "done", "held")` |
205
+ | `f.owner.eq(null)`, `f.owner.isNull()` | `isNull(owner)` |
206
+ | `f.plan.name.ne('Pro')` | `plan.name != "Pro"` |
207
+ | `f.due_at.lt(now().plus('7d'))` | `due_at < now() + 7d` |
208
+ | `f.task_id.eq(data.id)` | `task_id = {{id}}` |
209
+
210
+ `now().plus(...)` and `now().minus(...)` take a duration, a number and one of `s`, `m`, `h`, `d` or `w`. A filter's arrow gives one condition, or the layout fails as it loads; AIP-160 text stays for what the builder does not write, such as `related()`.
211
+
212
+ ## Texts in the reader's language
213
+
214
+ A `<Trans i18nKey="..." />` shows one of the app's own texts in the reader's language, as react-i18next's `<Trans>` does, wherever text goes: as a child, or as a `title`, `description`, `label` or `empty`. Its message is ICU, `values` gives what it formats, from a record with `{{path}}` or `data.title`, and `components` the element each of its tags draws:
215
+
216
+ ```tsx
217
+ <Card title={<Trans i18nKey="today.open" values={{ count: 2 }} />}>
218
+ <Trans i18nKey="today.owner" values={{ name: '{{owner}}' }} components={{ b: <Text as="strong" /> }} />
219
+ </Card>
220
+ ```
221
+
222
+ The texts are the app's `translations({ en, nl })`; see [Your own texts](languages.md#your-own-texts).
160
223
 
161
224
  ## How a page reads its data
162
225
 
@@ -271,7 +334,7 @@ export const tasksView = view<typeof tasks>('tasks').layout((r) => [
271
334
  ])
272
335
  ```
273
336
 
274
- The view's file is then `.tsx` and starts with the JSX import source, as a [layout file](#setup) does, or it imports the tree from a layout file of its own.
337
+ The view's file is then `.tsx` and starts with the JSX import source, as a [layout file](#setup) does, or it imports the tree from a layout file of its own. [`recordLayout('tasks', ({ data }) => ...)`](#typed-layouts) writes the same tree typed by the record, `data.title` for `{{title}}`.
275
338
 
276
339
  | | |
277
340
  | --- | --- |
@@ -319,7 +382,9 @@ A [`Timeline`](blocks.md#timeline) takes `select` too: a bar links to the page w
319
382
  | `status`, `plan.name` | A field of the records around it, through relations, by the [lookup of paths](#paths-and-scopes). |
320
383
  | `invoices.count` | How many `invoices` the user can see (an exact count from the list API). |
321
384
 
322
- Comparisons, `AND`, `OR`, `NOT`, parentheses, `isNull(field)` and `in(field, "a", "b")` work. <gap>A condition cannot call other functions, such as `now()`, because their evaluation is not implemented.</gap> A field that is missing or that the user cannot read makes the comparison false, and a `Show` that names a resource or field the user cannot see is left out of their page.
385
+ Comparisons, `AND`, `OR`, `NOT`, parentheses, `isNull(field)`, `in(field, "a", "b")`, `now()` and `now() + 7d` or `now() - 1h` work; a time compares with a timestamp field as the list API compares it. Any other function, such as `regex()` or `related()`, works only in a list's `filter`, which the API reads, and a condition that calls one fails as the config loads. A field that is missing or that the user cannot read makes the comparison false, and a `Show` that names a resource or field the user cannot see is left out of their page.
386
+
387
+ In a [typed layout](#typed-layouts), `when` takes [the builder's](#the-condition-builder) condition too: `when={data.status.eq('done')}` or `when={resources.invoices.count.gt(0)}`.
323
388
 
324
389
  Record pages take the same conditions in the `when` of `l.section`, `l.related` and `l.sidebar`; see [Form and read view](ui-config.md#form-and-read-view).
325
390