@protobase/cli 0.75.1 → 0.75.2

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.75.1";
2
+ var version = "0.75.2";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.75.1",
3
+ "version": "0.75.2",
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.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",
46
+ "@protobase/config": "0.75.2",
47
+ "@protobase/layout": "0.75.2",
48
+ "@protobase/query": "0.75.2",
49
+ "@protobase/schema": "0.75.2",
50
+ "@protobase/server": "0.75.2",
51
+ "@protobase/ui": "0.75.2",
52
+ "@protobase/workflows": "0.75.2",
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",
@@ -12,6 +12,6 @@ A bell in the top bar and push to browsers and phones, for what your app tells i
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
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
- - Push on iOS (coming soon): Notifications reach the iOS build of the app on a user's iPhones and iPads.
15
+ - [Push on iOS](../reference/notifications.md#ios) (in development): The mobile app receives notifications on iPhone and iPad through the Apple Push Notification service, set up by `protobase mobile`.
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.
@@ -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 and the Android app; push on iOS is coming soon.
10
+ Push reaches browsers and the Android app. On iPhone and iPad the server delivers through [APNs](#ios), but the mobile app does not register for push yet.
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), 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).
25
+ Every signed-in user gets [the bell](#the-bell), browsers receive push through [Web Push](#web-push), the Android app through [FCM](#android) and iOS devices through [APNs](#ios). `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
- Browsers receive push through [Web Push](#web-push), and the Android app through [FCM](#android): push on iOS is coming soon.
30
+ Browsers receive push through [Web Push](#web-push), and the Android app through [FCM](#android). The server delivers to iOS devices through [APNs](#ios), but the mobile app does not register for push on iOS yet.
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 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>
70
+ Browsers and the Android app receive push, and iOS devices through [APNs](#ios) once the mobile app registers them, which 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`.
@@ -211,6 +211,26 @@ export const PushButton = () => {
211
211
 
212
212
  `protobase serve` and `protobase dev` both serve the service worker that shows notifications, `protobase dev` only when the app has `notifications`.
213
213
 
214
+ ## iOS
215
+
216
+ :::caution[In development]
217
+ The mobile app does not register for push on iOS yet.
218
+ :::
219
+
220
+ iOS devices receive push through the Apple Push Notification service (APNs), with token authentication. You create an APNs key in your Apple developer account, under Certificates, Identifiers & Profiles, Keys, and set it in three environment variables:
221
+
222
+ | Variable | |
223
+ | --- | --- |
224
+ | `PROTOBASE_APNS_KEY` | the text of the `.p8` file you download, from `-----BEGIN PRIVATE KEY-----` to `-----END PRIVATE KEY-----` |
225
+ | `PROTOBASE_APNS_KEY_ID` | the key's id, ten letters and digits |
226
+ | `PROTOBASE_APNS_TEAM_ID` | your team's id, ten letters and digits |
227
+
228
+ Without them APNs is off and iOS devices are skipped. One or two of them set, a blank one, a key that is no APNs key or an id that is not ten letters and digits stops startup, naming the variable without its value, and so do the three set in an app without a [`mobile`](../guides/mobile-app.md) section. The key is a secret: keep it out of client code, `VITE_` variables and the repository. Anyone holding it can push to every iOS device of your apps.
229
+
230
+ The topic of every notification is the mobile app's `appId`. Each device goes to the environment it was registered with: development builds to the APNs sandbox, App Store and TestFlight builds to production. A device whose token is not lowercase hex, whose environment is neither `sandbox` nor `production`, or that was registered for another app id is `refused`.
231
+
232
+ The notification's title and body are its alert, with its `badge` and `sound`; the JSON also holds `url`, `data` and `user`, the id of the user the device is registered for. `urgency` sets the priority (`very-low` and `low` wait until the device saves power less), `ttl` how long APNs keeps it for a device that is offline, 28 days without one, and `tag` the collapse id. A message's `platform.apns` is merged into the JSON, such as `{ aps: { 'thread-id': 'chat' } }`, never into the request's headers; a `url` in it is checked as the message's is, and the JSON holds at most 4096 bytes. APNs answering that the device is unregistered, or that its token is bad, removes the device; any other refusal, such as a wrong topic or key, is retried and then fails the send, so a mistake in the configuration removes no device.
233
+
214
234
  ## Android
215
235
 
216
236
  :::caution[Beta]
@@ -288,7 +308,7 @@ A notification is `{ id, userId, title, body, url, data, createdAt, readAt }`, a
288
308
 
289
309
  ### Senders
290
310
 
291
- A sender delivers notifications to the devices of the kinds it names, through their push service. Web Push and FCM are built in; your own senders, such as from a package, are the default export of `notifications/senders.ts`, an array, and they replace the built-in ones, at most one for each kind. To keep Web Push beside them, list it too: `webPushSender(readVapidSettings(process.env)!)` from `@protobase/server` is the built-in sender, and `readVapidSettings` reads the [VAPID variables](#web-push), `undefined` when none is set:
311
+ A sender delivers notifications to the devices of the kinds it names, through their push service. Web Push, APNs and FCM are built in; your own senders, such as from a package, are the default export of `notifications/senders.ts`, an array, and they replace the built-in ones, at most one for each kind. To keep a built-in one beside them, list it too: `webPushSender(readVapidSettings(process.env)!)` from `@protobase/server` is the built-in Web Push sender, and `readVapidSettings` reads the [VAPID variables](#web-push), `undefined` when none is set; `apnsSender(readApnsSettings(process.env)!, { appId })` is the built-in APNs sender, with the mobile app's `appId`, and `readApnsSettings` reads the [APNs variables](#ios) the same way:
292
312
 
293
313
  ```ts
294
314
  // notifications/senders.ts