suppa-mcp-2 1.42.4 → 1.42.6
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/LICENSE +21 -21
- package/README.md +1 -1
- package/dist/auth.js +56 -12
- package/dist/cli/flags.js +21 -0
- package/dist/server.js +43 -4
- package/dist/tools/automation.js +68 -20
- package/dist/tools/entity.js +67 -38
- package/dist/utils.js +24 -0
- package/package.json +1 -1
- package/skills/suppa-entity-code/references/registration.md +274 -274
- package/skills/suppa-entity-code/references/seeds.md +173 -173
- package/skills/suppa-entity-code/references/v1-mapping.md +102 -102
- package/skills/suppa-entity-code/templates/entity.template.ts +125 -125
- package/skills/suppa-entity-code/templates/seed.template.ts +61 -61
- package/skills/suppa-entity-code/templates/tabular-part.template.ts +101 -101
- package/skills/suppa-form-v2/scripts/widget-code.mjs +449 -449
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Andrii Herasymchuk
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Andrii Herasymchuk
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ All variables are optional — the server works out of the box and authenticates
|
|
|
89
89
|
| `SUPPA_LANG` | `en` | Language (`en` / `uk`) |
|
|
90
90
|
| `SUPPA_LANGS` | (auto) | Languages a multi-language title/Name is written into. When unset, resolved from the platform: the languages the tenant has enabled (`SystemPreferences.availableLanguages`, what the builder UI reads), else the language keys of existing entity titles, falling back to `en,uk`. Only the 24 `Localizations` language columns are kept, and `en` is always included. Set e.g. `en,uk` to force it. |
|
|
91
91
|
| `SUPPA_TZ` | `Europe/Kyiv` | Timezone, sent as `X-Timezone`. Must be an IANA name (`Europe/Kyiv`, `UTC`): the platform refuses an offset such as `+03:00` on every request, so an invalid value falls back to the default with a warning on stderr. |
|
|
92
|
-
| `SUPPA_MCP_LOGIN_PORT` | `8080` | Local
|
|
92
|
+
| `SUPPA_MCP_LOGIN_PORT` | `8080` | Local port of the sign-in page (listens on 127.0.0.1 and [::1]). Another port works only once `http://localhost:<port>` is in the Google OAuth client's Authorized JavaScript origins — ask an admin first |
|
|
93
93
|
| `SUPPA_MCP_HOME` | `~/.suppa-mcp` | Directory for the tenant registry |
|
|
94
94
|
| `SUPPA_HTTP_TIMEOUT` | `60` | Per-request timeout, seconds |
|
|
95
95
|
| `SUPPA_MCP_DEBUG` | (off) | `1` logs each request line to stderr |
|
package/dist/auth.js
CHANGED
|
@@ -676,7 +676,7 @@ export function browserGoogleLogin(host, timeout = 180) {
|
|
|
676
676
|
/* socket already gone — ignore */
|
|
677
677
|
}
|
|
678
678
|
};
|
|
679
|
-
const
|
|
679
|
+
const handle = (req, res) => {
|
|
680
680
|
// A client that aborts mid-request makes `req` emit 'error'; with no
|
|
681
681
|
// listener Node re-throws it as an uncaughtException. Swallow it.
|
|
682
682
|
req.on("error", () => {
|
|
@@ -735,7 +735,17 @@ export function browserGoogleLogin(host, timeout = 180) {
|
|
|
735
735
|
// Contain any synchronous throw in the request handler.
|
|
736
736
|
finish(e instanceof Error ? e.message : String(e), null);
|
|
737
737
|
}
|
|
738
|
-
}
|
|
738
|
+
};
|
|
739
|
+
// The browser opens http://localhost:<port>, and localhost is [::1] before 127.0.0.1. Listening
|
|
740
|
+
// on 127.0.0.1 alone, a dev server on [::1]:<port> (the platform's pnpm run dev takes 8080) got
|
|
741
|
+
// the browser while both started without an error, and the sign-in hung until its timeout.
|
|
742
|
+
// So the page listens on both, and a [::1] that is taken is said at once.
|
|
743
|
+
const servers = [createServer(handle), createServer(handle)];
|
|
744
|
+
const closeAll = () => {
|
|
745
|
+
for (const s of servers) {
|
|
746
|
+
s.close();
|
|
747
|
+
}
|
|
748
|
+
};
|
|
739
749
|
const finish = (error, idToken) => {
|
|
740
750
|
if (settled) {
|
|
741
751
|
return;
|
|
@@ -744,7 +754,7 @@ export function browserGoogleLogin(host, timeout = 180) {
|
|
|
744
754
|
if (timer) {
|
|
745
755
|
clearTimeout(timer);
|
|
746
756
|
}
|
|
747
|
-
|
|
757
|
+
closeAll();
|
|
748
758
|
if (error) {
|
|
749
759
|
reject(new Error(`Google sign-in failed: ${error}`));
|
|
750
760
|
}
|
|
@@ -755,18 +765,52 @@ export function browserGoogleLogin(host, timeout = 180) {
|
|
|
755
765
|
reject(new Error("Google sign-in failed: no credential returned by Google"));
|
|
756
766
|
}
|
|
757
767
|
};
|
|
758
|
-
|
|
768
|
+
const otherPort = "or set SUPPA_MCP_LOGIN_PORT to another port — its origin http://localhost:<port> must " +
|
|
769
|
+
"also be in the Google OAuth client's Authorized JavaScript origins, or Google refuses the page.";
|
|
770
|
+
const refuse = (message) => {
|
|
759
771
|
if (settled) {
|
|
760
772
|
return;
|
|
761
773
|
}
|
|
762
774
|
settled = true;
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
775
|
+
closeAll();
|
|
776
|
+
reject(new Error(message));
|
|
777
|
+
};
|
|
778
|
+
const listenOn = (s, host) => new Promise((ok, fail) => {
|
|
779
|
+
s.once("error", fail);
|
|
780
|
+
s.listen(port, host, () => {
|
|
781
|
+
s.off("error", fail);
|
|
782
|
+
// An error after listening ends the sign-in, never the process (an EventEmitter
|
|
783
|
+
// 'error' with no listener is thrown).
|
|
784
|
+
s.on("error", (e) => finish(e.message, null));
|
|
785
|
+
ok();
|
|
786
|
+
});
|
|
768
787
|
});
|
|
769
|
-
|
|
788
|
+
void (async () => {
|
|
789
|
+
try {
|
|
790
|
+
await listenOn(servers[0], "127.0.0.1");
|
|
791
|
+
}
|
|
792
|
+
catch (e) {
|
|
793
|
+
const err = e;
|
|
794
|
+
return refuse(`Could not start the login server on port ${port} (${err.message}). ` +
|
|
795
|
+
`Close whatever is using it, ${otherPort}`);
|
|
796
|
+
}
|
|
797
|
+
try {
|
|
798
|
+
await listenOn(servers[1], "::1");
|
|
799
|
+
}
|
|
800
|
+
catch (e) {
|
|
801
|
+
const err = e;
|
|
802
|
+
if (err.code !== "EADDRNOTAVAIL" && err.code !== "EAFNOSUPPORT") {
|
|
803
|
+
return refuse(`Could not start the sign-in page: [::1]:${port} is already held by another server ` +
|
|
804
|
+
`(${err.code ?? err.message}) — most likely a local dev server; the platform's ` +
|
|
805
|
+
`pnpm run dev listens on 8080. The browser opens http://localhost:${port}, which ` +
|
|
806
|
+
"reaches [::1] first, so it would show that server instead of the sign-in page. " +
|
|
807
|
+
`Stop it for the minute the sign-in takes, ${otherPort}`);
|
|
808
|
+
}
|
|
809
|
+
servers.pop(); // no IPv6 loopback on this machine: nothing can shadow 127.0.0.1 there
|
|
810
|
+
}
|
|
811
|
+
if (settled) {
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
770
814
|
const url = `http://localhost:${port}/`;
|
|
771
815
|
const opened = openBrowser(url);
|
|
772
816
|
timer = setTimeout(() => {
|
|
@@ -774,11 +818,11 @@ export function browserGoogleLogin(host, timeout = 180) {
|
|
|
774
818
|
return;
|
|
775
819
|
}
|
|
776
820
|
settled = true;
|
|
777
|
-
|
|
821
|
+
closeAll();
|
|
778
822
|
reject(new Error(`Login timed out after ${timeout}s. ` +
|
|
779
823
|
(opened ? "" : `Open ${url} manually and sign in.`)));
|
|
780
824
|
}, timeout * 1000);
|
|
781
|
-
});
|
|
825
|
+
})();
|
|
782
826
|
});
|
|
783
827
|
}
|
|
784
828
|
/** Authenticate to a tenant via Google and store the tokens. Returns JSON status. */
|
package/dist/cli/flags.js
CHANGED
|
@@ -281,6 +281,27 @@ export function nearestName(target, candidates) {
|
|
|
281
281
|
return null;
|
|
282
282
|
return best.name;
|
|
283
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* `nearestName`, then one more way to be close: an abbreviation — the same first letter and every
|
|
286
|
+
* letter of `target` in order inside exactly one candidate. A typo is what `nearestName` catches;
|
|
287
|
+
* `filters` for `filters_json` or `cmp` for `comparator` is a short form, and scores below the
|
|
288
|
+
* threshold (0.58, 0.3). Two candidates that both contain it is a guess, so null.
|
|
289
|
+
*/
|
|
290
|
+
export function suggestName(target, candidates) {
|
|
291
|
+
const near = nearestName(target, candidates);
|
|
292
|
+
if (near !== null)
|
|
293
|
+
return near;
|
|
294
|
+
const t = target.toLowerCase();
|
|
295
|
+
const inOrder = (name) => {
|
|
296
|
+
let i = 0;
|
|
297
|
+
for (const c of name.toLowerCase())
|
|
298
|
+
if (c === t[i])
|
|
299
|
+
i++;
|
|
300
|
+
return i === t.length;
|
|
301
|
+
};
|
|
302
|
+
const hits = candidates.filter((name) => t.length > 1 && name[0]?.toLowerCase() === t[0] && inOrder(name));
|
|
303
|
+
return hits.length === 1 ? hits[0] : null;
|
|
304
|
+
}
|
|
284
305
|
/**
|
|
285
306
|
* Optimal-string-alignment distance: Levenshtein (insert / delete / substitute,
|
|
286
307
|
* each cost 1) plus one more move — swapping two adjacent characters counts as
|
package/dist/server.js
CHANGED
|
@@ -29,6 +29,7 @@ import * as query from "./tools/query.js";
|
|
|
29
29
|
import * as auth from "./auth.js";
|
|
30
30
|
import * as tenants from "./tenants.js";
|
|
31
31
|
import { confirmRequired, jsonResponse } from "./utils.js";
|
|
32
|
+
import { suggestName } from "./cli/flags.js";
|
|
32
33
|
import { installToolsListEconomy } from "./toolsListEconomy.js";
|
|
33
34
|
import { PACKAGE_NAME, PACKAGE_VERSION, knownLatest, isOutdated, refreshLatestVersion, upgradeNotice, } from "./version.js";
|
|
34
35
|
export { PACKAGE_VERSION };
|
|
@@ -1770,6 +1771,11 @@ export function buildToolTable() {
|
|
|
1770
1771
|
annotations: _MUT,
|
|
1771
1772
|
}, async (a) => {
|
|
1772
1773
|
if (!a.confirm) {
|
|
1774
|
+
// The checks first: a human asked to approve a write that is then refused approved nothing.
|
|
1775
|
+
const refused = await entity.refusedRecordUpdate(a.entity_name, a.fields_json, a.merge_json, a.unmerge_json);
|
|
1776
|
+
if (refused) {
|
|
1777
|
+
return text(refused);
|
|
1778
|
+
}
|
|
1773
1779
|
let proposed;
|
|
1774
1780
|
try {
|
|
1775
1781
|
proposed = JSON.parse(a.fields_json);
|
|
@@ -1821,6 +1827,10 @@ export function buildToolTable() {
|
|
|
1821
1827
|
annotations: _MUT,
|
|
1822
1828
|
}, async (a) => {
|
|
1823
1829
|
if (!a.confirm) {
|
|
1830
|
+
const refused = await entity.refusedRecordDelete(a.entity_name);
|
|
1831
|
+
if (refused) {
|
|
1832
|
+
return text(refused);
|
|
1833
|
+
}
|
|
1824
1834
|
return text(confirmRequired("delete record", {
|
|
1825
1835
|
entity: a.entity_name,
|
|
1826
1836
|
record_id: a.record_id,
|
|
@@ -2066,9 +2076,11 @@ export function buildToolTable() {
|
|
|
2066
2076
|
reg("suppa_create_automation", {
|
|
2067
2077
|
description: "Create a DRAFT automation workflow (AutomationWorkflow). Writes only draft\n" +
|
|
2068
2078
|
" columns (name/nodes/connections/settings) with isActive=false — it is NOT live\n" +
|
|
2069
|
-
" until published (suppa_publish_automation). Runs pre-flight validation (
|
|
2070
|
-
" trigger
|
|
2071
|
-
"
|
|
2079
|
+
" until published (suppa_publish_automation). Runs pre-flight validation (at least\n" +
|
|
2080
|
+
" one trigger — triggerEntity, triggerManual, triggerWebhook, triggerSchedule,\n" +
|
|
2081
|
+
" formSubmission or any the live catalog lists; several are allowed, in any position —\n" +
|
|
2082
|
+
" unique node ids, connections reference known nodes, DAG, trigger and suppa node\n" +
|
|
2083
|
+
" params); on failure nothing is written and the errors are returned.",
|
|
2072
2084
|
inputSchema: {
|
|
2073
2085
|
name: z.string().describe("Automation name."),
|
|
2074
2086
|
nodes_json: z
|
|
@@ -2820,6 +2832,33 @@ export function buildToolTable() {
|
|
|
2820
2832
|
}, async (a) => text(await healthCheck(a.deep)));
|
|
2821
2833
|
return table;
|
|
2822
2834
|
}
|
|
2835
|
+
/**
|
|
2836
|
+
* A tool's input schema that REFUSES an argument the tool does not declare. The SDK builds a plain
|
|
2837
|
+
* z.object from a raw shape, and that strips unknown keys: `filters` written for `filters_json`
|
|
2838
|
+
* vanished, the default "[]" stood in, and the search ran unfiltered — answered as if filtered
|
|
2839
|
+
* (09.10.2026, on every tool). The CLI refused this from the start (cli/run.ts); this is the same
|
|
2840
|
+
* refusal on the MCP side, with the same suggestion. In tools/list every tool with arguments
|
|
2841
|
+
* already said `additionalProperties: false`; the six without now say it too.
|
|
2842
|
+
*/
|
|
2843
|
+
export function strictArguments(tool, shape) {
|
|
2844
|
+
const names = Object.keys(shape);
|
|
2845
|
+
return z
|
|
2846
|
+
.object(shape, {
|
|
2847
|
+
errorMap: (issue, ctx) => {
|
|
2848
|
+
if (issue.code !== "unrecognized_keys")
|
|
2849
|
+
return { message: ctx.defaultError };
|
|
2850
|
+
const unknown = issue.keys.map((key) => {
|
|
2851
|
+
const near = suggestName(key, names);
|
|
2852
|
+
return `unknown argument '${key}'${near ? ` — did you mean '${near}'?` : ""}`;
|
|
2853
|
+
});
|
|
2854
|
+
return {
|
|
2855
|
+
message: `${unknown.join("; ")}. ${tool} takes: ${names.join(", ") || "no arguments"}. ` +
|
|
2856
|
+
"Nothing was sent — an undeclared argument is never dropped, because the call would run without it.",
|
|
2857
|
+
};
|
|
2858
|
+
},
|
|
2859
|
+
})
|
|
2860
|
+
.strict();
|
|
2861
|
+
}
|
|
2823
2862
|
export function buildServer() {
|
|
2824
2863
|
// Reset so repeated buildServer() calls (e.g. in tests) do not double-count.
|
|
2825
2864
|
TOOL_NAMES.length = 0;
|
|
@@ -2839,7 +2878,7 @@ export function buildServer() {
|
|
|
2839
2878
|
for (const spec of buildToolTable()) {
|
|
2840
2879
|
server.registerTool(spec.name, {
|
|
2841
2880
|
description: compactDescription(spec.description),
|
|
2842
|
-
inputSchema: (spec.inputSchema ?? {}),
|
|
2881
|
+
inputSchema: strictArguments(spec.name, spec.inputSchema ?? {}),
|
|
2843
2882
|
annotations: spec.annotations,
|
|
2844
2883
|
}, spec.handler);
|
|
2845
2884
|
TOOL_NAMES.push(spec.name);
|
package/dist/tools/automation.js
CHANGED
|
@@ -826,14 +826,40 @@ export async function searchEntities(query, limit = 20) {
|
|
|
826
826
|
// hasUnpublishedChanges/triggerEntityName) are NEVER written here — publishing
|
|
827
827
|
// promotes the draft into those via the automation-service.
|
|
828
828
|
// ===========================================================================
|
|
829
|
-
// Trigger node types
|
|
830
|
-
// `trigger
|
|
829
|
+
// Trigger node types — the live catalog's category 'trigger' (GET /api/automation/nodes on dev,
|
|
830
|
+
// 2026-10-15) plus `trigger`, the legacy/abstract type kept for backward compatibility. The builder's
|
|
831
|
+
// own test is the same: category 'trigger', else the `trigger` prefix (FE workflowBuilder/
|
|
832
|
+
// testRunWaiting.ts isTriggerNodeType) — formSubmission carries no prefix, which is how it was missed.
|
|
833
|
+
// A workflow needs at least one. It may have several (the builder saves drafts with two and three),
|
|
834
|
+
// and one need not be the first node: array order is not graph order — a PUBLISHED version on dev
|
|
835
|
+
// (workflow 8) carries its trigger as the fifth node. Until 1.42.5 this refused both.
|
|
831
836
|
const _TRIGGER_TYPES = new Set([
|
|
832
837
|
"triggerEntity",
|
|
833
838
|
"triggerManual",
|
|
834
839
|
"triggerWebhook",
|
|
840
|
+
"triggerSchedule",
|
|
841
|
+
"formSubmission",
|
|
835
842
|
"trigger",
|
|
836
843
|
]);
|
|
844
|
+
const _isTriggerType = (type, extra) => _TRIGGER_TYPES.has(type) || extra.has(type) || type.startsWith("trigger");
|
|
845
|
+
/**
|
|
846
|
+
* The trigger types the tenant's live catalog lists beyond the known ones — a trigger type added to
|
|
847
|
+
* the automation-service is then accepted without a new release. Best-effort: an older build without
|
|
848
|
+
* the catalog, or a catalog that cannot be read, adds nothing.
|
|
849
|
+
*/
|
|
850
|
+
async function _catalogTriggerTypes() {
|
|
851
|
+
try {
|
|
852
|
+
const catalog = await _fetchNodeCatalog();
|
|
853
|
+
return new Set((catalog ?? [])
|
|
854
|
+
.filter((n) => isPlainObject(n) && n.category === "trigger" && typeof n.type === "string")
|
|
855
|
+
.map((n) => String(n.type)));
|
|
856
|
+
}
|
|
857
|
+
catch {
|
|
858
|
+
return new Set();
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
/** A value written as an expression (`={{ … }}`) rather than a literal. */
|
|
862
|
+
const _isExpression = (v) => typeof v === "string" && (v.startsWith("=") || v.includes("{{"));
|
|
837
863
|
// Data-operation actions a `suppa` node may perform.
|
|
838
864
|
const _SUPPA_ACTIONS = new Set([
|
|
839
865
|
"select",
|
|
@@ -885,7 +911,7 @@ function _hasCycle(adj) {
|
|
|
885
911
|
* readable error strings; an empty list means the workflow is well-formed.
|
|
886
912
|
* Never throws — every branch guards against non-dict nodes/params.
|
|
887
913
|
*/
|
|
888
|
-
export function _validateWorkflow(nodes, connections) {
|
|
914
|
+
export function _validateWorkflow(nodes, connections, extraTriggerTypes = new Set()) {
|
|
889
915
|
const errors = [];
|
|
890
916
|
if (!Array.isArray(nodes) || nodes.length === 0) {
|
|
891
917
|
errors.push("nodes must be a non-empty array");
|
|
@@ -921,21 +947,11 @@ export function _validateWorkflow(nodes, connections) {
|
|
|
921
947
|
for (const d of sortedStrings(dups)) {
|
|
922
948
|
errors.push(`duplicate node id: ${d}`);
|
|
923
949
|
}
|
|
924
|
-
//
|
|
925
|
-
const
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
}
|
|
930
|
-
});
|
|
931
|
-
if (triggerIdx.length === 0) {
|
|
932
|
-
errors.push("no trigger node found (exactly one trigger required)");
|
|
933
|
-
}
|
|
934
|
-
else if (triggerIdx.length > 1) {
|
|
935
|
-
errors.push(`multiple trigger nodes found (${triggerIdx.length}); exactly one required`);
|
|
936
|
-
}
|
|
937
|
-
else if (triggerIdx[0] !== 0) {
|
|
938
|
-
errors.push("trigger node must be the first node");
|
|
950
|
+
// at least one trigger, anywhere in the array
|
|
951
|
+
const hasTrigger = nodes.some((n) => isPlainObject(n) && typeof n.type === "string" && _isTriggerType(n.type, extraTriggerTypes));
|
|
952
|
+
if (!hasTrigger) {
|
|
953
|
+
const known = sortedStrings(new Set([..._TRIGGER_TYPES, ...extraTriggerTypes]));
|
|
954
|
+
errors.push(`no trigger node found — a workflow starts at one or more of: ${known.join(", ")}`);
|
|
939
955
|
}
|
|
940
956
|
// per-node parameter requirements
|
|
941
957
|
for (const n of nodes) {
|
|
@@ -952,6 +968,38 @@ export function _validateWorkflow(nodes, connections) {
|
|
|
952
968
|
if (n.type === "triggerWebhook" && !params.webhookPath) {
|
|
953
969
|
errors.push(`trigger node '${idLabel}' (triggerWebhook) requires parameters.webhookPath`);
|
|
954
970
|
}
|
|
971
|
+
// FE workflowBuilder/docs/nodes.md "Form Submission": formId is a literal number — publish E18 when
|
|
972
|
+
// missing or behind an expression; the event is fixed (after-insert), so `events` is E19.
|
|
973
|
+
if (n.type === "formSubmission") {
|
|
974
|
+
const formId = params.formId;
|
|
975
|
+
const literal = typeof formId === "number" || (typeof formId === "string" && /^\d+$/.test(formId));
|
|
976
|
+
if (!literal || Number(formId) <= 0) {
|
|
977
|
+
errors.push(`trigger node '${idLabel}' (formSubmission) requires parameters.formId — the id of a published form ` +
|
|
978
|
+
`with no entity, as a literal number${_isExpression(formId) ? " (an expression is refused at publish, E18)" : ""}`);
|
|
979
|
+
}
|
|
980
|
+
if ("events" in params) {
|
|
981
|
+
errors.push(`trigger node '${idLabel}' (formSubmission) takes no parameters.events — the event is fixed to the submission (publish E19)`);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
// FE nodes.md "Schedule Trigger": mode recurring (a five-field UTC cron) or once (runAt, epoch ms).
|
|
985
|
+
if (n.type === "triggerSchedule") {
|
|
986
|
+
const mode = params.mode;
|
|
987
|
+
if (mode !== "recurring" && mode !== "once") {
|
|
988
|
+
errors.push(`trigger node '${idLabel}' (triggerSchedule) requires parameters.mode: 'recurring' or 'once'`);
|
|
989
|
+
}
|
|
990
|
+
else if (mode === "recurring") {
|
|
991
|
+
const cron = params.cron;
|
|
992
|
+
if (typeof cron !== "string" || !cron.trim()) {
|
|
993
|
+
errors.push(`trigger node '${idLabel}' (triggerSchedule, recurring) requires parameters.cron — a five-field cron, in UTC`);
|
|
994
|
+
}
|
|
995
|
+
else if (cron.trim().split(/\s+/).length !== 5) {
|
|
996
|
+
errors.push(`trigger node '${idLabel}' (triggerSchedule) cron '${cron}' must be five fields (minute hour day month weekday, UTC) — a seconds field is rejected`);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
else if (typeof params.runAt !== "number") {
|
|
1000
|
+
errors.push(`trigger node '${idLabel}' (triggerSchedule, once) requires parameters.runAt — epoch milliseconds`);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
955
1003
|
// suppa data node: identified by type 'suppa' or a present `action` param.
|
|
956
1004
|
const isSuppa = n.type === "suppa" || "action" in params;
|
|
957
1005
|
if (isSuppa) {
|
|
@@ -1028,7 +1076,7 @@ export async function createAutomation(name, nodesJson, connectionsJson, setting
|
|
|
1028
1076
|
catch (ex) {
|
|
1029
1077
|
return jsonResponse({ error: ex instanceof Error ? ex.message : String(ex) });
|
|
1030
1078
|
}
|
|
1031
|
-
const errors = _validateWorkflow(nodes, connections);
|
|
1079
|
+
const errors = _validateWorkflow(nodes, connections, await _catalogTriggerTypes());
|
|
1032
1080
|
if (errors.length) {
|
|
1033
1081
|
return jsonResponse({ error: "validation failed", errors });
|
|
1034
1082
|
}
|
|
@@ -1094,7 +1142,7 @@ export async function updateAutomation(automationId, name = null, nodesJson, con
|
|
|
1094
1142
|
// (the missing half is read from the current record). A name-only or settings-
|
|
1095
1143
|
// only update must not be blocked by a stored graph that predates the validator.
|
|
1096
1144
|
if (nodesSupplied || connectionsSupplied) {
|
|
1097
|
-
const errors = _validateWorkflow(nodes, connections);
|
|
1145
|
+
const errors = _validateWorkflow(nodes, connections, await _catalogTriggerTypes());
|
|
1098
1146
|
if (errors.length) {
|
|
1099
1147
|
return jsonResponse({ error: "validation failed", errors });
|
|
1100
1148
|
}
|
package/dist/tools/entity.js
CHANGED
|
@@ -3079,23 +3079,27 @@ async function _resolveEntity(name) {
|
|
|
3079
3079
|
if (ci) {
|
|
3080
3080
|
return { name: ci, names };
|
|
3081
3081
|
}
|
|
3082
|
-
// The
|
|
3083
|
-
//
|
|
3084
|
-
//
|
|
3085
|
-
//
|
|
3086
|
-
//
|
|
3087
|
-
//
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3082
|
+
// The listing is not the tenant. It leaves out the extension tables
|
|
3083
|
+
// ('<Entity>CustomFields', api/entity-builder/custom-fields.html §6B) and an
|
|
3084
|
+
// application's own tables (LeadsSales, CRM migration 06.10.2026), and both
|
|
3085
|
+
// are served by name — describe and query read them while this refused a
|
|
3086
|
+
// write as "does not exist". So a miss is asked by name before it is refused:
|
|
3087
|
+
// a schema that comes back with fields IS the entity, spelled as it answers.
|
|
3088
|
+
try {
|
|
3089
|
+
const schema = await makeRequest("GET", `/api/core/schema/${encodeURIComponent(name)}`);
|
|
3090
|
+
const fields = _extractFields(schema);
|
|
3091
|
+
// An extension table is one only with its `owner` column, as before.
|
|
3092
|
+
const isEntity = name.endsWith(CUSTOM_FIELDS_EXTENSION_SUFFIX)
|
|
3093
|
+
? fields.some((f) => f.name === "owner")
|
|
3094
|
+
: fields.length > 0;
|
|
3095
|
+
if (isEntity) {
|
|
3096
|
+
const served = isPlainObject(schema) && typeof schema.name === "string" && schema.name ? schema.name : name;
|
|
3097
|
+
return { name: served, names };
|
|
3097
3098
|
}
|
|
3098
3099
|
}
|
|
3100
|
+
catch {
|
|
3101
|
+
// fall through to the refusal below — a failed read is not an entity
|
|
3102
|
+
}
|
|
3099
3103
|
const nl = name.toLowerCase();
|
|
3100
3104
|
const near = names
|
|
3101
3105
|
.filter((n) => n.toLowerCase().includes(nl) || nl.includes(n.toLowerCase()))
|
|
@@ -3507,6 +3511,35 @@ function _parseNameList(raw, param) {
|
|
|
3507
3511
|
* change.
|
|
3508
3512
|
*/
|
|
3509
3513
|
export async function updateRecord(entityName, recordId, fieldsJson, mergeJson = null, unmergeJson = null) {
|
|
3514
|
+
const checked = await _checkRecordUpdate(entityName, fieldsJson, mergeJson, unmergeJson);
|
|
3515
|
+
if ("error" in checked) {
|
|
3516
|
+
return checked.error;
|
|
3517
|
+
}
|
|
3518
|
+
const { fields, merge, unmerge } = checked;
|
|
3519
|
+
entityName = checked.entityName;
|
|
3520
|
+
let result;
|
|
3521
|
+
try {
|
|
3522
|
+
result = await updateEntity(entityName, recordId, fields, merge, unmerge);
|
|
3523
|
+
}
|
|
3524
|
+
catch (e) {
|
|
3525
|
+
const hinted = _writeErrorWithHint(e, [fields]);
|
|
3526
|
+
if (hinted) {
|
|
3527
|
+
return hinted;
|
|
3528
|
+
}
|
|
3529
|
+
throw e;
|
|
3530
|
+
}
|
|
3531
|
+
return _updateResult(entityName, recordId, fields, merge, unmerge, result, checked.v);
|
|
3532
|
+
}
|
|
3533
|
+
/**
|
|
3534
|
+
* The refusal `updateRecord` would answer, or null — every check it makes before the write, and
|
|
3535
|
+
* nothing sent. The confirm gate runs this FIRST: it used to ask a human to approve a write and
|
|
3536
|
+
* only then find the entity missing or a field misspelt (CRM migration, 06.10.2026).
|
|
3537
|
+
*/
|
|
3538
|
+
export async function refusedRecordUpdate(entityName, fieldsJson, mergeJson = null, unmergeJson = null) {
|
|
3539
|
+
const checked = await _checkRecordUpdate(entityName, fieldsJson, mergeJson, unmergeJson);
|
|
3540
|
+
return "error" in checked ? checked.error : null;
|
|
3541
|
+
}
|
|
3542
|
+
async function _checkRecordUpdate(entityName, fieldsJson, mergeJson, unmergeJson) {
|
|
3510
3543
|
let fields;
|
|
3511
3544
|
let merge;
|
|
3512
3545
|
let unmerge;
|
|
@@ -3516,36 +3549,28 @@ export async function updateRecord(entityName, recordId, fieldsJson, mergeJson =
|
|
|
3516
3549
|
unmerge = _parseNameList(unmergeJson, "unmerge_json");
|
|
3517
3550
|
}
|
|
3518
3551
|
catch (e) {
|
|
3519
|
-
return jsonResponse({ error: e instanceof Error ? e.message : String(e) });
|
|
3552
|
+
return { error: jsonResponse({ error: e instanceof Error ? e.message : String(e) }) };
|
|
3520
3553
|
}
|
|
3521
3554
|
const mergeProblems = mergeListProblems(fields, merge, unmerge);
|
|
3522
3555
|
if (mergeProblems.length > 0) {
|
|
3523
|
-
return jsonResponse({
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3556
|
+
return { error: jsonResponse({
|
|
3557
|
+
error: "Refused: the merge/unmerge lists do not line up with fields_json. Nothing " +
|
|
3558
|
+
"was written — sending this would have REPLACED the list instead of " +
|
|
3559
|
+
"adding to it, and reported success.",
|
|
3560
|
+
problems: mergeProblems,
|
|
3561
|
+
hint: 'merge_json/unmerge_json take field NAMES (e.g. ["watchers"]); each name ' +
|
|
3562
|
+
'must also appear in fields_json with an array value (e.g. {"watchers": ' +
|
|
3563
|
+
'[{"id": 15}]}), and no name may be in both lists.',
|
|
3564
|
+
}) };
|
|
3532
3565
|
}
|
|
3533
3566
|
const v = await _validateRecordWrite(entityName, fields);
|
|
3534
3567
|
if (v.error) {
|
|
3535
|
-
return v.error;
|
|
3536
|
-
}
|
|
3537
|
-
entityName = v.entityName;
|
|
3538
|
-
let result;
|
|
3539
|
-
try {
|
|
3540
|
-
result = await updateEntity(entityName, recordId, fields, merge, unmerge);
|
|
3541
|
-
}
|
|
3542
|
-
catch (e) {
|
|
3543
|
-
const hinted = _writeErrorWithHint(e, [fields]);
|
|
3544
|
-
if (hinted) {
|
|
3545
|
-
return hinted;
|
|
3546
|
-
}
|
|
3547
|
-
throw e;
|
|
3568
|
+
return { error: v.error };
|
|
3548
3569
|
}
|
|
3570
|
+
return { entityName: v.entityName, fields, merge, unmerge, v };
|
|
3571
|
+
}
|
|
3572
|
+
/** The answer to an update that was sent: whether a row moved, what it replaced, what to warn about. */
|
|
3573
|
+
function _updateResult(entityName, recordId, fields, merge, unmerge, result, v) {
|
|
3549
3574
|
// Not "is the body falsy" but "did a row move": {"affected": 0} and [{}] are
|
|
3550
3575
|
// the platform saying it matched nothing just as surely as [], and this was
|
|
3551
3576
|
// the last writer still reading them as a completed update.
|
|
@@ -3862,6 +3887,10 @@ export async function attachFileToRecord(entityName, recordId, filePath, fieldNa
|
|
|
3862
3887
|
* column is RENAMED to <name>_<timestamp> rather than dropped — so restore-fields
|
|
3863
3888
|
* brings the field and every value back. Verified end-to-end on a live tenant.
|
|
3864
3889
|
*/
|
|
3890
|
+
/** The refusal `deleteRecord` would answer before sending anything, or null — for the confirm gate. */
|
|
3891
|
+
export async function refusedRecordDelete(entityName) {
|
|
3892
|
+
return (await _resolveEntity(entityName)).error ?? null;
|
|
3893
|
+
}
|
|
3865
3894
|
export async function deleteRecord(entityName, recordId) {
|
|
3866
3895
|
// Verify the entity exists (best-effort) so a typo'd name gives a clear error
|
|
3867
3896
|
// rather than an opaque platform failure.
|
package/dist/utils.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { randomUUID } from "node:crypto";
|
|
7
7
|
import { config } from "./config.js";
|
|
8
|
+
import { suggestName } from "./cli/flags.js";
|
|
8
9
|
import { statSync, readFileSync } from "node:fs";
|
|
9
10
|
import { extname, basename } from "node:path";
|
|
10
11
|
export function makeFilter(field, value, comparator = "=") {
|
|
@@ -48,6 +49,22 @@ export function isConditionNode(node) {
|
|
|
48
49
|
function isPlainObj(v) {
|
|
49
50
|
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
50
51
|
}
|
|
52
|
+
// The platform's Filter and Condition have these keys and no others (data.txt:33-42).
|
|
53
|
+
const FILTER_KEYS = ["field", "value", "comparator", "function"];
|
|
54
|
+
const CONDITION_KEYS = ["operator", "filters"];
|
|
55
|
+
/**
|
|
56
|
+
* A key the node does not have is refused, not dropped. Dropped, `{"cmp": "like"}` sent the
|
|
57
|
+
* default "=" and `{"match": "any"}` an AND — a different query, answered as if it were this one.
|
|
58
|
+
*/
|
|
59
|
+
function refuseUnknownKeys(node, allowed, path, what) {
|
|
60
|
+
for (const key of Object.keys(node)) {
|
|
61
|
+
if (allowed.includes(key))
|
|
62
|
+
continue;
|
|
63
|
+
const near = suggestName(key, allowed);
|
|
64
|
+
throw new Error(`${path}: unknown key '${key}'${near ? ` — did you mean '${near}'?` : ""} A ${what} takes ` +
|
|
65
|
+
`${allowed.map((k) => `"${k}"`).join(", ")} and nothing else (data.txt:33-42).`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
51
68
|
/**
|
|
52
69
|
* Validate + normalize ONE node: either a flat filter or a nested condition
|
|
53
70
|
* group. Flat "f=v" filters (what makeFilter produces, used across the tasks /
|
|
@@ -65,10 +82,16 @@ export function normalizeConditionNode(node, path = "filters_json") {
|
|
|
65
82
|
// Shorthand: {"or": [...]} / {"and": [...]}.
|
|
66
83
|
for (const op of CONDITION_OPERATORS) {
|
|
67
84
|
if (op in node && !("operator" in node)) {
|
|
85
|
+
refuseUnknownKeys(node, [op], path, `{"${op}": [...]} group`);
|
|
68
86
|
return normalizeConditionNode({ operator: op, filters: node[op] }, path);
|
|
69
87
|
}
|
|
70
88
|
}
|
|
71
89
|
if ("operator" in node || "filters" in node) {
|
|
90
|
+
if ("field" in node && !("filters" in node)) {
|
|
91
|
+
throw new Error(`${path}: a filter compares with "comparator", not "operator" — "operator" ("and"|"or") ` +
|
|
92
|
+
'belongs to a condition group {"operator", "filters"} (data.txt:35-40).');
|
|
93
|
+
}
|
|
94
|
+
refuseUnknownKeys(node, CONDITION_KEYS, path, "condition group");
|
|
72
95
|
const rawOp = node.operator;
|
|
73
96
|
const operator = typeof rawOp === "string" ? rawOp.trim().toLowerCase() : "";
|
|
74
97
|
if (!CONDITION_OPERATORS.includes(operator)) {
|
|
@@ -86,6 +109,7 @@ export function normalizeConditionNode(node, path = "filters_json") {
|
|
|
86
109
|
};
|
|
87
110
|
}
|
|
88
111
|
// Leaf filter.
|
|
112
|
+
refuseUnknownKeys(node, FILTER_KEYS, path, "filter");
|
|
89
113
|
const field = node.field;
|
|
90
114
|
if (typeof field !== "string" || !field.trim()) {
|
|
91
115
|
throw new Error(`${path}: a filter needs "field" — a field name or dotted path such as ` +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suppa-mcp-2",
|
|
3
|
-
"version": "1.42.
|
|
3
|
+
"version": "1.42.6",
|
|
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": {
|