@protobase/cli 0.99.16 → 0.100.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.
- package/dist/build/shell-chunks.js +18 -1
- package/dist/cli/package.js +1 -1
- package/package.json +8 -8
- package/skills/protobase/references/features/compatibility.md +4 -0
- package/skills/protobase/references/features/workflows.md +6 -1
- package/skills/protobase/references/reference/workflow-plugins.md +1 -1
- package/skills/protobase/references/reference/workflows.md +66 -11
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { uiEntry } from "../project/admin-app.js";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import path from "node:path";
|
|
1
4
|
//#region src/build/shell-chunks.ts
|
|
2
5
|
/**
|
|
3
6
|
* The npm package a module id belongs to, as the last `node_modules` segment of its path names it, since Bun's store
|
|
@@ -20,6 +23,10 @@ const isVendorModule = (id) => {
|
|
|
20
23
|
return name !== void 0 && !reactPackages.has(name) && name !== "lucide-react";
|
|
21
24
|
};
|
|
22
25
|
const preloadHelper = "\0vite/preload-helper.js";
|
|
26
|
+
const workflowsDir = path.resolve(path.dirname(createRequire(uiEntry).resolve("@protobase/workflows")), "..");
|
|
27
|
+
const slashed = (file) => file.replaceAll("\\", "/");
|
|
28
|
+
/** Whether a module is one of the workflow engine's, which go in the `workflows` chunk: inside its folder, not beside it. */
|
|
29
|
+
const isWorkflowsModule = (id, dir = workflowsDir) => slashed(id).startsWith(`${slashed(dir).replace(/\/$/, "")}/`);
|
|
23
30
|
/** The chunk name of a third-party module only lazy code loads: its package's, such as `lib-xyflow-react`. */
|
|
24
31
|
const libChunkName = (id) => `lib-${npmPackage(id).replace("@", "").replace("/", "-")}`;
|
|
25
32
|
/**
|
|
@@ -42,7 +49,17 @@ const shellCodeSplitting = { groups: [
|
|
|
42
49
|
name: libChunkName,
|
|
43
50
|
debugName: "lib",
|
|
44
51
|
test: isVendorModule
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "workflows-start",
|
|
55
|
+
test: (id) => isWorkflowsModule(id),
|
|
56
|
+
tags: ["$initial"],
|
|
57
|
+
priority: 1
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "workflows",
|
|
61
|
+
test: (id) => isWorkflowsModule(id)
|
|
45
62
|
}
|
|
46
63
|
] };
|
|
47
64
|
//#endregion
|
|
48
|
-
export { isReactModule, isVendorModule, libChunkName, npmPackage, shellCodeSplitting };
|
|
65
|
+
export { isReactModule, isVendorModule, isWorkflowsModule, libChunkName, npmPackage, shellCodeSplitting };
|
package/dist/cli/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.100.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": {
|
|
@@ -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.
|
|
47
|
-
"@protobase/layout": "0.
|
|
48
|
-
"@protobase/query": "0.
|
|
49
|
-
"@protobase/schema": "0.
|
|
50
|
-
"@protobase/server": "0.
|
|
51
|
-
"@protobase/ui": "0.
|
|
52
|
-
"@protobase/workflows": "0.
|
|
46
|
+
"@protobase/config": "0.100.0",
|
|
47
|
+
"@protobase/layout": "0.100.0",
|
|
48
|
+
"@protobase/query": "0.100.0",
|
|
49
|
+
"@protobase/schema": "0.100.0",
|
|
50
|
+
"@protobase/server": "0.100.0",
|
|
51
|
+
"@protobase/ui": "0.100.0",
|
|
52
|
+
"@protobase/workflows": "0.100.0",
|
|
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",
|
|
@@ -14,6 +14,10 @@ Apps written for other systems that keep working on Protobase, and moving their
|
|
|
14
14
|
- [Supabase Realtime](../reference/supabase-realtime.md) (beta): Database changes, broadcast and presence through supabase-js channels, private ones authorized by the policies on `realtime.messages`, broadcasts sent from a server without joining a channel, and broadcasts from the database with `realtime.send()` and `realtime.broadcast_changes()`, across [several processes](../reference/supabase-realtime.md#several-processes) serving one app.
|
|
15
15
|
- [Edge Functions](../guides/api-functions.md#functions-moved-from-supabase): Functions moved from Supabase answer at their old addresses.
|
|
16
16
|
|
|
17
|
+
## AWS Step Functions
|
|
18
|
+
|
|
19
|
+
- [Step Functions import](../reference/workflows.md#importing-from-step-functions) (beta): A JSONata state machine exported from AWS Step Functions saves and runs as a workflow as it is, and what does not run here, its service tasks included, is refused by name.
|
|
20
|
+
|
|
17
21
|
## Template paths
|
|
18
22
|
|
|
19
23
|
- [Paths and scopes](../reference/layouts.md#paths-and-scopes) (beta): Layout paths follow Mustache's context-stack lookup and Handlebars' path grammar: `../`, `this`, `./`, `@root`, `@index`, `@first` and `@last`, though `@root` cannot be read yet. Protobase differs in three ways: a placeholder is escaped for the string it lands in, such as a filter's quoted value, rather than for HTML; `@params` names a [page parameter](../reference/layouts.md#page-parameters), which a `SelectInput` sets; and a name no record around it has fails the build instead of drawing empty.
|
|
@@ -9,8 +9,13 @@ Graphs of steps the server runs along their edges, written in a language a model
|
|
|
9
9
|
- [Checked on save](../reference/workflows.md#reading-values-by-name) (beta): A definition that does not fit the language, has an edge to no step, reads a value nothing gives or leaves out an argument its step type needs is refused, naming the step and the field.
|
|
10
10
|
- [Workflow editor](../reference/workflows.md#the-editor) (beta): The admin app draws a workflow as a graph that lays itself out, to add, connect and remove steps of every trigger and step type of the app, its plugins' included, each with a form for its input beside the graph, with every problem the save would refuse shown on its step as it is edited.
|
|
11
11
|
- [One page per workflow](../reference/workflows.md#the-workflows-page) (beta): A workflow's focus page is its graph, with Add step, Test run, Runs and Publish beside it in a panel, so you build, test and debug without leaving it; in the sidebar, Workflows lists the workflows.
|
|
12
|
+
- [Pins and wires](../reference/workflows.md#the-workflows-page) (beta): A step's inputs and the values it gives are pins coloured by type; drag an output pin to an input to read that value there, and a wire that does not fit is refused, saying why.
|
|
13
|
+
- [Break and Make](../reference/workflows.md#the-workflows-page) (beta): Take an object apart into a pin for each field, such as a record's fields, or build one from a pin per field, with no extra step to run.
|
|
14
|
+
- [Pins or Simple](../reference/workflows.md#the-workflows-page) (beta): Draw the graph with every pin and wire, or with only the steps and the lines between them, and switch at any time; nothing saved changes.
|
|
15
|
+
- [Build on the graph](../reference/workflows.md#the-workflows-page) (beta): Click a step's handle to add a step right there, or drag from it to another step to connect them; the wheel and a pinch zoom the graph, and dragging pans it.
|
|
12
16
|
- [Branches, steps per item and retries](../reference/workflows.md#states) (beta): Choices, a step per item with their results merged, waits, and per-step retries, timeouts and error paths.
|
|
13
|
-
- [
|
|
17
|
+
- [Order from the data](../reference/workflows.md#execution-order-from-the-data) (beta): A workflow in data order runs each step once the steps it reads from have ended, steps that read nothing of each other at once, with a Condition on any step and skips that pass on; switch a workflow between data order and the States Language's own sequence in the editor.
|
|
18
|
+
- [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.
|
|
14
19
|
- [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.
|
|
15
20
|
- [Mail step](../reference/workflows.md#appmailsend) (beta): Sends mail, with files the run downloaded attached, from the app's own sender.
|
|
16
21
|
- [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.
|
|
@@ -63,7 +63,7 @@ Two plugins of one name stop startup, naming both. The exception is an app's own
|
|
|
63
63
|
| --- | --- |
|
|
64
64
|
| `label`, `description` | What the type list shows, to a person and to a model. |
|
|
65
65
|
| `input` | The JSON Schema of the Task's `Arguments`, checked before `run`: arguments that do not fit fail the step as `<errorPrefix>.InvalidArguments`, naming the field. |
|
|
66
|
-
| `output` | The JSON Schema of what `run` returns, for the type list. |
|
|
66
|
+
| `output` | The JSON Schema of what `run` returns, for the type list, which types the step's pins in the editor and what the save checks reading it. A property of an untitled object is a pin of its own, and an object with a `title` one pin a Break takes apart. `{ "x-record-of": "<argument>" }` is the record of the resource that argument names, and `{ "x-schema-of": "<argument>" }` the schema that argument holds, and `{ "x-one-or-many-of": "<argument>", "anyOf": [<one>, <list>] }` the one or the list as that argument holds an object or a list; in `input`, `"x-record-use": "write"` beside `x-record-of` types the fields a write takes. |
|
|
67
67
|
| `errorPrefix`, `errors` | The prefix of its error names, `Step` by default, and the errors it fails with by name, each with what it means. |
|
|
68
68
|
| `connection` | The connection it signs in with, by the name the plugin declares it under. |
|
|
69
69
|
| `cache` | Reuses the result of an identical earlier call: see [Caching results](#caching-results). Without it the engine looks up and keeps nothing for the type, unless a workflow forces it on. |
|
|
@@ -22,8 +22,8 @@ It adds five resources, over a `workflows` schema that [`protobase migration`](c
|
|
|
22
22
|
|
|
23
23
|
| Resource | |
|
|
24
24
|
| --- | --- |
|
|
25
|
-
| `workflows` | A name, a description and the definition
|
|
26
|
-
| `workflow_versions` | Every version of every definition as it was saved, with who saved it and when. Read-only. |
|
|
25
|
+
| `workflows` | A name, a description and the definition, in fields of its own: `state_machine`, `trigger`, `execution_order`, `connections` and `trace`. Each save that changes one of them is checked, and kept as the workflow's next version, saved by the caller. |
|
|
26
|
+
| `workflow_versions` | Every version of every definition as it was saved, its five fields together, with who saved it and when. Read-only. |
|
|
27
27
|
| `workflow_runs` | A run, started by creating it with `workflow_id`, an `input` and, if it says, its own `trace`, and a saved `version` to run another than the published one, or on a workflow that is off the one saved last, or with `rerun_of` to [re-run a failed run](#re-running-a-failed-run), and `replay: true` too to [replay a run](#replaying-a-run); it runs the version its workflow had then, and a re-run or a replay the input of the run it names. Its status, output, error, timing and trace file are written by the runner. |
|
|
28
28
|
| `workflow_triggers` | The trigger of each enabled workflow that has one besides `manual`: its type, status and last error. Read-only. |
|
|
29
29
|
| `workflow_resolutions` | Each time someone [marked a workflow resolved](#run-status), by whom and when. Created only. |
|
|
@@ -45,7 +45,17 @@ Records steps act as the user who saved the run's version, with the roles the pr
|
|
|
45
45
|
|
|
46
46
|
## The document
|
|
47
47
|
|
|
48
|
-
A
|
|
48
|
+
A workflow's definition is kept in fields of its own, saved together as one version:
|
|
49
|
+
|
|
50
|
+
| Field | |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| `state_machine` | The States Language with JSONata, as its specification writes it: in sequence order every state names where the run goes next. |
|
|
53
|
+
| `trigger` | What starts its runs, as [Triggers](#triggers) says. |
|
|
54
|
+
| `execution_order` | `sequence` (the default), the States Language's own order, or `data`, where [the data orders the states](#execution-order-from-the-data). Filterable. |
|
|
55
|
+
| `connections` | The account each connection of its types signs in with, as [Connecting an account](#connecting-an-account) says. |
|
|
56
|
+
| `trace` | Which of its runs keep a [trace](#traces). |
|
|
57
|
+
|
|
58
|
+
Every value in the state machine is JSON; a string written as `{% ... %}` is a JSONata expression, evaluated when the state runs, and keeps its value's type. The example below shows the trigger and the state machine as one document, `{ "trigger", "stateMachine" }`, the shape the runner and the check read them in.
|
|
49
59
|
|
|
50
60
|
```json
|
|
51
61
|
{
|
|
@@ -89,6 +99,44 @@ A definition is one JSON document: the workflow's trigger, and the state machine
|
|
|
89
99
|
|
|
90
100
|
The document holds no layout: the [editor](#the-editor) lays the graph out from its edges.
|
|
91
101
|
|
|
102
|
+
### Execution order from the data
|
|
103
|
+
|
|
104
|
+
:::caution[Beta]
|
|
105
|
+
A step skipped in a run is not in its trace yet, and the editor has no condition nodes yet: a Condition is written as an expression.
|
|
106
|
+
:::
|
|
107
|
+
|
|
108
|
+
With `execution_order` `data`, the state machine has no `StartAt` and its states no `Next` or `End`: a state runs once every state it reads from has ended, and states that read nothing of each other run at once, at most 20 of a run at a time.
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"QueryLanguage": "JSONata",
|
|
113
|
+
"States": {
|
|
114
|
+
"Rate": { "Type": "Task", "Resource": "app:http", "Arguments": { "url": "https://rates.example.com/eur" }, "Assign": { "rate": "{% $states.result.body %}" } },
|
|
115
|
+
"Stock": { "Type": "Task", "Resource": "app:http", "Arguments": { "url": "https://stock.example.com/42" }, "Assign": { "stock": "{% $states.result.body %}" } },
|
|
116
|
+
"Save": { "Type": "Task", "Resource": "app:records.update", "Arguments": { "resource": "products", "key": "42", "data": { "price": "{% $rate.value * 10 %}", "stock": "{% $stock.count %}" } } },
|
|
117
|
+
"Tell": { "Type": "Task", "Resource": "app:mail.send", "Condition": "{% $states.context.Steps.Save.Status = 'SUCCEEDED' %}", "Arguments": { "to": "ops@example.com", "subject": "Product 42 updated", "text": "Done" } }
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
- **What a state runs after:** each state whose variables it reads, and each whose status it reads as `$states.context.Steps.<state>`: `{ Status, Error, Cause }`, the status one of `SUCCEEDED`, `FAILED`, `TIMED_OUT` (its error was `States.Timeout`), `ABORTED` and `SKIPPED`. Each variable has one state that assigns it, and a state that would run after itself is refused.
|
|
123
|
+
- **Condition:** an expression a state runs under, evaluated once what it runs after has ended; false skips it. Choice and Succeed are not used in this order: a Condition decides, and the run ends once no state is left to run.
|
|
124
|
+
- **Skips pass on:** a state one of whose dependencies did not succeed is skipped, unless its Condition reads that dependency's `$states.context.Steps` entry, which takes the outcome in hand: a failure skips what depends on it unless a step says it handles it.
|
|
125
|
+
- **Order without data:** a Condition that reads the earlier state's status, such as Tell above, which runs only once Save succeeded.
|
|
126
|
+
- **Failures:** an uncaught failure fails the run at once, and the states running then take no step after the one they are in, as a failing Parallel branch stops the others. A catcher without `Next` keeps the run going: the state's status is `FAILED`, with its `Error` and `Cause`, and the catcher's `Output` and `Assign` take effect. `Retry` works as in sequence order. Any `FAILED` a state can read was caught, since an uncaught one ends the run.
|
|
127
|
+
- **The run's output:** the output of the states nothing reads from, by name, or that one state's alone. A Map's or a Block's states run in the workflow's order.
|
|
128
|
+
|
|
129
|
+
A workflow switches order in the editor (see [The editor](#the-editor)), or by saving its fields in the other order.
|
|
130
|
+
|
|
131
|
+
### Importing from Step Functions
|
|
132
|
+
|
|
133
|
+
:::caution[Beta]
|
|
134
|
+
- <gap>A JSONPath state machine cannot import because converting JSONPath to JSONata is not implemented.</gap>
|
|
135
|
+
- <gap>A state machine with a service task, the HTTP task (`arn:aws:states:::http:invoke`) included, a `Parallel` or a distributed Map cannot import because running them, or turning an HTTP task into an `app:http` step, is not implemented: write such a task with one of this app's step types, such as `app:http`.</gap>
|
|
136
|
+
:::
|
|
137
|
+
|
|
138
|
+
A JSONata state machine exported from AWS Step Functions saves and runs as it is, in sequence order: `create_workflow` over MCP takes it as `state_machine`, with a manual trigger unless one is given. Refused, each by name: a JSONPath state machine (`QueryLanguage` missing or `JSONPath`, or a state with `InputPath`, `Parameters`, `ResultSelector`, `ResultPath`, `OutputPath` or `ItemsPath`), every service task (`arn:aws:...`, the HTTP task, `.sync` and `.waitForTaskToken` included), Parallel, a distributed Map, `HeartbeatSeconds`, `Credentials` and a whole-run `TimeoutSeconds`.
|
|
139
|
+
|
|
92
140
|
### Triggers
|
|
93
141
|
|
|
94
142
|
`trigger` holds one key: `manual`, or a trigger type `<plugin>:<key>` with its input. The built-in ones are the `app` plugin's; a [workflow plugin](workflow-plugins.md) adds its own the same way, and `list_workflow_types` over MCP lists them all with their inputs.
|
|
@@ -192,7 +240,8 @@ The save is refused, naming each state and field, when the document does not fit
|
|
|
192
240
|
- a `Next`, `Default` or catcher names no state, a state is never reached, or a state name is used twice, Maps included;
|
|
193
241
|
- a Task names a step type the app does not have, or the state type is not one of Task, Choice, Pass, Map, Wait, Succeed and Fail;
|
|
194
242
|
- an expression does not parse, or reads anything but the names above: the state's input as JSONata's context (a bare field name, `$`, `$$`), `$states.input` outside an item's first state, `$states.context` but for the three reads above, a variable no state that can run before it assigns, or `$eval`;
|
|
195
|
-
- a limit below is passed
|
|
243
|
+
- a limit below is passed;
|
|
244
|
+
- an argument, or a field of an argument written as an object, is one read by name of a value whose type its step type does not take there, such as `{% $fetch.status %}`, a whole number, for a records step's text field: the types come from each type's input and output schemas, the trigger's and the steps' records typed by the resource they name.
|
|
196
245
|
|
|
197
246
|
The problem's `problems` lists them as `{ state, field, message }`, where a state inside a Map is named by its path, such as `Each/Total`. The document's JSON Schema is `definitionSchema` of `@protobase/workflows`, and `checkDefinition` runs the whole check.
|
|
198
247
|
|
|
@@ -259,7 +308,7 @@ A workflow's record page in the admin app, `/workflows/<id>`, is a [focus page](
|
|
|
259
308
|
A version can be published or looked at, not compared with another beyond a count of its changes, the version selector lists only the latest 100, the Runs panel the latest 20, and the graph has no undo.
|
|
260
309
|
:::
|
|
261
310
|
|
|
262
|
-
The bar under the breadcrumb holds what is live, the version shown, *Add step*, *Runs*, how the work stands, *Test run*, *Save* and *Publish*, with the rest behind "...": *Discard changes*, *Workflow details*, *Turn off* and *Delete*. The graph takes the rest of the page; the wheel
|
|
311
|
+
The bar under the breadcrumb holds what is live, the version shown, *Add step*, *Runs*, how the work stands, *Test run*, *Save* and *Publish*, with the rest behind "...": *Discard changes*, *Workflow details*, *Turn off* and *Delete*. The graph takes the rest of the page; the wheel and a pinch zoom it towards the pointer, and dragging its empty space with any mouse button pans it, with Shift-drag selecting a box; a trackpad's two-finger scroll zooms too. Choosing a step opens its form in the panel beside the graph, and the graph makes room. *Workflow details* leads to the workflow's standard form at `?standard=true`, with its name, description and published version and the Trigger, Runs and Versions tables.
|
|
263
312
|
|
|
264
313
|
- **Save and Publish.** *Save* makes a new version and changes nothing that is live, so a change can be tried first. *Publish* asks in the panel, says what changes and how many steps differ, warns about a version with no test run, and names the trigger it starts. With unsaved changes it saves them first, and a refused save stops there. *Turn off* stops the workflow; runs in progress stay on their version.
|
|
265
314
|
- **Versions.** *Version* chooses which saved version the graph shows, each marked as the latest and as live; it lists the latest 100. <gap>The version selector cannot offer a version older than the latest 100 because loading more of them into it is not implemented.</gap> Such a version still opens by its address. The latest version is the one you edit. An older one is read-only, with *Edit latest version* in the notice, and publishing it goes back to it. The version is in the address, `/workflows/<id>?version=<number>`, so a link opens it.
|
|
@@ -272,9 +321,13 @@ The bar under the breadcrumb holds what is live, the version shown, *Add step*,
|
|
|
272
321
|
|
|
273
322
|
A user who may read a workflow but not change it gets the same page, its fields and graph locked, without Save or Publish. On a mobile screen the bar holds what is live, *Runs* and *Test run*, or *Save* with unsaved changes, and the rest behind "..."; a step's form can be changed, and steps are added on a wider screen.
|
|
274
323
|
|
|
275
|
-
- **The graph lays itself out.** The trigger is on
|
|
276
|
-
- **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. 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.
|
|
277
|
-
- **
|
|
324
|
+
- **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.
|
|
325
|
+
- **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.
|
|
326
|
+
- **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*.
|
|
327
|
+
- **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.
|
|
328
|
+
- **Execution order.** "Run the steps from the data" or "in sequence" under "..." switches the draft's order. To data, each `Next` becomes what the state it names runs after, by its data or, where it reads none of it, by a Condition on the earlier state's status, so the states run in the same order; refused with a Choice, an error path to another state or a variable two states assign. To sequence, the states form one chain in an order every dependency keeps; refused with a Condition or a catcher without `Next`. In data order the graph has no execution handles: in Pins the wires order the steps, each step has an Only when pin (its Condition) first and a Step status pin last, and in Simple an arrow joins each pair of steps where one reads the other, dashed where it reads only the other's status; a step with a Condition shows an "only when" badge.
|
|
329
|
+
- **Pins or Simple.** *Pins* and *Simple* above the graph switch how it is drawn: Simple shows the steps and the lines between them alone, with every input edited in the step's form, where a wire made in Pins shows as the read it wrote. Both draw the same document, so switching changes nothing saved; the browser remembers the choice, Pins by default.
|
|
330
|
+
- **Connecting steps.** Drag from a step's execution handle to another step; a click or tap without a drag adds a step there instead. The first handle sets `Next`, a Choice's *When* handle adds a rule and its *Otherwise* handle sets `Default`, a Task's or Map's *On error* handle adds a catcher of `States.ALL`, and the trigger's handle sets `StartAt`. A step leads only to steps of its own machine, so an edge into or out of a Map is refused. The chosen step's form sets the same edges with menus: *Goes on to*, each rule's and catcher's *Then goes to*, and *Otherwise goes to*.
|
|
278
331
|
- **Removing.** Delete or Backspace removes the chosen step or edge, as does the form's *Remove step*. Removing a step removes the edges to it: a `Next` to it becomes `End`, and a rule, `Default` or catcher naming it goes. Removing the first step of a workflow or Map makes the first step left in it the first.
|
|
279
332
|
- **A step's form.** Choosing a step opens its form in the side panel beside the graph: its name, which renames every edge to it, then what its type takes. A Task's form has a field for each argument of its step type's input schema, the ones it needs marked, as listed under [Step types](#step-types) or by its plugin: one line of text for a string, one line for a number or `true` and `false`, a menu for an `enum`, names separated by commas for a list of strings, and JSON for anything else; a Choice's its rules and `Default`; a Map's `Items` and `MaxConcurrency`; a Wait's `Seconds`; a Pass's and a Succeed's `Output`; a Fail's `Error` and `Cause`. A field takes text, an expression (`{% ... %}`) or JSON; an emptied field is left out. *The step as JSON* edits every field of the step, such as `Retry`, `Assign` and `TimeoutSeconds`. The trigger's form picks among the app's triggers, its plugins' included, and draws a field for each input of its schema the same way, such as a record trigger's resource, `when` and `key`.
|
|
280
333
|
- **Problems on their step.** The editor runs the same check as a save on every change, and shows each problem on the step it names, as a count on its box and a list and a marked field in its form; a problem with the trigger or the first step shows on the trigger, and the bar counts them all, with the list in the panel. A field left to fill in is not a fault yet: a new step shows no red, and the bar says how many fields are left. Save, Test run and Publish then go to the first of them, which says so. A warning of the check, such as a [Wait after a Block](#blocks), shows on its step as a mark and in its form as something to check, and never stops a save. Until then the draft stays on this browser, through a reload. Saving writes the definition through the API, where the save hook checks it again: a definition with a problem is refused with the 400 above, whose `errors` hold each problem for the `definition` field, with its state and field in `params`.
|
|
@@ -321,8 +374,10 @@ One request to a URL built at run time:
|
|
|
321
374
|
| `method` | `GET` (default), `POST`, `PUT`, `PATCH` or `DELETE`. |
|
|
322
375
|
| `headers`, `query` | Objects of text values; `query` is added to the URL's query. |
|
|
323
376
|
| `body` | Text is sent as it is, a file value as its bytes with its type, any other value as JSON; a `GET` sends none. |
|
|
324
|
-
| `
|
|
325
|
-
| `
|
|
377
|
+
| `body_encoding` | `json` sends the body as JSON whatever it holds, a text as a JSON string, with `Content-Type: application/json` unless the headers give one. |
|
|
378
|
+
| `response` | How the answer's body is read: `json`, parsed (empty is `null`), `text`, or `file`, kept as a file of the run. Without it, by the answer's `Content-Type`: JSON for `application/json` and any `+json` type, text for `text/*` and other textual types (XML, JavaScript, YAML, TOML, NDJSON, form data), a file for any other type or none, and `null` for an empty body. |
|
|
379
|
+
| `body_schema` | The JSON Schema of the answer's body as it is read, such as `{ "type": "object", "properties": { "ip": { "type": "string" } } }`: a body that does not fit it fails the step with `Http.InvalidBody`, and the editor offers the body's fields by it. |
|
|
380
|
+
| `store` | `{ configuration, path? }`: streams the answer's body, of any size, into a [storage configuration](#storing-files), and gives the stored file as `body`. Takes no `response` or `body_schema`. |
|
|
326
381
|
|
|
327
382
|
A `GET` only reads; every other method is recorded. The result is `{ status, headers, body }`, without the cookies the answer sets. A status outside 2xx fails the step with `Http.Status`, whose cause names the status and holds at most the first 200 characters of the body, secrets blanked out first; a redirect is never followed. `Http.Network` is a request that got no answer. The step resolves the URL's host when it runs and refuses it with `Http.AddressRefused` unless every address is public, then connects to the very address it checked, so a URL built from a webhook's payload cannot reach the app's own network. It reads at most 10 MiB of the answer's body: a larger one fails the step with `Http.ResponseTooLarge`, rather than being cut short. With `store`, the body streams straight into the store, so its size is limited only by what the store takes, and the step is recorded, a `GET` too: a run taken up again keeps the stored file and does not fetch it again, from a link that may have expired by then.
|
|
328
383
|
|
|
@@ -335,7 +390,7 @@ A `GET` only reads; every other method is recorded. The result is `{ status, hea
|
|
|
335
390
|
| `app:records.get` | `resource`, `key` | the record |
|
|
336
391
|
| `app:records.list` | `resource`, optional `filter` (the API's filter syntax), `order_by`, `limit` | `{ records }` |
|
|
337
392
|
|
|
338
|
-
A get and a list only read; a create and an update are recorded. They go through the app's API as the user who saved the run's version, with the roles that user holds now in the run's tenant, so its access rules, tenant scope, validation and write hooks apply as they do to that user's own requests. Whoever may start a run (`workflow_runs.create`) thus has it do what the workflow's last editor may do; a workflow never does more. When that user holds no role any more, or the version was saved by the app's code, the step fails with `Records.Refused`, as it does for a refusal of the API, its status and message in the cause. A number for a decimal field is written as its text; a file field takes a file value the run keeps.
|
|
393
|
+
A get and a list only read; a create and an update are recorded. They go through the app's API as the user who saved the run's version, with the roles that user holds now in the run's tenant, so its access rules, tenant scope, validation and write hooks apply as they do to that user's own requests. Whoever may start a run (`workflow_runs.create`) thus has it do what the workflow's last editor may do; a workflow never does more. When that user holds no role any more, or the version was saved by the app's code, the step fails with `Records.Refused`, as it does for a refusal of the API, its status and message in the cause. A number for a decimal field is written as its text; a file field takes a file value the run keeps. Their records, and a record trigger's, are typed by the resource's fields, as the editor's pins and the save's check read them.
|
|
339
394
|
|
|
340
395
|
### app:mail.send
|
|
341
396
|
|