@protobase/cli 0.133.12 → 0.134.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/package.js +1 -1
- package/dist/dev/realtime-release.js +6 -6
- package/package.json +8 -8
- package/skills/protobase/references/features/build-and-run.md +1 -1
- package/skills/protobase/references/features/history-comments-and-live-updates.md +1 -1
- package/skills/protobase/references/guides/deploy.md +2 -2
- package/skills/protobase/references/reference/live.md +14 -4
- package/skills/protobase/references/reference/realtime-relay.md +2 -2
package/dist/cli/package.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
//#region src/dev/realtime-release.json
|
|
2
2
|
var realtime_release_default = {
|
|
3
|
-
version: "0.
|
|
3
|
+
version: "0.2.0",
|
|
4
4
|
sha256: {
|
|
5
|
-
"protobase-realtime-linux-amd64": "
|
|
6
|
-
"protobase-realtime-linux-arm64": "
|
|
7
|
-
"protobase-realtime-darwin-amd64": "
|
|
8
|
-
"protobase-realtime-darwin-arm64": "
|
|
9
|
-
"protobase-realtime-windows-amd64.exe": "
|
|
5
|
+
"protobase-realtime-linux-amd64": "df30c0e6600744f36d5a6f5ffc56a68318a2fe7eb53dc8bcb86a47fc83430fc2",
|
|
6
|
+
"protobase-realtime-linux-arm64": "6d7b27f49ede3086a0f1077b0ce21c14e5c9fe7182427ef607fe592b092baab0",
|
|
7
|
+
"protobase-realtime-darwin-amd64": "43f892cd10ec2873c98448cc4bdfca28cf24d7d84cd9a023750094eb2d12e60b",
|
|
8
|
+
"protobase-realtime-darwin-arm64": "8ccca3f8724247da157bc1f951502611d6a290d29f02902d86c2c54771df97ef",
|
|
9
|
+
"protobase-realtime-windows-amd64.exe": "c1dd4ffba08b8fd3db27a35e652c0a5650f07e48a218cbeae1472f6db7e7e137"
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
12
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.134.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": {
|
|
@@ -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.
|
|
47
|
-
"@protobase/layout": "0.
|
|
48
|
-
"@protobase/query": "0.
|
|
49
|
-
"@protobase/schema": "0.
|
|
50
|
-
"@protobase/server": "0.
|
|
51
|
-
"@protobase/ui": "0.
|
|
52
|
-
"@protobase/workflows": "0.
|
|
46
|
+
"@protobase/config": "0.134.0",
|
|
47
|
+
"@protobase/layout": "0.134.0",
|
|
48
|
+
"@protobase/query": "0.134.0",
|
|
49
|
+
"@protobase/schema": "0.134.0",
|
|
50
|
+
"@protobase/server": "0.134.0",
|
|
51
|
+
"@protobase/ui": "0.134.0",
|
|
52
|
+
"@protobase/workflows": "0.134.0",
|
|
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",
|
|
@@ -32,7 +32,7 @@ Develop, build and run an app, on servers, in containers and on phones.
|
|
|
32
32
|
- [Self-hosted image](../guides/deploy.md#a-self-hosted-image): One image with the app inside that serves, migrates and creates the first admin.
|
|
33
33
|
- [Protobase Cloud deploys](../guides/deploy.md#protobase-cloud): A push to the app's GitHub branch builds it, migrates and checks its database in one transaction, and switches to the new version once it answers its health check.
|
|
34
34
|
- [Deploy checks in CI](../guides/deploy.md#check-a-change-before-it-merges): One step in an app's GitHub workflow runs the checks a Protobase Cloud deploy runs, the server's startup checks included, on a fresh Postgres of its own, so a change that would not deploy or start fails before it merges.
|
|
35
|
-
- [The version before in CI](../guides/deploy.md#test-the-version-that-serves-on-the-new-schema) (
|
|
35
|
+
- [The version before in CI](../guides/deploy.md#test-the-version-that-serves-on-the-new-schema) (coming soon): A workflow to copy into an app runs the tests of the version that serves now on a database with a branch's migrations applied, so a migration that takes what that version reads fails before it deploys.
|
|
36
36
|
- [Mobile apps](../guides/mobile-app.md) (beta): Runs an app on iOS and Android, also on your own iPhone, with sign-in, and builds signed store releases from a section in its config. Your app shows its own home-screen icon on iOS and Android, generated from one image you name in your config. It can open on a splash screen of its own, an image on a colour, in light and dark mode.
|
|
37
37
|
- [Files from the phone](../guides/mobile-app.md#files-from-the-phone) (beta): In the iOS and Android app, Import and file fields open the phone's file picker, offering Excel, CSV and JSON files from the device and its cloud drives.
|
|
38
38
|
- [Mobile releases](../reference/cli.md#mobile-releases) (in development): The server offers the mobile app a newer copy of its files, signed, and any host that serves bundles can offer the same from the bundle's files without running its config.
|
|
@@ -13,7 +13,7 @@ The changes of each record, comments on it, and pages that refresh as records ch
|
|
|
13
13
|
- [Mentions](../reference/comments.md#mentions): Mentioning a colleague in a comment sends them an email with a link to the record.
|
|
14
14
|
- [Comment moderation](../reference/comments.md#moderation): Admins find and delete comments across the app.
|
|
15
15
|
- [Live updates](../reference/live.md#what-a-page-hears): Open lists and record pages refresh within seconds when a record changes, including changes made outside the API.
|
|
16
|
-
- [Live tokens](../reference/live.md#live-tokens) (in development): A list or record read asked for with `Prefer: live` also returns an encrypted token that holds what the reader read and may read, with the read's snapshot, bound to their session.
|
|
16
|
+
- [Live tokens](../reference/live.md#live-tokens) (in development): A list or record read asked for with `Prefer: live` also returns an encrypted token that holds what the reader read and may read, with the read's snapshot, bound to their session. In an app with the relay, pages subscribe with it on the relay's one socket and poll where the relay cannot keep a resource live.
|
|
17
17
|
- [Refreshing access](../reference/live.md#refreshing-access) (in development): An API function tells a person's open pages to read again once their access changed, so they get new tokens.
|
|
18
18
|
- [Live views](../reference/live.md#resources-backed-by-a-view) (experimental): A resource backed by a view updates live when the tables it reads change.
|
|
19
19
|
- [Change stream](../reference/live.md#the-stream): Apps follow record changes over a stream that catches up after a reconnect.
|
|
@@ -50,8 +50,8 @@ It refuses as well on a database ahead of it by a migration that is not additive
|
|
|
50
50
|
|
|
51
51
|
### Test the version that serves on the new schema
|
|
52
52
|
|
|
53
|
-
:::caution[
|
|
54
|
-
<gap>The workflow cannot find the version that serves by itself because recording the app's deployed release is not implemented.</gap>
|
|
53
|
+
:::caution[Coming soon]
|
|
54
|
+
<gap>An app cannot take up this workflow as a file because shipping it in an example or a Protobase file, tested, is not implemented.</gap> <gap>The workflow cannot find the version that serves by itself because recording the app's deployed release is not implemented.</gap>
|
|
55
55
|
:::
|
|
56
56
|
|
|
57
57
|
While a deploy migrates, the version that serves now keeps running on the new schema until the new one takes over. This workflow, as `.github/workflows/older-code.yml`, applies a branch's migrations to an empty Postgres 18 and runs the tests of the version that serves now, checked out with its own packages, against that database through `DATABASE_URL`. A failing test names what the version before needs and the branch's migrations take, such as a column they drop. It checks what the app's tests read from the database, so it proves as much as those tests open. Run it from the Actions tab, giving the tag, branch or commit that serves; add `pull_request:` under `on:` to run it on every pull request, against the branch it merges into. A migration marked `-- protobase:breaks-older-code` is expected to fail it, since the version before refuses to start on it, but it does so only through a test that starts that version's server or reads what the migration changed: tests that do neither still pass.
|
|
@@ -33,7 +33,7 @@ It is live data, not multiplayer editing: two people editing the same record sti
|
|
|
33
33
|
|
|
34
34
|
## The stream
|
|
35
35
|
|
|
36
|
-
`GET /api/live` answers a `text/event-stream` to anyone who may read a live resource, a visitor of the anonymous role too. Each event's data is JSON with a `cursor`:
|
|
36
|
+
An app with the [relay](realtime-relay.md) serves no stream: its pages hear the same [over the relay](#over-the-relay). `GET /api/live` answers a `text/event-stream` to anyone who may read a live resource, a visitor of the anonymous role too. Each event's data is JSON with a `cursor`:
|
|
37
37
|
|
|
38
38
|
| `type` | |
|
|
39
39
|
| --- | --- |
|
|
@@ -47,7 +47,7 @@ Connecting again with `?after=<cursor>` catches up on what was missed while disc
|
|
|
47
47
|
## Live tokens
|
|
48
48
|
|
|
49
49
|
:::caution[In development]
|
|
50
|
-
|
|
50
|
+
Live tokens and the pages that subscribe with them over the relay are in development.
|
|
51
51
|
:::
|
|
52
52
|
|
|
53
53
|
A list or record read of a live resource gives a live token on request: `GET /api/v1/<resource>`, `GET /api/v1/<resource>/<key>`, the list under a record and `:search` take RFC 7240 `Prefer: live`, or `?live=1` where a page cannot set headers. The answer then has `Preference-Applied: live` and the token in `Protobase-Live`. Without the request the server resolves and encrypts nothing. These reads answer `Vary: Prefer`, so a cache keeps the two answers apart, and the API's CORS allows `Prefer` and exposes `Protobase-Live` and `Preference-Applied`.
|
|
@@ -74,10 +74,20 @@ The server gives no token, and no `Preference-Applied`, when it cannot write the
|
|
|
74
74
|
### Refreshing access
|
|
75
75
|
|
|
76
76
|
:::caution[In development]
|
|
77
|
-
Pages read again on a refresh
|
|
77
|
+
Pages read again on a refresh. Only pages of an app with the relay join with the new tokens; under `protobase dev`, and in an app without the relay, nothing takes them yet.
|
|
78
78
|
:::
|
|
79
79
|
|
|
80
|
-
`live.refresh({ user })`, on the context of an [API function](../guides/api-functions.md), also one served for supabase-js, and of a function a webhook subscription calls, tells the open pages of the user with that id to read everything they show again, which gives them new tokens for their access as it is now. Call it once a change of their roles or memberships has committed. It writes a notice in its own transaction, so a page that reconnects with `?after=` still gets it. In an app without a live resource or calls it does nothing.
|
|
80
|
+
`live.refresh({ user })`, on the context of an [API function](../guides/api-functions.md), also one served for supabase-js, and of a function a webhook subscription calls, tells the open pages of the user with that id to read everything they show again, which gives them new tokens for their access as it is now. Call it once a change of their roles or memberships has committed. It writes a notice in its own transaction, so a page that reconnects with `?after=` still gets it; with the relay, it publishes `refresh` to the user on the relay's `people` channel, and the page also reads again each time its socket connects again. In an app without a live resource or calls it does nothing.
|
|
81
|
+
|
|
82
|
+
### Over the relay
|
|
83
|
+
|
|
84
|
+
In an app with the relay, each page follows its live resources on the relay's one socket, with the socket its other relay features use. [`client.relay.live({ resources, polled?, onChanges, onResync })`](client.md) of `@protobase/client` does the same from code, sharing one socket however many callers follow it. For each resource it reads a token of every record the caller may read, `GET /api/v1/<resource>?limit=1` with `Prefer: live`, and joins the relay's live query `live:<resource>` with it. It then hears the changes as `onChanges` does above, and reads the resource again once, since what the page read came before the token.
|
|
85
|
+
|
|
86
|
+
- Each change carries a cursor. When the token expires, or the socket connects again, it joins with a fresh token after the last cursor, so nothing in between is missed.
|
|
87
|
+
- When the relay's changes service no longer has every change since the cursor, the live query starts again from a new read, and the resource is read again.
|
|
88
|
+
- The relay's `people` channel carries `refresh`, which reads everything again with new tokens, and `rings`, for the calls that ring the person.
|
|
89
|
+
|
|
90
|
+
A resource the relay cannot keep live is read again every 30 seconds instead, and whenever the window gets the focus again, as every query is. That happens when the read gives no token, when the relay has no changes service or lost it, and while the socket is down. Polling stops at the resource's next change. A token read that got no answer is tried again at each poll, until the join succeeds. A resource live from others, given in `polled`, is always polled this way. <gap>A resource live from others (`.live({ reads })`) cannot update at once over the relay because live queries of the resources it reads are not implemented.</gap> <gap>Pages under `protobase dev` cannot take live updates over its relay, and poll instead, because running a change stream for that relay is not implemented.</gap>
|
|
81
91
|
|
|
82
92
|
## Resources backed by a view
|
|
83
93
|
|
|
@@ -161,7 +161,7 @@ An event's name is 1 to 64 bytes and none of `heartbeat`, `interest`, `presence`
|
|
|
161
161
|
|
|
162
162
|
With `realtime.relay`, the admin app follows the relay for someone signed in, on one socket per page, and `/meta` names the resources whose changes the relay notices:
|
|
163
163
|
|
|
164
|
-
- **Live updates:** the lists, records and counts of those resources are read again as the relay notices their changes, new, edited and deleted records alike,
|
|
164
|
+
- **Live updates:** the lists, records and counts of those resources are read again as the relay notices their changes, new, edited and deleted records alike, and the other `.live()` resources over [live queries](live.md#over-the-relay) on the same socket: an app with the relay serves no `/api/live`. While a [conversation page](ui-config.md#conversation-pages) is open, only its own channel's notices read it again; the notices of other channels only move the [unread marks](sidebar.md#typing-and-unread-from-the-relay). After the socket was down, everything shown is read again once.
|
|
165
165
|
- **Typing:** a conversation page with `typing` says who else types, above its box and in a thread's box, and tells the others while the reader types, as `typing` events on the record's relay channel. Without the relay, it goes over the record's own [channel](channels.md) instead. A sidebar group with [`typing`](sidebar.md#typing-and-unread-from-the-relay) says "typing…" beside a record someone types in, wherever the reader is.
|
|
166
166
|
- **Unread:** a sidebar group with [`unread`](sidebar.md#typing-and-unread-from-the-relay) counts each conversation's unread messages once, then adds the relay's notices without reading.
|
|
167
167
|
- **Presence:** the page tells the relay the person is away while it is hidden and online once it shows; a page that shows again, or a device back online, connects again at once. With [presence](#presence), `/meta` names its resource and fields, never its key, and the sidebar's person marks, the members page and a conversation's members title show who is online, away or offline: the page reads the records of the people it shows, up to 100 in one request, those it shows later as they appear, everyone shown again after the socket was down, and applies each `presence_changed` as it comes, keeping a status only over one that began earlier. The `presence_changed` events reach everyone who shares a channel with the person, whatever their role reads, but the reads go through the reader's role: someone whose record it may not read shows no presence until their next change comes, so grant `presences.read` to the people who see each other. An app's own [`presence` hook](status.md#in-the-app) goes over it.
|
|
@@ -192,7 +192,7 @@ client.relay.presence('away')
|
|
|
192
192
|
|
|
193
193
|
| | |
|
|
194
194
|
| --- | --- |
|
|
195
|
-
| `follow(handlers)` | Hears every notice and event until the returned function is called. The first follower opens the socket and the last closes it. The socket connects with a fresh ticket each time, joins the relay's own topic and every channel the ticket lists, and each channel a `joined` event names, telling `onJoined` once it joined it, and connects again after a pause that grows with each failure, up to 30 seconds; an app that refuses a ticket with a client error, such as for a session that ended, ends it (`ended`), as does a relay that closes it with code 1000. It tries a WebSocket first: when that fails before it opened, or does not open within 2.5 seconds, as on a network that blocks WebSockets, and none opened before, it connects over the relay's server-sent events at once instead, and stays on them until the page loads again.
|
|
195
|
+
| `follow(handlers)` | Hears every notice and event until the returned function is called. The first follower opens the socket and the last closes it. The socket connects with a fresh ticket each time, joins the relay's own topic and every channel the ticket lists, and each channel a `joined` event names, telling `onJoined` once it joined it, and connects again after a pause that grows with each failure, up to 30 seconds; an app that refuses a ticket with a client error, such as for a session that ended, ends it (`ended`), as does a relay that closes it with code 1000. It tries a WebSocket first: when that fails before it opened, or does not open within 2.5 seconds, as on a network that blocks WebSockets, and none opened before, it connects over the relay's server-sent events at once instead, and stays on them until the page loads again. |
|
|
196
196
|
| `send(channel, event, payload)` | Sends a declared event to the channel's other sockets. Rejects with a `RelayRefusal` and the relay's reason, such as `rate_limited` or `event_not_allowed`, or `not_joined`. |
|
|
197
197
|
| `direct(to, event, payload)` | Sends a declared direct event to every device of a person who shares a channel with the sender. |
|
|
198
198
|
| `join(channel)` | Joins a channel the ticket did not list, such as one the person joined since, and again after each reconnect until the returned function is called. The socket stays in the channel until it next connects. |
|