@protobase/cli 0.40.9 → 0.41.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.
Files changed (52) hide show
  1. package/dist/build/deploy-bundle.js +2 -0
  2. package/dist/bundle/manifest.js +4 -1
  3. package/dist/cli/package.js +1 -1
  4. package/dist/mobile/api-origin-page.js +11 -0
  5. package/dist/mobile/fingerprint.js +13 -7
  6. package/dist/mobile/pinned-packages.js +7 -2
  7. package/dist/mobile/run.js +3 -7
  8. package/dist/mobile/web-part.js +17 -10
  9. package/dist/serve/app.js +3 -2
  10. package/dist/serve/bundle-site.js +2 -1
  11. package/dist/serve/env.js +4 -1
  12. package/dist/serve/lifecycle.js +14 -1
  13. package/dist/serve/mobile-release.js +41 -0
  14. package/dist/serve/serve-dir.js +5 -1
  15. package/dist/serve/site-files.js +21 -0
  16. package/dist/serve/static-site.js +6 -3
  17. package/package.json +6 -6
  18. package/skills/protobase/SKILL.md +1 -0
  19. package/skills/protobase/references/features/access.md +17 -0
  20. package/skills/protobase/references/features/actions.md +11 -0
  21. package/skills/protobase/references/features/ai.md +14 -0
  22. package/skills/protobase/references/features/api-functions.md +13 -0
  23. package/skills/protobase/references/features/build-and-run.md +22 -0
  24. package/skills/protobase/references/features/compatibility.md +14 -0
  25. package/skills/protobase/references/features/composed-pages.md +18 -0
  26. package/skills/protobase/references/features/data-model.md +22 -0
  27. package/skills/protobase/references/features/email-and-public-forms.md +12 -0
  28. package/skills/protobase/references/features/events-webhooks-and-jobs.md +18 -0
  29. package/skills/protobase/references/features/files-and-images.md +16 -0
  30. package/skills/protobase/references/features/history-comments-and-live-updates.md +14 -0
  31. package/skills/protobase/references/features/list-displays.md +18 -0
  32. package/skills/protobase/references/features/lists.md +28 -0
  33. package/skills/protobase/references/features/look-and-language.md +13 -0
  34. package/skills/protobase/references/features/navigation.md +14 -0
  35. package/skills/protobase/references/features/record-pages.md +20 -0
  36. package/skills/protobase/references/features/releases.md +12 -0
  37. package/skills/protobase/references/features/rest-api.md +24 -0
  38. package/skills/protobase/references/features/several-apps.md +8 -0
  39. package/skills/protobase/references/features/sign-in-and-accounts.md +27 -0
  40. package/skills/protobase/references/features/start-a-project.md +15 -0
  41. package/skills/protobase/references/features/your-own-code.md +19 -0
  42. package/skills/protobase/references/features.md +39 -0
  43. package/skills/protobase/references/getting-started.md +6 -2
  44. package/skills/protobase/references/guides/deploy.md +5 -1
  45. package/skills/protobase/references/guides/mobile-app.md +4 -0
  46. package/skills/protobase/references/reference/access.md +2 -0
  47. package/skills/protobase/references/reference/api.md +1 -1
  48. package/skills/protobase/references/reference/cli.md +16 -2
  49. package/skills/protobase/references/reference/data-config.md +12 -4
  50. package/skills/protobase/references/reference/files.md +4 -0
  51. package/skills/protobase/references/reference/mcp.md +10 -2
  52. package/skills/protobase/references/reference/versioning.md +5 -1
@@ -0,0 +1,18 @@
1
+ <!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/features/events-webhooks-and-jobs.md: run `bun run docs:skill`, do not edit. -->
2
+
3
+ # Events, webhooks and jobs
4
+
5
+ React to changes, deliver them to other systems, and run work in the background.
6
+
7
+ - [Events](../reference/events.md#declaring-events): A resource declares named events, such as an order that was created or a status that changed.
8
+ - [Change capture](../reference/events.md#how-changes-are-captured): Every change is captured in the database, in the same transaction, whoever made it.
9
+ - [Webhooks](../reference/webhooks.md#subscription): Events are sent to a URL, an API function or your own code, filtered by event, condition and tenant.
10
+ - [Signed webhooks](../reference/webhooks.md#what-a-receiver-gets): Deliveries are signed under the Standard Webhooks spec.
11
+ - [Delivery retries](../reference/webhooks.md#delivery-and-retries): Failed deliveries are retried for about three days.
12
+ - [Webhooks in the admin app](../reference/webhooks.md#subscriptions-in-the-admin-app): Users create subscriptions, send test events and resend failures in the app.
13
+ - [Background jobs](../reference/jobs.md#enqueueing): Jobs are kept in the app's own Postgres and can be queued in the same transaction as a write, also from SQL.
14
+ - [Retries](../reference/jobs.md#failures): Failed jobs are retried with growing waits, and duplicates can be prevented with a key.
15
+ - [Ordered groups](../reference/jobs.md#ordered-groups): Jobs in one group run one at a time, in order.
16
+ - [Recurring jobs](../reference/jobs.md#recurring-jobs): Jobs run on a cron schedule in a chosen time zone.
17
+ - [Failed jobs page](../reference/jobs.md#failed-jobs-page): Admins see jobs that failed for good and retry or delete them.
18
+ - [Jobs on hosts that sleep](../reference/jobs.md#hosts-that-sleep): A host that stops idle apps can wake them when a job is due.
@@ -0,0 +1,16 @@
1
+ <!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/features/files-and-images.md: run `bun run docs:skill`, do not edit. -->
2
+
3
+ # Files and images
4
+
5
+ Uploaded files and images, where they are kept and how they are served.
6
+
7
+ - [File fields](../reference/files.md#what-the-column-holds): A text column holds an uploaded file, with limits on type and size.
8
+ - [File storage](../reference/files.md#providers): Files are kept on disk, or in a bucket of your own.
9
+ - [S3-compatible buckets](../reference/files.md#s3-compatible-buckets) (beta): Files are kept in any bucket that speaks the S3 API, when the app runs on Bun.
10
+ - [Type detection](../reference/files.md#how-the-type-is-decided): An upload's type is decided from its content, and a disguised file is refused.
11
+ - [Signed downloads](../reference/files.md#downloads): Private files open through short-lived links that stop working once the record no longer holds the file.
12
+ - [Derived fields](../reference/files.md#derived-fields): Width, height, size and type of each upload are written to other fields.
13
+ - [Image variants and placeholders](../reference/files.md#image-variants-and-placeholders): Resized copies of uploaded images, and a blurred placeholder while they load.
14
+ - [External URLs](../reference/files.md#external-urls): A file field can hold a link to a file on another site.
15
+ - [Image referrers](../reference/files.md#image-referrers): Images from other sites load without telling them which page showed them.
16
+ - [File cleanup](../reference/files.md#deleting-files): Replaced and cleared files are deleted later on a schedule, so a database restore still finds its files.
@@ -0,0 +1,14 @@
1
+ <!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/features/history-comments-and-live-updates.md: run `bun run docs:skill`, do not edit. -->
2
+
3
+ # History, comments and live updates
4
+
5
+ The changes of each record, comments on it, and pages that refresh as records change.
6
+
7
+ - [Record history](../reference/history.md#on-the-record-page): Every change to a record is kept with who made it and when, including changes made outside the API.
8
+ - [Activity](../reference/history.md#activity): Admins see all changes across resources in one list.
9
+ - [History retention](../reference/history.md#keeping-it): Changes older than a set number of days are removed by a daily job.
10
+ - [Comments](../reference/comments.md#on-the-record-page): Anyone who can read a record can read and add comments on it.
11
+ - [Mentions](../reference/comments.md#mentions): Mentioning a colleague in a comment sends them an email with a link to the record.
12
+ - [Comment moderation](../reference/comments.md#moderation): Admins find and delete comments across the app.
13
+ - [Live updates](../reference/live.md#what-a-page-hears): Open lists and record pages refresh within seconds when a record changes, including changes made outside the API.
14
+ - [Change stream](../reference/live.md#the-stream): Apps follow record changes over a stream that catches up after a reconnect.
@@ -0,0 +1,18 @@
1
+ <!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/features/list-displays.md: run `bun run docs:skill`, do not edit. -->
2
+
3
+ # List displays
4
+
5
+ Show a list as cards, a map, a board, a calendar or a timeline, and reorder records by hand.
6
+
7
+ - [List displays](../reference/ui-config.md#list-displays): Besides a table, a list shows as cards, a map, a board, a calendar, a timeline or your own component, picked with a switch.
8
+ - [Cards](../reference/ui-config.md#list-displays): Records as cards with an image, title, subtitle, amount, badge and meta icons.
9
+ - [Card photos](../reference/ui-config.md#card-photos): Cards step through a record's photos by swiping or with arrows.
10
+ - [Boards](../reference/ui-config.md#boards): Records in columns by status, with counts. Cards are dragged between columns by mouse, touch or keyboard.
11
+ - [Calendars](../reference/ui-config.md#calendars): Records by date in a month or week grid. Dragging an event to another day reschedules it.
12
+ - [Timelines](../reference/ui-config.md#timelines): Each record is a bar from start to end over a week, month or quarter, optionally in lanes. Dragging a bar moves its dates.
13
+ - [Maps](../reference/ui-config.md#maps): Records on a map with clustered counts, and a pin on the record page. Rough locations show as an area, and extra layers such as aerial photos can be switched on.
14
+ - [Phone layout](../reference/ui-config.md#list-displays): On phones a list opens as cards or as one row per record, with filters and sort in a sheet.
15
+ - [Reordering by hand](../reference/ui-config.md#reordering-by-hand): Records with their own order are reordered by dragging, by touch or by keyboard. Each drop saves at once, and Undo puts it back.
16
+ - [Drop rules](../reference/ui-config.md#drop-rules): Rules for where a dragged record may land, such as never above a task it waits for.
17
+ - [Ranked after dependencies](../reference/ui-config.md#ranked-after-what-they-depend-on): Ranked records stay below the records they depend on while those are pending.
18
+ - [Board drops](../reference/ui-config.md#board-drops): Dropping a card on a board column can run your own write, such as creating an approval.
@@ -0,0 +1,28 @@
1
+ <!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/features/lists.md: run `bun run docs:skill`, do not edit. -->
2
+
3
+ # Lists
4
+
5
+ The list page of each resource, with its columns, filters, charts, search, exports and imports.
6
+
7
+ - [Names and columns](../reference/ui-config.md#names-and-columns): Each resource gets singular and plural names and a title field, and a list shows the columns you choose, with a starting sort and search.
8
+ - [Field display hints](../reference/ui-config.md#names-and-columns): Labels, help lines, badges, codes, percentages, currencies, units, decimals and relative times such as "5 minutes ago".
9
+ - [Email, phone and web links](../reference/ui-config.md#names-and-columns): Fields marked as email, phone or URL show as links and are edited with the matching phone keyboard and browser autofill.
10
+ - [Markdown and long text](../reference/ui-config.md#names-and-columns): Long text is edited in a box that grows with it. Markdown fields have Write and Preview and show rendered on the record page.
11
+ - [Enum labels and colours](../reference/ui-config.md#names-and-columns): Enum values get readable labels and badge colours that show everywhere the value appears.
12
+ - [Pinned title column](../reference/ui-config.md#names-and-columns): Columns size to their content, and on desktop the title column stays in place while the table scrolls sideways.
13
+ - Pinned columns: A column's menu pins it to the left edge of the table, and each user's pins are kept.
14
+ - [Related records as dots](../reference/ui-config.md#related-records-in-a-list): A list column or card shows linked records as coloured status dots, with the record's card on hover.
15
+ - [Editing in the list](../reference/ui-config.md#editing-in-the-list): Chosen columns are edited in their cells, as in a spreadsheet, with keyboard navigation. Each change saves at once and is refused if someone else changed the record first.
16
+ - [Filters](../reference/ui-config.md#filters-and-the-chart): Value menus with counts, date presets, range sliders with histograms, toggles and flags. Less used filters wait under More filters.
17
+ - [Filters beside the list](../reference/client.md#the-admin-app): A list can show its filters in a panel beside the table instead of a bar above it.
18
+ - [Default filter](../reference/ui-config.md#a-filter-the-list-opens-with): A list can open with a filter applied, shown as chips users can clear or change.
19
+ - [More than one list](../reference/ui-config.md#more-than-one-list): One resource can have several lists, each with its own sidebar entry, columns, filters and chart.
20
+ - [List charts](../reference/ui-config.md#filters-and-the-chart): A chart above a list shows records over time or per value, follows the list's filters, and filters the list when a value is clicked.
21
+ - [Shareable list addresses](../reference/client.md#the-admin-app): Filters, sort, display and saved search are kept in the address, so a list can be bookmarked and shared.
22
+ - [Empty states](../reference/ui-config.md#filters-and-the-chart): An empty list says why it is empty and offers Clear search, Clear filters or New.
23
+ - [Long lists](../reference/ui-config.md#list-displays): Lists of any length scroll at once, drawing only the rows in view, and Back returns to the same place.
24
+ - [Saved searches](../reference/ui-config.md#saved-searches): Users save a filtered list as a named search and see which records are new since they last looked.
25
+ - [Favorites](../reference/ui-config.md#favorites): A heart on each card saves the record to the user's favorites, which a list page can show.
26
+ - [Sign-in prompts](../reference/ui-config.md#sign-in-prompts): Visitors who are not signed in see what signing in gives them, in place of a list or when they press favorite or save search.
27
+ - [Export to Excel and CSV](../reference/ui-config.md#exports): Any list, or the selected rows, is saved as an Excel or CSV file with the columns the user picks.
28
+ - [Import from a spreadsheet](../reference/ui-config.md#importing-records): Records are created or updated from Excel or CSV. Every row is checked before anything is saved, and refused rows can be downloaded with the reasons.
@@ -0,0 +1,13 @@
1
+ <!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/features/look-and-language.md: run `bun run docs:skill`, do not edit. -->
2
+
3
+ # Look and language
4
+
5
+ The app's colours, name, icon, language and installation.
6
+
7
+ - [Theme](../reference/theme.md): One CSS file sets the app's colours, corners and fonts for light and dark, and keeps working on every release.
8
+ - [Dark mode](../reference/theme.md#light-dark-or-the-system): Each user picks light, dark or the system setting.
9
+ - [App name, icon and colours](../reference/app-identity.md): The app's own name, icon and colours in the sidebar, browser tabs, home-screen icon and mail.
10
+ - [Logo and favicon](../reference/theme.md#logo-and-favicon): Your own favicon or logo replaces Protobase's.
11
+ - [English and Dutch](../reference/languages.md): The built-in screens come in English and Dutch, with numbers and dates written to match.
12
+ - [Installable app](../reference/installable-app.md): The admin installs as an app on phones and computers, and says when the server cannot be reached.
13
+ - Reduced motion: When the system asks for less motion, animations and pulsing dots stop.
@@ -0,0 +1,14 @@
1
+ <!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/features/navigation.md: run `bun run docs:skill`, do not edit. -->
2
+
3
+ # Navigation
4
+
5
+ The sidebar, the user menu, the bottom bar on phones and the global search.
6
+
7
+ - [Sidebar](../reference/sidebar.md): Resources and pages in groups, in the order you set.
8
+ - [Recent records](../reference/sidebar.md#recent-records): A sidebar entry lists a few records under it with status dots.
9
+ - [User menu](../reference/user-menu.md): Account pages, help links, security settings, the theme switch and Sign out.
10
+ - [Bottom bar](../reference/bottom-bar.md): On phones, tabs along the bottom for each role's main screens.
11
+ - [Global search](../reference/client.md#global-search): A search box, also on Cmd+K or Ctrl+K, finds records in every resource and jumps to pages and New forms.
12
+ - Breadcrumbs: The top bar shows the group, list and record you are on, each a link back.
13
+ - Update notice: When the server runs a newer Protobase version, open pages offer a reload so the user can save their work first.
14
+ - Config refresh: When the config or the user's roles change, open pages load the new menus, columns and permissions without a reload.
@@ -0,0 +1,20 @@
1
+ <!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/features/record-pages.md: run `bun run docs:skill`, do not edit. -->
2
+
3
+ # Record pages
4
+
5
+ The page of one record, with its sections, related records, galleries, charts and editing.
6
+
7
+ - [Record page layout](../reference/ui-config.md#the-record-page): Sections, a summary sidebar, related tables, maps, charts, galleries, history, comments and your own components.
8
+ - [Read view and edit](../reference/ui-config.md#read-view-and-edit): A record opens as a read-only fact sheet or a form, and Edit opens the form at its own address.
9
+ - [Unsaved edits](../reference/ui-config.md#read-view-and-edit): Unsaved changes stay in the browser and can be resumed, and leaving a form with changes asks first.
10
+ - [Save feedback](../reference/ui-config.md#the-record-page): A view shows saving on the Save button instead of in a toast.
11
+ - Save conflicts: When someone else changed a record while you edited it, Save shows their value beside yours for each field you both changed, and you keep yours or take theirs.
12
+ - [Groups and tabs](../reference/ui-config.md#groups): Parts of a record page sit under headings that open on click, or in tabs, and the open ones are kept in the address.
13
+ - [Key facts](../reference/ui-config.md#key-facts): A section shows its values side by side with icons.
14
+ - [Conditional sections](../reference/ui-config.md#form-and-read-view): Sections and fields show only while editing, only while reading, or only when a condition on the record holds.
15
+ - [Galleries](../reference/ui-config.md#galleries): A record's photos show as tiles that open a full-screen lightbox, with keyboard and swipe navigation.
16
+ - [Related records](../reference/ui-config.md#related-records): Every record page shows how many records point at it, and can list related records as a table, another display or cards with buttons.
17
+ - Record lines: Lines that belong to a record, with a position and a quantity, such as those of an invoice, show as a table with totals on its page. You drag them into a new order, and Save writes the record and the order together.
18
+ - [Charts of samples](../reference/ui-config.md#charts-of-related-records): A record page graphs numeric samples over the last hour, day or week, such as a server's CPU use.
19
+ - [Fresh data on return](../reference/ui-config.md#the-record-page): Records and lists reload when the browser tab is focused again, keeping unsaved edits.
20
+ - Safe deletes: Deleting asks first, offers a review when the record changed since it was opened, and a soft delete shows Undo.
@@ -0,0 +1,12 @@
1
+ <!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/features/releases.md: run `bun run docs:skill`, do not edit. -->
2
+
3
+ # Releases
4
+
5
+ How Protobase is released and versioned, and what a release keeps working.
6
+
7
+ - [Releases](../reference/versioning.md#releases): Every fix and feature is released when it lands, as npm packages, published with provenance, and images of one version.
8
+ - [Version rules](../reference/versioning.md#versions-below-10): Semantic versioning. Below 1.0 a minor version may break.
9
+ - [Bundles and runtimes](../reference/versioning.md#bundles-and-runtimes): A runtime serves only bundles of a compatible version, and says why when it refuses one.
10
+ - [Plugins keep working](../reference/versioning.md#plugins): Plugins target a plugin API that releases keep.
11
+ - [Runtime updates](../reference/versioning.md#runtime-updates): Admins see whether the runtime has an update and start it from the app, when the host offers one.
12
+ - [New version notice](../reference/versioning.md#a-new-version-under-an-open-page): An open page keeps working when the server moves to a new Protobase version, and offers a reload.
@@ -0,0 +1,24 @@
1
+ <!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/features/rest-api.md: run `bun run docs:skill`, do not edit. -->
2
+
3
+ # REST API
4
+
5
+ The API every resource gets, with filters, writes, errors and the typed client.
6
+
7
+ - [Generated REST API](../reference/api.md#routes): List, get, create, update and delete endpoints for every resource, following the AIP API design guidelines.
8
+ - [OpenAPI and reference](../reference/api.md#meta-and-openapi-per-caller): An OpenAPI 3.1 document and an API reference page, each showing only what the caller may see and do.
9
+ - [Filters](../reference/api.md#filters): AIP-160 filters and ordering, with full-text search, lists of values and relative dates.
10
+ - [Counts, facets and charts](../reference/api.md#routes): Endpoints for value counts, grouped sums and averages, records over time, histograms and paging to any row.
11
+ - [Map queries](../reference/api.md#maps): The records inside a map's view, or counts per area when there are many.
12
+ - [Related names and photos](../reference/api.md#related-names): A list response can carry the names of related records and each record's first photos.
13
+ - [ETags](../reference/api.md#writes): Every record has a version, and a write based on an old version is refused.
14
+ - [Minimal responses](../reference/api.md#writes): A create or update can answer without the record, to save the transfer.
15
+ - [Batch writes](../reference/api.md#batch-writes): Up to 500 creates, updates, deletes and reorders across resources in one transaction.
16
+ - [Record permissions](../reference/api.md#record-permissions): Responses say which records and fields the caller may change.
17
+ - [Scan guard](../reference/api.md#safety): Reads that would scan a large table without an index are refused, with the index to create.
18
+ - [Statement timeouts](../reference/api.md#safety): Every request runs with a time limit, and reads run read-only.
19
+ - [Errors](../reference/api.md#errors): Every error is a problem document with a stable type and per-field details.
20
+ - [Audit events](../reference/api.md#audit-events): Reveals of sensitive values and organization changes are published as audit events.
21
+ - [Error reporting](../reference/api.md#error-reporting): Server and admin app errors go to a Sentry-compatible error tracker when a DSN is set.
22
+ - [JWT authentication](../reference/api.md#authentication): The API accepts tokens from another identity provider, or a check of your own.
23
+ - [CORS](../reference/api.md#cors): Websites on other origins can call the API once their origins are listed.
24
+ - [Typed client](../reference/client.md): A typed fetch client and React hooks for the API.
@@ -0,0 +1,8 @@
1
+ <!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/features/several-apps.md: run `bun run docs:skill`, do not edit. -->
2
+
3
+ # Several apps
4
+
5
+ Show another Protobase app's records and accept its users.
6
+
7
+ - [Remote resources](../reference/remote-resources.md): An app shows another Protobase app's records with its own lists, record pages and sidebar.
8
+ - [Sign-in across apps](../reference/auth.md#users-of-another-app): An app accepts the signed-in users of another Protobase app and maps their roles.
@@ -0,0 +1,27 @@
1
+ <!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/features/sign-in-and-accounts.md: run `bun run docs:skill`, do not edit. -->
2
+
3
+ # Sign-in and accounts
4
+
5
+ Sign-in methods, users, roles, organizations and tokens.
6
+
7
+ - [Built-in sign-in](../reference/auth.md): Password sign-in, sessions and short-lived tokens, with no separate identity service.
8
+ - [First admin](../reference/auth.md#first-run): No account can be made over the web while the app has no users. You create the first admin from the terminal, and the last active admin cannot be deleted, demoted or blocked.
9
+ - [Existing users table](../reference/auth.md#an-existing-users-table): Sign-in can use the users table another system keeps in the same database.
10
+ - [Users page](../reference/auth.md#users-page): Admins find people, set roles, block them, add accounts and invite people by email.
11
+ - [Password reset](../reference/auth.md#password-reset): People reset a forgotten password through an emailed link.
12
+ - [Emailed sign-in codes](../reference/auth.md#emailed-sign-in-codes): People sign in with a code sent to their email.
13
+ - [Open sign-up](../reference/auth.md#open-sign-up): Anyone can create an account after confirming an emailed code.
14
+ - [Passkeys](../reference/auth.md#passkeys): People sign in with their device's face or fingerprint unlock, or with a security key.
15
+ - [Two-factor authentication](../reference/auth.md#two-factor-authentication): A second step with an authenticator app, backup codes or emailed codes.
16
+ - [Sign-in policy](../reference/auth.md#sign-in-policy): Admins choose which sign-in methods are on, off or required, and the server refuses a policy that would lock people out.
17
+ - [GitHub and social sign-in](../reference/auth.md#sign-in-with-github): People sign in with GitHub or another social provider.
18
+ - [SAML sign-in](../reference/auth.md#sign-in-with-saml): People sign in through any SAML provider.
19
+ - [OpenID Connect provider](../reference/auth.md#platform-sign-in-provider): A host adds an OpenID Connect provider for people who already have an account.
20
+ - [Staff sign-in](../reference/auth.md#staff-sign-in): The team that runs an app signs in as a person to help them, with a reason and a log entry.
21
+ - [Roles](../reference/auth.md#roles): A user holds one or more roles and switches between them without signing in again.
22
+ - [Organizations](../reference/auth.md#organizations): People work in one organization at a time, see only its records, and are invited with their own roles.
23
+ - [API tokens](../reference/auth.md#tokens-and-roles): A signed-in session gets short-lived tokens for the API.
24
+ - [Immediate revocation](../reference/auth.md#when-a-token-stops-working): A ban, removed role or ended session takes effect on the next request.
25
+ - [Tokens for scripts](../reference/auth.md#tokens-for-scripts-and-curl): A token for an existing user, for scripts and curl.
26
+ - [Several origins](../reference/auth.md#several-origins): One app works on several domains, such as its own address and a custom domain.
27
+ - [Sign-in rate limits](../reference/auth.md#client-addresses): Sign-in and code requests are limited per client address, also behind a proxy.
@@ -0,0 +1,15 @@
1
+ <!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/features/start-a-project.md: run `bun run docs:skill`, do not edit. -->
2
+
3
+ # Start a project
4
+
5
+ Start a new app, or an admin over an existing Postgres database, and keep the config in step with it.
6
+
7
+ - [Project starter](../getting-started.md#start-an-app): `npm create protobase` starts a new app from the scratch, ERP or real estate preset and prints the next steps. Each preset has an `AGENTS.md` with rules for coding agents.
8
+ - [Example apps](../getting-started.md#run-the-erp-example): Seeded example apps on Postgres: an ERP, real estate property management and a public property portal.
9
+ - [Scaffold from a database](../reference/cli.md#scaffold): Reads your Postgres tables and writes the data config for them, with field types, keys, relations, enums, soft delete, tenants and search filled in, and with `--ui` a first view of each.
10
+ - [Safe re-scaffolding](../reference/cli.md#re-running): Running scaffold again adds only the columns that are not declared yet and leaves your own config code as it is.
11
+ - [Schema drift report](../reference/cli.md#drift-report): After each scaffold, lists declared fields whose column is gone, whose type changed or whose enum values differ, with a suggested fix.
12
+ - [Doctor](../reference/cli.md#doctor): Checks every resource and view against the database, including reads that lack an index, and prints the fix for each problem.
13
+ - [Admin without a view](../guides/table-to-admin.md#1-the-table-as-it-is): A table with an empty view already gives a working admin with every column, sorting, paging, a record page and a New button.
14
+ - [Agent skills](../reference/cli.md#skill): `protobase skill install` writes agent skills that match the installed version into the project, for the coding agents that work on it.
15
+ - [Docs as Markdown](../getting-started.md#docs-as-markdown): Every docs page is also Markdown at its address plus `.md`, for coding agents and chat assistants.
@@ -0,0 +1,19 @@
1
+ <!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/features/your-own-code.md: run `bun run docs:skill`, do not edit. -->
2
+
3
+ # Your own code
4
+
5
+ React components, field types, pages and handlers of your own, loaded as plugins.
6
+
7
+ - [Custom components](../reference/custom-components.md#components): Your own React components used by name in layouts, reading data under the user's access.
8
+ - [Custom list displays](../reference/custom-components.md#list-displays): Draw a list with your own component while the list page keeps loading, filters, search and paging.
9
+ - [Custom record sections](../reference/custom-components.md#record-sections): Your own component on a record page, beside its sections.
10
+ - [Custom record cards](../reference/custom-components.md#record-cards): Draw each card with your own component, with the built-in card as the fallback.
11
+ - [Custom field types](../reference/plugins.md#field-types): Register how a kind of value is shown and edited, and pick it per field in a view.
12
+ - [Custom create pages](../reference/custom-components.md#create-pages): Replace a resource's create form with your own page, such as a booking flow.
13
+ - [Form parts](../reference/custom-components.md#form-parts): Build your own forms from the app's fields, pickers, switches, buttons and dialogs.
14
+ - [Action handlers](../reference/custom-components.md#action-handlers): Your own code for a named action, with the record, the API client and the action's inputs.
15
+ - [Shell slots](../reference/custom-components.md#shell-slots): Your own components in the top bar, in a panel beside every page, or as the sidebar logo.
16
+ - [Plugins](../reference/plugins.md#how-a-plugin-stays-working): Your React code is a plugin that the app loads at start and that keeps working across Protobase releases without changes.
17
+ - [Plugin settings](../reference/plugins.md#loading): Plugins are loaded from the config, limited to roles and given settings.
18
+ - [Plugin fallbacks](../reference/plugins.md#when-a-plugin-is-off): A plugin that fails or does not fit the version is turned off alone, and admins see why.
19
+ - [Before sign-in](../reference/plugins.md#before-sign-in): A plugin can run around the sign-in page, for example to sign someone in from a link.
@@ -0,0 +1,39 @@
1
+ <!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/features.md: run `bun run docs:skill`, do not edit. -->
2
+
3
+ # Features
4
+
5
+ Every feature of Protobase, grouped by area, with whether it is stable.
6
+
7
+ Every feature of Protobase is listed on the page of its area, one line per feature: its name and what it gives you. A linked name leads to the page that explains it in full.
8
+
9
+ A feature without a mark is stable. The others say so after their name:
10
+
11
+ - **beta**: built, released and usable, with the limits its page lists. It may change more than a stable feature.
12
+ - **in development**: partly released, not usable on its own yet.
13
+ - **coming soon**: documented, not built yet.
14
+
15
+ ## Areas
16
+
17
+ - [Start a project](features/start-a-project.md): Start a new app, or an admin over an existing Postgres database, and keep the config in step with it.
18
+ - [Data model](features/data-model.md): Describe the tables of an existing Postgres database as resources, with their fields, keys and rules.
19
+ - [Access](features/access.md): Decide who may read and change which records and fields.
20
+ - [Lists](features/lists.md): The list page of each resource, with its columns, filters, charts, search, exports and imports.
21
+ - [List displays](features/list-displays.md): Show a list as cards, a map, a board, a calendar or a timeline, and reorder records by hand.
22
+ - [Record pages](features/record-pages.md): The page of one record, with its sections, related records, galleries, charts and editing.
23
+ - [Actions](features/actions.md): Buttons that change records, ask for input or run your own code, per role.
24
+ - [Composed pages](features/composed-pages.md): Pages of your own, built from blocks in a JSX layout.
25
+ - [Your own code](features/your-own-code.md): React components, field types, pages and handlers of your own, loaded as plugins.
26
+ - [Look and language](features/look-and-language.md): The app's colours, name, icon, language and installation.
27
+ - [Navigation](features/navigation.md): The sidebar, the user menu, the bottom bar on phones and the global search.
28
+ - [REST API](features/rest-api.md): The API every resource gets, with filters, writes, errors and the typed client.
29
+ - [API functions](features/api-functions.md): Endpoints of your own beside the REST API.
30
+ - [Sign-in and accounts](features/sign-in-and-accounts.md): Sign-in methods, users, roles, organizations and tokens.
31
+ - [Files and images](features/files-and-images.md): Uploaded files and images, where they are kept and how they are served.
32
+ - [History, comments and live updates](features/history-comments-and-live-updates.md): The changes of each record, comments on it, and pages that refresh as records change.
33
+ - [Events, webhooks and jobs](features/events-webhooks-and-jobs.md): React to changes, deliver them to other systems, and run work in the background.
34
+ - [Email and public forms](features/email-and-public-forms.md): Mail the app sends, and forms for people without an account.
35
+ - [AI](features/ai.md): Fields and actions filled by a model, the assistant beside the admin, and MCP.
36
+ - [Compatibility and moving from other systems](features/compatibility.md): Apps written for other systems that keep working on Protobase, and moving their data and code over.
37
+ - [Several apps](features/several-apps.md): Show another Protobase app's records and accept its users.
38
+ - [Build and run](features/build-and-run.md): Develop, build and run an app, on servers, in containers and on phones.
39
+ - [Releases](features/releases.md): How Protobase is released and versioned, and what a release keeps working.
@@ -10,13 +10,17 @@ An app's own React code, its components, field types and actions, is a [plugin](
10
10
 
11
11
  ## Start an app
12
12
 
13
- `npm create protobase my-app` asks which preset to start from, scratch (the default), the ERP or real estate, writes the project into `my-app`, with the `@protobase` packages in the range of the latest release's major, and prints the next steps: install it with Bun, point `.env` at a Postgres database, migrate it, load the preset's base data, if it has any, create a user and run `bun run dev`. `--preset <name>` picks one without asking; without a terminal it takes scratch. It needs Node 22.12 or later.
13
+ `npm create protobase my-app` asks which preset to start from, scratch (the default), the ERP or real estate, writes the project into `my-app`, with the `@protobase` packages in the range of the latest release's major, and prints the next steps: install it with Bun, point `.env` at a Postgres database, migrate it, load the preset's base data, if it has any, create a user and run `bun run dev`. `--preset <name>` picks one without asking; without a terminal it takes scratch. It needs Node 22.12 or later. Each preset has an `AGENTS.md` with the rules for a coding agent that changes the app, such as a new migration file for every schema change.
14
14
 
15
15
  ```sh
16
16
  npm create protobase my-app
17
17
  npm create protobase my-app -- --preset real-estate
18
18
  ```
19
19
 
20
+ ## Docs as Markdown
21
+
22
+ Every page of these docs is also Markdown at its address plus `.md`: `https://docs.protobase.net/reference/cli/` is also `https://docs.protobase.net/reference/cli.md`. The code a page shows from example files is written out in it, and its live demos are left out, so a coding agent or a chat assistant reads the page whole. In a project, [`protobase skill install`](reference/cli.md#skill) gives coding agents the docs of the installed version.
23
+
20
24
  The rest of this page works in a clone of this repository, on its examples.
21
25
 
22
26
  ## Setup
@@ -51,7 +55,7 @@ bun run --cwd examples/real-estate dev # http://localhost:5173
51
55
 
52
56
  ## Run the property portal example
53
57
 
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`.
58
+ `examples/property-portal` is a public portal of homes for sale and for rent in the Netherlands and Spain. 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
59
 
56
60
  ```sh
57
61
  bun run db:up && bun run --cwd examples/property-portal db:migrate && bun run --cwd examples/property-portal db:seed --scale small
@@ -28,7 +28,11 @@ 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. 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
+
33
+ ## Migrations
34
+
35
+ 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)). [`protobase migration`](../reference/cli.md#migration) writes the files the config's features need, such as the auth and jobs schemas, as the project's own migrations, and [a self-hosted image](#a-self-hosted-image) runs `migrate` as a step of its own before the app starts.
32
36
 
33
37
  ## Images
34
38
 
@@ -6,6 +6,10 @@ 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
+ :::caution[Beta]
10
+ In the app, passkeys and sign-in with another provider do not work yet, and "Forgot password?" is not offered.
11
+ :::
12
+
9
13
  ## 1. Install the tools
10
14
 
11
15
  - **iOS**, on a Mac: Xcode, with a simulator.
@@ -26,6 +26,7 @@ defineRoles<'orders' | 'products'>({
26
26
  })
27
27
  ```
28
28
 
29
+ - **Scopes**: `.own` gives the records whose [`.owner()`](data-config.md#resource) field holds the user's id, and `.team` those owned by the users that `teamOf` returns for them, a function given as `defineRoles(roles, { teamOf: (user) => ids })`. A scoped capability on a resource without `.owner()` fails the request.
29
30
  - **Fields** (`['sku', 'price']`, or `fields` in an object) are an allowlist: for `<resource>.read`, `.create` or `.update`, the role reads or writes only the fields listed, so a column added later stays hidden from it until someone lists it. Key columns are always there, because records are addressed by them. A plain capability (`'products.read'`) still means every field.
30
31
  - **Filter** is AIP-160 text, like a filter an access rule returns. It narrows the rows of the capability, together with `.own` or `.team` when the capability has one.
31
32
  - A limit names one resource, never `*`, and fields go with `read`, `create` or `update` only; `defineRoles` refuses anything else. At startup the server refuses a field the resource does not have, a filter that does not fit it, and a limit on a name that is not a resource.
@@ -159,6 +160,7 @@ export const operations = resource('operations')
159
160
 
160
161
  - **Every write is checked.** Creating a record checks the parent it names; changing it, the parent it points at and the one it moves to; deleting and undeleting it, the parent it points at. So a record cannot be created under an allowed parent and then moved under another. It holds for `/api/v1` and its batches, and for everything that writes through them: forms, [API functions](../guides/api-functions.md) and the assistant.
161
162
  - **The caller's own rules decide.** The parent is read as the caller would read it, with its tenant, row filters, soft delete and record-level rules; for `update`, also its update row filter and record-level update rule, given an empty input. A parent the caller cannot see, may not update, that is soft deleted or does not exist gets the same `403` as a refused create (`You may not create this operations record`), and nothing is written: the answer does not tell which VM ids exist.
163
+ - **One column, to a key of one field.** The config does not load with a relation of several columns as a parent, and the server does not start with a parent resource the app does not have or whose key has several fields.
162
164
  - **A null relation checks nothing.** A relation set by a column default or a trigger is checked from the record as written.
163
165
  - **`update` follows the parent's own parents**, so with VMs under `.parent((r) => r.folder_id, 'update')` an operation needs update on the VM's folder too. A write that would put a record under itself, or under a cycle already in the data, is refused. A `read` parent is not followed further.
164
166
  - **Several parents** are each checked with their own access, also two of one resource, such as a transfer that reads its `source_vm_id` and updates its `target_vm_id`.
@@ -108,7 +108,7 @@ Get responses carry `permissions: { update, delete, fields }`, where `fields` ma
108
108
 
109
109
  ### `/meta` and OpenAPI per caller
110
110
 
111
- `/meta` returns, per caller: the resources they can do anything with as restricted models (hidden fields absent, `readOnly` unless writable), the view for their roles ([`pickView`](https://docs.protobase.net/api/schema/functions/pickview/)) with every reference to a hidden field removed (columns, sort, search, filters, layout, chart, title, search result) and the [related sections](ui-config.md#related-records) they cannot use, `permissions[resource]` as `{ read, create, update, delete, conditional }`, the [user menu](user-menu.md) as `userMenu` and the [bottom bar](bottom-bar.md) of their active role as `bottomBar`, each without the resources and pages they cannot see, and the [composed pages](layouts.md#access) as `pages`, each without the elements that name what they cannot see or do, and, for a caller with the `admin` or `ai` role, the [assistant](assistant.md#who-sees-it) backend as `assistant: { url }` when the app has one, and, for a caller with the `admin` role, the [runtime updates](versioning.md#runtime-updates) endpoint as `runtime: { url }` when the app has one, and, for everyone, the style of the record page's [maps](ui-config.md#maps) as `maps: { style }` when the app has one, the [language](languages.md) of its screens as `locale` when it sets one, and the Protobase version the server runs as `protobaseVersion`. When that version changes under an open page, the admin app keeps what the page shows, stops reading `/meta`, and offers to reload the page, asking first while a form holds unsaved changes or a save is under way. `conditional` lists the operations allowed only for some records (a row filter or a record-level rule decides). A view's sidebar group ([`nav.recent`](sidebar.md#recent-records)) is dropped when it uses a field they cannot read. The ETag hashes all of it, so it differs per user and per roles. The OpenAPI document is generated the same way: record and body schemas have only the readable and writable fields, and methods the caller may not use are left out. Its `servers` are relative to the document (`v1` for the resources, `.` for the system endpoints), and `/api/docs` loads `openapi.json` beside it, so both are right on any host and under any prefix the API is reached at.
111
+ `/meta` returns, per caller: the resources they can do anything with as restricted models (hidden fields absent, `readOnly` unless writable, [write-only](access.md#write-only-fields) fields marked `writeOnly`), the view for their roles ([`pickView`](https://docs.protobase.net/api/schema/functions/pickview/)) with every reference to a hidden field removed (columns, sort, search, filters, layout, chart, title, search result) and the [related sections](ui-config.md#related-records) they cannot use, `permissions[resource]` as `{ read, create, update, delete, conditional }`, the [user menu](user-menu.md) as `userMenu` and the [bottom bar](bottom-bar.md) of their active role as `bottomBar`, each without the resources and pages they cannot see, and the [composed pages](layouts.md#access) as `pages`, each without the elements that name what they cannot see or do, and, for a caller with the `admin` or `ai` role, the [assistant](assistant.md#who-sees-it) backend as `assistant: { url }` when the app has one, and, for a caller with the `admin` role, the [runtime updates](versioning.md#runtime-updates) endpoint as `runtime: { url }` when the app has one, and, for everyone, the style of the record page's [maps](ui-config.md#maps) as `maps: { style }` when the app has one, the [language](languages.md) of its screens as `locale` when it sets one, and the Protobase version the server runs as `protobaseVersion`. When that version changes under an open page, the admin app keeps what the page shows, stops reading `/meta`, and offers to reload the page, asking first while a form holds unsaved changes or a save is under way. `conditional` lists the operations allowed only for some records (a row filter or a record-level rule decides). A view's sidebar group ([`nav.recent`](sidebar.md#recent-records)) is dropped when it uses a field they cannot read. The ETag hashes all of it, so it differs per user and per roles. The OpenAPI document is generated the same way: record and body schemas have only the readable and writable fields, and methods the caller may not use are left out. Its `servers` are relative to the document (`v1` for the resources, `.` for the system endpoints), and `/api/docs` loads `openapi.json` beside it, so both are right on any host and under any prefix the API is reached at.
112
112
 
113
113
  ## Sensitive fields and audit
114
114
 
@@ -106,6 +106,7 @@ One process, one port: Vite serves the admin app from `@protobase/ui`'s `src/app
106
106
  - **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 points to its `db:up` script when it has one). The project needs `pg` installed, because the API connects with Kysely over the project's own `pg`.
107
107
  - **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).
108
108
  - **Login:** real sign-in only, with the `authenticate` and `auth` exported by `protobase.config.ts` (see [Login with Better Auth](auth.md)). A project without an authenticator fails at startup with a message pointing there, one whose auth schema is behind with the tables and columns it lacks (see [`auth migration`](#auth-migration)), 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. Create the first admin with `protobase users create`.
109
+ - **Mobile releases:** see [below](#mobile-releases).
109
110
  - **Jobs:** with [jobs](jobs.md) in the config it runs them in its process, once the jobs schema checks out (see [`migration`](#migration)); an edited job runs its new code from the next job on.
110
111
  - **Tunnels and other hosts:** Vite only answers `localhost` by default. `--allowed-hosts .trycloudflare.com,app.example.com` adds Host headers (a leading dot matches all subdomains). Hot reload needs no extra setting: the Vite client takes protocol, host and port from the page, so behind an HTTPS tunnel it connects over `wss` on 443 as long as the tunnel forwards WebSockets.
111
112
  - **Project discovery**, by convention: `config/index.ts` exports the resources (and views), and every `config/*/ui.ts` export that is not already exported by the index is added as a view. Each `functions/<name>.ts` (or `functions/<name>/index.ts`) is an [API function](../guides/api-functions.md) at `/api/functions/<name>`. A `protobase.config.ts` in the project root replaces the convention; its default export may contain any of:
@@ -194,7 +195,9 @@ A token the [theme](theme.md) sets that the app does not read prints a `warning:
194
195
 
195
196
  By default the bundle runs on Node and on Bun. `--bun` makes it a bundle for Bun only, as the Protobase images and the cloud serve it: Bun's bundler writes the config module (see [the config module](#the-config-module)), so the build needs `bun` on `PATH` and fails without it.
196
197
 
197
- `--source-maps` writes a source map beside each script of the shell and the plugins, `assets/<name>-<hash>.js.map`, for an error tracker to read the browser's stack frames with. Each script ends with a `//# debugId=<uuid>` comment, and its map carries the same `debugId`; the scripts name no map, but a host serves the maps with the rest of `public/` unless it moves them out. The shell's maps come prebuilt in `@protobase/ui`'s `dist/shell-source-maps/`. Without the option the bundle has no maps.
198
+ ### Source maps
199
+
200
+ `--source-maps` writes a source map beside each script of the shell and the plugins, `assets/<name>-<hash>.js.map`, for an error tracker to read the browser's stack frames with. Each script ends with a `//# debugId=<uuid>` comment, and its map carries the same `debugId`; the scripts name no map, but a host serves the maps with the rest of `public/` unless it moves them out. The shell's maps come prebuilt in `@protobase/ui`'s `dist/shell-source-maps/`. Without the option the bundle has no maps. [`build-plugin --source-maps`](#build-plugin) does the same for a plugin built on its own.
198
201
 
199
202
  ### Extensions
200
203
 
@@ -221,6 +224,7 @@ By default the bundle runs on Node and on Bun. `--bun` makes it a bundle for Bun
221
224
  { "name": "app", "path": "plugins/app/plugin.json", "api": 1, "protobase": ">=0.12.0", "fields": { "steps": ["enum"] } }
222
225
  ],
223
226
  "shell": { "protobase": "0.12.0", "pluginApi": 1, "paths": ["/index.html", "/assets", "/protobase.sw.js"] },
227
+ "native": { "@capacitor/core": "8.5.3", "@capacitor/ios": "8.5.3" },
224
228
  "nodeModules": "node_modules",
225
229
  "migrations": "migrations"
226
230
  }
@@ -230,6 +234,7 @@ By default the bundle runs on Node and on Bun. `--bun` makes it a bundle for Bun
230
234
  - `server`, `public`, `nodeModules` and `migrations` are relative to the bundle folder; `spa`, `theme` and each plugin's `path` to `public`.
231
235
  - `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.
232
236
  - `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, of a release every plugin of the bundle loads in, may serve its own for those paths instead (see [The UI](#the-ui)), so the app gets that release's fixes without a rebuild.
237
+ - `native` is the native packages, name to version, that `shell` runs on in the [mobile app](../guides/mobile-app.md): those `@protobase/mobile` pins. The fingerprint of the bundle's [mobile release](#mobile-releases) names them. A bundle built before it serves no mobile release.
233
238
  - `theme` is the project's [theme](theme.md), which the app links at `/protobase.theme.css`. It is always there, empty when the project has none.
234
239
  - `nodeModules` is present only when the config module imports [native packages](#native-packages). It is always the `node_modules` folder beside `server`, where Bun and Node resolve the module's imports from, and holds plain packages: JavaScript, `package.json` files and native binaries for linux x64 and arm64 (glibc), which the runtime loads with `dlopen`. A host keeps it next to the server module and must not mount it `noexec` (an add-on there then fails with `failed to map segment from shared object`). Its binaries link nothing but glibc, `libstdc++.so.6`, `libgcc_s.so.1` and libraries in the bundle itself, so the run image must have those three. Without `nodeModules`, the server module is the only file the runtime reads.
235
240
  - `migrations` is present only when the project has a `db/migrations` folder: its `.sql` files, which the runtime's `migrate` applies (see [Deploy](../guides/deploy.md)). A host never serves it.
@@ -393,6 +398,7 @@ Serves the API of a bundle from `protobase build` and owns the process around it
393
398
  | `PROTOBASE_STARTUP_CHECKS` | `false` skips the startup reads of the auth, changes, computed columns, webhooks and jobs schemas, which make a start slower; default `true`. Set it only to restart a bundle that already started on this database, such as when a platform wakes a sleeping app, never for a new bundle or after its migrations ran |
394
399
  | `PROTOBASE_SHELL` | `protobase serve <bundle>` only: a shell folder, such as the `/opt/protobase/shell` of a protobase image or `@protobase/ui`'s `dist/shell`, to serve the bundle's app from (see [its own shell](#serve)) |
395
400
  | `PROTOBASE_TRUSTED_PROXIES` | the proxies in front of the server, addresses or CIDR ranges, comma separated: a request from one of them names its client in `X-Forwarded-For`; without it the client is the connection's address ([Client addresses](auth.md#client-addresses)) |
401
+ | `PROTOBASE_MOBILE_SIGNING_KEY` | an RSA private key of at least 2048 bits, PEM, its newlines real or written `\n`, that signs every file of the [mobile release](#mobile-releases) in `X-Signature`, for an app whose updater checks signatures with the matching public key; another kind of key, or a shorter one, stops startup |
396
402
  | `PROTOBASE_JOBS_DRAIN_TOKEN` | the operator's bearer token for `POST /api/jobs/drain`, which [runs the due jobs](jobs.md#hosts-that-sleep) of a host that lets the app sleep; without it there is no such endpoint |
397
403
 
398
404
  Better Auth and other settings are the project's own variables (`BETTER_AUTH_SECRET`, `BETTER_AUTH_URL`, ...), read by its config. `protobase serve` also loads the nearest `.env`, like `dev`; the runtime takes the environment as it is.
@@ -406,6 +412,13 @@ Better Auth and other settings are the project's own variables (`BETTER_AUTH_SEC
406
412
  - **Host modules:** under Bun, the runtime registers [the modules it supplies](#the-config-module) as virtual modules, so the bundle needs no `node_modules` for them. `protobase serve`, on Node or Bun, resolves them from the `node_modules` next to the bundle, so keep the bundle inside the project. Native packages load from the bundle's own `node_modules/` under both.
407
413
  - **Read-only hosts:** nothing is written: no install (`--no-install`), and for a bundle built with `--bun` no transpiling and so no transpiler cache. A bundle with `node_modules/` needs its folder mounted without `noexec`, since its add-ons are mapped as executable code.
408
414
 
415
+ ### Mobile releases
416
+
417
+ With a `mobile` section, the server serves the [mobile app](../guides/mobile-app.md) a newer copy of its files, for its live updater, so the app gets UI changes without a store release. The release is what the server serves the web, composed at startup: every file of `public/`, with the server's own shell where `protobase serve` uses it, and `index.html` naming the API origin, the auth `baseURL` (https, or plain http to `localhost`, `127.0.0.1` or `[::1]`). There is none when the server serves the API alone, has no such `baseURL`, or the bundle names no `native`.
418
+
419
+ - `GET /api/mobile/release?fingerprint=<native fingerprint>&shell_version=<x.y.z>` answers `{ "bundleId", "url", "required" }`: the release's id, a hash of its files, and its absolute base URL, both `null` when the release does not run on the asking binary, whose native fingerprint must equal the release's. `required` is true when the shell the app runs no longer works with the server's API: below 1.0 another minor, from 1.0 another major. A missing fingerprint or a shell version that is no x.y.z version gets 400.
420
+ - `GET /api/mobile/releases/<bundleId>?href=<file>` serves the release's file `<file>`, such as `assets/index-abc123.js`, and with `href=capawesome-live-update-manifest.json` its manifest, a JSON array of `{ "href", "checksum", "sizeInBytes" }`. Each comes with its sha256 in hex in `X-Checksum` and, with `PROTOBASE_MOBILE_SIGNING_KEY`, its signature in `X-Signature`. Any other file, or another release's id, gets 404.
421
+
409
422
  ## `worker`
410
423
 
411
424
  ```sh
@@ -538,7 +551,8 @@ Builds the project in the current directory as an iOS or Android app with Capaci
538
551
  - `build` makes a signed release, an `.aab` (Android) or `.ipa` (iOS), and copies it to `--out`, which ignores itself in git when the command creates it, as `<appId>-<version>-<build number>`. Android signs through Gradle with the keystore, alias and passwords in `PROTOBASE_ANDROID_KEYSTORE`, `PROTOBASE_ANDROID_KEY_ALIAS`, `PROTOBASE_ANDROID_KEYSTORE_PASSWORD` and `PROTOBASE_ANDROID_KEY_PASSWORD`; iOS runs Capacitor's build with `--team`, and `--certificate` with `--profile` for manual signing.
539
552
  - A release calls an https server that is not this machine, and `--app-version` (one to three numbers) and `--build-number` (1 to 2100000000) are required.
540
553
  - npm and Capacitor get the CLI's environment without any variable named in the current directory's `.env*` files, nor the four `PROTOBASE_ANDROID_*` signing variables, which only Gradle gets, and with `CI=true`, which keeps Capacitor's telemetry off.
541
- - It prints the workspace, the API origin and the native fingerprint, which the app also sends in its user agent as `ProtobaseNative/<fingerprint>`: a hash of the `@protobase/mobile` version and the extra plugins' installed versions.
554
+ - It prints the workspace, the API origin and the native fingerprint, which the app also sends in its user agent as `ProtobaseNative/<fingerprint>`: a hash of the native packages `@protobase/mobile` pins, at their versions, and the section's `plugins`, at the versions they give. A [mobile release](#mobile-releases) runs only on a binary of its own fingerprint. A Protobase release that pins the same native packages keeps it; raise a plugin's version when the app's files start using a newer native feature of it, which changes it.
555
+ - The app's files carry the live updater's manifest of them, so an update downloads only the files that changed.
542
556
 
543
557
  ## `token`
544
558
 
@@ -60,7 +60,7 @@ export const repairs = resource('repairs')
60
60
  | `.primaryKey((r) => r.id)` | The key, one field or a list (`(r) => [r.order_id, r.line_no]`). Required; records are addressed by it. |
61
61
  | `.softDelete((r) => r.deleted_at)` | A nullable timestamp or date: deleting sets it, lists leave such rows out, `:undelete` clears it. See [REST API](api.md#routes). |
62
62
  | `.tenant((r) => r.organization_id)` | The column that separates tenants: every query is limited to the caller's tenant, creates set it, and a request body may not. |
63
- | `.owner((r) => r.owner_id)` | The field holding the owning user's id, which `.own` capabilities filter on (see [Access](#access)). |
63
+ | `.owner((r) => r.owner_id)` | The field holding the owning user's id, which `.own` and `.team` capabilities filter on (see [Access](#access)). The server does not start when its column cannot hold the signed-in users' ids, such as an integer column with Better Auth's text ids; see [user ids](auth.md#roles-and-access-in-the-api). |
64
64
  | `.search((r) => [r.number, r.name])` | The fields that `search("...")` and bare words in a filter match, and what the admin's [global search](client.md#global-search) looks in. Every word of the text must appear in one of them, ignoring case, and part of a word is enough: `port` finds "Portfolio". `r.phone.digitsEnd()` matches only the end of a field's digits instead, ignoring spaces, `+` and dashes, and only words written like phone numbers: `9623`, `47069623` and `+31 6 47069623` find "+31 6 47069623", `4706` and `+316` do not. Each field needs a pg_trgm index (`using gin (name gin_trgm_ops)`), a `digitsEnd` one on `regexp_replace(phone, '[^0-9]', '', 'g')`, or the API refuses the search. |
65
65
  | `.position((r) => r.position, { within?, after? })` | The integer field holding the records' order by hand, 1 the first, which a list's **Reorder** button changes by dragging; with `within: (r) => r.invoice_id`, a filterable relation, each parent's records have an order of their own, sorted in its related section; with `after`, a record never ranks above the records it depends on. The field must be sortable. See [Reordering by hand](ui-config.md#reordering-by-hand) and [Ranked after what they depend on](ui-config.md#ranked-after-what-they-depend-on). |
66
66
  | `.parent((r) => r.vm_id, 'update')` | The relation whose record each record belongs to, and the access on it (`'read'` or `'update'`) that creating, changing, deleting and undeleting a record needs, checked with the caller's own rules on that resource. The relation is one column, to a resource with a key of one field. See [Records that belong to another](access.md#records-that-belong-to-another). |
@@ -70,7 +70,7 @@ export const repairs = resource('repairs')
70
70
  | `.history()` | Keeps every change of its records with who made it, shown on the record page and listed for admins as Activity. See [Record history](history.md). |
71
71
  | `.comments()` | Lets whoever may read a record comment on it and @mention others who may, who are emailed; shown on the record page and listed for admins. See [Record comments](comments.md). |
72
72
 
73
- Field and resource names are snake_case by convention, like the columns: they are the names in URLs, the API, filters and sorts as written (`/stock_moves?order_by=moved_at desc`). The column is the snake_case of the name unless `.column()` says otherwise, so a camelCase name such as `movedAt` maps to `moved_at` too.
73
+ Field and resource names are snake_case by convention, like the columns: they are the names in URLs, the API, filters and sorts as written (`/stock_moves?order_by=moved_at desc`). The column is the snake_case of the name unless `.column()` says otherwise, so a camelCase name such as `movedAt` maps to `moved_at` too. [`protobase scaffold`](cli.md#scaffold) writes snake_case names, and the built-in resources, such as `failed_jobs` and `webhook_subscriptions`, have them too. Nothing checks the convention: a resource or field may have any name.
74
74
 
75
75
  ## Field types
76
76
 
@@ -146,6 +146,10 @@ export const products = resource('products')
146
146
 
147
147
  ## Rollups and formulas
148
148
 
149
+ :::caution[Beta]
150
+ A rollup over its own table, a resource with a key of several columns, or a relation of several columns is not supported yet.
151
+ :::
152
+
149
153
  A **rollup** is a value of the other records that point at a record, such as an order's total of its lines. A **formula** is a value computed from the record's own fields, such as a line's amount. Neither needs SQL: you declare the field, and [`protobase migration`](cli.md#migration) writes its column into the project's next migration (`NNN_computed.sql`). Both are real columns, kept by the database in the transaction that writes, so they are right for writes from psql or other services too, and they filter and sort like any column once they have an index.
150
154
 
151
155
  ```ts title="docs-examples/reference/rollups.ts"
@@ -194,7 +198,7 @@ Empty values of `field` are left out, as in SQL. The migration adds the column,
194
198
 
195
199
  `.formula(expression)` is a Postgres generated column. The expression reads the record's number fields, and takes numbers, `+ - * /`, parentheses, `coalesce(a, b, ...)` and `round(x)` or `round(x, digits)`. It is computed exactly as decimals, so `7 / 2` is 3.5, and is stored as the field's type, so an integer field rounds the result. A formula that reads an optional field is `.optional()` too, unless `coalesce()` gives that field a value. A formula cannot read another formula. When the expression changes, the migration drops the column and adds it again, so an index on it must be created again in the same migration.
196
200
 
197
- Neither field can be written through the API, have a default, or be sensitive. The server does not start while a declared column, function or trigger is missing or out of date, with a message that names the fields; the migration fixes that. It stops with an error, without writing anything, when the column already exists as the project's own: a plain column where a formula is declared, a generated column it did not write, or a rollup column of another type.
201
+ Neither field can be written through the API, have a default, or be sensitive, an AI field, a file, or the key, tenant, owner or soft delete field, and a formula cannot read a sensitive field. The server does not start while a declared column, function or trigger is missing or out of date, with a message that names the fields; the migration fixes that. It stops with an error, without writing anything, when the column already exists as the project's own: a plain column where a formula is declared, a generated column it did not write, or a rollup column of another type.
198
202
 
199
203
  ## Sensitive fields
200
204
 
@@ -306,12 +310,16 @@ export const partOrders = resource('part_orders')
306
310
 
307
311
  A relation's value in the API is the other record's key. The admin shows the other record's name instead (its view's `title`, else a field such as `name` or `number`) and links to it. The create form and the record's form pick it from a list, with a link beside it on the record's form; a relation the user may not change, the record's own key and a relation to a record with a key of several columns stay links.
308
312
 
313
+ ## Schema API reference
314
+
315
+ Every builder, option and type that `@protobase/schema` exports has a doc comment, which your editor shows as you write a config, and the [schema API reference](https://docs.protobase.net/api/schema/) lists them with their types. The types the builders return, such as [`ResourceBuilder`](https://docs.protobase.net/api/schema/interfaces/resourcebuilder/), [`Field`](https://docs.protobase.net/api/schema/interfaces/field/) and [`RecordOf`](https://docs.protobase.net/api/schema/type-aliases/recordof/), are exported, so a helper of your own that takes or returns them is typed too.
316
+
309
317
  ## Access
310
318
 
311
319
  Without rules everyone who can sign in may do everything. Rules come in three kinds, and the [Access](access.md) reference explains the defaults:
312
320
 
313
321
  - **Per operation** (`list`, `read`, `create`, `update`, `delete`): `.access({ update: rule })`. A rule returns `true`, `false`, or an AIP-160 filter that limits the rows, like row-level security. A rule that reads the record (`record.status`) is checked against the stored row.
314
- - **Per row**: a filter from a rule, or a `.own` capability with `.owner(...)`.
322
+ - **Per row**: a filter from a rule, or a `.own` or `.team` capability with `.owner(...)`: `.own` gives the records whose owner is the user, `.team` those owned by the users that `defineRoles(roles, { teamOf: (user) => ids })` returns for them.
315
323
  - **Per field**: `.access({ read, create, update })` on the field. Field rules see only the user, never a record, so the fields a user can read are the same for every row.
316
324
 
317
325
  [`defineRoles`](https://docs.protobase.net/api/schema/functions/defineroles/) turns roles into capabilities (`work_orders.update.own`, `money.read`, `*`), and `roles.can(...)` and `roles.is(...)` make rules of them; `.and()` and `.or()` combine rules.