@protobase/cli 0.60.1 → 0.61.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.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.60.1";
2
+ var version = "0.61.0";
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.60.1",
3
+ "version": "0.61.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": {
@@ -42,12 +42,12 @@
42
42
  "dependencies": {
43
43
  "@better-auth/core": "^1.7.12",
44
44
  "@hono/node-server": "^2.1.3",
45
- "@protobase/config": "0.60.1",
46
- "@protobase/layout": "0.60.1",
47
- "@protobase/query": "0.60.1",
48
- "@protobase/schema": "0.60.1",
49
- "@protobase/server": "0.60.1",
50
- "@protobase/ui": "0.60.1",
45
+ "@protobase/config": "0.61.0",
46
+ "@protobase/layout": "0.61.0",
47
+ "@protobase/query": "0.61.0",
48
+ "@protobase/schema": "0.61.0",
49
+ "@protobase/server": "0.61.0",
50
+ "@protobase/ui": "0.61.0",
51
51
  "@react-email/render": "^2.1.0",
52
52
  "@scalar/hono-api-reference": "^0.12.10",
53
53
  "@tailwindcss/vite": "^4.3.3",
@@ -25,7 +25,7 @@ Sign-in methods, users, roles, organizations and tokens.
25
25
  - [Staff sign-in](../reference/auth.md#staff-sign-in): The team that runs an app signs in as a person to help them, with a reason and a log entry.
26
26
  - [Roles](../reference/auth.md#roles): A user holds one or more roles and switches between them without signing in again.
27
27
  - [Organizations](../reference/auth.md#organizations): People work in one organization at a time, see only its records, and are invited with their own roles.
28
- - [Status](../reference/status.md) (beta): People set themselves busy or do not disturb, with a text of their own such as "Having lunch" and a time it clears, from the user menu; the people they share an organization with see it beside their name.
28
+ - [Status](../reference/status.md) (beta): People set themselves busy or do not disturb, with a text of their own such as "Having lunch" and a time it clears, from the user menu; the people they share an organization with see it beside their name, with your app's online or away mark on the members page and in the sidebar.
29
29
  - [API tokens](../reference/auth.md#tokens-and-roles): A signed-in session gets short-lived tokens for the API.
30
30
  - [Immediate revocation](../reference/auth.md#when-a-token-stops-working): A ban, removed role or ended session takes effect on the next request.
31
31
  - [Signing key rotation](../reference/auth.md#signing-keys): The keys that sign the tokens are replaced every 30 days on their own, and old ones keep verifying the tokens they signed for a week.
@@ -106,8 +106,20 @@ export default defineUi({ marks: { unread: useUnreadMarks } })
106
106
  | `strong` | The record's title shows bold and in the foreground colour, not muted. |
107
107
  | `count` | A small badge at the end of the row, the pill of the notification bell's count; `99+` above 99, none at 0. |
108
108
  | `label` | Added to the record's name for screen readers and its tooltip, such as "3 mentions". |
109
+ | `person` | The user id of the one person the record stands for, such as the other person in a direct message. The row shows their online or away dot, from the app's [presence](status.md#in-the-app), and their busy or do-not-disturb mark beside its title, and adds them and their status text to its name and tooltip. |
109
110
 
110
- The records keep the group's order. A mark is presentation only: it is no field, filter or sort key, and the server computes nothing for it; what it counts comes from the requests the hook makes as the reader. Icon sidebars show no records, so no marks either. A group whose name no UI config registers, such as a plugin's that is turned off, shows its records unmarked. <gap>A marks hook that throws cannot be confined to its own group because an error boundary around a group's marks is not implemented, so it stops the sidebar as a throwing component would.</gap>
111
+ A direct message's mark names the other person:
112
+
113
+ ```tsx
114
+ const useConversationMarks = () => {
115
+ // conversation_partners: a resource of the project's own, the other person in each of the reader's direct messages
116
+ const partners = useList('conversation_partners', { pageSize: 100 })
117
+ if (partners.isPending) return
118
+ return Object.fromEntries(partners.items.map((row) => [String(row.conversation_id), { person: String(row.user_id) }]))
119
+ }
120
+ ```
121
+
122
+ A row shows one person's presence; a row for a group names no one and shows none. The records keep the group's order. A mark is presentation only: it is no field, filter or sort key, and the server computes nothing for it; what it counts comes from the requests the hook makes as the reader. Icon sidebars show no records, so no marks either. A group whose name no UI config registers, such as a plugin's that is turned off, shows its records unmarked. <gap>A marks hook that throws cannot be confined to its own group because an error boundary around a group's marks is not implemented, so it stops the sidebar as a throwing component would.</gap>
111
123
 
112
124
  ### Checks
113
125
 
@@ -64,19 +64,59 @@ Your own server code asks the same question with `onDoNotDisturb(db, statusNames
64
64
 
65
65
  ## In the app
66
66
 
67
- The organization's members page shows each member's status beside their name. `useMembers()` from `@protobase/ui` gives each member their `status` when they have one, beside their name and photo, and `useStatuses()` the statuses alone. `StatusMark` draws a status beside a name: a mark for busy, one for do not disturb, and the text, in full or, with `textShown="hover"`, on hover. Who is online or away is each app's own, from its [presence](channels.md#presence); pass its mark as `presence`, and `StatusMark` draws it first, so the two sit side by side:
67
+ The members page and the sidebar can show who is online or away beside each person's status. Who is online or away is your app's own, from its [presence](channels.md#presence), and you give it to Protobase once, as `presence` in `protobase.ui.tsx`: a React hook that answers each person's presence, `'online'` or `'away'`, by their user id, and leaves out someone with no page open. Protobase calls it once while the app shows, so it may use your own [channels](channels.md) and live updates, and the marks follow it without a reload; Protobase opens no connection of its own for it, and a channel shares the socket the page already has.
68
68
 
69
69
  ```tsx
70
- import { StatusMark, useMembers } from '@protobase/ui'
70
+ // protobase.ui.tsx
71
+ import { useEffect, useState } from 'react'
72
+ import { defineUi, useClient, type Presence } from '@protobase/ui'
73
+
74
+ // Each page of the app tracks itself on the channel of its workspace's record: online, or away when the tab is hidden.
75
+ const usePeoplePresence = () => {
76
+ const client = useClient()
77
+ const [presence, setPresence] = useState<Record<string, Presence>>()
78
+ useEffect(() => {
79
+ const lobby = client.channel('workspaces', 1)
80
+ const track = () => void lobby.track({ away: document.hidden })
81
+ const stop = lobby.onPresence((entries) => {
82
+ const byUser: Record<string, Presence> = {}
83
+ for (const entry of entries) {
84
+ const user = entry.user === null ? undefined : String(entry.user)
85
+ // Someone with one page in view is online, whatever their other pages say.
86
+ if (user === undefined || byUser[user] === 'online') continue
87
+ byUser[user] = (entry.state as { away: boolean }).away ? 'away' : 'online'
88
+ }
89
+ setPresence(byUser)
90
+ })
91
+ track()
92
+ document.addEventListener('visibilitychange', track)
93
+ return () => {
94
+ document.removeEventListener('visibilitychange', track)
95
+ stop()
96
+ lobby.leave()
97
+ }
98
+ }, [client])
99
+ return presence
100
+ }
101
+
102
+ export default defineUi({ presence: usePeoplePresence })
103
+ ```
104
+
105
+ The organization's members page then shows each member as online or away beside their status, and a sidebar record whose mark names a person, such as a direct message, shows that person's presence and status beside its title, with the status text on hover and in the row's name (see [Marks per reader](sidebar.md#marks-per-reader)). Someone the hook leaves out shows no presence, and without the hook nothing shows but the statuses. <gap>A sidebar row cannot show the presence of several people, such as a group conversation's, because a mark naming more than one person is not implemented.</gap>
106
+
107
+ `useMembers()` from `@protobase/ui` gives each member their `status` when they have one, beside their name and photo, `useStatuses()` the statuses alone, and `usePresence()` the presence your hook gives, by user id. `StatusMark` draws them beside a name: the online or away dot for `presence`, a mark for busy, one for do not disturb, and the text, in full or, with `textShown="hover"`, on hover:
108
+
109
+ ```tsx
110
+ import { StatusMark, useMembers, usePresence } from '@protobase/ui'
71
111
 
72
- export const Person = ({ id, online }: { id: string; online: boolean }) => {
112
+ export const Person = ({ id }: { id: string }) => {
73
113
  const person = useMembers().member(id)
114
+ const presence = usePresence()?.[id]
74
115
  if (!person) return null
75
- const dot = <span role="img" aria-label={online ? 'Online' : 'Away'} className={online ? 'size-2 rounded-full bg-success' : 'size-2 rounded-full bg-muted'} />
76
116
  return (
77
117
  <span className="flex items-center gap-1.5">
78
118
  {person.name}
79
- <StatusMark status={person.status} presence={dot} textShown="hover" />
119
+ <StatusMark status={person.status} presence={presence} textShown="hover" />
80
120
  </span>
81
121
  )
82
122
  }