@protobase/cli 0.87.1 → 0.88.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/doctor/page-shapes.js +4 -2
- package/package.json +8 -8
- package/skills/protobase/references/features/composed-pages.md +2 -0
- package/skills/protobase/references/features/workflows.md +1 -0
- package/skills/protobase/references/features/your-own-code.md +1 -1
- package/skills/protobase/references/reference/blocks.md +40 -0
- package/skills/protobase/references/reference/custom-components.md +17 -0
- package/skills/protobase/references/reference/layouts.md +10 -2
- package/skills/protobase/references/reference/mcp.md +1 -1
- package/skills/protobase/references/reference/ui-config.md +1 -1
- package/skills/protobase/references/reference/workflow-plugins.md +1 -1
- package/skills/protobase/references/reference/workflows.md +34 -3
package/dist/cli/package.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { configFilter, configSort, sortText } from "./shape-filters.js";
|
|
2
2
|
import { listSort } from "./view-shapes.js";
|
|
3
|
-
import { walkTree } from "@protobase/layout";
|
|
3
|
+
import { threadSort, walkTree } from "@protobase/layout";
|
|
4
4
|
//#region src/doctor/page-shapes.ts
|
|
5
5
|
const listing = [
|
|
6
6
|
"RecordRow",
|
|
@@ -8,10 +8,12 @@ const listing = [
|
|
|
8
8
|
"Table",
|
|
9
9
|
"CardRow",
|
|
10
10
|
"RecordCard",
|
|
11
|
-
"Stat"
|
|
11
|
+
"Stat",
|
|
12
|
+
"Thread"
|
|
12
13
|
];
|
|
13
14
|
const text = (value) => typeof value === "string" ? value : void 0;
|
|
14
15
|
const blockSort = (node, model, view) => {
|
|
16
|
+
if (node.type === "Thread") return configSort(model, threadSort(String(node.props.time)));
|
|
15
17
|
const given = configSort(model, text(node.props.sort));
|
|
16
18
|
if (given) return given;
|
|
17
19
|
return node.type === "RecordRow" || node.type === "RecordCards" ? listSort(model, view) : void 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.88.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.
|
|
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.88.1",
|
|
47
|
+
"@protobase/layout": "0.88.1",
|
|
48
|
+
"@protobase/query": "0.88.1",
|
|
49
|
+
"@protobase/schema": "0.88.1",
|
|
50
|
+
"@protobase/server": "0.88.1",
|
|
51
|
+
"@protobase/ui": "0.88.1",
|
|
52
|
+
"@protobase/workflows": "0.88.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",
|
|
@@ -8,6 +8,7 @@ Pages of your own, built from blocks in a JSX layout.
|
|
|
8
8
|
- [Layout checks](../reference/layouts.md#what-a-layout-may-hold): The build refuses a layout with code, unknown props or unknown fields, and names the file and place.
|
|
9
9
|
- [Conditions](../reference/layouts.md#conditions): Part of a page shows only while a condition on a record or a count holds.
|
|
10
10
|
- [App addresses](../reference/layouts.md#addresses): Links to lists, records, create forms and pages are typed addresses that can carry filters and prefilled values.
|
|
11
|
+
- [Component fallbacks](../reference/custom-components.md#fallbacks): A custom component declares what a client that cannot draw it shows instead, or nothing, and the web shows it too when the component is missing or throws.
|
|
11
12
|
- [Per-user pages](../reference/layouts.md#access): Each user gets the page without the parts, fields and actions they cannot use.
|
|
12
13
|
- [Layout blocks](../reference/blocks.md#layout): Pages, responsive grids, cards and links.
|
|
13
14
|
- [Full-width pages](../reference/blocks.md#page): A page fills the whole area beside the sidebar instead of a centred column, for a dashboard with many blocks.
|
|
@@ -15,6 +16,7 @@ Pages of your own, built from blocks in a JSX layout.
|
|
|
15
16
|
- [Record rows](../reference/blocks.md#recordrow): A sideways row of cards for a filter, favorites or saved searches, with a count and new-record marks.
|
|
16
17
|
- [Record cards](../reference/blocks.md#recordcards): Full-width cards with fields and buttons, stacked or in a carousel.
|
|
17
18
|
- [Chart block](../reference/blocks.md#chart): Counts, sums or averages by value or by date, as bars, lines or a donut, and over time split by a second field.
|
|
19
|
+
- [Conversations](../reference/blocks.md#conversation): A chat declared in the layout: a thread of a resource's messages under each sender's name and time, following new ones as they arrive, and a box that sends one as the signed-in user.
|
|
18
20
|
- [Buttons and forms](../reference/blocks.md#behaviour): Buttons for named actions, and create or edit forms in a dialog.
|
|
19
21
|
- [Settings block](../reference/blocks.md#settings): Each person's own settings from a resource with one record per person, saved as they change, with defaults until the first save.
|
|
20
22
|
- [Users block](../reference/blocks.md#users): User management on any page: find users, set roles, block them and invite by email.
|
|
@@ -29,6 +29,7 @@ Graphs of steps the server runs along their edges, written in a language a model
|
|
|
29
29
|
- [Record triggers](../reference/workflows.md#apprecord) (beta): A workflow starts once for each record that becomes ready, at once or when a time in it comes, read as the user who saved the enabled version.
|
|
30
30
|
- [Triggers turned on while the app runs](../reference/workflows.md#turning-a-trigger-on) (beta): Publishing a saved version registers its trigger on every server process, and turning the workflow off stops it, with no restart; a save goes live only once it is published.
|
|
31
31
|
- [Workflow plugins](../reference/workflow-plugins.md) (beta): A file of the app or a package adds trigger and step types through the same public interface the built-in types use.
|
|
32
|
+
- [Blocks](../reference/workflows.md#blocks) (beta): build your own step from other steps. A block runs once and is cached by what it reads, so a workflow that reaches it again, in this run or another, reuses its result, such as a file fetched from a link that expires.
|
|
32
33
|
- [Step cache](../reference/workflow-plugins.md#caching-results) (beta): A plugin's step reuses the result of an identical earlier call from any run or workflow, as its plugin decides, while secrets always come in with their current value; a workflow can force it on, and the graph marks a step forced on against its plugin's advice.
|
|
33
34
|
- [Guarded requests for plugins](../reference/workflow-plugins.md#sending-requests) (beta): A plugin's requests reach only public addresses, follow no redirect and read at most 10 MiB.
|
|
34
35
|
- [Webhook trigger](../reference/workflows.md#appwebhook) (beta): A workflow starts from a signed call to a URL of its own, limited in size and rate.
|
|
@@ -6,7 +6,7 @@ React components, field types, pages and handlers of your own, loaded as plugins
|
|
|
6
6
|
|
|
7
7
|
- [Custom components](../reference/custom-components.md#components): Your own React components used by name in layouts, reading data under the user's access.
|
|
8
8
|
- [Custom list displays](../reference/custom-components.md#list-displays): Draw a list with your own component while the list page keeps loading, filters, search and paging.
|
|
9
|
-
- [Custom record sections](../reference/custom-components.md#record-sections): Your own component on a record page, beside its sections.
|
|
9
|
+
- [Custom record sections](../reference/custom-components.md#record-sections): Your own component on a record page, beside its sections, with sections to show instead where it cannot be drawn.
|
|
10
10
|
- [Custom record cards](../reference/custom-components.md#record-cards): Draw each card with your own component, with the built-in card as the fallback.
|
|
11
11
|
- [Custom field types](../reference/plugins.md#field-types): Register how a kind of value is shown and edited, and pick it per field in a view.
|
|
12
12
|
- [Custom create pages](../reference/custom-components.md#create-pages): Replace a resource's create form with your own page, such as a booking flow.
|
|
@@ -339,6 +339,46 @@ Counts, sums or averages of the records that match `filter`, per value of a fiel
|
|
|
339
339
|
|
|
340
340
|
Each value takes its colour from the view's `valueColors`, else an enum value's place among its values, from the [chart tokens](theme.md#tokens). A chart whose field the user cannot read is left out of their page, and a field it cannot group or add up stops the server at startup.
|
|
341
341
|
|
|
342
|
+
## Conversation
|
|
343
|
+
|
|
344
|
+
A chat declared in the layout like any other block: a `Thread` lists the messages of a resource and a `Composer` beneath it sends one, so [`/meta`](api.md#meta-and-openapi-per-caller) describes the conversation and every client can draw it, with no component of the app's own.
|
|
345
|
+
|
|
346
|
+
```tsx
|
|
347
|
+
<Card title="General">
|
|
348
|
+
<Thread resource="messages" filter="room = 'general'" sender="author_id" time="sent_at" text="body" />
|
|
349
|
+
<Composer resource="messages" field="body" values={{ room: 'general' }} placeholder="Message General" />
|
|
350
|
+
</Card>
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
A message resource marks its sender with [`.author()`](data-config.md#resource), which every create sets to the signed-in user, so a message is never sent in someone else's name.
|
|
354
|
+
|
|
355
|
+
### Thread
|
|
356
|
+
|
|
357
|
+
The latest messages that match `filter`, oldest first, each under its sender's name and the time it was sent, with a line between days and a sender's next message that day drawn under the first. **Load earlier messages** at the top reads the ones before. The thread opens at the newest message and scrolls in a box of its own, so it follows what arrives while the reader is at the end and keeps their place when they scrolled back, until their own message arrives; new messages come in with the app's [live updates](live.md), and screen readers announce them politely. It is left out of the page of a user who cannot read its sender, time or text.
|
|
358
|
+
|
|
359
|
+
| Prop | |
|
|
360
|
+
| --- | --- |
|
|
361
|
+
| `resource`, `filter` | Which messages. `resource` is required. |
|
|
362
|
+
| `sender` | Who wrote each message: a relation, named as the record it points at, or a text field. Required. |
|
|
363
|
+
| `time` | When each was sent: a date or timestamp field the API can sort by, which orders them. Required. |
|
|
364
|
+
| `text` | The message. Required. |
|
|
365
|
+
| `limit` | How many of the latest it shows at first, and how many each **Load earlier messages** adds; default 50. |
|
|
366
|
+
| `title`, `description`, `actions` | The heading; no card is drawn around the thread, so it can sit in a `Card` with its composer. |
|
|
367
|
+
| `empty` | Text while there are no messages. |
|
|
368
|
+
| `span` | Width in a grid. |
|
|
369
|
+
|
|
370
|
+
### Composer
|
|
371
|
+
|
|
372
|
+
A text box that grows with its text: Enter or the send button creates a record of `resource` with the text in `field` and the `values`, and Shift+Enter starts a new line. The text stays in the box until the server took it, so a message it refuses is still there to send again, under the reason. It is not shown to a user who may not create a record of `resource` or write its fields.
|
|
373
|
+
|
|
374
|
+
| Prop | |
|
|
375
|
+
| --- | --- |
|
|
376
|
+
| `resource` | Where a message is created. Required. |
|
|
377
|
+
| `field` | The writable text field the message goes in. Required. |
|
|
378
|
+
| `values` | Sent with every message, such as the room or the parent record's key. |
|
|
379
|
+
| `placeholder` | The box's text while empty. |
|
|
380
|
+
| `span` | Width in a grid. |
|
|
381
|
+
|
|
342
382
|
## Behaviour
|
|
343
383
|
|
|
344
384
|
### Action
|
|
@@ -76,6 +76,17 @@ A component that shows markdown, such as a chat message, uses `Markdown` from `@
|
|
|
76
76
|
|
|
77
77
|
`protobase build` fails when the config declares a component that `protobase.ui.tsx` does not export, naming it; while you work, `protobase dev` draws a warning in its place. A component a plugin provides is declared with the plugin's name, `component('DraftOrders', { plugin: 'sales-tools' })`, and the build does not look for it in `protobase.ui.tsx`. A component that throws while drawing shows a warning in its own place, not a blank app. The object form, `defineUi({ components: { OrdersPerDay } })`, still works, and a name given both ways must be the same component.
|
|
78
78
|
|
|
79
|
+
### Fallbacks
|
|
80
|
+
|
|
81
|
+
A client that cannot draw a component, such as a native app without React or the admin app without the plugin that provides it, draws the component's fallback in its place. Declare it with `component()`, as elements or `[]` to draw nothing:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
export const SeatChart = component('SeatChart', { fallback: <Progress label="Seats" value="seats_used" max="plan.seats" /> })
|
|
85
|
+
export const Confetti = component('Confetti', { fallback: [] })
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The admin app draws the fallback too when the component is missing or throws while drawing; `protobase dev` also shows the warning above it. Without a fallback, the warning stands in the component's place, as above. A [record section](#record-sections) takes `fallback` in `l.custom`.
|
|
89
|
+
|
|
79
90
|
### Fields and resources in props
|
|
80
91
|
|
|
81
92
|
A prop that names a field is a field reference, `fieldRef('plan.name')` from `@protobase/layout`, read from the record around the element or the resource its `resource` prop names. The component gets the plain name (`'plan.name'`), and the names are checked when the server starts. A `resource` prop names a resource the way a block's does.
|
|
@@ -140,6 +151,12 @@ export const CustomerRepairs = ({ limit }: { limit: number }) => {
|
|
|
140
151
|
|
|
141
152
|
A list that should stay live polls: `useList('repairs', { refetchInterval: 5000 })` refetches every 5 seconds. It is TanStack Query's `refetchInterval`, so it also takes `false` to stop, or a function of the query, and pauses while the tab is in the background.
|
|
142
153
|
|
|
154
|
+
`fallback` gives what shows in the section's place, its title included, where the component cannot be drawn: sections and related tables in the main column, sidebar maps in the sidebar, or `[]` for nothing. `/api/meta` sends it with what the user cannot see left out, as [fallbacks](#fallbacks) of composed pages. <gap>A sidebar section cannot fall back to sections or related tables because drawing those in the sidebar is not implemented.</gap>
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
l.custom(CustomerRepairs, { title: 'Earlier repairs', props: { limit: 5 }, fallback: [l.section('Customer', [r.customer_id])] })
|
|
158
|
+
```
|
|
159
|
+
|
|
143
160
|
## Full-area record pages
|
|
144
161
|
|
|
145
162
|
A view can make a component the whole record page with [`.record({ component })`](ui-config.md#full-area-record-pages). It gets the record from `useLayoutRecord()`, as a record section does, and fills the area beside the sidebar and under the top bar, where the page does not scroll: a list in it scrolls in a box of its own with `min-h-0 flex-1 overflow-y-auto`, and what follows the list stays at the bottom. It links to the record's standard page, which keeps the form, the related records, Edit and Delete:
|
|
@@ -45,6 +45,14 @@ Every element compiles to `{ type, props, children }`, and a custom component al
|
|
|
45
45
|
|
|
46
46
|
Children are elements and text. `null`, `undefined` and booleans render nothing and numbers become text, as in React, so `{isBeta && <Card />}` and `.map()` over a constant list work. Fragments are flattened. An element may be a prop value too: `actions={<Action name="cancel" />}` or a list of them.
|
|
47
47
|
|
|
48
|
+
A custom component declared with a [fallback](custom-components.md#fallbacks) carries it on each of its elements as `fallback`, elements and text like children, or `[]` to draw nothing:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{ "type": "SeatChart", "props": {}, "children": [], "custom": true, "fallback": [{ "type": "Progress", "props": { "label": "Seats", "value": "seats_used", "max": "plan.seats" }, "children": [] }] }
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
A client that cannot draw the component, such as one without React, draws the fallback instead, and the checks read it like the rest of the tree.
|
|
55
|
+
|
|
48
56
|
## What a layout may hold
|
|
49
57
|
|
|
50
58
|
A prop is a string, a finite number, a boolean, `null`, or an array or plain object of those (elements included). It is JSON in the end, so the rules are checked twice:
|
|
@@ -56,7 +64,7 @@ Behaviour comes from [named actions](#named-actions); React code from [custom co
|
|
|
56
64
|
|
|
57
65
|
## Data
|
|
58
66
|
|
|
59
|
-
`Stat`, `RecordCard`, `Table`, `CardRow`, `RecordRow` and `
|
|
67
|
+
`Stat`, `RecordCard`, `Table`, `CardRow`, `RecordRow`, `RecordCards` and `Thread` read records of a `resource`. `filter` is AIP-160 and `sort` AIP-132, exactly as the list API's `filter` and `order_by`, so a filter that works in the list's URL works here.
|
|
60
68
|
|
|
61
69
|
A `RecordCard` (its first match) and each card of a `CardRow` hold a **record**. Inside one, `Field`, `Progress`, `Stat field`, `Show`, `Action` and `ModalForm mode="edit"` work on that record, and a `RecordCard`'s header `actions` do too. A field name may follow relations: `company_id.city` is the city of the record's company, fetched like the record page fetches it and cached.
|
|
62
70
|
|
|
@@ -133,4 +141,4 @@ Every block reads the regular API with the user's token, so the access rules app
|
|
|
133
141
|
- `ModalForm` needs create or update permission and keeps only the fields they may write;
|
|
134
142
|
- an `Action` missing from their view of the resource is left out, and so is a `Show` that names something they cannot see.
|
|
135
143
|
|
|
136
|
-
Custom components are kept: they get only their props, and fetch through the same API.
|
|
144
|
+
Custom components are kept: they get only their props, and fetch through the same API. A custom component's fallback loses what the user cannot use like the rest of the tree, and a fallback left with nothing is sent as `[]`, so a client still draws nothing in the component's place.
|
|
@@ -107,7 +107,7 @@ In an app with [workflows](workflows.md), the endpoint also offers tools to find
|
|
|
107
107
|
| `list_workflow_types` | The step types a Task names as its `Resource` and the triggers a definition holds, built-in and [plugin](workflow-plugins.md) ones alike, each by id with its label, description, input as JSON Schema and, when the type declares one, its output, the errors a step fails with, and whether the app can run it. |
|
|
108
108
|
| `list_workflows` | A page of the workflows the person may read, newest change first, without their definitions: `filter` on `name`, `page_size` (20 by default, at most 100) and `page_token`. |
|
|
109
109
|
| `get_workflow` | One workflow with its whole definition and its ETag. |
|
|
110
|
-
| `validate_workflow` | Checks a `definition`, or a workflow's `id` with an `edit` of its saved definition, as a save checks it, and saves nothing: `{ valid: true }`, or `{ valid: false, problems }`. A record trigger is checked against the resources and fields the person may read, so a resource they cannot read is not a resource of the app. |
|
|
110
|
+
| `validate_workflow` | Checks a `definition`, or a workflow's `id` with an `edit` of its saved definition, as a save checks it, and saves nothing: `{ valid: true }`, or `{ valid: false, problems }`. A valid one may come with `warnings` in the same shape, which a save goes through with, such as a [Wait after a Block](workflows.md#blocks); `create_workflow` and `update_workflow` return them with what they saved. A record trigger is checked against the resources and fields the person may read, so a resource they cannot read is not a resource of the app. |
|
|
111
111
|
| `get_workflow_run` | A run's status, input, output, error and cause, with its steps in the order they ran, each with its state, scope, try, status, input, output, assigned variables, logs, error and cause; `state` reads one state's steps, a page of 20 by default. |
|
|
112
112
|
| `list_connections` | The person's own [connected accounts](workflows.md#connecting-an-account), by each connection the app's plugins declare: its key and label, and each account's `id`, scopes and `needs_sign_in`. A definition's `connections` binds an account by its `id`. It returns no token, and no one else's accounts. |
|
|
113
113
|
| `create_workflow` | Creates a workflow from its `name`, `description` and `definition`, and returns its `id`, `version` and ETag. |
|
|
@@ -659,7 +659,7 @@ export const repairsView = filtered
|
|
|
659
659
|
| `l.tab(title, items)` | A tab holding main-column items; a view's tabs show as one strip on the read view and the form. See [Tabs](#tabs). |
|
|
660
660
|
| `l.sidebar(fields, { when? })` | A summary card beside it, read-only, each value on one line, cut off with an ellipsis when it does not fit and shown whole on hover. The record's created and updated times show in a Details card below it, but for those the summary lists. `when` also takes a [condition](#form-and-read-view). |
|
|
661
661
|
| `l.related(title, { ... })` | A table or cards of the records of another resource that point at this one, in the main column. See [Related records](#related-records). |
|
|
662
|
-
| `l.custom(Component, { title?, props?, sidebar?, when? })` | A [custom component](custom-components.md#record-sections) where it is listed: in the main column under `title`, or with `sidebar: true` as a sidebar card. |
|
|
662
|
+
| `l.custom(Component, { title?, props?, sidebar?, when?, fallback? })` | A [custom component](custom-components.md#record-sections) where it is listed: in the main column under `title`, or with `sidebar: true` as a sidebar card. `fallback` shows in its place where it cannot be drawn. |
|
|
663
663
|
| `l.map(title, { latitude, longitude, zoom?, sidebar?, when? })` | A map with a pin at the record's position, in the main column or with `sidebar: true` as a sidebar card. See [Maps](#maps). |
|
|
664
664
|
| `l.chart(title, { resource, field, at, series, range?, help?, when? })` | Line graphs of numbers of the records that point at this one, such as a machine's samples, over the last hour, day or week. See [Charts of related records](#charts-of-related-records). |
|
|
665
665
|
| `l.gallery(title, { image?, photos?, when? })` | The record's photos as tiles, opening a lightbox. See [Galleries](#galleries). |
|
|
@@ -121,7 +121,7 @@ lookup: {
|
|
|
121
121
|
| `key` | What a call's key covers. `reads` (default): only the input values `run` read, everything it serialised, listed or handed to `fetch` counting as read. `input`: the whole input. A function of the input: its value, as JSON; one that throws or gives nothing leaves the call uncached. Under `reads`, a value read only after `run` returned is not in the key, so a type that reads its input in a callback later uses `input`. |
|
|
122
122
|
| `actsAs` | `records`, as the person who saved the version, and `mailbox`, as the person who turned it on: the services a cached call may act through, each adding that person to the key. |
|
|
123
123
|
|
|
124
|
-
Two calls share a result only when their keys match and they act as the same people: the run's tenant always; the saver and the enabler where `actsAs` lists them; and the account the version binds to the type's connection, with the person who turned it on. The app reads these from the run, never from the step. A cached call of a type with a connection checks the connection before it looks up the cache, as its `accessToken()` does, so once the run may no longer use the account, the call throws its `not_connected` `ConnectionError` rather than return an earlier result, and the step fails with `States.TaskFailed`, the name a `Catch` matches. A call that used `records` or `mailbox` without listing them, or touched the run's files, which are the run's alone, or storage, runs as always and is not kept. Only a call that succeeded with a result is kept, at most 256 KiB of it as the run records it, so secrets are blanked out. Each type keeps at most 1,000 results per tenant, and the ones that expire soonest go first. A cache that cannot be read within two seconds or written leaves the step to run without it.
|
|
124
|
+
Two calls share a result only when their keys match and they act as the same people: the run's tenant always; the saver, with the roles they hold now, and the enabler where `actsAs` lists them, so a change of the saver's roles makes earlier results ones that no longer match, and a saver with no role gets and keeps none; and the account the version binds to the type's connection, with the person who turned it on. The app reads these from the run, never from the step. A cached call of a type with a connection checks the connection before it looks up the cache, as its `accessToken()` does, so once the run may no longer use the account, the call throws its `not_connected` `ConnectionError` rather than return an earlier result, and the step fails with `States.TaskFailed`, the name a `Catch` matches. A call that used `records` or `mailbox` without listing them, or touched the run's files, which are the run's alone, or storage, runs as always and is not kept. Only a call that succeeded with a result is kept, at most 256 KiB of it as the run records it, so secrets are blanked out. Each type keeps at most 1,000 results per tenant, and the ones that expire soonest go first. A cache that cannot be read within two seconds or written leaves the step to run without it.
|
|
125
125
|
|
|
126
126
|
A workflow forces the cache on with `Cache: true` on its Task, even for a type without `cache` or with a hidden one. A type without `cache` then keys on its whole input and on every person a step can act as, and keeps a result for an hour; a type with `cache` keeps its own `ttl`, `key`, `use` and `actsAs`. A Task with `Cache: false` never uses it.
|
|
127
127
|
|
|
@@ -207,6 +207,7 @@ A save refuses a Task that leaves out an argument its step type needs, as [the e
|
|
|
207
207
|
| `Choice` | Goes to the `Next` of the first of its `Choices` whose `Condition` is true, else to its `Default`; with neither it fails with `States.NoChoiceMatched`. A rule may carry its own `Output` and `Assign`. |
|
|
208
208
|
| `Wait` | Waits `Seconds`, or until a `Timestamp` (ISO 8601), as a number or an expression. |
|
|
209
209
|
| `Map` | Runs its `ItemProcessor` once per item of `Items`, at most `MaxConcurrency` at once (0, the default, means the most, 20); its result is the items' outputs in order. |
|
|
210
|
+
| `Block` | Runs its `Processor` once as a run of its own on its `Arguments`, and keeps the result for `Cache.Ttl`, as [Blocks](#blocks) says; `Retry` and `Catch` as a Task. |
|
|
210
211
|
| `Succeed` | Ends the run, or the Map item, with its `Output`. |
|
|
211
212
|
| `Fail` | Ends it as failed with its `Error` and `Cause`. |
|
|
212
213
|
|
|
@@ -216,6 +217,37 @@ A state's output is its `Output`, else its result (a Task or Map) or the input i
|
|
|
216
217
|
|
|
217
218
|
A failing Task or Map fails with an error name: a step type's own, such as `Http.Status`, `States.Timeout` when it ran past its timeout, `States.TaskFailed` for any other error it threw, and `States.QueryEvaluationError` for an expression that did not evaluate or ran past its limits. The first retrier whose `ErrorEquals` names it tries the state again after `IntervalSeconds` (default 1), times `BackoffRate` (default 2) for each earlier retry, up to `MaxDelaySeconds`; `MaxAttempts` counts the retries after the first try (default 3, 0 for none). Without `Retry` a failure is not retried. Once no retry is left, the first catcher that names it goes on to its `Next`; without one the run fails. `States.ALL` names every error but `States.DataLimitExceeded` and `States.Runtime`, which end the run even where a retrier or catcher names them.
|
|
218
219
|
|
|
220
|
+
### Blocks
|
|
221
|
+
|
|
222
|
+
:::caution[Beta]
|
|
223
|
+
<gap>Two runs that reach a block with the same key at the same moment cannot share one run of it, because joining a block's run already under way is not implemented.</gap> Each of them runs the block.
|
|
224
|
+
:::
|
|
225
|
+
|
|
226
|
+
A block wraps steps into one step that runs once while what it reads stays the same. Its steps run as a run of their own, and its result is kept for a time you set, so a workflow that reaches it again, in this run or another, gets that result without running them. Use it for work that must not be repeated, such as fetching a file from a link that expires and storing it: once stored, the stored file is what counts.
|
|
227
|
+
|
|
228
|
+
```json
|
|
229
|
+
"Keep file": {
|
|
230
|
+
"Type": "Block",
|
|
231
|
+
"Arguments": { "url": "{% $states.context.Execution.Input.url %}" },
|
|
232
|
+
"Processor": {
|
|
233
|
+
"StartAt": "Download",
|
|
234
|
+
"States": {
|
|
235
|
+
"Download": { "Type": "Task", "Resource": "app:http", "Arguments": { "url": "{% $states.context.Execution.Input.url %}", "store": { "configuration": "archive" } }, "End": true }
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
"Cache": { "Ttl": "1 day" },
|
|
239
|
+
"Assign": { "file": "{% $states.result %}" },
|
|
240
|
+
"Next": "Mail"
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
- **What it reads.** `Arguments` is the block's input. Its steps read it as `$states.context.Execution.Input`, and secrets by name; they never read the variables around the block. A variable a step inside assigns stays inside. The block's result is its last step's output, which its `Output` and `Assign` read as `$states.result`.
|
|
245
|
+
- **When it runs again.** The block is keyed by the values of its input that its steps read and by the secrets they read, together with its steps as they are written. So a changed value that only a later step reads runs it again, and a value none of them reads does not. `Cache.Key`, an expression, keys it on its value instead. `Cache.Ttl` is how long a result serves, as seconds or text such as `10 minutes`, `1 hour` or `2 days`, at most 30 days; a definition without a valid one is refused. A result is kept under the run's tenant, the version's last editor with the roles they hold now, the person who turned it on and the accounts it binds, so another run reuses it only when it acts as the same people, and none is reused once the last editor's roles change or while they hold none. A result that is empty is kept too.
|
|
246
|
+
- **What is never kept.** A secret: a result that holds a secret's value is not kept, so the next visit runs the block again, and a block reached after a secret it reads changed runs again too. `Arguments` may not hold a secret, since the block's run keeps its input; read it inside the block by name. A result is reused only while the accounts its steps sign in with can still be used.
|
|
247
|
+
- **Its own run.** A block's run has its own trace and limits. Its output, like every value a run keeps, is at most 256 KiB; larger data goes through a [storage configuration](#storing-files). On the run's page, the Block step links to the run that gave its result, the earlier one when the result was reused, and that page marks the block's steps from its own trace. Open it to read each step, replay it by itself, or go back to the run that started it. A failed block fails the Block step with the block run's error, which `Retry` and `Catch` take; each try starts a new run of the block. A run waits for its block's run and goes on once that ends.
|
|
248
|
+
- **Building one.** In the editor, *Add step* offers *Block*, which comes with one step inside; with the block or one of its steps chosen, *Add step* adds inside it, as for For each.
|
|
249
|
+
- **A Wait after it.** When a state reads, after a Wait, a variable a Block set before that Wait, the check warns on that state that what the block fetched may have expired by then. The editor shows the warning on the step and in its form, and MCP clients get it in `warnings`; a save goes through with it.
|
|
250
|
+
|
|
219
251
|
## The editor
|
|
220
252
|
|
|
221
253
|
A workflow's record page in the admin app, `/workflows/<id>`, is a [focus page](ui-config.md#focus-pages): the graph fills the page, and everything you do to it happens beside it. It saves the same document the API saves. A new workflow asks for its name and opens here with no steps and the step picker open. In the admin app's sidebar, Workflows is the only entry, with the workflows listed under it by their [run status](#run-status): a workflow's versions, runs, steps and trigger are on its page, and their resources and API stay as they are.
|
|
@@ -244,7 +276,7 @@ A user who may read a workflow but not change it gets the same page, its fields
|
|
|
244
276
|
- **Connecting steps.** Drag from a step's handle to another step, or tap one handle and then the other: the bottom 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*.
|
|
245
277
|
- **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.
|
|
246
278
|
- **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`.
|
|
247
|
-
- **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. 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`.
|
|
279
|
+
- **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`.
|
|
248
280
|
|
|
249
281
|
A save also refuses a Task that leaves out an argument its step type needs, such as `app:http` without `url`, unless its `Arguments` is one expression, whose value is known only when it runs. A user who may read a workflow but not change it sees the same graph and forms, locked. <gap>The editor cannot undo a single change because an undo history is not implemented.</gap> The editor reads the app's types from `GET /api/workflows/types`, `client.workflowTypes()` of `@protobase/client`: the same list `list_workflow_types` gives over MCP, `{ step_types, triggers }`, which only a user who may read workflows gets. A type the app cannot run, such as one that signs in through a connection whose OAuth client the app does not set, is not offered, and the check refuses it with the reason; a stored trigger of such a type, or of a type the app does not have, shows its type and input, read-only. The boxes, their accessible names and a run's step headings name each type by the label the list gives it, such as *Shout* for `acme:shout`.
|
|
250
282
|
|
|
@@ -278,8 +310,6 @@ The built-in step types are the `app` plugin's, written on the same [plugin inte
|
|
|
278
310
|
|
|
279
311
|
A step's call either changes the world, such as mail sent, a record written or a `POST`, or only reads, such as a `GET`, a record read or a list, as its type declares. A call that changes the world is **recorded**: its checkpoint is saved before the run goes on, with its result and the time it was fetched, so a run taken up again does not make it again. A call a crash cut off before its checkpoint was saved can happen again, as [How a run is run](#how-a-run-is-run) says. A read is done again when a crash comes before the next checkpoint.
|
|
280
312
|
|
|
281
|
-
<gap>An author cannot wrap steps in a block that runs once, cached by what it reads, with a run and trace of its own, because blocks are not implemented.</gap>
|
|
282
|
-
|
|
283
313
|
### app:http
|
|
284
314
|
|
|
285
315
|
One request to a URL built at run time:
|
|
@@ -534,6 +564,7 @@ Every limit fails closed: a run or step that passes one fails, rather than going
|
|
|
534
564
|
| Steps of one run, every try and item counted | 50,000; beyond, the run fails with `States.Runtime`. |
|
|
535
565
|
| The input, output and variables of a step, and a Map's items' outputs together | 256 KiB each, as JSON; beyond, the step fails with `States.DataLimitExceeded`, whose cause gives the size. Keep large data in a store and pass a reference. |
|
|
536
566
|
| A step's logs | 100 lines of 1,000 characters; more lines are left out with a last line saying how many. |
|
|
567
|
+
| Blocks | 4 nested in one another at most; 1,000 runs of blocks started by one run. |
|
|
537
568
|
| A run's input | 256 KiB as JSON, 64 levels deep. |
|
|
538
569
|
| An answer `app:http` reads, a file a run keeps | 10 MiB. |
|
|
539
570
|
| A Wait | 366 days, by `Seconds` or `Timestamp`. |
|