@protobase/cli 0.53.3 → 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/record-pages.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/skills/protobase/references/reference/ui-config.md +13 -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.
|
|
@@ -12,6 +12,7 @@ The page of one record, with its sections, related records, galleries, charts an
|
|
|
12
12
|
- [Save conflicts](../reference/ui-config.md#editing-a-record): When someone else changed a record while you edited it, Save shows their value beside yours for each field you both changed, and you keep yours or take theirs.
|
|
13
13
|
- [Groups and tabs](../reference/ui-config.md#groups): Parts of a record page sit under headings that open on click, or in tabs, and the open ones are kept in the address.
|
|
14
14
|
- [Key facts](../reference/ui-config.md#key-facts): A section shows its values side by side with icons.
|
|
15
|
+
- [Confirming a change](../reference/ui-config.md#confirming-a-change): A field that is easy to set by mistake asks a question before a person changes it in a form or a list cell, and Cancel keeps its value.
|
|
15
16
|
- [Help while editing](../reference/ui-config.md#help-while-editing): Help lines meant for whoever changes a record show only on its form.
|
|
16
17
|
- [Conditional sections](../reference/ui-config.md#form-and-read-view): Sections and fields show only while editing, only while reading, or only when a condition on the record holds.
|
|
17
18
|
- [Galleries](../reference/ui-config.md#galleries): A record's photos show as tiles that open a full-screen lightbox, with keyboard and swipe navigation.
|
|
@@ -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). |
|
|
@@ -69,6 +69,7 @@ Field hints:
|
|
|
69
69
|
| --- | --- |
|
|
70
70
|
| `.label(text)` | Instead of the name in words (`customer_id` would be "Customer" anyway). |
|
|
71
71
|
| `.help(text, { when? })` | A line under the field on the record page and in forms. `when: 'editing'` shows it only while the record is edited; see [Help while editing](#help-while-editing). |
|
|
72
|
+
| `.confirm(question)` | Asks `question` before a person changes the value in a form or a list cell, and Cancel keeps it. See [Confirming a change](#confirming-a-change). |
|
|
72
73
|
| `.format(format)` | `badge` shows statuses as coloured badges, `code` sets identifiers in monospace, `percent` adds a % sign. On a text field, `email`, `phone` and `url` show the value as a link that writes to it (`mailto:`), calls it (`tel:`, its digits and a leading +) or opens it in a new tab (only an `http` or `https` address; anything else stays text), on the record page, in its sidebar and in the list's cells but the title's, which links to the record; forms edit it in an email, phone or web address input, which brings up the keyboard for it on a mobile screen and offers the browser's autofill. Another field type with one of them stops the server at startup. `relative` on a timestamp shows it as "5 minutes ago" or "in 2 hours" in lists and on the record page, with the exact time on hover; `absolute` and `compact` are accepted and carried in `/meta` for apps that render their own lists. <gap>The admin does not use the `absolute` and `compact` formats yet.</gap> |
|
|
73
74
|
| `.multiline()` | A text of several lines, such as a description: forms edit it in a box that grows with the text, so the page scrolls rather than the box, and the record page's sections, a page's field blocks and a card's subtitle keep its line breaks (a card shows the first three lines); the record's sidebar shows it on one line. On the record page and the create form it takes the whole width of its section. Only a text field takes it; the list's table shows the text on one line. |
|
|
74
75
|
| `.markdown()` | Markdown, such as a task's notes: forms edit its source in a box that grows with it, with a Write and Preview switch above it, and store it exactly as typed. The record page's sections and a page's field blocks show it rendered as GitHub does, line breaks kept; raw HTML shows as text, links and images keep only http(s), mailto, tel and relative addresses, and links open in a new tab. A card's subtitle shows its first three lines rendered, its links as text; the list's table, the record's sidebar and a card's other lines show its text on one line without the marks. On the record page and the create form it takes the whole width of its section. Only a text field takes it, and the renderer loads with the first markdown shown. |
|
|
@@ -682,6 +683,18 @@ view<typeof listings>('listings')
|
|
|
682
683
|
}))
|
|
683
684
|
```
|
|
684
685
|
|
|
686
|
+
### Confirming a change
|
|
687
|
+
|
|
688
|
+
A field that is easy to set by mistake, but that people may still need to change, can ask before it changes instead of being locked away with [access rules](access.md). `.confirm(question)` shows a dialog titled "Change" and the field's label, with the question under it, as the value first moves away from the saved one: when a switch is turned, a choice is picked or a record is chosen, and at the first key typed into a text or a number, not at every key after. Cancel, Escape or a click outside the dialog keeps the value; Change takes the new one, which saves as the editor saves it: with Save on the record page, at once for a switch or a choice in a list cell. A field set back to its saved value asks again when it is changed once more.
|
|
689
|
+
|
|
690
|
+
It asks on the record page's form, in a list's editable cells, on the create form and in a page's settings and form blocks. It only asks: the API writes the field as any other, so a rule that must hold belongs in the field's [access](access.md) or the resource's `.validate()`.
|
|
691
|
+
|
|
692
|
+
```ts
|
|
693
|
+
view<typeof tasks>('tasks').fields((r) => ({
|
|
694
|
+
researched: r.researched.confirm('The research job sets this once it is done. Set it by hand only to skip the research.'),
|
|
695
|
+
}))
|
|
696
|
+
```
|
|
697
|
+
|
|
685
698
|
### Form and read view
|
|
686
699
|
|
|
687
700
|
The read view and the form share the layout, so every item and field shows on both by default. `when` on an item, `l.related(title, { ..., when })` included, shows it only on one of them, and a field's `.when(...)` does so for the field wherever the record page shows it:
|