@protobase/cli 0.117.7 → 0.118.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/package.js +1 -1
- package/package.json +8 -8
- package/skills/protobase/references/features/sign-in-and-accounts.md +1 -0
- package/skills/protobase/references/reference/api.md +3 -2
- package/skills/protobase/references/reference/auth.md +23 -1
- package/skills/protobase/references/reference/client.md +1 -1
- package/skills/protobase/references/reference/config/sign-in.md +3 -3
- package/skills/protobase/references/reference/sidebar.md +16 -1
- package/skills/protobase/references/reference/ui-config.md +2 -0
package/dist/cli/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.118.1",
|
|
4
4
|
"description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@better-auth/core": "^1.7.12",
|
|
45
45
|
"@hono/node-server": "^2.1.3",
|
|
46
|
-
"@protobase/config": "0.
|
|
47
|
-
"@protobase/layout": "0.
|
|
48
|
-
"@protobase/query": "0.
|
|
49
|
-
"@protobase/schema": "0.
|
|
50
|
-
"@protobase/server": "0.
|
|
51
|
-
"@protobase/ui": "0.
|
|
52
|
-
"@protobase/workflows": "0.
|
|
46
|
+
"@protobase/config": "0.118.1",
|
|
47
|
+
"@protobase/layout": "0.118.1",
|
|
48
|
+
"@protobase/query": "0.118.1",
|
|
49
|
+
"@protobase/schema": "0.118.1",
|
|
50
|
+
"@protobase/server": "0.118.1",
|
|
51
|
+
"@protobase/ui": "0.118.1",
|
|
52
|
+
"@protobase/workflows": "0.118.1",
|
|
53
53
|
"@react-email/render": "^2.1.0",
|
|
54
54
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
55
55
|
"@sentry/vite-plugin": "^11.10.0",
|
|
@@ -38,6 +38,7 @@ Sign-in methods, users, roles, organizations and tokens.
|
|
|
38
38
|
- [Staff sign-in](../reference/auth.md#staff-sign-in): The team that runs an app signs in as a person to help them, with a reason and a log entry.
|
|
39
39
|
- [Roles](../reference/auth.md#roles): A user holds one or more roles and switches between them without signing in again.
|
|
40
40
|
- [Organizations](../reference/auth.md#organizations): People work in one organization at a time, see only its records, and are invited with their own roles.
|
|
41
|
+
- [First organization](../reference/auth.md#first-organization-and-start-address) (beta): People outside any organization name their first one in one step, or join one they are invited to, and land on the start address your app sets. You choose the word your app uses for an organization, such as workspace.
|
|
41
42
|
- [Status](../reference/status.md) (beta): People set themselves busy or do not disturb, with a text of their own such as "Having lunch" and a time it clears, from the user menu; the people they share an organization with see it beside their name, with your app's online or away mark on the members page and in the sidebar.
|
|
42
43
|
- [API tokens](../reference/auth.md#tokens-and-roles): A signed-in session gets short-lived tokens for the API.
|
|
43
44
|
- [Immediate revocation](../reference/auth.md#when-a-token-stops-working): A ban, removed role or ended session takes effect on the next request.
|
|
@@ -51,6 +51,7 @@ Under `/api/v1`:
|
|
|
51
51
|
| `GET /{resource}:aggregate?group_by=&sum=&average=&maximum=&filter=` | `{ group_by, groups: [{ value, count, sum }] }`: the records the whole filter finds, per value of `group_by`, each with its count and, with `sum`, `average` or `maximum` (one of them), that of a numeric field, `null` when no record of the group has one. Values come largest first, the first `limit` (100 by default, at most 1,000), with `label` as in `:facets`. A date or timestamp `group_by` is bucketed like `:series` instead (`granularity` `minute`, `5_minutes`, `15_minutes` or `hour` to `year`, `range` or `from` and `to`, `time_zone`), empty buckets included, and each `value` is the bucket's start; the response adds `granularity` and `time_zone`. With `split_by` (a filterable field of values), a date `group_by` also splits each bucket: the response adds `split_by` and `splits` (the `split_limit` largest values over the range, 8 by default and at most 100, ranked by the sum, else by count; `split_label` names a relation's values), and each group lists its `splits` with their count and sum, average or maximum. Unlike `:facets`, the filter's terms on `group_by` apply too, so the groups add up to what the filter finds. A values `group_by` takes [`limit_per=<field>:<n>`](#first-rows-per-value): the first `n` groups per value of `field`, each with that value as `per`, by `per`, with `limit` capping all groups together; a date `group_by` refuses it |
|
|
52
52
|
| `GET /{resource}:series?field=&range=&granularity=&time_zone=&filter=` | `range` is `1h`, `24h`, `7d`, `30d`, `90d`, `1y`, `all`, or `from` and `to` (ISO); `granularity` `minute`, `5_minutes`, `15_minutes`, `hour`, `day` (the default), `week` or `month`. Buckets of minutes start on the clock's multiples of them |
|
|
53
53
|
| `GET /{resource}:histogram?field=&buckets=&filter=` | equal-width buckets of a numeric field |
|
|
54
|
+
| `POST /{resource}:batchAggregates` | `{ facets: [...], histograms: [...], series: [...] }`, each a list of reads with the parameters of `:facets`, `:histogram` and `:series` (at most 100 of each), answered with lists of what those methods answer, in the same order. Reads that filter the same rows, a facet's own terms left out, share their scans of the table: one for the bounds of every histogram, and one per four facets, histograms of several buckets and series. Each keeps its method's access, scan guard and labels, and a read that fails fails the request. A list page sends its filters' counts and its chart this way |
|
|
54
55
|
| `GET /{resource}:map?latitude=&longitude=&zoom=&filter=&order_by=&fields=&labels=&photos=&photos_order_by=` | the records in a map's view, the bounding box being in `filter` (`lat >= 51.9 AND lat <= 52.1 AND lng >= 4.2 AND lng <= 4.5`), as `{ items, buckets, total_size }`; see [Maps](#maps) |
|
|
55
56
|
| `GET /{resource}:seek?position=&order_by=&filter=&page_size=&fields=&labels=&photos=&photos_order_by=` | the page at a row position (scrollbar jumps), with `next_page_token` and `prev_page_token`; same items as a list |
|
|
56
57
|
| `GET /api/meta` | resource, view and page models (fields carry `default`: `{ value }` or `{ db: true }`) and the caller's `permissions`; the `ETag` hashes both, so it differs per user; `If-None-Match` gives `304` |
|
|
@@ -109,7 +110,7 @@ The photos are read as the caller lists that resource, in one query for the whol
|
|
|
109
110
|
Access is resolved once per request and resource ([`resolveAccess`](https://docs.protobase.net/api/schema/functions/resolveaccess/), see [Login with Better Auth](auth.md) for roles and capabilities), and everything downstream uses the result:
|
|
110
111
|
|
|
111
112
|
- **Operations**: a denied operation is `403`; a resource the caller can do nothing with does not exist for them (`404` everywhere, absent from `/meta` and the OpenAPI document).
|
|
112
|
-
- **Readable fields**: the caller works with a restricted model that has only the fields they may read. `filter`, `order_by`, `fields`, `search(...)`, `:facets`, `:aggregate`, `:histogram`, `:series`, `:map`, `:seek` and `:search` bodies are checked against it, so a hidden field is refused exactly like an unknown one (same status, same message and hint, nothing that says it exists). List, get, create, update and delete responses contain readable fields only, and queries select only those columns.
|
|
113
|
+
- **Readable fields**: the caller works with a restricted model that has only the fields they may read. `filter`, `order_by`, `fields`, `search(...)`, `:facets`, `:aggregate`, `:histogram`, `:series`, `:batchAggregates`, `:map`, `:seek` and `:search` bodies are checked against it, so a hidden field is refused exactly like an unknown one (same status, same message and hint, nothing that says it exists). List, get, create, update and delete responses contain readable fields only, and queries select only those columns.
|
|
113
114
|
- **Sensitive fields** are readable fields that no response carries and no request may name, except `:reveal`; they can be written. See [Sensitive fields and audit](#sensitive-fields-and-audit).
|
|
114
115
|
- **Writable fields**: only fields the caller may write and read are accepted, and [write-only](access.md#write-only-fields) ones; any other is `400`, worded as unknown (hidden) or read-only.
|
|
115
116
|
- **Row filters**: a rule that returns a filter (`.own`, `.team`) narrows every read (list, get, aggregates) and the rows a write may target; the database applies it, so it may use columns the caller cannot see. A row outside it is a `404`.
|
|
@@ -267,7 +268,7 @@ The API sends no CORS headers until it has something to allow: other websites in
|
|
|
267
268
|
|
|
268
269
|
- Every request runs in a transaction with `SET LOCAL statement_timeout` (`statementTimeoutMs`, default 1 s), so a slow query fails where it runs instead of holding a connection that other requests wait for. List, search, get, histogram, series, map and seek transactions are read-only. A query that runs longer is stopped: a `504` `statement-timeout` that names the request, its limit and the ways out, such as `GET /api/v1/orders ran a query longer than 1 s, so the database stopped it. Make the query faster, such as with an index or a narrower filter, or move the work into a function or job with longQueries: true, whose queries may run up to 30 s.` It goes to the app's error hook (`hooks/error.ts`, `createAdmin`'s `options.onUnhandledError`) and the [error tracker](#error-reporting) like a `500`. A read that needs longer has no way to opt out: give it an index, or move it into a [function](../guides/api-functions.md#long-queries) or [job](jobs.md) with `longQueries`.
|
|
269
270
|
- Under `protobase dev` and `serve`, a request waits at most 2 seconds for a free database connection. When every connection stays busy that long, it is a `503` `connections-busy` with `Retry-After: 1` that names the request, reported the same way, rather than a request that hangs behind slow ones. A request that finds room for a new connection waits up to 30 seconds for it to open, such as while a database that scaled to zero wakes.
|
|
270
|
-
- **Scan guard**: a list, `:search`, `:seek`, `:map` page, card photos, `:facets` and `:aggregate` read only columns an index serves, so they stay cheap however many rows match. The server reads each table's valid indexes from the catalog once, then checks every column the caller's filter, the role's row filter, the sort's first field, a facet's or an aggregate's grouped field, the field of [`limit_per`](#first-rows-per-value), a [`read` parent](access.md#records-that-belong-to-another)'s relation read and a [`related()`](#filtering-through-related-records) term's `field`, the columns of the parent's own row filter against the parent's table, and the subfilter's columns and `key` of a term against its resource's table:
|
|
271
|
+
- **Scan guard**: a list, `:search`, `:seek`, `:map` page, card photos, `:facets` (in `:batchAggregates` too) and `:aggregate` read only columns an index serves, so they stay cheap however many rows match. The server reads each table's valid indexes from the catalog once, then checks every column the caller's filter, the role's row filter, the sort's first field, a facet's or an aggregate's grouped field, the field of [`limit_per`](#first-rows-per-value), a [`read` parent](access.md#records-that-belong-to-another)'s relation read and a [`related()`](#filtering-through-related-records) term's `field`, the columns of the parent's own row filter against the parent's table, and the subfilter's columns and `key` of a term against its resource's table:
|
|
271
272
|
- Comparisons, `in`, null checks, sorts and facets need a btree index with the column as a key, every key before it pinned by the query: by `=` or `in` in the filter (outside `OR` and `NOT`), by the tenant or by soft delete. `(for_sale, status, published_at desc)` serves `for_sale = true AND status = "available"` sorted by `published_at desc`, but not `status` alone. `=` on text may use a pg_trgm index instead.
|
|
272
273
|
- `limit_per` reads each value's records in the sort's order, so it needs one btree index with its field as a key and the sort's first field under it, `(task_id, created_at)` for `limit_per=task_id:3&order_by=created_at desc`; without an `order_by`, an index on its field alone.
|
|
273
274
|
- Patterns (`name = "*port*"`), `regex()`, `similar()` and `search()` need a pg_trgm (GIN or GiST) index on each column they read, a `digitsEnd` search field one on its digits; JSON `field:value` needs a GIN index.
|
|
@@ -753,7 +753,29 @@ await listOrganizations(auth, { after?, size? })
|
|
|
753
753
|
await addAppRoleToOwners(auth, appRole) // a role the project added later, to every owner
|
|
754
754
|
```
|
|
755
755
|
|
|
756
|
-
The app's own pages are under the profile menu: the switcher, "Manage organizations" (theirs, a new one, and for global roles any one), "Organization" (details, leaving, handing over, deleting), and for owners and admins "Members" and "Invitations". The client has them as `session.organizations` (`list`, `current`, `switchTo`, `members`, `invite`, ...).
|
|
756
|
+
The app's own pages are under the profile menu: the switcher, "Manage organizations" (theirs, a new one, and for global roles any one), "Organization" (details, leaving, handing over, deleting), and for owners and admins "Members" and "Invitations". The client has them as `session.organizations` (`list`, `current`, `switchTo`, `members`, `invite`, ...). `session.organizations.create({ name })` makes one from its name alone: the server makes the slug from the name, and when another organization has that slug, adds a dash and six random letters and digits, such as `acme-k3x9q2`. The organization page changes the slug afterwards.
|
|
757
|
+
|
|
758
|
+
### First organization and start address
|
|
759
|
+
|
|
760
|
+
:::caution[Beta]
|
|
761
|
+
The start address is the same for everyone in an app; it does not yet remember where each person was last.
|
|
762
|
+
:::
|
|
763
|
+
|
|
764
|
+
Someone signed in who works in no organization, such as the first person in a new app, sees one screen before anything else, whatever address they opened: at `/-/first-organization`, with the app's mark and no sidebar entries, they name their first organization in one field and press Create. With invitations waiting for their address, the screen lists those first, each with Join, and "Create a new organization instead" leads to the form at `/-/first-organization/new`. Someone who may not create one (`create: 'admins'`) and has no invitation is told to ask for one. The screen names who is signed in, with Sign out, and for someone with a global role links to every organization. Creating or joining opens the app at its start address. Until they work in one, the shell shows none of the app's resources, on the account pages and the organizations page too.
|
|
765
|
+
|
|
766
|
+
The word the screens use for an organization is yours: `names` takes it as a view's names are written, and `createDescription` adds a line under the screen's title. The built-in texts around the word come in English and Dutch, on this screen, the organization pages and the profile menu:
|
|
767
|
+
|
|
768
|
+
```ts
|
|
769
|
+
auth: {
|
|
770
|
+
organizations: {
|
|
771
|
+
create: 'everyone',
|
|
772
|
+
names: { singular: 'Workspace', plural: 'Workspaces' },
|
|
773
|
+
createDescription: 'Your team talks here, in channels.',
|
|
774
|
+
},
|
|
775
|
+
}
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
The screen then reads "Create your workspace", its field "Workspace name" and its button "Create workspace". <gap>The organization word cannot come in each reader's language because translations of `auth.organizations.names` are not implemented.</gap> `/` opens the record a sidebar entry names with [`nav({ start })`](sidebar.md#start-record), such as a chat's #general channel, found by a filter on an indexed field; without one, or when nothing matches, the first sidebar entry, as before.
|
|
757
779
|
|
|
758
780
|
## Tokens and roles
|
|
759
781
|
|
|
@@ -17,7 +17,7 @@ const { record, etag } = await api.get(orders, id)
|
|
|
17
17
|
await api.update(orders, id, { status: 'shipped' }, etag) // 412 rejects with PreconditionFailedError
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
Pass a resource builder to get its record type ([`InferRecord`](https://docs.protobase.net/api/schema/type-aliases/inferrecord/)), or a name for loose records. Filters are AIP-160 text or [`where`](https://docs.protobase.net/api/schema/variables/where/) results (printed with [`printFilter`](https://docs.protobase.net/api/schema/functions/printfilter/)), and a list whose query string passes 4,000 characters goes by `:search`. Errors are `ApiError` (`status`, `slug`, `errors`, `filterErrors` with spans, `blockedBy` for a delete other records point at), which `isApiError(error)` tells apart. Also: `search`, `create`, `remove`, `facets`, `series`, `histogram`, `map(resource, { latitude, longitude, zoom, filter?, orderBy?, fields? })` (the records in a map's view, or buckets of them, see [`:map`](api.md#maps)), `seek`, `reveal(resource, key, field)` (a [sensitive field](data-config.md#sensitive-fields)'s value), `generate(resource, key, action)` (runs an [AI action](ai.md#ai-actions) and resolves to the record as written), `meta(etag?, { signal? })`, `invoke(name, { body?, method?, path?, query?, cache? })` (one of the app's [API functions](../guides/api-functions.md#calling-a-function); its answer as parsed JSON, text, or a `Blob` for any other type), `history(resource, key, { pageSize?, pageToken? })` (a page of a record's [changes](history.md), newest first), `comments(resource, key, { pageSize?, pageToken? })`, `comment(resource, key, { body, mentions? })` and `mentionable(resource, key, query)` (a record's [comments](comments.md#the-endpoints), adding one, and the people it may mention), `form(name)`, `formChallenge(name)` and `submitForm(name, values, proof)` (a [public form](forms.md#routes)), `upload(resource, field, file, { onProgress?, signal? })` (a file for a [file field](files.md#uploading); its `value` goes in the next write, and `onProgress` uses XMLHttpRequest, since fetch reports no upload progress), `live({ onChanges, onResync, onRetry? })` (hears which records of the [live](live.md) resources change until the function it returns is called, connecting again by itself; every caller of one client shares one stream), `channel(resource, key)` (a record's [channel](channels.md#from-a-page), with its presence and broadcasts, every channel of the client on one socket), `bridges.open(name, target)` (a [TCP bridge](tcp-bridges.md#opening-a-bridge)'s socket, with when the server closes it).
|
|
20
|
+
Pass a resource builder to get its record type ([`InferRecord`](https://docs.protobase.net/api/schema/type-aliases/inferrecord/)), or a name for loose records. Filters are AIP-160 text or [`where`](https://docs.protobase.net/api/schema/variables/where/) results (printed with [`printFilter`](https://docs.protobase.net/api/schema/functions/printfilter/)), and a list whose query string passes 4,000 characters goes by `:search`. Errors are `ApiError` (`status`, `slug`, `errors`, `filterErrors` with spans, `blockedBy` for a delete other records point at), which `isApiError(error)` tells apart. Also: `search`, `create`, `remove`, `facets`, `series`, `histogram`, `batchAggregates(resource, { facets?, histograms?, series? })` (several of those reads in one [`:batchAggregates`](api.md#routes) request, answered as each would be), `map(resource, { latitude, longitude, zoom, filter?, orderBy?, fields? })` (the records in a map's view, or buckets of them, see [`:map`](api.md#maps)), `seek`, `reveal(resource, key, field)` (a [sensitive field](data-config.md#sensitive-fields)'s value), `generate(resource, key, action)` (runs an [AI action](ai.md#ai-actions) and resolves to the record as written), `meta(etag?, { signal? })`, `invoke(name, { body?, method?, path?, query?, cache? })` (one of the app's [API functions](../guides/api-functions.md#calling-a-function); its answer as parsed JSON, text, or a `Blob` for any other type), `history(resource, key, { pageSize?, pageToken? })` (a page of a record's [changes](history.md), newest first), `comments(resource, key, { pageSize?, pageToken? })`, `comment(resource, key, { body, mentions? })` and `mentionable(resource, key, query)` (a record's [comments](comments.md#the-endpoints), adding one, and the people it may mention), `form(name)`, `formChallenge(name)` and `submitForm(name, values, proof)` (a [public form](forms.md#routes)), `upload(resource, field, file, { onProgress?, signal? })` (a file for a [file field](files.md#uploading); its `value` goes in the next write, and `onProgress` uses XMLHttpRequest, since fetch reports no upload progress), `live({ onChanges, onResync, onRetry? })` (hears which records of the [live](live.md) resources change until the function it returns is called, connecting again by itself; every caller of one client shares one stream), `channel(resource, key)` (a record's [channel](channels.md#from-a-page), with its presence and broadcasts, every channel of the client on one socket), `bridges.open(name, target)` (a [TCP bridge](tcp-bridges.md#opening-a-bridge)'s socket, with when the server closes it).
|
|
21
21
|
|
|
22
22
|
With an absolute `baseUrl`, such as another app's `https://desk.example.com/api/v1`, the `url` of each [file](files.md) in a record the client answers is absolute too, on that API's origin, where the API answers a path on its own origin. `routedClient(own, sourceOf)` is one client over several APIs: each call about a resource goes to the client `sourceOf(resource)` gives, else to `own`, as the admin app does for [remote resources](remote-resources.md), and `sourceMeta(meta, source)` keeps the part of another API's `/meta` an app draws.
|
|
23
23
|
|
|
@@ -50,13 +50,13 @@ export default defineConfig({ auth: { roles: ['admin', 'sales', 'warehouse'], de
|
|
|
50
50
|
|
|
51
51
|
## auth.organizations
|
|
52
52
|
|
|
53
|
-
- **Type:** `true | { create?: 'admins' | 'everyone'; creatorAppRoles?: 'all' | string[]; invitationDays?: number; membershipLimit?: number; deleteRecords?: 'refuse' | 'cascade'; invitationUrl?: string }`
|
|
53
|
+
- **Type:** `true | { create?: 'admins' | 'everyone'; names?: { singular: string; plural: string }; createDescription?: string; creatorAppRoles?: 'all' | string[]; invitationDays?: number; membershipLimit?: number; deleteRecords?: 'refuse' | 'cascade'; invitationUrl?: string }`
|
|
54
54
|
- **Default:** off: the app works as one organization
|
|
55
55
|
|
|
56
|
-
Turns on organizations: people work in one at a time, records of `.tenant` resources are scoped to it, and roles are held globally or per membership. `create` is who may create one (default `admins`), `creatorAppRoles` the roles its creator holds there (default `all`), `invitationDays` how long an invitation works (default 7), `membershipLimit` the most members (default 1000), `deleteRecords` whether deleting one is refused while it has records (`refuse`, the default) or left to the foreign keys (`cascade`), and `invitationUrl` the page an invitation opens (default `/-/invitation` on the origin the invitation was made on). Its hooks are in `auth/hooks.ts`. See [Organizations](../auth.md#organizations).
|
|
56
|
+
Turns on organizations: people work in one at a time, records of `.tenant` resources are scoped to it, and roles are held globally or per membership. `create` is who may create one (default `admins`), `names` what the screens call an organization, as a view's names are written (default Organization), `createDescription` a line under the title of the screen where someone names their first, `creatorAppRoles` the roles its creator holds there (default `all`), `invitationDays` how long an invitation works (default 7), `membershipLimit` the most members (default 1000), `deleteRecords` whether deleting one is refused while it has records (`refuse`, the default) or left to the foreign keys (`cascade`), and `invitationUrl` the page an invitation opens (default `/-/invitation` on the origin the invitation was made on). Its hooks are in `auth/hooks.ts`. See [Organizations](../auth.md#organizations) and [First organization](../auth.md#first-organization-and-start-address).
|
|
57
57
|
|
|
58
58
|
```ts
|
|
59
|
-
export default defineConfig({ auth: { organizations: { create: 'everyone', invitationDays: 14 } } })
|
|
59
|
+
export default defineConfig({ auth: { organizations: { create: 'everyone', invitationDays: 14, names: { singular: 'Workspace', plural: 'Workspaces' } } } })
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
## auth.signUp
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
How sidebar entries are grouped and which icon each shows, how an entry lists recent records, with status dots or without, and how it links to its create form.
|
|
6
6
|
|
|
7
|
-
The admin's sidebar has one entry per resource view, grouped by `nav.group` (default: the database schema, with no group name for `public`) and sorted by `nav.order`, then by the order `config/index.ts` exports them, in `protobase dev` and in a built bundle alike. The app opens on the first entry. A view's [named lists](ui-config.md#more-than-one-list) are entries of their own, placed by their own `nav`. `nav({ hidden: true })` leaves a resource out, for line and link tables; a resource in the [user menu](user-menu.md) is left out too. [Composed pages](layouts.md#setup) have entries of their own, and groups that hold pages come first. A [remote resource](remote-resources.md) has its entry where its source's view places it; while its source cannot be reached, it sits under the source's label, marked "Cannot reach" with the source's name.
|
|
7
|
+
The admin's sidebar has one entry per resource view, grouped by `nav.group` (default: the database schema, with no group name for `public`) and sorted by `nav.order`, then by the order `config/index.ts` exports them, in `protobase dev` and in a built bundle alike. The app opens on the first entry, or on the [start record](#start-record) an entry names. A view's [named lists](ui-config.md#more-than-one-list) are entries of their own, placed by their own `nav`. `nav({ hidden: true })` leaves a resource out, for line and link tables; a resource in the [user menu](user-menu.md) is left out too. [Composed pages](layouts.md#setup) have entries of their own, and groups that hold pages come first. A [remote resource](remote-resources.md) has its entry where its source's view places it; while its source cannot be reached, it sits under the source's label, marked "Cannot reach" with the source's name.
|
|
8
8
|
|
|
9
9
|
Below the `md` breakpoint (768px) the sidebar is a drawer, which the top bar's menu button opens, It is 88% of the screen wide, at most 384px. With a [bottom bar](bottom-bar.md#search-and-more), **More** opens the sidebar as a page of its own instead.
|
|
10
10
|
|
|
@@ -58,6 +58,21 @@ view<typeof apps>('apps')
|
|
|
58
58
|
|
|
59
59
|
`/meta` writes the session's organization into the list's opening filter, here `isNull(parent_id) AND organization_id = "<id>"`, and into the filter of its [recent records](#recent-records). Like any opening filter it applies when the address names no filter: the facet shows the organization chosen, and the person picks others or clears it, which lists every organization they are a member of. A link with its own filter replaces it, and switching organization opens the app again on the new one. A [named list](ui-config.md#more-than-one-list) takes `tenant` in its own `nav`. `createAdmin` refuses to start when the view has no `.list(...)`, or the resource has no `.tenant()` on a `.filterable()` field.
|
|
60
60
|
|
|
61
|
+
## Start record
|
|
62
|
+
|
|
63
|
+
`nav({ start: { filter } })` makes `/` open the first record of the entry's resource that the filter finds, such as a chat's #general channel, instead of the first sidebar entry:
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
export const channelsView = view<typeof channels>('channels').nav({ recent: { orderBy: 'name asc', limit: 20 }, start: { filter: 'name = "general"' } })
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- The filter is AIP-160 text, as `?filter=` on the list API takes it, so it reads only `.filterable()` fields, which are indexed. `orderBy` picks among several matches; the list's sort when omitted.
|
|
70
|
+
- The record is read with the caller's token: their access rules apply, and an entry they do not see names no start. When several entries name one, the first in the sidebar's order does.
|
|
71
|
+
- When nothing matches, or the list is refused, `/` opens the first sidebar entry. Until the answer comes, `/` draws nothing, so no list shows first; the answer is kept for the next start.
|
|
72
|
+
- A [named list](ui-config.md#more-than-one-list) names no start of its own.
|
|
73
|
+
|
|
74
|
+
`createAdmin` refuses a filter or order that does not fit the resource; `/meta` leaves out a start whose filter or order reads a field the caller cannot read.
|
|
75
|
+
|
|
61
76
|
## Entries for creators
|
|
62
77
|
|
|
63
78
|
`nav({ creatorsOnly: true })` shows the entry only to whoever its list offers **New**, as for the [create link](#create-link), for a list that is there to make records, such as the [tables users add](user-tables.md#in-the-admin-app). Anyone else who may read the resource still opens it at its address.
|
|
@@ -409,6 +409,8 @@ A list without rows says why, in the table, the cards and the phone's List alike
|
|
|
409
409
|
|
|
410
410
|
Every widget takes `secondary: true` (e.g. `w.facets(r.agent, { secondary: true })`): it waits behind the bar's **More filters** menu until it is picked there, and shows in the bar whenever it is set, such as from the address. The panel layout and the phone's filter sheet show every filter.
|
|
411
411
|
|
|
412
|
+
The widgets' counts and ranges and the list's chart load together as one [`:batchAggregates`](api.md#routes) request, so a page with many filters reads a large table a few times rather than once per filter. Counts that could not be loaded say **Could not load the counts** in their menu, and a chart that could not be loaded says **Could not load the chart.**, never zero counts or empty bars.
|
|
413
|
+
|
|
412
414
|
### Charts (graphs): records per day or week, or per value, above a list
|
|
413
415
|
|
|
414
416
|
A list can show a graph of how many of its records fall on each day or week, such as a daily graph of new listings. `.chart((r) => ({ field, range, granularity }))` draws the list's records per day over a date or timestamp field as bars above the list, following its filters, headed by their total and how much the second half of the bars differs from the first. `range` is how far back it reaches: `7d`, `30d`, `90d`, `1y` or `all`. A **Day** and **Week** switch changes the bars, and **Week** shows the last 12 weeks whatever the range; `granularity: 'week'` opens it on weeks. <gap>`hour` and `month` are accepted and show days, as hourly and monthly bars are not built.</gap> A bar's tooltip names its day or whole week, today's bar or this week's is outlined with a dash, as it is still filling up, and the chart reads by keyboard and screen reader as a [trend](#trends-of-related-records)'s does. Its bars do not filter the list.
|