@protobase/cli 0.82.1 → 0.83.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/cli/package.js +1 -1
- package/package.json +8 -8
- package/skills/protobase/references/features/workflows.md +1 -0
- package/skills/protobase/references/reference/config/jobs-and-events.md +12 -1
- package/skills/protobase/references/reference/data-config.md +1 -1
- package/skills/protobase/references/reference/workflow-plugins.md +3 -2
- package/skills/protobase/references/reference/workflows.md +73 -3
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.83.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.83.0",
|
|
47
|
+
"@protobase/layout": "0.83.0",
|
|
48
|
+
"@protobase/query": "0.83.0",
|
|
49
|
+
"@protobase/schema": "0.83.0",
|
|
50
|
+
"@protobase/server": "0.83.0",
|
|
51
|
+
"@protobase/ui": "0.83.0",
|
|
52
|
+
"@protobase/workflows": "0.83.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",
|
|
@@ -13,6 +13,7 @@ Graphs of steps the server runs along their edges, written in a language a model
|
|
|
13
13
|
- [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.
|
|
14
14
|
- [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
15
|
- [Mail step](../reference/workflows.md#appmailsend) (beta): Sends mail, with files the run downloaded attached, from the app's own sender.
|
|
16
|
+
- [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.
|
|
16
17
|
- [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.
|
|
17
18
|
- [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.
|
|
18
19
|
- [Run status](../reference/workflows.md#run-status) (beta): The sidebar lists your workflows under Workflows, each marked by how its last 10 ended runs went, red, orange, green or gray, in a shape of its own; a workflow's page says why in words, links to the run, and offers Mark as resolved.
|
|
@@ -211,7 +211,7 @@ export default defineConfig(({ command }) => ({ webhooks: { allowPrivateAddresse
|
|
|
211
211
|
|
|
212
212
|
## workflows
|
|
213
213
|
|
|
214
|
-
- **Type:** `{ schema?: string; secrets?: string[]; allowPrivateAddresses?: boolean; plugins?: string[] }`
|
|
214
|
+
- **Type:** `{ schema?: string; secrets?: string[]; allowPrivateAddresses?: boolean; plugins?: string[]; storage?: { root?: string; endpoints?: string[] } }`
|
|
215
215
|
- **Default:** off; `{}` turns them on
|
|
216
216
|
|
|
217
217
|
Workflows that people and models make in the app, kept with their versions, runs and steps in a schema of the app's database that `protobase migration` writes, and run by the `workflows.segment` job. Records steps act as each workflow's last editor, with the roles they hold now, read from the app's sign-in; a project that signs people in otherwise exports its own, `async ({ id, tenant }) => [...]`, as the default of `workflows/saved-by-roles.ts`. See [Workflows](../workflows.md).
|
|
@@ -264,6 +264,17 @@ Packages of [workflow plugins](../workflow-plugins.md) the app runs, by package
|
|
|
264
264
|
export default defineConfig({ workflows: { plugins: ['@acme/workflow-plugin'] } })
|
|
265
265
|
```
|
|
266
266
|
|
|
267
|
+
## workflows.storage
|
|
268
|
+
|
|
269
|
+
- **Type:** `{ root?: string; endpoints?: string[] }`
|
|
270
|
+
- **Default:** off
|
|
271
|
+
|
|
272
|
+
Turns on [storage configurations](../workflows.md#storing-files), the named places workflows store files in. `root` is the one folder local configurations live inside, such as a mounted file share; it must not overlap a file provider's folder. Without it, only S3-compatible configurations are taken. `endpoints` are the `https://` origins an S3-compatible configuration may name; without them, it uses the S3 API's default host. The configurations' keys are encrypted, so the app needs `PROTOBASE_ENCRYPTION_KEY`.
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
export default defineConfig({ workflows: { storage: { root: './data/workflow-storage', endpoints: ['https://storage.example.com'] } } })
|
|
276
|
+
```
|
|
277
|
+
|
|
267
278
|
## notifications
|
|
268
279
|
|
|
269
280
|
- **Type:** `{ ui?: boolean; schema?: string; devices?: { table?: string; columns?: Record<string, string> }; history?: { table?: string; columns?: Record<string, string> } }`
|
|
@@ -276,7 +276,7 @@ The rollup's records have these fields, all read-only:
|
|
|
276
276
|
|
|
277
277
|
Records the source soft deleted are left out. The migration creates the table in the rollup's schema, with a unique index on `(bucket, by...)` and an index on `(group, bucket)` per group, so a list filtered on the bucket, on a group or on both passes the [scan guard](api.md#safety). It writes `rollups.<table>_refresh(from timestamptz)`, which recomputes every bucket from the one `from` falls in, in one statement: it upserts their counts and sums and deletes those left without records. `select rollups.readings_hourly_refresh(now() - interval '2 hours')` brings the example up to date. When the rollup's declaration changes, the migration drops its table and creates and fills it again. The table and function of a rollup the config no longer has stay; a migration of your own drops them, in a deploy after the one that stops reading them.
|
|
278
278
|
|
|
279
|
-
Only the database writes a rollup's rows: creates, updates and deletes are refused whatever its rules say, and it cannot have soft delete, a manual order, an author, a parent or `.openExisting()`. Its access is its own `.access()`: the source's rules do not reach it, so give it rules that let read only those who may see every record of a group. Its tenant is the source's, which is why `by` includes it. The server does not start while the source has its own `read` or `list` rule in `.access()`, whatever the rule returns, or while a role reads only some of the source's records that a bucket mixes with others: `.own` or `.team` while `by` does not include the source's owner field, or a role's filter on fields outside `by`. <gap>A time rollup cannot group by an optional field because a bucket key with empty parts is not implemented.</gap> <gap>A time rollup cannot roll up a resource whose reads follow a parent because applying the parent's access to buckets is not implemented.</gap> <gap>A time rollup cannot roll up a resource with its own `read` or `list` access rule because declaring the fields such a rule filters on is not implemented.</gap>
|
|
279
|
+
Only the database writes a rollup's rows: creates, updates and deletes are refused whatever its rules say, and it cannot have soft delete, a manual order, an author, a parent or `.openExisting()`. Its access is its own `.access()`: the source's rules do not reach it, so give it rules that let read only those who may see every record of a group. Its tenant is the source's, which is why `by` includes it. A field that is sensitive or has its own read rule, such as `.access({ read: roles.can('costs.read') })`, cannot be grouped by or measured, and one with its own read rule cannot be the rollup's `time`, since a bucket would show it to anyone who reads the rollup. The server does not start while the source has its own `read` or `list` rule in `.access()`, whatever the rule returns, or while a role reads only some of the source's records that a bucket mixes with others: `.own` or `.team` while `by` does not include the source's owner field, or a role's filter on fields outside `by`. <gap>A time rollup cannot group by an optional field because a bucket key with empty parts is not implemented.</gap> <gap>A time rollup cannot roll up a resource whose reads follow a parent because applying the parent's access to buckets is not implemented.</gap> <gap>A time rollup cannot roll up a resource with its own `read` or `list` access rule because declaring the fields such a rule filters on is not implemented.</gap>
|
|
280
280
|
|
|
281
281
|
The server does not start while a rollup's table or function is missing or out of date, with a message that names the rollup; the migration fixes that. It stops with an error, without writing anything, when the table already exists as the project's own.
|
|
282
282
|
|
|
@@ -78,6 +78,7 @@ What `run` gets, and nothing more:
|
|
|
78
78
|
| `fetch(url, init)` | The only way a plugin should send a request: see [Sending requests](#sending-requests). |
|
|
79
79
|
| `records` | `create`, `createMany`, `update`, `get` and `list` of the app's records, through the API as the user who saved the version the run runs, with the roles they hold now: their access rules, tenant, validation and write hooks apply. A refusal fails the step with `Records.Refused`. |
|
|
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
|
+
| `storage` | `put(configuration, path, stream, { name, type })` streams a file into a [storage configuration](workflows.md#storing-files) and returns the stored file; `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. |
|
|
81
82
|
| `mail` | `send(message)` from the app's own sender; `undefined` when the app sends no mail. |
|
|
82
83
|
| `connection` | `accessToken()` of the connection the step declares, or `undefined`. |
|
|
83
84
|
| `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. |
|
|
@@ -88,7 +89,7 @@ What `run` gets, and nothing more:
|
|
|
88
89
|
|
|
89
90
|
### Sending requests
|
|
90
91
|
|
|
91
|
-
`fetch` resolves the URL's host once, refuses it unless every address is public, and connects to the very address it checked, so a URL built from a run's data cannot reach the app's own network or a cloud metadata address. It follows no redirect: a 3xx comes back as it is, and a plugin that follows one calls `fetch` again with the new URL, whose host is checked in turn. It reads at most `maxBytes` of the answer's body as it comes, 10 MiB by default and at most, and never decodes a `Content-Encoding`, so a large or endless answer fails with `ResponseTooLargeError` instead of filling memory; a refused address fails with `AddressRefusedError`. [`workflows.allowPrivateAddresses`](config/jobs-and-events.md#workflowsallowprivateaddresses) lets it reach private addresses, for development and tests.
|
|
92
|
+
`fetch` resolves the URL's host once, refuses it unless every address is public, and connects to the very address it checked, so a URL built from a run's data cannot reach the app's own network or a cloud metadata address. It follows no redirect: a 3xx comes back as it is, and a plugin that follows one calls `fetch` again with the new URL, whose host is checked in turn. It reads at most `maxBytes` of the answer's body as it comes, 10 MiB by default and at most, and never decodes a `Content-Encoding`, so a large or endless answer fails with `ResponseTooLargeError` instead of filling memory; a refused address fails with `AddressRefusedError`. With `stream: true`, the answer comes back with its body unread and of any size, for a step that passes it on as a stream, such as into `storage.put`. [`workflows.allowPrivateAddresses`](config/jobs-and-events.md#workflowsallowprivateaddresses) lets it reach private addresses, for development and tests.
|
|
92
93
|
|
|
93
94
|
A plugin sends through `context.fetch`, never through the global `fetch`, Node's `http`, `https`, `net` or `tls`, or an HTTP client of its own: those are not guarded, so a workflow's data could make them reach the app's own network. The built-in plugins are held to this by the repository's boundary check, which fails on any of them.
|
|
94
95
|
|
|
@@ -120,7 +121,7 @@ lookup: {
|
|
|
120
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`. |
|
|
121
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. |
|
|
122
123
|
|
|
123
|
-
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, 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 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
125
|
|
|
125
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.
|
|
126
127
|
|
|
@@ -28,6 +28,8 @@ It adds five resources, over a `workflows` schema that [`protobase migration`](c
|
|
|
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. |
|
|
30
30
|
|
|
31
|
+
With `storage` it adds a sixth, `storage_configurations`, the places workflows [store files](#storing-files) in.
|
|
32
|
+
|
|
31
33
|
| `workflows` | |
|
|
32
34
|
| --- | --- |
|
|
33
35
|
| `schema` | The schema of its tables, for a database that has a `workflows` schema already. Default `workflows`. |
|
|
@@ -35,6 +37,7 @@ It adds five resources, over a `workflows` schema that [`protobase migration`](c
|
|
|
35
37
|
| `allowPrivateAddresses` | Lets the `app:http` step, and every plugin's `fetch`, reach private, loopback and link-local addresses, for development and tests. Default false. |
|
|
36
38
|
| `plugins` | Packages of [workflow plugins](workflow-plugins.md) to run, by name, beside the app's own in `workflows/plugins/<name>.ts`. |
|
|
37
39
|
| `trace` | Which runs keep a [trace](#traces): `all` (default), `failed` or `none`. Any other value stops startup. |
|
|
40
|
+
| `storage` | Turns on [storage configurations](#storing-files): `root`, the one folder local configurations live inside, and `endpoints`, the `https://` origins an S3-compatible configuration may name. Needs `PROTOBASE_ENCRYPTION_KEY`. |
|
|
38
41
|
|
|
39
42
|
Runs keep their traces and the files steps store in the app's `private` [file provider](files.md), local disk under `data/files/private` unless `PROTOBASE_FILES_PRIVATE` names an S3 bucket, so an app with workflows needs a files secret: `secret`, `files.secret`, `PROTOBASE_FILES_SECRET` or `PROTOBASE_SECRET`.
|
|
40
43
|
|
|
@@ -275,7 +278,7 @@ The built-in step types are the `app` plugin's, written on the same [plugin inte
|
|
|
275
278
|
|
|
276
279
|
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.
|
|
277
280
|
|
|
278
|
-
<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>
|
|
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>
|
|
279
282
|
|
|
280
283
|
### app:http
|
|
281
284
|
|
|
@@ -288,8 +291,9 @@ One request to a URL built at run time:
|
|
|
288
291
|
| `headers`, `query` | Objects of text values; `query` is added to the URL's query. |
|
|
289
292
|
| `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. |
|
|
290
293
|
| `response` | How the answer's body is read: `json` (default, parsed; empty is `null`), `text`, or `file`, kept as a file of the run. |
|
|
294
|
+
| `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`. |
|
|
291
295
|
|
|
292
|
-
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.
|
|
296
|
+
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.
|
|
293
297
|
|
|
294
298
|
### app:records
|
|
295
299
|
|
|
@@ -321,6 +325,70 @@ The mail goes from the app's own sender with the app's mailer; a workflow cannot
|
|
|
321
325
|
|
|
322
326
|
A file value is `{ uri, name, type, size }`, the handle to bytes in the app's storage that the API returns for a file field. `app:http` with `response: "file"` keeps the answer as a file of the run, in the `private` file provider under the run's id; steps take only the files of their own run, so a workflow cannot attach, send or store another file of the app's by naming its URI. <gap>A workflow cannot send or attach a file it read from a record because steps reading the app's other files is not implemented.</gap>
|
|
323
327
|
|
|
328
|
+
### Storing files
|
|
329
|
+
|
|
330
|
+
:::caution[Beta]
|
|
331
|
+
Changing a configuration does not move the files already in it, a run is not kept on the server that holds its local files, and an S3 configuration's keys are set through the API or MCP, not yet in the admin app's form.
|
|
332
|
+
:::
|
|
333
|
+
|
|
334
|
+
A value a run keeps is at most 256 KiB, so larger files, such as a 150 MB download, go to storage. A workflow names a **storage configuration**, such as `archive`, rather than where the file lives: a folder on the server, a file share mounted on it, or an S3-compatible bucket. Changing where a configuration points, from a bucket to a local folder say, changes the configuration alone; the workflows that name it stay as they are.
|
|
335
|
+
|
|
336
|
+
Turn them on with `storage` in `workflows`:
|
|
337
|
+
|
|
338
|
+
```ts
|
|
339
|
+
export default defineConfig({
|
|
340
|
+
workflows: { storage: { root: './data/workflow-storage', endpoints: ['https://storage.example.com'] } },
|
|
341
|
+
})
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
Their table, `workflows.storage_configurations`, comes with the next [`protobase migration`](cli.md#migration) after you turn them on, so an app that turns storage on later writes a migration then.
|
|
345
|
+
|
|
346
|
+
A configuration is a record of `storage_configurations`, which you create and change on its standard pages, linked from each workflow's page, through the API or over MCP:
|
|
347
|
+
|
|
348
|
+
| Field | |
|
|
349
|
+
| --- | --- |
|
|
350
|
+
| `name` | What workflows name it by: a lowercase letter, then lowercase letters, digits and `_`. Unique in the tenant. |
|
|
351
|
+
| `kind` | `local`, a folder under `root`, or `s3`, a bucket. |
|
|
352
|
+
| `dir` | For `local`: a folder inside `root`, such as `invoices/2026`. A path that would leave it, through `..` or a symlink, is refused. Without `root`, only `s3` configurations are taken. |
|
|
353
|
+
| `bucket`, `region` | For `s3`: the bucket and its region. |
|
|
354
|
+
| `endpoint` | For `s3` off the S3 API's default host: one of the `endpoints` the app lists. Its host must resolve to public addresses, which every step checks again. |
|
|
355
|
+
| `access_key_id`, `secret_access_key` | For `s3`: the bucket's keys, both required before a step can use it. They are stored encrypted, and nobody can read them again once saved, not even you; set new ones to change them. |
|
|
356
|
+
|
|
357
|
+
You set the keys with the API or the MCP `update_record` tool: `PATCH /api/v1/storage_configurations/<id>` with its `If-Match` and `{ "access_key_id": "...", "secret_access_key": "..." }`. <gap>An S3 configuration's keys cannot be set in the admin app's form because its editor for write-only fields is not implemented.</gap>
|
|
358
|
+
|
|
359
|
+
Steps store and read files with:
|
|
360
|
+
|
|
361
|
+
| Step type | Arguments | Result |
|
|
362
|
+
| --- | --- | --- |
|
|
363
|
+
| `app:storage.put` | `configuration`, `file`: a file of the run or a stored file, optional `path` | the stored file |
|
|
364
|
+
| `app:storage.get` | `file`: a stored file | a file of the run, up to 10 MiB, for steps that take one, such as mail attachments |
|
|
365
|
+
| `app:http` with `store` | `store: { configuration, path? }` | `{ status, headers, body }`, `body` the stored file |
|
|
366
|
+
|
|
367
|
+
A stored file is `{ configuration, node, path, name, type, size }`: the configuration, the server that holds it for a local one, and its path there, never a folder, bucket or key. A `path` is relative: letters, digits, `.`, `_` and `-` in segments split by `/`, none starting with `.`; any other fails the step with `Storage.InvalidArguments` before anything is stored. Without a `path`, a step stores under a path of its own in its run, the same each time the step is tried, so a step a crash made run again replaces its file rather than leaving a second one. A put is recorded; a get only reads.
|
|
368
|
+
|
|
369
|
+
```json
|
|
370
|
+
{
|
|
371
|
+
"Fetch": { "Type": "Task", "Resource": "app:http", "Arguments": { "url": "{% $states.context.Execution.Input.link %}", "store": { "configuration": "archive" } }, "Assign": { "report": "{% $states.result.body %}" }, "Next": "Read" },
|
|
372
|
+
"Read": {
|
|
373
|
+
"Type": "Task", "Resource": "app:storage.get", "Arguments": { "file": "{% $report %}" },
|
|
374
|
+
"Catch": [{ "ErrorEquals": ["Storage.NotFound"], "Next": "Gone" }],
|
|
375
|
+
"Next": "Mail"
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
A step reads the configuration it names afresh each time, as the user who saved the run's version, with the roles they hold now. It fails with:
|
|
381
|
+
|
|
382
|
+
| Error | |
|
|
383
|
+
| --- | --- |
|
|
384
|
+
| `Storage.NotFound` | No configuration of that name the workflow's last editor may read, which says nothing of one in another tenant or one they may not read; or the file is gone, which a `Catch` can take. |
|
|
385
|
+
| `Storage.Unavailable` | The configuration cannot be used as it is, such as an S3 one without keys or keys that no longer decrypt. |
|
|
386
|
+
| `Storage.Failed` | The store failed; the cause names its error code only. |
|
|
387
|
+
| `Storage.Full` | The store has no room left. |
|
|
388
|
+
| `Storage.TooLarge` | `app:storage.get` of a file over 10 MiB. |
|
|
389
|
+
|
|
390
|
+
A stored file is read from where its configuration points now. <gap>Changing a configuration cannot move the files already in it because moving stored files is not implemented.</gap> A local configuration's files are on one server. <gap>A run cannot be kept on the server that holds its local files because routing runs to a server is not implemented.</gap>
|
|
391
|
+
|
|
324
392
|
## Runs and their steps
|
|
325
393
|
|
|
326
394
|
A run starts when it is created, through the API or the admin app, in the same transaction: `POST /api/v1/workflow_runs` with `{ "workflow_id": "...", "input": { ... } }`. The input is at most 256 KiB as JSON and nests at most 64 levels; a larger one is refused with `input-too-large` or `input-too-deep` and no run. From the app's own code, such as a job or a write hook, `startWorkflow(db, { workflow, input, tenant, startedBy, trace })` from `@protobase/server` starts one in `db`'s transaction, so it starts when the caller's writes commit, or not at all. With a `key`, such as `orders:42`, a workflow runs once per key: a start with a key it has a run for already, in this transaction or another, starts nothing and returns that run's id.
|
|
@@ -425,6 +493,8 @@ The workflow resources take only [named grants](access.md#resources-that-need-na
|
|
|
425
493
|
| `workflow_runs.create` | Run a workflow, with any input. The API writes only the fields a caller reads, so it goes with `workflow_runs.read`, and the caller must read the workflow too. |
|
|
426
494
|
| `workflows.read`, `workflow_versions.read`, `workflow_runs.read`, `workflow_triggers.read` | Read workflows, their versions, runs and triggers, the runs' traces with every step's input and output included. |
|
|
427
495
|
| `workflow_resolutions.read` | Read who marked which workflow resolved and when. Marking one needs no grant of its own: whoever may change the workflow may. |
|
|
496
|
+
| `storage_configurations.read` | Let workflows you save use the [storage configurations](#storing-files), and see them. Their keys are never shown. |
|
|
497
|
+
| `storage_configurations.create`, `storage_configurations.update`, `storage_configurations.delete` | Make, change and delete storage configurations. |
|
|
428
498
|
|
|
429
499
|
```ts
|
|
430
500
|
defineRoles({
|
|
@@ -433,7 +503,7 @@ defineRoles({
|
|
|
433
503
|
})
|
|
434
504
|
```
|
|
435
505
|
|
|
436
|
-
All
|
|
506
|
+
All of them are scoped to the tenant like any resource with `.tenant()`. A run takes its workflow's tenant; a start of another tenant's workflow is refused as one of a workflow that is not there.
|
|
437
507
|
|
|
438
508
|
## How a run is run
|
|
439
509
|
|