@protobase/cli 0.40.7 → 0.40.9

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.
Files changed (53) hide show
  1. package/dist/cli/package.js +1 -1
  2. package/package.json +6 -6
  3. package/skills/protobase/references/getting-started.md +8 -8
  4. package/skills/protobase/references/guides/api-functions.md +12 -12
  5. package/skills/protobase/references/guides/billing-page.md +2 -2
  6. package/skills/protobase/references/guides/create-page.md +5 -5
  7. package/skills/protobase/references/guides/deploy.md +6 -6
  8. package/skills/protobase/references/guides/export-a-list.md +2 -2
  9. package/skills/protobase/references/guides/field-type.md +2 -2
  10. package/skills/protobase/references/guides/first-composed-page.md +4 -4
  11. package/skills/protobase/references/guides/first-plugin.md +3 -3
  12. package/skills/protobase/references/guides/import-records.md +1 -1
  13. package/skills/protobase/references/guides/mobile-app.md +11 -4
  14. package/skills/protobase/references/guides/plugin-build.md +5 -5
  15. package/skills/protobase/references/guides/record-card.md +3 -3
  16. package/skills/protobase/references/guides/remote-resources.md +10 -10
  17. package/skills/protobase/references/guides/table-to-admin.md +5 -5
  18. package/skills/protobase/references/guides/theme-an-app.md +4 -4
  19. package/skills/protobase/references/reference/access.md +9 -9
  20. package/skills/protobase/references/reference/ai.md +6 -6
  21. package/skills/protobase/references/reference/api.md +25 -25
  22. package/skills/protobase/references/reference/app-identity.md +4 -4
  23. package/skills/protobase/references/reference/architecture.md +1 -1
  24. package/skills/protobase/references/reference/assistant.md +6 -6
  25. package/skills/protobase/references/reference/auth.md +20 -20
  26. package/skills/protobase/references/reference/blocks.md +18 -13
  27. package/skills/protobase/references/reference/bottom-bar.md +5 -5
  28. package/skills/protobase/references/reference/cli.md +63 -63
  29. package/skills/protobase/references/reference/client.md +5 -5
  30. package/skills/protobase/references/reference/comments.md +8 -8
  31. package/skills/protobase/references/reference/custom-components.md +18 -18
  32. package/skills/protobase/references/reference/data-config.md +26 -26
  33. package/skills/protobase/references/reference/email.md +8 -8
  34. package/skills/protobase/references/reference/events.md +5 -5
  35. package/skills/protobase/references/reference/files.md +7 -7
  36. package/skills/protobase/references/reference/forms.md +6 -6
  37. package/skills/protobase/references/reference/history.md +7 -7
  38. package/skills/protobase/references/reference/installable-app.md +1 -1
  39. package/skills/protobase/references/reference/jobs.md +5 -5
  40. package/skills/protobase/references/reference/layouts.md +11 -11
  41. package/skills/protobase/references/reference/live.md +4 -4
  42. package/skills/protobase/references/reference/mcp.md +5 -5
  43. package/skills/protobase/references/reference/plugins.md +20 -20
  44. package/skills/protobase/references/reference/remote-resources.md +15 -15
  45. package/skills/protobase/references/reference/sidebar.md +1 -1
  46. package/skills/protobase/references/reference/supabase-realtime.md +2 -2
  47. package/skills/protobase/references/reference/supabase-rest.md +2 -2
  48. package/skills/protobase/references/reference/supabase-storage.md +1 -1
  49. package/skills/protobase/references/reference/theme.md +5 -5
  50. package/skills/protobase/references/reference/ui-config.md +60 -60
  51. package/skills/protobase/references/reference/user-menu.md +3 -3
  52. package/skills/protobase/references/reference/versioning.md +5 -5
  53. package/skills/protobase/references/reference/webhooks.md +7 -7
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.40.7";
2
+ var version = "0.40.9";
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.40.7",
3
+ "version": "0.40.9",
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.40.7",
40
- "@protobase/query": "0.40.7",
41
- "@protobase/schema": "0.40.7",
42
- "@protobase/server": "0.40.7",
43
- "@protobase/ui": "0.40.7",
39
+ "@protobase/layout": "0.40.9",
40
+ "@protobase/query": "0.40.9",
41
+ "@protobase/schema": "0.40.9",
42
+ "@protobase/server": "0.40.9",
43
+ "@protobase/ui": "0.40.9",
44
44
  "@react-email/render": "^2.1.0",
45
45
  "@scalar/hono-api-reference": "^0.12.10",
46
46
  "@tailwindcss/vite": "^4.3.3",
@@ -4,9 +4,9 @@
4
4
 
5
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
- 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)).
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
- 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))).
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
11
  ## Start an app
12
12
 
@@ -37,7 +37,7 @@ bun run --cwd examples/erp protobase users create you@example.com --generate-pas
37
37
  bun run --cwd examples/erp dev # http://localhost:5173
38
38
  ```
39
39
 
40
- `BETTER_AUTH_SECRET` in `examples/erp/.env` signs the session cookies; see [Login with Better Auth](reference/auth.md)). `protobase dev` serves the admin app and the API on one port and reloads both on every change ([CLI](reference/cli.md#dev))).
40
+ `BETTER_AUTH_SECRET` in `examples/erp/.env` signs the session cookies; see [Login with Better Auth](reference/auth.md). `protobase dev` serves the admin app and the API on one port and reloads both on every change ([CLI](reference/cli.md#dev)).
41
41
 
42
42
  ## Run the real estate example
43
43
 
@@ -51,7 +51,7 @@ bun run --cwd examples/real-estate dev # http://localhost:5173
51
51
 
52
52
  ## Run the property portal example
53
53
 
54
- `examples/property-portal` is a public portal of homes for sale and for rent in the Netherlands and Spain, in the style of Funda and Idealista. Visitors browse and filter the listings without signing in, through the [anonymous role](reference/access.md#anonymous-access)); members save searches of the listings that mail them new homes, and keep favorites and notes that only they see. The seed makes two members, `anna@portal.example` and `bram@portal.example`, and an admin, `admin@portal.example`, all with the password `property-portal-demo`.
54
+ `examples/property-portal` is a public portal of homes for sale and for rent in the Netherlands and Spain, in the style of Funda and Idealista. Visitors browse and filter the listings without signing in, through the [anonymous role](reference/access.md#anonymous-access); members save searches of the listings that mail them new homes, and keep favorites and notes that only they see. The seed makes two members, `anna@portal.example` and `bram@portal.example`, and an admin, `admin@portal.example`, all with the password `property-portal-demo`.
55
55
 
56
56
  ```sh
57
57
  bun run db:up && bun run --cwd examples/property-portal db:migrate && bun run --cwd examples/property-portal db:seed --scale small
@@ -70,7 +70,7 @@ bun run --cwd examples/property-portal dev # http://localhost:5173
70
70
  | `bun run test:integration` | the database, subprocess and build tests (projects `integration*`), against the Postgres container, among them the real-Postgres tests (`*.postgres.test.ts`) |
71
71
  | `bun run test:smoke` / `node --run test:smoke` | the CLI on Bun or on Node builds the ERP and serves its bundle, whose `€` must come back intact; part of `test:integration` on Bun |
72
72
  | `bun run presets:write <version> <dir>` | writes each preset to `<dir>/<name>`: a standalone copy of its example with the `@protobase` packages in the range of `<version>`'s major (`>=0.y.z <1` below 1.0, `^x.y.z` from 1.0) and its own `bun.lock` at exactly `<version>`, which must be on npm |
73
- | `bun run images:context` | the build contexts of the `protobase` and `protobase-dev` images in `dist/images`, at the version in `package.json` (see [Deploy](guides/deploy.md#images))) |
73
+ | `bun run images:context` | the build contexts of the `protobase` and `protobase-dev` images in `dist/images`, at the version in `package.json` (see [Deploy](guides/deploy.md#images)) |
74
74
  | `bun run test:presets` | writes each preset as `bun run presets:write` does it and installs it with Bun from npm (so at a published version), then migrates, seeds, checks, tests and builds it on a database of its own, as a role without superuser rights; needs the Postgres container |
75
75
  | `bun run test:postgres` | the Postgres suite in `tests/postgres/` (Vitest project `postgres`): the ERP's medium seed and the planner's statistics on it, and the jobs and event delivery through PgBouncer; needs the Postgres and PgBouncer containers and `bun run test:db postgres` |
76
76
  | `bun run test:db` | builds the template databases the database tests clone for each run (`protobase_test_template`, `real_estate_test_template`, `property_portal_test_template`, all at small scale, and the empty, auth and jobs `snapshot_*_test_template` the real-Postgres and end-to-end tests clone), when missing or older than what they are built from; without them those tests skip. `bun run test:db postgres` builds the Postgres suite's (`protobase_medium_test_template`, the ERP at medium scale), `bun run test:db snapshots` the ones `test:record` records on (`snapshot_*_test_template`). Tests never use the `protobase`, `real_estate` or `property_portal` databases |
@@ -80,10 +80,10 @@ bun run --cwd examples/property-portal dev # http://localhost:5173
80
80
  | `bun run storybook` | Storybook on port 6006 |
81
81
  | `bun run build-storybook` | static Storybook build; its toolbar switches every story between light and dark |
82
82
  | `bun run screenshots` / `bun run screenshots:dark` | screenshots of the stories tagged `website`, in light into `screenshots/`, in dark into `screenshots/dark/` |
83
- | `bun run build:serve` | the serve runtime, `dist/protobase-serve.js` (see [Deploy](guides/deploy.md))) |
83
+ | `bun run build:serve` | the serve runtime, `dist/protobase-serve.js` (see [Deploy](guides/deploy.md)) |
84
84
  | `bun run docs:dev` | this site on port 4321 |
85
85
  | `bun run docs:build` | this site, built into `website/dist/`; fails on broken links |
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
+ | `bun run release --dry-run` | the next version and its changelog, from the commits since the last release (see [Versioning](reference/versioning.md)) |
87
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 |
88
88
 
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.
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.
@@ -4,11 +4,11 @@
4
4
 
5
5
  Endpoints of your own beside the generated REST API, one file each in functions/, acting as the signed-in caller or open to a webhook.
6
6
 
7
- The [REST API](../reference/api.md)) covers reading and writing records. For anything else you write a function: a webhook from a payment provider, a button that makes three writes and then texts the customer, an endpoint for another app. Each function is one file in the project's `functions/` folder, served at `/api/functions/<name>`.
7
+ The [REST API](../reference/api.md) covers reading and writing records. For anything else you write a function: a webhook from a payment provider, a button that makes three writes and then texts the customer, an endpoint for another app. Each function is one file in the project's `functions/` folder, served at `/api/functions/<name>`.
8
8
 
9
9
  If you have used Supabase Edge Functions, this will feel familiar. A function is a Web-standard handler that takes a `Request` and returns a `Response`. Only signed-in callers get in unless the function says otherwise. It has a data client that acts as the caller, and the raw database for privileged work.
10
10
 
11
- The examples below come from Pip's bike shop (see [From a table to an admin](table-to-admin.md))). The repository compiles and tests every one of them.
11
+ The examples below come from Pip's bike shop (see [From a table to an admin](table-to-admin.md)). The repository compiles and tests every one of them.
12
12
 
13
13
  ## A first function
14
14
 
@@ -38,7 +38,7 @@ The app's own `authenticate` checks the token, the same one that guards the REST
38
38
  - **Not functions:** files and folders starting with `_` (shared code, such as `functions/_shared/`), dotfiles, `*.test.ts`, `*.spec.ts` and `*.d.ts`. A folder without an `index.ts` is an error that says so.
39
39
  - **The default export** is `defineFunction(...)` from `@protobase/server`, a bare `(request, context)` handler, or a Hono app. The last two need a signed-in caller.
40
40
  - **Any method** reaches the function, and so does any path below its name. The request's path is the part after `/api/functions/<name>`: `/` for the function itself, `/42/advance` for `/api/functions/workshop/42/advance`. The query string and the body are passed through unchanged.
41
- - **In `protobase.config.ts`,** `functions: { name: fn }` replaces the folder, the same way `config` replaces `config/index.ts`. The functions of [extended configs](../reference/cli.md#extending-a-config)) are kept, and a name used by two configs is an error that names both.
41
+ - **In `protobase.config.ts`,** `functions: { name: fn }` replaces the folder, the same way `config` replaces `config/index.ts`. The functions of [extended configs](../reference/cli.md#extending-a-config) are kept, and a name used by two configs is an error that names both.
42
42
 
43
43
  ## The context
44
44
 
@@ -89,7 +89,7 @@ export default defineFunction({ roles: ['mechanic', 'desk'] }, async (request, {
89
89
  | `update(resource, key, data, { etag }?)` | With `etag`, it fails with `412` when the record changed after it was read. |
90
90
  | `delete(resource, key, { etag }?)` | `{ record, etag }` of the record as it was. It is a soft delete when the resource has one. |
91
91
 
92
- A refusal or a missing record rejects with the problem the REST API would answer, such as `403`, `404` or `412`. Left uncaught, that problem becomes the function's response. Each call is its own transaction. Use the [batch endpoint](../reference/api.md#batch-writes)) when several writes must succeed or fail together.
92
+ A refusal or a missing record rejects with the problem the REST API would answer, such as `403`, `404` or `412`. Left uncaught, that problem becomes the function's response. Each call is its own transaction. Use the [batch endpoint](../reference/api.md#batch-writes) when several writes must succeed or fail together.
93
93
 
94
94
  ### Checking input
95
95
 
@@ -97,9 +97,9 @@ A refusal or a missing record rejects with the problem the REST API would answer
97
97
 
98
98
  ### Roles
99
99
 
100
- `defineFunction({ roles: ['mechanic', 'desk'] }, handler)` lets in callers with at least one of those roles. `defineFunction({ capability: 'vms.update' }, handler)` lets in callers whose roles hold all of that capability ([`roles.holds`](../reference/access.md#wildcards-in-has-can-and-holds))): `*`, `vms.*` or a plain `vms.update`, but not `vms.update.own` or a `vms.update` limited to fields or rows. A wildcard means all of it, so `vms.*` needs a role that holds `vms.*` or `*`. Anyone else gets a `403 function-forbidden` problem before the handler runs. Finer rules belong in the resources' [access rules](../reference/access.md)), which `records` already applies.
100
+ `defineFunction({ roles: ['mechanic', 'desk'] }, handler)` lets in callers with at least one of those roles. `defineFunction({ capability: 'vms.update' }, handler)` lets in callers whose roles hold all of that capability ([`roles.holds`](../reference/access.md#wildcards-in-has-can-and-holds)): `*`, `vms.*` or a plain `vms.update`, but not `vms.update.own` or a `vms.update` limited to fields or rows. A wildcard means all of it, so `vms.*` needs a role that holds `vms.*` or `*`. Anyone else gets a `403 function-forbidden` problem before the handler runs. Finer rules belong in the resources' [access rules](../reference/access.md), which `records` already applies.
101
101
 
102
- In an app with [roles](../reference/access.md)) (`options: { roles }`), a function with neither is closed like a resource without a rule: only callers whose roles hold `*`, such as `admin: ['*']`, may call it, unless `defaultAccess` is `allow`. A function for everyone signed in says so with its roles. In an app without roles, every signed-in caller may call it. A `capability` needs the app's roles, and a function takes `roles` or `capability`, not both: the server refuses to start otherwise.
102
+ In an app with [roles](../reference/access.md) (`options: { roles }`), a function with neither is closed like a resource without a rule: only callers whose roles hold `*`, such as `admin: ['*']`, may call it, unless `defaultAccess` is `allow`. A function for everyone signed in says so with its roles. In an app without roles, every signed-in caller may call it. A `capability` needs the app's roles, and a function takes `roles` or `capability`, not both: the server refuses to start otherwise.
103
103
 
104
104
  ## Public functions and webhooks
105
105
 
@@ -317,7 +317,7 @@ export default defineFunction({ roles: ['desk'] }, async (request, { records })
317
317
 
318
318
  ## Calling a function
319
319
 
320
- From the admin UI, an [action handler](../reference/custom-components.md#action-handlers)) gets a `client` that carries the user's token. `client.invoke` calls a function the way `supabase.functions.invoke` does:
320
+ From the admin UI, an [action handler](../reference/custom-components.md#action-handlers) gets a `client` that carries the user's token. `client.invoke` calls a function the way `supabase.functions.invoke` does:
321
321
 
322
322
  ```tsx
323
323
  // protobase.ui.tsx
@@ -377,7 +377,7 @@ app.onError((error) => {
377
377
  export default app
378
378
  ```
379
379
 
380
- A Hono app's routes start at `/`, because the request path no longer includes `/api/functions/<name>`. The deploy bundle supplies `hono`, `hono/cors`, `hono/http-exception` and `hono/validator` (see [the config module](../reference/cli.md#the-config-module))). Other Hono middleware is bundled with the function, as are its other packages.
380
+ A Hono app's routes start at `/`, because the request path no longer includes `/api/functions/<name>`. The deploy bundle supplies `hono`, `hono/cors`, `hono/http-exception` and `hono/validator` (see [the config module](../reference/cli.md#the-config-module)). Other Hono middleware is bundled with the function, as are its other packages.
381
381
 
382
382
  ### CORS
383
383
 
@@ -391,17 +391,17 @@ Preflight requests are answered before authentication, because a browser sends t
391
391
 
392
392
  ## Errors
393
393
 
394
- - **Problems:** throw an `HttpProblem` (or `badRequest`, `unauthorized`, `forbidden`, `notFound` from `@protobase/server`) to answer with an [RFC 9457 problem](../reference/api.md#errors)). Hono's `HTTPException` works too.
394
+ - **Problems:** throw an `HttpProblem` (or `badRequest`, `unauthorized`, `forbidden`, `notFound` from `@protobase/server`) to answer with an [RFC 9457 problem](../reference/api.md#errors). Hono's `HTTPException` works too.
395
395
  - **Everything else:** any other error, or a handler that returns something other than a `Response`, becomes a `500 internal-error` problem without its message. The error goes to `options.onUnhandledError`, which `protobase dev` and `serve` print.
396
396
 
397
397
  ## Functions moved from Supabase
398
398
 
399
- [`protobase import supabase`](../reference/cli.md#import-supabase)) converts `supabase/functions` into `functions/`. A converted function keeps Supabase's shape, `defineFunction({ supabase: true }, { fetch })`, and keeps working with `@supabase/server` and supabase-js:
399
+ [`protobase import supabase`](../reference/cli.md#import-supabase) converts `supabase/functions` into `functions/`. A converted function keeps Supabase's shape, `defineFunction({ supabase: true }, { fetch })`, and keeps working with `@supabase/server` and supabase-js:
400
400
 
401
- - **At `/api/sb/functions/v1/<name>` too,** so `supabase.functions.invoke` callers do not change. Only a function with `supabase: true` answers there, and any other function answers `404`. There a protected function lets in a request with the app's publishable or secret key in the `apikey` header, and a user token of [`/api/sb/auth/v1`](../reference/auth.md#supabase-js-and-supabasessr)) as the bearer, if any, as Supabase's `verify_jwt` does. A public function lets in anyone. The keys are those of [supabase-js's Realtime](../reference/supabase-realtime.md)): without them, only public functions answer there. As on Supabase, the request's path starts at the function's name (`/<name>/more/parts`), and a CORS preflight reaches the function, which answers it.
401
+ - **At `/api/sb/functions/v1/<name>` too,** so `supabase.functions.invoke` callers do not change. Only a function with `supabase: true` answers there, and any other function answers `404`. There a protected function lets in a request with the app's publishable or secret key in the `apikey` header, and a user token of [`/api/sb/auth/v1`](../reference/auth.md#supabase-js-and-supabasessr) as the bearer, if any, as Supabase's `verify_jwt` does. A public function lets in anyone. The keys are those of [supabase-js's Realtime](../reference/supabase-realtime.md): without them, only public functions answer there. As on Supabase, the request's path starts at the function's name (`/<name>/more/parts`), and a CORS preflight reaches the function, which answers it.
402
402
  - **Its context there** is `{ name, db, caller() }`, where `caller()` resolves to who the key and token make the request: `{ role: 'anon' }` for the publishable key alone, `{ role: 'app' }` for the secret key, or `{ role: 'authenticated', claims }`. There is no `session` and no `records`. The publishable key alone lets callers in, so give `supabase: true` only to functions written for Supabase's `verify_jwt`. Together with `roles` or `capability`, which the address cannot check, it stops startup.
403
403
  - **Supabase's variables:** `protobase dev` sets `SUPABASE_URL` to the app's address with `/api/sb`, where supabase-js finds it, `SUPABASE_ANON_KEY`, `SUPABASE_PUBLISHABLE_KEY` and `SUPABASE_PUBLISHABLE_KEYS` to the publishable key, `SUPABASE_SERVICE_ROLE_KEY`, `SUPABASE_SECRET_KEY` and `SUPABASE_SECRET_KEYS` to the secret key, `SUPABASE_JWKS_URL` to the key set of `/api/sb/auth/v1`, and `SUPABASE_DB_URL` to the database. A variable set in `.env` wins. Under `protobase serve`, set them where the host keeps its settings.
404
- - **`waitUntil(promise)`** from `@protobase/server` takes the place of `EdgeRuntime.waitUntil`. The response goes out at once, and the process waits for the work when it shuts down gracefully. Work still running when the host kills the process is lost. On Protobase Cloud's Starter plan an app stops 30 seconds after its last request, with 10 seconds to finish, so move longer work into a [job](../reference/jobs.md)).
404
+ - **`waitUntil(promise)`** from `@protobase/server` takes the place of `EdgeRuntime.waitUntil`. The response goes out at once, and the process waits for the work when it shuts down gracefully. Work still running when the host kills the process is lost. On Protobase Cloud's Starter plan an app stops 30 seconds after its last request, with 10 seconds to finish, so move longer work into a [job](../reference/jobs.md).
405
405
 
406
406
  ## What functions are not
407
407
 
@@ -6,7 +6,7 @@ Give your customers one page for their plan, billing details, cards and invoices
6
6
 
7
7
  Northwind Labs hosts its apps on your platform. Ada, who looks after their money, signs in once a month with four questions: what are we on, who do you bill, which card do you charge, and what did we pay. Today those answers sit in four lists. This guide gives Ada one page with all four, plus the buttons to act on them.
8
8
 
9
- It builds on [Your first composed page](first-composed-page.md)), so `page`, `Stat`, `Table` and `RecordCard` are familiar. New here: forms in a dialog, actions that delete records or open links, conditions on a record's own fields, and a component written in React. The data is a small billing schema: `plans`, `subscriptions` (with a `plan` relation), `billing_profiles`, `payment_methods` and `invoices`.
9
+ It builds on [Your first composed page](first-composed-page.md), so `page`, `Stat`, `Table` and `RecordCard` are familiar. New here: forms in a dialog, actions that delete records or open links, conditions on a record's own fields, and a component written in React. The data is a small billing schema: `plans`, `subscriptions` (with a `plan` relation), `billing_profiles`, `payment_methods` and `invoices`.
10
10
 
11
11
  ## 1. Your plan
12
12
 
@@ -285,4 +285,4 @@ The rest is familiar: a paged `Table` of invoices spanning two of the three colu
285
285
 
286
286
  If the app has no component registered under a name, the page says so where the component would be, and an action without a handler is disabled:
287
287
 
288
- Next: [Custom components](../reference/custom-components.md)) for the details of `protobase.ui.tsx`, and [Layouts](../reference/layouts.md)) for named actions, conditions and access.
288
+ Next: [Custom components](../reference/custom-components.md) for the details of `protobase.ui.tsx`, and [Layouts](../reference/layouts.md) for named actions, conditions and access.
@@ -4,11 +4,11 @@
4
4
 
5
5
  Replace a resource's create form with a page of the app's own, built from the app's form parts, that creates records through an API function.
6
6
 
7
- Pip's bike shop books repairs at the desk, and a booking is more than a row: the workshop wants to know what the bike needs, in words a customer understands, and the shop's API function plans the job. This guide gives the repairs a page of their own for that, opened by **New** on their list, and lets the API refuse plain creates. It uses the bike shop of the [first guide](table-to-admin.md)).
7
+ Pip's bike shop books repairs at the desk, and a booking is more than a row: the workshop wants to know what the bike needs, in words a customer understands, and the shop's API function plans the job. This guide gives the repairs a page of their own for that, opened by **New** on their list, and lets the API refuse plain creates. It uses the bike shop of the [first guide](table-to-admin.md).
8
8
 
9
9
  ## 1. The page
10
10
 
11
- A create page is a [composed page](../reference/layouts.md)) like any other, with a [component](../reference/custom-components.md#components)) of the project's own in it:
11
+ A create page is a [composed page](../reference/layouts.md) like any other, with a [component](../reference/custom-components.md#components) of the project's own in it:
12
12
 
13
13
  ```tsx
14
14
  // config/pages/book-repair.tsx
@@ -30,7 +30,7 @@ Its `roles` say who may book: they are the people who get the page, and so **New
30
30
 
31
31
  ## 2. The component
32
32
 
33
- The component asks its questions with the [form parts](../reference/custom-components.md#form-parts)) of `@protobase/ui`, so it looks like the app's own forms, and keeps the answers in the address, so a reload keeps them:
33
+ The component asks its questions with the [form parts](../reference/custom-components.md#form-parts) of `@protobase/ui`, so it looks like the app's own forms, and keeps the answers in the address, so a reload keeps them:
34
34
 
35
35
  ```tsx
36
36
  // components/book-repair.tsx, exported from protobase.ui.tsx: export { BookRepair } from './components/book-repair'
@@ -94,7 +94,7 @@ export const repairsView = view<typeof repairs>('repairs')
94
94
 
95
95
  ## 4. Create through a function
96
96
 
97
- With its own page, the shop can make the [API function](api-functions.md)) `book-repair` the only way in: it checks the answers, plans the job and inserts the repair with `db`, which skips the access rules. The resource's API then refuses creates:
97
+ With its own page, the shop can make the [API function](api-functions.md) `book-repair` the only way in: it checks the answers, plans the job and inserts the repair with `db`, which skips the access rules. The resource's API then refuses creates:
98
98
 
99
99
  ```ts
100
100
  // config/repairs/data.ts
@@ -105,4 +105,4 @@ export const repairs = resource('repairs')
105
105
 
106
106
  **New** follows the page, not this rule, so it stays for the desk. **Import** on the list follows the rule, and goes.
107
107
 
108
- The [UI config](../reference/ui-config.md#create-pages)) has the details.
108
+ The [UI config](../reference/ui-config.md#create-pages) has the details.
@@ -12,7 +12,7 @@ bun run build:serve # the runtime the host carries: dist/pro
12
12
  bun --no-install /opt/protobase/protobase-serve.js /app/protobase.config.js # on the host: the API
13
13
  ```
14
14
 
15
- Both builds write plain JavaScript that Node and Bun load as it is. For a host that runs Bun, as the images below do, add `--bun` to either: Bun's bundler then writes the final file, the form Bun loads without transpiling, and the build needs `bun` on `PATH` ([details](../reference/cli.md#the-config-module))).
15
+ Both builds write plain JavaScript that Node and Bun load as it is. For a host that runs Bun, as the images below do, add `--bun` to either: Bun's bundler then writes the final file, the form Bun loads without transpiling, and the build needs `bun` on `PATH` ([details](../reference/cli.md#the-config-module)).
16
16
 
17
17
  The bundle holds three things, more when the project has migrations or the config uses native add-ons:
18
18
 
@@ -28,7 +28,7 @@ dist/
28
28
  plugins and the app's version
29
29
  ```
30
30
 
31
- The host serves `public/` itself and sends only the manifest's `api` paths to the runtime (`/api` and the two OAuth discovery documents of [MCP clients](../reference/auth.md#oauth-for-mcp-clients)), and `/.well-known/webauthn`, for an app on [several origins](../reference/auth.md#several-origins))), so loading the UI never needs a running container. With the UI it sends `X-Frame-Options: DENY` and `Content-Security-Policy: frame-ancestors 'none'`, as `protobase serve` does, so no other site frames the app's pages. The runtime serves the API alone; `protobase serve dist` serves the whole folder the same way, to check a bundle locally. The host passes `DATABASE_URL`, `PORT` (default 8787) and optionally `PROTOBASE_DB_CONNECTIONS` (the connections the app may open, so its functions and jobs leave one to requests, see [`serve`](../reference/cli.md#serve))), `REQUEST_LOG`, `PROTOBASE_SMTP_URL` and `PROTOBASE_MAIL_FROM` (the mail server and sender for [password reset](../reference/auth.md#password-reset)) and emailed sign-in codes) `PROTOBASE_APP_NAME` (the app's name in that mail, see [`appName`](../reference/auth.md#configuration))) `PROTOBASE_SIGN_IN_*` (a provider people with an account sign in with, the [platform sign-in provider](../reference/auth.md#platform-sign-in-provider))) `PROTOBASE_OPERATOR_*` (the provider its staff sign in with for [staff sign-in](../reference/auth.md#staff-sign-in))), `PROTOBASE_ORIGINS` and `PROTOBASE_PASSKEY_DOMAIN` (the app's [other origins](../reference/auth.md#several-origins)) and its passkey domain) `PROTOBASE_CORS_ORIGINS` (the websites that may call its API, see [CORS](../reference/api.md#cors))), `PROTOBASE_TRUSTED_PROXIES` (the proxies in front of the runtime, whose `X-Forwarded-For` names the client the sign-in limits count, see [Client addresses](../reference/auth.md#client-addresses))) and `PROTOBASE_SENTRY_DSN` (the app's [error tracker](../reference/api.md#error-reporting))), plus the project's own settings (`BETTER_AUTH_SECRET`, ...). The runtime and the config module are plain JavaScript for Bun: no install, no TypeScript, no writes. The runtime supplies protobase and the dependencies it runs on the server (`pg`, `postgres`, `kysely`, `better-auth`, ...), so the config module carries only the project's code and the other packages it uses. The runtime serves only bundles built by a compatible Protobase version, below 1.0 the same minor (see [Versioning](../reference/versioning.md#bundles-and-runtimes))), so rebuild the bundle when the host's runtime moves to another one. Serving never changes the database: the bundle carries the project's `db/migrations` as `migrations/`, and the runtime's `migrate <bundle>` applies the pending ones, the app's and the auth schema's, before a new version serves, with no other writes while it runs. It applies them in one transaction behind a lock, recorded in `public.schema_migrations` as the presets' `db:migrate` does, so a database either script migrated is current for the other. A file that would end that transaction (`BEGIN`, `COMMIT`, `ROLLBACK`) or cannot run in one (`create index concurrently`) is refused, and a refused or failing file leaves the database unchanged. The runtime refuses to start while the auth schema lacks a table or column the new version needs (see [migrations](../reference/auth.md#migrations))). The manifest format and the routing rules are in the CLI reference: [`build`](../reference/cli.md#build)), [`build-serve`](../reference/cli.md#build-serve)) and [`serve`](../reference/cli.md#serve)).
31
+ The host serves `public/` itself and sends only the manifest's `api` paths to the runtime (`/api` and the two OAuth discovery documents of [MCP clients](../reference/auth.md#oauth-for-mcp-clients), and `/.well-known/webauthn`, for an app on [several origins](../reference/auth.md#several-origins)), so loading the UI never needs a running container. With the UI it sends `X-Frame-Options: DENY` and `Content-Security-Policy: frame-ancestors 'none'`, as `protobase serve` does, so no other site frames the app's pages. The runtime serves the API alone; `protobase serve dist` serves the whole folder the same way, to check a bundle locally. The host passes `DATABASE_URL`, `PORT` (default 8787) and optionally `PROTOBASE_DB_CONNECTIONS` (the connections the app may open, so its functions and jobs leave one to requests, see [`serve`](../reference/cli.md#serve)), `REQUEST_LOG`, `PROTOBASE_SMTP_URL` and `PROTOBASE_MAIL_FROM` (the mail server and sender for [password reset](../reference/auth.md#password-reset) and emailed sign-in codes) `PROTOBASE_APP_NAME` (the app's name in that mail, see [`appName`](../reference/auth.md#configuration)) `PROTOBASE_SIGN_IN_*` (a provider people with an account sign in with, the [platform sign-in provider](../reference/auth.md#platform-sign-in-provider)) `PROTOBASE_OPERATOR_*` (the provider its staff sign in with for [staff sign-in](../reference/auth.md#staff-sign-in)), `PROTOBASE_ORIGINS` and `PROTOBASE_PASSKEY_DOMAIN` (the app's [other origins](../reference/auth.md#several-origins) and its passkey domain) `PROTOBASE_CORS_ORIGINS` (the websites that may call its API, see [CORS](../reference/api.md#cors)), `PROTOBASE_TRUSTED_PROXIES` (the proxies in front of the runtime, whose `X-Forwarded-For` names the client the sign-in limits count, see [Client addresses](../reference/auth.md#client-addresses)) and `PROTOBASE_SENTRY_DSN` (the app's [error tracker](../reference/api.md#error-reporting)), plus the project's own settings (`BETTER_AUTH_SECRET`, ...). The runtime and the config module are plain JavaScript for Bun: no install, no TypeScript, no writes. The runtime supplies protobase and the dependencies it runs on the server (`pg`, `postgres`, `kysely`, `better-auth`, ...), so the config module carries only the project's code and the other packages it uses. The runtime serves only bundles built by a compatible Protobase version, below 1.0 the same minor (see [Versioning](../reference/versioning.md#bundles-and-runtimes)), so rebuild the bundle when the host's runtime moves to another one. Serving never changes the database: the bundle carries the project's `db/migrations` as `migrations/`, and the runtime's `migrate <bundle>` applies the pending ones, the app's and the auth schema's, before a new version serves, with no other writes while it runs. It applies them in one transaction behind a lock, recorded in `public.schema_migrations` as the presets' `db:migrate` does, so a database either script migrated is current for the other. A file that would end that transaction (`BEGIN`, `COMMIT`, `ROLLBACK`) or cannot run in one (`create index concurrently`) is refused, and a refused or failing file leaves the database unchanged. The runtime refuses to start while the auth schema lacks a table or column the new version needs (see [migrations](../reference/auth.md#migrations)). The manifest format and the routing rules are in the CLI reference: [`build`](../reference/cli.md#build), [`build-serve`](../reference/cli.md#build-serve) and [`serve`](../reference/cli.md#serve).
32
32
 
33
33
  ## Images
34
34
 
@@ -36,7 +36,7 @@ Every release pushes two public images to GitHub's registry, for `linux/amd64` a
36
36
 
37
37
  | Image | What it holds |
38
38
  | --- | --- |
39
- | `ghcr.io/prototeamhq/protobase:<version>` | the serve runtime, compiled with Bun into `/opt/protobase/protobase-serve`, which serves the API of the bundle mounted at `/app` (and, given the folder, its app too, see [a self-hosted image](#a-self-hosted-image)); the release's prebuilt admin app at `/opt/protobase/shell`, which a host may serve for the bundle's [shell paths](../reference/plugins.md#the-shell)) instead of the bundle's copy; Bun for its healthcheck on `/health`, and the C++ runtime native add-ons link. It runs as `nonroot` (65532) and writes nothing, so it runs with a read-only root filesystem |
39
+ | `ghcr.io/prototeamhq/protobase:<version>` | the serve runtime, compiled with Bun into `/opt/protobase/protobase-serve`, which serves the API of the bundle mounted at `/app` (and, given the folder, its app too, see [a self-hosted image](#a-self-hosted-image)); the release's prebuilt admin app at `/opt/protobase/shell`, which a host may serve for the bundle's [shell paths](../reference/plugins.md#the-shell) instead of the bundle's copy; Bun for its healthcheck on `/health`, and the C++ runtime native add-ons link. It runs as `nonroot` (65532) and writes nothing, so it runs with a read-only root filesystem |
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
@@ -88,7 +88,7 @@ BETTER_AUTH_URL=http://localhost:8787
88
88
  PROTOBASE_TRUSTED_PROXIES=172.30.87.1
89
89
  ```
90
90
 
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
+ `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.
92
92
 
93
93
  ```yaml
94
94
  services:
@@ -147,7 +147,7 @@ networks:
147
147
  gateway: 172.30.87.1
148
148
  ```
149
149
 
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.
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.
151
151
 
152
152
  ### Local only by default
153
153
 
@@ -161,7 +161,7 @@ app.example.com {
161
161
  }
162
162
  ```
163
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.
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.
165
165
 
166
166
  ### First admin
167
167
 
@@ -39,6 +39,6 @@ With a limit, the dialog says when the list finds more rows than a file holds, a
39
39
 
40
40
  ## 3. What a file holds
41
41
 
42
- A file holds what the user could read in the list, and no more: the rows come from the same list API, as that user, so their role's [row filters and field lists](../reference/access.md#capabilities)) apply, and a [sensitive field](../reference/data-config.md#sensitive-fields)) is never offered. To keep a field out of someone's exports, keep it out of what their role may read. A view's limit only shapes the page; someone who may read the orders can still read them all through the API.
42
+ A file holds what the user could read in the list, and no more: the rows come from the same list API, as that user, so their role's [row filters and field lists](../reference/access.md#capabilities) apply, and a [sensitive field](../reference/data-config.md#sensitive-fields) is never offered. To keep a field out of someone's exports, keep it out of what their role may read. A view's limit only shapes the page; someone who may read the orders can still read them all through the API.
43
43
 
44
- The [UI config](../reference/ui-config.md#exports)) has the details: how cells are typed in a workbook, how a CSV file is quoted, and how files are named.
44
+ The [UI config](../reference/ui-config.md#exports) has the details: how cells are typed in a workbook, how a CSV file is quoted, and how files are named.
@@ -4,7 +4,7 @@
4
4
 
5
5
  Show and edit a field your own way everywhere the app shows it, with a field type a plugin registers and a view picks.
6
6
 
7
- An order's status is one of six values, and each order moves through them in turn: draft, confirmed, picking, shipped, delivered. The app shows it as a badge and edits it with a select. Rijnland's warehouse wants to see at a glance how far along an order is, and to move it with one click. That is a field type: a component that shows the value, one that edits it, and the storage types it works for. This guide adds one, `steps`, to the ERP example (`examples/erp`). [Field types](../reference/plugins.md#field-types)) has the contract.
7
+ An order's status is one of six values, and each order moves through them in turn: draft, confirmed, picking, shipped, delivered. The app shows it as a badge and edits it with a select. Rijnland's warehouse wants to see at a glance how far along an order is, and to move it with one click. That is a field type: a component that shows the value, one that edits it, and the storage types it works for. This guide adds one, `steps`, to the ERP example (`examples/erp`). [Field types](../reference/plugins.md#field-types) has the contract.
8
8
 
9
9
  ## 1. Show the value
10
10
 
@@ -118,7 +118,7 @@ A field type that throws while drawing takes only its own field with it: the fie
118
118
 
119
119
  ## 6. One field type for many apps
120
120
 
121
- The `steps` field type above is the project's own, built with its bundle. To give it to other apps too, move `components/order-steps.tsx` into a [plugin](first-plugin.md)) of its own and register it there:
121
+ The `steps` field type above is the project's own, built with its bundle. To give it to other apps too, move `components/order-steps.tsx` into a [plugin](first-plugin.md) of its own and register it there:
122
122
 
123
123
  ```tsx
124
124
  // workshop-tools/protobase.ui.tsx
@@ -37,7 +37,7 @@ export const overview = page(
37
37
  )
38
38
  ```
39
39
 
40
- That first comment matters. `@jsxImportSource @protobase/layout` makes the JSX build plain data instead of React elements: `<Stat label="Draft orders" ... />` becomes `{ type: 'Stat', props: { label: 'Draft orders', ... }, children: [] }`. The server sends that to the browser in `/api/meta`, and the admin renders it. So a layout holds no functions and no state, and the build refuses one that tries (see [Layouts](../reference/layouts.md#what-a-layout-may-hold))).
40
+ That first comment matters. `@jsxImportSource @protobase/layout` makes the JSX build plain data instead of React elements: `<Stat label="Draft orders" ... />` becomes `{ type: 'Stat', props: { label: 'Draft orders', ... }, children: [] }`. The server sends that to the browser in `/api/meta`, and the admin renders it. So a layout holds no functions and no state, and the build refuses one that tries (see [Layouts](../reference/layouts.md#what-a-layout-may-hold)).
41
41
 
42
42
  Each `Stat` counts the records of `resource` that match `filter`, written in the same AIP-160 syntax as the list's `?filter=`. The count is a link to exactly that filtered list. `page('overview', ...)` puts it at `/overview`, and `nav` puts it first in the Sales group of the sidebar.
43
43
 
@@ -222,9 +222,9 @@ A `CardRow` shows a few records side by side, and its children are the template
222
222
 
223
223
  ## What the page did without
224
224
 
225
- There is no endpoint for "biggest unpaid delivery" and no component for "lead card". Every block reads the regular API with Sam's token, so the access rules apply exactly as on the lists. A sales rep with `orders.read.own` sees only their own orders in every count, table and card, and a field they may not read is not on their page at all (see [Access](../reference/layouts.md#access))).
225
+ There is no endpoint for "biggest unpaid delivery" and no component for "lead card". Every block reads the regular API with Sam's token, so the access rules apply exactly as on the lists. A sales rep with `orders.read.own` sees only their own orders in every count, table and card, and a field they may not read is not on their page at all (see [Access](../reference/layouts.md#access)).
226
226
 
227
227
  The ERP example carries this page, with a few more blocks, in `examples/erp/config/overview/page.tsx`. Next:
228
228
 
229
- - [A billing page](billing-page.md)) adds forms, delete and link actions, and a React component of your own.
230
- - [Blocks](../reference/blocks.md)) lists every block and its props.
229
+ - [A billing page](billing-page.md) adds forms, delete and link actions, and a React component of your own.
230
+ - [Blocks](../reference/blocks.md) lists every block and its props.
@@ -4,7 +4,7 @@
4
4
 
5
5
  Build a plugin, serve it, load it into an app and change it without rebuilding the app.
6
6
 
7
- Sam's sales team wants the newest draft orders on their start page, each a link to the order. That is a few lines of React. Written in the app's `protobase.ui.tsx`, it would be that app's alone, shipped with each of its builds. Written as a [plugin](../reference/plugins.md)) of its own, it is built once, served on its own, and loaded by every app that lists it when it starts, whatever release the app runs.
7
+ Sam's sales team wants the newest draft orders on their start page, each a link to the order. That is a few lines of React. Written in the app's `protobase.ui.tsx`, it would be that app's alone, shipped with each of its builds. Written as a [plugin](../reference/plugins.md) of its own, it is built once, served on its own, and loaded by every app that lists it when it starts, whatever release the app runs.
8
8
 
9
9
  This guide builds that plugin, serves it, loads it into an app and changes it without touching the app. It uses the orders of the ERP example (`examples/erp`); any resource of yours works the same.
10
10
 
@@ -157,10 +157,10 @@ Reload the app. The card shows three orders, and the app was neither rebuilt nor
157
157
 
158
158
  ## 7. Ship it
159
159
 
160
- Put `dist/` on a static host, and list its `plugin.json` in the deployed app's `PROTOBASE_PLUGINS`, or in `options.plugins` of its `protobase.config.ts`, which can also give the plugin settings and limit it to some roles (see [loading](../reference/plugins.md#loading))). Serve `plugin.json` without caching, so a new build reaches the apps on their next load, and the files in `assets/`, whose names change with their content, as long as you like.
160
+ Put `dist/` on a static host, and list its `plugin.json` in the deployed app's `PROTOBASE_PLUGINS`, or in `options.plugins` of its `protobase.config.ts`, which can also give the plugin settings and limit it to some roles (see [loading](../reference/plugins.md#loading)). Serve `plugin.json` without caching, so a new build reaches the apps on their next load, and the files in `assets/`, whose names change with their content, as long as you like.
161
161
 
162
162
  ## When the app moves on
163
163
 
164
164
  The app updates to a new release of Protobase. Nothing happens to the plugin: within plugin API 1, every release keeps what the plugin imports, and the plugin runs on the newer `@protobase/ui` it is handed, its fixes included.
165
165
 
166
- If the app were older than the plugin needs, it would not load the plugin at all. Its admins would see a notice above the app, such as "The plugin sales-tools is off: it needs Protobase >=0.12.0, and this app runs 0.11.1.", and the card would show a warning in place of the drafts, while the rest of the app works as before. [Versions](../reference/plugins.md#versions)) has the rules.
166
+ If the app were older than the plugin needs, it would not load the plugin at all. Its admins would see a notice above the app, such as "The plugin sales-tools is off: it needs Protobase >=0.12.0, and this app runs 0.11.1.", and the card would show a warning in place of the drafts, while the rest of the app works as before. [Versions](../reference/plugins.md#versions) has the rules.
@@ -4,7 +4,7 @@
4
4
 
5
5
  Bring a spreadsheet of companies into the admin app with the list's Import, update them from another, and turn Import off where it does not belong.
6
6
 
7
- Rijnland's sales team keeps a spreadsheet of companies they met at a trade fair, and wants them in the ERP example (`examples/erp`) without typing each one. Every list offers **Import** to a user who may create its records, so there is nothing to build: this guide walks through an import, an update from a second file, and turning Import off. The [reference](../reference/ui-config.md#importing-records)) has every rule.
7
+ Rijnland's sales team keeps a spreadsheet of companies they met at a trade fair, and wants them in the ERP example (`examples/erp`) without typing each one. Every list offers **Import** to a user who may create its records, so there is nothing to build: this guide walks through an import, an update from a second file, and turning Import off. The [reference](../reference/ui-config.md#importing-records) has every rule.
8
8
 
9
9
  ## 1. Import new records
10
10
 
@@ -6,8 +6,6 @@ Run a Protobase app on iOS and Android and build signed store releases from a mo
6
6
 
7
7
  A Protobase app runs as an iOS or Android app with nothing more than a `mobile` section in its `protobase.config.ts`. `protobase mobile` wraps the app in [Capacitor](https://capacitorjs.com): the app's shell, its UI plugins, theme and favicon open from files on the device, and the app calls your server's API.
8
8
 
9
- Signing in from the app is not supported yet: until then the app shows that it cannot reach the server's sign-in, while its API calls go through.
10
-
11
9
  ## 1. Install the tools
12
10
 
13
11
  - **iOS**, on a Mac: Xcode, with a simulator.
@@ -31,7 +29,16 @@ export default defineConfig({
31
29
  - `appId` is the app's id in reverse-DNS form: at least two parts separated by dots, each starting with a letter and holding only letters, digits and underscores.
32
30
  - `plugins`, optional, are extra native [Capacitor plugins](https://capacitorjs.com/docs/plugins), npm name to version. Capacitor itself, `@capacitor/app`, `@capacitor/splash-screen` and `@capawesome/capacitor-live-update` come with Protobase at fixed versions and cannot be listed. A plugin runs native code with the app's rights, and one that writes files, such as `@capacitor/filesystem`, lets a script that got into the page point the app at files it wrote (with Capacitor's own `WebView.setServerBasePath`), so list only plugins the app needs.
33
31
 
34
- With a mobile section, the API answers the app's origins, `capacitor://localhost` on iOS and `https://localhost` on Android, through [CORS](../reference/api.md#cors)). Apps without one get no new dependency, and `protobase build` and `protobase dev` work as before.
32
+ With a mobile section, the API answers the app's origins, `capacitor://localhost` on iOS and `https://localhost` on Android, through [CORS](../reference/api.md#cors). Apps without one get no new dependency, and `protobase build` and `protobase dev` work as before.
33
+
34
+ Signing in works in the app as on the web, with nothing more to set up:
35
+
36
+ - Emailed codes, passwords and the second step of two-factor authentication work. Passkeys and sign-in with another provider do not yet.
37
+ - The app calls `/api/auth` through the device's native HTTP, naming its Capacitor origin. With a mobile section, sign-in trusts the Capacitor origin a request names, for that request only, without CORS.
38
+ - The session lives in the device's cookie store, so it survives reloads, updates and relaunches. On iOS, signing in or out within about a second of killing the app may be lost.
39
+ - "Forgot password?" is not offered in the app, as the emailed link cannot lead back into it.
40
+ - In the app, page script can reach the session cookie through Capacitor's native plugins, so keep untrusted script out of UI plugins.
41
+ - While you develop over plain `http://localhost` with a mobile section, a page served on `https://localhost` in the same browser can send sign-in requests that carry your dev session, as some browsers treat the two as the same site. Do not open untrusted pages on `https://localhost` while you develop.
35
42
 
36
43
  ## 3. Run it
37
44
 
@@ -40,7 +47,7 @@ protobase mobile run android
40
47
  protobase mobile run ios
41
48
  ```
42
49
 
43
- The first run installs Capacitor into `.protobase/mobile/`, which ignores itself in git. Every run builds the app's files as [`protobase build`](../reference/cli.md#build)) does and generates the native project from your config again, so never edit the projects in `.protobase/mobile/` by hand. Your own package.json gains nothing.
50
+ The first run installs Capacitor into `.protobase/mobile/`, which ignores itself in git. Every run builds the app's files as [`protobase build`](../reference/cli.md#build) does and generates the native project from your config again, so never edit the projects in `.protobase/mobile/` by hand. Your own package.json gains nothing.
44
51
 
45
52
  The app calls the server at the project's auth `baseURL`; pass `--api https://shop.example.com` for another one. Plain http is only for a server on this machine (`localhost`) or, on the Android emulator, its host `10.0.2.2`; any other server needs https. An Android phone on USB reaches a server on `localhost` through a forwarded port; an iPhone needs an https server. The app's UI plugins load from the device only when the server serves a built bundle (`protobase serve dist`): against `protobase dev`, use `--live`.
46
53
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  What changes for a project whose protobase.ui.tsx was built into the admin app, now that protobase build makes it a plugin beside a prebuilt app.
6
6
 
7
- Until 0.12, `protobase build` built the whole admin app into each bundle, with the project's `protobase.ui.tsx` and every `--extend` folder's compiled into it. Each bundle was frozen at the `@protobase/ui` it was built with: the app's fixes reached it only with a rebuild. From 0.12 the admin app is prebuilt once per release, and `protobase build` builds the project's `protobase.ui.tsx` as a [plugin](../reference/plugins.md)) beside it. The project's code is written the same way; this guide moves a project over and says what to look at.
7
+ Until 0.12, `protobase build` built the whole admin app into each bundle, with the project's `protobase.ui.tsx` and every `--extend` folder's compiled into it. Each bundle was frozen at the `@protobase/ui` it was built with: the app's fixes reached it only with a rebuild. From 0.12 the admin app is prebuilt once per release, and `protobase build` builds the project's `protobase.ui.tsx` as a [plugin](../reference/plugins.md) beside it. The project's code is written the same way; this guide moves a project over and says what to look at.
8
8
 
9
9
  ## 1. Update and rebuild
10
10
 
@@ -35,7 +35,7 @@ dist/
35
35
 
36
36
  ## 2. Check protobase.ui.tsx
37
37
 
38
- Nothing in it has to change: its named component exports, `defineUi({ actions, shell, extends })` and the components it registers work as before. `definePlugin` is the same function under its new name, and also takes [field types](../reference/plugins.md#field-types)). Three things a plugin cannot do, which a built-in `protobase.ui.tsx` could, fail the build or show at once:
38
+ Nothing in it has to change: its named component exports, `defineUi({ actions, shell, extends })` and the components it registers work as before. `definePlugin` is the same function under its new name, and also takes [field types](../reference/plugins.md#field-types). Three things a plugin cannot do, which a built-in `protobase.ui.tsx` could, fail the build or show at once:
39
39
 
40
40
  - **Modules of the shared packages.** `react`, `react/jsx-runtime`, `react-dom` and `@protobase/ui` come from the app, by those names. An import of another module of theirs, such as `react-dom/client` or a file inside `@protobase/ui`, fails the build: import from the package's main entry instead.
41
41
  - **Browser work at the top level.** The build loads `protobase.ui.tsx` once in Node to read its field types. Code that touches `window`, `document` or `localStorage` when a module loads fails the build; move it into a component, a hook or a handler.
@@ -43,7 +43,7 @@ Nothing in it has to change: its named component exports, `defineUi({ actions, s
43
43
 
44
44
  ## 3. Check its styles
45
45
 
46
- The project's Tailwind classes are built into the plugin's own stylesheet, `plugins/app/assets/styles-<hash>.css`: utilities only, each reading the app's [tokens](../reference/theme.md)). `bg-primary` and `rounded-md` look as before. A class that only worked because the app's own stylesheet happened to have it is now in the plugin's too, so nothing is lost. To change the app's colors, radius or font, write a [`protobase.theme.css`](theme-an-app.md)), not rules against the app's markup.
46
+ The project's Tailwind classes are built into the plugin's own stylesheet, `plugins/app/assets/styles-<hash>.css`: utilities only, each reading the app's [tokens](../reference/theme.md). `bg-primary` and `rounded-md` look as before. A class that only worked because the app's own stylesheet happened to have it is now in the plugin's too, so nothing is lost. To change the app's colors, radius or font, write a [`protobase.theme.css`](theme-an-app.md), not rules against the app's markup.
47
47
 
48
48
  ## 4. Extensions
49
49
 
@@ -54,7 +54,7 @@ Each `--extend` folder's `protobase.ui.tsx` becomes a plugin of its own, `plugin
54
54
  A host that serves `public/` as before keeps working: `index.html` for navigations, files for the rest. Two things are new:
55
55
 
56
56
  - The plugins' `assets/` folders, `public/plugins/<name>/assets/`, are named by their content like `public/assets/`: serve them as immutable too. `plugin.json`, `protobase.theme.css`, `protobase.favicon.svg` and the PNG icons are served with `no-cache`.
57
- - A host that keeps the prebuilt app of newer releases may serve it for the manifest's `shell.paths`, so the app gets that release's fixes without a rebuild (see [the shell](../reference/plugins.md#the-shell))). `protobase serve` does so with its own when every plugin of the bundle loads in it.
57
+ - A host that keeps the prebuilt app of newer releases may serve it for the manifest's `shell.paths`, so the app gets that release's fixes without a rebuild (see [the shell](../reference/plugins.md#the-shell)). `protobase serve` does so with its own when every plugin of the bundle loads in it.
58
58
 
59
59
  ## 6. protobase dev
60
60
 
@@ -62,4 +62,4 @@ Nothing changes: `protobase dev` builds `protobase.ui.tsx` into its page with ho
62
62
 
63
63
  ## After the move
64
64
 
65
- From now on, a release of Protobase within the same minor needs no rebuild of the project's UI: the app it runs in is the release's, and the plugin keeps working within its [plugin API](../reference/plugins.md#versions)). The server config still follows the [bundle's rule](../reference/versioning.md#bundles-and-runtimes)), so a new minor below 1.0 is still a rebuild.
65
+ From now on, a release of Protobase within the same minor needs no rebuild of the project's UI: the app it runs in is the release's, and the plugin keeps working within its [plugin API](../reference/plugins.md#versions). The server config still follows the [bundle's rule](../reference/versioning.md#bundles-and-runtimes), so a new minor below 1.0 is still a rebuild.
@@ -4,7 +4,7 @@
4
4
 
5
5
  Draw each card of a cards display with a component of your own, and keep the built-in card as its fallback.
6
6
 
7
- A list can show its records as [cards](../reference/ui-config.md#list-displays)) beside its table: a title, a subtitle, a badge and a few small fields. Rijnland's sales team wants order cards that lead with the total and the customer, the way they talk about orders. That is a card component: the list page still loads the orders, filters, sorts and links each card to its order; the component only draws what is inside a card. This guide adds one to the ERP example (`examples/erp`).
7
+ A list can show its records as [cards](../reference/ui-config.md#list-displays) beside its table: a title, a subtitle, a badge and a few small fields. Rijnland's sales team wants order cards that lead with the total and the customer, the way they talk about orders. That is a card component: the list page still loads the orders, filters, sorts and links each card to its order; the component only draws what is inside a card. This guide adds one to the ERP example (`examples/erp`).
8
8
 
9
9
  ## 1. The card
10
10
 
@@ -29,7 +29,7 @@ export const OrderCard = ({ row }: RecordCardProps) => (
29
29
 
30
30
  `row.record` is the order as the list API gives it, and `row.labels` the name of the record each relation points at: `company_id` is the company's id, `labels.company_id` its name. `row.key` is the order's key.
31
31
 
32
- The whole card is a link to the order, so the component draws no links or buttons of its own; the app draws the card's border, padding and hover, in the app's [theme](../reference/theme.md)).
32
+ The whole card is a link to the order, so the component draws no links or buttons of its own; the app draws the card's border, padding and hover, in the app's [theme](../reference/theme.md).
33
33
 
34
34
  ## 2. Export it
35
35
 
@@ -58,7 +58,7 @@ export const OrderCard = component('OrderCard')
58
58
 
59
59
  Run `bun run protobase dev`, open the orders and switch to Cards: each order is drawn by `OrderCard`. The display keeps everything else the list has: its search, filters, sort menu, the count of orders and loading more as you scroll.
60
60
 
61
- `protobase build` fails when the config declares `OrderCard` and `protobase.ui.tsx` does not export it. A card from a [plugin](../reference/plugins.md)) is declared with the plugin's name, `component('OrderCard', { plugin: 'sales-tools' })`.
61
+ `protobase build` fails when the config declares `OrderCard` and `protobase.ui.tsx` does not export it. A card from a [plugin](../reference/plugins.md) is declared with the plugin's name, `component('OrderCard', { plugin: 'sales-tools' })`.
62
62
 
63
63
  ## 4. When the card fails
64
64
 
@@ -6,11 +6,11 @@ Two Protobase apps, where the shop's admin app shows the service desk's tickets
6
6
 
7
7
  Sam runs a web shop, and its customers' questions land in the company's service desk, a Protobase app of its own. When a customer calls about an order, Sam's people look the order up in the shop's admin app, then open the desk in another tab to find the customer's ticket. They want the tickets in the shop's admin app, next to the orders: a list, each ticket's page, the open ones in the sidebar, and a status they can change. The desk's agents keep working in the desk.
8
8
 
9
- This guide makes the desk's tickets a [remote resource](../reference/remote-resources.md)) of the shop: the shop draws them with its own pages, while the desk keeps the data, the rules and the views. Nothing is copied and nothing is proxied: the shop's admin app reads the desk's API with the shop's own sign-in.
9
+ This guide makes the desk's tickets a [remote resource](../reference/remote-resources.md) of the shop: the shop draws them with its own pages, while the desk keeps the data, the rules and the views. Nothing is copied and nothing is proxied: the shop's admin app reads the desk's API with the shop's own sign-in.
10
10
 
11
11
  ## 1. Two apps
12
12
 
13
- You need two Protobase projects, each with its own database, its own [admin store](../reference/auth.md#admin-store)) and a user: the from-scratch preset (`examples/scratch` in the repository) is enough for both. Each runs on its own origin; this guide runs them side by side on one machine:
13
+ You need two Protobase projects, each with its own database, its own [admin store](../reference/auth.md#admin-store) and a user: the from-scratch preset (`examples/scratch` in the repository) is enough for both. Each runs on its own origin; this guide runs them side by side on one machine:
14
14
 
15
15
  | | `BETTER_AUTH_URL` in its `.env` | Started with |
16
16
  | --- | --- | --- |
@@ -53,7 +53,7 @@ export const ticketNotes = resource('ticket_notes')
53
53
  .access({ delete: deskOnly })
54
54
  ```
55
55
 
56
- Only the desk's own admins delete: the [access rule](../reference/access.md)) holds for everyone who reaches the desk's API, the shop's people included.
56
+ Only the desk's own admins delete: the [access rule](../reference/access.md) holds for everyone who reaches the desk's API, the shop's people included.
57
57
 
58
58
  ```ts
59
59
  // desk: config/tickets/ui.ts
@@ -95,9 +95,9 @@ export const authenticate = betterAuthAuthenticator({
95
95
  })
96
96
  ```
97
97
 
98
- The desk now checks a token from the shop against the shop's keys, at `http://localhost:4710/api/auth/jwks`. Its holder is `shop` at the desk, never the desk's `admin`, so the `deskOnly` rule keeps tickets from being deleted from the shop; a shop user with any other role is refused. The [reference](../reference/remote-resources.md#signing-in-at-the-source)) has the details, such as the ids those users get.
98
+ The desk now checks a token from the shop against the shop's keys, at `http://localhost:4710/api/auth/jwks`. Its holder is `shop` at the desk, never the desk's `admin`, so the `deskOnly` rule keeps tickets from being deleted from the shop; a shop user with any other role is refused. The [reference](../reference/remote-resources.md#signing-in-at-the-source) has the details, such as the ids those users get.
99
99
 
100
- The origin: the shop's admin app runs on `http://localhost:4710`, so the desk answers [CORS](../reference/api.md#cors)) for it:
100
+ The origin: the shop's admin app runs on `http://localhost:4710`, so the desk answers [CORS](../reference/api.md#cors) for it:
101
101
 
102
102
  ```ts
103
103
  // desk: protobase.config.ts
@@ -149,7 +149,7 @@ Behind it, the shop's admin app read the desk's `/api/meta` with the shop's toke
149
149
 
150
150
  ## 5. A view for the shop's people
151
151
 
152
- "Support" is how the desk's agents think of tickets. In the shop they are about customers, and only the open ones matter in the sidebar. The desk decides what the shop's people see, so it gives the role it gave them, `shop`, a [view of its own](../reference/ui-config.md#actions-and-views-per-role)):
152
+ "Support" is how the desk's agents think of tickets. In the shop they are about customers, and only the open ones matter in the sidebar. The desk decides what the shop's people see, so it gives the role it gave them, `shop`, a [view of its own](../reference/ui-config.md#actions-and-views-per-role):
153
153
 
154
154
  ```ts
155
155
  // desk: config/tickets/ui.ts
@@ -170,7 +170,7 @@ Start the desk again and press **Try again**: the tickets are back. The same hap
170
170
 
171
171
  ## Custom sections
172
172
 
173
- The desk's views can name [custom components](../reference/custom-components.md)), such as a timeline of the ticket with `l.custom(TicketTimeline)`. The shop draws them by name from its [plugins](../reference/plugins.md)), so the desk ships them as a plugin, built with `protobase build-plugin` and served wherever the shop's browser can load it, and the shop lists it with the source, for instance:
173
+ The desk's views can name [custom components](../reference/custom-components.md), such as a timeline of the ticket with `l.custom(TicketTimeline)`. The shop draws them by name from its [plugins](../reference/plugins.md), so the desk ships them as a plugin, built with `protobase build-plugin` and served wherever the shop's browser can load it, and the shop lists it with the source, for instance:
174
174
 
175
175
  ```sh
176
176
  PROTOBASE_PLUGINS='http://localhost:4720/plugins/desk/plugin.json'
@@ -180,6 +180,6 @@ Inside, the component reads the ticket with `useLayoutRecord()`, and `useList` a
180
180
 
181
181
  ## Where to go from here
182
182
 
183
- - [Remote resources](../reference/remote-resources.md)): how it works, the contract between an app and its sources, and the API.
184
- - [Your first plugin](first-plugin.md)): build the plugin a source's views need.
185
- - [Access](../reference/access.md)): what the role you give another app's users may do.
183
+ - [Remote resources](../reference/remote-resources.md): how it works, the contract between an app and its sources, and the API.
184
+ - [Your first plugin](first-plugin.md): build the plugin a source's views need.
185
+ - [Access](../reference/access.md): what the role you give another app's users may do.