@protobase/cli 0.39.0 → 0.39.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 +6 -6
- package/skills/protobase/references/guides/deploy.md +21 -5
- package/skills/protobase/references/reference/access.md +1 -1
- package/skills/protobase/references/reference/auth.md +3 -3
- package/skills/protobase/references/reference/cli.md +1 -1
- package/skills/protobase/references/reference/data-config.md +2 -0
- package/skills/protobase/references/reference/ui-config.md +1 -1
package/dist/cli/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.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": {
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"@better-auth/core": "^1.7.12",
|
|
37
37
|
"@hono/node-server": "^2.1.3",
|
|
38
38
|
"@hono/vite-dev-server": "^0.26.1",
|
|
39
|
-
"@protobase/layout": "0.39.
|
|
40
|
-
"@protobase/query": "0.39.
|
|
41
|
-
"@protobase/schema": "0.39.
|
|
42
|
-
"@protobase/server": "0.39.
|
|
43
|
-
"@protobase/ui": "0.39.
|
|
39
|
+
"@protobase/layout": "0.39.1",
|
|
40
|
+
"@protobase/query": "0.39.1",
|
|
41
|
+
"@protobase/schema": "0.39.1",
|
|
42
|
+
"@protobase/server": "0.39.1",
|
|
43
|
+
"@protobase/ui": "0.39.1",
|
|
44
44
|
"@react-email/render": "^2.1.0",
|
|
45
45
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
46
46
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -40,7 +40,7 @@ Every release pushes two public images to GitHub's registry, for `linux/amd64` a
|
|
|
40
40
|
| `ghcr.io/prototeamhq/protobase-dev:<version>` | Bun and the presets at `/opt/protobase/presets/<name>` (`erp`, `real-estate`, `scratch`), with the dependencies they share installed in `/workspace` and Bun's cache in `/opt/bun-cache`. It has no Node: the presets' scripts and the `protobase` command run on Bun. It runs as `bun` (1000) |
|
|
41
41
|
|
|
42
42
|
```sh
|
|
43
|
-
docker run -v "$PWD/dist:/app:ro" -p 8787:8787 -e DATABASE_URL -e BETTER_AUTH_SECRET ghcr.io/prototeamhq/protobase:0.2.0
|
|
43
|
+
docker run -v "$PWD/dist:/app:ro" -p 127.0.0.1:8787:8787 -e DATABASE_URL -e BETTER_AUTH_SECRET ghcr.io/prototeamhq/protobase:0.2.0
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
In `protobase-dev`, copy a preset into `/workspace` and `bun install --frozen-lockfile` has nothing to do; installed anywhere else, it comes from the cache, without the network.
|
|
@@ -85,9 +85,10 @@ APP_DB_PASSWORD=... # openssl rand -hex 24
|
|
|
85
85
|
```sh
|
|
86
86
|
BETTER_AUTH_SECRET=... # openssl rand -base64 32
|
|
87
87
|
BETTER_AUTH_URL=http://localhost:8787
|
|
88
|
+
PROTOBASE_TRUSTED_PROXIES=172.30.87.1
|
|
88
89
|
```
|
|
89
90
|
|
|
90
|
-
`BETTER_AUTH_URL` is the address the browser opens, exactly: sign-in from `http://127.0.0.1:8787` is refused as another origin. Add the app's other variables to `app.env` too.
|
|
91
|
+
`BETTER_AUTH_URL` is the address the browser opens, exactly: sign-in from `http://127.0.0.1:8787` is refused as another origin. `PROTOBASE_TRUSTED_PROXIES` is the compose network's gateway, which every connection through the published port comes from, a reverse proxy's included; trusting it lets the sign-in limits count each client by the proxy's `X-Forwarded-For` (see [Client addresses](../reference/auth.md#client-addresses))). Add the app's other variables to `app.env` too.
|
|
91
92
|
|
|
92
93
|
```yaml
|
|
93
94
|
services:
|
|
@@ -137,15 +138,30 @@ configs:
|
|
|
137
138
|
|
|
138
139
|
volumes:
|
|
139
140
|
db:
|
|
141
|
+
|
|
142
|
+
networks:
|
|
143
|
+
default:
|
|
144
|
+
ipam:
|
|
145
|
+
config:
|
|
146
|
+
- subnet: 172.30.87.0/24
|
|
147
|
+
gateway: 172.30.87.1
|
|
140
148
|
```
|
|
141
149
|
|
|
142
|
-
`docker compose up -d` starts Postgres, runs `migrate` once and starts the app only when it succeeded. The app and `migrate` connect as `app`, which owns its database but is no superuser (see the [assistant](../reference/assistant.md)) on why that matters); the superuser's password stays in `.env` and the `postgres` service. Postgres runs the init file only on an empty volume. `configs` with `content` needs a recent Compose v2 (tested with 2.39.4).
|
|
150
|
+
`docker compose up -d` starts Postgres, runs `migrate` once and starts the app only when it succeeded. The app and `migrate` connect as `app`, which owns its database but is no superuser (see the [assistant](../reference/assistant.md)) on why that matters); the superuser's password stays in `.env` and the `postgres` service. Postgres runs the init file only on an empty volume. `configs` with `content` needs a recent Compose v2 (tested with 2.39.4). The network's addresses are fixed so that `app.env` can name its gateway: if `172.30.87.0/24` is taken on the host, `up` stops with "Pool overlaps", so pick another range and change the gateway in `app.env` to match.
|
|
143
151
|
|
|
144
152
|
### Local only by default
|
|
145
153
|
|
|
146
154
|
The template publishes the app on `127.0.0.1:8787` only, so only the machine running it can open `http://localhost:8787`, and it speaks plain HTTP. To try it on a remote server, tunnel it with `ssh -L 8787:localhost:8787 <server>` and open `http://localhost:8787` on your own machine.
|
|
147
155
|
|
|
148
|
-
Before other machines may reach it, put HTTPS in front: a reverse proxy on the host that forwards to `127.0.0.1:8787`,
|
|
156
|
+
Before other machines may reach it, put HTTPS in front: a reverse proxy on the host that forwards to `127.0.0.1:8787`, such as Caddy with this Caddyfile, which gets the certificate itself and adds the client's address to `X-Forwarded-For`:
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
app.example.com {
|
|
160
|
+
reverse_proxy 127.0.0.1:8787
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Then set `BETTER_AUTH_URL=https://app.example.com` in `app.env` and run `docker compose up -d` to apply it. Only then are the session cookies `Secure` and passwords and codes encrypted on the way. Another proxy must also append the client's address to `X-Forwarded-For` (see [Client addresses](../reference/auth.md#client-addresses))), or every visitor shares one sign-in limit. Do not change the port to `8787:8787`: that publishes plain HTTP on every interface, ahead of host firewall rules such as ufw. On Docker Engine older than 28.0, hosts on the same local network can still reach a port published to `127.0.0.1`, so use 28.0 or newer.
|
|
149
165
|
|
|
150
166
|
### First admin
|
|
151
167
|
|
|
@@ -153,7 +169,7 @@ Before other machines may reach it, put HTTPS in front: a reverse proxy on the h
|
|
|
153
169
|
docker compose run --rm --no-deps app create-admin /app you@example.com --generate-password
|
|
154
170
|
```
|
|
155
171
|
|
|
156
|
-
Then open `
|
|
172
|
+
Then open the address in `BETTER_AUTH_URL` and sign in with that email and the printed password: `https://app.example.com` once the proxy is in front, `http://localhost:8787` (or the SSH tunnel) only while `BETTER_AUTH_URL` is still `http://localhost:8787`, since sign-in from any other address is refused as another origin. `--no-deps` keeps compose from running `migrate` first, which during an upgrade would migrate under the old version while it serves; use it with every `docker compose run … app`. Where container logs leave the host, pass the password on stdin instead: `docker compose run --rm --no-deps -T app create-admin /app you@example.com --password-stdin < password.txt`.
|
|
157
173
|
|
|
158
174
|
### Upgrade
|
|
159
175
|
|
|
@@ -118,7 +118,7 @@ A field rule goes from the field to the roles: `cost_price` above is hidden from
|
|
|
118
118
|
|
|
119
119
|
### Write-only fields
|
|
120
120
|
|
|
121
|
-
A role writes a field it cannot read only when the field's own `create` or `update` rule allows it: `f.text().access({ read: roles.is('loop'), create: roles.is('admin'), update: roles.is('admin') })` lets `admin` set a value only `loop` reads. A write rule the field follows from its resource never does, so hiding a field from a role does not let everyone who updates the resource overwrite it. The value is in no response, history, export or webhook of the writer, and `/meta`
|
|
121
|
+
A role writes a field it cannot read only when the field's own `create` or `update` rule allows it: `f.text().access({ read: roles.is('loop'), create: roles.is('admin'), update: roles.is('admin') })` lets `admin` set a value only `loop` reads. A write rule the field follows from its resource never does, so hiding a field from a role does not let everyone who updates the resource overwrite it. The value is in no response, history, export or webhook of the writer, and no reveal shows it to them. `/meta` gives the writer the field marked `writeOnly: true`, sensitive and neither filterable nor sortable, and keeps it in the view's record sections and field hints only, so the admin app edits it only where a section of the layout names it: as a password-style input to type a new value in, with no stored value or eye to reveal one, never kept in a form's unsaved changes, and nowhere on the read view. The record's `permissions.fields` lists it as `edit` where the writer may update it. A file field, or the field a resource orders its records by (`.position()`), is never write-only, and no `reorder` orders by a write-only field.
|
|
122
122
|
|
|
123
123
|
## Records that belong to another
|
|
124
124
|
|
|
@@ -80,7 +80,7 @@ The columns Better Auth needs that the table lacks, filled from what the other s
|
|
|
80
80
|
| `PROTOBASE_APP_NAME` | the app's name, passed by the platform: it overrides `appName` |
|
|
81
81
|
| `PROTOBASE_SIGN_IN_ISSUER`, `PROTOBASE_SIGN_IN_CLIENT_ID`, `PROTOBASE_SIGN_IN_CLIENT_SECRET` | the [platform sign-in provider](#platform-sign-in-provider) for people who have an account, passed by the platform; off without them. `PROTOBASE_SIGN_IN_PROVIDER` and `PROTOBASE_SIGN_IN_NAME` are optional |
|
|
82
82
|
| `PROTOBASE_OPERATOR_ISSUER`, `PROTOBASE_OPERATOR_CLIENT_ID`, `PROTOBASE_OPERATOR_CLIENT_SECRET` | the [operator provider](#operator-provider) its staff sign in with to sign in as people, passed by the platform; staff sign-in is off without them. `PROTOBASE_OPERATOR_NAME` and `PROTOBASE_OPERATOR_GROUP` are optional |
|
|
83
|
-
| `PROTOBASE_TRUSTED_PROXIES` | the proxies in front of `protobase serve`, addresses or CIDR ranges, comma separated, such as `172.
|
|
83
|
+
| `PROTOBASE_TRUSTED_PROXIES` | the proxies in front of `protobase serve`, addresses or CIDR ranges, comma separated, such as `172.30.87.1`, the Docker network's gateway in the [compose template](../guides/deploy.md#compose-template)); see [Client addresses](#client-addresses) |
|
|
84
84
|
|
|
85
85
|
- Cookies are `SameSite=Lax`, and `Secure` when `BETTER_AUTH_URL` is https.
|
|
86
86
|
- Sign-in is rate limited (5 password attempts per minute and client by default, `signInPerMinute`, which also limits [sign-up](#open-sign-up) requests; 3 per minute for emailed codes); [Client addresses](#client-addresses) says how a client is known.
|
|
@@ -91,8 +91,8 @@ The columns Better Auth needs that the table lacks, filled from what the other s
|
|
|
91
91
|
|
|
92
92
|
The rate limits count each client address on its own: an IPv4 address, or an IPv6 address by its /64. `protobase serve` and the runtime image find it themselves and pass it on in `X-Forwarded-For`, replacing whatever the client sent:
|
|
93
93
|
|
|
94
|
-
- Without `PROTOBASE_TRUSTED_PROXIES`, the client is the address the connection comes from. That fits
|
|
95
|
-
- Behind a reverse proxy (Caddy, nginx, Traefik, a load balancer), every connection comes from the proxy, so every client would share its one limit, and three emailed codes a minute from anyone would stop everyone signing in. Set `PROTOBASE_TRUSTED_PROXIES` to the proxy's address, or the
|
|
94
|
+
- Without `PROTOBASE_TRUSTED_PROXIES`, the client is the address the connection comes from. That fits clients that reach the server directly, such as a browser on the same machine as `docker run -p 127.0.0.1:8787:8787`.
|
|
95
|
+
- Behind a reverse proxy (Caddy, nginx, Traefik, a load balancer), every connection comes from the proxy, so every client would share its one limit, and three emailed codes a minute from anyone would stop everyone signing in. Set `PROTOBASE_TRUSTED_PROXIES` to the proxy's address, or the Docker network's gateway for a proxy on the host, such as `172.30.87.1` in the deploy guide's [compose template](../guides/deploy.md#compose-template)); a range must not cover the clients themselves, or they all share the one limit again. Have the proxy append the address it took the request from to `X-Forwarded-For` (Caddy and Traefik do by default, nginx with `proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for`). The client is then the rightmost address in it that is not a trusted proxy, so one the client wrote itself counts for nothing. Behind several proxies, such as a CDN in front of Caddy, trust them all.
|
|
96
96
|
|
|
97
97
|
An app served another way than `protobase serve`, such as its own server around `createAdmin`, gets what its server passes: the limits read `X-Forwarded-For` holding one address, and requests without one share a single limit.
|
|
98
98
|
|
|
@@ -312,7 +312,7 @@ COPY --from=libs /out/ /
|
|
|
312
312
|
```
|
|
313
313
|
|
|
314
314
|
```sh
|
|
315
|
-
docker run --rm -p 8787:8787 -e DATABASE_URL -e BETTER_AUTH_SECRET \
|
|
315
|
+
docker run --rm -p 127.0.0.1:8787:8787 -e DATABASE_URL -e BETTER_AUTH_SECRET \
|
|
316
316
|
-v "$PWD/dist:/app:ro" -v "$PWD/protobase-serve.js:/opt/protobase/protobase-serve.js:ro" \
|
|
317
317
|
protobase-run --no-install /opt/protobase/protobase-serve.js /app/protobase.config.js
|
|
318
318
|
```
|
|
@@ -204,6 +204,8 @@ A sensitive field, such as a bank account number, is written like any other fiel
|
|
|
204
204
|
iban: f.text().sensitive().access({ read: roles.can('screening.read') }),
|
|
205
205
|
```
|
|
206
206
|
|
|
207
|
+
A role may also set a sensitive field it cannot read, such as a sealed value only a worker reads, when the field's own `create` or `update` rule allows it: see [write-only fields](access.md#write-only-fields)).
|
|
208
|
+
|
|
207
209
|
A sensitive field cannot be `.filterable()`, `.sortable()`, aliased, searched, or the key, tenant, owner or soft delete field, and a view may only put it in a record page section: in a list, filter, chart, sidebar, title, recent-record group or action it would always be empty, so the config fails to load.
|
|
208
210
|
|
|
209
211
|
A [webhook subscription](webhooks.md)) delivering `as` a role runs that role's access rules on a captured change, which holds no sensitive field. A rule or row filter that reads one there throws, and the change is kept as failed for that subscription instead of delivered, so decide that access on a field that is not sensitive. A rule that reads the field before it checks the role, such as `record.api_secret == null || ctx.user.roles.includes('admin')`, fails even for `as: { roles: ['admin'] }`: check the role first, as in `ctx.user.roles.includes('admin') || ...`.
|
|
@@ -610,7 +610,7 @@ export const repairsView = filtered
|
|
|
610
610
|
|
|
611
611
|
A custom component draws only its part: the page around it stays the record page, at `/<resource>/<key>`, with its breadcrumbs, Save, the action rail with Edit and Delete, and the related records, and a layout may hold only custom components. The repairs above list the customer's earlier repairs under the bike:
|
|
612
612
|
|
|
613
|
-
Without a layout the record page shows one section with every field the user may change; its [read view](#read-view-and-edit), which is what a user who may change none gets, shows every field. A section or sidebar card with no field the user may see is left out. The record's title is the page's heading, above the sections, with an enum `status` as a badge beside it unless the sidebar shows it already. `.saveFeedback('button')` shows saving on the Save button instead of a toast (`'toast'`, the default). A [sensitive field](data-config.md#sensitive-fields)) in a section is masked, with an eye button that reveals it.
|
|
613
|
+
Without a layout the record page shows one section with every field the user may change; its [read view](#read-view-and-edit), which is what a user who may change none gets, shows every field. A section or sidebar card with no field the user may see is left out. The record's title is the page's heading, above the sections, with an enum `status` as a badge beside it unless the sidebar shows it already. `.saveFeedback('button')` shows saving on the Save button instead of a toast (`'toast'`, the default). A [sensitive field](data-config.md#sensitive-fields)) in a section is masked, with an eye button that reveals it. A [write-only field](access.md#write-only-fields)) is on the form only where a section names it, never in the section without a layout, and shows as an empty input to set a new value in.
|
|
614
614
|
|
|
615
615
|
A record opened from a list, by its row or its card, shows the fields the list loaded at once, with placeholders for the others, and takes input once the whole record has loaded; actions, custom components, maps and galleries wait for it. What the page shows is read again whenever the browser tab or window regains focus, as are the lists, unless the record has unsaved changes, which keep the version they were made to.
|
|
616
616
|
|