suppa-mcp-2 1.2.4 → 1.3.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/README.md +419 -391
- package/dist/bin.js +1 -1
- package/dist/httpClient.js +200 -6
- package/dist/server.js +491 -89
- package/dist/tools/docs.js +3 -3
- package/dist/tools/entity.js +981 -49
- package/dist/tools/migrate.js +13 -0
- package/dist/utils.js +117 -4
- package/package.json +13 -4
package/dist/tools/migrate.js
CHANGED
|
@@ -604,6 +604,11 @@ async function _planFields(props, entName, v2EntName, targetResolver, entIndex,
|
|
|
604
604
|
title: ftitle,
|
|
605
605
|
type: cls.v2Type,
|
|
606
606
|
required,
|
|
607
|
+
// Builder Field Options (builder.txt:60, keys :66-73). Null = "send none",
|
|
608
|
+
// which is what 1.0 tells us: it has no equivalent metadata, so nothing is
|
|
609
|
+
// invented here. The key exists so an EDITED plan can carry them —
|
|
610
|
+
// {"searchable": true, "showInTable": true} — and _execute forwards it.
|
|
611
|
+
options: null,
|
|
607
612
|
// The v1 default must travel with the planned field: _requiredOpts reads
|
|
608
613
|
// `default_value` off the PLAN, so a plan that omits it downgrades every
|
|
609
614
|
// required field to nullable and the notNull path is never taken.
|
|
@@ -637,6 +642,7 @@ async function _planFields(props, entName, v2EntName, targetResolver, entIndex,
|
|
|
637
642
|
default_value: p.default_value ?? null,
|
|
638
643
|
enum_name: _enumNameFor(v2EntName, v2Fname),
|
|
639
644
|
values,
|
|
645
|
+
options: null, // see relation_fields above — builder.txt:60 / :66-73
|
|
640
646
|
});
|
|
641
647
|
continue;
|
|
642
648
|
}
|
|
@@ -652,6 +658,7 @@ async function _planFields(props, entName, v2EntName, targetResolver, entIndex,
|
|
|
652
658
|
max_length: cls.v2Type === "text" ? maxLength : null,
|
|
653
659
|
decimal_places: cls.v2Type === "numeric" ? decimalPlaces : null,
|
|
654
660
|
multilingual: cls.multilingual,
|
|
661
|
+
options: null, // see relation_fields above — builder.txt:60 / :66-73
|
|
655
662
|
};
|
|
656
663
|
if (cls.note) {
|
|
657
664
|
field.note = cls.note;
|
|
@@ -1097,6 +1104,7 @@ export async function _execute(plan, mode = "create") {
|
|
|
1097
1104
|
subType: f.sub_type ?? null,
|
|
1098
1105
|
maxLength: f.max_length ?? null,
|
|
1099
1106
|
decimalPlaces: f.decimal_places ?? null,
|
|
1107
|
+
options: f.options ?? null, // builder.txt:60 — plan-carried Field Options
|
|
1100
1108
|
}));
|
|
1101
1109
|
step.entity = name;
|
|
1102
1110
|
details.push(step);
|
|
@@ -1122,6 +1130,7 @@ export async function _execute(plan, mode = "create") {
|
|
|
1122
1130
|
const step = await _runWrite(`add_enum_field:${f.name}`, () => entityTools.addField(name, f.name, f.type ?? "enum", f.title, {
|
|
1123
1131
|
..._requiredOpts(name, { ...f, type: f.type ?? "enum" }, requiredDowngrades),
|
|
1124
1132
|
enumName: f.enum_name,
|
|
1133
|
+
options: f.options ?? null, // builder.txt:60
|
|
1125
1134
|
}));
|
|
1126
1135
|
step.entity = name;
|
|
1127
1136
|
details.push(step);
|
|
@@ -1148,6 +1157,7 @@ export async function _execute(plan, mode = "create") {
|
|
|
1148
1157
|
subType: f.sub_type ?? null,
|
|
1149
1158
|
maxLength: f.max_length ?? null,
|
|
1150
1159
|
decimalPlaces: f.decimal_places ?? null,
|
|
1160
|
+
options: f.options ?? null, // builder.txt:60
|
|
1151
1161
|
}));
|
|
1152
1162
|
step.entity = tpName;
|
|
1153
1163
|
details.push(step);
|
|
@@ -1168,6 +1178,7 @@ export async function _execute(plan, mode = "create") {
|
|
|
1168
1178
|
const step = await _runWrite(`add_enum_field:${f.name}`, () => entityTools.addField(tpName, f.name, f.type ?? "enum", f.title, {
|
|
1169
1179
|
..._requiredOpts(tpName, { ...f, type: f.type ?? "enum" }, requiredDowngrades),
|
|
1170
1180
|
enumName: f.enum_name,
|
|
1181
|
+
options: f.options ?? null, // builder.txt:60
|
|
1171
1182
|
}));
|
|
1172
1183
|
step.entity = tpName;
|
|
1173
1184
|
details.push(step);
|
|
@@ -1212,6 +1223,7 @@ export async function _execute(plan, mode = "create") {
|
|
|
1212
1223
|
const step = await _runWrite(`add_relation:${f.name}`, () => entityTools.addField(name, f.name, f.type, f.title, {
|
|
1213
1224
|
..._requiredOpts(name, f, requiredDowngrades),
|
|
1214
1225
|
relationEntity: f.relation_entity,
|
|
1226
|
+
options: f.options ?? null, // builder.txt:60
|
|
1215
1227
|
}));
|
|
1216
1228
|
step.entity = name;
|
|
1217
1229
|
details.push(step);
|
|
@@ -1250,6 +1262,7 @@ export async function _execute(plan, mode = "create") {
|
|
|
1250
1262
|
const step = await _runWrite(`add_relation:${f.name}`, () => entityTools.addField(tp.name, f.name, f.type, f.title, {
|
|
1251
1263
|
..._requiredOpts(tp.name, f, requiredDowngrades),
|
|
1252
1264
|
relationEntity: f.relation_entity,
|
|
1265
|
+
options: f.options ?? null, // builder.txt:60
|
|
1253
1266
|
}));
|
|
1254
1267
|
step.entity = tp.name;
|
|
1255
1268
|
details.push(step);
|
package/dist/utils.js
CHANGED
|
@@ -9,6 +9,117 @@ import { extname, basename } from "node:path";
|
|
|
9
9
|
export function makeFilter(field, value, comparator = "=") {
|
|
10
10
|
return { field, value, comparator };
|
|
11
11
|
}
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Conditions: flat filters AND nested groups
|
|
14
|
+
//
|
|
15
|
+
// Shared objects, captures/api-entity-builder-data.txt:33-42 —
|
|
16
|
+
// Condition: operator (string, required, "and or or", :35)
|
|
17
|
+
// filters (object[], required, "Filters, or NESTED CONDITION
|
|
18
|
+
// OBJECTS", :36)
|
|
19
|
+
// Filter: field (string, required, "Field path, e.g. owner.id", :39)
|
|
20
|
+
// comparator (string, required, :40)
|
|
21
|
+
// value (any, required, :41)
|
|
22
|
+
// function (string, optional, "Field function", :42)
|
|
23
|
+
//
|
|
24
|
+
// Because a Condition's `filters` may hold Conditions, an expression like
|
|
25
|
+
// (status=open AND owner=me) OR priority=high is one payload:
|
|
26
|
+
// {"operator": "or", "filters": [
|
|
27
|
+
// {"operator": "and", "filters": [
|
|
28
|
+
// {"field": "status.value", "value": "open", "comparator": "="},
|
|
29
|
+
// {"field": "owner.id", "value": "$current-user", "comparator": "="}]},
|
|
30
|
+
// {"field": "priority.value", "value": "high", "comparator": "="}]}
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
/** data.txt:35 — the only two condition operators. */
|
|
33
|
+
export const CONDITION_OPERATORS = ["and", "or"];
|
|
34
|
+
/** Comparators that stand alone — the platform ignores any value sent with them. */
|
|
35
|
+
const VALUELESS_COMPARATORS = new Set(["is null", "is not null", "isnull", "isnotnull"]);
|
|
36
|
+
/** Build a nested condition group (data.txt:33-36). */
|
|
37
|
+
export function makeCondition(operator, nodes) {
|
|
38
|
+
return normalizeConditionNode({ operator, filters: nodes }, "condition");
|
|
39
|
+
}
|
|
40
|
+
/** True for a node that is a group rather than a leaf filter. */
|
|
41
|
+
export function isConditionNode(node) {
|
|
42
|
+
return (node !== null &&
|
|
43
|
+
typeof node === "object" &&
|
|
44
|
+
!Array.isArray(node) &&
|
|
45
|
+
"operator" in node);
|
|
46
|
+
}
|
|
47
|
+
function isPlainObj(v) {
|
|
48
|
+
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Validate + normalize ONE node: either a flat filter or a nested condition
|
|
52
|
+
* group. Flat "f=v" filters (what makeFilter produces, used across the tasks /
|
|
53
|
+
* docs / forms tools) pass through with their keys unchanged — this only adds
|
|
54
|
+
* the nested case and refuses shapes the platform would silently mis-read.
|
|
55
|
+
*
|
|
56
|
+
* Accepts the documented group shape {"operator": "or", "filters": [...]} and
|
|
57
|
+
* the shorthand {"or": [...]} / {"and": [...]}, which normalizes to it.
|
|
58
|
+
*/
|
|
59
|
+
export function normalizeConditionNode(node, path = "filters_json") {
|
|
60
|
+
if (!isPlainObj(node)) {
|
|
61
|
+
throw new Error(`${path} must be a filter object {"field", "value", "comparator"} or a ` +
|
|
62
|
+
`condition group {"operator": "and"|"or", "filters": [...]} — got ${typeName(node)}.`);
|
|
63
|
+
}
|
|
64
|
+
// Shorthand: {"or": [...]} / {"and": [...]}.
|
|
65
|
+
for (const op of CONDITION_OPERATORS) {
|
|
66
|
+
if (op in node && !("operator" in node)) {
|
|
67
|
+
return normalizeConditionNode({ operator: op, filters: node[op] }, path);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if ("operator" in node || "filters" in node) {
|
|
71
|
+
const rawOp = node.operator;
|
|
72
|
+
const operator = typeof rawOp === "string" ? rawOp.trim().toLowerCase() : "";
|
|
73
|
+
if (!CONDITION_OPERATORS.includes(operator)) {
|
|
74
|
+
throw new Error(`${path}: a condition group needs "operator": "and" or "or" ` +
|
|
75
|
+
`(data.txt:35) — got ${JSON.stringify(rawOp ?? null)}.`);
|
|
76
|
+
}
|
|
77
|
+
const rawFilters = node.filters;
|
|
78
|
+
if (!Array.isArray(rawFilters)) {
|
|
79
|
+
throw new Error(`${path}: a condition group needs "filters": [...] — an array of filters ` +
|
|
80
|
+
"or nested groups (data.txt:36).");
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
operator: operator,
|
|
84
|
+
filters: rawFilters.map((child, i) => normalizeConditionNode(child, `${path}[${i}]`)),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
// Leaf filter.
|
|
88
|
+
const field = node.field;
|
|
89
|
+
if (typeof field !== "string" || !field.trim()) {
|
|
90
|
+
throw new Error(`${path}: a filter needs "field" — a field name or dotted path such as ` +
|
|
91
|
+
'"owner.id" (data.txt:39). Nested groups instead need "operator" + "filters".');
|
|
92
|
+
}
|
|
93
|
+
const rawCmp = node.comparator;
|
|
94
|
+
if (rawCmp !== undefined && rawCmp !== null && typeof rawCmp !== "string") {
|
|
95
|
+
throw new Error(`${path}: "comparator" must be a string (data.txt:40).`);
|
|
96
|
+
}
|
|
97
|
+
const comparator = (rawCmp ?? "=").trim() || "=";
|
|
98
|
+
if (!("value" in node) && !VALUELESS_COMPARATORS.has(comparator.toLowerCase())) {
|
|
99
|
+
throw new Error(`${path}: a filter needs "value" (data.txt:41) — only 'is null' / ` +
|
|
100
|
+
"'is not null' may omit it.");
|
|
101
|
+
}
|
|
102
|
+
const out = {
|
|
103
|
+
field: field.trim(),
|
|
104
|
+
value: "value" in node ? node.value : null,
|
|
105
|
+
comparator,
|
|
106
|
+
};
|
|
107
|
+
if (typeof node.function === "string" && node.function.trim()) {
|
|
108
|
+
out.function = node.function.trim(); // data.txt:42 — optional field function
|
|
109
|
+
}
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Normalize a list of filters/groups (the `filters` of the top-level Condition).
|
|
114
|
+
* A single object is tolerated as a one-element list, as before.
|
|
115
|
+
*/
|
|
116
|
+
export function normalizeConditionNodes(nodes, path = "filters_json") {
|
|
117
|
+
if (nodes === null || nodes === undefined) {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
const list = Array.isArray(nodes) ? nodes : [nodes];
|
|
121
|
+
return list.map((n, i) => normalizeConditionNode(n, `${path}[${i}]`));
|
|
122
|
+
}
|
|
12
123
|
/**
|
|
13
124
|
* Parse human-friendly deadline strings into ISO datetime.
|
|
14
125
|
*
|
|
@@ -464,13 +575,15 @@ export function confirmRequired(action, target, proposedChanges) {
|
|
|
464
575
|
"with confirm=true." +
|
|
465
576
|
(isDelete
|
|
466
577
|
? " Semantics: this is a SOFT delete — it sets deletedAt, the row remains " +
|
|
467
|
-
"in the database and the delete is reversible
|
|
468
|
-
"
|
|
469
|
-
"
|
|
578
|
+
"in the database and the delete is reversible with suppa_restore_record " +
|
|
579
|
+
"(find the row again with deleted_scope='deleted'). It is NOT the platform's " +
|
|
580
|
+
"permanent delete, which this server does not expose, but the record does " +
|
|
581
|
+
"disappear from every normal read."
|
|
470
582
|
: ""),
|
|
471
583
|
};
|
|
472
584
|
if (isDelete) {
|
|
473
|
-
body.delete_semantics =
|
|
585
|
+
body.delete_semantics =
|
|
586
|
+
"soft — sets deletedAt, row remains, reversible via suppa_restore_record";
|
|
474
587
|
}
|
|
475
588
|
if (proposedChanges !== undefined) {
|
|
476
589
|
body.proposed_changes = proposedChanges;
|
package/package.json
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suppa-mcp-2",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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
|
-
"bin": {
|
|
6
|
+
"bin": {
|
|
7
|
+
"suppa-mcp": "dist/bin.js"
|
|
8
|
+
},
|
|
7
9
|
"main": "dist/bin.js",
|
|
8
|
-
"files": [
|
|
9
|
-
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"skills",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18"
|
|
18
|
+
},
|
|
10
19
|
"scripts": {
|
|
11
20
|
"build": "tsc",
|
|
12
21
|
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
|