@protobase/cli 0.59.2 → 0.60.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.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.59.2";
2
+ var version = "0.60.0";
3
3
  //#endregion
4
4
  export { version };
@@ -1,5 +1,5 @@
1
1
  import { projectFiles, projectFunctions, projectJobs, projectNotifications, projectOptions, projectResources, projectWebhooks } from "./project-parts.js";
2
- import { buildAppAuth, buildAuthenticator, checkCallsOptions } from "@protobase/server/internal";
2
+ import { buildAppAuth, buildAuthenticator, checkCallsOptions, checkStatusOptions } from "@protobase/server/internal";
3
3
  //#region src/config/build-project.ts
4
4
  /**
5
5
  * The app's own mailer, the default export of its auth/mailer.ts: what sign-in and the jobs (`context.mail`) both send
@@ -70,6 +70,7 @@ const buildProject = async (config, database) => {
70
70
  ...webhooks && { webhooks },
71
71
  ...config.realtime && { realtime: config.realtime },
72
72
  ...notifications && { notifications },
73
+ ...config.status && { status: checkStatusOptions(config.status) },
73
74
  ...config.calls && { calls: checkCallsOptions(config.calls) },
74
75
  ...mailer && { mailer },
75
76
  ...config.mobile && { mobile: config.mobile },
package/dist/dev/entry.js CHANGED
@@ -7,7 +7,7 @@ import { devRealtimePrune } from "./dev-prune.js";
7
7
  import { devDatabase, loadDevConfig } from "./project.js";
8
8
  import { withDevServiceWorker } from "./service-worker-route.js";
9
9
  import { setMissing, supabaseEnv } from "./supabase-env.js";
10
- import { apiKeySettings, assistantSettings, authSchemaDrift, authStoreTables, checkAi, checkAuthSchema, checkChanges, checkChannelSends, checkComments, checkComputed, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkResourcesOutsideAuthStore, checkWebhooksSchema, configExports, hasUsers, relayed, sqlSends } from "@protobase/server";
10
+ import { apiKeySettings, assistantSettings, authSchemaDrift, authStoreTables, checkAi, checkAuthSchema, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkResourcesOutsideAuthStore, checkStatusSchema, checkWebhooksSchema, configExports, hasUsers, relayed, sqlSends } from "@protobase/server";
11
11
  import { upgradeWebSocket } from "@hono/node-server";
12
12
  import { Hono } from "hono";
13
13
  //#region src/dev/entry.ts
@@ -25,6 +25,7 @@ if (project.auth && !store.__protobaseAuthSchemaChecked) {
25
25
  if (project.auth) await checkResourcesOutsideAuthStore(db, resources.map((resource) => resource.toModel()), project.auth);
26
26
  await checkChanges(db, resources.map((resource) => resource.toModel()), project.events);
27
27
  await checkComments(db, resources.map((resource) => resource.toModel()));
28
+ await checkCalls(db, project.calls);
28
29
  await checkComputed(db, resources.map((resource) => resource.toModel()));
29
30
  if (assistantSettings(project.options?.assistant, process.env)?.kind === "built-in") await checkQueryRunner(db, project.auth ? authStoreTables(project.auth) : {
30
31
  tables: [],
@@ -40,6 +41,7 @@ if (project.webhooks) await checkWebhooksSchema(db, project.webhooks);
40
41
  if (relayed(project.realtime)) await checkRealtimeRelay(db);
41
42
  if (sqlSends(project.realtime)) await checkChannelSends(db);
42
43
  if (project.notifications) await checkNotificationsSchema(db, project.notifications, project.auth);
44
+ if (project.status) await checkStatusSchema(db, project.status, project.auth);
43
45
  setMissing(process.env, supabaseEnv({
44
46
  url: process.env.PROTOBASE_DEV_URL,
45
47
  databaseUrl: process.env.PROTOBASE_DATABASE_URL,
@@ -5,6 +5,7 @@ import { loadSourceConfig } from "../config/source-config.js";
5
5
  import { openAppDatabase } from "../project/pg-db.js";
6
6
  import pg from "pg";
7
7
  import { assistantSettings, authStoreTables, configExports } from "@protobase/server";
8
+ import { checkStatusOptions } from "@protobase/server/internal";
8
9
  //#region src/migration/load-project.ts
9
10
  /**
10
11
  * The project in `dir` as `protobase dev` merges it, for what its database needs: protobase.config.ts, with the
@@ -39,7 +40,9 @@ const migrationProject = async (config, url) => {
39
40
  ...config.events && { events: config.events },
40
41
  ...webhooks && { webhooks },
41
42
  ...config.realtime && { realtime: config.realtime },
43
+ ...config.calls && { calls: config.calls },
42
44
  ...notifications && { notifications },
45
+ ...config.status && { status: checkStatusOptions(config.status) },
43
46
  jobs,
44
47
  readOnlyQueries: assistantSettings(config.assistant, process.env)?.kind === "built-in",
45
48
  authTables: auth ? authStoreTables(auth) : {
@@ -1,5 +1,5 @@
1
1
  import { authMigrationTitle } from "../auth/migration-file.js";
2
- import { authSchemaMigration, changesMigration, channelSendsMigration, commentsMigration, computedMigration, isCaptured, jobsSchemaMigration, notificationsMigration, queryRunnerMigration, realtimeRelayMigration, relayed, sqlSends, webhooksMigration } from "@protobase/server";
2
+ import { authSchemaMigration, callsMigration, changesMigration, channelSendsMigration, commentsMigration, computedMigration, isCaptured, jobsSchemaMigration, notificationsMigration, queryRunnerMigration, realtimeRelayMigration, relayed, sqlSends, statusMigration, webhooksMigration } from "@protobase/server";
3
3
  //#region src/migration/parts.ts
4
4
  /** Every feature the project's config enables, in the order their files are written. */
5
5
  const migrationParts = (project) => {
@@ -46,6 +46,16 @@ const migrationParts = (project) => {
46
46
  title: "The tables of notifications",
47
47
  sql: () => notificationsMigration(project.db, project.notifications, project.auth)
48
48
  }] : [],
49
+ ...project.status ? [{
50
+ name: "status",
51
+ title: "The statuses table of people's own status",
52
+ sql: () => statusMigration(project.db, project.status, project.auth)
53
+ }] : [],
54
+ ...project.calls ? [{
55
+ name: "calls",
56
+ title: "The calls on records, who is in them, and the signals between the processes serving the app",
57
+ sql: () => callsMigration(project.db)
58
+ }] : [],
49
59
  ...relayed(project.realtime) ? [{
50
60
  name: "realtime_relay",
51
61
  title: "The relay of Realtime broadcasts and presence between the processes serving the app",
@@ -28,6 +28,7 @@ const projectAdmin = (project, db, ui, reporter, upgradeWebSocket) => {
28
28
  ...project.webhooks && { webhooks: project.webhooks },
29
29
  ...project.realtime && { realtime: project.realtime },
30
30
  ...project.notifications && { notifications: project.notifications },
31
+ ...project.status && { status: project.status },
31
32
  ...project.calls && { calls: project.calls },
32
33
  ...project.mobile && { mobile: project.mobile },
33
34
  ...project.app && { app: project.app },
@@ -9,7 +9,7 @@ import { startCleanupTimer } from "./cleanup-timer.js";
9
9
  import { closeSockets } from "./close-sockets.js";
10
10
  import { servedRelease } from "./mobile-release.js";
11
11
  import pg from "pg";
12
- import { assistantSettings, authStoreTables, backgroundSettled, checkAi, checkAuthSchema, checkChanges, checkChannelSends, checkComments, checkComputed, checkJobsSchema, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkResourcesOutsideAuthStore, checkWebhooksSchema, configExports, createFileCleanup, relayed, sqlSends, startJobs } from "@protobase/server";
12
+ import { assistantSettings, authStoreTables, backgroundSettled, checkAi, checkAuthSchema, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkJobsSchema, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkResourcesOutsideAuthStore, checkStatusSchema, checkWebhooksSchema, configExports, createFileCleanup, relayed, sqlSends, startJobs } from "@protobase/server";
13
13
  import { createAdaptorServer, upgradeWebSocket } from "@hono/node-server";
14
14
  //#region src/serve/lifecycle.ts
15
15
  const listen = (server, port) => new Promise((resolve, reject) => {
@@ -31,6 +31,7 @@ const startServe = async ({ config, env, openDb = (url) => openAppDatabase(pg, u
31
31
  if (env.startupChecks && project.auth) await checkResourcesOutsideAuthStore(db, resources.map((resource) => resource.toModel()), project.auth);
32
32
  if (env.startupChecks) await checkChanges(db, resources.map((resource) => resource.toModel()), project.events);
33
33
  if (env.startupChecks) await checkComments(db, resources.map((resource) => resource.toModel()));
34
+ if (env.startupChecks) await checkCalls(db, project.calls);
34
35
  if (env.startupChecks) await checkComputed(db, resources.map((resource) => resource.toModel()));
35
36
  if (env.startupChecks && assistantSettings(project.options?.assistant, process.env)?.kind === "built-in") await checkQueryRunner(db, project.auth ? authStoreTables(project.auth) : {
36
37
  tables: [],
@@ -46,6 +47,7 @@ const startServe = async ({ config, env, openDb = (url) => openAppDatabase(pg, u
46
47
  if (env.startupChecks && relayed(project.realtime)) await checkRealtimeRelay(db);
47
48
  if (env.startupChecks && sqlSends(project.realtime)) await checkChannelSends(db);
48
49
  if (env.startupChecks && project.notifications) await checkNotificationsSchema(db, project.notifications, project.auth);
50
+ if (env.startupChecks && project.status) await checkStatusSchema(db, project.status, project.auth);
49
51
  const { admin, jobs: definitions } = projectAdmin(project, db, ui, reporter, upgradeWebSocket);
50
52
  if (env.startupChecks && definitions.length > 0) await checkJobsSchema(db);
51
53
  const jobs = definitions.length > 0 ? await startJobs({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.59.2",
3
+ "version": "0.60.0",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -42,12 +42,12 @@
42
42
  "dependencies": {
43
43
  "@better-auth/core": "^1.7.12",
44
44
  "@hono/node-server": "^2.1.3",
45
- "@protobase/config": "0.59.2",
46
- "@protobase/layout": "0.59.2",
47
- "@protobase/query": "0.59.2",
48
- "@protobase/schema": "0.59.2",
49
- "@protobase/server": "0.59.2",
50
- "@protobase/ui": "0.59.2",
45
+ "@protobase/config": "0.60.0",
46
+ "@protobase/layout": "0.60.0",
47
+ "@protobase/query": "0.60.0",
48
+ "@protobase/schema": "0.60.0",
49
+ "@protobase/server": "0.60.0",
50
+ "@protobase/ui": "0.60.0",
51
51
  "@react-email/render": "^2.1.0",
52
52
  "@scalar/hono-api-reference": "^0.12.10",
53
53
  "@tailwindcss/vite": "^4.3.3",
@@ -89,6 +89,7 @@ Reference:
89
89
  - When running background jobs → read [Jobs](references/reference/jobs.md)
90
90
  - When sending email → read [Email](references/reference/email.md)
91
91
  - When registering users' devices for push notifications → read [Notifications](references/reference/notifications.md)
92
+ - When people should set themselves busy, do not disturb or a status text, or see others' beside their names → read [Status](references/reference/status.md)
92
93
  - When adding audio and video calls, through LiveKit or peer to peer → read [Calls](references/reference/calls.md)
93
94
  - When setting roles, capabilities and row filters → read [Access](references/reference/access.md)
94
95
  - When configuring sign-in, tokens and the auth schema → read [Login with Better Auth](references/reference/auth.md)
@@ -4,7 +4,7 @@
4
4
 
5
5
  Audio and video calls between an app's users, through LiveKit or peer to peer, with Protobase deciding who is in a call and who hears whom.
6
6
 
7
- - [Calls](../reference/calls.md#turning-them-on) (in development): `calls: { backend }` in the config carries calls' audio and video through a media plugin inside the server, and an app without it loads none of it.
7
+ - [Calls](../reference/calls.md) (beta): Voice and video calls on any record, with screen sharing. The record's readers see each call live, with who is in it, and you can remove someone from a call.
8
8
  - [LiveKit](../reference/calls.md#livekit) (in development): The media goes through a LiveKit server, self-hosted or LiveKit Cloud, which Protobase speaks to for each member.
9
9
  - [Peer to peer](../reference/calls.md#peer-to-peer) (in development): With no media server, the members' browsers send their media straight to each other, for small calls.
10
10
  - [Admitting members](../reference/calls.md#admitting-members) (in development): A function of your own admits the caller to a call with what they may send and whose tracks they hear.
@@ -8,7 +8,7 @@ The sidebar, the user menu, the bottom bar on phones and the global search.
8
8
  - [Recent records](../reference/sidebar.md#recent-records): A sidebar entry lists a few records under it, with status dots or as titles alone, and marked per reader, such as unread ones in bold with a count.
9
9
  - [Create link](../reference/sidebar.md#create-link): A sidebar entry links to its create form, such as "New message" under Direct messages, for whoever may create.
10
10
  - [The current organization](../reference/sidebar.md#the-current-organization): A sidebar entry opens its list on the organization you work in, which you can clear to see every organization you are a member of.
11
- - [User menu](../reference/user-menu.md): Account pages, help links, security settings, the theme switch and Sign out.
11
+ - [User menu](../reference/user-menu.md): Account pages, help links, security settings, setting a status, the theme switch and Sign out.
12
12
  - [Bottom bar](../reference/bottom-bar.md): On phones, tabs along the bottom for each role's main screens.
13
13
  - [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.
14
14
  - Breadcrumbs: The top bar shows the group, list and record you are on, each a link back.
@@ -13,4 +13,5 @@ A bell in the top bar and push to browsers and phones, for what your app tells i
13
13
  - [Web Push](../reference/notifications.md#web-push) (beta): Notifications reach desktop and Android browsers and home-screen web apps on iPhone through Web Push, with keys you generate.
14
14
  - Push on Android (coming soon): Notifications reach the Android build of the app on a user's phones.
15
15
  - Push on iOS (coming soon): Notifications reach the iOS build of the app on a user's iPhones and iPads.
16
+ - [Do not disturb](../reference/status.md#do-not-disturb) (beta): While someone is on do not disturb, sends push nothing to their devices and keep inbox notifications in the bell for later.
16
17
  - [Notification bell](../reference/notifications.md#the-bell) (beta): The top bar shows how many inbox notifications are unread; its panel opens each one, marks them read and turns push on or off for this device.
@@ -25,6 +25,7 @@ Sign-in methods, users, roles, organizations and tokens.
25
25
  - [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.
26
26
  - [Roles](../reference/auth.md#roles): A user holds one or more roles and switches between them without signing in again.
27
27
  - [Organizations](../reference/auth.md#organizations): People work in one organization at a time, see only its records, and are invited with their own roles.
28
+ - [Status](../reference/status.md) (beta): People set themselves busy or do not disturb, with a text of their own such as "Having lunch" and a time it clears, from the user menu; the people they share an organization with see it beside their name.
28
29
  - [API tokens](../reference/auth.md#tokens-and-roles): A signed-in session gets short-lived tokens for the API.
29
30
  - [Immediate revocation](../reference/auth.md#when-a-token-stops-working): A ban, removed role or ended session takes effect on the next request.
30
31
  - [Signing key rotation](../reference/auth.md#signing-keys): The keys that sign the tokens are replaced every 30 days on their own, and old ones keep verifying the tokens they signed for a week.
@@ -2,14 +2,14 @@
2
2
 
3
3
  # Calls
4
4
 
5
- Audio and video calls between an app's users, through a LiveKit server or straight between browsers, with Protobase deciding who is in a call, who may send and who hears whom.
5
+ Audio and video calls on any record of an app, through a LiveKit server or straight between browsers, with Protobase deciding who is in a call, who may send and who hears whom.
6
6
 
7
- ## Turning them on
8
-
9
- :::caution[In development]
10
- Members join through a function of your own and the browser client. Call rows, a lobby, stage mode, recording, guests and the call UI are not built yet, and only Chrome has been tested.
7
+ :::caution[Beta]
8
+ Calls live on records, with who is in them, removal and their end. A lobby, stage mode, recording, guests and the call UI are not built yet, and calls have been tested in Chromium and Firefox only.
11
9
  :::
12
10
 
11
+ ## Turning them on
12
+
13
13
  Calls carry audio and video between an app's users. The browser runs plain WebRTC and talks only to Protobase, which relays its offers, answers and candidates to the call's media plugin, inside the Protobase server: [LiveKit](#livekit), whose server carries the media, or [peer to peer](#peer-to-peer), where the browsers send it to each other. Either way the media never passes through Protobase, which decides who is in a call, who may send and who hears whom, and apps load no media library.
14
14
 
15
15
  ```ts
@@ -26,38 +26,75 @@ export default defineConfig(({ env }) => ({
26
26
  - `url`: the LiveKit server, self-hosted or LiveKit Cloud, such as `wss://livekit.example.com`.
27
27
  - `apiKey`, `apiSecret`: the key Protobase signs each member's LiveKit token with.
28
28
 
29
- Or, with no media server, `backend: { kind: 'peer' }`, with `iceServers` for the STUN and TURN servers browsers reach each other through: `[{ urls: ['stun:stun.example.com:3478'] }]`.
29
+ Or, with no media server, `backend: { kind: 'peer' }`: see [Peer to peer](#peer-to-peer) for its `iceServers` and `maxMembers`.
30
30
 
31
- Without `calls`, an app has none of it: the server loads no calls code, and only a page that imports `@protobase/client/calls` bundles the browser side.
31
+ - `maxMinutes`: how long a call lasts at most, 240 by default. Then it ends, whoever is still in it.
32
+ - `processes`: `'many'` when several processes serve the app behind one address, so members that different processes serve meet in one call; `'one'`, the default, otherwise.
33
+
34
+ Without `calls`, an app has none of it: the server loads no calls code, and only a page that imports `@protobase/client/calls` bundles the browser side. With `calls`, [`protobase migration`](cli.md#migration) adds the `calls` schema, where calls and their members are kept; apply it with the project's other migrations. `protobase dev` and `protobase serve` do not start while it is missing.
32
35
 
33
36
  Running LiveKit on your own machine: `bun run calls:up` in the Protobase repository starts one from `docker-compose.yml`, at `ws://127.0.0.1:7880` with the key `devkey` and the secret `secretsecretsecretsecretsecretsecret`.
34
37
 
35
- ## Admitting members
38
+ ## Calls on records
39
+
40
+ A call belongs to a record, such as a conversation or a meeting, and the record's readers see it live: who is in it, when it started and when it ended. You can remove someone from a call, a call ends by itself once everyone has left, and a peer-to-peer call has a size limit.
41
+
42
+ A record has at most one call going on: the first member to join starts it, and everyone who joins the record's call after meets them in it. Who started it, when, who joined and who was removed stay on the record once it ended, as its history.
36
43
 
37
- A member joins a call through an [API function](../guides/api-functions.md) of your own, which decides whether the caller may join, then answers with `acceptWebSocket(await calls.join(member))`:
44
+ ### Admitting members
45
+
46
+ A member joins the call on a record through an [API function](../guides/api-functions.md) of your own, which decides whether the caller may join, then answers with `acceptWebSocket(await calls.join(member))`:
38
47
 
39
48
  ```ts
40
49
  // functions/meeting.ts
41
50
  import { defineFunction } from '@protobase/server'
42
51
 
43
52
  export default defineFunction(async (request, { session, records, acceptWebSocket, calls }) => {
44
- const id = new URL(request.url).searchParams.get('call')!
45
- // The caller's access to the meeting record decides whether they may join; a refusal is a problem, as in any function.
46
- const meeting = await records.get('meetings', id)
53
+ const id = new URL(request.url).searchParams.get('meeting')!
54
+ const { record: meeting } = await records.get('meetings', id)
47
55
  return acceptWebSocket(
48
- await calls.join({ call: id, member: String(session.user.id), publish: meeting.host === session.user.id ? true : ['microphone'] }),
56
+ await calls.join({
57
+ record: { resource: 'meetings', key: id },
58
+ member: String(session.user.id),
59
+ publish: meeting.host_id === session.user.id ? true : ['microphone'],
60
+ }),
49
61
  )
50
62
  })
51
63
  ```
52
64
 
53
65
  | | |
54
66
  | --- | --- |
55
- | `call` | The call: members with the same `call` meet. |
56
- | `member` | Who joins, unique in the call, such as the user's id. LiveKit knows the member by nothing else: no name, no metadata. |
67
+ | `record` | The record the call is on, `{ resource, key }`. Only a signed-in caller who can read it joins: a visitor without an account is refused with 403, and one who cannot read it with the API's 404. |
68
+ | `member` | Who joins, unique in the call. Take it from the signed-in caller, such as `session.user.id`, never from the request: the other members know them by it. LiveKit knows the member by nothing else: no name, no metadata. |
57
69
  | `publish` | `true` to send any source, a list of `'camera'`, `'microphone'`, `'screen'` and `'screen-audio'`, or `false` to only listen. |
58
70
  | `hears` | Optional: which of the others' tracks the member hears, as `(track) => boolean` of `{ member, kind, source }`; every track by default. |
71
+ | `recheck` | Optional: the function's own checks, such as whether the caller is still invited, repeated every minute. Throw a 401, 403 or 404 problem to take the member out. |
72
+
73
+ The socket is checked again every minute, like any function's, and so is the caller's read of the record, then `recheck`: a member who can no longer read the record, or whom `recheck` refuses, is out of the call within the minute, and so is one whose check fails or takes longer than a minute. Pass your own check as `recheck` to `calls.join`, not on the events it returns, which would replace the record's check. A member who joins the same call again, from another tab, takes the place of their first socket.
74
+
75
+ ### Who is in it
76
+
77
+ Each member's browser gets everyone in the call, themselves too, members who send nothing included, whenever that changes: `onMembers` of `joinCall`, and `call.members()`, as `[{ member, joined_at }]`. A change made on the process that serves a member reaches them at once; one made on another process, within a second.
78
+
79
+ The record's readers get its calls, each with who is in it now, at `GET /api/{resource}/{key}:calls`, the one going on first, then the newest, 20 at most:
80
+
81
+ ```json
82
+ { "items": [{ "id": "4b1f…", "started_by": "ann", "started_at": "2026-10-29T10:00:00.000Z", "ended_at": null, "members": [{ "member": "ann", "joined_at": "2026-10-29T10:00:00.000Z" }], "removed": [] }] }
83
+ ```
59
84
 
60
- The socket is checked again every minute like any function's: a caller who would now be refused is closed out of the socket and leaves the call. The function's own checks, such as access to the meeting, are repeated only when it passes them as `recheck`.
85
+ With `?watch=true` the same comes as a `text/event-stream`, each event's data `{ items }`, at once and whenever the calls change; the stream ends once its user can no longer read the record, at the next minute's check. Who reads a record reads its calls: the same operation, tenant, row filter and record-level rule as a get, and a record the caller cannot read is a 404 whether or not it has a call. A visitor without an account is refused. `client.calls(resource, key)` and `client.watchCalls(resource, key, { onCalls })` of `@protobase/client` read and follow them, and `calls.of({ resource, key })` in a function gives them to your own code, with no access check, like `db`. Readers see who is in a call, never the members' signaling or network addresses. <gap>A list cannot show its records' calls live because a stream of several records' calls is not implemented.</gap>
86
+
87
+ ### Removing someone
88
+
89
+ `calls.remove(call, member)` in a function takes the member out of the call at once, the call's `id` as `joinCall`'s `call.id` and the record's calls give it. Their sockets close, with `removed` as the reason `onState` gets, the others' browsers close their connections to them, and the call keeps the removal: the member's resume and every join of theirs to that call are refused, also one already on its way. It returns whether they were in the call; a removal from a call that ended, or of someone in another call, changes nothing. Who may remove whom is your function's to decide.
90
+
91
+ ### The end of a call
92
+
93
+ A call ends when its last member left. A member whose socket was lost stays in the call for 30 seconds while their browser resumes, so a call whose members all lost their connection, or whose server process stopped, ends 30 seconds later. A call also ends at `maxMinutes`, whoever is still in it: the server closes every member out. A call that ended stays ended: a resume of it is refused, and the next join starts a new call on the record.
94
+
95
+ ### Size
96
+
97
+ A peer-to-peer call admits `maxMembers` at most, 8 by default. One more is refused with the reason `full`, which `onState` gets as `{ state: 'left', reason: 'full' }`, for the app to say "This call is full". A member who joins the call again from another tab is no one more.
61
98
 
62
99
  ## Joining from the browser
63
100
 
@@ -67,8 +104,9 @@ The socket is checked again every minute like any function's: a caller who would
67
104
  import { joinCall } from '@protobase/client/calls'
68
105
 
69
106
  const call = await joinCall({
70
- url: `/api/functions/meeting?call=${id}`,
107
+ url: `/api/functions/meeting?meeting=${id}`,
71
108
  onTracks: (tracks) => render(tracks), // [{ sid, member, kind, source, muted, track? }]
109
+ onMembers: (members) => showMembers(members), // [{ member, joined_at }]
72
110
  onState: (state) => showState(state), // connecting, joined, resuming, or left with its reason
73
111
  })
74
112
  const media = await navigator.mediaDevices.getUserMedia({ video: true, audio: true })
@@ -84,11 +122,13 @@ await call.publish({ camera: media.getVideoTracks()[0], microphone: media.getAud
84
122
  | `restartIce()` | New network paths, such as after a network change; a failed connection restarts by itself. |
85
123
  | `leave()` | Leaves the call. |
86
124
 
87
- `onSpeakers` gets who speaks how loudly, and `onUnpublished` a source the media server stopped, such as after the member lost the right to send.
125
+ `call.id` is the call, as the record's calls list it and `calls.remove` takes it. `onSpeakers` gets who speaks how loudly, and `onUnpublished` a source the media server stopped, such as after the member lost the right to send.
126
+
127
+ A call that is left rejects the join, or ends a joined call, with its reason in `onState`: `ended`, `removed` (by `calls.remove`, or by a check that refused the member), `full`, `refused` (the function refused the caller), or `unavailable`, when the server failed to take the member in `maxRetries` times in a row.
88
128
 
89
129
  ## Reconnecting
90
130
 
91
- When the socket to Protobase closes, such as during a deploy, media keeps flowing and the browser opens a new socket that resumes the member from its own state. With LiveKit any process serving the app can take it; when LiveKit no longer knows the member, the browser joins again and sends the same tracks. After `maxRetries` tries in a row, 8 by default, the call is left.
131
+ When the socket to Protobase closes, such as during a deploy, media keeps flowing and the browser opens a new socket that resumes the member from its own state, through the function again, so a member who can no longer read the record, or was removed, is refused. Any process serving the app can take it; when LiveKit no longer knows the member, the browser joins again and sends the same tracks. After `maxRetries` tries in a row, 8 by default, the call is left.
92
132
 
93
133
  ## LiveKit
94
134
 
@@ -96,8 +136,21 @@ When the socket to Protobase closes, such as during a deploy, media keeps flowin
96
136
 
97
137
  ## Peer to peer
98
138
 
99
- `kind: 'peer'`. Each member's browser keeps a peer connection to every other member's and sends them its media directly; Protobase passes their descriptions and candidates between them and tells each member who else is in the call and which tracks they hear. It suits small calls: a browser uploads its media once per other member. Members meet only on the same process, which keeps who is in each call, and a member whose socket was lost stays in the call for 30 seconds while their browser resumes. `hears` decides which tracks a member is told of; the media itself goes between the browsers, which Protobase cannot stop.
139
+ `kind: 'peer'`. Each member's browser keeps a peer connection to every other member's and sends them its media directly; Protobase passes their descriptions and candidates between the members of the same call only, and tells each member who else is in the call and which tracks they hear. `hears` decides which tracks a member is told of; the media itself goes between the browsers, which Protobase cannot stop.
140
+
141
+ A peer-to-peer call holds a small group only: a browser uploads its media once per other member, so `maxMembers`, 8 by default, bounds it. Members of a peer-to-peer call can see each other's network addresses, as their browsers connect to each other; readers of the record who are not in the call cannot.
142
+
143
+ With `calls: { processes: 'many' }`, members that different processes serve meet in one call: a description or candidate for a member another process serves goes through the `calls` schema, which each process with a member in a call reads ten times a second.
144
+
145
+ ```ts
146
+ calls: {
147
+ backend: { kind: 'peer', maxMembers: 8, iceServers: [{ urls: ['stun:stun.example.com:3478'] }] },
148
+ }
149
+ ```
150
+
151
+ - `iceServers`: the STUN and TURN servers the browsers find a path to each other through, which every member's browser gets; Protobase has none by default, and the browser never chooses its own. Without a STUN server, only browsers on the same network connect: set one so that people behind ordinary home routers do.
152
+ - A direct connection can fail behind some strict networks, such as a company firewall that lets no UDP through, and the members then hear nothing of each other. Protobase relays no media: add a TURN server of your own to `iceServers` for them, with short-lived credentials, since every member's browser receives them.
100
153
 
101
154
  ## Contract test
102
155
 
103
- The repository's contract test runs members in Chromium through both plugins, against a real LiveKit server: `bun run calls:up`, then `bun run test:calls`. `LIVEKIT_IMAGE` in the environment of `calls:up` tries another LiveKit version.
156
+ The repository's contract test runs members in Chromium and Firefox through both plugins, against a real LiveKit server and a Postgres test database: `bun run test:db` and `bun run calls:up`, then `bun run test:calls`. `LIVEKIT_IMAGE` in the environment of `calls:up` tries another LiveKit version.
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Jobs and events options
4
4
 
5
- The config keys of what the app does in the background and records as it changes, jobs, events, history, webhooks and notifications, with their types and defaults, and the files where a job's run and the stores of its own go.
5
+ The config keys of what the app does in the background and records as it changes, jobs, events, history, webhooks, notifications and status, with their types and defaults, and the files where a job's run and the stores of its own go.
6
6
 
7
7
  The keys of the app's background work and of what it keeps as records change, at the top level of [`protobase.config.ts`](../config.md).
8
8
 
@@ -265,3 +265,25 @@ The history table, each user's inbox: its name, and its columns named otherwise
265
265
  ```ts
266
266
  export default defineConfig({ notifications: { history: { table: 'inbox_items' } } })
267
267
  ```
268
+
269
+ ## status
270
+
271
+ - **Type:** `{ schema?: string }`
272
+ - **Default:** off; `{}` turns it on
273
+
274
+ People set their own status, busy, do not disturb or a text of their own, which the people they share an organization with see, and do not disturb holds their pushes. It needs `auth` with organizations, and its table is written by `protobase migration`. See [Status](../status.md).
275
+
276
+ ```ts
277
+ export default defineConfig({ auth: { organizations: true }, status: {} })
278
+ ```
279
+
280
+ ## status.schema
281
+
282
+ - **Type:** `string`
283
+ - **Default:** `status`
284
+
285
+ The schema of the statuses table.
286
+
287
+ ```ts
288
+ export default defineConfig({ status: { schema: 'presence' } })
289
+ ```
@@ -30,7 +30,7 @@ Each key is described with its type and default in the option pages:
30
30
  | [Sign-in options](config/sign-in.md) | `auth`, `authenticate`, `signingKeyDays`, `signingKeyGraceDays` |
31
31
  | [API options](config/api.md) | `apiPath`, `apiKeys`, `cors`, `defaultAccess`, `rowPermissions`, `statementTimeoutMs`, `scanGuard`, `errorReporting`, `writeHooks`, `mcpEndpoint`, `remoteResources`, `runtimeUpdates`, `realtime`, `calls` |
32
32
  | [Admin app options](config/admin-app.md) | `assistant`, `maps`, `plugins` |
33
- | [Jobs and events options](config/jobs-and-events.md) | `jobs`, `events`, `history`, `webhooks`, `notifications` |
33
+ | [Jobs and events options](config/jobs-and-events.md) | `jobs`, `events`, `history`, `webhooks`, `notifications`, `status` |
34
34
  | [Files options](config/files.md) | `files` |
35
35
 
36
36
  ## Config types
@@ -335,7 +335,7 @@ export const Channel = ({ messages, sent, members, onSend, onLoadEarlier }: Chan
335
335
 
336
336
  ### Members' names
337
337
 
338
- The author is a user id, and `useMembers()` from `@protobase/ui` turns it into a name: the members of the organization the signed-in person works in, `{ id, name, image? }` by name, with `id` the user id that `.author()` stores and that `onSend`'s mentions hold. Every member reads it, owners, admins and members alike; it holds no email addresses. It is a TanStack Query result (`data`, `isLoading`, `error`) with `member(id)`, which finds one and, for an id it does not know, such as a newcomer's first message, reads the list again once it is 10 seconds old; it is also read again when the window regains focus and the list is 30 seconds old. It needs [organizations](auth.md#organizations): without them, `error` says so.
338
+ The author is a user id, and `useMembers()` from `@protobase/ui` turns it into a name: the members of the organization the signed-in person works in, `{ id, name, image? }` by name, with `id` the user id that `.author()` stores and that `onSend`'s mentions hold. Every member reads it, owners, admins and members alike; it holds no email addresses. It is a TanStack Query result (`data`, `isLoading`, `error`) with `member(id)`, which finds one and, for an id it does not know, such as a newcomer's first message, reads the list again once it is 10 seconds old; it is also read again when the window regains focus and the list is 30 seconds old. It needs [organizations](auth.md#organizations): without them, `error` says so. In an app with [status](status.md#in-the-app), each member carries their `status` too, read again every 15 seconds.
339
339
 
340
340
  ```tsx
341
341
  import { ChatMessage, Composer, MentionedText, useMembers } from '@protobase/ui'
@@ -112,6 +112,8 @@ A send checks no permission. A device send reaches the devices whatever user hol
112
112
 
113
113
  A user send reaches the user's devices as they are when the job runs. A device that moved to someone else, or was removed, gets nothing. With Protobase's auth, a device whose sign-in session has [ended](#devices) is removed instead; a send whose devices' sessions cannot be read pushes to none of them and is retried. With an app's own authenticator, a device keeps receiving its user's notifications until it is removed. When a push service reports a device gone, the device is removed. A device whose push service asks to try again later is tried once more, on the job's next try, and then given up on without being removed. <gap>A push service's own wait before a retry cannot set when the device is tried again because retries follow the job's backoff and timing them per device is not implemented.</gap> A sender that fails is retried with its devices, up to 5 tries of the job. Devices of a kind without a sender are skipped. Without any sender, a send for the inbox is kept in the history and a send that is not does nothing.
114
114
 
115
+ In an app with [status](status.md#do-not-disturb), a user on do not disturb when the send's job runs gets nothing pushed, by any sender, built-in or the app's own, and a send to devices holds their devices too; a send for the inbox still keeps the notification in their history, which the bell shows unread. Nothing of the send is pushed to them once do not disturb ends, and the others in the send are pushed as usual.
116
+
115
117
  ## History
116
118
 
117
119
  :::caution[Beta]
@@ -0,0 +1,97 @@
1
+ <!-- Generated by scripts/protobase-skill.ts from docs/website/src/content/docs/reference/status.md: run `bun run docs:skill`, do not edit. -->
2
+
3
+ # Status
4
+
5
+ People set their own status, busy, do not disturb or a text such as "Having lunch", which the people they share an organization with see beside their name, and do not disturb holds their push notifications.
6
+
7
+ ## Turning it on
8
+
9
+ :::caution[Beta]
10
+ A status is the same in every organization; a status per organization and do-not-disturb schedules are not part of it.
11
+ :::
12
+
13
+ A status says whether someone wants to be reached: an availability, busy or do not disturb, and a short text of their own, such as "Having lunch" or "On vacation 🌴". You turn it on in `protobase.config.ts`:
14
+
15
+ ```ts
16
+ import { defineConfig } from '@protobase/config'
17
+
18
+ export default defineConfig({
19
+ auth: { organizations: true },
20
+ status: {},
21
+ })
22
+ ```
23
+
24
+ Then run `protobase migration`, which writes the statuses table, `status.statuses`, as a migration of the project's own, and apply it with the project's migrations. `status: { schema: 'presence' }` puts the table in another schema. `protobase dev` and `protobase serve` refuse to start while the table is missing. Without `status` there is none of it: no menu item, no endpoints, no table and no migration, and notifications go out as before.
25
+
26
+ People see the statuses of those they share an [organization](auth.md#organizations) with, so status needs organizations: an app without them stops at startup, and `protobase migration` says why.
27
+
28
+ ## Setting a status
29
+
30
+ Someone signed in as themselves opens "Set a status" in the [user menu](user-menu.md) and picks:
31
+
32
+ - an availability: automatic, the default, which says nothing; busy; or do not disturb;
33
+ - a text of at most 100 characters, one line of plain text; an emoji typed in it is one character;
34
+ - when it clears: never, in 30 minutes, 1 hour or 4 hours, at the end of today or of this week (midnight, Sunday night for the week, in their own time zone), or at a date and time they choose.
35
+
36
+ Their status then shows by their name at the bottom of the sidebar, and the item shows it; they change it or clear it there at any time. Staff [signed in as the person](auth.md#staff-sign-in) see no item.
37
+
38
+ Each person has one status, shown in every organization they are in. Only they set it: the server takes the person from the session, never from the request, and refuses staff signed in as them, visitors and outside apps acting for them, such as an MCP client. A text with control characters, a line break among them, or over 100 characters is refused with a `400` that says why, and so is a clear time that has passed. The text is always shown as text, never as HTML.
39
+
40
+ | Request | |
41
+ | --- | --- |
42
+ | `GET /api/status` | the caller's own status, `{ status }`, `null` without one |
43
+ | `PUT /api/status` | sets it from `{ availability, text, clearsAt }`, each required, `text` and `clearsAt` `null` for none and never; answers `{ status }` |
44
+ | `DELETE /api/status` | clears it; answers `204` |
45
+ | `GET /api/status/people` | `{ statuses }`, the statuses of everyone who shares an organization with the caller, their own among them |
46
+
47
+ A status is `{ userId, availability, text, clearsAt }`, with `availability` one of `automatic`, `busy` and `do_not_disturb`, and `clearsAt` an ISO time or `null`.
48
+
49
+ ## Who sees it
50
+
51
+ The members of every organization the person is in see their status. Someone who shares no organization with them gets nothing, as for a person they cannot see: `GET /api/status/people` leaves them out. A visitor, signed in as no one, is refused with a `401`. <gap>`GET /api/status/people` cannot page because paging statuses is not implemented, so it answers every status set by those who share an organization with the caller, which suits a team, not thousands of people.</gap>
52
+
53
+ ## How it clears
54
+
55
+ A status ends at its clear time for everyone, also while the person has no page open: the server reads a status whose time has passed as none, and do not disturb ends with it.
56
+
57
+ A page reads the statuses again every 15 seconds while it is in view, and when it comes back into view, over the connections it already has, so another person's change, or a status whose time has passed, shows within 15 seconds without reloading. It opens no connection of its own: a page near the 6 connections a browser keeps per server under HTTP/1.1 keeps working.
58
+
59
+ ## Do not disturb
60
+
61
+ While someone is on do not disturb, when a [send](notifications.md#sending)'s job runs, the send pushes to none of their devices, through any sender, built-in or the app's own. A send for the inbox still keeps the notification in their history, so the bell shows it and counts it unread. Nothing of that send is pushed later, when do not disturb ends. The others in the same send are pushed as usual. A send to devices, `{ deviceIds }`, holds the devices of someone on do not disturb too. Busy is a mark only, and holds nothing.
62
+
63
+ Your own server code asks the same question with `onDoNotDisturb(db, statusNames(options), userIds)` from `@protobase/server`, which answers the set of those on do not disturb now, so whatever else alerts people holds it alike.
64
+
65
+ ## In the app
66
+
67
+ The organization's members page shows each member's status beside their name. `useMembers()` from `@protobase/ui` gives each member their `status` when they have one, beside their name and photo, and `useStatuses()` the statuses alone. `StatusMark` draws a status beside a name: a mark for busy, one for do not disturb, and the text, in full or, with `textShown="hover"`, on hover. Who is online or away is each app's own, from its [presence](channels.md#presence); pass its mark as `presence`, and `StatusMark` draws it first, so the two sit side by side:
68
+
69
+ ```tsx
70
+ import { StatusMark, useMembers } from '@protobase/ui'
71
+
72
+ export const Person = ({ id, online }: { id: string; online: boolean }) => {
73
+ const person = useMembers().member(id)
74
+ if (!person) return null
75
+ const dot = <span role="img" aria-label={online ? 'Online' : 'Away'} className={online ? 'size-2 rounded-full bg-success' : 'size-2 rounded-full bg-muted'} />
76
+ return (
77
+ <span className="flex items-center gap-1.5">
78
+ {person.name}
79
+ <StatusMark status={person.status} presence={dot} textShown="hover" />
80
+ </span>
81
+ )
82
+ }
83
+ ```
84
+
85
+ `StatusMark` draws nothing of a status whose clear time has passed, even before the page reads the statuses again.
86
+
87
+ ## The client
88
+
89
+ `client.status` of `@protobase/client` reads and sets the signed-in person's own status and reads the others':
90
+
91
+ ```ts
92
+ const lunch = await client.status.set({ availability: 'busy', text: 'Having lunch', clearsAt: new Date(Date.now() + 3_600_000).toISOString() })
93
+ const everyone = await client.status.people()
94
+ await client.status.clear()
95
+ ```
96
+
97
+ `set` rejects with an `ApiError` whose `slug` is `invalid-status-text`, `invalid-clear-time` or `invalid-status` for what the server refuses, and `own-sign-in-only` for staff signed in as the person.
@@ -4,7 +4,7 @@
4
4
 
5
5
  The user menu at the bottom of the sidebar, with the app's own account pages and links.
6
6
 
7
- The signed-in user sits at the bottom of the sidebar. Clicking them opens a menu with their name and email, which link to their account, the app's own pages, the theme switch, and "Sign out". Account pages (organization, billing, users) and help links belong here rather than among the working resources.
7
+ The signed-in user sits at the bottom of the sidebar. Clicking them opens a menu with their name and email, which link to their account, "Set a status" in an app with [status](status.md), the app's own pages, the theme switch, and "Sign out". Account pages (organization, billing, users) and help links belong here rather than among the working resources.
8
8
 
9
9
  Export one [`userMenu(...)`](https://docs.protobase.net/api/schema/functions/usermenu/) from `config/index.ts`:
10
10