@protobase/cli 0.123.2 → 0.123.4

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.123.2";
2
+ var version = "0.123.4";
3
3
  //#endregion
4
4
  export { version };
@@ -93,7 +93,7 @@ const migrationParts = (project) => {
93
93
  ...project.realtime?.relay ? [{
94
94
  name: "relay",
95
95
  title: "The trigger that closes a deleted sign-in session's sockets on the realtime relay",
96
- sql: () => relayMigration(project.db, project.auth)
96
+ sql: ({ authWritten }) => relayMigration(project.db, project.auth, authWritten)
97
97
  }] : [],
98
98
  ...sqlSends(project.realtime) ? [{
99
99
  name: "channel_sends",
@@ -24,7 +24,7 @@ const runMigration = async ({ projectDir, dir, auth, database, protobaseVersion,
24
24
  if (database && difference.migration && difference.migration.checks.length > 0) await runPreconditions(database.url, difference.migration.checks);
25
25
  const compared = [];
26
26
  for (const part of database?.parts ?? []) {
27
- const sql = await part.sql();
27
+ const sql = await part.sql({ authWritten: Boolean(difference.migration) });
28
28
  if (sql !== void 0) compared.push({
29
29
  name: part.name,
30
30
  text: section(part.title, sql)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.123.2",
3
+ "version": "0.123.4",
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.123.2",
47
- "@protobase/layout": "0.123.2",
48
- "@protobase/query": "0.123.2",
49
- "@protobase/schema": "0.123.2",
50
- "@protobase/server": "0.123.2",
51
- "@protobase/ui": "0.123.2",
52
- "@protobase/workflows": "0.123.2",
46
+ "@protobase/config": "0.123.4",
47
+ "@protobase/layout": "0.123.4",
48
+ "@protobase/query": "0.123.4",
49
+ "@protobase/schema": "0.123.4",
50
+ "@protobase/server": "0.123.4",
51
+ "@protobase/ui": "0.123.4",
52
+ "@protobase/workflows": "0.123.4",
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",
@@ -19,6 +19,6 @@ The changes of each record, comments on it, and pages that refresh as records ch
19
19
  - [Presence](../reference/channels.md#presence) (beta): Apps see who else has a record open and what each of them tracks, such as online or away, for whoever may read the record.
20
20
  - [Realtime relay](../reference/realtime-relay.md) (in development): Apps hand their realtime connections to a relay, so they and their database can sleep while people stay connected: the app issues connect tickets for signed-in people and visitors, keeps the relay's channel members in step with its members records, tells each channel's members of every change, and closes a session's sockets when it signs out or expires. `protobase dev` runs a relay for the app by itself.
21
21
  - [Relay presence](../reference/realtime-relay.md#presence) (in development): The relay reports who comes online, goes away and goes offline; the app keeps it in a resource of its own, raises that resource's events, so workflows can act when someone goes offline, and tells the people who share a conversation with them.
22
- - [Relay in pages](../reference/realtime-relay.md#pages) (in development): Pages follow the relay on one socket: open views stay current from its notices and read again once after a reconnect, conversations show who types, sidebar groups say "typing…" and count unread messages without reading per message, all by configuration; `client.relay` gives the same from code.
22
+ - [Relay in pages](../reference/realtime-relay.md#pages) (in development): Pages follow the relay on one socket: open views stay current from its notices and read again once after a reconnect, conversations show who types, sidebar groups say "typing…" and count unread messages without reading per message, also of a conversation the person was just added to, all by configuration; `client.relay` gives the same from code.
23
23
  - [Relay client events](../reference/realtime-relay.md#client-events) (in development): Each channel resource declares in the config the events its clients may send each other, such as typing, with a schema, a size and a rate.
24
24
  - [Broadcasts](../reference/channels.md#broadcasts) (beta): Apps on a record send each other short-lived events, such as typing, which are never stored, as JSON or as bytes, such as a chunk of audio or a drawing stroke; the app's own code sends them too, from an API function, over HTTP or [from SQL](../reference/channels.md#from-sql) with `channels.send()`.
@@ -45,7 +45,7 @@ export default defineConfig(({ env }) => ({
45
45
  | `channels.<resource>.events` | The [events](#client-events) the channel's members may send each other, by name, each with its payload's `schema`, its `maxBytes` and the rate one person may send it at, `perSecond` in bursts of `burst`. |
46
46
  | `presence` | Turns on [presence](#presence): the app's own resource it is kept in, its fields of the person's user id (`user`), the status (`status`) and when it began (`at`), and the bearer token of the relay's reports (`key`), at least 32 characters. |
47
47
 
48
- The relay needs the app's own [sign-in](auth.md), whose sessions its tickets name, with its store in the app's own database, as the `auth` config puts it: an auth store in another database is refused. A members resource's changes must be captured, so declare [`.live()`](live.md) on it; the relay hears of the changes of every resource whose changes are captured, such as a live one, that is a channel resource or has a relation field to one. [`protobase migration`](cli.md#migration) writes the trigger that ends a deleted session's sockets, in the `relay` schema, and the server checks it at start.
48
+ The relay needs the app's own [sign-in](auth.md), whose sessions its tickets name, with its store in the app's own database, as the `auth` config puts it: an auth store in another database is refused. A members resource's changes must be captured, so declare [`.live()`](live.md) on it; the relay hears of the changes of every resource whose changes are captured, such as a live one, that is a channel resource or has a relation field to one. [`protobase migration`](cli.md#migration) writes the trigger that ends a deleted session's sockets, in the `relay` schema, after the auth store's steps when the same file writes them, so a new app's first migration sets up both; the server checks it at start.
49
49
 
50
50
  [`protobase relay app`](cli.md#relay-app) prints the app's entry for the relay's apps file, from this config and the app's `url`.
51
51
 
@@ -79,7 +79,7 @@ The [dispatch](events.md) that turns each transaction's changes into events also
79
79
 
80
80
  `kind` is `create`, `update`, `delete` or `undelete`; `mentions` is there with `mentions` set. A notice tells clients what changed, so they read only the records they show. On a channel with members it reaches its members as the database holds them at dispatch, and a person who joined or left with that change; on an open channel, everyone joined to it, while the anonymous role reads its record as it stands at dispatch. The relay sends a notice once, however often the job sends it again.
81
81
 
82
- A members record that is created or undeleted adds its person to the channel on the sockets they have open, before its notice, and one that is deleted or soft-deleted takes them out after it: they can join, or are closed out, without connecting again. Commands go in commit order, one job at a time; while the relay is down, they wait and try again, once a minute at most. A command the relay refuses, such as one over its size limit, goes to the app's error reporter and is passed over.
82
+ A members record that is created or undeleted adds its person to the channel on the sockets they have open, before its notice, and one that is deleted or soft-deleted takes them out after it: they can join, or are closed out, without connecting again. The person added, and no one else, also hears a `joined` event on `people` that names the channel, `{ "channel": "conversations/7" }`, so their pages join it. Commands go in commit order, one job at a time; while the relay is down, they wait and try again, once a minute at most. A command the relay refuses, such as one over its size limit, goes to the app's error reporter and is passed over.
83
83
 
84
84
  Once an open channel's record stops being public, its notices stop, and a new ticket refuses it. <gap>Sockets that joined an open channel stay joined after its record stops being public, hearing nothing of it, until they reconnect, because closing a channel on every socket is not implemented.</gap>
85
85
 
@@ -140,7 +140,7 @@ A conversation page with `typing` declares the event on its resource's channels:
140
140
 
141
141
  With the relay, a conversation page's `typing` needs its resource among `channels`: the server refuses to start otherwise.
142
142
 
143
- <gap>A page does not hear of a channel the person joined after it connected, such as a new direct message, until it opens that conversation or connects again, because telling a person's sockets of a new channel is not implemented.</gap> <gap>An unread count also counts the reader's own messages sent from another device or tab, until they open the conversation, because notices do not name who made the change.</gap>
143
+ A page joins a channel the person is added to while it is open, such as a new direct message, as it hears `joined`, and reads again what it shows once, so a sidebar group lists the conversation with who types and its unread count at once. <gap>An unread count also counts the reader's own messages sent from another device or tab, until they open the conversation, because notices do not name who made the change.</gap>
144
144
 
145
145
  ### From code
146
146
 
@@ -152,6 +152,7 @@ const stop = client.relay.follow({
152
152
  onEvent: (event) => {}, // { event, payload, from: { user, connection }, at, channel } or, direct, { ..., to }
153
153
  onResync: () => {}, // connected again after a drop: read again what is shown
154
154
  onStatus: (status) => {}, // 'connecting', 'open' or 'ended'
155
+ onJoined: (channel) => {}, // joined a channel the person was added to: read again what is shown
155
156
  })
156
157
  await client.relay.send('conversations/7', 'typing', { typing: true })
157
158
  await client.relay.direct('u2', 'ring', { call: 12 })
@@ -161,7 +162,7 @@ client.relay.presence('away')
161
162
 
162
163
  | | |
163
164
  | --- | --- |
164
- | `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 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`). |
165
+ | `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`). |
165
166
  | `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`. |
166
167
  | `direct(to, event, payload)` | Sends a declared direct event to every device of a person who shares a channel with the sender. |
167
168
  | `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. |