@protobase/server 0.123.2 → 0.123.3

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/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.123.2";
2
+ var version = "0.123.3";
3
3
  //#endregion
4
4
  export { version };
@@ -1,6 +1,9 @@
1
+ import { peopleChannel } from "./presence-commands.js";
1
2
  //#region src/relay/change-commands.ts
2
3
  /** The event every notice of a change is published as. */
3
4
  const changeEvent = "change";
5
+ /** The event that tells a person on `people` of a channel they were added to, so their open pages join it. */
6
+ const joinedEvent = "joined";
4
7
  /** A channel by name: `<resource>/<key>`, as the record channels name it too. */
5
8
  const channelName = (resource, key) => `${resource}/${String(key)}`;
6
9
  const present = (value) => value !== null && value !== void 0;
@@ -60,22 +63,30 @@ const notice = (models, change, channel, members, moved) => {
60
63
  }
61
64
  };
62
65
  };
66
+ const joinedCommand = (sequence, add) => ({
67
+ kind: "publish",
68
+ id: `${sequence}:${add.channel}:${joinedEvent}`,
69
+ channel: peopleChannel,
70
+ users: add.users,
71
+ event: joinedEvent,
72
+ payload: { channel: add.channel }
73
+ });
63
74
  const reaches = (command, open) => command.users === void 0 ? open.has(command.channel) : command.users.length > 0;
64
75
  /**
65
76
  * The relay's commands for a dispatched batch, in commit order: for each change, a person who joins a channel joins it
66
- * first, then each channel the record was or is on hears one notice, then a person who left it leaves. A channel with
67
- * members hears it only through its members as the app's database has them (`members`), and the person who joined or
68
- * left; an open one through everyone joined to it, and only while its record is public (`open`), so sockets that joined
77
+ * first and hears `joined` of it on `people`, then each channel the record was or is on hears one notice, then a person
78
+ * who left it leaves. A channel with members hears it only through its members as the app's database has them
79
+ * (`members`), and the person who joined or left; an open one through everyone joined to it, and only while its record is public (`open`), so sockets that joined
69
80
  * it before hear nothing once it is not. A notice of a channel with no one to reach is left out.
70
81
  */
71
82
  const changeCommands = (models, changes, members, open) => changes.flatMap((change) => {
72
83
  const moved = membersCommands(models, change);
73
84
  const notices = noticedChannels(models, change).map((channel) => notice(models, change, channel, members, moved)).filter((command) => reaches(command, open));
74
85
  return [
75
- ...moved.filter((command) => command.kind === "add"),
86
+ ...moved.filter((command) => command.kind === "add").flatMap((add) => [add, joinedCommand(change.sequence, add)]),
76
87
  ...notices,
77
88
  ...moved.filter((command) => command.kind === "remove")
78
89
  ];
79
90
  });
80
91
  //#endregion
81
- export { audienceChannels, changeCommands, changeEvent, channelName, noticedChannels, openChannels };
92
+ export { audienceChannels, changeCommands, changeEvent, channelName, joinedEvent, noticedChannels, openChannels };
@@ -2,9 +2,9 @@ import { runningJobs } from "../jobs/current.js";
2
2
  import { dispatchJobName } from "../changes/capture-sql.js";
3
3
  import { anonymousSession } from "../anonymous.js";
4
4
  import { readableKeys } from "../channels/records-readable.js";
5
+ import { presenceCommands, presencePeople } from "./presence-commands.js";
5
6
  import { audienceChannels, changeCommands, openChannels } from "./change-commands.js";
6
7
  import { channelMembers, coMembers } from "./members-sql.js";
7
- import { presenceCommands, presencePeople } from "./presence-commands.js";
8
8
  import { presenceRoutes } from "./presence-route.js";
9
9
  import { presenceWriter } from "./presence-sql.js";
10
10
  import { relayClient } from "./relay-commands.js";
@@ -3,8 +3,8 @@ import { channelRecord } from "../channels/channel-name.js";
3
3
  import { recordReadable } from "../channels/record-readable.js";
4
4
  import { anonymousSession } from "../anonymous.js";
5
5
  import { jsonBody, jsonOnly } from "../notifications/history-request.js";
6
- import { memberships } from "./members-sql.js";
7
6
  import { peopleChannel } from "./presence-commands.js";
7
+ import { memberships } from "./members-sql.js";
8
8
  import { signTicket } from "./ticket.js";
9
9
  import { Hono } from "hono";
10
10
  import { bodyLimit } from "hono/body-limit";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/server",
3
- "version": "0.123.2",
3
+ "version": "0.123.3",
4
4
  "description": "The Protobase REST API as a Hono app, with Better Auth sign-in.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -44,11 +44,11 @@
44
44
  "@better-auth/sso": "^1.7.12",
45
45
  "@livekit/protocol": "1.53.1",
46
46
  "@modelcontextprotocol/server": "^2.3.1",
47
- "@protobase/layout": "0.123.2",
48
- "@protobase/query": "0.123.2",
49
- "@protobase/schema": "0.123.2",
50
- "@protobase/workflow-plugins": "0.123.2",
51
- "@protobase/workflows": "0.123.2",
47
+ "@protobase/layout": "0.123.3",
48
+ "@protobase/query": "0.123.3",
49
+ "@protobase/schema": "0.123.3",
50
+ "@protobase/workflow-plugins": "0.123.3",
51
+ "@protobase/workflows": "0.123.3",
52
52
  "@react-email/render": "^2.1.0",
53
53
  "@react-pdf/primitives": "^4.4.0",
54
54
  "@react-pdf/renderer": "^4.9.0",