@protobase/cli 0.49.1 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/protobase.mjs +3 -2
- package/dist/build/config-bundle.js +1 -1
- package/dist/build/deploy-bundle.js +3 -4
- package/dist/build/plugin-build.js +16 -8
- package/dist/build/plugin-fields.js +5 -2
- package/dist/build/ui-check.js +5 -0
- package/dist/build/view-check.js +1 -1
- package/dist/cli/package.js +1 -1
- package/dist/config/build-project.js +13 -6
- package/dist/config/project-files.js +4 -1
- package/dist/config/read-config.js +5 -1
- package/dist/config/source-config.js +1 -1
- package/dist/db/read-only-db.js +1 -1
- package/dist/dev/api-process.js +1 -1
- package/dist/dev/app-server.js +43 -35
- package/dist/dev/create-db.js +2 -2
- package/dist/dev/dev-jobs.js +5 -3
- package/dist/dev/entry.js +3 -3
- package/dist/dev/project.js +3 -2
- package/dist/dev/server-package.js +9 -21
- package/dist/doctor/run.js +1 -1
- package/dist/hand-over.d.ts +15 -0
- package/dist/hand-over.js +32 -0
- package/dist/main.js +22 -5
- package/dist/migration/load-project.js +1 -1
- package/dist/project/bundled-imports.js +41 -0
- package/dist/project/import-project-file.js +28 -8
- package/dist/project/load-bundle-project.js +1 -1
- package/dist/project/load-data-config.js +4 -3
- package/dist/project/project-types.js +66 -0
- package/dist/project-auth.d.ts +2 -0
- package/dist/project-auth.js +2 -0
- package/dist/run/preload.d.ts +1 -0
- package/dist/run/preload.js +20 -0
- package/dist/run/run-script.js +36 -0
- package/dist/serve/app.js +1 -1
- package/dist/serve/create-admin.js +1 -1
- package/dist/serve/host-modules.js +3 -3
- package/dist/serve/lifecycle.js +4 -3
- package/dist/supabase/load-phase.js +6 -5
- package/dist/users/load-auth.d.ts +10 -0
- package/dist/users/load-auth.js +1 -1
- package/dist/version/project-packages.js +39 -0
- package/dist/version/project-version.js +33 -12
- package/dist/worker/start-worker.js +3 -2
- package/package.json +10 -8
- package/skills/protobase/SKILL.md +1 -1
- package/skills/protobase/references/features/build-and-run.md +3 -0
- package/skills/protobase/references/features/events-webhooks-and-jobs.md +1 -0
- package/skills/protobase/references/features/files-and-images.md +1 -0
- package/skills/protobase/references/features/releases.md +2 -1
- package/skills/protobase/references/features/sign-in-and-accounts.md +1 -0
- package/skills/protobase/references/features/start-a-project.md +1 -1
- package/skills/protobase/references/getting-started.md +18 -5
- package/skills/protobase/references/guides/api-functions.md +1 -1
- package/skills/protobase/references/guides/billing-page.md +4 -4
- package/skills/protobase/references/guides/create-page.md +2 -2
- package/skills/protobase/references/guides/deploy.md +24 -8
- package/skills/protobase/references/guides/field-type.md +1 -1
- package/skills/protobase/references/guides/first-plugin.md +1 -1
- package/skills/protobase/references/guides/plugin-build.md +1 -1
- package/skills/protobase/references/guides/remote-resources.md +1 -1
- package/skills/protobase/references/guides/table-to-admin.md +8 -8
- package/skills/protobase/references/reference/ai.md +1 -1
- package/skills/protobase/references/reference/api.md +4 -4
- package/skills/protobase/references/reference/architecture.md +11 -6
- package/skills/protobase/references/reference/assistant.md +1 -1
- package/skills/protobase/references/reference/auth.md +24 -6
- package/skills/protobase/references/reference/blocks.md +1 -1
- package/skills/protobase/references/reference/bottom-bar.md +2 -2
- package/skills/protobase/references/reference/cli.md +51 -22
- package/skills/protobase/references/reference/client.md +3 -1
- package/skills/protobase/references/reference/config/api.md +2 -2
- package/skills/protobase/references/reference/config/app.md +2 -2
- package/skills/protobase/references/reference/config/sign-in.md +3 -4
- package/skills/protobase/references/reference/config.md +13 -10
- package/skills/protobase/references/reference/custom-components.md +3 -2
- package/skills/protobase/references/reference/email.md +5 -5
- package/skills/protobase/references/reference/events.md +1 -1
- package/skills/protobase/references/reference/files.md +6 -3
- package/skills/protobase/references/reference/jobs.md +20 -10
- package/skills/protobase/references/reference/layouts.md +2 -2
- package/skills/protobase/references/reference/mcp.md +9 -8
- package/skills/protobase/references/reference/notifications.md +10 -8
- package/skills/protobase/references/reference/plugins.md +3 -3
- package/skills/protobase/references/reference/ui-config.md +1 -1
- package/skills/protobase/references/reference/user-menu.md +3 -3
- package/skills/protobase/references/reference/versioning.md +21 -4
- package/skills/protobase/references/reference/webhooks.md +5 -5
|
@@ -38,7 +38,7 @@ Each version's statements are followed by its row in `auth_migrations`. The file
|
|
|
38
38
|
|
|
39
39
|
Every store has the tables of every feature, whether the app turns the feature on or not: [passkeys](#passkeys), [two-factor authentication](#two-factor-authentication), [organizations](#organizations) and the [OAuth provider for MCP](#oauth-for-mcp-clients). Turning a feature on or off needs no migration and drops nothing; the columns a feature adds to the user and session tables are empty until it is on. SAML providers and open sign-up keep nothing in the store.
|
|
40
40
|
|
|
41
|
-
The store's tables and columns are snake_case, like the app's (`sign_in_policy.platform_sign_in`, `session.user_id`); the code and the API keep Better Auth's camelCase names. The names the app configures, the store's schema (`
|
|
41
|
+
The store's tables and columns are snake_case, like the app's (`sign_in_policy.platform_sign_in`, `session.user_id`); the code and the API keep Better Auth's camelCase names. The names the app configures, the store's schema ([`auth.schema`](config/sign-in.md#authschema)), the [user table](#an-existing-users-table) and its columns, and uuid ids (`generateUserId: 'uuid'`), are the ones in effect when the file is written. Changing one later is a migration of the project's own, such as a rename.
|
|
42
42
|
|
|
43
43
|
The server never changes the schema, and never compares it with what Better Auth needs. `protobase serve` and `protobase dev` read `auth_migrations` at startup and refuse to start while a version of this Protobase is not applied, naming it and `protobase auth migration`, or while the store has a version newer than this Protobase knows. The examples' `db:migrate` applies all pending files in one transaction, so a migration that fails leaves the database as the running version expects it. The host must guarantee the rest: nothing but the migrations writes while they run, and the new version serves only after they succeeded. Only [`protobase dev`](cli.md#dev), on the developer's machine, compares the store's tables with what the app's Better Auth needs, and warns at startup about each table, column or index that drifted, such as one changed by hand.
|
|
44
44
|
|
|
@@ -72,7 +72,7 @@ The store's migrations make the user table only when it is missing, and add each
|
|
|
72
72
|
| `PROTOBASE_SECRET` | the app's secret, the default of `secret`: signs cookies and encrypts the token keys; `openssl rand -base64 32`; never committed (`.env.example` has a placeholder) |
|
|
73
73
|
| `PROTOBASE_PREVIOUS_SECRETS` | the app's secrets before `PROTOBASE_SECRET`, newest first, comma separated, the default of `previousSecrets`; see [Changing the secret](#changing-the-secret) |
|
|
74
74
|
| `PROTOBASE_URL` | the app's public URL, the default of `url` (in `protobase dev`, the dev server's own); issuer and audience of the tokens; when tunnelling, the https tunnel URL |
|
|
75
|
-
| `PROTOBASE_TRUSTED_ORIGINS` | extra comma separated origins, the default of `auth.trustedOrigins`; a dev tunnel needs its exact host here, such as `https://my-tunnel.trycloudflare.com`, since
|
|
75
|
+
| `PROTOBASE_TRUSTED_ORIGINS` | extra comma separated origins, the default of `auth.trustedOrigins`; a dev tunnel needs its exact host here, such as `https://my-tunnel.trycloudflare.com`, since none is trusted by default; an entry with `*` trusts every host it matches |
|
|
76
76
|
| `PROTOBASE_ORIGINS` | the other origins the app is served on, comma separated, passed by the platform; see [Several origins](#several-origins) |
|
|
77
77
|
| `PROTOBASE_PASSKEY_DOMAIN` | the host new [passkeys](#passkeys) are made for, passed by the platform; default the host of the app's `url` |
|
|
78
78
|
| `PROTOBASE_CORS_ORIGINS` | other websites whose browser code may call the API, `*` or comma separated http and https origins, passed by the platform; see [CORS](api.md#cors) |
|
|
@@ -124,15 +124,18 @@ An app served another way than `protobase serve`, such as its own server around
|
|
|
124
124
|
|
|
125
125
|
## First run
|
|
126
126
|
|
|
127
|
-
Accounts are never created over the web while the store is empty: there is no setup route, and [open sign-up](#open-sign-up), when an app turns it on, waits for the first admin, so a freshly deployed URL cannot be claimed by whoever reaches it first. The first admin is created on the host, with the CLI (`protobase users create you@example.com --generate-password`, or `--no-password` for an account that signs in by emailed code, passkey or a sign-in provider only). The `users` commands call these functions of `@protobase/server`, on the app's sign-in
|
|
127
|
+
Accounts are never created over the web while the store is empty: there is no setup route, and [open sign-up](#open-sign-up), when an app turns it on, waits for the first admin, so a freshly deployed URL cannot be claimed by whoever reaches it first. The first admin is created on the host, with the CLI (`protobase users create you@example.com --generate-password`, or `--no-password` for an account that signs in by emailed code, passkey or a sign-in provider only). The `users` commands call these functions of `@protobase/server`, on the app's sign-in. A script of the project's own, such as a seed, builds that sign-in as the commands do, from the project's config and `DATABASE_URL`, with `loadProjectAuth` of `@protobase/cli/auth`:
|
|
128
128
|
|
|
129
129
|
```ts
|
|
130
|
-
import {
|
|
130
|
+
import { loadProjectAuth } from '@protobase/cli/auth'
|
|
131
|
+
import { createUser, deleteUser, hasUsers, listUsers, setUserBanned, setUserRole } from '@protobase/server'
|
|
132
|
+
|
|
133
|
+
const auth = await loadProjectAuth(process.cwd()) // the project's folder; its .env is loaded too
|
|
131
134
|
|
|
132
135
|
await createUser(auth, { email, password?, name?, role? }) // the first user is always an admin; later ones default to `user`
|
|
133
136
|
await hasUsers(auth) // boolean
|
|
134
137
|
await listUsers(auth) // [{ id, email, role, banned, createdAt }], never passwords
|
|
135
|
-
await setUserRole(auth, { email, role }) //
|
|
138
|
+
await setUserRole(auth, { email, role }) // a role of auth.roles, or several comma separated
|
|
136
139
|
await setUserBanned(auth, { email, banned }) // banning ends the user's sessions and blocks sign-in
|
|
137
140
|
await deleteUser(auth, email) // with sessions and accounts
|
|
138
141
|
```
|
|
@@ -225,7 +228,7 @@ import type { Mailer } from '@protobase/server'
|
|
|
225
228
|
export default { send: async ({ to, subject, text }) => { /* deliver it */ } } satisfies Mailer
|
|
226
229
|
```
|
|
227
230
|
|
|
228
|
-
[Jobs](jobs.md#mail) send their own mail through the same server, with `mail` in their context, and so do the app's [email templates](email.md).
|
|
231
|
+
[Jobs](jobs.md#mail) send their own mail through the same server, or the same `auth/mailer.ts`, with `mail` in their context, and so do the app's [email templates](email.md) given it.
|
|
229
232
|
|
|
230
233
|
- The email names the app and gives the link, as a button and in its plain-text part, that it works for 1 hour and once, and that it can be ignored (see [Protobase's own mail](email.md#protobases-own-mail)).
|
|
231
234
|
- The SMTP client greets the server with the sender's domain (`admin.example.com` above), not the container's `[127.0.0.1]`; a `?name=` on `PROTOBASE_SMTP_URL` overrides it.
|
|
@@ -584,6 +587,19 @@ It is Better Auth's organization plugin, with its tables named in snake_case (`o
|
|
|
584
587
|
|
|
585
588
|
**Ids.** The `generateOrganizationId` [hook](#hooks) makes a new organization's id, by default a UUID; `.tenant` columns hold it, so `text` or `uuid`. An app whose tenant columns are integers takes the next value of its own organizations sequence instead, and adds its own row in `onOrganizationCreated`, as the ERP example does (`tests/apps/erp/auth/hooks.ts`). An app that ran as one organization keeps its tenant value: `protobase organizations create "Acme" --owner you@example.com --id 1 --members all` makes that organization, with every user in it: superusers as owners, everyone else as a member, their global roles moved onto the membership.
|
|
586
589
|
|
|
590
|
+
**On the host.** The [`protobase organizations`](cli.md#organizations) commands call these functions of `@protobase/server`, which a script of the project's own, such as a seed, calls with the sign-in of [`loadProjectAuth`](#first-run). The host acts as a superuser, so it may give any role; `organization` is a slug or an id:
|
|
591
|
+
|
|
592
|
+
```ts
|
|
593
|
+
import { addAppRoleToOwners, addMember, createOrganization, listOrganizations, removeMember, setMemberRoles } from '@protobase/server'
|
|
594
|
+
|
|
595
|
+
await createOrganization(auth, { name, slug, owner: email, id? }) // the owner holds every app role
|
|
596
|
+
await addMember(auth, { organization, email, role?, appRoles? }) // role: owner, admin or member (default)
|
|
597
|
+
await setMemberRoles(auth, { organization, email, role?, appRoles? })
|
|
598
|
+
await removeMember(auth, { organization, email }) // refuses the last owner
|
|
599
|
+
await listOrganizations(auth) // oldest first, with members' emails and roles
|
|
600
|
+
await addAppRoleToOwners(auth, appRole) // a role the project added later, to every owner
|
|
601
|
+
```
|
|
602
|
+
|
|
587
603
|
The app's own pages are under the profile menu: the switcher, "Manage organizations" (theirs, a new one, and for global roles any one), "Organization" (details, leaving, handing over, deleting), and for owners and admins "Members" and "Invitations". The client has them as `session.organizations` (`list`, `current`, `switchTo`, `members`, `invite`, ...).
|
|
588
604
|
|
|
589
605
|
## Tokens and roles
|
|
@@ -673,8 +689,10 @@ An app moving from Supabase keeps its `supabase.auth` calls and its `@supabase/s
|
|
|
673
689
|
There is no development login. For scripts, mint a token for an existing user on the host (the CLI exposes it as `protobase token you@example.com`):
|
|
674
690
|
|
|
675
691
|
```ts
|
|
692
|
+
import { loadProjectAuth } from '@protobase/cli/auth'
|
|
676
693
|
import { issueToken } from '@protobase/server'
|
|
677
694
|
|
|
695
|
+
const auth = await loadProjectAuth(process.cwd())
|
|
678
696
|
const { token, expiresAt } = await issueToken(auth, { email: 'you@example.com', ttlSeconds: 3600 }) // default 15 minutes, at most 24 hours
|
|
679
697
|
```
|
|
680
698
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Every built-in layout block, its props and what it does, with examples from the ERP's sales overview.
|
|
6
6
|
|
|
7
|
-
Blocks are imported from `@protobase/layout`. "Record" below means the record of the `RecordCard` or `CardRow` card around a block (see [Data](layouts.md#data)); `filter` is AIP-160 and `sort` AIP-132, as in the list API.
|
|
7
|
+
Blocks are imported from `@protobase/layout`. "Record" below means the record of the `RecordCard` or `CardRow` card around a block (see [Data](layouts.md#data)); `filter` is AIP-160 and `sort` AIP-132, as in the list API. The ERP example's sales overview uses `Page`, `Grid`, `Card`, `Stat`, `Table`, `RecordCard`, `CardRow`, `Field`, `Chart`, `Action`, `ModalForm` and `Show`; of the others, the property portal's home uses `RecordRow`, and the [Users page](auth.md#users-page) `Users`:
|
|
8
8
|
|
|
9
9
|
```tsx title="tests/apps/erp/config/overview/page.tsx"
|
|
10
10
|
/** @jsxImportSource @protobase/layout */
|
|
@@ -6,7 +6,7 @@ Tabs along the bottom of a phone, as on iOS, for the roles that work from one.
|
|
|
6
6
|
|
|
7
7
|
On phones the sidebar is a drawer behind the top bar's menu button. For people who work from a phone, such as on a warehouse floor, a bottom bar puts their few screens one tap away: up to four tabs, each an icon above its label, the current one highlighted, and "More" last, which opens the drawer with the rest. The bar keeps clear of the iPhone home indicator. From the `md` breakpoint (768px) up there is no bar; the sidebar shows instead.
|
|
8
8
|
|
|
9
|
-
Export a [`bottomBar(...)`](https://docs.protobase.net/api/schema/functions/bottombar/) from
|
|
9
|
+
Export a [`bottomBar(...)`](https://docs.protobase.net/api/schema/functions/bottombar/) from `config/index.ts` for each group of roles that gets one:
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
12
|
// tests/apps/erp/config/bottom-bar.ts, re-exported from config/index.ts
|
|
@@ -36,7 +36,7 @@ Each bar names its roles, and a role belongs to one bar. A caller gets the bar t
|
|
|
36
36
|
|
|
37
37
|
`createAdmin` refuses to start when a bar names a resource or page that does not exist, has no roles, no items or more than four, names a role the app does not have (the roles of [`auth.roles`](auth.md#roles) and [`defineRoles`](access.md); without either, any role is accepted), shares a role with another bar, or has the label of another bar. The checks are [`bottomBarErrors`](https://docs.protobase.net/api/schema/functions/bottombarerrors/) from `@protobase/schema`, a pure function of the bars and the app's names.
|
|
38
38
|
|
|
39
|
-
`protobase dev`, `protobase build` and `protobase serve` pick the bars up from
|
|
39
|
+
`protobase dev`, `protobase build` and `protobase serve` pick the bars up from `config/index.ts`. With `createAdmin` directly, pass them as `bottomBars`:
|
|
40
40
|
|
|
41
41
|
```ts
|
|
42
42
|
const { resources, views, bottomBars } = configExports(config)
|
|
@@ -4,15 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
Every protobase command, from scaffold, doctor, dev, build, build-plugin, build-serve and serve to users, organizations, token and skill.
|
|
6
6
|
|
|
7
|
-
The `protobase` command comes with `@protobase/cli`. Install it in a project next to the packages its config imports:
|
|
7
|
+
The `protobase` command comes with `@protobase/cli`. Install it globally, or in a project next to the packages its config imports:
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
bun add @protobase/cli
|
|
11
|
-
bun
|
|
12
|
-
bun run
|
|
10
|
+
bun add --global @protobase/cli # the protobase command for every bundled project
|
|
11
|
+
bun add --dev @protobase/cli @protobase/config @protobase/schema @protobase/layout @protobase/server @protobase/ui
|
|
12
|
+
bun run protobase <command> # from the project, config folder defaults to ./config
|
|
13
|
+
bun run --cwd tests/apps/erp protobase <command> # in this repository, for an example
|
|
13
14
|
```
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
Listed in `devDependencies`, as the presets list them, or not at all, the packages make the project bundled: whichever CLI runs supplies them, so a global CLI runs a project with nothing installed. Listed in `dependencies`, they lock it to the installed copies. See [Bundled and locked projects](versioning.md#bundled-and-locked-projects).
|
|
17
|
+
|
|
18
|
+
Any package manager installs it, and the command runs on Node or on Bun: `npm install` and `npx protobase <command>` work the same. The bin starts with `#!/usr/bin/env node`, so where Node is installed `bun run protobase` starts it on Node, unless the project's `bunfig.toml` sets `[run] bun = true`, as the presets' does. `protobase --version` (or `-v`) prints the Protobase version. Before any command runs, the CLI checks that the version specifier the current directory's `package.json` lists the `@protobase` packages at holds its own version, and stops with an error naming both when it does not (see [Versioning](versioning.md#bundles-and-runtimes)). That is the CLI's one version check. Outside a project, or in one that lists no `@protobase` package, there is nothing to check. In a locked project that has its own `@protobase/cli` installed, a CLI installed elsewhere, globally, in CI or in an image, hands the command over to that one before anything else, with a line on stderr naming its version, so the project runs on the version it is locked to.
|
|
16
19
|
|
|
17
20
|
## How it runs
|
|
18
21
|
|
|
@@ -22,7 +25,7 @@ In this repository nothing needs a build: the packages' `exports` point at `src`
|
|
|
22
25
|
|
|
23
26
|
### In another process
|
|
24
27
|
|
|
25
|
-
A process that runs many commands, such as a deploy, can run them without starting the CLI each time. `@protobase/cli/runner` exports one function,
|
|
28
|
+
A process that runs many commands, such as a deploy, can run them without starting the CLI each time. `@protobase/cli/runner` exports one function for that; `@protobase/cli/auth` exports the other one a script may call, `loadProjectAuth`, which builds the project's sign-in as the `users` commands do (see [Auth](auth.md#first-run)). Nothing else of the CLI is exported:
|
|
26
29
|
|
|
27
30
|
```ts
|
|
28
31
|
import { runCommand } from '@protobase/cli/runner'
|
|
@@ -38,7 +41,7 @@ const { exitCode, stdout, stderr } = await runCommand(['doctor', '--env', 'DATAB
|
|
|
38
41
|
|
|
39
42
|
The serve runtime is bundled by `protobase build-serve` into one JavaScript file for Bun, so production needs neither `node_modules` nor the CLI (see [serve](#serve)).
|
|
40
43
|
|
|
41
|
-
|
|
44
|
+
`scaffold` and `doctor` read the database with `default_transaction_read_only = on`, so they can never write, and so does `dev`'s check of the connection. The commands that manage the app's data do write: `users`, `organizations`, `encryption apply`, `files cleanup` and `import supabase`.
|
|
42
45
|
|
|
43
46
|
## `scaffold`
|
|
44
47
|
|
|
@@ -52,6 +55,7 @@ Protobase's own tables are left out, since they hold password hashes, OAuth toke
|
|
|
52
55
|
|
|
53
56
|
| Option | Effect |
|
|
54
57
|
| --- | --- |
|
|
58
|
+
| `--env <variable>` | read the connection string from this variable instead of `DATABASE_URL` |
|
|
55
59
|
| `--config <dir>` | config folder, default `config` |
|
|
56
60
|
| `--yes` | accept every proposal, no prompts (required without a TTY) |
|
|
57
61
|
| `--dry-run` | print a diff, write nothing |
|
|
@@ -125,10 +129,10 @@ protobase dev [--port 5173] [--env DATABASE_URL] [--cache-dir <dir>] [--allowed-
|
|
|
125
129
|
|
|
126
130
|
One port, two processes: Vite serves the admin app from `@protobase/ui`'s `src/app/` (`dist/app/` when installed; `index.html` and `main.tsx`, or `main.js`; the command fails with a clear message when they are missing) and hands `/api`, supabase-js's `/api/sb` included, to the Hono app from `createAdmin`, which runs in a process of its own; the CLI's process never loads `@protobase/server`. Open `http://localhost:<port>`; the API reference is at `/api/docs`.
|
|
127
131
|
|
|
128
|
-
- **Server package:** the API's process loads `@protobase/server` from the project's `node_modules
|
|
132
|
+
- **Server package:** in a locked project, whose `package.json` lists the `@protobase` packages in `dependencies`, the API's process loads `@protobase/server` from the project's `node_modules`; one that is not installed fails as with any missing package. A bundled project, which lists them in `devDependencies`, lists none or has no `package.json`, gets the CLI's own copies of every package the serve runtime supplies, the `@protobase` packages, `kysely`, `pg`, `react` and the rest of [the list](#the-config-module), for its files too, whatever it installed; its page code's imports of the `@protobase` packages, React and React DOM get the admin app's own copies.
|
|
129
133
|
|
|
130
134
|
- **Secret:** a `PROTOBASE_SECRET` still set to the placeholder of `.env.example` (`change-me-...`) prints a warning once the server is ready, as `serve` does at start: anyone who knows it can sign session cookies.
|
|
131
|
-
- **Database:** the URL comes from the variable named by `--env`, read from the environment or the nearest `.env` at or above the project. The connection is checked before anything starts; if it fails, the command names host, port and reason (and, when nothing listens there, points to its `db:up` script when it has one). The
|
|
135
|
+
- **Database:** the URL comes from the variable named by `--env`, read from the environment or the nearest `.env` at or above the project. The connection is checked before anything starts; if it fails, the command names host, port and reason (and, when nothing listens there, points to its `db:up` script when it has one). The API connects with Kysely over the `pg` the config gets: the project's own when it is locked, the CLI's when bundled.
|
|
132
136
|
- **Port:** the app listens on `--port` at both `127.0.0.1` and `::1`, since `localhost` is either one depending on the runtime and the browser. When another process holds the port on either address the command stops before it starts and names that address; stop the other server or pass another `--port`.
|
|
133
137
|
- **Cache:** Vite's dependency cache is `node_modules/.vite`; two dev servers sharing it can disturb each other's optimisation, so pass `--cache-dir` for a second one (the integration test does).
|
|
134
138
|
- **Login:** real sign-in only, with the config's `auth`, on by default, or its `authenticate` for tokens of an auth server elsewhere (see [protobase.config.ts](config.md) and [Login with Better Auth](auth.md)). A project with sign-in off and no authenticator fails at startup with a message pointing there, as does one with sign-in on and no `PROTOBASE_SECRET`, one whose auth store has not applied every migration of this version, naming them (see [`auth migration`](#auth-migration)), one with a resource over a table of the auth store, and one with a resource whose [events](events.md) or [history](history.md) lack their triggers, or whose [comments](comments.md) lack their table, or whose [rollup and formula fields](data-config.md#rollups-and-formulas) lack their columns or triggers, which it checks again on every reload (see [`migration`](#migration)), and one with an [AI field or action](ai.md#the-model) and no model key; there is no development login. The `login` line of the startup message says how to sign in: while the auth store has no users, it prints the exact command that creates the first admin, such as `bun run protobase users create you@example.com --generate-password` (the package manager that started `dev`, `npx` otherwise). Against a database that has users already, such as an app's hosted one, sign in as one of them or add one with a new email; its own password is set there. A `warning` line follows for each way the auth store's tables differ from what the app's sign-in needs, such as a column dropped by hand: the one place Protobase compares them, since `serve` reads the store's record of [migrations](auth.md#migrations) alone.
|
|
@@ -210,7 +214,7 @@ By default the bundle runs on Node and on Bun. `--bun` makes it a bundle for Bun
|
|
|
210
214
|
}
|
|
211
215
|
```
|
|
212
216
|
|
|
213
|
-
- `protobase` is the Protobase version the
|
|
217
|
+
- `protobase` is the Protobase version of the copies the build used: the building CLI's own in a bundled project, and in a locked one the `@protobase` packages its lockfile installed, whichever CLI built the bundle. A host serves the bundle on the runtime of that version (see [Versioning](versioning.md#bundles-and-runtimes)). A bundled project needs nothing installed; a locked one fails without its `@protobase` packages installed.
|
|
214
218
|
- `server`, `public`, `nodeModules` and `migrations` are relative to the bundle folder; `spa`, `theme` and each plugin's `path` to `public`.
|
|
215
219
|
- `plugins` are the bundle's own plugins, in the order the app merges them: the extensions', then the project's (`app`). Each names its `plugin.json`, the plugin API and Protobase versions it is built for, and the [field types](plugins.md#field-types) it registers with the storage types each shows, which the serve runtime checks the views against at startup. `/api/meta` names them to everyone, before any other plugin.
|
|
216
220
|
- `shell` is the admin app `public/` holds a copy of: its Protobase version and plugin API, and its files as URL paths. A host with a shell of its own may serve its own for those paths instead (see [The UI](#the-ui)), so the app gets that release's fixes without a rebuild.
|
|
@@ -228,7 +232,7 @@ By default the bundle runs on Node and on Bun. `--bun` makes it a bundle for Bun
|
|
|
228
232
|
`public/` holds two parts that are built apart.
|
|
229
233
|
|
|
230
234
|
- **The shell**, `index.html`, `assets/` and `protobase.sw.js`: the admin app, a production build of `@protobase/ui`'s `src/app` with no project code in it, the same for every project on a release. `@protobase/ui`'s package ships it prebuilt in `dist/shell/` and the [protobase image](../guides/deploy.md#images) at `/opt/protobase/shell/`; the build copies it. It calls the API on its own origin under `/api`, so the same bundle works under any hostname, and reads everything else at runtime: the resources, views, pages and roles from `/api/meta`, sign-in from `/api/auth`, the project's UI from its plugins and its look from `/protobase.theme.css`, which it links after its own stylesheets, its tab icon from `/protobase.favicon.svg`, and its [web app manifest](installable-app.md) from `/api/manifest.webmanifest`.
|
|
231
|
-
- **The plugins**, `plugins/<name>/`: the project's `protobase.ui.tsx` as the plugin `app`, and each [extension](#extensions)'s, each built as [`build-plugin`](#build-plugin) builds one, against the `@protobase/ui` installed in
|
|
235
|
+
- **The plugins**, `plugins/<name>/`: the project's `protobase.ui.tsx` as the plugin `app`, and each [extension](#extensions)'s, each built as [`build-plugin`](#build-plugin) builds one, against the CLI's own `@protobase/ui` in a bundled project and the one installed in a locked project. `/api/meta` names them, and the shell loads them as it loads any [plugin](plugins.md). A component or field type the config declares but no `protobase.ui.tsx` exports fails the build (see [Components](custom-components.md#components)).
|
|
232
236
|
|
|
233
237
|
The modules the app shares with plugins, `react`, `react/jsx-runtime`, `react-dom` and `@protobase/ui`, are entries of their own, `/assets/shared-<name>-<hash>.js`, each exporting every name of its module. `index.html` maps the four names to them with an import map, ahead of every script, so a plugin's imports of them run on the app's copies.
|
|
234
238
|
|
|
@@ -298,6 +302,24 @@ docker run --rm -p 127.0.0.1:8787:8787 -e DATABASE_URL -e PROTOBASE_URL -e PROTO
|
|
|
298
302
|
protobase-run --no-install /opt/protobase/protobase-serve.js /app/protobase.config.js
|
|
299
303
|
```
|
|
300
304
|
|
|
305
|
+
## `types`
|
|
306
|
+
|
|
307
|
+
```sh
|
|
308
|
+
protobase types # writes .protobase/tsconfig.json; dev and build write it too
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Writes `.protobase/tsconfig.json`, which the project's `tsconfig.json` extends (`"extends": "./.protobase/tsconfig.json"`). In a bundled project its `paths` point each `@protobase` package and each package the serve runtime supplies, by name and by each of its exports (`@protobase/layout/jsx-runtime`, `kysely`, `zod`, ...), at the declarations of the CLI that builds the app, so the editor and `tsc` see the version that runs with nothing installed. There is no catch-all, so a package the project imports and lacks still fails as missing. React carries no types of its own, so the project keeps `@types/react`, as it keeps `@types/node`. A locked project's installed packages type themselves, so its file holds no `paths`. A `paths` of the project's own `tsconfig.json` replaces the generated one, as `extends` does with any option.
|
|
312
|
+
|
|
313
|
+
`.protobase/` ignores itself in git: the paths are this machine's. Write the file again after installing another CLI; `dev` and `build` do it on every run.
|
|
314
|
+
|
|
315
|
+
## `run`
|
|
316
|
+
|
|
317
|
+
```sh
|
|
318
|
+
protobase run <file> [args...] # e.g. "db:seed": "protobase run seed/cli.ts"
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Runs one of the project's scripts, such as a seed or a migration, under Bun in a process of its own, in the current directory, with the arguments after the file, options included, passed to the script and its exit code passed back. In a bundled project the script's imports of the `@protobase` packages and of every package the serve runtime supplies (`kysely`, `pg`, `postgres`, `zod`, ...) get the CLI's own copies, as a bundle gets the runtime's, with nothing installed: a preload registers them as Bun's virtual modules. A locked project's script imports its installed packages. Bun never installs a missing package for it (`--no-install`), so a script that imports a package the project lacks fails as missing. It needs `bun` on `PATH`.
|
|
322
|
+
|
|
301
323
|
## `build-plugin`
|
|
302
324
|
|
|
303
325
|
```sh
|
|
@@ -316,7 +338,7 @@ dist/
|
|
|
316
338
|
- The output folder is emptied first, so it must not be the plugin's folder or hold it.
|
|
317
339
|
- The module is `protobase.ui.tsx` with everything it imports bundled, except the four modules the app shares (`react`, `react/jsx-runtime`, `react-dom`, `@protobase/ui`), which stay imports by those names. Any other module of those packages, such as `react-dom/client`, fails the build. React's production build and JSX runtime are used, whatever `NODE_ENV` says, and every export of `protobase.ui.tsx` is kept.
|
|
318
340
|
- The stylesheet is Tailwind's utilities for the classes in the plugin's folder: no reset, no theme values. Each utility reads the theme of the app that loads it, with Tailwind's default as the fallback (`text-sm` is `font-size: var(--text-sm, 0.875rem)`).
|
|
319
|
-
- `plugin.json` names the plugin (`--name`, else its `package.json`'s `name`, else its folder's), its own `version`, the plugin API (`api`) and the Protobase versions (`protobase`) it is built for, the module (`entry`) and stylesheet (`css`), relative to it, and the [field types](plugins.md#field-types) it registers (`fields`), each with the storage types it shows. Both versions come from the `@protobase/ui` installed for the plugin,
|
|
341
|
+
- `plugin.json` names the plugin (`--name`, else its `package.json`'s `name`, else its folder's), its own `version`, the plugin API (`api`) and the Protobase versions (`protobase`) it is built for, the module (`entry`) and stylesheet (`css`), relative to it, and the [field types](plugins.md#field-types) it registers (`fields`), each with the storage types it shows. Both versions come from the `@protobase/ui` installed for the plugin, else for the project it extends, else the CLI's own: `api` is its plugin API, and `protobase` is `>=` its version unless the plugin's `package.json` names a range in `engines.protobase` (see [Plugins](plugins.md#versions)).
|
|
320
342
|
- `--source-maps` ends each script with a `//# debugId=<uuid>` comment, naming no map, and writes its source map, `<script>.js.map` carrying the same `debugId`, beside it, for an error tracker to read the browser's stack frames with.
|
|
321
343
|
|
|
322
344
|
To read its field types, the build loads the plugin's module once in Node, with everything bundled; nothing is rendered, but code at the top level of its modules runs, so keep browser-only work (`window`, `document`) inside components and handlers. The app loads it from wherever `plugin.json` is served, listed in `PROTOBASE_PLUGINS` or the config's `plugins` (see [loading](plugins.md#loading)).
|
|
@@ -332,10 +354,10 @@ Bundles the serve runtime (`@protobase/cli`'s `src/serve/main.ts`) and all its d
|
|
|
332
354
|
```sh
|
|
333
355
|
bun --no-install protobase-serve.js [serve] <bundle> # the folder: the app and the API; the config module: the API
|
|
334
356
|
bun --no-install protobase-serve.js migrate <bundle> # apply the bundle's migrations to DATABASE_URL
|
|
335
|
-
bun --no-install protobase-serve.js create-admin <bundle> <email> # --generate-password
|
|
357
|
+
bun --no-install protobase-serve.js create-admin <bundle> <email> # [--name <name>] [--generate-password | --password-stdin]
|
|
336
358
|
```
|
|
337
359
|
|
|
338
|
-
`migrate` runs none of the app's code and needs only `DATABASE_URL`; `create-admin` loads the app with its settings and refuses an auth schema that is behind. Given the folder, the runtime serves the bundle's own copy of the app. [Deploy](../guides/deploy.md#a-self-hosted-image) puts the three in a self-hosted image.
|
|
360
|
+
`migrate` runs none of the app's code and needs only `DATABASE_URL`; `create-admin` loads the app with its settings and refuses an auth schema that is behind; without `--generate-password` or `--password-stdin` it asks for the password at a hidden prompt. Given the folder, the runtime serves the bundle's own copy of the app. [Deploy](../guides/deploy.md#a-self-hosted-image) puts the three in a self-hosted image.
|
|
339
361
|
|
|
340
362
|
## `serve`
|
|
341
363
|
|
|
@@ -362,7 +384,14 @@ Serves the API of a bundle from `protobase build` and owns the process around it
|
|
|
362
384
|
| `PROTOBASE_OPERATOR_ISSUER`, `PROTOBASE_OPERATOR_CLIENT_ID`, `PROTOBASE_OPERATOR_CLIENT_SECRET` | the OpenID Connect provider of the operator's staff, for [staff sign-in](auth.md#staff-sign-in) as people of the app; all three or none. `PROTOBASE_OPERATOR_NAME` and `PROTOBASE_OPERATOR_GROUP` are optional ([Operator provider](auth.md#operator-provider)) |
|
|
363
385
|
| `PROTOBASE_ORIGINS`, `PROTOBASE_PASSKEY_DOMAIN` | the other origins the app is served on, comma separated, and the host new passkeys are made for ([Several origins](auth.md#several-origins)) |
|
|
364
386
|
| `PROTOBASE_CORS_ORIGINS` | other websites whose browser code may call the API, `*` or comma separated http and https origins ([CORS](api.md#cors)) |
|
|
387
|
+
| `PROTOBASE_PREVIOUS_SECRETS` | the app's secrets before `PROTOBASE_SECRET`, newest first, comma separated, which still decrypt what they encrypted, unless the config sets [`previousSecrets`](config/app.md#previoussecrets) |
|
|
388
|
+
| `PROTOBASE_TRUSTED_ORIGINS` | extra origins that may call the auth endpoints, comma separated, unless the config sets [`auth.trustedOrigins`](config/sign-in.md#authtrustedorigins) |
|
|
389
|
+
| `PROTOBASE_PUBLISHABLE_KEY`, `PROTOBASE_SECRET_KEY` | the app's [API keys](config/api.md#apikeys), unless the config sets `apiKeys` |
|
|
390
|
+
| `PROTOBASE_PLUGINS`, `PROTOBASE_PLUGINS_BEFORE_SIGN_IN` | [plugins](plugins.md#loading) a hosting platform adds to the app, their `plugin.json` URLs comma separated; the second also load before sign-in |
|
|
391
|
+
| `PROTOBASE_FORMS_SECRET` | the secret [public forms](forms.md#bot-check) sign their bot checks with, over the app's secret |
|
|
392
|
+
| `PROTOBASE_VAPID_PUBLIC_KEY`, `PROTOBASE_VAPID_PRIVATE_KEY`, `PROTOBASE_VAPID_SUBJECT` | the key pair and contact of [Web Push](notifications.md#web-push), from [`notifications vapid-keys`](#notifications-vapid-keys) |
|
|
365
393
|
| `PROTOBASE_ASSISTANT_URL`, `PROTOBASE_ASSISTANT_API_KEY`, `PROTOBASE_ASSISTANT_MODEL`, `PROTOBASE_ASSISTANT_BASE_URL` | the [assistant](assistant.md#which-backend): a backend elsewhere, or the built-in one on OpenRouter or another OpenAI-compatible endpoint; without them there is none |
|
|
394
|
+
| `PROTOBASE_ASSISTANT_CHATS` | the folder the built-in assistant keeps its conversations in; default `.protobase/chats` |
|
|
366
395
|
| `PROTOBASE_RUNTIME_URL` | the endpoint behind the top bar's [runtime update button](versioning.md#runtime-updates), such as a hosting platform's; without it there is no button |
|
|
367
396
|
| `PROTOBASE_SENTRY_DSN` | the DSN of a Sentry-compatible error tracker the app's server and admin app send their errors to, after the config's `errorReporting` ([Error reporting](api.md#error-reporting)); without it nothing is sent |
|
|
368
397
|
| `PROTOBASE_MAP_STYLE_URL` | the URL of the MapLibre style the record page's [maps](ui-config.md#maps) are drawn with, after the config's `maps`; without it there are no maps |
|
|
@@ -401,7 +430,7 @@ With a `mobile` section, the server serves the [mobile app](../guides/mobile-app
|
|
|
401
430
|
protobase worker <bundle> # a bundle from `protobase build`: its folder or its protobase.config.js
|
|
402
431
|
```
|
|
403
432
|
|
|
404
|
-
Runs the bundle's [jobs](jobs.md), and the delivery of its [events](webhooks.md#delivery-and-retries), and nothing else, until SIGTERM or SIGINT, which let running jobs finish for 30 seconds as `serve` does. It checks the bundle's version and the jobs schema at start like `serve`, reads the `.env` nearest the current directory and needs `DATABASE_URL`. Run it beside a `serve` with `PROTOBASE_JOBS=false`, from the same bundle. `protobase worker running <n> jobs` means it is ready.
|
|
433
|
+
Runs the bundle's [jobs](jobs.md), and the delivery of its [events](webhooks.md#delivery-and-retries), and nothing else, until SIGTERM or SIGINT, which let running jobs finish for 30 seconds as `serve` does. It checks the bundle's version and the jobs schema at start like `serve`, reads the `.env` nearest the current directory and needs `DATABASE_URL`. Run it beside a `serve` with `PROTOBASE_JOBS=false`, from the same bundle. It refuses a bundle with nothing to run: no jobs, and no resource with events, history, comments or an AI field, whose jobs are Protobase's own. Like `serve`, it reports a crash to the app's [error tracker](api.md#error-reporting). `protobase worker running <n> jobs` means it is ready.
|
|
405
434
|
|
|
406
435
|
## `files cleanup`
|
|
407
436
|
|
|
@@ -433,7 +462,7 @@ Encrypts every plaintext value of the encrypted fields with the current key, enc
|
|
|
433
462
|
|
|
434
463
|
`--rebind <resource>[.<field>]` with `--from-table <table>` (as `.table()` wrote it) or `--from-column <column>` also takes values sealed where the field was before a rename, and seals them where it is now; running it again rebinds nothing more. It refuses a former place another resource still encrypts.
|
|
435
464
|
|
|
436
|
-
Run it at update time, after the migrations and before the new version serves, and again once an old version that wrote plaintext has stopped. It works over one database connection
|
|
465
|
+
Run it at update time, after the migrations and before the new version serves, and again once an old version that wrote plaintext has stopped. It works over one database connection.
|
|
437
466
|
|
|
438
467
|
## `notifications vapid-keys`
|
|
439
468
|
|
|
@@ -447,7 +476,7 @@ Prints a fresh key pair for [Web Push](notifications.md#web-push) as `PROTOBASE_
|
|
|
447
476
|
|
|
448
477
|
```sh
|
|
449
478
|
protobase users create <email> [--name <name>] [--role <role>] [--password-stdin | --generate-password | --no-password] [--github-id <id>]
|
|
450
|
-
[--organization <
|
|
479
|
+
[--organization <organization> [--org-role <role>] [--app-roles <a,b>]]
|
|
451
480
|
protobase users list
|
|
452
481
|
protobase users roles
|
|
453
482
|
protobase users set-role <email> <role>
|
|
@@ -455,13 +484,13 @@ protobase users disable <email> # and: enable <email>
|
|
|
455
484
|
protobase users delete <email> [--yes]
|
|
456
485
|
```
|
|
457
486
|
|
|
458
|
-
Run inside a project with sign-in on (its config's `auth`, on unless `false`). There is no web setup page, and [open sign-up](auth.md#open-sign-up), when a project turns it on, waits for the first admin: the first admin is created here. The first user is always an admin, whatever `--role` says; later users get `--role`, or the project's default role (`auth: { roles, defaultRole }` in its config). `protobase users roles` lists the roles of the project; anything else is refused with that list. `set-role` also takes comma separated roles (`sales,accountant`). `--github-id` links the new user to a GitHub user id (the number, not the login), so signing in with GitHub, the app's own provider or the [platform's](auth.md#platform-sign-in-provider), finds them whatever address GitHub reports; an id that signs in another user already is refused. `createUser(auth, { ..., accounts: [{ providerId, accountId }] })` does the same from code.
|
|
487
|
+
Run inside a project with sign-in on (its config's `auth`, on unless `false`, or unless the config leaves `auth` out and sets `authenticate.jwksUrl`). Like `organizations`, `token` and `auth migration`, it reads the `.env` nearest the project and needs `DATABASE_URL`. There is no web setup page, and [open sign-up](auth.md#open-sign-up), when a project turns it on, waits for the first admin: the first admin is created here. The first user is always an admin, whatever `--role` says; later users get `--role`, or the project's default role (`auth: { roles, defaultRole }` in its config). `protobase users roles` lists the roles of the project; anything else is refused with that list. `set-role` also takes comma separated roles (`sales,accountant`). `--github-id` links the new user to a GitHub user id (the number, not the login), so signing in with GitHub, the app's own provider or the [platform's](auth.md#platform-sign-in-provider), finds them whatever address GitHub reports; an id that signs in another user already is refused. `createUser(auth, { ..., accounts: [{ providerId, accountId }] })` does the same from code.
|
|
459
488
|
|
|
460
489
|
The password is typed at a hidden prompt with confirmation, read from stdin with `--password-stdin` (for scripts, e.g. `pass show erp | protobase users create me@example.com --password-stdin`), or generated with `--generate-password` and printed once; it must be 12 to 128 characters, the length the app requires of every new password. `--no-password` makes an account without one, which signs in by [emailed code](auth.md#emailed-sign-in-codes), passkey or a sign-in provider, as with an app whose [sign-in policy](auth.md#sign-in-policy) turns passwords off. A password is never accepted as an argument, since it would end up in shell history. `users list` prints email, role and creation date (and `disabled` for banned users), never credentials.
|
|
461
490
|
|
|
462
491
|
`delete` asks you to type the email back (or pass `--yes`), and needs a terminal otherwise. `delete`, `set-role` and `disable` refuse to touch the last admin, so the project cannot lock itself out. `disable` bans the user and revokes their sessions; tokens already issued stop working on their next request, and `protobase token` refuses disabled users. With [MCP](auth.md#oauth-for-mcp-clients) on, it also disconnects their MCP clients. `enable` lifts the ban; the clients have to be allowed again. `protobase dev` prints the command that creates the first admin at startup while the user table is empty (see [`dev`](#dev)).
|
|
463
492
|
|
|
464
|
-
With [organizations](auth.md#organizations), `--role` is the user's global role (none by default) and `--organization` adds the new user to an organization, with `--org-role` (`owner`, `admin`, or `member`, the default) and `--app-roles` there.
|
|
493
|
+
With [organizations](auth.md#organizations), `--role` is the user's global role (none by default) and `--organization` adds the new user to an organization, by its slug or id, with `--org-role` (`owner`, `admin`, or `member`, the default) and `--app-roles` there.
|
|
465
494
|
|
|
466
495
|
## `organizations`
|
|
467
496
|
|
|
@@ -527,7 +556,7 @@ protobase mobile build <ios|android> --app-version <x.y.z> --build-number <n> [-
|
|
|
527
556
|
[--team <id> [--certificate <name> --profile <name>]]
|
|
528
557
|
```
|
|
529
558
|
|
|
530
|
-
Builds the project in the current directory as an iOS or Android app with Capacitor, from the `mobile` section of its `protobase.config.ts`; without one it stops and says what to add. See [A mobile app](../guides/mobile-app.md).
|
|
559
|
+
Builds the project in the current directory as an iOS or Android app with Capacitor, from the `mobile` section of its `protobase.config.ts`; without one it stops and says what to add. `--extend <dir>` (repeatable) merges an [extension](config.md#extensions)'s `protobase.config.ts` and `protobase.ui.tsx` before the project's, as `build` does. See [A mobile app](../guides/mobile-app.md).
|
|
531
560
|
|
|
532
561
|
- It installs `@protobase/mobile`, of the CLI's version, which pins Capacitor and its plugins, with the section's `plugins` into `.protobase/mobile/` with npm, when that changed, and on every run for a package from a local folder, given as `file:` or a path such as `../my-plugin`, which npm copies. When such a folder's dependencies are not the versions installed, it removes the workspace's `node_modules` and `package-lock.json` so npm resolves them again, and stops when a pin is still not met, as when two packages pin one dependency at different versions. It builds the app's files as [`build`](#build) does and keeps only `public/`, its `index.html` naming the API origin; writes `capacitor.config.json`, compiling in only the section's plugins; and generates the platform's native project again, replacing the last one.
|
|
533
562
|
- `--api` is the server the app calls, the app's `url` by default: an http or https origin, plain http only to `localhost`, `127.0.0.1` and, on iOS, `[::1]`, or on Android `10.0.2.2`. An Android app calling `localhost` gets the port forwarded.
|
|
@@ -563,10 +592,10 @@ Copies the agent skills of this CLI's version into the current project, or only
|
|
|
563
592
|
```sh
|
|
564
593
|
bun run db:up && bun run --cwd tests/apps/erp db:migrate && bun run --cwd tests/apps/erp db:seed --scale small
|
|
565
594
|
bun run --cwd tests/apps/erp protobase scaffold postgres://protobase:protobase@localhost:55432/protobase \
|
|
566
|
-
--yes --ui --exclude
|
|
595
|
+
--yes --ui --exclude public.schema_migrations --exclude public.seed_info
|
|
567
596
|
bun run --cwd tests/apps/erp protobase doctor postgres://protobase:protobase@localhost:55432/protobase
|
|
568
597
|
```
|
|
569
598
|
|
|
570
|
-
|
|
599
|
+
The ERP keeps Better Auth's users, sessions and signing keys in the `auth` schema of the same database; scaffold leaves that store out on its own, so they are never exposed through the admin API. `--exclude` leaves out the migrations' and the seed's own bookkeeping tables.
|
|
571
600
|
|
|
572
601
|
The integration test (`packages/cli/tests/scaffold/scaffold.integration.test.ts`) scaffolds into a temp folder and is skipped when the database is unreachable.
|
|
@@ -17,10 +17,12 @@ const { record, etag } = await api.get(orders, id)
|
|
|
17
17
|
await api.update(orders, id, { status: 'shipped' }, etag) // 412 rejects with PreconditionFailedError
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
Pass a resource builder to get its record type ([`InferRecord`](https://docs.protobase.net/api/schema/type-aliases/inferrecord/)), or a name for loose records. Filters are AIP-160 text or [`where`](https://docs.protobase.net/api/schema/variables/where/) results (printed with [`printFilter`](https://docs.protobase.net/api/schema/functions/printfilter/)). Errors are `ApiError` (`status`, `slug`, `errors`, `filterErrors` with spans, `blockedBy` for a delete other records point at). Also: `search`, `create`, `remove`, `facets`, `series`, `histogram`, `map(resource, { latitude, longitude, zoom, filter?, orderBy?, fields? })` (the records in a map's view, or buckets of them, see [`:map`](api.md#maps)), `seek`, `reveal(resource, key, field)` (a [sensitive field](data-config.md#sensitive-fields)'s value), `generate(resource, key, action)` (runs an [AI action](ai.md#ai-actions) and resolves to the record as written), `meta(etag?, { signal? })`, `invoke(name, { body?, method?, path?, query? })` (one of the app's [API functions](../guides/api-functions.md#calling-a-function)), `upload(resource, field, file, { onProgress?, signal? })` (a file for a [file field](files.md#uploading); its `value` goes in the next write, and `onProgress` uses XMLHttpRequest, since fetch reports no upload progress), `live({ onChanges, onResync, onRetry? })` (hears which records of the [live](live.md) resources change until the function it returns is called, connecting again by itself).
|
|
20
|
+
Pass a resource builder to get its record type ([`InferRecord`](https://docs.protobase.net/api/schema/type-aliases/inferrecord/)), or a name for loose records. Filters are AIP-160 text or [`where`](https://docs.protobase.net/api/schema/variables/where/) results (printed with [`printFilter`](https://docs.protobase.net/api/schema/functions/printfilter/)). Errors are `ApiError` (`status`, `slug`, `errors`, `filterErrors` with spans, `blockedBy` for a delete other records point at), which `isApiError(error)` tells apart. Also: `search`, `create`, `remove`, `facets`, `series`, `histogram`, `map(resource, { latitude, longitude, zoom, filter?, orderBy?, fields? })` (the records in a map's view, or buckets of them, see [`:map`](api.md#maps)), `seek`, `reveal(resource, key, field)` (a [sensitive field](data-config.md#sensitive-fields)'s value), `generate(resource, key, action)` (runs an [AI action](ai.md#ai-actions) and resolves to the record as written), `meta(etag?, { signal? })`, `invoke(name, { body?, method?, path?, query? })` (one of the app's [API functions](../guides/api-functions.md#calling-a-function)), `upload(resource, field, file, { onProgress?, signal? })` (a file for a [file field](files.md#uploading); its `value` goes in the next write, and `onProgress` uses XMLHttpRequest, since fetch reports no upload progress), `live({ onChanges, onResync, onRetry? })` (hears which records of the [live](live.md) resources change until the function it returns is called, connecting again by itself).
|
|
21
21
|
|
|
22
22
|
With an absolute `baseUrl`, such as another app's `https://desk.example.com/api/v1`, the `url` of each [file](files.md) in a record the client answers is absolute too, on that API's origin, where the API answers a path on its own origin. `routedClient(own, sourceOf)` is one client over several APIs: each call about a resource goes to the client `sourceOf(resource)` gives, else to `own`, as the admin app does for [remote resources](remote-resources.md), and `sourceMeta(meta, source)` keeps the part of another API's `/meta` an app draws.
|
|
23
23
|
|
|
24
|
+
`createStaticSession(token)` is a session already signed in with a token you hold, such as one from [`protobase token`](cli.md#token), for stories and scripts: it never refreshes, so the token must outlive the run, and it cannot change the account. `tokenExpiry(token)` reads a JWT's expiry, in milliseconds.
|
|
25
|
+
|
|
24
26
|
## The admin app
|
|
25
27
|
|
|
26
28
|
`<App baseUrl="/api/v1" />` renders the shell from `/api/meta` (beside the API, so `createClient` derives it from `baseUrl`) and routes `/:page` and `/:page/:tab` ([composed pages](layouts.md) and their [tabs](blocks.md#tabs-and-tab)), `/:resource` (list) and `/:resource/:key` (record); it opens on the first entry of the [sidebar](sidebar.md) the user sees, or, with none, the first page or resource. Its own pages sit under `/-/`, which no page or resource name takes: `/-/account` and its tabs (the user's [account page](auth.md#account-page), from `/meta`'s `account`) and `/-/sign-in-policy` (admins: the policy, and the log of staff sign-ins). Before the shell, it signs in on its sign-in route, `/-/sign-in`, with the methods the server offers and asks for what the [sign-in policy](auth.md#sign-in-policy) requires. Someone signed out goes there from any page, with that page in `?next=`, and signing in comes back to it; each step (a forgotten password, an emailed code, making an account) adds `?step=`, so the browser's Back returns to the step before; `?staff-sign-in` opens the [staff sign-in](auth.md#staff-sign-in) page instead, and a staff session gets a banner below the top bar. `createAuthSession` from `@protobase/client` is that session (`signIn`, `signInWithCode`, `signInWithPasskey`, `verifyTwoFactor`, `account`, `signInPolicy`, `staff`). `ui` takes the project's [custom components and action handlers](custom-components.md). The list state lives in the URL: `?list=`, a [named list](ui-config.md#more-than-one-list), `?filter=` (AIP-160), `?order_by=`, `?display=`, the [display](ui-config.md#list-displays) it shows, `?layout=panel`, the filters in a panel beside the table on a desktop instead of a bar above it, `?map=52.37,4.89,12`, where a [map](ui-config.md#maps) looks, `?calendar=month,2026-10-01`, the month or week a [calendar](ui-config.md#calendars) shows, `?timeline=quarter,2026-10-01`, the week, month or quarter a [timeline](ui-config.md#timelines) shows, and `?saved_search=`, the [saved search](ui-config.md#saved-searches) the list was opened from. Views come from `tests/apps/*/config/*/ui.ts`. The sidebar's recent-record groups and the user menu are configured there too: see [Sidebar](sidebar.md), [User menu](user-menu.md) and [Bottom bar](bottom-bar.md).
|
|
@@ -11,7 +11,7 @@ The keys of the API, at the top level of [`protobase.config.ts`](../config.md).
|
|
|
11
11
|
- **Type:** `string`
|
|
12
12
|
- **Default:** `/api/v1`
|
|
13
13
|
|
|
14
|
-
The path of the REST API on the app's origin.
|
|
14
|
+
The path of the REST API on the app's origin. A bundle serves only `/api/v1`: `protobase serve`, the serve runtime and `protobase worker` refuse a config with another path, so another one works in `protobase dev` and in a server of the app's own around `createAdmin`.
|
|
15
15
|
|
|
16
16
|
```ts
|
|
17
17
|
export default defineConfig({ apiPath: '/api/v2' })
|
|
@@ -117,7 +117,7 @@ export default defineConfig({ writeHooks: ['queue-sent-invoice'] })
|
|
|
117
117
|
- **Type:** `{ sql?: boolean; writes?: boolean | { resources?: string[]; rolesWithoutApproval?: string[] } } | false`
|
|
118
118
|
- **Default:** the read tools only: `list_resources`, `list_records` and `get_record`
|
|
119
119
|
|
|
120
|
-
The MCP endpoint's tools; [`auth.mcp`](sign-in.md#authmcp) turns the endpoint on. `sql: true` also offers admins and the `ai` role `run_read_only_query`, which reads the whole database outside the access rules. `writes: true` offers `create_record` and `
|
|
120
|
+
The MCP endpoint's tools; [`auth.mcp`](sign-in.md#authmcp) turns the endpoint on. `sql: true` also offers admins and the `ai` role `run_read_only_query`, which reads the whole database outside the access rules. `writes: true` offers `create_record`, `update_record`, `delete_record` and `batch_write` through the REST API's rules, each approved by the person in their client; `writes.resources` limits them to the resources named, and `writes.rolesWithoutApproval` lets holders of those roles, such as a service account, write without the approval. `false` is for a host that serves its own MCP endpoint at `auth.mcp.path`, in front of this app. See [MCP](../mcp.md#the-tools).
|
|
121
121
|
|
|
122
122
|
```ts
|
|
123
123
|
export default defineConfig({ auth: { mcp: true }, mcpEndpoint: { writes: { resources: ['tasks'] } } })
|
|
@@ -12,7 +12,7 @@ The keys of the app itself, at the top level of [`protobase.config.ts`](../confi
|
|
|
12
12
|
- **Default:** `Protobase`
|
|
13
13
|
- **Environment variable:** `PROTOBASE_APP_NAME`, which overrides it
|
|
14
14
|
|
|
15
|
-
The app's name: sign-in prompts and passkeys show it, the mail it sends names the app with it and is sent as it, and the sidebar, the browser tabs and the [installed app](../installable-app.md) are called by it. A deployment renames the app with `PROTOBASE_APP_NAME`, which wins over the config. See [App identity](../app-identity.md#the-name).
|
|
15
|
+
The app's name: sign-in prompts and passkeys show it, the mail it sends names the app with it and is sent as it, and the sidebar, the browser tabs and the [installed app](../installable-app.md) are called by it. A deployment renames the app with `PROTOBASE_APP_NAME`, which wins over the config. The name reaches the app through its sign-in, so with sign-in off (`auth: false`, or an `authenticate.jwksUrl` without `auth`) the app shows `PROTOBASE_APP_NAME`, else `Protobase`, and only [`protobase mobile`](../cli.md#mobile) reads `name` itself. See [App identity](../app-identity.md#the-name).
|
|
16
16
|
|
|
17
17
|
```ts
|
|
18
18
|
export default defineConfig({ name: 'Property Finder' })
|
|
@@ -36,7 +36,7 @@ export default defineConfig({ url: 'https://admin.example.com' })
|
|
|
36
36
|
- **Default:** `PROTOBASE_SECRET`
|
|
37
37
|
- **Environment variable:** `PROTOBASE_SECRET`
|
|
38
38
|
|
|
39
|
-
The app's secret, made with `openssl rand -base64 32`: it signs session cookies, upload tickets, download links and public forms' bot checks, and encrypts the token signing keys. Sign-in needs it, and file fields too unless [`files.secret`](files.md#filessecret) names another. Keep it out of the config's source and read it from the environment, which the default does.
|
|
39
|
+
The app's secret, made with `openssl rand -base64 32`: it signs session cookies, upload tickets, download links and public forms' bot checks, and encrypts the token signing keys. Sign-in needs it, and file fields too unless [`files.secret`](files.md#filessecret) names another; public forms sign their bot checks with `PROTOBASE_FORMS_SECRET` instead when it is set. Keep it out of the config's source and read it from the environment, which the default does.
|
|
40
40
|
|
|
41
41
|
```ts
|
|
42
42
|
export default defineConfig(({ env }) => ({ secret: env.ADMIN_SECRET }))
|
|
@@ -20,8 +20,7 @@ export default defineConfig({ auth: { roles: ['admin', 'sales'], signInFirst: 'e
|
|
|
20
20
|
Sign-in runs the project's own code from these files, each loaded when Protobase builds sign-in:
|
|
21
21
|
|
|
22
22
|
- `auth/hooks.ts`: the hooks, as named exports typed with `AuthHooks` from `@protobase/server`: `generateUserId`, `onUserCreated`, `generateOrganizationId`, `onOrganizationCreated`, `beforeOrganizationDeleted` and `organizationHooks`. Each gets the app's database, `{ db }`, as its last argument. See [Hooks](../auth.md#hooks).
|
|
23
|
-
- `auth/mailer.ts`: a mailer of the project's own
|
|
24
|
-
- `emails/`: the templates of sign-in's mail. See [Templates](../email.md#templates).
|
|
23
|
+
- `auth/mailer.ts`: a mailer of the project's own, as its default export, in place of the SMTP mailer: sign-in's mail and the jobs' `mail` both go through it. See [Email](../email.md).
|
|
25
24
|
|
|
26
25
|
With [extensions](../config.md#extensions), the hooks and the mailer are those of the last folder whose config sets `auth`.
|
|
27
26
|
|
|
@@ -264,7 +263,7 @@ export default defineConfig({ auth: { origins: ['https://admin.shop.com'], passk
|
|
|
264
263
|
- **Default:** `PROTOBASE_TRUSTED_ORIGINS`, comma separated
|
|
265
264
|
- **Environment variable:** `PROTOBASE_TRUSTED_ORIGINS`
|
|
266
265
|
|
|
267
|
-
Extra origins that may call the auth endpoints, such as the exact host of a dev tunnel;
|
|
266
|
+
Extra origins that may call the auth endpoints, such as the exact host of a dev tunnel; none is trusted by default. An entry with `*`, such as `https://*.example.com`, trusts every host it matches, so list only hosts you control. `url` and `origins` always are. Set in the config, it replaces the variable's list.
|
|
268
267
|
|
|
269
268
|
```ts
|
|
270
269
|
export default defineConfig(({ env }) => ({
|
|
@@ -354,7 +353,7 @@ export default defineConfig({ authenticate: { jwksUrl: 'https://auth.example.com
|
|
|
354
353
|
- **Type:** `{ refreshMs?: number; minReloadMs?: number }`
|
|
355
354
|
- **Default:** `{ refreshMs: 600000, minReloadMs: 30000 }`
|
|
356
355
|
|
|
357
|
-
How long the key set is kept
|
|
356
|
+
How long the app's own key set is kept, when the tokens are those of `auth`: reloaded whole every `refreshMs`, so removed keys stop working, and when a token names an unknown key, at most every `minReloadMs`. A key set at `jwksUrl` is cached by its own rules, and `cache` does not change them.
|
|
358
357
|
|
|
359
358
|
```ts
|
|
360
359
|
export default defineConfig({ authenticate: { cache: { refreshMs: 60_000 } } })
|
|
@@ -57,7 +57,7 @@ export default defineConfig(({ command, env }) => ({
|
|
|
57
57
|
|
|
58
58
|
| | |
|
|
59
59
|
| --- | --- |
|
|
60
|
-
| `command` | `dev`, `build`, `serve` (also `protobase worker` and the serve runtime's `migrate`
|
|
60
|
+
| `command` | `dev`, `build`, `serve` (also `protobase worker` and the serve runtime's `create-admin`; the runtime's `migrate` never reads the config), or `tool`, any other command over the project, such as `migration`, `users` or `doctor` |
|
|
61
61
|
| `env` | `process.env`, with the project's `.env` loaded |
|
|
62
62
|
| `root` | the project's folder |
|
|
63
63
|
|
|
@@ -87,7 +87,7 @@ export default defineConfig(({ env }) => ({
|
|
|
87
87
|
}))
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
-
A JSON config reads one with an `$env` value: `{ "$env": "NAME" }`, with `"default"` for when the variable is unset or empty, and `"split": ","` for a list of its non-empty parts, each trimmed. A value whose variable is unset and has no default is left out, as if the key were not written. A TypeScript config may write `$env` values too, but its types do not know them; `env` is the typed way.
|
|
90
|
+
A JSON config reads one with an `$env` value: `{ "$env": "NAME" }`, with `"default"` for when the variable is unset or empty, and `"split": ","` for a list of its non-empty parts, each trimmed. A value whose variable is unset and has no default is left out, as if the key were not written (an item of a list stays, as `undefined`). An `$env` value is always text, the variable's or the `default` as written: `"30"` is not the number 30, and `"false"` is not `false`, so a key that takes a number or a boolean takes it written in the config, or from a TypeScript config that converts it. A TypeScript config may write `$env` values too, but its types do not know them; `env` is the typed way.
|
|
91
91
|
|
|
92
92
|
The app's database is `DATABASE_URL`'s, with the pool size of `PROTOBASE_DB_CONNECTIONS`; neither is a key of the config.
|
|
93
93
|
|
|
@@ -97,6 +97,7 @@ The app's database is `DATABASE_URL`'s, with the pool size of `PROTOBASE_DB_CONN
|
|
|
97
97
|
|
|
98
98
|
```json
|
|
99
99
|
{
|
|
100
|
+
"$schema": "./node_modules/@protobase/config/schema.json",
|
|
100
101
|
"url": { "$env": "PROTOBASE_URL", "default": "http://localhost:5173" },
|
|
101
102
|
"timezone": "Europe/Amsterdam",
|
|
102
103
|
"auth": { "roles": ["admin", "sales"], "trustedOrigins": { "$env": "TUNNEL_URLS", "split": "," } },
|
|
@@ -105,7 +106,7 @@ The app's database is `DATABASE_URL`'s, with the pool size of `PROTOBASE_DB_CONN
|
|
|
105
106
|
}
|
|
106
107
|
```
|
|
107
108
|
|
|
108
|
-
JSON cannot branch on the command or compute a value; a config that needs to is written in TypeScript.
|
|
109
|
+
JSON cannot branch on the command or compute a value; a config that needs to is written in TypeScript. `$schema` points the editor at the file's JSON Schema, which `@protobase/config` ships as `schema.json`, made from the same types as a TypeScript config: it completes and checks every key and value as it is typed, and takes an `$env` value wherever a value goes. Protobase itself leaves `$schema` out. Where a key holds the settings of a library underneath, such as `auth.socialProviders`, the schema takes any object, and the app checks it when it starts.
|
|
109
110
|
|
|
110
111
|
## One config per project
|
|
111
112
|
|
|
@@ -117,21 +118,21 @@ Every command reads the config, in a few milliseconds: reading it runs the confi
|
|
|
117
118
|
|
|
118
119
|
## Where the code is
|
|
119
120
|
|
|
120
|
-
Protobase loads each file below only when the app needs it, never while the config is read.
|
|
121
|
+
Protobase loads each file below only when the app needs it, never while the config is read. Sign-in's hooks in `auth/hooks.ts` get the app's database, `{ db }` (Kysely, as jobs get it), as their last argument; a write hook gets the write's transaction. A job named in the config without its `jobs/<name>.ts`, or a write hook without its `hooks/<name>.ts`, stops the app at start with an error that names the file.
|
|
121
122
|
|
|
122
123
|
The resources and roles have no key of their own:
|
|
123
124
|
|
|
124
125
|
| File | What it holds | See |
|
|
125
126
|
| --- | --- | --- |
|
|
126
|
-
| `config/index.ts`, `config/<dir>/ui.ts` | the resources, views and pages, as exports | [Data config](data-config.md) |
|
|
127
|
-
| `config/roles.ts` | the `roles` export, made with `defineRoles` | [Access](access.md) |
|
|
128
|
-
| `functions/<name>.ts` | an API function, as its default export | [API functions](../guides/api-functions.md) |
|
|
127
|
+
| `config/index.ts`, `config/<dir>/ui.ts` | the resources, views and pages, and the [webhook subscriptions](webhooks.md), as exports | [Data config](data-config.md) |
|
|
128
|
+
| `config/roles.ts` | the `roles` export (or the default export), made with `defineRoles` | [Access](access.md) |
|
|
129
|
+
| `functions/<name>.ts`, or `functions/<name>/index.ts` for a function of several files | an API function, as its default export; a file or folder whose name starts with `_` or `.`, a test and a `.d.ts` are not functions | [API functions](../guides/api-functions.md) |
|
|
129
130
|
|
|
130
131
|
The other files belong to an option, and are described with it:
|
|
131
132
|
|
|
132
133
|
| File | Option |
|
|
133
134
|
| --- | --- |
|
|
134
|
-
| `auth/hooks.ts`, `auth/mailer.ts
|
|
135
|
+
| `auth/hooks.ts`, `auth/mailer.ts` | [`auth`](config/sign-in.md#auth) |
|
|
135
136
|
| `auth/authenticate.ts` | [`authenticate`](config/sign-in.md#authenticate) |
|
|
136
137
|
| `hooks/<name>.ts` | [`writeHooks`](config/api.md#writehooks) |
|
|
137
138
|
| `hooks/error.ts`, `audit/queue.ts` | [Code of the API](config/api.md#code-of-the-api) |
|
|
@@ -143,7 +144,7 @@ The other files belong to an option, and are described with it:
|
|
|
143
144
|
|
|
144
145
|
## Extensions
|
|
145
146
|
|
|
146
|
-
`protobase dev --extend <dir>` and `protobase build --extend <dir>` merge an extension's folder into the app, before the project. The extension's folder has a config and code of its own, found by the same paths in that folder.
|
|
147
|
+
`protobase dev --extend <dir>` and `protobase build --extend <dir>` merge an extension's folder into the app, before the project, and so do `protobase migration` and `protobase mobile` with the same option. The extension's folder has a config and code of its own, found by the same paths in that folder; its config is a `protobase.config.ts`, since an extension's `protobase.config.json` is not read.
|
|
147
148
|
|
|
148
149
|
```tsx
|
|
149
150
|
// protobase.ui.tsx
|
|
@@ -158,7 +159,9 @@ export default defineUi({ extends: [tasksUi] })
|
|
|
158
159
|
| resources, views and pages of `config/` | all kept | an error naming both folders |
|
|
159
160
|
| user menu | at most one among all folders | an error |
|
|
160
161
|
| assistant tools of `assistant/tools.ts` | the extensions' first, in order, then the app's | an error naming the tool and both folders |
|
|
161
|
-
| `jobs`, functions, file providers | all kept, by name | an error naming the name and both folders |
|
|
162
|
+
| `jobs`, functions, file providers (`files.providers`) | all kept, by name | an error naming the name and both folders |
|
|
163
|
+
| `files.trustedHosts` | all kept | |
|
|
164
|
+
| the other keys of `files` | each the app's own; otherwise the last config that sets it | |
|
|
162
165
|
| `writeHooks` | all run, in the same order | |
|
|
163
166
|
| `config/roles.ts`, `auth/authenticate.ts`, `audit/queue.ts`, `hooks/error.ts`, `webhooks/owner-roles.ts`, `notifications/*.ts` | the app's own; otherwise the last extension's | |
|
|
164
167
|
| `auth/hooks.ts`, `auth/mailer.ts` | those of the last folder whose config sets `auth`; otherwise the app's | |
|
|
@@ -67,6 +67,7 @@ The element stays data, `{ type: 'OrdersPerDay', props: { days: 30 }, children:
|
|
|
67
67
|
`protobase.ui.tsx` exports the React component under the same name. It gets the props, and the rendered children when the element has any. Inside it:
|
|
68
68
|
|
|
69
69
|
- the hooks of `@protobase/ui` (`useList`, `useRecord`, `useSeries`, `useFacets`, `useHistogram`, `useClient`, ...) read the API with the user's token, under the same access rules as everything else;
|
|
70
|
+
- `useUpdateRecord` rejects with an error that `isConflict(error)` recognises when someone changed the record since it was read (a `412`), so the component can load it again;
|
|
70
71
|
- `useLayoutRecord()` gives the record around it in a `RecordCard` or `CardRow` (`{ model, record, key, etag, permissions }`), and `undefined` elsewhere.
|
|
71
72
|
|
|
72
73
|
A component that asks for a one-time code uses `OtpInput` from `@protobase/ui`, the field of the app's own code pages: a box per digit drawn over one real input, so pasting a whole code into any box, the system's code autofill from a mail or a text message, and the phone's digit keyboard all work. It takes `value` and `onChange`, `length` (6 by default), `invalid` and `disabled`, and `onComplete` gets the code once its last digit is in, to check it at once. Ask for a code on a step of its own, before anything else.
|
|
@@ -298,7 +299,7 @@ When the app has an [assistant](assistant.md), its button follows the project's
|
|
|
298
299
|
|
|
299
300
|
`bell` replaces the [notification bell](notifications.md#the-bell) of the top bar with your own, drawn where it would be, and takes no props either; [the bell's slot](notifications.md#the-bells-slot) lists the hooks it reads the user's notifications with. With a bell from a plugin and one from the project, the project's shows.
|
|
300
301
|
|
|
301
|
-
`logo` replaces Protobase's logo at the top of the sidebar with the app's own. It gets `compact`, true when the sidebar shows only icons, so it draws a mark alone, `workspace`, the name of the user's organization that Protobase's logo shows under it, `appName`, the app's [name](
|
|
302
|
+
`logo` replaces Protobase's logo at the top of the sidebar with the app's own. It gets `compact`, true when the sidebar shows only icons, so it draws a mark alone, `workspace`, the name of the user's organization that Protobase's logo shows under it, `appName`, the app's [name](config/app.md#name), which Protobase's logo shows beside its mark, and `appIcon`, the path of the project's own [icon](app-identity.md#the-icons) when it has one (`ShellLogoProps`). Its colors follow the [theme](theme.md), and a `dark:` class gives dark its own. When it throws, Protobase's logo shows instead. The tab's icon is [the favicon](theme.md#logo-and-favicon).
|
|
302
303
|
|
|
303
304
|
```tsx
|
|
304
305
|
import { defineUi, type ShellLogoProps } from '@protobase/ui'
|
|
@@ -315,6 +316,6 @@ export default defineUi({ shell: { logo: Logo } })
|
|
|
315
316
|
|
|
316
317
|
## Without protobase dev
|
|
317
318
|
|
|
318
|
-
`<App ui={...} />` from `@protobase/ui` takes the same object, for an app that mounts the admin itself, and so do stories.
|
|
319
|
+
`<App ui={...} />` from `@protobase/ui` takes the same object, for an app that mounts the admin itself, and so do stories. Outside `<App>`, `<ApiProvider baseUrl="/api/v1" token={...}>` gives components the API client and the query cache the hooks read through, as `<App>` does.
|
|
319
320
|
|
|
320
321
|
Below 1.0, a project built before 0.12 had its `protobase.ui.tsx` built into the admin app; [Moving onto the plugin build](../guides/plugin-build.md) says what changes.
|