@protobase/cli 0.90.0 → 0.90.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/composed-pages.md +1 -0
- package/skills/protobase/references/guides/api-functions.md +1 -1
- package/skills/protobase/references/reference/blocks.md +36 -0
- package/skills/protobase/references/reference/client.md +1 -1
- package/skills/protobase/references/reference/custom-components.md +3 -0
- package/skills/protobase/references/reference/layouts.md +1 -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.90.
|
|
3
|
+
"version": "0.90.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.90.
|
|
47
|
-
"@protobase/layout": "0.90.
|
|
48
|
-
"@protobase/query": "0.90.
|
|
49
|
-
"@protobase/schema": "0.90.
|
|
50
|
-
"@protobase/server": "0.90.
|
|
51
|
-
"@protobase/ui": "0.90.
|
|
52
|
-
"@protobase/workflows": "0.90.
|
|
46
|
+
"@protobase/config": "0.90.1",
|
|
47
|
+
"@protobase/layout": "0.90.1",
|
|
48
|
+
"@protobase/query": "0.90.1",
|
|
49
|
+
"@protobase/schema": "0.90.1",
|
|
50
|
+
"@protobase/server": "0.90.1",
|
|
51
|
+
"@protobase/ui": "0.90.1",
|
|
52
|
+
"@protobase/workflows": "0.90.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",
|
|
@@ -16,6 +16,7 @@ Pages of your own, built from blocks in a JSX layout.
|
|
|
16
16
|
- [Row buttons](../reference/blocks.md#row-buttons): A table's rows carry a button to an address their fields name, such as a task's tab, labelled by a field of the row, such as its next step.
|
|
17
17
|
- [Record rows](../reference/blocks.md#recordrow): A sideways row of cards for a filter, favorites or saved searches, with a count and new-record marks.
|
|
18
18
|
- [Record cards](../reference/blocks.md#recordcards): Full-width cards with fields and buttons, stacked or in a carousel.
|
|
19
|
+
- [Image block](../reference/blocks.md#image): A picture one of the app's API functions draws for the reader, such as a system map, at the size and theme the client asks, refreshed on a timer; a client that draws no images shows its alt text, or nothing.
|
|
19
20
|
- [Chart block](../reference/blocks.md#chart): Counts, sums or averages by value or by date, as bars, lines or a donut, and over time split by a second field.
|
|
20
21
|
- [Conversations](../reference/blocks.md#conversation): A chat declared in the layout: a thread of a resource's messages under each sender's name and time, following new ones as they arrive, and a box that sends one as the signed-in user.
|
|
21
22
|
- [Buttons and forms](../reference/blocks.md#behaviour): Buttons for named actions, and create or edit forms in a dialog.
|
|
@@ -351,7 +351,7 @@ export default defineUi({
|
|
|
351
351
|
})
|
|
352
352
|
```
|
|
353
353
|
|
|
354
|
-
`invoke(name, { method?, body?, path?, query?, headers? })` sends a `GET`, or a `POST` with a JSON `body
|
|
354
|
+
`invoke(name, { method?, body?, path?, query?, headers?, cache? })` sends a `GET`, or a `POST` with a JSON `body`; `cache` is the browser's fetch cache mode, such as `no-store` for an answer only its caller may see. It resolves to the parsed JSON, to text for a `text/*` answer or one without a content type, to a `Blob` of any other type, or to `undefined` for a `204`. A function sends a file, such as a PDF, as a plain `Response` with its type and name: `new Response(bytes, { headers: { 'content-type': 'application/pdf', 'content-disposition': 'attachment; filename="invoice.pdf"' } })`, and `invoke` gives the caller that `Blob`, with its `type`. A problem rejects with an `ApiError`, as any call of the client does. Outside the admin, `createClient` from `@protobase/client` gives the same `invoke`, or you can call the URL with `fetch` and an `Authorization: Bearer` header.
|
|
355
355
|
|
|
356
356
|
## Hono apps
|
|
357
357
|
|
|
@@ -332,6 +332,42 @@ A bar for `value` out of `max`, with both numbers. It turns amber from 90%.
|
|
|
332
332
|
<Progress label="Seats" value="seats_used" max="plan.seats" />
|
|
333
333
|
```
|
|
334
334
|
|
|
335
|
+
### Image
|
|
336
|
+
|
|
337
|
+
A picture an [API function](../guides/api-functions.md) draws, such as a system map: the block calls `GET /api/functions/<function>` with the reader's token, and draws the image it answers with, such as a PNG. The query says what to draw:
|
|
338
|
+
|
|
339
|
+
| Query | |
|
|
340
|
+
| --- | --- |
|
|
341
|
+
| `width` | The width the client draws it at, in CSS pixels: the block's `width`, else the width of its space, rounded up to a multiple of 100 so resizing the window asks again only now and then. |
|
|
342
|
+
| `height` | The block's `height`, when it has one. Without it the query names no height, and the picture's own proportions decide. |
|
|
343
|
+
| `theme` | `light` or `dark`, the theme the page is drawn in. |
|
|
344
|
+
|
|
345
|
+
| Prop | |
|
|
346
|
+
| --- | --- |
|
|
347
|
+
| `function` | The function's name, as in `functions/<function>.ts`. Required; the server stops at startup when the app has no such function. |
|
|
348
|
+
| `alt` | What the picture shows, for screen readers and for clients that draw no images. |
|
|
349
|
+
| `width`, `height` | The size it is drawn at, in CSS pixels. |
|
|
350
|
+
| `refresh` | Every how many seconds the client asks for the picture again, keeping the last one on screen while the next loads; once when omitted. Regaining window focus never asks again. |
|
|
351
|
+
|
|
352
|
+
```tsx
|
|
353
|
+
<Image function="system-map" alt="The servers and the links between them" height={320} refresh={60} />
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
```ts
|
|
357
|
+
// functions/system-map.ts
|
|
358
|
+
import { defineFunction } from '@protobase/server'
|
|
359
|
+
import { drawSystemMap } from './_shared/system-map'
|
|
360
|
+
|
|
361
|
+
export default defineFunction({ roles: ['admin', 'support'] }, async (request, { records }) => {
|
|
362
|
+
const query = new URL(request.url).searchParams
|
|
363
|
+
const { items } = await records.list('servers')
|
|
364
|
+
const png = await drawSystemMap(items, { width: Number(query.get('width')), height: Number(query.get('height')) || undefined, dark: query.get('theme') === 'dark' })
|
|
365
|
+
return new Response(png, { headers: { 'content-type': 'image/png' } })
|
|
366
|
+
})
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
The function reads records as the caller, so the picture shows only what they may see. A reader the function's `roles` or `capability` leave out gets the page without the block. So does a visitor without a token, unless the function is public, since only a public function takes a call without one. A client that draws no images, such as one that shows text only, shows `alt` in its place, or nothing without it; the admin app does the same when the function refuses, answers no image or one the browser cannot draw, also when a later request fails after an earlier one drew a picture. <gap>An Image cannot ask for a sharper picture on high-density screens because a scale in its query is not implemented.</gap>
|
|
370
|
+
|
|
335
371
|
### Chart
|
|
336
372
|
|
|
337
373
|
Counts, sums or averages of the records that match `filter`, per value of a field or per hour, day, week, month or year of a date field, in a card. It reads [`:aggregate`](api.md#routes), so only what the user may see is counted, and the grouped field needs an index ([scan guard](api.md#safety)).
|
|
@@ -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? })` (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`, `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
|
|
|
@@ -82,9 +82,12 @@ A client that cannot draw a component, such as a native app without React or the
|
|
|
82
82
|
|
|
83
83
|
```tsx
|
|
84
84
|
export const SeatChart = component('SeatChart', { fallback: <Progress label="Seats" value="seats_used" max="plan.seats" /> })
|
|
85
|
+
export const SystemMap = component('SystemMap', { fallback: <Image function="system-map" /> })
|
|
85
86
|
export const Confetti = component('Confetti', { fallback: [] })
|
|
86
87
|
```
|
|
87
88
|
|
|
89
|
+
A visual component, such as a map, falls back to the [picture](blocks.md#image) an API function draws of it; with no `alt`, a client that shows text only draws nothing in its place.
|
|
90
|
+
|
|
88
91
|
The admin app draws the fallback too when the component is missing or throws while drawing; `protobase dev` also shows the warning above it. Without a fallback, the warning stands in the component's place, as above. A [record section](#record-sections) takes `fallback` in `l.custom`.
|
|
89
92
|
|
|
90
93
|
### Fields and resources in props
|
|
@@ -140,5 +140,6 @@ Every block reads the regular API with the user's token, so the access rules app
|
|
|
140
140
|
- `Field`, `Progress` and `Stat field` on a field they cannot read are left out, and table columns are narrowed;
|
|
141
141
|
- `ModalForm` needs create or update permission and keeps only the fields they may write;
|
|
142
142
|
- an `Action` missing from their view of the resource is left out, and so is a `Show` that names something they cannot see.
|
|
143
|
+
- an `Image` whose function they may not call is left out.
|
|
143
144
|
|
|
144
145
|
Custom components are kept: they get only their props, and fetch through the same API. A custom component's fallback loses what the user cannot use like the rest of the tree, and a fallback left with nothing is sent as `[]`, so a client still draws nothing in the component's place.
|