suppa-mcp-2 1.44.2 → 1.44.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/README.md CHANGED
@@ -725,6 +725,9 @@ process when someone opens it:
725
725
  - request and form flows take what the submission already carries (`formData`,
726
726
  `number`, `createdBy`) instead of selecting it again;
727
727
  - business rules are visible on the canvas, technical logic goes into one `code` node.
728
+ - **Settings and the Set node.** `$workflow.settings` is read in any expression, trigger
729
+ conditions included, with no read node; a Set «Config» holds per-flow constants;
730
+ settings are never state and never hold secrets (those are credentials).
728
731
  - **Publishing that survives the builder.** It writes through the API with the builder
729
732
  tab closed, verifies the draft by hash, then publishes and tests a live run.
730
733
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suppa-mcp-2",
3
- "version": "1.44.2",
3
+ "version": "1.44.3",
4
4
  "description": "MCP server for the Suppa platform (modern.suppa.me) — Tasks, Docs/Pages, Entities & Schema, Forms, Automations, and file attachments, with multi-tenant Google auth. Node port of PyPI suppa-mcp.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -33,7 +33,7 @@ Parameter shapes (triggers, conditions, switch outputs, approvals, links) are in
33
33
  - **Loop protection is keyed by workflow id.** A write from flow A never starts flow B of the same automation. A write from another automation does start it. So:
34
34
  - inside one automation, the flow that writes does its own follow-up (mark the request rejected, notify);
35
35
  - across automations, the same write runs twice. That is the classic duplicate notification.
36
- - **Settings live in the automation.** Put everything tenant-specific in `settings.<key>`: people, project and stage ids, BP switches, testMode. Each flow reads it with `getById AutomationWorkflow id: "={{ $workflow.id }}"` → `activeSettings`. Do not keep a separate settings record or select.
36
+ - **Settings live in the automation.** Put everything tenant-specific in `settings.<key>`: people, project and stage ids, BP switches, testMode. Every expression reads it directly, trigger conditions included: `={{ $workflow.settings.<key>.<name> }}`. No settings read node is needed, and no separate settings record or select. Details and limits are in «Settings and the Set node».
37
37
 
38
38
  ## Requests and form submissions: the trigger already holds the data
39
39
 
@@ -111,7 +111,53 @@ Someone who opens the automation should read the flow from the canvas alone. Eve
111
111
 
112
112
  - **Do not leave dangling ends by accident.** A free `false` / `rejected` / switch output must be intended. Say so in the description, or connect it.
113
113
  - **Size budget.** More than ~25 nodes or ~20 columns in one flow means it no longer reads at a glance. Move logic into a `code` node or drop decoration before splitting.
114
- - **Settings over literals.** Ids, people, stages and switches live in settings. The trigger filter is generated from them in the build.
114
+ - **Settings over literals.** Ids, people, stages and switches live in settings. The trigger filter reads them too (`"value": "={{ $workflow.settings.<key>.stages }}"`), so a change needs a republish, not a rebuild.
115
+
116
+ ## Settings and the Set node
117
+
118
+ Verified on modern-expo.test (2026-10-27, a throwaway probe automation):
119
+ - `$workflow.settings.*` resolves in any node's expressions and in trigger conditions;
120
+ - a production run sees the **published** settings: a draft change it ignored until the republish.
121
+
122
+ | Where a value lives | Use it for | How it is read |
123
+ |---|---|---|
124
+ | `settings.<key>` | Everything tenant-specific the whole automation shares: people, project / stage ids, switches, testMode. **The only place a trigger condition can read from** | `={{ $workflow.settings.<key>.<name> }}` in any expression. A `code` node has no `$workflow`, so pass it through the `set` before it |
125
+ | A `set` node «Config» right after the trigger | Constants and derived values local to one flow, including ones computed from settings (`={{ $workflow.settings.<key>.limit * 2 }}`) | `={{ $('A1.1 Config').first().json.<name> }}` |
126
+ | A dedicated directory entity (real relation fields) | Many record references, or references that must survive moving the automation between dev / stage / prod | A `suppa` read |
127
+ | Credentials | **Secrets.** Never in settings or a `set`: every value an expression produces lands in the run data, which anyone who can read the automation's runs can see | — |
128
+
129
+ **Settings: shape and limits**
130
+ - **A relation from settings is written like any relation, `{ id }`, and the expression must be the whole field.** A Suppa node passes `fields` to entity-builder as they are.
131
+
132
+ | Field type | Value |
133
+ |---|---|
134
+ | many-to-one | `"responsible": "={{ { id: $workflow.settings.<key>.responsibleId } }}"` |
135
+ | many-to-many, replaced | `"watchers": "={{ $workflow.settings.<key>.watchers }}"`, with settings holding `[{ "id": 5 }, { "id": 7 }]` |
136
+ | many-to-many, added or removed | the same, plus `merge` / `unmerge: ["watchers"]` on an update |
137
+ | enum (a relation in 2.0) | `{ id: <enumValueId> }`, never the value text |
138
+
139
+ - `={{ … }}` in the middle of text turns an object into the string `[object Object]`. This was verified: `"owner ={{ { id: 1 } }}"` gave `"owner [object Object]"`.
140
+ - A bare number instead of `{ id }` returns success and stores `null`.
141
+ - **An id in settings is a number in JSON, not a relation.**
142
+ - Nothing checks that the record exists. A deleted record leaves a dangling id.
143
+ - Ids differ between tenants and environments. Moving an automation between dev, stage and prod does not remap the ids inside settings.
144
+ - Fields of that record are **not** reachable through settings. `$workflow.settings.<key>.responsible.name` does not exist, and lazy loading works only for `$json` items. For a name, read the record (`getById`).
145
+ - Settings suit one or two stable records, such as a default assignee. For many references, or ones that must survive environment moves, use a directory entity with real relation fields.
146
+ - **One top-level key per process (`settings.itRequest`).** The platform keeps keys of its own next to yours (seen on test: `alertUserIds`, `fullRefresh`, `definitionKey` / `definitionVersion`; the engine also reads `rateLimit*`, `errorBreaker*` and `alertChannels` there). An update merges top-level keys, so resend your whole `settings.<key>` and never replace the object as a whole.
147
+ - `settings.variables` / `$vars` is not available yet: `typeof $vars` is `undefined` in a run. Keep user-facing configuration under your own key.
148
+
149
+ **The Set node «Config»: what it does and does not do**
150
+ - **It is not visible to trigger conditions.** They are checked before any node has run, so filters read settings only.
151
+ - **It must be on the path the run took.** `$('Config')` sees only nodes that ran in this run. On a branch that did not run, it is `undefined`, and no error is raised.
152
+ - **It reshapes the item.**
153
+ - Without `keepOnlySet`, the config fields join `$json` and travel on with the record.
154
+ - With `keepOnlySet: true`, the item becomes the config, and the trigger data is reachable only through `$('A1. Start…')`.
155
+ - **Changing a value needs a republish, as with settings.** The value is part of the published nodes. A test run sees the draft at once.
156
+
157
+ **Settings are not state.** Nothing a run does reaches the automation's published settings:
158
+ - A `set` changes only the items moving through the flow.
159
+ - A Suppa write to `AutomationWorkflow.settings` changes only the **draft**. entity-builder's `AutomationDraftGuardExtension` strips every write to `activeSettings` except the publish, and raises `hasUnpublishedChanges`. Production runs do not see the value, and a run already going keeps its snapshot. An automation that edits itself is a bad idea in any case.
160
+ - A counter or a «last processed» marker belongs in a record of its own entity, read and written by `suppa` nodes.
115
161
 
116
162
  ## Safe runs
117
163
 
@@ -144,7 +190,7 @@ Someone who opens the automation should read the flow from the canvas alone. Eve
144
190
  ## Optimize with measurements
145
191
 
146
192
  - `suppa_get_automation_run` gives per-node timings. Writes cost 150–500 ms each (create task, link, update); reads cost about 30 ms each, plus a node on the canvas. Reads of **the same entity** merge into one query (see «One read per entity per flow»). Reads of different entities stay separate nodes, because merging them through `code` hides what the flow reads.
147
- - **Idle runs** are the real waste. Filter in the trigger: `watchFields` plus `conditions` (for example `stage.id in [...]`), so moves that mean nothing start no run. Generate the id lists from settings in the build.
193
+ - **Idle runs** are the real waste. Filter in the trigger: `watchFields` plus `conditions` (for example `stage.id in [...]`), so moves that mean nothing start no run. Take the id lists from `$workflow.settings` in the condition value.
148
194
  - **A select that returns nothing ends the branch.** Guard optional lookups with an `if`, or fan out to the select and to a `merge` (append) so the flow continues.
149
195
  - A `code` node sees only `$json` / `$input`. Feed it from a `set` node that gathers `$('…')` values.
150
196
  - testMode: route every role to the test user, and send approvals to a **second** account. An approval whose approver started the run is auto-approved.
@@ -169,6 +215,10 @@ Follow `references/publishing.md`:
169
215
  | Guard selects against duplicates from your own other automation | Merge the automations, or let only one side write |
170
216
  | `if` true/false or approved/rejected drawn into one row "because same size" | Place by handle offset, detour above |
171
217
  | Publishing a draft saved in the builder UI | The UI drops expression `approvers` to `[]`. Rebuild from source |
218
+ | A `getById AutomationWorkflow` node to read settings | `={{ $workflow.settings.<key> }}` in the expression: one node and one query fewer. `lint-graph` notes it |
219
+ | A secret (token, password) in settings or a `set` | Credentials. Expression values are stored in run data that everyone who reads runs can see |
220
+ | A counter or «last processed» written into settings | Its own entity. A settings write changes only the draft |
221
+ | `"text ={{ { id: x } }}"` for a relation | Make the expression the whole field. In text, an object becomes `[object Object]` |
172
222
  | Editing settings partially | Updates merge top-level keys. Resend the whole `settings.<key>`, then republish |
173
223
  | Option key `constructor` in settings | The platform strips it. Look options up with `hasOwnProperty` |
174
224
  | A node reads `$('X')` where X runs on another branch or later | `undefined` at runtime, with no error. `lint-graph` catches it |
@@ -33,7 +33,7 @@ Several triggers in one automation are allowed. The run starts at the trigger th
33
33
 
34
34
  | Node | Parameters |
35
35
  |---|---|
36
- | `suppa` getById | `{ "action": "getById", "entityName": "AutomationWorkflow", "id": "={{ $workflow.id }}", "fields": {"id": true, "activeSettings": true} }` — the automation's own settings. |
36
+ | `suppa` getById | `{ "action": "getById", "entityName": "Users", "id": "={{ $('A1. Start…').first().json.createdBy.id }}", "fields": {"id": true, "fullName": true, "employees": {"department": {"title": true}}} }` — one record, related records nested in `fields`. Settings need no read node: `={{ $workflow.settings.<key> }}`. |
37
37
  | `suppa` select | `{ "action": "select", "entityName": "OrgEmployees", "limit": 50, "fields": {"id": true, "user": {"id": true}}, "conditions": {"operator": "and", "filters": [{"field": "id", "comparator": "in", "value": "={{ … }}"}]} }` — **0 rows ends the branch.** |
38
38
  | `suppa` insert / updateById | `{ "action": "updateById", "entityName": "Tasks", "id": "={{ … }}", "fields": {"stage": "={{ x != null ? { id: x } : null }}"}, "merge": ["watchers"] }` — relations are `{id}`. List fields are replaced unless named in `merge`. |
39
39
  | `set` | `{ "keepOnlySet": true, "assignments": [{"name": "request", "value": "={{ $('A1. Start: …').first().json }}"}] }` |
@@ -69,8 +69,10 @@ then read `instanceA.value.id ?? instanceA.id`.
69
69
  - `={{ js }}` evaluates. Text and several `={{ }}` mix inside one string.
70
70
  - Reference a node as `$('Node name').first().json`. `$json` is the incoming item.
71
71
  - A trigger or `suppa` item lazily loads `$json.<field>` that was not selected (the item carries `meta.entity`).
72
+ - `$workflow.settings.<key>` is the published settings in any expression, trigger conditions included; a test run sees the draft. A `code` node has no `$workflow` — pass values through a `set`.
72
73
  - Settings are stored as jsonb:
73
74
  - object keys get re-sorted, so keep an explicit order array;
74
75
  - a key named `constructor` is stripped;
75
76
  - an update merges top-level keys only, so resend the whole `settings.<key>`;
76
- - flows read `activeSettings`, so republish after any change.
77
+ - production runs read the published settings, so republish after any change.
78
+ - Never put a secret in settings or a `set`: expression values are kept in run data. Use credentials.
@@ -125,6 +125,16 @@ export const lint = (graph, { previous } = {}) => {
125
125
  else if (/formData/.test(text) && fieldKeys.length && fieldKeys.every((k) => k === 'id')) add('WARN', `${n.id}: reads only id of a record picked in the form — formData already has { id }`);
126
126
  }
127
127
  if (n.type === 'suppa' && p.entityName === 'AutomationWorkflow' && p.action === 'getById' && !/\$workflow\.id/.test(String(p.id))) add('WARN', `${n.id}: reads another automation's settings by literal id — keep settings in this automation ($workflow.id)`);
128
+ else if (n.type === 'suppa' && p.entityName === 'AutomationWorkflow' && p.action === 'getById') add('NOTE', `${n.id}: reads this automation's settings — every expression has them as $workflow.settings.<key>, trigger conditions included; drop the node`);
129
+ // An object literal inside a string that is not ONE whole expression arrives as "[object Object]".
130
+ // Only an object: an array of plain values in text joins as "a,b" (`[a, b].join('-')` is fine), and a
131
+ // string holding two expressions is text even when it starts with ={{ and ends with }}.
132
+ const objectInText = (v) => {
133
+ if (typeof v !== 'string' || !/=\{\{\s*\(?\s*\{/.test(v)) return false;
134
+ return !(v.split('={{').length === 2 && /^=\{\{[\s\S]*\}\}$/.test(v.trim()));
135
+ };
136
+ const values = n.type === 'set' ? (p.assignments || []).map((a) => [a.name, a.value]) : n.type === 'suppa' ? Object.entries(p.fields ?? {}) : [];
137
+ for (const [k, v] of values) if (objectInText(v)) add('WARN', `${n.id}: ${k} builds an object inside text — it arrives as "[object Object]"; make ={{ … }} the whole value`);
128
138
  if (n.type === 'triggerEntity') {
129
139
  const upd = (p.events || []).some((e) => /update/.test(e));
130
140
  if (upd && !(p.watchFields || []).length) add('WARN', `${n.id}: update trigger without watchFields starts a run on every edit`);
@@ -178,6 +188,24 @@ export const lint = (graph, { previous } = {}) => {
178
188
  if (t && typeof t === 'object' && !('uk' in t)) add('WARN', `${n.id}: ${key} has no uk — notifications carry the users' language next to en`);
179
189
  }
180
190
  }
191
+ // Settings values land in run data that anyone reading runs can see: secrets go to credentials.
192
+ // Matched on whole words of the key, so apiToken / webhookSecret / API_KEY are caught and
193
+ // secretaryId / tokenizerMode are not; only a filled string can be a secret.
194
+ const secretLike = (key) => {
195
+ const words = key.replace(/([a-z0-9])([A-Z])/g, '$1 $2').toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
196
+ return words.some((w, i) => /^(password|passwd|secret|token|apikey|privatekey)s?$/.test(w) || (/^(api|private)$/.test(w) && words[i + 1] === 'key'));
197
+ };
198
+ const secretKeys = [];
199
+ const walk = (v, path) => {
200
+ if (!v || typeof v !== 'object') return;
201
+ for (const [k, x] of Object.entries(v)) {
202
+ const at = path ? `${path}.${k}` : k;
203
+ if (secretLike(k) && typeof x === 'string' && x !== '') secretKeys.push(at);
204
+ walk(x, at);
205
+ }
206
+ };
207
+ walk(graph.settings, '');
208
+ if (secretKeys.length) add('WARN', `settings hold what looks like a secret (${secretKeys.join(', ')}) — expression values are kept in run data; use credentials`);
181
209
  if (previous) {
182
210
  const now = new Set(nodes.map((n) => n.id));
183
211
  for (const n of previous.nodes ?? []) if (n.type === 'approval' && !now.has(n.id)) add('WARN', `approval ${n.id} («${n.name}») is published now and missing from the new graph — runs waiting there cannot continue; keep its id, or check status:"waiting" runs before publishing`);