@protobase/cli 0.96.17 → 0.97.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.
@@ -11,6 +11,7 @@ import { copyPackages } from "./packages/copy-packages.js";
11
11
  import { buildTheme } from "./theme.js";
12
12
  import { shellForBuild, shellManifestFile } from "./shell.js";
13
13
  import { checkUi } from "./ui-check.js";
14
+ import { checkPageScopes } from "./page-scope-check.js";
14
15
  import { checkViews } from "./view-check.js";
15
16
  import { pagesCarryClasses } from "./page-classes.js";
16
17
  import { existsSync } from "node:fs";
@@ -47,7 +48,7 @@ const copyShell = async (publicDir, sourceMaps) => {
47
48
  }
48
49
  return shell;
49
50
  };
50
- const buildDeployBundle = async ({ projectDir, outDir, bun, extensions = [], sourceMaps = false, onWarning }) => {
51
+ const buildDeployBundle = async ({ projectDir, outDir, bun, extensions = [], sourceMaps = false, onWarning, strict = false }) => {
51
52
  const protobase = bundleProtobaseVersion(projectDir);
52
53
  await removeOwnFolder(outDir, bundleNodeModules, "nodeModules");
53
54
  await removeOwnFolder(outDir, bundleMigrations, "migrations");
@@ -60,7 +61,11 @@ const buildDeployBundle = async ({ projectDir, outDir, bun, extensions = [], sou
60
61
  components
61
62
  });
62
63
  const mobileSection = bundleMobile(mobile, notifications);
63
- const pages = await checkViews(projectDir);
64
+ const { pages, models } = await checkViews(projectDir);
65
+ checkPageScopes(pages, models, {
66
+ strict,
67
+ onWarning
68
+ });
64
69
  await checkUi(projectDir, extensions, components);
65
70
  const packages = native.length > 0 ? await copyPackages(native, path.join(outDir, bundleNodeModules)) : [];
66
71
  const publicDir = path.join(outDir, bundleLayout.public);
@@ -0,0 +1,18 @@
1
+ import { pageFindings } from "@protobase/layout";
2
+ //#region src/build/page-scope-check.ts
3
+ /**
4
+ * Hears of each bare name in the pages that a nearer record shadows, which reads the nearest one as Mustache does;
5
+ * with `strict` (`protobase build --strict`) they fail the build instead. The models are the config folder's own, so
6
+ * every other problem of a page is left to the server's check of them all.
7
+ */
8
+ const checkPageScopes = (pages, models, { strict = false, onWarning }) => {
9
+ const byName = Object.fromEntries(models.map((model) => [model.name, model]));
10
+ const warnings = pages.flatMap((page) => pageFindings(page, {
11
+ models: byName,
12
+ actions: () => /* @__PURE__ */ new Set()
13
+ }).warnings.map((warning) => `Page "${page.name}": ${warning}`));
14
+ if (strict && warnings.length > 0) throw new Error(`The pages read shadowed names, which --strict refuses:\n${warnings.map((warning) => ` - ${warning}`).join("\n")}`);
15
+ for (const warning of warnings) onWarning?.(warning);
16
+ };
17
+ //#endregion
18
+ export { checkPageScopes };
@@ -7,14 +7,20 @@ import { checkViewQueries } from "@protobase/server";
7
7
  * Fails the build, instead of a page once it asks, when a view filters, counts, sorts or searches by a field that its
8
8
  * resource does not mark for it. It loads the config folder once in Node, config/index.ts and config/<dir>/ui.ts with
9
9
  * what they import; protobase.config.ts does not run, so the build still needs no secrets and no database. Returns the
10
- * folder's pages, which the build reads too.
10
+ * folder's pages and resources, which the build reads too.
11
11
  */
12
12
  const checkViews = async (projectDir) => {
13
13
  const configDir = path.join(projectDir, "config");
14
- if (!existsSync(path.join(configDir, "index.ts"))) return [];
14
+ if (!existsSync(path.join(configDir, "index.ts"))) return {
15
+ pages: [],
16
+ models: []
17
+ };
15
18
  const { models, views, pages } = await loadDataConfig(configDir, projectDir);
16
19
  checkViewQueries(models, views);
17
- return pages;
20
+ return {
21
+ pages,
22
+ models
23
+ };
18
24
  };
19
25
  //#endregion
20
26
  export { checkViews };
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.96.17";
2
+ var version = "0.97.0";
3
3
  //#endregion
4
4
  export { version };
package/dist/main.js CHANGED
@@ -92,7 +92,7 @@ program.command("dev").description("Serve the admin app and API for the project
92
92
  process.once("SIGINT", () => void server.close().then(() => process.exit(0)));
93
93
  process.once("SIGTERM", () => void server.close().then(() => process.exit(0)));
94
94
  });
95
- program.command("build").description("Build the deploy bundle of the project in the current directory: its config module, the admin app with the project's UI as a plugin, and the manifest").option("--out <dir>", "output folder", "dist").option("--bun", "have Bun's bundler write the config module, for a bundle only Bun serves (needs bun on PATH)", false).option("--extend <dir>", "merge the protobase.config.ts and protobase.ui.tsx in this folder before the project's, repeatable", collect, []).option("--source-maps", "end each script with a //# debugId= comment and write its source map, carrying the same id, beside it", false).action(async (opts) => {
95
+ program.command("build").description("Build the deploy bundle of the project in the current directory: its config module, the admin app with the project's UI as a plugin, and the manifest").option("--out <dir>", "output folder", "dist").option("--bun", "have Bun's bundler write the config module, for a bundle only Bun serves (needs bun on PATH)", false).option("--extend <dir>", "merge the protobase.config.ts and protobase.ui.tsx in this folder before the project's, repeatable", collect, []).option("--source-maps", "end each script with a //# debugId= comment and write its source map, carrying the same id, beside it", false).option("--strict", "fail on what it otherwise warns of in the pages, such as a name a nearer record shadows", false).action(async (opts) => {
96
96
  const [{ buildDeployBundle }, { manifestFile }, { resolveExtensions }, { writeProjectTypes }] = await Promise.all([
97
97
  import("./build/deploy-bundle.js"),
98
98
  import("./bundle/manifest.js"),
@@ -108,7 +108,8 @@ program.command("build").description("Build the deploy bundle of the project in
108
108
  bun: opts.bun,
109
109
  extensions,
110
110
  sourceMaps: opts.sourceMaps,
111
- onWarning
111
+ onWarning,
112
+ strict: opts.strict
112
113
  });
113
114
  const packages = manifest.nodeModules ? `, ${manifest.nodeModules}/` : "";
114
115
  const plugins = manifest.plugins.length > 0 ? ` with plugins ${manifest.plugins.map((plugin) => plugin.name).join(", ")}` : "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.96.17",
3
+ "version": "0.97.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.96.17",
47
- "@protobase/layout": "0.96.17",
48
- "@protobase/query": "0.96.17",
49
- "@protobase/schema": "0.96.17",
50
- "@protobase/server": "0.96.17",
51
- "@protobase/ui": "0.96.17",
52
- "@protobase/workflows": "0.96.17",
46
+ "@protobase/config": "0.97.0",
47
+ "@protobase/layout": "0.97.0",
48
+ "@protobase/query": "0.97.0",
49
+ "@protobase/schema": "0.97.0",
50
+ "@protobase/server": "0.97.0",
51
+ "@protobase/ui": "0.97.0",
52
+ "@protobase/workflows": "0.97.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",
@@ -7,6 +7,7 @@ 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
  - [Conditions](../reference/layouts.md#conditions): Part of a page shows only while a condition on a record or a count holds.
10
+ - [Paths and scopes](../reference/layouts.md#paths-and-scopes) (beta): Layout values resolve through the records around them with Handlebars paths, such as `../name`, `@root` and `@index`; typos and reads that would wait on other reads fail the build, and `Show`, `Switch` and `Match` choose what is drawn.
10
11
  - [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
12
  - [Component fallbacks](../reference/custom-components.md#fallbacks): A custom component declares what a client that cannot draw it shows instead, or nothing, and the web shows it too when the component is missing or throws.
12
13
  - [Text form](../reference/layouts.md#text-form): Every layout block renders to Markdown text through one shared function, built up from its children, as the last-resort fallback and for MCP clients and LLMs.
@@ -53,7 +53,7 @@ export const subscriptionsView = view<typeof subscriptions>('subscriptions')
53
53
  .fields((r) => ({ renews_at: r.renews_at.label('Renews on'), status: r.status.valueLabels({ active: 'Active', canceled: 'Canceled' }).valueColors({ active: 'green' }) }))
54
54
  .actions((a) => [
55
55
  a.update('cancel', { label: 'Cancel plan', set: { status: 'canceled' }, confirm: 'Your plan stays active until the end of the period.' }),
56
- a.link('upgrade', { label: 'Upgrade', href: 'mailto:sales@example.com?subject=Upgrade%20from%20plan%20{plan}' }),
56
+ a.link('upgrade', { label: 'Upgrade', href: 'mailto:sales@example.com?subject=Upgrade%20from%20plan%20{{plan}}' }),
57
57
  ])
58
58
 
59
59
  export const billingProfilesView = view<typeof billingProfiles>('billing_profiles').nav({ hidden: true }).fields((r) => ({ vat_number: r.vat_number.label('VAT number') }))
@@ -73,7 +73,7 @@ export const invoicesView = view<typeof invoices>('invoices').icon('file-text')
73
73
  .actions((a) => [a.action('download', { label: 'Download PDF' })])
74
74
  ```
75
75
 
76
- `a.update('cancel', ...)` sets `status` after its `confirm` question. `a.link` opens its `href`, with `{plan}` filled in from the record: an `href` leaves the app (`https:`, `mailto:`), while a place in the app is a `to`, such as `{ kind: 'record', resource: 'plans', key: '{plan}' }`; a path in the app as an `href` is refused. Cancel the plan in the story and the card says there is no active plan, because its `filter` no longer matches.
76
+ `a.update('cancel', ...)` sets `status` after its `confirm` question. `a.link` opens its `href`, with `{{plan}}` filled in from the record: an `href` leaves the app (`https:`, `mailto:`), while a place in the app is a `to`, such as `{ kind: 'record', resource: 'plans', key: '{{plan}}' }`; a path in the app as an `href` is refused. Cancel the plan in the story and the card says there is no active plan, because its `filter` no longer matches.
77
77
 
78
78
  ## 2. Who we bill
79
79
 
@@ -90,7 +90,7 @@ export const repairsView = view<typeof repairs>('repairs')
90
90
  .create({ page: 'book-repair' })
91
91
  ```
92
92
 
93
- **New** on the repairs list now opens the page at `/repairs/new`, and so does every link to a new repair, such as one on a customer's page with `values: { customer_id: '{id}' }`. Someone the page leaves out gets no **New**, and `/repairs/new` tells them they cannot create repairs; the plain create form no longer shows. The server refuses a page name it does not know when it starts.
93
+ **New** on the repairs list now opens the page at `/repairs/new`, and so does every link to a new repair, such as one on a customer's page with `values: { customer_id: '{{id}}' }`. Someone the page leaves out gets no **New**, and `/repairs/new` tells them they cannot create repairs; the plain create form no longer shows. The server refuses a page name it does not know when it starts.
94
94
 
95
95
  ## 4. Create through a function
96
96
 
@@ -181,7 +181,7 @@ export { customersView }
181
181
  export const repairsView = laidOut.actions((a) => [
182
182
  a.update('ready', { label: 'Ready for pickup', icon: 'send', set: { status: 'ready' } }),
183
183
  a.update('collect', { label: 'Collected and paid', icon: 'wallet', set: { status: 'collected', paid: true }, confirm: 'Has the customer paid and taken the bike?' }),
184
- a.link('customerRepairs', { label: 'Other repairs of this customer', icon: 'file-text', to: { kind: 'list', resource: 'repairs', filter: 'customer_id = {customer_id}' } }),
184
+ a.link('customerRepairs', { label: 'Other repairs of this customer', icon: 'file-text', to: { kind: 'list', resource: 'repairs', filter: 'customer_id = {{customer_id}}' } }),
185
185
  ])
186
186
 
187
187
  /** What mechanics get instead: no money, and their own move. */
@@ -25,7 +25,7 @@ export const tickets = resource('tickets')
25
25
  description: f.text().optional(),
26
26
  priority: f.enum(['low', 'normal', 'urgent']).optional(),
27
27
  // empty until the job fills it, after a create and after a change of the title or description
28
- summary: f.text().optional().ai({ prompt: 'Summarise this support ticket in one sentence.\n\nTitle: {title}\n\n{description}' }),
28
+ summary: f.text().optional().ai({ prompt: 'Summarise this support ticket in one sentence.\n\nTitle: {{title}}\n\n{{description}}' }),
29
29
  })
30
30
  .primaryKey((r) => r.id)
31
31
 
@@ -34,14 +34,14 @@ export const ticketsView = view<typeof tickets>('tickets')
34
34
  .title((r) => r.title)
35
35
  .layout((r) => [l.section('Ticket', [r.title, r.description, r.priority, r.summary])])
36
36
  .actions((a) => [
37
- a.ai('translate', { label: 'Translate to English', icon: 'file-text', prompt: 'Translate into English:\n\n{description}', writes: 'description' }),
38
- a.ai('triage', { label: 'Suggest priority', icon: 'tag', prompt: 'How urgent is this support ticket?\n\n{title}\n{description}', writes: 'priority', confirm: 'Replace the priority?' }),
37
+ a.ai('translate', { label: 'Translate to English', icon: 'file-text', prompt: 'Translate into English:\n\n{{description}}', writes: 'description' }),
38
+ a.ai('triage', { label: 'Suggest priority', icon: 'tag', prompt: 'How urgent is this support ticket?\n\n{{title}}\n{{description}}', writes: 'priority', confirm: 'Replace the priority?' }),
39
39
  ])
40
40
  ```
41
41
 
42
42
  ## Prompts
43
43
 
44
- A prompt names fields of the record as `{field}`, at least one. The model gets a fixed instruction to answer with the value only, and the prompt with each `{field}` replaced by the record's value as text: text as it is, numbers and booleans written out, json as JSON, an empty value as nothing. For an enum field, the prompt ends with the values the answer must be one of. Nothing else of the record or the app is sent. The answer is trimmed, and validated as any write is, so an enum value the field does not have, or text over its `.max()`, is refused.
44
+ A prompt names fields of the record as `{{field}}`, at least one. The model gets a fixed instruction to answer with the value only, and the prompt with each `{{field}}` replaced by the record's value as text: text as it is, numbers and booleans written out, json as JSON, an empty value as nothing. For an enum field, the prompt ends with the values the answer must be one of. Nothing else of the record or the app is sent. The answer is trimmed, and validated as any write is, so an enum value the field does not have, or text over its `.max()`, is refused.
45
45
 
46
46
  When every field the prompt reads is empty, the model is not asked: an AI field is cleared to `null` and an AI action answers `422`. A summary of nothing is never invented.
47
47
 
@@ -150,7 +150,7 @@ A link in text: `to` an address in the app, or an `href` that leaves it (`https:
150
150
 
151
151
  | Prop | |
152
152
  | --- | --- |
153
- | `to` | An [address](layouts.md#addresses). Inside a record, `{field}` in its key, filter or order is the record's value. |
153
+ | `to` | An [address](layouts.md#addresses). `{{path}}` in it is the value of that [path](layouts.md#paths-and-scopes) through the records around the link. |
154
154
  | `href` | A link that leaves the app. A path in the app is refused when the config loads: give it as `to`. |
155
155
  | `variant` | `primary`, `secondary`, `danger` or `ghost`: drawn as a button of that variant, still a link. `className` adds to it, such as `w-full`. |
156
156
 
@@ -254,7 +254,7 @@ On a phone this table shows Title and Verdict; on a wider screen Rank, Title, Po
254
254
  Row buttons may change in any release. They do not show when a table switches to a list display such as cards.
255
255
  :::
256
256
 
257
- `button: { label, to }` adds a last column with a button on each row: a link, drawn as a button, to `to`, an [address](layouts.md#addresses) in the app, such as a record on one of its [tabs](ui-config.md#tabs). `{field}` in the address or the label is replaced by the row's value, the label's as the record page shows it (an enum value by its label), so each row can name its own next step. The column is as wide as the longest label among the first rows shown, up to 18rem, past which a label shortens and shows whole on hover. Below the `md` breakpoint (768px), where a table keeps its columns whole and scrolls sideways, the button sits under the text of the row's first cell instead, so it is on screen without scrolling. A row with no value for a field the button names shows no button. The button is checked when the config loads, and `/meta` gives it, on the block or the related section, to callers who can read the fields it names and follow its address, and leaves it out for the others. A [related section](ui-config.md#related-records) takes the same `button`, on its table's rows or its cards.
257
+ `button: { label, to }` adds a last column with a button on each row: a link, drawn as a button, to `to`, an [address](layouts.md#addresses) in the app, such as a record on one of its [tabs](ui-config.md#tabs). `{{field}}` in the address or the label is replaced by the row's value, the label's as the record page shows it (an enum value by its label), so each row can name its own next step. The column is as wide as the longest label among the first rows shown, up to 18rem, past which a label shortens and shows whole on hover. Below the `md` breakpoint (768px), where a table keeps its columns whole and scrolls sideways, the button sits under the text of the row's first cell instead, so it is on screen without scrolling. A row with no value for a field the button names shows no button. The button is checked when the config loads, and `/meta` gives it, on the block or the related section, to callers who can read the fields it names and follow its address, and leaves it out for the others. A [related section](ui-config.md#related-records) takes the same `button`, on its table's rows or its cards.
258
258
 
259
259
  ```tsx
260
260
  <Table
@@ -262,15 +262,15 @@ Row buttons may change in any release. They do not show when a table switches to
262
262
  resource="holds"
263
263
  filter="state = 'open'"
264
264
  columns={['reason', 'task_id']}
265
- button={{ label: '{verb}', to: { kind: 'record', resource: 'tasks', key: '{task_id}', tab: 'Review' } }}
265
+ button={{ label: '{{verb}}', to: { kind: 'record', resource: 'tasks', key: '{{task_id}}', tab: 'Review' } }}
266
266
  />
267
267
  ```
268
268
 
269
269
  Each row can decide where its button goes:
270
270
 
271
- - **A record's tab from a field**: `tab: '{tab}'` opens the tab the row's `tab` field names; a name the record page has no tab for opens its first tab.
272
- - **A filtered list**: `{ kind: 'list', resource: 'holds', filter: 'task_id = {task_id} AND state = "{state}"' }` opens the list with a filter built from the row. A text value goes in quotes, on its own, escaped so a title with quotes in it stays one value; a `{field}` inside a longer quoted value, such as `'re {verb}'`, is refused when the config loads; a value outside quotes must be a number or `true`/`false`, and a row with any other value there shows no button. The filter's fields must be filterable, as in any address.
273
- - **An outside page**: `{ label: 'Error report', href: '{report_url}' }` opens the page the row's `report_url` field holds, in a new tab without the referrer, and the button carries the outside-link mark, which screen readers hear as "opens in a new tab". The `href` is one field, never a URL put together from parts, and a row whose field holds no `https:` URL shows no button.
271
+ - **A record's tab from a field**: `tab: '{{tab}}'` opens the tab the row's `tab` field names; a name the record page has no tab for opens its first tab.
272
+ - **A filtered list**: `{ kind: 'list', resource: 'holds', filter: 'task_id = {{task_id}} AND state = "{{state}}"' }` opens the list with a filter built from the row. A text value goes in quotes, on its own, escaped so a title with quotes in it stays one value; a `{{field}}` inside a longer quoted value, such as `'re {{verb}}'`, is refused when the config loads; a value outside quotes must be a number or `true`/`false`, and a row with any other value there shows no button. The filter's fields must be filterable, as in any address.
273
+ - **An outside page**: `{ label: 'Error report', href: '{{report_url}}' }` opens the page the row's `report_url` field holds, in a new tab without the referrer, and the button carries the outside-link mark, which screen readers hear as "opens in a new tab". The `href` is one field, never a URL put together from parts, and a row whose field holds no `https:` URL shows no button.
274
274
  - **A different kind per row**: `button` takes a list of these, and each row shows the first whose fields it holds, so one list can hold items that each need a different act. A row whose first such choice leads nowhere, such as an `href` field without an `https:` URL, shows no button rather than the next choice. A caller who cannot read a choice's fields or follow its address gets the list without it.
275
275
 
276
276
  ```tsx
@@ -279,9 +279,9 @@ Each row can decide where its button goes:
279
279
  resource="alerts"
280
280
  columns={['summary']}
281
281
  button={[
282
- { label: 'Open the error report', href: '{report_url}' },
283
- { label: '{verb}', to: { kind: 'record', resource: 'tasks', key: '{task_id}', tab: '{tab}' } },
284
- { label: 'See its failed jobs', to: { kind: 'list', resource: 'failed_jobs', filter: 'alert_id = {id}' } },
282
+ { label: 'Open the error report', href: '{{report_url}}' },
283
+ { label: '{{verb}}', to: { kind: 'record', resource: 'tasks', key: '{{task_id}}', tab: '{{tab}}' } },
284
+ { label: 'See its failed jobs', to: { kind: 'list', resource: 'failed_jobs', filter: 'alert_id = {{id}}' } },
285
285
  ]}
286
286
  />
287
287
  ```
@@ -304,7 +304,7 @@ Records that wait on the same act, such as several steps one approval unlocks, a
304
304
  when: "state = 'waiting'",
305
305
  confirm: 'Tick each detail you confirm.',
306
306
  inputs: (i) => [i.checklist('checked', { label: 'What you checked', from: 'checklist' })],
307
- set: { checked: '{checked}', state: 'approved' },
307
+ set: { checked: '{{checked}}', state: 'approved' },
308
308
  }),
309
309
  ])
310
310
  ```
@@ -313,7 +313,7 @@ Records that wait on the same act, such as several steps one approval unlocks, a
313
313
  <Table title="Waiting on you" resource="approvals" filter="state = 'waiting'" bulk />
314
314
  ```
315
315
 
316
- With `from`, each record brings its own boxes from that JSON field, a list of texts, and the dialog shows each box once, however many of the records hold it. Each record then gets the boxes it holds as its answer, so `'{checked}'` writes what was signed off for that record; a record that holds no boxes needs none ticked. With `items`, every record shows and gets the same boxes. The record page's button for the action opens the same dialog with that record's boxes.
316
+ With `from`, each record brings its own boxes from that JSON field, a list of texts, and the dialog shows each box once, however many of the records hold it. Each record then gets the boxes it holds as its answer, so `'{{checked}}'` writes what was signed off for that record; a record that holds no boxes needs none ticked. With `items`, every record shows and gets the same boxes. The record page's button for the action opens the same dialog with that record's boxes.
317
317
 
318
318
  Access is checked per record: a record the person may not change, by its permissions or by the API's answer, is refused while the others are signed off, and the toast names it, such as **Approve: done on 2, refused on 1** with "Not done on “Rotate the signing key”: you may not change it.". `protobase build` refuses a `from` that is no JSON field of the resource, and `/api/meta` leaves the action out for someone who cannot read that field.
319
319
 
@@ -591,18 +591,35 @@ A button that opens a form in a dialog. `create` makes a record of `resource`; `
591
591
 
592
592
  ### Show
593
593
 
594
- Its children while [`when`](layouts.md#conditions) holds.
594
+ 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.
595
595
 
596
596
  | Prop | |
597
597
  | --- | --- |
598
598
  | `when` | A condition. Required. |
599
+ | `fallback` | Text or elements drawn while `when` does not hold. |
599
600
 
600
601
  ```tsx
601
- <Show when="orders.count = 0">
602
+ <Show when="orders.count = 0" fallback={<Text>Orders are coming in.</Text>}>
602
603
  <Card title="No orders yet">...</Card>
603
604
  </Show>
604
605
  ```
605
606
 
607
+ ### Switch and Match
608
+
609
+ The first `Match` whose `when` holds, else the `Switch`'s `fallback`, as SolidJS's [`<Switch>` and `<Match>`](https://docs.solidjs.com/reference/components/switch-and-match). A `Switch` holds `Match`es only. Its text form is the branch it draws.
610
+
611
+ | Prop | |
612
+ | --- | --- |
613
+ | `Switch fallback` | Text or elements drawn while no `Match` holds. |
614
+ | `Match when` | A [condition](layouts.md#conditions). Required. |
615
+
616
+ ```tsx
617
+ <Switch fallback={<Text>Not started</Text>}>
618
+ <Match when="status = 'done'"><Text>Done</Text></Match>
619
+ <Match when="claims.count > 0"><Text>Claimed</Text></Match>
620
+ </Switch>
621
+ ```
622
+
606
623
  ## Accounts
607
624
 
608
625
  ### Users
@@ -197,7 +197,7 @@ Sign-in with a passkey or an outside provider, such as Google, belongs to the in
197
197
  ## `build`
198
198
 
199
199
  ```sh
200
- protobase build [--out dist] [--bun] [--extend <dir>] [--source-maps] # run inside a project, e.g. bun run --cwd tests/apps/erp protobase build
200
+ protobase build [--out dist] [--bun] [--extend <dir>] [--source-maps] [--strict] # run inside a project, e.g. bun run --cwd tests/apps/erp protobase build
201
201
  ```
202
202
 
203
203
  Writes the project's deploy bundle, the folder a deployment ships:
@@ -226,6 +226,8 @@ By default the bundle runs on Node and on Bun. `--bun` makes it a bundle for Bun
226
226
 
227
227
  ### Source maps
228
228
 
229
+ `--strict` fails the build on what it otherwise warns of in the config folder's layouts: a bare name that more than one record around it has, which reads the nearest (see [Paths and scopes](layouts.md#paths-and-scopes)).
230
+
229
231
  `--source-maps` writes a source map beside each script of the shell and the plugins, `assets/<name>-<hash>.js.map`, for an error tracker to read the browser's stack frames with. Each script ends with a `//# debugId=<uuid>` comment, and its map carries the same `debugId`; the scripts name no map, but a host serves the maps with the rest of `public/` unless it moves them out. The shell's maps come prebuilt in `@protobase/ui`'s `dist/shell-source-maps/`. Without the option the bundle has no maps. [`build-plugin --source-maps`](#build-plugin) does the same for a plugin built on its own.
230
232
 
231
233
  ### Extensions
@@ -115,7 +115,7 @@ Every option returns a new [field](https://docs.protobase.net/api/schema/interfa
115
115
  | `.sensitive()` | Hidden like a password: no response carries it, and a caller who may read it reveals one record's value at a time. See [Sensitive fields](#sensitive-fields). |
116
116
  | `.encrypted()` | Sensitive, and stored encrypted with the app's own key, so the database only ever holds ciphertext. Text only. See [Encrypted fields](#encrypted-fields). |
117
117
  | `.strongSignIn({ minutes })` | Sensitive, and revealed only after a passkey or a second step in the last `minutes` (15 by default). See [Recent strong sign-in](#recent-strong-sign-in). |
118
- | `.ai({ prompt })` | A job fills the field from `prompt`, `{field}` replaced by the record's values, after a create and after an update of a field the prompt reads, as the user who wrote. Text or enum, optional. See [AI fields and actions](ai.md). |
118
+ | `.ai({ prompt })` | A job fills the field from `prompt`, `{{field}}` replaced by the record's values, after a create and after an update of a field the prompt reads, as the user who wrote. Text or enum, optional. See [AI fields and actions](ai.md). |
119
119
  | `.rollup({ from, via, fn, field })` | The database keeps the field from the records of another resource: their count, sum, average, least or greatest value. Read-only. See [Rollups and formulas](#rollups-and-formulas). |
120
120
  | `.formula(expression)` | The database computes the field from the record's other number fields, as a generated column. Read-only. See [Rollups and formulas](#rollups-and-formulas). |
121
121
 
@@ -222,13 +222,13 @@ Scripts in uploaded HTML files do not run.
222
222
 
223
223
  HTML files open in a sandboxed frame that cannot reach your app. Relative images, videos and links resolve to the record's other files. Your own viewer can draw the HTML it generates in the same frame and use the same link resolution.
224
224
 
225
- Protobase brings this viewer itself, for `text/html`, the type an upload named `.html` or `.htm` is stored as; an app or plugin that registers its own `text/html` viewer replaces it. The page shows below the file's bar, as tall as its content, so the app's page scrolls:
225
+ Protobase brings this viewer itself, for `text/html`, the type an upload named `.html` or `.htm` is stored as; an app or plugin that registers its own `text/html` viewer replaces it. The page shows below the file's bar, as tall as its content, so the app's page scrolls. A page sized by its frame, such as one `100vh` tall, would grow each time the frame did: the frame stays 60% of the screen tall for it, and the page scrolls inside. An empty page, measured 0 tall, keeps that height too:
226
226
 
227
227
  - The frame has an opaque origin: the page cannot read the app's cookies or storage, call its API as the signed-in user, or navigate the app's window. It loads nothing from the network, so an image or stylesheet from another site stays blank, and it submits no forms.
228
228
  - A relative `src`, `poster`, `srcset` candidate, `<link href>` or CSS `url()` in a `style` attribute or `<style>` element that names a sibling by its file name, such as `shots/before.png` or `./clip.webm`, shows that sibling. The admin app reads each such sibling once, with the signed-in user's rights, and hands it to the page as its bytes. A name with escapes, such as `my%20chart.png`, matches `my chart.png`. A reference to no sibling, a path from the root or one that climbs out with `..` stays as written, so it shows nothing, and such a link becomes plain text.
229
229
  - A link to a sibling opens it on its record's address with `?file=<field>`, the address the link shows: in its viewer, such as another HTML page, or beside its Download button when it has none. A middle or modified click opens it in a new tab. A link to an `http` or `https` address opens it in a new tab that cannot reach back to the app. A link to a place on the page, such as `#results`, scrolls the app's page to it and moves the focus there. Any other link, such as `javascript:`, does nothing.
230
230
 
231
- <gap>An HTML file's siblings over 10 MB, such as a long video, cannot show in its page because reading larger files in the app is not implemented.</gap> <gap>A `url()` inside a linked stylesheet cannot name a sibling because rewriting stylesheet files is not implemented.</gap>
231
+ <gap>An HTML file's siblings over 10 MB, such as a long video, cannot show in its page because reading larger files in the app is not implemented.</gap> <gap>A `url()` inside a linked stylesheet cannot name a sibling because rewriting stylesheet files is not implemented.</gap> <gap>A link to a place on a page that scrolls inside its frame cannot scroll the frame to it because moving the frame's own scroll from the link script is not implemented.</gap>
232
232
 
233
233
  Your own viewer draws a page in the same frame with `HtmlFrame`, and resolves its references with `useSiblingPage`, such as for a page it builds from a template and a JSON file:
234
234
 
@@ -71,7 +71,7 @@ renderText(<Page title="Order"><Field name="status" /></Page>, {
71
71
 
72
72
  | Option | |
73
73
  | --- | --- |
74
- | `record` | The record around the tree. `Field`, `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. Without it, a field reads as its label alone, a `Show` reads as all it holds, and addresses keep their `{field}`s. |
74
+ | `record` | The record around the tree. `Field`, `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
76
  | `tables` | Per `Table` element, the records it shows and its columns (`{ columns: [{ name, label, title?, badge?, valueLabels? }], rows }`), which you loaded; the table then reads as its heading and a Markdown table. Without it, a table reads as its heading. |
77
77
  | `basePath` | What links start with, such as `https://example.com/admin`. |
@@ -109,13 +109,45 @@ Behaviour comes from [named actions](#named-actions); React code from [custom co
109
109
 
110
110
  A `RecordCard` (its first match) and each card of a `CardRow` hold a **record**. Inside one, `Field`, `Progress`, `Stat field`, `Show`, `Action` and `ModalForm mode="edit"` work on that record, and a `RecordCard`'s header `actions` do too. A field name may follow relations: `company_id.city` is the city of the record's company, fetched like the record page fetches it and cached.
111
111
 
112
+ ## Paths and scopes
113
+
114
+ A `RecordCard` and each card of a `CardRow` put their record on a stack of records, as each section does in [Mustache](https://mustache.github.io/mustache.5.html): an element inside both a task's `RecordCard` and a `CardRow` of its claims sits in a claim, inside the task. A name in a layout is looked up through that stack, by the rules of the [Mustache spec](https://github.com/mustache/spec) and [Handlebars path expressions](https://handlebarsjs.com/guide/expressions.html#path-expressions):
115
+
116
+ | Path | Reads |
117
+ | --- | --- |
118
+ | `status` | The nearest record that has a field `status`, then each record around it in turn. |
119
+ | `meta.size` | `meta` as above, then `size` from that value only: when it has none, the path is empty, and no record further out is tried (Mustache's "Dotted Names - Context Precedence"). |
120
+ | `../id`, `../../id` | The record one, or two, out from the nearest. |
121
+ | `this.id`, `./id` | The nearest record only. |
122
+ | `@index`, `@first`, `@last` | The card's place among a `CardRow`'s cards, from 0, and whether it is the first or the last. |
123
+ | `@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> |
124
+ | `@params.window` | The page parameter `window`. <gap>A path cannot read `@params` because the input that sets a page parameter is not implemented.</gap> |
125
+
126
+ `Field name`, `Stat field`, `Progress`, and the names in a [condition](#conditions) take a path. A string prop takes `{{path}}` placeholders, double braces as in Handlebars, filled with the path's value where the element draws, and empty when it has none:
127
+
128
+ - `title`, `description`, `empty` and `label` read any path: `<Table resource="claim_steps" title="Steps of {{title}}" />`.
129
+ - `filter`, `recordKey` and `values` read a field of a record around them. A filter takes one only as a top-level `AND` equality, `claim_id = {{id}} AND done = false`, the shape a read can take for every row at once with a [`related()`](api.md#filtering-through-related-records) filter. A filter takes a page parameter anywhere.
130
+ - `when` takes them where a name cannot go, such as `this.status = '{{../status}}'`, since a name in AIP-160 cannot start with `../` or `@`.
131
+ - A [link's address](#addresses) takes them in its resource, key, tab, filter, order and values.
132
+
133
+ A placeholder quoted on its own in a filter or condition, `title = '{{title}}'`, is filled with its quotes and backslashes escaped, so any text stays one value; Handlebars escapes for HTML instead. One inside a longer quoted value, `title = 'about {{title}}'`, fails the build, as it would be filled unescaped. Paths are all a placeholder holds: no helpers, subexpressions, literals, `@key` or `{{{triple braces}}}`. A `{{…}}` that holds anything else fails as soon as the layout loads, before its names are checked.
134
+
135
+ The build checks every path where it sits:
136
+
137
+ - **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?`. Mustache would draw it empty, so a layout the build accepts draws the same under Mustache's rules.
138
+ - **Bad roots.** `../` past the outermost record, `@root` on a page without a record, `@index` outside a `CardRow`, and `@params.x` without an input setting `x` fail.
139
+ - **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.
140
+ - **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.
141
+
142
+ <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>
143
+
112
144
  ## Conditions
113
145
 
114
- `<Show when="...">` keeps its children while the condition holds. It is AIP-160 over named values:
146
+ `<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:
115
147
 
116
148
  | Name | Value |
117
149
  | --- | --- |
118
- | `status`, `plan.name` | A field of the record around it, through relations. |
150
+ | `status`, `plan.name` | A field of the records around it, through relations, by the [lookup of paths](#paths-and-scopes). |
119
151
  | `invoices.count` | How many `invoices` the user can see (an exact count from the list API). |
120
152
 
121
153
  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.
@@ -128,34 +160,34 @@ Record pages take the same conditions in the `when` of `l.section`, `l.related`
128
160
 
129
161
  | Builder | Does |
130
162
  | --- | --- |
131
- | `a.update(name, { label, set, confirm?, icon?, bulk?, inputs? })` | Updates the record with `set`, with its ETag; not offered on a record that holds those values already, unless it asks for `inputs`, whose answers it writes where `set` says `'{name}'`. |
163
+ | `a.update(name, { label, set, confirm?, icon?, bulk?, inputs? })` | Updates the record with `set`, with its ETag; not offered on a record that holds those values already, unless it asks for `inputs`, whose answers it writes where `set` says `'{{name}}'`. |
132
164
  | `a.remove(name, { label, confirm?, icon? })` | Deletes the record (soft delete when the resource has one). |
133
- | `a.link(name, { label, to, icon? })` | Goes `to` an [address](#addresses) in the app, with `{field}` in its key, tab, filter, order or create values replaced by the record's value (one in quotes in a filter, `title = "{title}"`, with its quotes escaped, so any text stays one value), and its resource too when that is only `{field}`: see [links to a resource the record names](#links-to-a-resource-the-record-names). |
134
- | `a.link(name, { label, href, icon? })` | Opens an `href` that leaves the app (`https:`, `mailto:`), with `{field}` replaced by the record's value (percent-encoded); an `https:` or `http:` link opens in a new tab without the referrer. An `href` that is only a field, `'{website}'`, opens the URL the record holds, as it is: see [links to a record's URL](#links-to-a-records-url). A path in the app is refused when the config loads: give it as `to`. |
135
- | `a.ai(name, { label, prompt, writes, confirm?, icon? })` | Has the model write the field `writes` of the record from `prompt`, `{field}` replaced by the record's values, as the user, on the server; see [AI fields and actions](ai.md#ai-actions). |
165
+ | `a.link(name, { label, to, icon? })` | Goes `to` an [address](#addresses) in the app, with `{{field}}` in its key, tab, filter, order or create values replaced by the record's value (one in quotes in a filter, `title = "{{title}}"`, with its quotes escaped, so any text stays one value), and its resource too when that is only `{{field}}`: see [links to a resource the record names](#links-to-a-resource-the-record-names). |
166
+ | `a.link(name, { label, href, icon? })` | Opens an `href` that leaves the app (`https:`, `mailto:`), with `{{field}}` replaced by the record's value (percent-encoded); an `https:` or `http:` link opens in a new tab without the referrer. An `href` that is only a field, `'{{website}}'`, opens the URL the record holds, as it is: see [links to a record's URL](#links-to-a-records-url). A path in the app is refused when the config loads: give it as `to`. |
167
+ | `a.ai(name, { label, prompt, writes, confirm?, icon? })` | Has the model write the field `writes` of the record from `prompt`, `{{field}}` replaced by the record's values, as the user, on the server; see [AI fields and actions](ai.md#ai-actions). |
136
168
  | `a.action(name, { label, confirm?, icon?, bulk?, inputs? })` | Runs the handler the app registers under `name` in [`protobase.ui.tsx`](custom-components.md#action-handlers), after asking for its [`inputs`](ui-config.md#actions-that-ask-for-input) in a dialog when it has some. |
137
169
 
138
170
  `icon` is one of `archive`, `arrow-right-left`, `ban`, `bath`, `bed`, `bell`, `bookmark`, `calendar`, `camera`, `copy`, `cpu`, `door-open`, `download`, `external-link`, `file-text`, `hard-drive`, `heart`, `history`, `house`, `key`, `land-plot`, `leaf`, `memory`, `network`, `play`, `plug`, `plus`, `power`, `restart`, `ruler`, `send`, `server`, `stop`, `table`, `tag`, `terminal`, `upload`, `wallet` or `wrench`; another name shows a lightning bolt. With `confirm` the button asks first. Every builder also takes `when`, `otherwise` and `reason`, which limit the action to the records it [applies to](ui-config.md#where-an-action-applies), and `variant: 'danger'`, which draws it in red. The button is disabled, with the reason as its tooltip, when the user may not update or delete the record (or, for an AI action, the field it writes), when an `a.action` has no handler, or when an update, delete or AI action has no record. After an action, everything shown of that resource reloads. The record page's action rail runs the same actions the same way; there an `a.link` is a real link that looks like the rail's buttons, which the browser can preview, copy or open in a new tab, while a disabled one is a disabled button with its reason. <gap>An `<Action>` block for an `a.link` cannot be opened in a new tab or copied as a link because drawing link actions as links is not implemented for the block.</gap>
139
171
 
140
172
  ### Links to a record's URL
141
173
 
142
- A link whose `href` is a single `{field}` opens the address that field holds, such as the page a listing came from:
174
+ A link whose `href` is a single `{{field}}` opens the address that field holds, such as the page a listing came from:
143
175
 
144
176
  ```ts
145
- a.link('source', { label: 'View on {host}', icon: 'external-link', href: '{source_url}' })
177
+ a.link('source', { label: 'View on {{host}}', icon: 'external-link', href: '{{source_url}}' })
146
178
  ```
147
179
 
148
- The value is used as it is, not percent-encoded, and must be an absolute `https:` or `http:` URL: on a record whose field is empty or holds anything else the button does not show. It opens in a new tab that gets neither the app's window nor its address. `{host}` in the label becomes the URL's host without `www.`, so the button above reads "View on example.com". The field must be one of the resource's, and the button shows to whoever the view grants the field, a visitor who is not signed in included; for anyone it hides the field from, the action is left out.
180
+ The value is used as it is, not percent-encoded, and must be an absolute `https:` or `http:` URL: on a record whose field is empty or holds anything else the button does not show. It opens in a new tab that gets neither the app's window nor its address. `{{host}}` in the label becomes the URL's host without `www.`, so the button above reads "View on example.com". The field must be one of the resource's, and the button shows to whoever the view grants the field, a visitor who is not signed in included; for anyone it hides the field from, the action is left out.
149
181
 
150
182
  ### Links to a resource the record names
151
183
 
152
- A link whose address has only a `{field}` as its `resource` goes to the resource that field names, such as a record that describes a table and links to that table's list:
184
+ A link whose address has only a `{{field}}` as its `resource` goes to the resource that field names, such as a record that describes a table and links to that table's list:
153
185
 
154
186
  ```ts
155
- a.link('open_table', { label: 'Open table', to: { kind: 'list', resource: '{name}' } })
187
+ a.link('open_table', { label: 'Open table', to: { kind: 'list', resource: '{{name}}' } })
156
188
  ```
157
189
 
158
- The button shows only while the app gives the user a resource of that name: on a record whose field is empty, or names a resource the user cannot see or the app does not serve yet, it is left out, and it shows once `/meta` names it. As the resource is known only when the link is followed, such an address takes no filter, order or create values, which the server refuses when it starts; a record's `key` may still be a `{field}`.
190
+ The button shows only while the app gives the user a resource of that name: on a record whose field is empty, or names a resource the user cannot see or the app does not serve yet, it is left out, and it shows once `/meta` names it. As the resource is known only when the link is followed, such an address takes no filter, order or create values, which the server refuses when it starts; a record's `key` may still be a `{{field}}`.
159
191
 
160
192
  ## Tailwind classes
161
193
 
@@ -194,7 +226,7 @@ Every place in the app has an address, and the app writes and reads them in one
194
226
  | --- | --- |
195
227
  | `{ 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. |
196
228
  | `{ 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>`). |
197
- | `{ 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. |
229
+ | `{ 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. |
198
230
  | `{ 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. |
199
231
 
200
232
  The resources, pages and fields an address names are checked when the server starts, like every other name.
@@ -143,18 +143,18 @@ Cards, boards and the mobile rows do not open a url link's address yet. JSON sum
143
143
 
144
144
  Tables show JSON fields readably, and links can carry their own text. A JSON field, such as a tool call's input, shows in a list's table, a related table, a page's `Table` block and on cards and the mobile rows as a short summary on one line: an object as its keys and values, plain values before nested ones, `command: ls -la, cwd: /tmp, env: {…}`, a list of plain values as those values, and a list of objects as how many it holds, `3 items`. An object or list inside another shows as `{…}` or `[…]`, an empty text as `""`, each value is cut at 40 characters so one long value leaves room for the rest, and the summary at 160. The keys keep the order the database returns, which for a `jsonb` column is shortest first. The record page shows the value written out on several lines across the width of its section; a value of more than 20 lines shows its first 20 with a "Show all" button that shows the rest.
145
145
 
146
- A `url` field's link shows its address unless you give it a text. `.format('url', { text })` takes a fixed text, or one with `{field}` placeholders the record fills in, each as the record page shows it, such as an enum value by its label and a relation by the name of the record it points at:
146
+ A `url` field's link shows its address unless you give it a text. `.format('url', { text })` takes a fixed text, or one with `{{field}}` placeholders the record fills in, each as the record page shows it, such as an enum value by its label and a relation by the name of the record it points at:
147
147
 
148
148
  ```ts
149
149
  view<typeof errors>('errors').fields((r) => ({
150
150
  report: r.report.format('url', { text: 'Error report' }),
151
- trace: r.trace.format('url', { text: '{title}' }),
151
+ trace: r.trace.format('url', { text: '{{title}}' }),
152
152
  }))
153
153
  ```
154
154
 
155
155
  The link still opens the address in a new tab, in the list's cells, related tables, the record page and its sidebar; cards and the mobile rows show the text too. When a field it names is empty, the link shows its address rather than a text with a gap, and so does it for a reader who cannot read a field it names. The list loads the fields a link's text names along with its columns. A text on another format, or one naming a field the resource does not have, stops the server at startup; a later `.format()` with another format drops the text.
156
156
 
157
- <gap>Lists, related tables and cards cannot fill a `{field}` naming a relation with the related record's name because resolving those names for link text outside the record page is not implemented; they show its key.</gap>
157
+ <gap>Lists, related tables and cards cannot fill a `{{field}}` naming a relation with the related record's name because resolving those names for link text outside the record page is not implemented; they show its key.</gap>
158
158
 
159
159
  <gap>Cards, boards and a list's mobile rows cannot open a url field's address because links on a card's one-line parts are not implemented; they show its text or address as plain text.</gap>
160
160
 
@@ -624,7 +624,7 @@ view<typeof repairs>('repairs').create({ page: 'book-repair' })
624
624
  - `/<resource>/new` shows that page instead of the create form, so the list's **New** button and every [create address](layouts.md#addresses) open it. The breadcrumb reads the resource and **New**, as for the form.
625
625
  - **New** shows to whoever `/api/meta` gives the page, as its `roles` say, whatever the resource's `create` access. The resource's API can then refuse creates (`create: () => false`) while the page creates through an [API function](../guides/api-functions.md) that writes with `db`. Someone without the page gets no **New**, and `/<resource>/new` tells them they cannot create there: the create form never shows. **Import** still follows the resource's `create` access.
626
626
  - The address's `values` stay in it. A component on the page reads them with `useAppAddress()` and can keep its answers there as they are given, so a reload, a link, or a round trip through another site keeps them. See [Create pages](custom-components.md#create-pages).
627
- - A create address's `values` may name what is not a field of the resource, such as `{ kind: 'create', resource: 'tasks', values: { objective_id: '{id}' } }` for a task's objectives kept in a join resource, since the page reads them. Its `{field}` placeholders are still checked against the record the link sits on. A resource without a create page still refuses such values, as its create form would drop them.
627
+ - A create address's `values` may name what is not a field of the resource, such as `{ kind: 'create', resource: 'tasks', values: { objective_id: '{{id}}' } }` for a task's objectives kept in a join resource, since the page reads them. Its `{{field}}` placeholders are still checked against the record the link sits on. A resource without a create page still refuses such values, as its create form would drop them.
628
628
  - The server refuses a page that does not exist when it starts.
629
629
 
630
630
  [A create page of your own](../guides/create-page.md) builds one step by step.
@@ -725,10 +725,10 @@ view<typeof objectives>('objectives')
725
725
 
726
726
  ### A record page that opens another
727
727
 
728
- `.recordOpens(to)` sends a record's page to another address in its place, its `{field}`s, in the resource, the key and `run`, filled from the record, replacing the record's address in the history so Back skips it: a workflow run's page opens its workflow's page with the run on the graph. A caller who cannot follow it, such as one who may not read the resource it names or open the page it names, gets the record's own page. The record's own page stays at its address with `?standard=true`.
728
+ `.recordOpens(to)` sends a record's page to another address in its place, its `{{field}}`s, in the resource, the key and `run`, filled from the record, replacing the record's address in the history so Back skips it: a workflow run's page opens its workflow's page with the run on the graph. A caller who cannot follow it, such as one who may not read the resource it names or open the page it names, gets the record's own page. The record's own page stays at its address with `?standard=true`.
729
729
 
730
730
  ```ts
731
- view<typeof workflowRuns>('workflow_runs').recordOpens({ kind: 'record', resource: 'workflows', key: '{workflow_id}', run: '{id}' })
731
+ view<typeof workflowRuns>('workflow_runs').recordOpens({ kind: 'record', resource: 'workflows', key: '{{workflow_id}}', run: '{{id}}' })
732
732
  ```
733
733
 
734
734
  A record address can also carry `version`, an earlier saved version of the record shown by a field type that keeps versions, such as the `workflow` field type: the record page then shows its read view, without Save or Edit.
@@ -763,7 +763,7 @@ view<typeof reports>('reports').record({ component: component('ReportStudio'), f
763
763
 
764
764
  The bar gets the record's state, Save, its [actions](#actions-and-views-per-role) behind "...", *Discard changes* while there are any, and a link to the form at `?standard=true`, named after the record, such as *Workflow details*, where the layout's sections and related records stay. A refused save, a conflict and a restored draft show in the notice, a reader who may not change the record gets no Save, and the form shows instead when the surface throws. A caller who may not read the surface's field gets the form. The record's name is in the breadcrumb, with a hidden heading for screen readers. What fills the bar and panels, and how a surface reaches them, is under [Focus pages](custom-components.md#focus-pages). `.record(...)` with `surface` needs a [field type](plugins.md#field-types) that draws the whole area; the built-in `workflow` field is one.
765
765
 
766
- A create address can open a page in place of the form too, for a record made where it is used, as a workflow's test run is made in the workflow's page. `.createOpens(to)` replaces the address, its `{field}`s filled from the address's `values`; when the address's `values` lack any of those `{field}`s, or the caller may not open the page, the create address shows what the view shows without it: its [`.create(...)`](#create-pages) page when it has one, else the form. A record address's `panel` (`?panel=<name>`) names a panel its surface opens with.
766
+ A create address can open a page in place of the form too, for a record made where it is used, as a workflow's test run is made in the workflow's page. `.createOpens(to)` replaces the address, its `{{field}}`s filled from the address's `values`; when the address's `values` lack any of those `{{field}}`s, or the caller may not open the page, the create address shows what the view shows without it: its [`.create(...)`](#create-pages) page when it has one, else the form. A record address's `panel` (`?panel=<name>`) names a panel its surface opens with.
767
767
 
768
768
  ### Read view and edit
769
769
 
@@ -1004,7 +1004,7 @@ Without any configuration, the record page's rail has a **Related records** card
1004
1004
  | `actions` | Named actions of `resource`'s view, by name, as buttons on each card; only with `presentation: 'cards'` or `'compact'`. A screen reader names each button by its label and the card's title, such as *Mark clear: Lists lose their place*. |
1005
1005
  | `time` | A date or timestamp field of `resource` each compact card shows beside its title, as its view formats it; only with `presentation: 'compact'`. |
1006
1006
  | `tone` | An enum field of `resource` whose value colours each card's left edge, by its view's [`valueColors`](#value-tones-and-currencies); only with `presentation: 'cards'` or `'compact'`. |
1007
- | `button` | `{ label, to }` or `{ label, href }`, or a list of them of which each row shows the first whose fields it holds: a [button on each row](blocks.md#row-buttons), or each card, to an address the row's fields name, its tab or list filter too, or to the outside page a field holds, such as `{ label: '{verb}', to: { kind: 'record', resource: 'tasks', key: '{task_id}', tab: 'Review' } }`; a row without a value for a field it names shows none. Not with `lines`. |
1007
+ | `button` | `{ label, to }` or `{ label, href }`, or a list of them of which each row shows the first whose fields it holds: a [button on each row](blocks.md#row-buttons), or each card, to an address the row's fields name, its tab or list filter too, or to the outside page a field holds, such as `{ label: '{{verb}}', to: { kind: 'record', resource: 'tasks', key: '{{task_id}}', tab: 'Review' } }`; a row without a value for a field it names shows none. Not with `lines`. |
1008
1008
  | `open` | The relation of `resource` whose record a row opens, for rows that link this record to another. By default the one relation in `resource`'s primary key besides `field`, when there is exactly one (a join resource such as `task_dependencies` keyed on `[task_id, type, depends_on_id]`); otherwise rows open their own records. The row's menu then has **Open** for the other record and **Edit** for the link itself. |
1009
1009
  | `limit` | How many records it shows, 1 to 100; default 10. Not with `presentation: 'record'`. When there are more, the section says so beside View all, such as "The first 10 of 37.". Before 0.13 this was `pageSize`, rows per page; rename it. |
1010
1010
  | `display` | The display of `resource`'s list it opens in, and View all opens, such as `cards`; default the list's. Not with `presentation: 'record'`. |
@@ -1261,7 +1261,7 @@ export { customersView }
1261
1261
  export const repairsView = laidOut.actions((a) => [
1262
1262
  a.update('ready', { label: 'Ready for pickup', icon: 'send', set: { status: 'ready' } }),
1263
1263
  a.update('collect', { label: 'Collected and paid', icon: 'wallet', set: { status: 'collected', paid: true }, confirm: 'Has the customer paid and taken the bike?' }),
1264
- a.link('customerRepairs', { label: 'Other repairs of this customer', icon: 'file-text', to: { kind: 'list', resource: 'repairs', filter: 'customer_id = {customer_id}' } }),
1264
+ a.link('customerRepairs', { label: 'Other repairs of this customer', icon: 'file-text', to: { kind: 'list', resource: 'repairs', filter: 'customer_id = {{customer_id}}' } }),
1265
1265
  ])
1266
1266
 
1267
1267
  /** What mechanics get instead: no money, and their own move. */
@@ -1343,10 +1343,10 @@ export const ordersView = view<typeof orders>('orders')
1343
1343
  ])
1344
1344
  ```
1345
1345
 
1346
- An `a.update` writes the answers with no code: a `set` value that is exactly `'{name}'` is the answer of the input called `name`. An empty answer writes `null`, an input that is hidden by `when` leaves its field as it is, and a `'{name}'` that names no input stops the config from loading. An update that asks for input is always offered, since the answer can always change the record. This button works the same on a composed page, so a dashboard can answer in place:
1346
+ An `a.update` writes the answers with no code: a `set` value that is exactly `'{{name}}'` is the answer of the input called `name`. An empty answer writes `null`, an input that is hidden by `when` leaves its field as it is, and a `'{{name}}'` that names no input stops the config from loading. An update that asks for input is always offered, since the answer can always change the record. This button works the same on a composed page, so a dashboard can answer in place:
1347
1347
 
1348
1348
  ```ts
1349
- a.update('answer', { label: 'Answer', inputs: (i) => [i.text('answer', { label: 'Answer', multiline: true })], set: { answer: '{answer}' } })
1349
+ a.update('answer', { label: 'Answer', inputs: (i) => [i.text('answer', { label: 'Answer', multiline: true })], set: { answer: '{{answer}}' } })
1350
1350
  ```
1351
1351
 
1352
1352
  | Input | Asks for |