@protobase/cli 0.53.4 → 0.53.5
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/package.json +7 -7
- package/skills/protobase/references/features/data-model.md +1 -0
- package/skills/protobase/references/features/your-own-code.md +1 -0
- package/skills/protobase/references/reference/custom-components.md +41 -0
- package/skills/protobase/references/reference/data-config.md +1 -0
package/dist/cli/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.53.
|
|
3
|
+
"version": "0.53.5",
|
|
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.53.
|
|
46
|
-
"@protobase/layout": "0.53.
|
|
47
|
-
"@protobase/query": "0.53.
|
|
48
|
-
"@protobase/schema": "0.53.
|
|
49
|
-
"@protobase/server": "0.53.
|
|
50
|
-
"@protobase/ui": "0.53.
|
|
45
|
+
"@protobase/config": "0.53.5",
|
|
46
|
+
"@protobase/layout": "0.53.5",
|
|
47
|
+
"@protobase/query": "0.53.5",
|
|
48
|
+
"@protobase/schema": "0.53.5",
|
|
49
|
+
"@protobase/server": "0.53.5",
|
|
50
|
+
"@protobase/ui": "0.53.5",
|
|
51
51
|
"@react-email/render": "^2.1.0",
|
|
52
52
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
53
53
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -11,6 +11,7 @@ Describe the tables of an existing Postgres database as resources, with their fi
|
|
|
11
11
|
- [Composite keys and relations](../reference/data-config.md#keys-and-relations): Records can have keys of several columns, and relations can point at them. The admin shows a related record by its name and links to it.
|
|
12
12
|
- [Soft delete](../reference/data-config.md#resource): Deleting a record marks it with a timestamp instead of removing it. Lists leave it out, and it can be restored.
|
|
13
13
|
- [Tenants](../reference/data-config.md#resource): A tenant column keeps each organization's records apart. Every query is limited to the caller's tenant, and new records get it set.
|
|
14
|
+
- [Record authors](../reference/data-config.md#resource): A record can keep who created it. The server sets it to the signed-in user on every create, and no request can set or change it.
|
|
14
15
|
- [Record search](../reference/data-config.md#resource): You choose which fields text search and the global search look in. Partial words match, and phone numbers match by their last digits.
|
|
15
16
|
- [Manual order](../reference/data-config.md#resource): Records can be kept in an order set by hand, also per parent record, such as the lines of an invoice.
|
|
16
17
|
- [Record validation](../reference/data-config.md#resource): A rule over the whole record runs on every create and update and reports each problem on the field it concerns.
|
|
@@ -13,6 +13,7 @@ React components, field types, pages and handlers of your own, loaded as plugins
|
|
|
13
13
|
- [Form parts](../reference/custom-components.md#form-parts): Build your own forms from the app's fields, pickers, switches, buttons and dialogs.
|
|
14
14
|
- [Image carousel](../reference/custom-components.md#image-carousel): Step through screenshots or a record's files in your own components by swiping or with arrows, as cards step through photos.
|
|
15
15
|
- [Assistant parts](../reference/assistant.md#in-the-ui): The assistant's panel, chat messages, composer and action cards for your own components, with a frameless action card for a page that is already framed.
|
|
16
|
+
- [Chat parts](../reference/custom-components.md#chat-parts): A chat between people from the app's parts: messages with their author, avatar, time and a status line, day and new-message lines, a thread that loads earlier messages, keeps the reader's place and jumps to the end when they send, and a composer of several lines with @mentions.
|
|
16
17
|
- [Action handlers](../reference/custom-components.md#action-handlers): Your own code for a named action, with the record, the API client and the action's inputs.
|
|
17
18
|
- [Shell slots](../reference/custom-components.md#shell-slots): Your own components in the top bar, in a panel beside every page, or as the sidebar logo.
|
|
18
19
|
- [Plugins](../reference/plugins.md#how-a-plugin-stays-working): Your React code is a plugin that the app loads at start and that keeps working across Protobase releases without changes.
|
|
@@ -269,6 +269,47 @@ export const PresetShots = () => (
|
|
|
269
269
|
)
|
|
270
270
|
```
|
|
271
271
|
|
|
272
|
+
## Chat parts
|
|
273
|
+
|
|
274
|
+
A chat between people, such as a team's channels, is built from the parts the [assistant](assistant.md#in-the-ui) uses, all from `@protobase/ui`:
|
|
275
|
+
|
|
276
|
+
| | |
|
|
277
|
+
| --- | --- |
|
|
278
|
+
| `ChatThread` | The scrolling list of messages: `length`, the number of messages, and `empty`, shown while there are none. A reader at the end follows new messages; one who scrolled back stays where they are, until `followKey` changes: change it when the reader sends, such as to a count of their sends, and the thread goes to the end and follows their message in. `onLoadEarlier` adds **Load earlier messages** at the top, with `loadingEarlier` while they come; the earlier messages keep the reader on the message they were reading. It scrolls inside itself, so the composer under it stays in view. |
|
|
279
|
+
| `ChatMessage` | One message. `author` (`{ id, name }`) draws it on the left beside the author's avatar, under their name and `time`, an ISO timestamp shown on the viewer's clock; `avatar` replaces the initials, such as with a photo, and `continued` leaves out avatar, name and time for a message that follows the same author's. `from: 'user' \| 'assistant'` draws an assistant chat's sides instead. `footer` adds a small line under either, such as whether it was read. |
|
|
280
|
+
| `ChatDivider` | A line across the chat with a label: `label` for a day, such as `chatDayLabel(time)` ("Today", "Yesterday" or the date, on the viewer's calendar) between two messages for which `sameChatDay(a, b)` is false; `tone="new"` for the red **New messages** line. |
|
|
281
|
+
| `Composer` | The box under the chat, which grows with its text: Enter or the button sends, Shift+Enter starts a new line. `onSend` gets the trimmed text and the ids of the people it mentions. With `searchPeople`, a function that returns the `{ id, name }` people whose name matches the text typed after `@`, such as a channel's members, typing `@` lists them above the box: the arrows move, Enter or Tab picks, Escape closes. `busy` keeps the text from being sent. |
|
|
282
|
+
| `MentionBox`, `MentionedText` | The text box with `@` mentions that the composer and [comments](comments.md) are built from, for a box of your own: `value` and `onChange` hold the text and the people picked (`emptyDraft` to start), and `mentionedIds(text, picked)` the ids still mentioned. `MentionedText` shows a message's `text` with each `@name` of its `mentions` picked out. |
|
|
283
|
+
|
|
284
|
+
The messages' author comes from the server: give the resource [`.author()`](data-config.md#resource), and each create stores the signed-in user's id, never a value the client sends.
|
|
285
|
+
|
|
286
|
+
```tsx
|
|
287
|
+
import { Fragment } from 'react'
|
|
288
|
+
import { ChatDivider, ChatMessage, ChatThread, Composer, MentionedText, chatDayLabel, sameChatDay } from '@protobase/ui'
|
|
289
|
+
|
|
290
|
+
export const Channel = ({ messages, sent, members, onSend, onLoadEarlier }: ChannelProps) => (
|
|
291
|
+
<div className="flex h-full flex-col">
|
|
292
|
+
<ChatThread length={messages.length} followKey={sent} onLoadEarlier={onLoadEarlier}>
|
|
293
|
+
{messages.map((message, index) => {
|
|
294
|
+
const previous = messages[index - 1]
|
|
295
|
+
const newDay = !previous || !sameChatDay(previous.sent_at, message.sent_at)
|
|
296
|
+
return (
|
|
297
|
+
<Fragment key={message.id}>
|
|
298
|
+
{newDay && <ChatDivider label={chatDayLabel(message.sent_at)} />}
|
|
299
|
+
<ChatMessage author={message.author} time={message.sent_at} continued={!newDay && previous?.author.id === message.author.id}>
|
|
300
|
+
<MentionedText text={message.body} mentions={message.mentions} />
|
|
301
|
+
</ChatMessage>
|
|
302
|
+
</Fragment>
|
|
303
|
+
)
|
|
304
|
+
})}
|
|
305
|
+
</ChatThread>
|
|
306
|
+
<div className="p-3">
|
|
307
|
+
<Composer placeholder="Message #general" onSend={onSend} searchPeople={members} />
|
|
308
|
+
</div>
|
|
309
|
+
</div>
|
|
310
|
+
)
|
|
311
|
+
```
|
|
312
|
+
|
|
272
313
|
## Components in the chat
|
|
273
314
|
|
|
274
315
|
The same components draw the assistant's [widget parts](assistant.md#widget-parts): a part names a component, and the dock draws it with the part's props, so one component can sit on a page and in the chat. In the chat there is no record around it, so a component that needs `useLayoutRecord()` works only on pages; take ids as props instead. Besides the API hooks, a widget can read the assistant backend with [`useBackendData`](assistant.md#reading-the-backend-from-a-widget).
|
|
@@ -61,6 +61,7 @@ export const repairs = resource('repairs')
|
|
|
61
61
|
| `.softDelete((r) => r.deleted_at)` | A nullable timestamp or date: deleting sets it, lists leave such rows out, `:undelete` clears it. See [REST API](api.md#routes). |
|
|
62
62
|
| `.tenant((r) => r.organization_id, { across? })` | The column that separates tenants: every query is limited to the caller's tenant, creates set it, and a request body may not. With `across: 'memberships'`, lists read every organization the person is a member of, each with their role there; see [Lists across organizations](access.md#lists-across-organizations). |
|
|
63
63
|
| `.owner((r) => r.owner_id)` | The field holding the owning user's id, which `.own` and `.team` capabilities filter on (see [Access](#access)). The server does not start when its column cannot hold the signed-in users' ids, such as an integer column with Better Auth's text ids; see [user ids](auth.md#roles-and-access-in-the-api). |
|
|
64
|
+
| `.author((r) => r.author_id)` | The field holding the id of the user who created the record, such as a chat message's sender: every create sets it to the signed-in user's id, and no request may write it, so a body that names it is refused as read-only. A create by no one signed in, through a [public form](forms.md), leaves it empty. Its column is checked at startup as an owner's is. |
|
|
64
65
|
| `.search((r) => [r.number, r.name])` | The fields that `search("...")` and bare words in a filter match, and what the admin's [global search](client.md#global-search) looks in. Every word of the text must appear in one of them, ignoring case, and part of a word is enough: `port` finds "Portfolio". `r.phone.digitsEnd()` matches only the end of a field's digits instead, ignoring spaces, `+` and dashes, and only words written like phone numbers: `9623`, `47069623` and `+31 6 47069623` find "+31 6 47069623", `4706` and `+316` do not. Each field needs a pg_trgm index (`using gin (name gin_trgm_ops)`), a `digitsEnd` one on `regexp_replace(phone, '[^0-9]', '', 'g')`, or the API refuses the search. |
|
|
65
66
|
| `.position((r) => r.position, { within?, after? })` | The integer field holding the records' order by hand, 1 the first, which a list's **Reorder** button changes by dragging; with `within: (r) => r.invoice_id`, a filterable relation, each parent's records have an order of their own, sorted in its related section; with `after`, a record never ranks above the records it depends on. The field must be sortable. See [Reordering by hand](ui-config.md#reordering-by-hand) and [Ranked after what they depend on](ui-config.md#ranked-after-what-they-depend-on). |
|
|
66
67
|
| `.parent((r) => r.vm_id, 'update')` | The relation whose record each record belongs to, and the access on it (`'read'` or `'update'`) that creating, changing, deleting and undeleting a record needs, checked with the caller's own rules on that resource. The relation is one column, to a resource with a key of one field. See [Records that belong to another](access.md#records-that-belong-to-another). |
|