@protobase/cli 0.23.13 → 0.24.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.
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.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": {
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@hono/node-server": "^2.1.3",
|
|
37
37
|
"@hono/vite-dev-server": "^0.26.1",
|
|
38
|
-
"@protobase/layout": "0.
|
|
39
|
-
"@protobase/query": "0.
|
|
40
|
-
"@protobase/schema": "0.
|
|
41
|
-
"@protobase/server": "0.
|
|
42
|
-
"@protobase/ui": "0.
|
|
38
|
+
"@protobase/layout": "0.24.0",
|
|
39
|
+
"@protobase/query": "0.24.0",
|
|
40
|
+
"@protobase/schema": "0.24.0",
|
|
41
|
+
"@protobase/server": "0.24.0",
|
|
42
|
+
"@protobase/ui": "0.24.0",
|
|
43
43
|
"@react-email/render": "^2.1.0",
|
|
44
44
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
45
45
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -10,10 +10,11 @@ An app's own React code, its components, field types and actions, is a [plugin](
|
|
|
10
10
|
|
|
11
11
|
## Start an app
|
|
12
12
|
|
|
13
|
-
`npm create protobase my-app`
|
|
13
|
+
`npm create protobase my-app` asks which preset to start from, scratch (the default), the ERP or real estate, writes the project into `my-app`, with the `@protobase` packages in the range of the latest release's major, and prints the next steps: install it with Bun, point `.env` at a Postgres database, migrate it, load the preset's base data, if it has any, create a user and run `bun run dev`. `--preset <name>` picks one without asking; without a terminal it takes scratch. It needs Node 22.12 or later.
|
|
14
14
|
|
|
15
15
|
```sh
|
|
16
16
|
npm create protobase my-app
|
|
17
|
+
npm create protobase my-app -- --preset real-estate
|
|
17
18
|
```
|
|
18
19
|
|
|
19
20
|
The rest of this page works in a clone of this repository, on its examples.
|
|
@@ -85,4 +86,4 @@ bun run --cwd examples/property-portal dev # http://localhost:5173
|
|
|
85
86
|
| `bun run release --dry-run` | the next version and its changelog, from the commits since the last release (see [Versioning](reference/versioning.md))) |
|
|
86
87
|
| `bun run docs:check` | opens every page of the built site in Chromium and fails on console errors and failed requests; `BASE=https://docs.protobase.net` checks the live site |
|
|
87
88
|
|
|
88
|
-
Each public import is a package in `packages/` (`@protobase/schema`, `layout`, `query`, `client`, `ui`, `server`, and `cli` for the `protobase` command); `packages/presets` writes the projects a new app starts from and is not published; `packages/create-protobase` is `npm create protobase`, with
|
|
89
|
+
Each public import is a package in `packages/` (`@protobase/schema`, `layout`, `query`, `client`, `ui`, `server`, and `cli` for the `protobase` command); `packages/presets` writes the projects a new app starts from and is not published; `packages/create-protobase` is `npm create protobase`, with every preset. See [Architecture](reference/architecture.md)) for the layout and import rules.
|
|
@@ -20,7 +20,7 @@ A Bun workspace of npm packages under the `@protobase` scope, in `packages/<name
|
|
|
20
20
|
| `@protobase/presets` | `packages/presets` | none: private, `bun run presets:write` writes a project per preset | Bun | none; each preset depends on the `@protobase` packages of the major it is written at, locked at that version |
|
|
21
21
|
| `examples/*` | | none | any | `@protobase/*` entry points only |
|
|
22
22
|
|
|
23
|
-
The presets are written from `examples/erp`, `examples/real-estate` and `examples/scratch` (from scratch) by `bun run presets:write <version> <dir>`, run from a clone of this repository;
|
|
23
|
+
The presets are written from `examples/erp`, `examples/real-estate` and `examples/scratch` (from scratch) by `bun run presets:write <version> <dir>`, run from a clone of this repository; `npm create protobase` (`packages/create-protobase`) writes them too, without a lockfile. Each is a standalone copy with the `@protobase` packages in the range of `<version>`'s major, `>=0.y.z <1` below 1.0 (where `^0.y.z` would cover only that minor) and `^x.y.z` from 1.0, so an app takes updates within that major, and its own `bun.lock` at exactly `<version>`. The three declare the same dependencies, so one `node_modules` fits them all, and their `db:migrate` (the auth schema's migrations included), `typecheck` and `test` scripts take their settings from the environment, or a `.env` beside them, and reach nothing outside the project.
|
|
24
24
|
|
|
25
25
|
The JSX runtime belongs to `@protobase/layout` because a layout file names one package in `@jsxImportSource @protobase/layout`, and TypeScript and Vite look up `jsx-runtime` and `jsx-dev-runtime` under it. Each field type is split along the same lines: its Zod builder is `packages/schema/src/fields/<type>.ts` and its SQL parameter conversion `packages/query/src/fields/<type>.ts`.
|
|
26
26
|
|
|
@@ -195,10 +195,27 @@ export const invoiceItemsView = view<typeof invoiceItems>('invoice_items')
|
|
|
195
195
|
|
|
196
196
|
The list of a resource ordered as one, such as the products, has a **Reorder** button beside its other buttons; a related section of records ordered within the page's record, such as the invoice's items, has one at the end of its title's line. **Reorder** shows every record in its order in the list's table, without the filters, search, chart and display switch, with a drag handle in each row where its checkbox was, and the page scrolls them; **Done** goes back. A row moves by dragging its handle, by a long press and drag on a touch screen, or from the keyboard: Space on a handle picks the row up, the up and down arrow keys move it, Space or Enter drops it and Escape puts it back, and a screen reader is told each step. The rest of the row still opens its record.
|
|
197
197
|
|
|
198
|
-
Each drop shows at once and is saved straight away: one [batch `reorder`](api.md#batch-writes)) sends only the stretch of records whose place changed, with the ETags they were listed with, and numbers them on from the record before them; it reaches further only where a gap or a tie left by an earlier write needs it, so a list of thousands saves a short move as a few records. Drops made while one saves are saved after it. A refusal, such as a record someone else changed since, puts the rows back as the server has them, with the reason. Every list of the resource reloads afterwards.
|
|
198
|
+
Each drop shows at once and is saved straight away: one [batch `reorder`](api.md#batch-writes)) sends only the stretch of records whose place changed, with the ETags they were listed with, and numbers them on from the record before them; it reaches further only where a gap or a tie left by an earlier write needs it, so a list of thousands saves a short move as a few records. Drops made while one saves are saved after it. A saved drop says so in a toast with **Undo**, which puts back the positions it changed; see [Dragging in the list](#dragging-in-the-list). A refusal, such as a record someone else changed since, puts the rows back as the server has them, with the reason. Every list of the resource reloads afterwards.
|
|
199
199
|
|
|
200
200
|
A user who may not update the resource or write the field gets no **Reorder**, and `/api/meta` leaves out `position` for one who cannot read its field or its `within`. A related section offers it only when it lists all of the parent's records: its `field` is the `within` relation, without a `filter` or `through`. The list page does not offer it for a resource ordered within a parent, since its list mixes the parents. The field must be `.sortable()` and `within` a `.filterable()` relation, checked when the config loads, and [`protobase doctor`](cli.md#doctor)) checks that an index serves each read in the field's order, such as `(invoice_id, position)`. Records created later are not numbered for you: give them a position, or the next drop numbers them, after the others when the field is empty.
|
|
201
201
|
|
|
202
|
+
### Dragging in the list
|
|
203
|
+
|
|
204
|
+
Nothing in a list moves by dragging unless its `.list(...)` says so with `drag`, each part on its own:
|
|
205
|
+
|
|
206
|
+
| `drag` | What it lets a user drag |
|
|
207
|
+
| --- | --- |
|
|
208
|
+
| `rank: true` | The records of a resource with a [`.position(...)`](#reordering-by-hand) and no `within`, at any time: the table's rows by their handles while the list shows every record in the position's order, ascending, without a filter or search, instead of after **Reorder**; and a [board's](#boards) cards to their place in a column. |
|
|
209
|
+
| `board: true` | A board's card to another column, which saves the record with that column's value. |
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
.list((r, d) => ({ columns: [r.title, r.status], sort: [[r.rank, 'asc']], displays: [d.board({ by: r.status })], drag: { rank: true, board: true } }))
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
A board may let cards move between columns without re-ranking (`board` alone), or be re-ranked within its columns without moving cards between them (`rank` alone). A list sorted another way, filtered or searched shows its own table, and **Reorder** stays for it. A named list has its own `drag`. Either part needs the right to update the field it writes, as **Reorder** does: a user without it drags nothing.
|
|
216
|
+
|
|
217
|
+
On a touch screen a card or a row's handle lifts only after a short hold, a quarter of a second, so a swipe across the board scrolls it instead of moving a card; a mouse or trackpad drags it straight away. Every saved drag says so in a toast with **Undo**, which puts back what it changed, the column and every position it renumbered, with the ETags the save gave the records, so a record changed again since is refused rather than overwritten. Only the latest drag can be undone: a new one replaces the toast.
|
|
218
|
+
|
|
202
219
|
## A filter the list opens with
|
|
203
220
|
|
|
204
221
|
```ts
|
|
@@ -291,6 +308,8 @@ export const repairsView = daily
|
|
|
291
308
|
d.calendar({ start: r.booked_on, title: r.number }),
|
|
292
309
|
],
|
|
293
310
|
default: 'board',
|
|
311
|
+
// A repair moves to another column of the board by dragging it
|
|
312
|
+
drag: { board: true },
|
|
294
313
|
}))
|
|
295
314
|
.layout((r) => [
|
|
296
315
|
l.section('The bike', [r.customer_id, r.bike, r.problem]),
|
|
@@ -304,7 +323,7 @@ export const repairsView = daily
|
|
|
304
323
|
| --- | --- |
|
|
305
324
|
| `d.cards({ image?, title?, subtitle?, amount?, badge?, meta?, footer?, flags?, dots? }, { name?, label?, icon?, card?, photos?, favorite? })` | A card per record, opening it: `image`, a [file field](files.md)), as a picture across the card's top (a raster image; anything else leaves the frame empty), then `title` (default: the view's `.title`) over `subtitle`, `badge` drawn as a badge with its value labels, `amount` the first of its fields with a value in bold (its suffix, such as ` /month`, not), such as a purchase price or else a rent, and a few small `meta` fields such as dates, each only when it has a value, after its field's `.icon` and as a badge when its field's format is `badge`. `footer` is a line at the card's bottom of its fields with a value, joined by bullets, such as a place and an agent. `flags` are boolean fields shown as small badges of their labels when true, such as a garden or parking. `dots` are [related columns](#related-records-in-a-list) of the list, each a line of its dots at the card's bottom. A relation shows the name of the record it points at. With `card`, a component declared with `component('RepairCard')` draws each card's content from the row of those fields instead (see [Record cards](custom-components.md#record-cards))). With `photos`, the picture steps through more photos, by swipe or arrows (see [Card photos](#card-photos)). With `favorite`, a heart in the card's top right corner saves the record (see [Favorites](#favorites)). Named `cards` unless `name` says otherwise. |
|
|
306
325
|
| `d.map({ latitude, longitude, approximate?, exact?, radius?, area? }, { name?, label?, icon?, cards?, defaultRadius? })` | The matching records in the map's view, with how many there are below it; it asks again as it pans and zooms, through the list API's [`:map`](api.md#maps)). From far out it shows a count for each part of the map, which zooms in when chosen; close in, or with few records in view, the records themselves. Nearby records share a marker with their count; choosing one shows the record's card at the map's bottom, with arrows through the marker's records, and choosing the map elsewhere or closing the card clears it. The card is the one of the cards display `cards` names, else the list's first cards display, else the record's title. A record at an approximate position has a hollow marker and the area around it; see [Approximate positions](#approximate-positions). Named `map` unless `name` says otherwise. See [Maps](#maps). |
|
|
307
|
-
| `d.board({ by, title?, subtitle?, badge?, meta? }, { name?, label?, icon? })` | A column per value of the enum field `by`, each with how many records have it, and a card per record that opens it: `title` (default: the view's `.title`) over `subtitle`, with `badge` and a few small `meta` fields, as the built-in card of `d.cards` draws them.
|
|
326
|
+
| `d.board({ by, title?, subtitle?, badge?, meta? }, { name?, label?, icon? })` | A column per value of the enum field `by`, each with how many records have it, and a card per record that opens it: `title` (default: the view's `.title`) over `subtitle`, with `badge` and a few small `meta` fields, as the built-in card of `d.cards` draws them. With the list's `drag: { board: true }`, dragging a card to another column, or moving it with the keyboard, saves the record with that column's value; with `drag: { rank: true }`, cards are reordered within a column when the resource has a `.position()`. Named `board` unless `name` says otherwise. See [Boards](#boards). |
|
|
308
327
|
| `d.calendar({ start, end?, title? }, { name?, label?, icon? })` | The records on the days from their date or timestamp field `start` to `end`, or on their start day alone, in a month grid or a week grid, each event a link to its record showing `title` (default: the view's `.title`). Dragging an event to another day, or moving it with the keyboard, saves the record with `start` and `end` moved by the same days. Named `calendar` unless `name` says otherwise. See [Calendars](#calendars). |
|
|
309
328
|
| `d.timeline({ start, end?, group?, title? }, { name?, label?, icon? })` | A Gantt-style timeline: each record a row with a bar from its date or timestamp field `start` to `end`, or on its start day alone, over a week, a month or a quarter, in lanes by the values of `group`. Each bar is a link to its record showing `title` (default: the view's `.title`). Dragging a bar along its row, or moving it with the keyboard, saves the record with `start` and `end` moved by the same days. Named `timeline` unless `name` says otherwise. See [Timelines](#timelines). |
|
|
310
329
|
| `d.custom(Component, { name, label, fields, props?, icon? })` | The rows drawn by a [custom component](custom-components.md#list-displays)). `fields` are the fields it shows, loaded with the names of the records relations point at; `props` are plain data, with `r.field` where it takes a field. |
|
|
@@ -321,14 +340,15 @@ Display names are checked when the config loads: unique, not `table`, and `defau
|
|
|
321
340
|
|
|
322
341
|
Each column reads its own records through the list API, with the list's filter, search and order and its value added, such as `(search("brompton")) AND status = "ready"`, page by page with **Show more** at its bottom. A filter on `by` itself leaves the other columns empty. The sort menu orders the cards in every column, unless the resource has a position. In an embedded list each column shows its first records, up to the list's limit, and **View all** opens the whole board.
|
|
323
342
|
|
|
324
|
-
|
|
343
|
+
With the list's `drag: { board: true }` (see [Dragging in the list](#dragging-in-the-list)), a card moves to another column by dragging it, by a long press and drag on a touch screen, or from the keyboard: Space on a card picks it up, the left and right arrow keys move it between columns, Space or Enter drops it and Escape puts it back; a screen reader is told each step. A move is one update of the record, `by` set to the column's value with the ETag the card was listed with, the same request a named [`a.update`](layouts.md#named-actions)) sends. So the resource's [access rules](access.md)) and `validate` decide: the card shows in its new column at once, a refused move puts it back with the server's reason, such as `validate`'s message, and a record changed by someone else since it was listed is refused too, as a stale ETag is. Every list of the resource reloads afterwards. A user who may not update the resource, or the `by` field, or a record its [row filters](access.md#restricted-model-and-row-filters)) keep them from updating, can open its card but not move it.
|
|
325
344
|
|
|
326
345
|
A resource with a [`.position(...)`](data-config.md#resource)) and no `within` has its board's columns in that order instead of the list's, so the board has no sort menu:
|
|
327
346
|
|
|
328
347
|
```ts title="docs-examples/reference/ranked-board.ts"
|
|
329
348
|
import { f, resource, view } from '@protobase/schema'
|
|
330
349
|
|
|
331
|
-
// A team's tasks on a board in the order of their rank, each
|
|
350
|
+
// A team's tasks on a board in the order of their rank, each card dragged to its place in a column or to another
|
|
351
|
+
// column, and the table in the same order, its rows dragged too.
|
|
332
352
|
|
|
333
353
|
export const tasks = resource('tasks')
|
|
334
354
|
.table('tasks')
|
|
@@ -343,10 +363,16 @@ export const tasks = resource('tasks')
|
|
|
343
363
|
|
|
344
364
|
export const tasksView = view<typeof tasks>('tasks')
|
|
345
365
|
.title((r) => r.title)
|
|
346
|
-
.list((r, d) => ({
|
|
366
|
+
.list((r, d) => ({
|
|
367
|
+
columns: [r.title, r.status],
|
|
368
|
+
sort: [[r.rank, 'asc']],
|
|
369
|
+
displays: [d.board({ by: r.status })],
|
|
370
|
+
default: 'board',
|
|
371
|
+
drag: { rank: true, board: true },
|
|
372
|
+
}))
|
|
347
373
|
```
|
|
348
374
|
|
|
349
|
-
|
|
375
|
+
With the list's `drag: { rank: true }`, a card then moves within its column by dragging it, or from the keyboard: Space, the up and down arrow keys, and Space again. In another column it lands where it is dropped, before the card under it or after the last one; the left and right arrow keys put it at the top. A screen reader is told the column and the place. A drop is one [batch write](api.md#batch-writes)): in another column first the update of `by` with the card's ETag, then a `reorder` numbering the column's cards 1, 2, 3, ... down to the last one that moved, each with its ETag. So access, `validate` and a stale ETag refuse it as they do a column move, and a refusal puts the cards back with the reason. The numbers are per column after a drop, so a unique index on the position alone would clash, while one that includes `by` is fine. Changing the order takes the right to update the position field, as **Reorder** does; a user without it, or a board without `rank`, moves cards between columns only, as on a board without a position, and one without `board` keeps each card in its column. A resource without a position, or with `within`, keeps the list's order.
|
|
350
376
|
|
|
351
377
|
`by` must be a filterable enum field, checked when the config loads and when the server starts, since each column filters by it. [`protobase doctor`](cli.md#doctor)) checks that an index serves each column's filter in the list's order, or the position's, as it does the list's. In `/api/meta`, a user who cannot read `by` gets the list without the board, opening in the table when it was the default, and a card loses the fields they cannot read.
|
|
352
378
|
|