@protobase/cli 0.121.4 → 0.121.6
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 +8 -8
- package/skills/protobase/references/features/record-pages.md +1 -1
- package/skills/protobase/references/features/workflows.md +1 -0
- package/skills/protobase/references/reference/email.md +1 -0
- package/skills/protobase/references/reference/ui-config.md +27 -2
- package/skills/protobase/references/reference/workflows.md +69 -2
package/dist/cli/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.121.
|
|
3
|
+
"version": "0.121.6",
|
|
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.121.
|
|
47
|
-
"@protobase/layout": "0.121.
|
|
48
|
-
"@protobase/query": "0.121.
|
|
49
|
-
"@protobase/schema": "0.121.
|
|
50
|
-
"@protobase/server": "0.121.
|
|
51
|
-
"@protobase/ui": "0.121.
|
|
52
|
-
"@protobase/workflows": "0.121.
|
|
46
|
+
"@protobase/config": "0.121.6",
|
|
47
|
+
"@protobase/layout": "0.121.6",
|
|
48
|
+
"@protobase/query": "0.121.6",
|
|
49
|
+
"@protobase/schema": "0.121.6",
|
|
50
|
+
"@protobase/server": "0.121.6",
|
|
51
|
+
"@protobase/ui": "0.121.6",
|
|
52
|
+
"@protobase/workflows": "0.121.6",
|
|
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",
|
|
@@ -11,7 +11,7 @@ The page of one record, with its sections, related records, galleries, charts an
|
|
|
11
11
|
- [Record pages that open another](../reference/ui-config.md#a-record-page-that-opens-another): A record's page opens another address built from its fields in its place, such as a workflow run opening its workflow's page with the run shown.
|
|
12
12
|
- [Record page opens elsewhere](../reference/ui-config.md#open-elsewhere) (beta): A view can send its record's address to another page its fields name, such as a message opening in its conversation, so search results and links land where the record is read.
|
|
13
13
|
- [Full-area record pages](../reference/ui-config.md#full-area-record-pages) (beta): A view draws its record pages with a component of its own that fills the area beside the sidebar and under the top bar, such as a chat channel, and links to the standard page.
|
|
14
|
-
- [Conversation pages](../reference/ui-config.md#conversation-pages) (beta): A record's page is its conversation, configured with no component of your own: a header with its title, topic and details, its messages grouped by day and author with mentions and edits shown, and a box that sends one, opening on a New messages line at the reader's place, on the web and at mobile width.
|
|
14
|
+
- [Conversation pages](../reference/ui-config.md#conversation-pages) (beta): A record's page is its conversation, configured with no component of your own: a header with its title, topic and details, its messages grouped by day and author with mentions and edits shown, and a box that sends one, opening on a New messages line at the reader's place, on the web and at mobile width. People react to its messages, edit and delete them and reply in threads beside the conversation, by pointer or touch.
|
|
15
15
|
- [Read view and edit](../reference/ui-config.md#read-view-and-edit): A record opens as a read-only fact sheet or a form, and Edit opens the form at its own address.
|
|
16
16
|
- [Unsaved edits](../reference/ui-config.md#editing-a-record): Unsaved changes to a record stay in the browser and can be resumed, and leaving a form, a dialog or a comment with changes asks first.
|
|
17
17
|
- [Record forms](../reference/ui-config.md#editing-a-record): Relations are picked from a list that narrows as you type, numbers are read as the browser's language writes them, and a refused save says under each field what is wrong.
|
|
@@ -23,6 +23,7 @@ Graphs of steps the server runs along their edges, written in a language a model
|
|
|
23
23
|
- [Records steps](../reference/workflows.md#apprecords) (beta): Create, update, get and list records as the workflow's last editor, with the roles they hold now.
|
|
24
24
|
- [Mail step](../reference/workflows.md#appmailsend) (beta): Sends mail, with files the run downloaded attached, from the app's own sender.
|
|
25
25
|
- [Send email step](../reference/workflows.md#appmailtemplate) (beta): Sends one of the app's email templates in a language of its own, with a pin for each field of the template's data, checked before it is sent.
|
|
26
|
+
- [Email series](../reference/workflows.md#email-series) (beta): Mail steps that share a series' name, with waits between them, send each person a timed series, such as after sign-up; the series is a mail category of its own with one-click unsubscribe in every mail, and an unsubscribe stops the rest of the series for that person.
|
|
26
27
|
- [Storing files](../reference/workflows.md#storing-files) (beta): The HTTP request step streams an answer of any size into a named storage configuration, an S3-compatible bucket, a file share or a local directory, past its 10 MiB read limit; later steps pass the stored file on or read it back, up to 10 MiB. Changing where a configuration points leaves the workflows that use it unchanged.
|
|
27
28
|
- [Runs and their traces](../reference/workflows.md#traces) (beta): Each run started by hand through the API, from the app's code or by a trigger keeps every step's input, output, logs, timing, tries and error as a JSONL trace in the app's private file storage, whole by the time the run is marked ended, secrets blanked out; every run, only failing ones, or none, set by the app, the workflow or the run.
|
|
28
29
|
- [Run debugger](../reference/workflows.md#following-and-debugging-a-run) (beta): Each workflow lists its runs with their status, who started them, when and for how long; a run chosen there marks every step's status on the graph of the version it ran on from its trace, and a run's own address shows it on the latest version, with the way to the one it ran on, live while it runs, with each step's input, output, logs, timing, tries and error, secrets blanked out.
|
|
@@ -305,6 +305,7 @@ await mail.send({ to: member.email, subject: 'News', text: '...', bulk: true, to
|
|
|
305
305
|
- **The click:** the mail client's `POST` with `List-Unsubscribe=One-Click` records the opt-out and answers `200`; doing it again changes nothing. Opening the link in a browser shows a page with an **Unsubscribe** button that sends that `POST`, so a scanner that follows links in mail unsubscribes no one. A link the app did not sign answers `400` and records nothing.
|
|
306
306
|
- **Skipped sends:** whoever unsubscribed from the topic is left out, found in one query, and the send resolves to them as `skipped` beside `sent`, each recipient it went to with its message id: `{ skipped: ['bob@example.com'], sent: [{ to: 'ada@example.com', messageId: '<…>' }], messageId: '<…>' }`, with `messageId` only when it went to exactly one. Other topics still reach them. Who unsubscribed is read once, before the first message goes out; one who unsubscribes while a send to several is going out is skipped from the next send on.
|
|
307
307
|
- **A refused message:** when the server refuses one recipient's message, the send rejects with a `BulkMailError` (exported by `@protobase/server`, its `code` `BULK_MAIL_FAILED`) after the messages before it went out. It fails the try, which is retried, and names the recipient it failed on as `to`, those it went to as `sent`, those skipped as `skipped`, and the server's error as `cause`. A retried try sends to everyone again, so catch it, record `error.sent`, rethrow, and leave those addresses out of the next try; or send to one recipient per call.
|
|
308
|
+
- **From a workflow:** a workflow's mail steps send bulk mail as an [email series](workflows.md#email-series), whose name is the topic.
|
|
308
309
|
- **Who unsubscribed:** admins see each recipient, topic and time under **Unsubscribes** in the admin app, and the app's code reads them as the `mail_unsubscribes` resource, `GET /api/v1/mail_unsubscribes?filter=topic = "newsletter"`. Nobody changes them but the link.
|
|
309
310
|
- **Refused:** `bulk` without a `topic` is refused, as the email is defined or the message sent. Bulk mail without `unsubscribe: true`, or sent another way than a job's `mail`, such as through `PROTOBASE_SMTP_URL` directly or from someone's own mailbox, is refused before anything is sent. A mailer of the project's own (`auth/mailer.ts`) that is handed bulk mail directly, outside a job's `mail`, gets it without its unsubscribe: send it through the job's `mail` instead.
|
|
310
311
|
- <gap>Bulk mail cannot be sent from an API function because only a job's `mail` adds the unsubscribe; enqueue a job instead.</gap>
|
|
@@ -775,7 +775,7 @@ The standard record page, with the layout's sections, the related records, Edit
|
|
|
775
775
|
### Conversation pages
|
|
776
776
|
|
|
777
777
|
:::caution[Beta]
|
|
778
|
-
A conversation page shows each message's text with its mentions and keeps line breaks, without markdown; it has no
|
|
778
|
+
A conversation page shows each message's text with its mentions and keeps line breaks, without markdown; it has no files or calls yet, and a deleted message leaves no trace in its place.
|
|
779
779
|
:::
|
|
780
780
|
|
|
781
781
|
`.record({ conversation })` makes the record page the record's conversation, for a record that holds one, such as a chat channel, a direct message or a support case, with no component of the app's own. It fills the content area as a [full-area record page](#full-area-record-pages) does, on the web and at mobile width: a header row, the messages that point at the record, and a box that sends one, which stays in view while the messages scroll above it.
|
|
@@ -793,6 +793,16 @@ view<typeof channels>('channels').record({
|
|
|
793
793
|
subtitle: 'topic',
|
|
794
794
|
readPosition: { resource: 'read_positions', field: 'channel_id', message: 'last_read_id' },
|
|
795
795
|
placeholder: 'Message the channel',
|
|
796
|
+
edit: true,
|
|
797
|
+
delete: { unless: 'reply_count > 0' },
|
|
798
|
+
reactions: {
|
|
799
|
+
resource: 'reactions',
|
|
800
|
+
field: 'message_id',
|
|
801
|
+
user: 'user_id',
|
|
802
|
+
emoji: 'emoji',
|
|
803
|
+
labels: { thumbs_up: { symbol: '👍', name: 'Thumbs up' }, heart: { symbol: '❤️', name: 'Heart' } },
|
|
804
|
+
},
|
|
805
|
+
thread: { field: 'thread_id', count: 'reply_count', last: 'last_reply_at' },
|
|
796
806
|
},
|
|
797
807
|
})
|
|
798
808
|
```
|
|
@@ -811,11 +821,26 @@ view<typeof channels>('channels').record({
|
|
|
811
821
|
| `readPosition` | Where each reader's read position is kept: `{ resource, field, message }`. |
|
|
812
822
|
| `placeholder` | The hint in the empty box. |
|
|
813
823
|
| `empty` | What the conversation says while it has no messages. |
|
|
824
|
+
| `edit` | `true`: a message's author changes its text and mentions in place, as the message resource's update access allows. |
|
|
825
|
+
| `delete` | `true`: anyone the message resource's delete access allows deletes a message, after confirming; or `{ unless }`, a condition on the message's own fields that keeps it, such as `reply_count > 0`. |
|
|
826
|
+
| `reactions` | Emoji reactions under each message: `{ resource, field, user, emoji, labels }`. |
|
|
827
|
+
| `thread` | Replies in a thread under a message, in a panel beside the conversation: `{ field, count, last }`. |
|
|
814
828
|
|
|
815
|
-
The header shows the record's title, which the top bar repeats at mobile width and so shows there only with `members`, the subtitle, and *Details*, a link to the record's standard page at `?standard=true`, with its sections, Edit and Delete. The latest 50 messages show oldest first, with *Load earlier messages* at the top for more. A day divider opens each day, and one person's messages sent within five minutes of each other show under their name once. A message resource with [`.live()`](live.md) shows new, changed and deleted messages as they happen. Every read goes through the reader's own access: a message they may not read never shows, and a reader who may not read the messages
|
|
829
|
+
The header shows the record's title, which the top bar repeats at mobile width and so shows there only with `members`, the subtitle, and *Details*, a link to the record's standard page at `?standard=true`, with its sections, Edit and Delete. The latest 50 messages show oldest first, with *Load earlier messages* at the top for more. A day divider opens each day, and one person's messages sent within five minutes of each other show under their name once. A message resource with [`.live()`](live.md) shows new, changed and deleted messages as they happen. Every read goes through the reader's own access: a message they may not read never shows, and a reader who may not read the messages, a field each one needs or the fields of `thread` gets the standard page. The box shows for a reader who may create messages.
|
|
816
830
|
|
|
817
831
|
With `readPosition`, the conversation opens on a *New messages* line above the first message someone else wrote since the reader's position, and moves the position to the newest message whenever they read to the end. The read position resource keeps one record per reader and record: its `.author()` is the reader, `field` is a relation to the record and `message` an integer field holding the key of the newest message read, so the message resource's key is one integer column that grows as messages arrive. The page reads and writes only the reader's own position. Without `readPosition`, there is no line and nothing is written.
|
|
818
832
|
|
|
833
|
+
#### Reactions, edits, deletes and threads
|
|
834
|
+
|
|
835
|
+
With `reactions`, `edit`, `delete` or `thread`, people act on the messages where they read them. With a pointer, a bar over a message's corner shows while they point at it or move into it with the keyboard: an emoji they have not reacted with yet, *Reply in thread*, *Edit* and *Delete*. On a touch screen, a tap or a long-press of half a second opens the same actions in a sheet from the bottom at mobile width, with every emoji and *Copy text*; a tap while the reader types only lowers the keyboard, and a button that only a keyboard or screen reader reaches opens the sheet too. The message's own links and buttons keep their tap and click. Each action shows only where the reader's access allows it, and the server checks every write again: a refused one changes nothing and shows the server's reason.
|
|
836
|
+
|
|
837
|
+
- **Reactions**: `resource` keeps one record per person, message and emoji: `field` is its filterable relation to the message, `user` the text field of the user id of the person who reacted, set by the server, such as its `.author()`, and `emoji` an enum field whose values, in their order, are the emoji offered. `labels` gives each value its `symbol` and its `name`, which a screen reader reads. Under a message, one chip per emoji shows how many reacted, naming them on hover: pressing your own takes it back, and another's adds yours. The reactions of a page of messages are read together with it, and with [`.live()`](live.md) they change as people react.
|
|
838
|
+
- **Edit**: *Edit* turns the author's message into a box with its mentions kept: Enter saves, Shift+Enter starts a new line and Escape cancels.
|
|
839
|
+
- **Delete**: *Delete* asks before the message goes for everyone. A reader who may not read the fields `unless` reads gets no *Delete*.
|
|
840
|
+
- **Threads**: `field` is the filterable relation of the messages to themselves that holds a reply's first message, empty for a message of the conversation itself, `count` an integer field holding a first message's number of replies and `last` a date or timestamp field holding when its last reply came, both kept by the database, such as by a trigger. The conversation shows only messages outside threads; under a message with replies, a link names how many and when the last came. It and *Reply in thread* open the thread at `?thread=<key>`, so a link can open it too: in a panel beside the conversation, covering the screen at mobile width, with the first message, its replies and a box of its own that replies in the thread. An address naming a message of another conversation opens no thread there. A reply gets its first message's conversation from the box, so keep the two the same in the database, such as by a check in the trigger that counts the replies, as an API create can set them apart.
|
|
841
|
+
|
|
842
|
+
<gap>A conversation page cannot offer *Edit* when its `sender` is a relation because matching a related record to the reader is not implemented; a `sender` of user ids, such as the resource's `.author()`, gets it.</gap>
|
|
843
|
+
|
|
819
844
|
<gap>A conversation page cannot open at a given message, such as a search result, because opening a conversation at a message is not implemented.</gap> <gap>A conversation page cannot show a message's markdown because rendering markdown together with mentions is not implemented.</gap>
|
|
820
845
|
|
|
821
846
|
### Focus pages
|
|
@@ -475,8 +475,9 @@ A get and a list only read; a create and an update are recorded. They go through
|
|
|
475
475
|
| `subject` | One line of text. |
|
|
476
476
|
| `text`, `html` | The body as text, and optionally as HTML. |
|
|
477
477
|
| `attachments` | A list of file values the run keeps, at most 10 MiB together. |
|
|
478
|
+
| `series` | Optional: the [email series](#email-series) the mail belongs to, such as `welcome`. |
|
|
478
479
|
|
|
479
|
-
The mail goes from the app's own sender with the app's mailer; a workflow cannot set the sender. The result is `{ message_id }`, the Message-ID the step sets, the same for each try of the step. Without mail the step fails.
|
|
480
|
+
The mail goes from the app's own sender with the app's mailer; a workflow cannot set the sender. The result is `{ message_id }`, the Message-ID the step sets, the same for each try of the step; with a `series`, `{ message_id, sent, skipped }`, as [Email series](#email-series) says. Without mail the step fails.
|
|
480
481
|
|
|
481
482
|
### app:mail.template
|
|
482
483
|
|
|
@@ -488,6 +489,7 @@ The mail goes from the app's own sender with the app's mailer; a workflow cannot
|
|
|
488
489
|
| `to` | One address. |
|
|
489
490
|
| `locale` | Optional: a BCP 47 language tag, such as `nl` or `en-GB`. The mail is in the template's language closest to it, so `nl-BE` picks `nl`. Without it, the mail is in the app's `locale` when the template has that language. Otherwise it is in English when the template has it, else in the template's first language. |
|
|
490
491
|
| `data` | The template's data, as its schema takes it. |
|
|
492
|
+
| `series` | Optional: the [email series](#email-series) the mail belongs to, such as `welcome`. |
|
|
491
493
|
|
|
492
494
|
```json
|
|
493
495
|
{
|
|
@@ -505,7 +507,72 @@ The mail goes from the app's own sender with the app's mailer; a workflow cannot
|
|
|
505
507
|
|
|
506
508
|
The editor draws one input pin for each field of the chosen template's data, and offers the template's languages for `locale`. A save checks each value read by name in `data` against the type of that field, as it checks a record's fields. `list_workflow_types` lists the app's template names in the step's `template` argument, and each template's languages and data schema under `templates`.
|
|
507
509
|
|
|
508
|
-
The mail goes from the app's own sender, as `app:mail.send`'s does. The result is `{ message_id, locale }`: the Message-ID the step sets, the same for each try of the step, and the language the mail was sent in. Data the template's schema refuses fails the step with `Mail.InvalidData`, its cause naming each path, such as `data.name: Invalid input`. A template the app does not have fails it with `Mail.UnknownTemplate`, and a `to` or `locale` of the wrong kind, such as a locale that is no language tag, with `Mail.InvalidArguments`. Without mail the step fails.
|
|
510
|
+
The mail goes from the app's own sender, as `app:mail.send`'s does. The result is `{ message_id, locale }`: the Message-ID the step sets, the same for each try of the step, and the language the mail was sent in; with a `series`, `sent` and `skipped` too, as [Email series](#email-series) says. Data the template's schema refuses fails the step with `Mail.InvalidData`, its cause naming each path, such as `data.name: Invalid input`. A template the app does not have fails it with `Mail.UnknownTemplate`, and a `to` or `locale` of the wrong kind, such as a locale that is no language tag, with `Mail.InvalidArguments`. Without mail the step fails.
|
|
511
|
+
|
|
512
|
+
### Email series
|
|
513
|
+
|
|
514
|
+
:::caution[Beta]
|
|
515
|
+
A run goes on to its end after an unsubscribe, sending nothing more in the series: a series has no step that ends the run by itself.
|
|
516
|
+
:::
|
|
517
|
+
|
|
518
|
+
An email series is mail a workflow sends over time, such as a welcome mail on sign-up, tips three days later and a check-in after two weeks. Give each mail step of the series the same `series`, a name such as `welcome`: a lowercase letter, then lowercase letters, digits, `_` and `-`, at most 63 characters. The `Wait` states between them set the timing. A trigger such as [`app:record`](#apprecord) starts one run per person, so each person has a series of their own.
|
|
519
|
+
|
|
520
|
+
The series is a mail category of its own, with nothing else to set up: each mail in it is bulk mail whose topic is the series' name, and carries its recipient's own [one-click unsubscribe](email.md#unsubscribe) from that series. It needs `unsubscribe: true` in the config; without it, the step fails before it sends anything.
|
|
521
|
+
|
|
522
|
+
- **After an unsubscribe:** every later mail step of the series sends that person nothing, so the rest of the series stops for them, in this run and any other. Their other series, and other people's runs of this one, go on. The step does not fail: its result is `{ sent: [], skipped: ['ada@example.com'] }`, and the run passes its remaining waits and ends as succeeded.
|
|
523
|
+
- **The result:** `sent` lists the addresses the mail went to and `skipped` those that unsubscribed from the series, with `message_id` when the mail went to anyone.
|
|
524
|
+
- **Other steps go on:** an unsubscribe stops the series' mail only. To stop the run's other steps too, follow a mail step with a `Choice` that ends the run when nobody got it, `{% $count($states.input.sent) = 0 %}`, with the mail step's result as its input.
|
|
525
|
+
- **Who unsubscribed:** they are listed under **Unsubscribes** in the admin app, with the series' name as the topic.
|
|
526
|
+
- <gap>A series cannot end its run when its recipient unsubscribes because a step that ends the run it is in is not implemented; the run's later mail steps send nothing instead.</gap>
|
|
527
|
+
|
|
528
|
+
A sign-up series, started for each new record of the app's `members` resource:
|
|
529
|
+
|
|
530
|
+
```json
|
|
531
|
+
{
|
|
532
|
+
"trigger": { "app:record": { "resource": "members" } },
|
|
533
|
+
"stateMachine": {
|
|
534
|
+
"QueryLanguage": "JSONata",
|
|
535
|
+
"StartAt": "Welcome",
|
|
536
|
+
"States": {
|
|
537
|
+
"Welcome": {
|
|
538
|
+
"Type": "Task",
|
|
539
|
+
"Resource": "app:mail.send",
|
|
540
|
+
"Arguments": {
|
|
541
|
+
"to": "{% $states.context.Execution.Input.record.email %}",
|
|
542
|
+
"subject": "{% 'Welcome, ' & $states.context.Execution.Input.record.name %}",
|
|
543
|
+
"text": "Thanks for signing up. Here is how to get started.",
|
|
544
|
+
"series": "welcome"
|
|
545
|
+
},
|
|
546
|
+
"Next": "Three days"
|
|
547
|
+
},
|
|
548
|
+
"Three days": { "Type": "Wait", "Seconds": 259200, "Next": "Tips" },
|
|
549
|
+
"Tips": {
|
|
550
|
+
"Type": "Task",
|
|
551
|
+
"Resource": "app:mail.send",
|
|
552
|
+
"Arguments": {
|
|
553
|
+
"to": "{% $states.context.Execution.Input.record.email %}",
|
|
554
|
+
"subject": "Three tips for your first week",
|
|
555
|
+
"text": "Here are three things most people set up first.",
|
|
556
|
+
"series": "welcome"
|
|
557
|
+
},
|
|
558
|
+
"Next": "Two weeks"
|
|
559
|
+
},
|
|
560
|
+
"Two weeks": { "Type": "Wait", "Seconds": 950400, "Next": "Check-in" },
|
|
561
|
+
"Check-in": {
|
|
562
|
+
"Type": "Task",
|
|
563
|
+
"Resource": "app:mail.send",
|
|
564
|
+
"Arguments": {
|
|
565
|
+
"to": "{% $states.context.Execution.Input.record.email %}",
|
|
566
|
+
"subject": "How is it going?",
|
|
567
|
+
"text": "You signed up two weeks ago. Reply to this mail and tell us how it is going.",
|
|
568
|
+
"series": "welcome"
|
|
569
|
+
},
|
|
570
|
+
"End": true
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
```
|
|
509
576
|
|
|
510
577
|
### app:piece
|
|
511
578
|
|