@protobase/cli 0.23.11 → 0.23.13

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
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.23.11";
2
+ var version = "0.23.13";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.23.11",
3
+ "version": "0.23.13",
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.23.11",
39
- "@protobase/query": "0.23.11",
40
- "@protobase/schema": "0.23.11",
41
- "@protobase/server": "0.23.11",
42
- "@protobase/ui": "0.23.11",
38
+ "@protobase/layout": "0.23.13",
39
+ "@protobase/query": "0.23.13",
40
+ "@protobase/schema": "0.23.13",
41
+ "@protobase/server": "0.23.13",
42
+ "@protobase/ui": "0.23.13",
43
43
  "@react-email/render": "^2.1.0",
44
44
  "@scalar/hono-api-reference": "^0.12.10",
45
45
  "@tailwindcss/vite": "^4.3.3",
@@ -2,12 +2,22 @@
2
2
 
3
3
  # Getting started
4
4
 
5
- Install the repository, run the ERP, real estate and property portal examples and learn the development commands.
5
+ Start an app with npm create protobase, install the repository, run the ERP, real estate and property portal examples and learn the development commands.
6
6
 
7
7
  Protobase is a config-driven admin panel framework for existing Postgres databases. Data config lives in `data.ts`, UI config in `ui.ts`; a Hono server serves the API and a React app renders the admin. Coding agents get the guides and reference of the installed version with [`protobase skill install`](reference/cli.md#skill)).
8
8
 
9
9
  An app's own React code, its components, field types and actions, is a [plugin](reference/plugins.md)): built on its own against a plugin API that Protobase's releases keep, and loaded by the admin app when it starts. Protobase maintains the admin app, the API and the server, and a plugin keeps working as the app moves to newer releases, with their fixes and features, without changes of its own. Below 1.0 a new minor version may still change the config, and the bundle is built again for it; the plugins' code stays as it is (see [Who maintains what](reference/plugins.md#who-maintains-what))).
10
10
 
11
+ ## Start an app
12
+
13
+ `npm create protobase my-app` writes a new project from scratch 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, create a user and run `bun run dev`. It needs Node 22.12 or later.
14
+
15
+ ```sh
16
+ npm create protobase my-app
17
+ ```
18
+
19
+ The rest of this page works in a clone of this repository, on its examples.
20
+
11
21
  ## Setup
12
22
 
13
23
  Requires Bun 1.4.2, which installs the repository and runs its scripts and tests, and Node 22.12 or later (`.nvmrc`) for the smoke test on Node.
@@ -75,4 +85,4 @@ bun run --cwd examples/property-portal dev # http://localhost:5173
75
85
  | `bun run release --dry-run` | the next version and its changelog, from the commits since the last release (see [Versioning](reference/versioning.md))) |
76
86
  | `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 |
77
87
 
78
- 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. See [Architecture](reference/architecture.md)) for the layout and import rules.
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 the from-scratch preset. See [Architecture](reference/architecture.md)) for the layout and import rules.
@@ -168,11 +168,11 @@ The rules behind these steps are described under [Access](#access).
168
168
  | `create` | `resource`, `data`, `ref?` |
169
169
  | `update` | `resource`, `key`, `etag` (required, `*` allowed), `data` |
170
170
  | `delete` | `resource`, `key`, `etag?` |
171
- | `reorder` | `resource`, `field`, `keys` (in final order), `etags` (per key text) |
171
+ | `reorder` | `resource`, `field`, `keys` (in final order), `start` (optional, 1 by default), `etags` (per key text) |
172
172
 
173
173
  - **Keys** are the URL text (`a,b` when composite), a number, a list of parts, or a reference.
174
174
  - **`$ref`**: `ref: 'invoice'` on a create names the record; later operations use `{ "$ref": "invoice" }` as a key, a key part, or a value in `data` (it stands for that record's key, or with `{ "$ref": "invoice", "field": "number" }` a readable field's value). A ref must come after its create.
175
- - **`reorder`** sets `field` to 1, 2, 3, ... in the order of `keys`, and writes only the records whose value changes, each as an ordinary update (so each needs its `etags` entry, and hooks see each). To work with a non-deferrable unique index such as `(invoice_id, position)`, the changing records are first moved out of the range in use, in the same transaction and without touching their ETags: above the highest value of the column, or, when a check constraint refuses that (checked with a savepoint), below the lowest one. Then they get their final values, which collide with nothing. The field must be an integer the caller may write; the keys must all exist and be visible to the caller.
175
+ - **`reorder`** sets `field` to `start`, `start` + 1, ... in the order of `keys`, so a long list sends only the stretch that moved, and writes only the records whose value changes, each as an ordinary update (so each needs its `etags` entry, and hooks see each). To work with a non-deferrable unique index such as `(invoice_id, position)`, the changing records are first moved out of the range in use, in the same transaction and without touching their ETags: above the highest value of the column, or, when a check constraint refuses that (checked with a savepoint), below the lowest one. Then they get their final values, which collide with nothing. The field must be an integer the caller may write; the keys must all exist and be visible to the caller.
176
176
  - **Result**: `{ results: [...] }`, one entry per operation in order: `create` and `update` give `record` and `etag`, `delete` gives `deleted: true`, `reorder` gives `records` (every key in order, with its etag).
177
177
  - **Failure**: nothing is written. The problem is the failing operation's own (`400`, `403`, `404`, `409`, `412`, `428`, ...) with `operation` (its index), `op` and `resource` added. A stale ETag anywhere is a `412` for the whole batch.
178
178
 
@@ -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; they are not on npm. 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.
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; they are not on npm, except the from-scratch one, which `npm create protobase` (`packages/create-protobase`) writes. 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
 
@@ -62,7 +62,7 @@ export const repairs = resource('repairs')
62
62
  | `.tenant((r) => r.organization_id)` | The column that separates tenants: every query is limited to the caller's tenant, creates set it, and a request body may not. |
63
63
  | `.owner((r) => r.owner_id)` | The field holding the owning user's id, which `.own` capabilities filter on (see [Access](#access)). |
64
64
  | `.search((r) => [r.number, r.name])` | The fields that `search("...")` and bare words in a filter match, and what the admin's [global search](client.md#global-search)) looks in. Every word of the text must appear in one of them, ignoring case, and part of a word is enough: `port` finds "Portfolio". `r.phone.digitsEnd()` matches only the end of a field's digits instead, ignoring spaces, `+` and dashes, and only words written like phone numbers: `9623`, `47069623` and `+31 6 47069623` find "+31 6 47069623", `4706` and `+316` do not. Each field needs a pg_trgm index (`using gin (name gin_trgm_ops)`), a `digitsEnd` one on `regexp_replace(phone, '[^0-9]', '', 'g')`, or the API refuses the search. |
65
- | `.position((r) => r.position, { within? })` | The integer field holding the records' order by hand, 1 the first, which a list's **Sort** button changes by dragging; with `within: (r) => r.invoice_id`, a filterable relation, each parent's records have an order of their own, sorted in its related section. The field must be sortable. See [Sorting by hand](ui-config.md#sorting-by-hand)). |
65
+ | `.position((r) => r.position, { within? })` | The integer field holding the records' order by hand, 1 the first, which a list's **Reorder** button changes by dragging; with `within: (r) => r.invoice_id`, a filterable relation, each parent's records have an order of their own, sorted in its related section. The field must be sortable. See [Reordering by hand](ui-config.md#reordering-by-hand)). |
66
66
  | `.validate((record) => issues)` | A rule over the whole record, run after the field checks on every create and update. It returns `[{ field, message }]` or `undefined`; issues answer `400` with the field named. |
67
67
  | `.access({ ... })` | Rules per operation. See [Access](#access). |
68
68
  | `.events((e, r) => [...])` | What changes of its records mean, such as `orders.created`, captured in the database for every write. See [Events](events.md)). |
@@ -135,7 +135,7 @@ Access needs nothing more: `/meta` keeps `editable` to the fields the user may w
135
135
 
136
136
  An editable column is a field of the resource with an editor of one line that the API may write: text that is neither `.multiline()` nor `.markdown()`, a number, a date, an enum, a boolean, a currency or a country. A relation is chosen and a file uploaded on the record page. The server refuses at startup an editable field outside the columns, a read-only one, or one of another type, and `.list(...)` throws on one that is not among its columns. Cards, maps and embedded lists show the values without editing them.
137
137
 
138
- ### Sorting by hand
138
+ ### Reordering by hand
139
139
 
140
140
  Records with an order of their own, such as the products in the order a shop lists them or an invoice's items in the order it prints them, are put in order by dragging them. The resource names the integer field that holds the order with [`.position(...)`](data-config.md#resource)), 1 the first; with `within`, a relation, each parent's records have an order of their own:
141
141
 
@@ -193,11 +193,11 @@ export const invoiceItemsView = view<typeof invoiceItems>('invoice_items')
193
193
  .list((r) => ({ columns: [r.description, r.amount], sort: [[r.position, 'asc']] }))
194
194
  ```
195
195
 
196
- The list of a resource ordered as one, such as the products, has a **Sort** 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. **Sort** 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.
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)) numbers the records 1, 2, 3, ... in their new order, writing those whose number changes with the ETags they were listed with, so a gap or a tie left by an earlier write is closed too. 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 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
- A user who may not update the resource or write the field gets no **Sort**, 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. At most 500 records are sorted at once, the list API's largest page; with more, **Sort** says so instead. 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.
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
202
  ## A filter the list opens with
203
203
 
@@ -772,7 +772,7 @@ export const unitsView = view<typeof units>('units')
772
772
  ])
773
773
  ```
774
774
 
775
- When `resource` is ordered by hand within the record on the page (`.position(..., { within })` names `field`), the section has a **Sort** button that puts its records in order by dragging them; see [Sorting by hand](#sorting-by-hand).
775
+ When `resource` is ordered by hand within the record on the page (`.position(..., { within })` names `field`), the section has a **Reorder** button that puts its records in order by dragging them; see [Reordering by hand](#reordering-by-hand).
776
776
 
777
777
  Every name is checked when the config loads. In `/meta` a caller who cannot read a resource the section names, or a field its filter or sort uses, does not get the section, and columns they cannot read are left out; the rows come from the list API with the caller's token, so row filters apply as everywhere else.
778
778