@protobase/cli 0.74.0 → 0.75.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.74.0";
2
+ var version = "0.75.1";
3
3
  //#endregion
4
4
  export { version };
@@ -1,3 +1,4 @@
1
+ import { pushPlugin } from "./pinned-packages.js";
1
2
  import path from "node:path";
2
3
  import { rm, writeFile } from "node:fs/promises";
3
4
  import { capacitorOrigin } from "@protobase/schema/internal";
@@ -5,6 +6,11 @@ import { capacitorOrigin } from "@protobase/schema/internal";
5
6
  const protobasePlugin = "@protobase/mobile";
6
7
  const keyboardPlugin = "@capacitor/keyboard";
7
8
  const liveUpdatePlugin = "@capawesome/capacitor-live-update";
9
+ const pushPresentation = [
10
+ "badge",
11
+ "sound",
12
+ "alert"
13
+ ];
8
14
  const readyTimeout = 3e4;
9
15
  /**
10
16
  * The app's `capacitor.config.json`, every key it sets named here. It never sets `server.url`, the hostname or the
@@ -15,12 +21,13 @@ const readyTimeout = 3e4;
15
21
  * files, background updates off, a rolled-back bundle blocked and `readyTimeout`, within which the shell must call
16
22
  * ready() or the app goes back to its own files. CapacitorHttp and CapacitorCookies stay off; the keyboard plugin
17
23
  * resizes natively, its default, and fills the space beside the keyboard's rounded corners with the page's background
18
- * instead of black. Protobase's plugin is compiled in last, so its stand-ins replace any plugin of the same name.
24
+ * instead of black. With `push`, Capacitor's push plugin is compiled in and shows a push while the app is open. It
25
+ * never sets `server.allowNavigation`, so no other host loads inside the WebView. Protobase's plugin is compiled in last, so its stand-ins replace any plugin of the same name.
19
26
  * Service workers get nothing from the local server on Android, which they would reach past the WebViewClient that
20
27
  * guards it. The file ships outside the app's web part, so the fingerprint in the user agent and ProtobaseAuth's
21
28
  * origins are beyond page script and a live update.
22
29
  */
23
- const capacitorConfig = ({ appId, appName, fingerprint, shellVersion, plugins, liveUpdate, allowances, apiOrigin, platform, release }) => ({
30
+ const capacitorConfig = ({ appId, appName, fingerprint, shellVersion, plugins, liveUpdate, allowances, apiOrigin, platform, release, push }) => ({
24
31
  appId,
25
32
  appName,
26
33
  webDir: "web",
@@ -28,6 +35,7 @@ const capacitorConfig = ({ appId, appName, fingerprint, shellVersion, plugins, l
28
35
  includePlugins: [
29
36
  ...plugins,
30
37
  ...liveUpdate ? [liveUpdatePlugin] : [],
38
+ ...push ? [pushPlugin] : [],
31
39
  keyboardPlugin,
32
40
  protobasePlugin
33
41
  ],
@@ -37,6 +45,7 @@ const capacitorConfig = ({ appId, appName, fingerprint, shellVersion, plugins, l
37
45
  origin: capacitorOrigin[platform]
38
46
  },
39
47
  Keyboard: { autoBackdropColor: "dom" },
48
+ ...push && { PushNotifications: { presentationOptions: pushPresentation } },
40
49
  ...liveUpdate && { LiveUpdate: {
41
50
  ...liveUpdate,
42
51
  readyTimeout,
@@ -1,3 +1,4 @@
1
+ import { copyGoogleServices } from "./google-services.js";
1
2
  import { withLocalNetworking } from "./info-plist.js";
2
3
  import { withProtobaseIcon } from "./native-icon.js";
3
4
  import path from "node:path";
@@ -6,16 +7,18 @@ import { readFile, rm, writeFile } from "node:fs/promises";
6
7
  const infoPlist = (ws) => path.join(ws, "ios", "App", "App", "Info.plist");
7
8
  /**
8
9
  * Generates the platform's native project in the workspace from its capacitor.config.json and app files, replacing
9
- * the last one: it is never edited by hand. Its home-screen icon is Protobase's, and an iOS app calling the API over
10
- * plain http may reach local addresses.
10
+ * the last one: it is never edited by hand. Its home-screen icon is Protobase's, an Android app with push gets the
11
+ * project's google-services.json from `googleServicesFrom`, and an iOS app calling the API over plain http may reach
12
+ * local addresses.
11
13
  */
12
- const generatePlatform = async (ws, platform, { cleartext }, cap) => {
14
+ const generatePlatform = async (ws, platform, { cleartext, googleServicesFrom }, cap) => {
13
15
  await rm(path.join(ws, platform), {
14
16
  recursive: true,
15
17
  force: true
16
18
  });
17
19
  await cap(["add", platform]);
18
20
  await withProtobaseIcon(ws, platform);
21
+ if (platform === "android" && googleServicesFrom !== void 0) await copyGoogleServices(googleServicesFrom, ws);
19
22
  if (platform !== "ios" || !cleartext) return;
20
23
  await writeFile(infoPlist(ws), withLocalNetworking(await readFile(infoPlist(ws), "utf8")));
21
24
  };
@@ -0,0 +1,28 @@
1
+ import path from "node:path";
2
+ import { copyFile, lstat } from "node:fs/promises";
3
+ //#region src/mobile/google-services.ts
4
+ /** Where an Android app's Firebase file is kept: the project's root, next to protobase.config.ts. */
5
+ const googleServicesFile = (projectDir) => path.join(projectDir, "google-services.json");
6
+ /** Why an Android build with `notifications()` has no push, naming the file it looks for. */
7
+ const missingGoogleServices = (projectDir) => `${googleServicesFile(projectDir)} is missing: the Android app builds without push. Put your Firebase project's google-services.json there to turn it on`;
8
+ /**
9
+ * Whether the project has its Firebase file: a regular file, never a link, which the copy would follow out of the
10
+ * project. Anything else at that place stops the build.
11
+ */
12
+ const hasGoogleServices = async (projectDir) => {
13
+ const file = googleServicesFile(projectDir);
14
+ const stats = await lstat(file).catch((error) => {
15
+ if (error.code === "ENOENT") return void 0;
16
+ throw error;
17
+ });
18
+ if (!stats) return false;
19
+ if (!stats.isFile()) throw new Error(`${file} is not a regular file: put the google-services.json of your Firebase project there`);
20
+ return true;
21
+ };
22
+ /**
23
+ * Copies the project's Firebase file into the generated Android app, where the template's build.gradle applies the
24
+ * google-services plugin only when the file is there.
25
+ */
26
+ const copyGoogleServices = (projectDir, ws) => copyFile(googleServicesFile(projectDir), path.join(ws, "android", "app", "google-services.json"));
27
+ //#endregion
28
+ export { copyGoogleServices, googleServicesFile, hasGoogleServices, missingGoogleServices };
@@ -5,20 +5,22 @@ import { appNameOver } from "@protobase/server";
5
5
  //#region src/mobile/load-project.ts
6
6
  /**
7
7
  * What a mobile build needs of the project in `dir`, merged as `protobase dev` merges it after the configs of
8
- * `extensions`: its mobile section, unchecked, and with sign-in on the app's URL, its tokens' issuer, and its name.
8
+ * `extensions`: its mobile section, unchecked, whether it has `notifications()`, and with sign-in on the app's URL, its
9
+ * tokens' issuer, and its name.
9
10
  * The project's .env is loaded first, as other commands do, and no `PROTOBASE_ANDROID_*` variable is left in the
10
11
  * environment; nothing but the configs runs.
11
12
  */
12
13
  const loadMobileProject = async (dir, extensions) => {
13
14
  loadNearestEnvFile(dir);
14
15
  dropAndroidSigning(process.env);
15
- const { mobile, auth, url, name } = await loadSourceConfig(dir, {
16
+ const { mobile, auth, url, name, notifications } = await loadSourceConfig(dir, {
16
17
  command: "tool",
17
18
  extensions
18
19
  });
19
20
  const appName = appNameOver(process.env, name);
20
21
  return {
21
22
  mobile,
23
+ notifications: Boolean(notifications),
22
24
  auth: auth && url ? {
23
25
  issuer: url,
24
26
  ...appName && { appName }
@@ -1,6 +1,6 @@
1
1
  //#region ../mobile/package.json
2
2
  var name = "@protobase/mobile";
3
- var nativeContract = 8;
3
+ var nativeContract = 9;
4
4
  var dependencies = {
5
5
  "@capacitor/android": "8.5.3",
6
6
  "@capacitor/app": "8.1.2",
@@ -8,6 +8,7 @@ var dependencies = {
8
8
  "@capacitor/core": "8.5.3",
9
9
  "@capacitor/ios": "8.5.3",
10
10
  "@capacitor/keyboard": "8.0.6",
11
+ "@capacitor/push-notifications": "8.1.3",
11
12
  "@capacitor/splash-screen": "8.0.2",
12
13
  "@capawesome/capacitor-live-update": "8.7.1"
13
14
  };
@@ -20,9 +20,12 @@ const pinnedNative = {
20
20
  [name]: `native-${nativeContract}`
21
21
  };
22
22
  const liveUpdate = "@capawesome/capacitor-live-update";
23
+ /** Capacitor's push plugin, which @protobase/mobile pins and an Android app with `notifications()` compiles in. */
24
+ const pushPlugin = "@capacitor/push-notifications";
23
25
  /** Why the plugin `key`, a package that is or names `name`, may not be listed; `undefined` when it may. */
24
26
  const pinnedProblem = (key, name = key) => {
25
27
  if (name === liveUpdate) return `mobile.plugins lists ${key}, ${liveUpdate}: live updates come with Protobase's updater, which mobile.publicKey turns on; remove it from mobile.plugins`;
28
+ if (name === "@capacitor/push-notifications") return `mobile.plugins lists ${key}, ${pushPlugin}: native push comes with notifications(); remove it from mobile.plugins`;
26
29
  if (pinnedPackages.has(name)) return `mobile.plugins lists ${key}, which ${name === key ? "comes" : `installs ${name}, which comes`} with Protobase at a fixed version: remove it from mobile.plugins`;
27
30
  };
28
31
  /**
@@ -46,4 +49,4 @@ const checkPinnedNative = (dir, pinned = nativeDependencies) => {
46
49
  }
47
50
  };
48
51
  //#endregion
49
- export { checkInstalledPlugins, checkPinnedNative, nativeDependencies, pinnedNative, pinnedPackages, pinnedProblem };
52
+ export { checkInstalledPlugins, checkPinnedNative, nativeDependencies, pinnedNative, pinnedPackages, pinnedProblem, pushPlugin };
@@ -1,13 +1,17 @@
1
1
  import path from "node:path";
2
2
  import { readFile, writeFile } from "node:fs/promises";
3
3
  //#region src/mobile/protobase-plugin.ts
4
- /** The classes of Protobase's native plugin that keep page script away from the session, by Java class name. */
4
+ /**
5
+ * The classes of Protobase's native plugin that keep page script away from the session, and ProtobaseExternal, which
6
+ * opens a url outside the app, by Java class name.
7
+ */
5
8
  const protobasePluginClasses = [
6
9
  "ProtobaseAuth",
7
10
  "RefusedHttp",
8
11
  "RefusedCookies",
9
12
  "RefusedWebView",
10
- "LocalServerGuard"
13
+ "LocalServerGuard",
14
+ "ProtobaseExternal"
11
15
  ].map((name) => `net.protobase.mobile.${name}`);
12
16
  const liveUpdatePackage = "@capawesome/capacitor-live-update";
13
17
  const stockLiveUpdate = "io.capawesome.capacitorjs.plugins.liveupdate.LiveUpdatePlugin";
@@ -10,6 +10,7 @@ import { buildWebPart, placeholderWebPart } from "./web-part.js";
10
10
  import { capacitorConfig, writeCapacitorConfig } from "./capacitor-config.js";
11
11
  import { childEnv, envFileKeys, projectEnvFiles } from "./child-env.js";
12
12
  import { deviceAppName } from "./device-app-name.js";
13
+ import { hasGoogleServices, missingGoogleServices } from "./google-services.js";
13
14
  import { generatePlatform } from "./generate.js";
14
15
  import { liveUpdateSettings } from "./live-update-settings.js";
15
16
  import { loadMobileProject } from "./load-project.js";
@@ -55,7 +56,9 @@ const prepare = async ({ projectDir, platform, api, extensions, live, release },
55
56
  ...build && { build },
56
57
  onWarning
57
58
  }) : await placeholderWebPart(ws);
58
- const fingerprint = nativeFingerprint(pinnedNative, mobile.plugins);
59
+ const fingerprint = nativeFingerprint(pinnedNative, mobile.plugins, { push: project.notifications });
60
+ const push = project.notifications && platform === "android" && await hasGoogleServices(projectDir);
61
+ if (project.notifications && platform === "android" && !push) onWarning(missingGoogleServices(projectDir));
59
62
  const liveUpdate = liveUpdateSettings({
60
63
  ...mobile.publicKey && { publicKey: mobile.publicKey },
61
64
  ...builtInOrder && { builtInOrder },
@@ -72,14 +75,18 @@ const prepare = async ({ projectDir, platform, api, extensions, live, release },
72
75
  allowances,
73
76
  apiOrigin: url.origin,
74
77
  platform,
75
- ...release && { release }
78
+ ...release && { release },
79
+ ...push && { push }
76
80
  };
77
81
  await writeCapacitorConfig(ws, capacitorConfig({
78
82
  ...config,
79
83
  ...liveUpdate.settings && { liveUpdate: liveUpdate.settings }
80
84
  }));
81
85
  const cap = capacitorRunner(ws, env, run);
82
- await generatePlatform(ws, platform, allowances, cap);
86
+ await generatePlatform(ws, platform, {
87
+ ...allowances,
88
+ ...push && { googleServicesFrom: projectDir }
89
+ }, cap);
83
90
  if (platform === "android") {
84
91
  await guardLiveUpdate(ws);
85
92
  await checkProtobasePlugin(ws);
@@ -65,7 +65,8 @@ const startServe = async ({ config, env, openDb = (url) => openAppDatabase(pg, u
65
65
  mobile: project.mobile,
66
66
  issuer: project.auth?.issuer,
67
67
  signingKey: env.mobileSigningKey,
68
- serverVersion: protobaseVersion
68
+ serverVersion: protobaseVersion,
69
+ push: Boolean(project.notifications)
69
70
  }) : void 0;
70
71
  const mobile = project.mobile && {
71
72
  ...release && { release },
@@ -18,17 +18,17 @@ const releaseOrigin = (issuer) => {
18
18
  };
19
19
  /**
20
20
  * The release of the app's files a server offers its mobile app: every file the site serves, its SPA page naming the
21
- * API origin as the app's own files do, for binaries of the fingerprint of the site's native packages and the project's
22
- * plugins. Signed, its statement binds it to its order, the app id, that fingerprint and the server's Protobase version.
21
+ * API origin as the app's own files do, for binaries of the fingerprint of the site's native packages, the project's
22
+ * plugins and whether it has native push. Signed, its statement binds it to its order, the app id, that fingerprint and the server's Protobase version.
23
23
  * None without a mobile section, without the site's files (the API alone, whose files a host serves), a site that
24
24
  * names no native packages (a bundle built before them), an API origin an app calls, or, signed, an order.
25
25
  */
26
- const servedRelease = async ({ site, mobile, issuer, signingKey, serverVersion }) => {
26
+ const servedRelease = async ({ site, mobile, issuer, signingKey, serverVersion, push = false }) => {
27
27
  const origin = releaseOrigin(issuer);
28
28
  if (!mobile || !site?.native || !origin) return void 0;
29
29
  const order = releaseOrder(site);
30
30
  if (signingKey && !order) return void 0;
31
- const fingerprint = nativeFingerprint(site.native, mobile.plugins);
31
+ const fingerprint = nativeFingerprint(site.native, mobile.plugins, { push });
32
32
  const files = await Promise.all((await siteFiles(site)).map(async ({ href, file }) => ({
33
33
  href,
34
34
  content: href === site.spa ? new TextEncoder().encode(withApiOrigin(await readFile(file, "utf8"), origin)) : new Uint8Array(await readFile(file))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.74.0",
3
+ "version": "0.75.1",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -43,13 +43,13 @@
43
43
  "dependencies": {
44
44
  "@better-auth/core": "^1.7.12",
45
45
  "@hono/node-server": "^2.1.3",
46
- "@protobase/config": "0.74.0",
47
- "@protobase/layout": "0.74.0",
48
- "@protobase/query": "0.74.0",
49
- "@protobase/schema": "0.74.0",
50
- "@protobase/server": "0.74.0",
51
- "@protobase/ui": "0.74.0",
52
- "@protobase/workflows": "0.74.0",
46
+ "@protobase/config": "0.75.1",
47
+ "@protobase/layout": "0.75.1",
48
+ "@protobase/query": "0.75.1",
49
+ "@protobase/schema": "0.75.1",
50
+ "@protobase/server": "0.75.1",
51
+ "@protobase/ui": "0.75.1",
52
+ "@protobase/workflows": "0.75.1",
53
53
  "@react-email/render": "^2.1.0",
54
54
  "@scalar/hono-api-reference": "^0.12.10",
55
55
  "@sentry/vite-plugin": "^11.10.0",
@@ -13,7 +13,7 @@ The sidebar, the user menu, the bottom bar on phones and the global search.
13
13
  - [User menu](../reference/user-menu.md): Account pages, help links, security settings, setting a status, the theme switch and Sign out.
14
14
  - [Bottom bar](../reference/bottom-bar.md): On phones, tabs along the bottom for each role's main screens.
15
15
  - [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.
16
- - [Breadcrumbs](../reference/ui-config.md#breadcrumbs): The top bar shows the group, list and record you are on, each a link back, and on a phone a back button to the one before.
16
+ - [Breadcrumbs](../reference/ui-config.md#breadcrumbs): The top bar shows the group and list you are on, each a link back, and on a phone a back button to the one before; a record page's heading names the record.
17
17
  - [Tab titles](../reference/ui-config.md#names-and-columns): Browser tabs name the record, list or page they show, then the app.
18
18
  - [Update notice](../reference/versioning.md#a-new-version-under-an-open-page): When the server runs a newer Protobase version, open pages offer a reload so the user can save their work first.
19
19
  - Config refresh: When the config or the user's roles change, open pages load the new menus, columns and permissions without a reload.
@@ -11,7 +11,7 @@ A bell in the top bar and push to browsers and phones, for what your app tells i
11
11
  - [Sending notifications](../reference/notifications.md#sending) (beta): Your code sends a notification to users or to devices as a background job, queued in the same transaction as a write, and says on each one whether it shows in the inbox.
12
12
  - [Notification history](../reference/notifications.md#history) (beta): Each user's inbox notifications are kept with when they were read, and the API lists them, counts the unread ones and marks them read.
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
- - [Push on Android](../reference/notifications.md#android) (in development): The server sends notifications to Android devices through Firebase Cloud Messaging with the service account key in `PROTOBASE_FCM_SERVICE_ACCOUNT`; the mobile app registering for them is coming soon.
14
+ - [Push on Android](../reference/notifications.md#android) (beta): The server sends notifications to Android devices through Firebase Cloud Messaging with the service account key in `PROTOBASE_FCM_SERVICE_ACCOUNT`, and the mobile app receives them, set up by `protobase mobile` from a `google-services.json` in the project.
15
15
  - Push on iOS (coming soon): Notifications reach the iOS build of the app on a user's iPhones and iPads.
16
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.
17
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.
@@ -12,7 +12,7 @@ The page of one record, with its sections, related records, galleries, charts an
12
12
  - [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.
13
13
  - [Unsaved edits](../reference/ui-config.md#editing-a-record): Unsaved changes to a record stay in the browser and can be resumed, and leaving a form, a dialog or a comment with changes asks first.
14
14
  - [Record forms](../reference/ui-config.md#editing-a-record): Relations are picked from a list that narrows as you type, numbers are read as the browser's language writes them, and a refused save says under each field what is wrong.
15
- - [Titles per reader](../reference/ui-config.md#titles-per-reader): A record without a name of its own, such as a direct message, is titled for each reader from its fields, such as after the other members, in the sidebar, breadcrumbs, heading, browser tab, relation links, list columns, relation pickers, filters and search.
15
+ - [Titles per reader](../reference/ui-config.md#titles-per-reader): A record without a name of its own, such as a direct message, is titled for each reader from its fields, such as after the other members, in the sidebar, heading, browser tab, relation links, list columns, relation pickers, filters and search.
16
16
  - [JSON fields on forms](../reference/plugins.md#json) (beta): A JSON field, such as a workflow run's input, is edited on forms as JSON text and shown written out on several lines.
17
17
  - [Member fields](../reference/plugins.md#members): A field that holds a list of people, such as a private channel's members, picks the organization's members by name on forms and shows them by avatar and name.
18
18
  - [Save feedback](../reference/ui-config.md#the-record-page): A view shows saving on the Save button instead of in a toast.
@@ -148,7 +148,19 @@ Build the binary again. Each deploy of the app then reaches it: it downloads the
148
148
  You submit the app under your own developer account, on both stores: Apple rejects apps from a template or app generation service unless the provider of the app's content submits them ([App Review Guidelines](https://developer.apple.com/app-store/review/guidelines/) 4.2.6).
149
149
 
150
150
  - **What may change without a store release:** the app's files, which a later Protobase release can update over the air: the shell, UI plugins, theme, in-app logo and copy, and fixes and features within the app's purpose. Apple allows downloaded interpreted code that does not change the app's primary purpose ([Apple Developer Program License Agreement](https://developer.apple.com/support/terms/apple-developer-program-license-agreement/) 3.3.1(B)), and Google Play allows JavaScript in a WebView ([Device and Network Abuse](https://support.google.com/googleplay/android-developer/answer/9888379)).
151
- - **What needs a store release:** native code, Capacitor or plugin changes (`mobile.plugins`), permissions, the app's name, its home-screen icon and its splash screen.
151
+ - **What needs a store release:** native code, Capacitor or plugin changes (`mobile.plugins`), turning [push](#9-push-notifications) on or off, permissions, the app's name, its home-screen icon and its splash screen.
152
152
  - **Big new features** still go through Apple's review with a store release, even when they could ship over the air: Apple asks that an app's features be documented and reviewed, none hidden (App Review Guidelines 2.3.1 and 2.5.19).
153
153
  - **Account deletion is built in:** Apple requires an app that lets people create an account to let them delete it in the app too (App Review Guidelines 5.1.1(v)). The account page's [Delete account](../reference/auth.md#deleting-the-account) does that, on by default; keep `auth.accountDeletion` on for an app you submit.
154
154
  - **A plain WebView of an admin app risks rejection:** Apple expects an app to be more than a repackaged website (4.2). Native touches help, such as push notifications, sharing, the camera or biometric sign-in, through `mobile.plugins`.
155
+
156
+ ## 9. Push notifications
157
+
158
+ With [`notifications()`](../reference/notifications.md) on, `protobase mobile` sets push up in the app itself: there is no push setting in the mobile section. Push on iOS is coming soon.
159
+
160
+ ### Android
161
+
162
+ Put your Firebase project's `google-services.json` in the project folder, next to `protobase.config.ts`. You download it from the Firebase console (Project settings, Your apps, an Android app whose package name is the mobile section's `appId`). Every `protobase mobile` run and build copies it into the Android app. Without it, the Android app builds without push and every run says so, naming the path. The server sends through FCM once you set [`PROTOBASE_FCM_SERVICE_ACCOUNT`](../reference/notifications.md#android).
163
+
164
+ The user turns push on from the bell, or from your own button with [`usePushNotifications`](../reference/notifications.md#in-the-browser). Android 13 and later ask for the permission then. Signing out removes the phone's registration.
165
+
166
+ A tap on a notification whose `url` is on your app's server opens that page inside the app. Any other `http` or `https` url opens in the phone's browser, never inside the app, and any other url opens nothing. Turning push on or off changes the app's native code, so it ships in a store release, not a [live update](#7-live-updates).
@@ -105,7 +105,7 @@ export const repairsView = view<typeof repairs>('repairs')
105
105
  }))
106
106
  ```
107
107
 
108
- `title` makes "R-303" the name of a repair everywhere: breadcrumbs, links, the record page. `fields` adjusts how values look: statuses become badges, the estimate gets a euro sign and two decimals, and `customer_id` shows as "Customer" (with the customer's name, since it is a relation). `list` picks the columns, the starting order, and what the search box looks in.
108
+ `title` makes "R-303" the name of a repair everywhere: links, the browser tab, the record page. `fields` adjusts how values look: statuses become badges, the estimate gets a euro sign and two decimals, and `customer_id` shows as "Customer" (with the customer's name, since it is a relation). `list` picks the columns, the starting order, and what the search box looks in.
109
109
 
110
110
  ## 3. Filters
111
111
 
@@ -157,7 +157,7 @@ export default defineConfig({ auth: { mcp: true }, mcpEndpoint: { writes: true }
157
157
 
158
158
  Each write goes through the REST API as the person: their role's access rules, `validate`, write hooks, events and webhooks apply, so the client can do only what the person may do in the app.
159
159
 
160
- Before each write the client asks the person to approve it, through MCP's form elicitation. The approval names the record as the record page's breadcrumb does, by the resource's label, its key and its title, such as `Update Task #42 "Fix the sign-in lockout"?`. An update lists each field it changes by its label, with its value before and after (`Status: In flight -> Done`); a create lists the new record's fields by their labels; a delete says whether the record can be restored, and for a resource without a soft delete says plainly that it cannot be undone. Enum values show by their labels, a [sensitive](data-config.md#sensitive-fields) field's value is hidden, and a value is cut at 200 characters. A record or field the person may not read is named by its key or its name in words, and an update or delete of a record changed since its `etag` is refused before asking. The approval, its button and the refusal for a client that cannot ask are in the person's [language](languages.md): the app's `locale`, or else the one the client's request accepts (`Accept-Language`). Nothing is written until they approve, and declining writes nothing. A client's own setting that always allows a tool is not this approval. An approval holds only for the call it was asked for, with the same arguments, by the same person in the same app, organization and client, and only once, within 10 minutes; any other call is asked again. A client that cannot ask, one without form elicitation or one on the 2025 protocol, gets each write refused with a message saying so.
160
+ Before each write the client asks the person to approve it, through MCP's form elicitation. The approval names the record by the resource's label, its key and its title, such as `Update Task #42 "Fix the sign-in lockout"?`. An update lists each field it changes by its label, with its value before and after (`Status: In flight -> Done`); a create lists the new record's fields by their labels; a delete says whether the record can be restored, and for a resource without a soft delete says plainly that it cannot be undone. Enum values show by their labels, a [sensitive](data-config.md#sensitive-fields) field's value is hidden, and a value is cut at 200 characters. A record or field the person may not read is named by its key or its name in words, and an update or delete of a record changed since its `etag` is refused before asking. The approval, its button and the refusal for a client that cannot ask are in the person's [language](languages.md): the app's `locale`, or else the one the client's request accepts (`Accept-Language`). Nothing is written until they approve, and declining writes nothing. A client's own setting that always allows a tool is not this approval. An approval holds only for the call it was asked for, with the same arguments, by the same person in the same app, organization and client, and only once, within 10 minutes; any other call is asked again. A client that cannot ask, one without form elicitation or one on the 2025 protocol, gets each write refused with a message saying so.
161
161
 
162
162
  <gap>An approval cannot be answered on another server instance or after a restart because a shared approval store is not implemented.</gap> Behind a load balancer, send an MCP client's calls to the same instance.
163
163
 
@@ -7,7 +7,7 @@ Turn on notifications, send them to users or devices, show each signed-in user t
7
7
  ## Turning them on
8
8
 
9
9
  :::caution[Beta]
10
- Push reaches browsers; push on Android and iOS is coming soon.
10
+ Push reaches browsers and the Android app; push on iOS is coming soon.
11
11
  :::
12
12
 
13
13
  Notifications tell a user about something in the app, in a bell in the top bar and as push on their devices. [Send notifications](../guides/push-notifications.md) walks through turning them on and sending the first one. You turn them on in `protobase.config.ts`:
@@ -22,12 +22,12 @@ export default defineConfig({
22
22
 
23
23
  Then run `protobase migration`, which writes the [devices and history tables](#table-names), and the jobs schema that [sending](#sending) runs on, as a migration of the project's own, and apply it with the project's migrations. `protobase dev` and `protobase serve` refuse to start while a table is missing or lacks what notifications need, and name it. Without `notifications` there is none of it: no endpoints, no tables and no migration.
24
24
 
25
- Every signed-in user gets [the bell](#the-bell), and browsers receive push through [Web Push](#web-push); push on Android and iOS is coming soon. `notifications: { ui: false }` keeps only the backend, [without the bell](#without-the-bell).
25
+ Every signed-in user gets [the bell](#the-bell), browsers receive push through [Web Push](#web-push), and the Android app through [FCM](#android); push on iOS is coming soon. `notifications: { ui: false }` keeps only the backend, [without the bell](#without-the-bell).
26
26
 
27
27
  ## Devices
28
28
 
29
29
  :::caution[Beta]
30
- Only browsers receive push yet, through [Web Push](#web-push): push on Android and iOS is coming soon.
30
+ Browsers receive push through [Web Push](#web-push), and the Android app through [FCM](#android): push on iOS is coming soon.
31
31
  :::
32
32
 
33
33
  A device is where a user receives push: a browser's push subscription, or an Android or iOS app's push token. Each signed-in user registers and removes only their own, through the API:
@@ -67,7 +67,7 @@ The path comes from `devicesPath('/api', id)`, and the name of its id parameter
67
67
  ## Sending
68
68
 
69
69
  :::caution[Beta]
70
- Browsers receive push, and Android devices through [FCM](#android) once the mobile app registers them, which is coming soon; push on iOS is coming soon. <gap>A send can reach a device twice, or keep an entry twice in a history store of your own, when a worker stops mid-send because saving the send's progress in the same step as the push is not implemented.</gap>
70
+ Browsers and the Android app receive push; push on iOS is coming soon. <gap>A send can reach a device twice, or keep an entry twice in a history store of your own, when a worker stops mid-send because saving the send's progress in the same step as the push is not implemented.</gap>
71
71
  :::
72
72
 
73
73
  [Send notifications](../guides/push-notifications.md) sends one from a record change, step by step. You send a notification from your server code, such as a job, a hook, an event subscription or an API function, with `sendNotification(db, to, message)` from `@protobase/server`. It is queued as a background job in `db`'s transaction when `db` is one, so it goes out only once your write commits, and nothing goes out when the transaction rolls back. A running job also has it as `sendNotification` in its context, beside `mail`, when the app has `notifications`.
@@ -189,7 +189,7 @@ Each message is encrypted for its browser and signed with the key. It goes only
189
189
 
190
190
  ### In the browser
191
191
 
192
- `usePushNotifications()` from `@protobase/ui` turns push on and off for the signed-in user in this browser, for your own button or menu item. Its `state` tells whether push is `on`, `off`, `blocked` because the user refused notifications in the browser's settings, or `unsupported`, and `loading` until it knows. Hide the button while it is `unsupported`: the browser has no Web Push, the app has no VAPID keys, or it runs in the Android or iOS app.
192
+ `usePushNotifications()` from `@protobase/ui` turns push on and off for the signed-in user in this browser, or in the Android app, for your own button or menu item. Its `state` tells whether push is `on`, `off`, `blocked` because the user refused notifications in the browser's or the phone's settings, or `unsupported`, and `loading` until it knows. Hide the button while it is `unsupported`: the browser has no Web Push, the app has no VAPID keys, the Android app was built without `google-services.json`, or it runs in the iOS app.
193
193
 
194
194
  ```tsx
195
195
  import { Button, usePushNotifications } from '@protobase/ui'
@@ -213,17 +213,17 @@ export const PushButton = () => {
213
213
 
214
214
  ## Android
215
215
 
216
- :::caution[In development]
217
- The mobile app does not register for push on Android yet.
216
+ :::caution[Beta]
217
+ Push on Android is new.
218
218
  :::
219
219
 
220
- Android devices receive push through Firebase Cloud Messaging's HTTP v1 API. You create a service account key in your Firebase project (Project settings, Service accounts, Generate new private key) and set its JSON as `PROTOBASE_FCM_SERVICE_ACCOUNT`. Without it, Android devices are skipped. Setting the mobile app up is coming soon.
220
+ Android devices receive push through Firebase Cloud Messaging's HTTP v1 API. You create a service account key in your Firebase project (Project settings, Service accounts, Generate new private key) and set its JSON as `PROTOBASE_FCM_SERVICE_ACCOUNT`. Without it, Android devices are skipped. `protobase mobile` sets the app up from your `google-services.json`: see [Push notifications in the mobile app guide](../guides/mobile-app.md#9-push-notifications).
221
221
 
222
222
  JSON that is not a service account key, a `project_id` that is not a Google project id, or a `private_key` that is not an RSA key of at least 2048 bits stops startup, naming the variable without its value. The key is a secret: keep it out of client code, `VITE_` variables and the repository. Anyone holding it can push to every Android device of the project.
223
223
 
224
224
  The server signs in as the service account with a token scoped to sending through FCM only, and keeps one token until five minutes before it expires. When no token can be had before the first request, the send fails with nothing pushed and is retried; a token that fails later retries only the devices still waiting for one. Requests go only to Google's token endpoint and to FCM, for the key's own project, never through a redirect; the URLs in the key's JSON are not read. A device is removed only when FCM reports its token unregistered. Any other refusal, such as a key without access to the project, keeps the device and retries it. A device stored with a token that is not an FCM token is `refused`.
225
225
 
226
- A message's title and body are the notification. Its `data` and `url` reach the app as FCM's data, each value a string (other JSON as its text), with `user`, the id of the user the device is registered for, over any `user` given. Its `ttl`, `urgency`, `tag`, `sound` and `badge` set the Android delivery and notification. A message's `platform.fcm` is merged over these, and may set only:
226
+ A message's title and body are the notification. Its `data` and `url` reach the app as FCM's data, the url under `url`, which the app opens on tap; a message whose `data` holds a `url` of its own is refused, each value a string (other JSON as its text), with `user`, the id of the user the device is registered for, over any `user` given. Its `ttl`, `urgency`, `tag`, `sound` and `badge` set the Android delivery and notification. A message's `platform.fcm` is merged over these, and may set only:
227
227
 
228
228
  | Field | |
229
229
  | --- | --- |
@@ -14,7 +14,7 @@ Nothing new is invented for a remote resource. Every page of the admin app is dr
14
14
 
15
15
  1. **The app names its sources.** Its `/api/meta` lists each source the caller may use: where its API is, what it is called, and the resources the app draws from it.
16
16
  2. **The browser reads each source's `/meta` itself,** with the signed-in person's own token, and keeps only the resources the app draws. The source answers as it answers anyone: with the resources the person may see there, each as they may see it, and the view for their role.
17
- 3. **The app merges them into its own.** A remote resource's model, view and permissions sit next to the app's own resources, so every part of the app that reads a resource reads it the same way: the sidebar places it by its view's `nav`, the breadcrumbs name it by its view's names and title, the list page shows its columns, filters and displays.
17
+ 3. **The app merges them into its own.** A remote resource's model, view and permissions sit next to the app's own resources, so every part of the app that reads a resource reads it the same way: the sidebar places it by its view's `nav`, the breadcrumbs name it by its view's names, the list page shows its columns, filters and displays.
18
18
  4. **Every call about a remote resource goes to its source.** The app's client sends each call to the API that serves the resource, with the same token: lists, records, writes, aggregates, uploads. The app's server is not in between and stores nothing of it.
19
19
 
20
20
  So the source decides what a person sees and may do, exactly as in its own admin app, and the app decides where it shows it. The app does not wait for its sources: its own resources show at once, and a source's resources join when its `/meta` has loaded.
@@ -116,7 +116,7 @@ Everything the app draws for a resource of its own, for a remote resource too:
116
116
  | List page | Its columns, sort, filters, search, displays and chart, at `/<resource>`, with every list state in the address. |
117
117
  | Record page | Its sections, related records, sidebar, actions and custom sections, at `/<resource>/<key>`, saved back to the source with its ETag. |
118
118
  | Create form | At `/<resource>/new`, when the person may create there. |
119
- | Breadcrumbs | The sidebar group, the list and the record's title, each a link. |
119
+ | Breadcrumbs | The sidebar group and the list, each a link. |
120
120
  | Global search | Its search fields, when it has them and a sidebar entry. |
121
121
  | Links and actions | Links to its own records and lists; `a.update` and `a.remove` write to the source; handlers run with the source's client (see [Custom components](#custom-components)). |
122
122
  | Files | Uploaded to the source, and downloaded from it. |
@@ -94,7 +94,7 @@ export const channelsView = view<typeof channels>('channels').nav({ recent: { or
94
94
  The entry then works like this:
95
95
 
96
96
  - The label opens the full list, as before; the chevron beside it shows or hides the records. The choice is kept per entry in this browser (`localStorage`), and an entry starts open.
97
- - Each record shows its title (the view's `title`, as in breadcrumbs) and opens its record page. The open record is highlighted.
97
+ - Each record shows its title (the view's `title`, as in its record page's heading) and opens its record page. The open record is highlighted.
98
98
  - "View all" ends the list and opens the full list, like the label.
99
99
  - Only text sidebars (`text-large`, `text-small`, and the phone drawer) show the records; icon sidebars keep a plain entry.
100
100
 
@@ -48,7 +48,7 @@ export const repairsView = view<typeof repairs>('repairs')
48
48
  | Method | |
49
49
  | --- | --- |
50
50
  | `.names({ singular, plural })` | "New repair", "Repairs" in the sidebar, breadcrumbs and browser tabs. Default: the resource name in words. |
51
- | `.title((r) => r.number)` | The field that names a record: in breadcrumbs, browser tabs, the record page's heading, relation links and search results. |
51
+ | `.title((r) => r.number)` | The field that names a record: in browser tabs, the record page's heading, relation links and search results. |
52
52
  | `.titleFrom(rule, (r) => [r.member_ids])` | A title derived in the browser for the person reading it, in place of `.title`, by the function `rule` names in the UI config's `titles`, from the fields picked. See [Titles per reader](#titles-per-reader). |
53
53
  | `.searchResult((r) => ({ title?, subtitle? }))` | A record in the [global search](client.md#global-search): `title` is one field or several joined by spaces (`[r.first_name, r.last_name]`, default: `.title`), `subtitle` the line under it (default: the first search field not in the title), replaced by the search field the text matched when neither line shows it. |
54
54
  | `.list((r, d, c) => ({ columns, sort?, search?, filter?, editable?, displays?, default? }))` | The list's columns in order, fields or [related records](#related-records-in-a-list) (`c.related`); the `filter` it [opens with](#a-filter-the-list-opens-with); its starting `sort` as `[[field, 'asc' \| 'desc'], ...]`, on `.sortable()` fields, else the primary key's order when it is `.sortable()`, else none, which the API orders by the key; the fields the search box suggests, among the resource's `.search` fields, which decide what search matches on the server; the columns [edited in their cell](#editing-in-the-list); other ways to show it, see [List displays](#list-displays). `protobase build` fails on a sort or search field outside those. |
@@ -64,7 +64,7 @@ A browser tab names what it shows, then the app's name ([`name`](config/app.md#n
64
64
 
65
65
  ### Breadcrumbs
66
66
 
67
- The top bar shows where a page is: the sidebar group, the list and the record's title, each a link back. On a phone, a back button before them goes to the one just before the current page.
67
+ The top bar shows where a page is: the sidebar group and the list, each a link back. A record page's trail ends at its list, such as Sales › Orders, and the heading below names the record. On a phone the top bar shows only the current page, with a back button before it to the page above; on a record page that button names the list it goes back to.
68
68
 
69
69
  ### Titles per reader
70
70
 
@@ -85,7 +85,7 @@ export default defineUi({
85
85
  })
86
86
  ```
87
87
 
88
- The derived title names the record wherever `.title` would: the sidebar's [recent records](sidebar.md#recent-records), whose list request reads the picked fields too, the breadcrumb, the record page's heading, the browser tab, the links of a record page's relation fields, related cards, the global search, unless the view's `.searchResult` gives a title, and every relation that points at such a record: a list's relation column and a card's relation field, which read the picked fields of a page's records in one request, the relation picker's options and a relation filter's values. The picker's typed text still matches the resource's search fields, or, without any, the derived titles of the records it loads. The record's key shows while the function returns nothing, such as while the members' names load, and when the reader cannot read a field it picks, or the UI config registers no function of that name. It is presentation only: no field, filter or sort reads it, and the search does not match it. Other members' names come only with organizations; without them, `member` finds no one.
88
+ The derived title names the record wherever `.title` would: the sidebar's [recent records](sidebar.md#recent-records), whose list request reads the picked fields too, the record page's heading, the browser tab, the links of a record page's relation fields, related cards, the global search, unless the view's `.searchResult` gives a title, and every relation that points at such a record: a list's relation column and a card's relation field, which read the picked fields of a page's records in one request, the relation picker's options and a relation filter's values. The picker's typed text still matches the resource's search fields, or, without any, the derived titles of the records it loads. The record's key shows while the function returns nothing, such as while the members' names load, and when the reader cannot read a field it picks, or the UI config registers no function of that name. It is presentation only: no field, filter or sort reads it, and the search does not match it. Other members' names come only with organizations; without them, `member` finds no one.
89
89
 
90
90
  <gap>An export of shown values and a chart grouped by a relation cannot name a record by its derived title because titling them per reader is not implemented.</gap>
91
91
 
@@ -702,7 +702,7 @@ A record address can also carry `version`, an earlier saved version of the recor
702
702
 
703
703
  ### Full-area record pages
704
704
 
705
- `.record({ component })` makes the record page at `/<resource>/<key>` a [custom component](custom-components.md#full-area-record-pages) of the app's own, for a record that is used rather than filled in, such as a chat channel. The component fills the content area, at full width beside the sidebar and down to the bottom bar on a phone, and the page does not scroll, so the component scrolls its own parts, such as messages above a box that stays at the bottom. The sidebar, the top bar with its breadcrumb naming the record, the bottom bar and a right panel stay; the heading, Save, the action rail, the sections, the related records and the Details card are not drawn. A record that does not exist, or that the user may not read, shows the record page's usual notice, and the component is never drawn.
705
+ `.record({ component })` makes the record page at `/<resource>/<key>` a [custom component](custom-components.md#full-area-record-pages) of the app's own, for a record that is used rather than filled in, such as a chat channel. The component fills the content area, at full width beside the sidebar and down to the bottom bar on a phone, and the page does not scroll, so the component scrolls its own parts, such as messages above a box that stays at the bottom. The sidebar, the top bar with its breadcrumb naming the record, since the page has no heading, the bottom bar and a right panel stay; the heading, Save, the action rail, the sections, the related records and the Details card are not drawn. A record that does not exist, or that the user may not read, shows the record page's usual notice, and the component is never drawn.
706
706
 
707
707
  ```ts
708
708
  export const ChannelChat = component('ChannelChat')