@protobase/cli 0.23.12 → 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.12";
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.12",
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.12",
39
- "@protobase/query": "0.23.12",
40
- "@protobase/schema": "0.23.12",
41
- "@protobase/server": "0.23.12",
42
- "@protobase/ui": "0.23.12",
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",
@@ -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
 
@@ -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