@protobase/cli 0.71.2 → 0.71.3
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { projectFiles, projectFunctions, projectJobs, projectNotifications, projectOptions, projectResources, projectWebhooks, projectWorkflows } from "./project-parts.js";
|
|
2
2
|
import { userTablesOn } from "./user-tables-config.js";
|
|
3
|
-
import { buildAppAuth, buildAuthenticator, checkCallsOptions, checkStatusOptions } from "@protobase/server/internal";
|
|
3
|
+
import { buildAppAuth, buildAuthenticator, checkCallsOptions, checkStatusOptions, workflowPlugins } from "@protobase/server/internal";
|
|
4
4
|
//#region src/config/build-project.ts
|
|
5
5
|
/**
|
|
6
6
|
* The app's own mailer, the default export of its auth/mailer.ts: what sign-in and the jobs (`context.mail`) both send
|
|
@@ -34,9 +34,9 @@ const projectAuth = async (config, { db, pool }, workflows) => {
|
|
|
34
34
|
...workflows && { workflowConnections: workflowConnectionsOf(workflows) }
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
|
-
/** The connections the workflows' plugins declare, which people connect accounts through at sign-in. */
|
|
37
|
+
/** The connections the workflows' plugins declare, the defaults' among them, which people connect accounts through at sign-in. */
|
|
38
38
|
const workflowConnectionsOf = (workflows) => ({
|
|
39
|
-
declared: (workflows.plugins
|
|
39
|
+
declared: workflowPlugins(workflows.plugins).flatMap(({ plugin }) => Object.entries(plugin.connections ?? {}).map(([name, declaration]) => ({
|
|
40
40
|
plugin: plugin.name,
|
|
41
41
|
name,
|
|
42
42
|
declaration
|
|
@@ -192,7 +192,7 @@ const projectWebhooks = async (config) => {
|
|
|
192
192
|
...ownerRoles && { ownerRoles }
|
|
193
193
|
};
|
|
194
194
|
};
|
|
195
|
-
const workflowPlugins = async (config, packages) => {
|
|
195
|
+
const workflowPlugins$1 = async (config, packages) => {
|
|
196
196
|
const project = config.sources.at(-1).files;
|
|
197
197
|
const fromPackages = await Promise.all(packages.map(async (name) => ({
|
|
198
198
|
plugin: (await project.package(name)).default,
|
|
@@ -209,7 +209,7 @@ const projectWorkflows = async (config) => {
|
|
|
209
209
|
if (!config.workflows) return void 0;
|
|
210
210
|
const { plugins: packages = [], ...options } = config.workflows;
|
|
211
211
|
const savedByRoles = await lastDefault(config, "workflows/saved-by-roles.ts");
|
|
212
|
-
const plugins = await workflowPlugins(config, packages);
|
|
212
|
+
const plugins = await workflowPlugins$1(config, packages);
|
|
213
213
|
return {
|
|
214
214
|
...options,
|
|
215
215
|
...savedByRoles && { savedByRoles },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.71.
|
|
3
|
+
"version": "0.71.3",
|
|
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.71.
|
|
47
|
-
"@protobase/layout": "0.71.
|
|
48
|
-
"@protobase/query": "0.71.
|
|
49
|
-
"@protobase/schema": "0.71.
|
|
50
|
-
"@protobase/server": "0.71.
|
|
51
|
-
"@protobase/ui": "0.71.
|
|
52
|
-
"@protobase/workflows": "0.71.
|
|
46
|
+
"@protobase/config": "0.71.3",
|
|
47
|
+
"@protobase/layout": "0.71.3",
|
|
48
|
+
"@protobase/query": "0.71.3",
|
|
49
|
+
"@protobase/schema": "0.71.3",
|
|
50
|
+
"@protobase/server": "0.71.3",
|
|
51
|
+
"@protobase/ui": "0.71.3",
|
|
52
|
+
"@protobase/workflows": "0.71.3",
|
|
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",
|
|
@@ -25,4 +25,5 @@ Graphs of steps the server runs along their edges, written in a language a model
|
|
|
25
25
|
- [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.
|
|
26
26
|
- [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.
|
|
27
27
|
- [Polling triggers](../reference/workflow-plugins.md#polling-and-webhook) (beta): A workflow starts once for each new item a plugin finds on a schedule, or at each time of a cron with `app:schedule`.
|
|
28
|
+
- [Incoming Gmail mail](../reference/workflow-plugins.md#incoming-gmail-mail) (beta): A workflow starts once for each new mail on a label of a connected Gmail mailbox that passes optional sender, recipient and subject filters, read with read-only access within about a minute; not yet checked against a real Google account.
|
|
28
29
|
- [Connected accounts](../reference/workflows.md#connecting-an-account) (beta): People connect their own accounts at other services through OAuth from the account page, see which workflows use each one, and MCP clients list them to bind. A workflow's steps and triggers sign in with one only once its owner turned the workflow on, with tokens encrypted and refreshed. Disconnecting deletes the token and revokes it at a provider that has a revocation endpoint, trying again for a few hours when the provider does not take it, and says which it did.
|
|
@@ -8,7 +8,7 @@ Add trigger and step types to workflows from a file of the app or a package, thr
|
|
|
8
8
|
Plugins add step types and record triggers. They also add polling and webhook triggers, which run within the limits named in their section, and connections that sign in to other services as an account a person connected, within the limits named under [Connections](#connections).
|
|
9
9
|
:::
|
|
10
10
|
|
|
11
|
-
A **workflow plugin** adds trigger and step types to an app's [workflows](workflows.md). Its types are named `<plugin>:<key>`, such as `acme:create_invoice`: a Task names a step type as its `Resource`, and a definition's `trigger` holds a trigger type with its input. The built-in types, `app:http`, `app:records.*`, `app:mail.send` and `app:record`, are a plugin like any other, written on this interface alone, so a plugin's types run, are checked and are listed exactly as they are.
|
|
11
|
+
A **workflow plugin** adds trigger and step types to an app's [workflows](workflows.md). Its types are named `<plugin>:<key>`, such as `acme:create_invoice`: a Task names a step type as its `Resource`, and a definition's `trigger` holds a trigger type with its input. The built-in types, `app:http`, `app:records.*`, `app:mail.send` and `app:record`, are a plugin like any other, written on this interface alone, so a plugin's types run, are checked and are listed exactly as they are. So is every [default plugin](#default-plugins), such as [incoming Gmail mail](#incoming-gmail-mail).
|
|
12
12
|
|
|
13
13
|
## Writing a plugin
|
|
14
14
|
|
|
@@ -46,6 +46,8 @@ export default definePlugin({
|
|
|
46
46
|
})
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
For a whole plugin to read, with a connection, a polling cursor, a refused token and bounded run input, see the Gmail plugin's source, `packages/workflow-plugins/src/gmail/` in the repository, which [the next section](#incoming-gmail-mail) describes.
|
|
50
|
+
|
|
49
51
|
`definePlugin` checks the plugin's names: its `name` is lowercase letters, digits and `_`, each type's key is lowercase words joined by `_` or `.`, and a type that names a connection must find it among the plugin's `connections`.
|
|
50
52
|
|
|
51
53
|
### Installing it
|
|
@@ -53,7 +55,7 @@ export default definePlugin({
|
|
|
53
55
|
- **The app's own:** the default export of `workflows/plugins/<name>.ts`, found by its path as jobs are. An [extension](config.md#extensions) adds its own from its folder.
|
|
54
56
|
- **From a package:** listed by name in [`workflows.plugins`](config/jobs-and-events.md#workflowsplugins), its default export the plugin. The package is a dependency of the app.
|
|
55
57
|
|
|
56
|
-
Two plugins of one name stop startup, naming both. A plugin is server code that runs with the app's rights, like the app's own code: load only plugins you trust. The interface's version is `pluginApi`, `1`; releases add optional keys to it and never break it.
|
|
58
|
+
Two plugins of one name stop startup, naming both. The exception is an app's own plugin named like a [default plugin](#default-plugins) other than `app`, which takes that default's place, such as one that pins its own version. A plugin is server code that runs with the app's rights, like the app's own code: load only plugins you trust. The interface's version is `pluginApi`, `1`; releases add optional keys to it and never break it.
|
|
57
59
|
|
|
58
60
|
## Step types
|
|
59
61
|
|
|
@@ -231,6 +233,57 @@ The token is blanked out of the step's logs, error and output, and out of the tr
|
|
|
231
233
|
|
|
232
234
|
An account connected through a provider of a connection's own never signs anyone in to the app, and never signs anyone up. <gap>A connection cannot be shared between people of an organization because shared connections are not implemented; each account is its owner's alone.</gap>
|
|
233
235
|
|
|
236
|
+
## Default plugins
|
|
237
|
+
|
|
238
|
+
Every app has these plugins besides `app`. A type that signs in is offered once the app can make its connection, as [Connections](#connections) says.
|
|
239
|
+
|
|
240
|
+
### Incoming Gmail mail
|
|
241
|
+
|
|
242
|
+
:::caution[Beta]
|
|
243
|
+
The Gmail plugin is tested against a stand-in of Gmail's API written to Google's published reference, but has not yet been checked against a real Google account. Mail starts its run within about a minute of arriving, not at once.
|
|
244
|
+
:::
|
|
245
|
+
|
|
246
|
+
`gmail:new_mail` starts one run for each new mail on a label of a connected Gmail mailbox. It reads the mailbox with read-only access, so a workflow it starts cannot send, change or delete mail through it.
|
|
247
|
+
|
|
248
|
+
To use it, turn on Google sign-in (`auth.socialProviders.google`) with `auth.encryptOAuthTokens`, and add the scope `https://www.googleapis.com/auth/gmail.readonly` to the app's Google consent screen (Data Access), as [Send mail from Gmail](../guides/send-from-gmail.md) does for its own scope. `gmail.readonly` is a restricted scope: until Google has verified the app, the consent screen warns that the app is unverified, and at most 100 people can connect. The person whose mailbox it is connects their Google account under **Connections** on the account page, binds that account in the workflow and turns the workflow on:
|
|
249
|
+
|
|
250
|
+
```json
|
|
251
|
+
{ "trigger": { "gmail:new_mail": { "label": "INBOX", "from": "@supplier.example", "subject": "invoice" } }, "connections": { "gmail:google": "<account id>" }, "stateMachine": { ... } }
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
| Input | What it does |
|
|
255
|
+
| --- | --- |
|
|
256
|
+
| `label` | The label to watch, by name or id. Default `INBOX`. A label the mailbox does not have fails the trigger, naming it. |
|
|
257
|
+
| `from` | Only mail whose sender's name or address contains this. |
|
|
258
|
+
| `to` | Only mail with a To or Cc recipient whose name or address contains this. |
|
|
259
|
+
| `subject` | Only mail whose subject contains this. |
|
|
260
|
+
|
|
261
|
+
Each filter ignores case, and a mail must pass every filter that is set. A mail without the value a filter reads, such as one with no sender, does not pass.
|
|
262
|
+
|
|
263
|
+
A run's input is the mail:
|
|
264
|
+
|
|
265
|
+
```json
|
|
266
|
+
{
|
|
267
|
+
"message_id": "18c2f0a9d3e4b5a6",
|
|
268
|
+
"thread_id": "18c2f0a9d3e4b5a6",
|
|
269
|
+
"from": { "name": "Ada", "address": "ada@example.com" },
|
|
270
|
+
"to": [{ "name": "Grace", "address": "grace@example.com" }],
|
|
271
|
+
"cc": [],
|
|
272
|
+
"subject": "Invoice 7",
|
|
273
|
+
"date": "2026-11-05T10:00:00.000Z",
|
|
274
|
+
"text": "Attached.",
|
|
275
|
+
"html": "<p>Attached.</p>",
|
|
276
|
+
"attachments": [{ "filename": "invoice-7.pdf", "content_type": "application/pdf", "size": 48213 }],
|
|
277
|
+
"truncated": false
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
- **The values** are as the mail states them, and `null` where it states none. `html` is the sender's own markup: treat it as untrusted wherever a workflow passes it on. Attachments come as their names, types and sizes, not their content.
|
|
282
|
+
- **Bounds:** each value has a fixed most length, such as 1,000 characters for the subject and 128 Ki characters for `text` and for `html`, and at most 50 recipients of each kind and 50 attachments. When the mail is still too large, `html` and then `text` are left out. A mail over about 7.5 MiB, whose answer from Gmail, in base64, is then over 10 MiB, or one too deeply nested to read, gives its headers alone, with `text`, `html` and `attachments` as `null`. A NUL character, or half of a character's surrogate pair, is left out, since the database cannot store it. `truncated` is `true` whenever something was cut short or left out.
|
|
283
|
+
- **When it starts:** from the moment the workflow is turned on. Mail already in the mailbox starts no run.
|
|
284
|
+
- **Polling:** every minute, the trigger reads the mailbox's history after where it stood, at most 90 mails a poll and the rest on the next poll, so each mail starts one run and none is skipped. Every mail it reads counts toward the 90, whether or not it passes the filters. Two triggers on one mailbox share Google's quota for that mailbox. When Google no longer keeps the history after the trigger's place, which can happen after a long time off, the trigger lists the label's mail since its last full read instead, 90 a poll, and then goes on from the history. <gap>A new Gmail mail cannot start its run at once because push notices from the mailbox are not implemented; the trigger polls every minute.</gap>
|
|
285
|
+
- **Sign-in:** the token is refreshed when it expires. When Google refuses the refresh, or refuses the token twice in a row, the trigger waits for the account's owner to connect it again, as [Polling and webhook](#polling-and-webhook) describes.
|
|
286
|
+
|
|
234
287
|
## The type list
|
|
235
288
|
|
|
236
289
|
[`list_workflow_types`](mcp.md#workflows) over MCP lists every step and trigger type the app has, built-in and plugin ones alike, as their plugins declare them: id, label, description, input and output schemas, errors, connection and a step type's cache advice (`choice`, `default` and `disclaimer`), with `available: false` and a reason for a type the app cannot run. A save, and `validate_workflow`, check a definition against the same list.
|