@protobase/cli 0.101.0 → 0.101.1
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/dist/project/project-admin.js +2 -1
- package/package.json +8 -8
- package/skills/protobase/references/features/email-and-public-forms.md +4 -3
- package/skills/protobase/references/features/workflows.md +1 -0
- package/skills/protobase/references/reference/email.md +65 -5
- package/skills/protobase/references/reference/languages.md +2 -0
- package/skills/protobase/references/reference/workflow-plugins.md +2 -1
- package/skills/protobase/references/reference/workflows.md +30 -1
- package/skills/protobase/workflows.md +6 -0
package/dist/cli/package.js
CHANGED
|
@@ -10,7 +10,7 @@ import { configExports, createAdmin } from "@protobase/server";
|
|
|
10
10
|
* beside the config's resources (see `readUserTables`). `report` is what the admin does with an unhandled error.
|
|
11
11
|
*/
|
|
12
12
|
const projectAdmin = (project, db, ui, reporter, upgradeWebSocket, userTables) => {
|
|
13
|
-
const { resources, views, pages, translations, userMenu, bottomBars, subscriptions } = configExports(project.config);
|
|
13
|
+
const { resources, views, pages, translations, templates, userMenu, bottomBars, subscriptions } = configExports(project.config);
|
|
14
14
|
const unhandled = project.options?.onUnhandledError ?? ((error) => console.error(error));
|
|
15
15
|
const report = (error, request) => {
|
|
16
16
|
reporter?.report(error, request);
|
|
@@ -22,6 +22,7 @@ const projectAdmin = (project, db, ui, reporter, upgradeWebSocket, userTables) =
|
|
|
22
22
|
...userTables && { userTables },
|
|
23
23
|
pages,
|
|
24
24
|
...translations && { translations },
|
|
25
|
+
templates,
|
|
25
26
|
...userMenu && { userMenu },
|
|
26
27
|
bottomBars,
|
|
27
28
|
db,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.101.
|
|
3
|
+
"version": "0.101.1",
|
|
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.101.
|
|
47
|
-
"@protobase/layout": "0.101.
|
|
48
|
-
"@protobase/query": "0.101.
|
|
49
|
-
"@protobase/schema": "0.101.
|
|
50
|
-
"@protobase/server": "0.101.
|
|
51
|
-
"@protobase/ui": "0.101.
|
|
52
|
-
"@protobase/workflows": "0.101.
|
|
46
|
+
"@protobase/config": "0.101.1",
|
|
47
|
+
"@protobase/layout": "0.101.1",
|
|
48
|
+
"@protobase/query": "0.101.1",
|
|
49
|
+
"@protobase/schema": "0.101.1",
|
|
50
|
+
"@protobase/server": "0.101.1",
|
|
51
|
+
"@protobase/ui": "0.101.1",
|
|
52
|
+
"@protobase/workflows": "0.101.1",
|
|
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",
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
Mail the app sends, the PDF documents it makes, and forms for people without an account.
|
|
6
6
|
|
|
7
7
|
- [Email](../reference/email.md#configuration): The app sends mail through one SMTP server or a mailer you supply.
|
|
8
|
-
- [Built-in emails](../reference/email.md#protobases-own-mail): Sign-in codes, password resets, invitations and mentions are sent in the app's name.
|
|
9
|
-
- [Email templates](../reference/email.md#templates): Your own emails are
|
|
10
|
-
- [
|
|
8
|
+
- [Built-in emails](../reference/email.md#protobases-own-mail): Sign-in codes, password resets, invitations and mentions are sent in the app's name, in English or Dutch.
|
|
9
|
+
- [Email templates](../reference/email.md#templates) (beta): Your own emails are templates with typed data, written in mail blocks with their texts in each language they are sent in, checked by a schema of yours or the data they read, and sent from jobs, hooks, functions or a workflow's Send email step.
|
|
10
|
+
- [Emails in React](../reference/email.md#emails-in-react): An email can be a React component with typed data instead, for a layout the mail blocks cannot draw.
|
|
11
|
+
- [Protobase's mail look](../reference/email.md#the-look-of-protobases-own-mail): Your emails use a layout, button, code and note with the look of Protobase's own mail.
|
|
11
12
|
- [Unsubscribe headers](../reference/email.md#templates): Your emails carry header fields of their own, such as a one-click unsubscribe link for bulk mail.
|
|
12
13
|
- [Attachments](../reference/email.md#attachments): A message carries files, such as an invoice's PDF, through the app's mail or someone's own mailbox.
|
|
13
14
|
- [PDF documents](../reference/pdf.md#documents): PDF files such as invoices and quotes are React components with typed data, rendered from jobs, hooks or functions and attached to mail as they are.
|
|
@@ -22,6 +22,7 @@ Graphs of steps the server runs along their edges, written in a language a model
|
|
|
22
22
|
- [HTTP request step](../reference/workflows.md#apphttp) (beta): Calls a URL built at run time through the outgoing-address guard, only at public addresses unless the config allows private ones, reading at most 10 MiB of the answer as JSON, text or a file, by its Content-Type unless the step says which. It can send its body as JSON whatever it holds, and check the answer's body against a JSON Schema, whose fields the editor then offers.
|
|
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
|
+
- [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.
|
|
25
26
|
- [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.
|
|
26
27
|
- [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.
|
|
27
28
|
- [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.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
The SMTP server and sender an app's mail goes out through, and emails of the app's own, written as React components with typed data and sent from jobs, hooks and API functions.
|
|
6
6
|
|
|
7
|
-
An app sends mail through one SMTP server: Protobase's own mail ([password reset](auth.md#password-reset), [emailed sign-in codes](auth.md#emailed-sign-in-codes), [invitations](auth.md#organizations), staff sign-in notices and [mentions in comments](comments.md#mentions)) and the emails the app defines itself.
|
|
7
|
+
An app sends mail through one SMTP server: Protobase's own mail ([password reset](auth.md#password-reset), [emailed sign-in codes](auth.md#emailed-sign-in-codes), [invitations](auth.md#organizations), staff sign-in notices and [mentions in comments](comments.md#mentions)) and the emails the app defines itself. Each is rendered to HTML with a plain-text part beside it.
|
|
8
8
|
|
|
9
9
|
## Configuration
|
|
10
10
|
|
|
@@ -36,15 +36,75 @@ A send through `PROTOBASE_SMTP_URL` gets 30 seconds in all: looking up the serve
|
|
|
36
36
|
|
|
37
37
|
## Protobase's own mail
|
|
38
38
|
|
|
39
|
-
The auth emails (sign-in, two-factor and sign-up codes, the note to an address that asked to sign up while it has an account, password reset, invitations and staff sign-in notices) and the email to someone a [comment mentions](comments.md#mentions) are
|
|
39
|
+
The auth emails (sign-in, two-factor and sign-up codes, the note to an address that asked to sign up while it has an account, password reset, invitations and staff sign-in notices) and the email to someone a [comment mentions](comments.md#mentions) are email templates: a heading, the message, one code or button, and a footer naming the app.
|
|
40
40
|
|
|
41
|
+
- They come in English and Dutch. An auth email is in the app's [`locale`](languages.md#choosing-the-language) when the app sets one, else in the language of the browser that asked for it, such as the one that asked for a sign-in code, else in English. The mention email is in the app's `locale`, else in English: it is sent by a job, after the request.
|
|
41
42
|
- They name the app by its [`name`](config/app.md#name), and link it on the origin the request came to: the footer links its home page, and the note to an address that has an account links its sign-in page.
|
|
42
|
-
- The plain-text part has each code on a line of its own and each link in full.
|
|
43
|
+
- The plain-text part has each code on a line of its own and each link in full. A date, such as when an invitation's link stops working, is written in the email's language, in UTC: `October 15, 2026 at 12:00 PM UTC`, `15 oktober 2026 om 12:00 UTC`.
|
|
43
44
|
- React Email and the templates are loaded when the first auth email is sent, so an app that sends none never loads them and the server starts as fast without them.
|
|
44
45
|
|
|
45
46
|
## Templates
|
|
46
47
|
|
|
47
|
-
An email of the app's own is `
|
|
48
|
+
An email of the app's own is a template: `defineTemplate`, with its data typed, its text in each language it is sent in, and its body written in mail blocks, as a [typed layout](layouts.md#typed-layouts) is. The body is built once, as the config loads, into a static tree: `data.name` is the placeholder `{{name}}`, `<Show when>` and `<Switch>` choose by the data, and an `ArrayField` repeats a list of it. Export the template from `config/index.ts`, so the workflow step [Send email](workflows.md#appmailtemplate) lists it.
|
|
49
|
+
|
|
50
|
+
```tsx title="config/emails/contact-reply.tsx"
|
|
51
|
+
/** @jsxImportSource @protobase/layout */
|
|
52
|
+
import { Button, Show, Text, Trans, translations } from '@protobase/layout'
|
|
53
|
+
import { defineTemplate } from '@protobase/server'
|
|
54
|
+
import { z } from 'zod'
|
|
55
|
+
import en from './contact-reply.en.json'
|
|
56
|
+
import nl from './contact-reply.nl.json'
|
|
57
|
+
|
|
58
|
+
export const contactReply = defineTemplate({
|
|
59
|
+
name: 'contact-reply',
|
|
60
|
+
texts: translations({ en, nl }),
|
|
61
|
+
schema: z.object({ name: z.string(), topic: z.enum(['sales', 'support']), days: z.number(), id: z.string() }),
|
|
62
|
+
subject: ({ data }) => <Trans i18nKey="subject" values={{ name: data.name }} />,
|
|
63
|
+
body: ({ data, app }) => (
|
|
64
|
+
<>
|
|
65
|
+
<Text as="h1"><Trans i18nKey="greeting" values={{ name: data.name }} /></Text>
|
|
66
|
+
<Text><Trans i18nKey="thanks" values={{ days: data.days }} /></Text>
|
|
67
|
+
<Show when={data.topic.eq('sales')}>
|
|
68
|
+
<Text><Trans i18nKey="sales" components={{ b: <Text as="strong" /> }} /></Text>
|
|
69
|
+
</Show>
|
|
70
|
+
<Button href={`${app.url}/contact/${data.id}`}><Trans i18nKey="cta" /></Button>
|
|
71
|
+
</>
|
|
72
|
+
),
|
|
73
|
+
})
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```json title="config/emails/contact-reply.nl.json"
|
|
77
|
+
{
|
|
78
|
+
"subject": "We hebben je bericht ontvangen, {name}",
|
|
79
|
+
"greeting": "Hoi {name},",
|
|
80
|
+
"thanks": "{days, plural, one {We antwoorden binnen # werkdag.} other {We antwoorden binnen # werkdagen.}}",
|
|
81
|
+
"sales": "Een collega van sales <b>belt je</b>.",
|
|
82
|
+
"cta": "Bekijk je bericht"
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
| `defineTemplate` option | |
|
|
87
|
+
| --- | --- |
|
|
88
|
+
| `name` | Names the template, in errors and in the step's list: a lowercase letter, then lowercase letters, digits and dashes. Each template of the app has its own. |
|
|
89
|
+
| `texts` | Its texts in each language it is sent in, `translations({ en, nl })` of ICU messages, which its `<Trans>` elements show, as the app's own [texts](languages.md#your-own-texts) are. Without it, the template is in one language, as written. |
|
|
90
|
+
| `subject` | The subject line: text, or a function of `{ data, app }` that gives text or a `<Trans>`. |
|
|
91
|
+
| `preview` | Optional: the line inboxes show after the subject, as `subject` is written. |
|
|
92
|
+
| `schema` | Optional: a [Standard Schema](https://standardschema.dev), such as a zod 4 schema, or Valibot's with `toStandardJsonSchema`, which checks the data before each send and types it. |
|
|
93
|
+
| `headers` | Optional: more header fields, or a function of `{ data, app }` that gives them, each one line. |
|
|
94
|
+
| `body` | A function of `{ data, app }` that gives the mail's blocks. `app.name` and `app.url` are the app the mail comes from. |
|
|
95
|
+
|
|
96
|
+
The body takes the mail blocks: `Text` (a paragraph, `as="h1"` to `h4` for a heading, `strong`, `em` or `span` in a line), `Trans`, `Link` with an `href`, `Button` with an `href`, `Image`, `Divider`, `Box`, `Row` and `Column`, `Show`, `Switch` and `Match`, `ArrayField` with `RecordsIterator`, and `Field`. Any other block, such as a `Table`, fails as the config loads, as does a `<Trans>` key the texts lack.
|
|
97
|
+
|
|
98
|
+
The template that comes back has two methods, both typed by the data:
|
|
99
|
+
|
|
100
|
+
- `render(data, { locale, app })` gives `{ subject, html, text, headers, locale }` without sending anything: for a test, or to look at the result.
|
|
101
|
+
- `send(to, data, { locale, mailer, app, attachments })` renders and sends it, through `mailer` when given (a job's `mail`), otherwise through `PROTOBASE_SMTP_URL`, and gives what it rendered. It rejects when mail is off or the server refuses the message.
|
|
102
|
+
|
|
103
|
+
A send is in the language of its texts closest to `locale`, by its tag (`nl-BE`) or its language (`nl`), else the app's `locale` when the texts have it, else English, else the first; `locale` says which it was. With a `schema`, data the schema refuses rejects with `TemplateDataError`, naming each path, before anything is sent. The data's JSON Schema, which the step draws its pins from, is the schema's own, or without one each path the template reads, such as `name` and a list `items` with its `title`.
|
|
104
|
+
|
|
105
|
+
### Emails in React
|
|
106
|
+
|
|
107
|
+
An email can also be `defineEmail`: a name, a subject, and a React component whose props are the email's data, for a layout the mail blocks cannot draw. The components of [React Email](https://react.email) render the tables and inline styles email clients need. `@protobase/server` brings React's renderer; the project adds the components, and React for its JSX, which a project with a UI has already:
|
|
48
108
|
|
|
49
109
|
```sh
|
|
50
110
|
bun add react-email react
|
|
@@ -103,7 +163,7 @@ headers: ({ unsubscribeUrl }: Digest) => ({ 'List-Unsubscribe': `<${unsubscribeU
|
|
|
103
163
|
|
|
104
164
|
### The look of Protobase's own mail
|
|
105
165
|
|
|
106
|
-
`@protobase/server/email` exports
|
|
166
|
+
`@protobase/server/email` exports React Email components with the look of Protobase's own mail, so an app's `defineEmail` emails can look the same: a white card on grey with a teal action.
|
|
107
167
|
|
|
108
168
|
| Component | |
|
|
109
169
|
| --- | --- |
|
|
@@ -62,6 +62,8 @@ Every built-in screen is translated: the shell with its sidebar, top bar, search
|
|
|
62
62
|
|
|
63
63
|
The screens where people add [tables of their own](user-tables.md#in-the-admin-app) are translated too: the tables list, a table's page with its fields, and the forms that make a table and a field, with the names of the field types. So are the other lists Protobase adds beside your resources, failed jobs, activity and comments, with their record pages, sections and actions.
|
|
64
64
|
|
|
65
|
+
Protobase's [own emails](email.md#protobases-own-mail) are translated too: the sign-in, two-factor, sign-up and confirmation codes, the notes to an address that has an account or has none, password reset and the note that a password changed, invitations, staff sign-in notices and the email to someone a comment mentions. An auth email is in the app's `locale`, or else in the language of the browser that asked for it; the mention email is in the app's `locale`, or else in English.
|
|
66
|
+
|
|
65
67
|
The approvals an AI client asks for over [MCP](mcp.md#writes) are translated too, with their buttons and the refusal for a client that cannot ask: in the app's `locale`, or else in the language the client's request accepts.
|
|
66
68
|
|
|
67
69
|
The other texts a plugin or the server writes itself, such as an error message the API sends back, show as they are written.
|
|
@@ -8,7 +8,7 @@ Add trigger and step types to workflows from a file of the app or a package, thr
|
|
|
8
8
|
Plugins add step types and record triggers. They also add polling and webhook triggers, which run within the limits named in their section, and connections that sign in to other services as an account a person connected, within the limits named under [Connections](#connections).
|
|
9
9
|
:::
|
|
10
10
|
|
|
11
|
-
A **workflow plugin** adds trigger and step types to an app's [workflows](workflows.md). Its types are named `<plugin>:<key>`, such as `acme:create_invoice`: a Task names a step type as its `Resource`, and a definition's `trigger` holds a trigger type with its input. The built-in types, `app:http`, `app:records.*`, `app:mail.send` and `app:record`, are a plugin like any other, written on this interface alone, so a plugin's types run, are checked and are listed exactly as they are. So is every [default plugin](#default-plugins), such as [incoming Gmail mail](#incoming-gmail-mail).
|
|
11
|
+
A **workflow plugin** adds trigger and step types to an app's [workflows](workflows.md). Its types are named `<plugin>:<key>`, such as `acme:create_invoice`: a Task names a step type as its `Resource`, and a definition's `trigger` holds a trigger type with its input. The built-in types, `app:http`, `app:records.*`, `app:mail.send`, `app:mail.template` and `app:record`, are a plugin like any other, written on this interface alone, so a plugin's types run, are checked and are listed exactly as they are. So is every [default plugin](#default-plugins), such as [incoming Gmail mail](#incoming-gmail-mail).
|
|
12
12
|
|
|
13
13
|
## Writing a plugin
|
|
14
14
|
|
|
@@ -80,6 +80,7 @@ What `run` gets, and nothing more:
|
|
|
80
80
|
| `files` | `keep(bytes, name, type)` stores a file of the run and returns its file value; `read(value, field)` reads one the run kept. No other file of the app is reachable. |
|
|
81
81
|
| `storage` | `put(configuration, path, stream, { name, type })` streams a file into a [storage configuration](workflows.md#storing-files) and returns the stored file, cancelling the stream when it fails; `open(configuration, path)` checks both before there is a stream, and its `put(stream, { name, type })` stores one there, for a step that should not fetch a file it cannot store; `read(file, field)` gives a stored file's bytes as a stream. Both read the configuration as the user who saved the version, and fail with `Storage.NotFound` for one they may not read, a file that is gone, or an app with storage off. |
|
|
82
82
|
| `mail` | `send(message)` from the app's own sender; `undefined` when the app sends no mail. |
|
|
83
|
+
| `templates` | `list`, the app's [email templates](email.md), each with its `name`, `languages`, `dataSchema` and `send(to, data, { locale, mailer, app })`, which rejects data its schema refuses with an error whose `issues` name each path; and `app`, the `{ name, url }` the mail names as the one it comes from. `list` is empty when the app exports no templates. |
|
|
83
84
|
| `connection` | `accessToken()` of the connection the step declares, or `undefined`. |
|
|
84
85
|
| `mailbox` | `send(message)` from the [own mailbox](email.md#from-someones-own-mailbox) of the person who turned on the version the run runs, signed in as themselves, while they may still change the workflow; otherwise it fails `not_linked` and sends nothing. `undefined` when the app links no mailboxes. |
|
|
85
86
|
| `runId`, `idempotencyKey` | The run, and a key that every retry of this visit of the step shares, while a later visit of the same state, such as in a loop, gets a new one: send it where the receiver deduplicates. A step that [waits for an outside result](workflows.md#waiting-for-an-outside-result) gets a new one with each token it hands off, so a receiver never drops the only token that can still answer. |
|
|
@@ -395,7 +395,7 @@ A user who may read a workflow but not change it gets the same page, its fields
|
|
|
395
395
|
|
|
396
396
|
- **The graph lays itself out.** The trigger is on the left, each state is a box, a Map is a box around the states it runs for each item, and each edge is drawn from the field that names it: a state's `Next`, a Choice's rules (labelled with their condition) and its `Default` ("Otherwise"), and a Task's or Map's catchers ("On error", dashed). The graph is laid out in layers, from left to right, each time a state, an edge, a pin or a wire is added, removed or renamed; the document keeps no positions, so the graph a person sees is the one a model or the API wrote, and the one they edit is what a model reads back. The canvas zooms with the wheel, a pinch and its buttons, and pans by dragging the empty canvas.
|
|
397
397
|
- **Moving nodes by hand.** Dragging a node, a step, the trigger, a Break, a Make or a condition node, puts it where it is let go, as do the arrow keys on the chosen node. Shift-click adds a node to the choice or takes it out, and Shift-drag on the empty canvas chooses every node its box covers; the nodes chosen move together, and Delete removes them all. A step's form opens only on a plain click on it, never while a choice is made with Shift or a box. It stays there, marked with a pin, and the nodes not moved are laid out around it, also as steps and connections change: one the layout would put under it goes below it, and a Map or Block grows around a node moved inside it. *Pins* and *Simple* each keep their own places, so a node moved in one view stays where the layout puts it in the other. The pin's *Unpin* hands the node back to the layout, and *Tidy up*, above the graph, lays the view shown out again, forgetting every node moved in it and leaving the other view's. Where nodes were moved is the workflow's [layout](#layout), shared with everyone who edits it and saved by *Save*; it makes no new version and needs no publish. An older version opens with the layout it was saved with, which cannot be changed. <gap>A step renamed in the editor cannot keep the place it was moved to because carrying its layout key over to its new name is not implemented.</gap>
|
|
398
|
-
- **Adding a step.** *Add step* opens a searchable picker in the panel: every step type the app can run, its plugins' included, each with what it does, then Choice, For each item, Wait, Set values, Succeed and Fail. Search finds other words too, such as *email* for Send mail. It says where the step lands, and choosing a step on the graph changes that. Clicking or tapping one of a step's handles, which grows into a plus under the pointer, opens the same picker for a step right there: at the bottom handle after the step, at a Choice's *When* as a new rule and at its *Otherwise* as its `Default`, at *On error* on the path of every error, and at the trigger's as the first step. Where the handle led to a step already, the new one goes in between and goes on to that step, such as between the trigger and the first step; a Succeed or Fail there stays unconnected. A new step is named `Step 1`, `Step 2` and so on, and goes after the chosen step, taking over where it went on to, or after the last step; into the Map chosen; or first, with the trigger chosen. After a Choice or a step that ends the run it stays unconnected, and so does a Succeed or Fail that would cut off the steps after it, such as one added between two steps or first in a workflow that has steps.
|
|
398
|
+
- **Adding a step.** *Add step* opens a searchable picker in the panel: every step type the app can run, its plugins' included, each with what it does, then Choice, For each item, Wait, Set values, Succeed and Fail. Search finds other words too, such as *email* for Send plain mail. It says where the step lands, and choosing a step on the graph changes that. Clicking or tapping one of a step's handles, which grows into a plus under the pointer, opens the same picker for a step right there: at the bottom handle after the step, at a Choice's *When* as a new rule and at its *Otherwise* as its `Default`, at *On error* on the path of every error, and at the trigger's as the first step. Where the handle led to a step already, the new one goes in between and goes on to that step, such as between the trigger and the first step; a Succeed or Fail there stays unconnected. A new step is named `Step 1`, `Step 2` and so on, and goes after the chosen step, taking over where it went on to, or after the last step; into the Map chosen; or first, with the trigger chosen. After a Choice or a step that ends the run it stays unconnected, and so does a Succeed or Fail that would cut off the steps after it, such as one added between two steps or first in a workflow that has steps.
|
|
399
399
|
- **Pins and wires.** Execution runs along the square handles in a box's header, and data along round pins below it, coloured by type: each argument of a Task's step type is a pin on the left, with its type on hover, and each value a step returns, or the trigger gives the run, is a pin on the right, such as an HTTP request's *Status*, *Headers* and *Body* and a record trigger's *Record*. A record, an HTTP body with a `body_schema`, headers and any other object with a title are one pin each. Dragging an output pin to an input pin wires them: the input reads that value by name, the step it comes from gets a variable keeping its result when it has none, and taking the wire away empties the input. A wire is refused over a pin that does not take it, saying why, such as *Whole number does not fit Text*, or that the step does not run before. An input no wire reads shows its value on its row, to type there where it is text, a number, true or false or a choice; an expression shows as ƒ and an object as {…}, both edited in the step's form. Inputs a type does not need and that hold nothing fold away behind *N more inputs*. The layout orders the nodes by where their wires meet their pins, so wires cross as little as they can, and in data order puts each node just before what reads it, so a Break, a condition node or a Select stands beside its step.
|
|
400
400
|
- **Break and Make.** Letting go of a wire from an object pin on the empty canvas offers *Break <Type>*, a node with a pin for each field of the object, such as a record's fields; from an object input, *Make <Type>*, which builds it from a pin per field, such as the fields a records step writes. They are the editor's own: they run no step and leave no trace, the inputs that use them read `$fetch.body.ip` and hold `{ "name": "{% $fetch.body.ip %}" }`, and opening a workflow draws a Break for each object a read goes into and a Make for each argument written as an object whose fields read values. One that nothing reads yet goes with a reload. A Break shows only the fields something reads, through a wire or an expression, and *N more fields* opens the rest; one that nothing reads yet shows them all.
|
|
401
401
|
- **Select.** An argument chosen by another value is drawn as a *Select* node between them: its one input is the value it looks at, a row per case gives a value of its own when that value is one of its own, and *Otherwise* gives one for any other, all typed on the node; *Add case* adds one. It is the editor's own: it writes a chain of conditionals, `{% $states.context.Execution.Input.body.topic = 'sales' ? 'sales@example.com' : 'support@example.com' %}`, and one written that way, spaced as the node writes it, opens as the node, as it was saved. Letting go of a wire from an input of a value, empty or holding one of its own, on the empty canvas offers *Select*, whose one case and Otherwise give what the input held. Its position is kept under `Notify.#select.to`. Removing it removes the argument.
|
|
@@ -478,6 +478,35 @@ A get and a list only read; a create and an update are recorded. They go through
|
|
|
478
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
480
|
|
|
481
|
+
### app:mail.template
|
|
482
|
+
|
|
483
|
+
**Send email** sends one of the app's [email templates](email.md), the `defineTemplate(...)` templates its config exports:
|
|
484
|
+
|
|
485
|
+
| Argument | |
|
|
486
|
+
| --- | --- |
|
|
487
|
+
| `template` | The template's name, one of the app's templates. |
|
|
488
|
+
| `to` | One address. |
|
|
489
|
+
| `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
|
+
| `data` | The template's data, as its schema takes it. |
|
|
491
|
+
|
|
492
|
+
```json
|
|
493
|
+
{
|
|
494
|
+
"Type": "Task",
|
|
495
|
+
"Resource": "app:mail.template",
|
|
496
|
+
"Arguments": {
|
|
497
|
+
"template": "order-confirmation",
|
|
498
|
+
"to": "{% $states.context.Execution.Input.record.email %}",
|
|
499
|
+
"locale": "{% $states.context.Execution.Input.record.language %}",
|
|
500
|
+
"data": { "name": "{% $states.context.Execution.Input.record.name %}", "order": "{% $states.context.Execution.Input.record.number %}" }
|
|
501
|
+
},
|
|
502
|
+
"End": true
|
|
503
|
+
}
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
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
|
+
|
|
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.
|
|
509
|
+
|
|
481
510
|
### app:piece
|
|
482
511
|
|
|
483
512
|
`piece`, `action`, `connection` and `props` name an action of a connector and its arguments. A save takes it, and a run fails it with `Piece.Error`. <gap>A piece step cannot run an action because its handler is not implemented.</gap>
|
|
@@ -13,6 +13,12 @@ state, step type and trigger, is in [the workflows reference](references/referen
|
|
|
13
13
|
not check a resource's name or its fields: `"resource": "contact_messages"` saves and fails when it runs.
|
|
14
14
|
3. Records steps act as the user who saved the workflow, with that user's roles now; mail always goes from the app's
|
|
15
15
|
own sender.
|
|
16
|
+
4. For a mail the app has a template for, use `app:mail.template` (Send email), not `app:mail.send`. Its
|
|
17
|
+
`template` argument in `list_workflow_types` names the app's templates, and the list's `templates` gives each one's
|
|
18
|
+
languages and the JSON Schema of its data. Pass `template`, `to`, an optional `locale` such as `nl`, and `data`
|
|
19
|
+
shaped as that schema: `{ "template": "welcome", "to": "{% $contact.email %}", "data": { "name": "{% $contact.name %}" } }`.
|
|
20
|
+
Data the schema refuses fails the step with `Mail.InvalidData`, naming each path. Use `app:mail.send` for a plain
|
|
21
|
+
mail whose subject and text the workflow writes itself.
|
|
16
22
|
|
|
17
23
|
## Sequence or data order
|
|
18
24
|
|