suppa-mcp-2 1.43.3 → 1.43.5
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 +5 -3
- package/dist/server.js +6 -6
- package/dist/toolTable.js +3 -3
- package/dist/tools/formV2.js +124 -10
- package/dist/tools/forms.js +65 -13
- package/package.json +1 -1
- package/skills/suppa-form-v2/SKILL.md +6 -6
- package/skills/suppa-form-v2/SOURCE.json +4 -4
- package/skills/suppa-form-v2/data/component-index.json +5 -0
- package/skills/suppa-form-v2/data/component-props.json +55 -3
- package/skills/suppa-form-v2/references/choosing-elements.md +2 -2
- package/skills/suppa-form-v2/references/publishing.md +1 -1
- package/skills/suppa-form-v2/scripts/form-core.mjs +313 -70
- package/skills/suppa-form-v2/scripts/validate-form-schema.mjs +11 -4
package/README.md
CHANGED
|
@@ -540,9 +540,11 @@ extension table is created outside that check and is not subject to it.
|
|
|
540
540
|
| `suppa_add_field_to_form` | Add a field element to a form (confirm-gated) |
|
|
541
541
|
| `suppa_list_form_field_types` | List form element types |
|
|
542
542
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
543
|
+
Of the seven above, `suppa_get_form` reads both generations: since 1.43.3 a 2.x form comes back as
|
|
544
|
+
the builder reads it (schema, variables, localizations, the Code Form's files). The other six are
|
|
545
|
+
**Suppa 1.0** forms: they read and write `data.formShema` (the platform's misspelling) and the v1
|
|
546
|
+
field types. A **Suppa 2.0** entity-builder form is a different product —
|
|
547
|
+
the `schema` column on the row since 2.1, 57 component types — and is served by the six below plus the bundled
|
|
546
548
|
`skills/suppa-form-v2` skill. The first two touch no tenant: they read files inside the package.
|
|
547
549
|
|
|
548
550
|
| Tool | Description |
|
package/dist/server.js
CHANGED
|
@@ -2461,7 +2461,7 @@ export function buildToolTable() {
|
|
|
2461
2461
|
" suppa_write_form_draft draft. Suppa 1.0: the row's `data` (formShema).",
|
|
2462
2462
|
inputSchema: {
|
|
2463
2463
|
form_id: z.number().int(),
|
|
2464
|
-
version: z.enum(["draft", "published"]).default("draft").describe("2.x: published = what
|
|
2464
|
+
version: z.enum(["draft", "published"]).default("draft").describe("2.x: published = what THIS user sees, read-only."),
|
|
2465
2465
|
include_artifact: z.boolean().default(false).describe("2.x: also the compiled JS of `code`."),
|
|
2466
2466
|
},
|
|
2467
2467
|
annotations: _READ,
|
|
@@ -2472,7 +2472,7 @@ export function buildToolTable() {
|
|
|
2472
2472
|
" (without entity_name it is refused, rather than creating an empty form).\n" +
|
|
2473
2473
|
" Form names are UNIQUE platform-wide — a duplicate name fails; pick a distinct one.\n" +
|
|
2474
2474
|
"\n SUPPA 1.0 FORM. This writes data.formShema and the v1 field types. A Suppa 2.0\n" +
|
|
2475
|
-
" (entity-builder) form is a different product — the `schema` column,
|
|
2475
|
+
" (entity-builder) form is a different product — the `schema` column, 57 types:\n" +
|
|
2476
2476
|
" use suppa_form_kb and suppa_validate_form_schema.",
|
|
2477
2477
|
inputSchema: {
|
|
2478
2478
|
name: z.string(),
|
|
@@ -2651,7 +2651,7 @@ export function buildToolTable() {
|
|
|
2651
2651
|
" kit the look of every record card, create form, window: the card kit's\n" +
|
|
2652
2652
|
" patterns (topic='p_block,…' = their elements); rules: ref card-kit\n" +
|
|
2653
2653
|
" note dynamicComponent = the widget contract (sandbox, formAPI, styles, translations)\n\n" +
|
|
2654
|
-
" No mode returns all
|
|
2654
|
+
" No mode returns all 57 prop tables: they are ~14,200 tokens stripped, and not carrying\n" +
|
|
2655
2655
|
" them is what this skill is for. Full skill: skills/suppa-form-v2/SKILL.md.",
|
|
2656
2656
|
inputSchema: {
|
|
2657
2657
|
mode: z
|
|
@@ -2713,9 +2713,9 @@ export function buildToolTable() {
|
|
|
2713
2713
|
" FULL state (an omitted variable is deleted), so an empty one is never sent and one that\n" +
|
|
2714
2714
|
" drops the form's default variable is refused. mobileSchema, code, localizations, entity,\n" +
|
|
2715
2715
|
" alias and parent are never sent; a child form's `schema.overrides` is preserved.\n\n" +
|
|
2716
|
-
" Refuses
|
|
2717
|
-
"
|
|
2718
|
-
" a form that moved
|
|
2716
|
+
" Refuses: someone else's lock (lockedBy), another form's file, a child's layer over a root,\n" +
|
|
2717
|
+
" a merged tree over a child, an emptied form, a published read. The file's `revision` (or\n" +
|
|
2718
|
+
" expected_revision) guards it: a form that moved is refused, not overwritten.",
|
|
2719
2719
|
inputSchema: {
|
|
2720
2720
|
form_id: z.number().describe("The Forms row id — the `form=` in the builder URL."),
|
|
2721
2721
|
path: z
|
package/dist/toolTable.js
CHANGED
|
@@ -6,9 +6,9 @@ export const PROFILES = {
|
|
|
6
6
|
schema: ["create_entity", "add_field", "update_field", "change_field_type", "update_entity_options", "set_title_field", "create_tabular_part", "list_tabular_parts", "list_field_types", "add_enum_values", "add_custom_field", "add_custom_fields_batch", "remove_custom_field", "restore_custom_field", "resolve_custom_fields", "link_custom_field", "apply_custom_fields", "validate_entity_code", "migrate_entities_from_v1", "read_v1_entities", "read_v1_entity_props", "read_v1_enum"],
|
|
7
7
|
docs: ["create_doc", "get_doc", "list_docs", "update_doc", "delete_doc", "create_page", "get_page", "list_pages", "read_page", "update_page", "delete_page", "create_blocks", "get_blocks", "insert_block", "update_block", "delete_block", "reorder_blocks"],
|
|
8
8
|
// Two form PRODUCTS live in this group, and the split is the thing to know before reading the
|
|
9
|
-
// list.
|
|
10
|
-
// misspelling) and the v1 field types. `form_kb` and `validate_form_schema` serve the 2.0
|
|
11
|
-
// entity-builder canvas — the `schema` COLUMN on the row since 2.1,
|
|
9
|
+
// list. Of the first seven, get_form reads both (a 2.x form as the builder reads it); the other six
|
|
10
|
+
// are Suppa 1.0: they read and write `data.formShema` (the platform's misspelling) and the v1 field types. `form_kb` and `validate_form_schema` serve the 2.0
|
|
11
|
+
// entity-builder canvas — the `schema` COLUMN on the row since 2.1, 57 component
|
|
12
12
|
// types — and share nothing with them.
|
|
13
13
|
forms: ["create_form", "get_form", "list_forms", "update_form", "add_field_to_form", "generate_form_schema", "list_form_field_types", "form_kb", "validate_form_schema",
|
|
14
14
|
"write_form_draft", "create_form_v2", "form_versions", "form_lifecycle"],
|
package/dist/tools/formV2.js
CHANGED
|
@@ -37,10 +37,9 @@ export function skillFile(...parts) {
|
|
|
37
37
|
* exists never looks for it — measured: given "зроби форму для клієнтів", agents with the CLI and
|
|
38
38
|
* agents with all 96 tools both reached for suppa_create_form, which writes the v1 blob.
|
|
39
39
|
*/
|
|
40
|
-
export const FORM_V2_INSTRUCTION_LINE = "FORMS — TWO PRODUCTS:
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"on the user's yes.";
|
|
40
|
+
export const FORM_V2_INSTRUCTION_LINE = "FORMS — TWO PRODUCTS: suppa_create_form/update_form write `data.formShema` (Suppa 1.0). A Suppa 2.x form " +
|
|
41
|
+
"is the `schema` COLUMN, 57 types (pre-2.1: `data.formSchema`): suppa_get_form reads it; suppa_form_kb, " +
|
|
42
|
+
"suppa_validate_form_schema (skills/suppa-form-v2/SKILL.md). Publish only on the user's yes.";
|
|
44
43
|
/**
|
|
45
44
|
* Is the vendored core actually USABLE, not merely present?
|
|
46
45
|
*
|
|
@@ -270,7 +269,7 @@ export async function formKb(mode, types, topic) {
|
|
|
270
269
|
if (!list.length) {
|
|
271
270
|
return jsonResponse({
|
|
272
271
|
error: "types is required for mode='api' — name the element types you are about to author, e.g. ['input','select'].",
|
|
273
|
-
note: `There is deliberately no way to fetch all
|
|
272
|
+
note: `There is deliberately no way to fetch all 57 at once: stripped of prose they are ~14,200 tokens, and the point of this tool is not to carry them. At most ${MAX_API_TYPES} per call.`,
|
|
274
273
|
});
|
|
275
274
|
}
|
|
276
275
|
// The cap is what makes the sentence above TRUE. Without it, listing all 58 in `types` returned
|
|
@@ -279,7 +278,7 @@ export async function formKb(mode, types, topic) {
|
|
|
279
278
|
if (list.length > MAX_API_TYPES) {
|
|
280
279
|
return jsonResponse({
|
|
281
280
|
error: `types names ${list.length} types; the cap is ${MAX_API_TYPES} per call.`,
|
|
282
|
-
note: "Name the types you are about to author — another call is free. Asking for all
|
|
281
|
+
note: "Name the types you are about to author — another call is free. Asking for all 57 is ~16,300 tokens, which is the cost this tool exists to avoid, not a shortcut.",
|
|
283
282
|
cap: MAX_API_TYPES,
|
|
284
283
|
asked: list.length,
|
|
285
284
|
});
|
|
@@ -886,6 +885,85 @@ function staleAnswer(message, id) {
|
|
|
886
885
|
current_revision: current,
|
|
887
886
|
};
|
|
888
887
|
}
|
|
888
|
+
const isFileObj = (v) => Boolean(v) && typeof v === "object" && !Array.isArray(v);
|
|
889
|
+
/** The one record of a `records` answer (suppa_search_records), else the file itself. */
|
|
890
|
+
const fileBody = (v) => {
|
|
891
|
+
if (!isFileObj(v))
|
|
892
|
+
return null;
|
|
893
|
+
const recs = v.records;
|
|
894
|
+
return Array.isArray(recs) && recs.length === 1 && isFileObj(recs[0]) ? recs[0] : v;
|
|
895
|
+
};
|
|
896
|
+
// The marker alone, wherever the read sits: an agent that copied the answer without `generation`, or kept it inside
|
|
897
|
+
// `records`, still holds a published read (review of 1.43.4).
|
|
898
|
+
const isPublishedRead = (v) => fileBody(v)?.read === "published";
|
|
899
|
+
const isRefId = (v) => Number.isInteger(v) && v > 0 ? v : isFileObj(v) && Number.isInteger(v.id) && v.id > 0 ? v.id : null;
|
|
900
|
+
/** The form a file was read from, when it says: a suppa_get_form answer's `id`, a previous-draft file's `form_id`, a
|
|
901
|
+
* one-record Forms read's row id. A FormVersions row's `id` is a VERSION, so a snapshot says nothing here. */
|
|
902
|
+
function fileFormId(v) {
|
|
903
|
+
if (!isFileObj(v))
|
|
904
|
+
return null;
|
|
905
|
+
if (typeof v.generation === "string")
|
|
906
|
+
return isRefId(v.id);
|
|
907
|
+
if (Number.isInteger(v.form_id))
|
|
908
|
+
return v.form_id;
|
|
909
|
+
const body = fileBody(v);
|
|
910
|
+
return body && body !== v && !("snapshot" in body) ? isRefId(body.id) : null;
|
|
911
|
+
}
|
|
912
|
+
/** The parent a file declares — a real reference only (parent / parentForm / parentVersion). */
|
|
913
|
+
function fileParent(v) {
|
|
914
|
+
const body = fileBody(v);
|
|
915
|
+
return body ? isRefId(body.parentForm) ?? isRefId(body.parent) : null;
|
|
916
|
+
}
|
|
917
|
+
/** The revision a suppa_get_form answer was read at — the guard of the write it becomes. */
|
|
918
|
+
const fileRevision = (v) => (isFileObj(v) && typeof v.generation === "string" && typeof v.revision === "string" ? v.revision : null);
|
|
919
|
+
const elementIds = (list) => Array.isArray(list) ? list.map((e) => (isFileObj(e) && typeof e.id === "string" ? e.id : null)).filter((x) => Boolean(x)) : [];
|
|
920
|
+
/**
|
|
921
|
+
* What a draft must not do to the form it is written to, judged against the LIVE row — each a refusal:
|
|
922
|
+
* another form's file; a child's layer over a form that is no child; a child's draft that carries elements it
|
|
923
|
+
* INHERITS (a merged tree — the published read, a FormVersions snapshot, or one copied out of either: written as the
|
|
924
|
+
* child's own layer they detach those elements from the parent); every element of a populated form removed.
|
|
925
|
+
* The inherited ids are the parent's published elements; when that read fails the check is said to be skipped.
|
|
926
|
+
*/
|
|
927
|
+
async function writeRefusals(id, file, row, draftComponents) {
|
|
928
|
+
// (a published read is refused before this — in the preview even when the row cannot be read)
|
|
929
|
+
const refusals = [];
|
|
930
|
+
const notes = [];
|
|
931
|
+
const fromForm = fileFormId(file);
|
|
932
|
+
if (fromForm !== null && fromForm !== id) {
|
|
933
|
+
refusals.push(`this file was read from form ${fromForm}, not form ${id}: written here it would replace form ${id}'s draft with another form's. Read form ${id} (suppa_get_form) and edit that.`);
|
|
934
|
+
}
|
|
935
|
+
const rowParent = isRefId(row.parent);
|
|
936
|
+
const declared = fileParent(file);
|
|
937
|
+
if (declared !== null && rowParent === null) {
|
|
938
|
+
refusals.push(`this file is a child form's layer (its parent is form ${declared}), and form ${id} is not a child: a child's own layer over a root form would remove the elements it has.`);
|
|
939
|
+
}
|
|
940
|
+
const own = elementIds(isFileObj(row.schema) ? row.schema.components : null);
|
|
941
|
+
const draftIds = elementIds(draftComponents);
|
|
942
|
+
if (draftIds.length === 0 && own.length > 0) {
|
|
943
|
+
refusals.push(`the draft has no elements and form ${id} has ${own.length}: saving it would delete every one. Remove elements in the builder if that is really meant.`);
|
|
944
|
+
}
|
|
945
|
+
if (rowParent !== null && draftIds.length) {
|
|
946
|
+
try {
|
|
947
|
+
const parent = (await makeRequest("GET", `/api/core/forms/${rowParent}/schema`, null, { query: { mode: "published" } }));
|
|
948
|
+
const inherited = new Set(elementIds(isFileObj(parent?.schema) ? parent.schema.components : null));
|
|
949
|
+
const ownSet = new Set(own);
|
|
950
|
+
const carried = draftIds.filter((x) => inherited.has(x) && !ownSet.has(x));
|
|
951
|
+
if (carried.length) {
|
|
952
|
+
refusals.push(`the draft carries ${carried.length} element(s) form ${id} INHERITS from its parent, form ${rowParent} (${carried.slice(0, 5).join(", ")}${carried.length > 5 ? ", …" : ""}): ` +
|
|
953
|
+
"a merged tree — a published read, a FormVersions snapshot, or one copied out of either. A child's draft is its OWN layer: " +
|
|
954
|
+
"read it with suppa_get_form (the draft) and edit that.");
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
catch (e) {
|
|
958
|
+
notes.push(`the inherited-element check was skipped: form ${rowParent}'s published elements could not be read (${e instanceof Error ? e.message : String(e)}).`);
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
return { refusals, notes };
|
|
962
|
+
}
|
|
963
|
+
const PUBLISHED_READ_REFUSAL = "this file is a suppa_get_form version='published' read — the version users see (a child form's MERGED tree, " +
|
|
964
|
+
"without its own layer), not the draft. Saved as the draft it would revert the draft's later edits and turn a " +
|
|
965
|
+
"child's inherited elements into its own. Read the draft (suppa_get_form without version) to edit it; to bring a " +
|
|
966
|
+
"published version back use suppa_form_lifecycle action='rollback'.";
|
|
889
967
|
export async function writeFormDraft(formId, path, confirm = false, normalize = false, expectedRevision = null) {
|
|
890
968
|
const id = Number(formId);
|
|
891
969
|
const target = String(path ?? "").trim();
|
|
@@ -926,6 +1004,10 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
|
|
|
926
1004
|
const peek = readJson(target);
|
|
927
1005
|
if (peek.error)
|
|
928
1006
|
preview = `the draft could not be read yet: ${peek.error}`;
|
|
1007
|
+
else if (isPublishedRead(peek.value)) {
|
|
1008
|
+
preview = "not a draft: a published read";
|
|
1009
|
+
gateLines = [`the confirmed call will REFUSE this file: ${PUBLISHED_READ_REFUSAL}`];
|
|
1010
|
+
}
|
|
929
1011
|
else {
|
|
930
1012
|
draftVars = sentVariables(peek.value);
|
|
931
1013
|
const s = skillFile("scripts", "validate-form-schema.mjs");
|
|
@@ -1026,11 +1108,30 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
|
|
|
1026
1108
|
variables = `the form's variables could not be read (${e instanceof Error ? e.message : String(e)}); the confirmed call reads them again and refuses if that fails`;
|
|
1027
1109
|
}
|
|
1028
1110
|
}
|
|
1029
|
-
|
|
1111
|
+
// What the confirmed call will refuse outright, said now — the same guards, against the same row.
|
|
1112
|
+
const fileValue = peeked.error ? null : peeked.value;
|
|
1113
|
+
const published = isPublishedRead(fileValue);
|
|
1114
|
+
let refused = published;
|
|
1115
|
+
if (row && fileValue && !published) {
|
|
1116
|
+
const guards = await writeRefusals(id, fileValue, row, draftComponents);
|
|
1117
|
+
for (const r of guards.refusals)
|
|
1118
|
+
warnings.push(`the confirmed call will REFUSE this file: ${r}`);
|
|
1119
|
+
warnings.push(...guards.notes);
|
|
1120
|
+
refused = guards.refusals.length > 0;
|
|
1121
|
+
}
|
|
1122
|
+
const fromFile = fileRevision(fileValue);
|
|
1123
|
+
if (fromFile && revision && fromFile !== revision) {
|
|
1124
|
+
warnings.push(`the form changed since this file was read (read at ${fromFile}, now ${revision}): the confirmed call sends the file's revision and the ` +
|
|
1125
|
+
"platform refuses it, so the change made since is not overwritten — read the form again (suppa_get_form) and redo the edit on it.");
|
|
1126
|
+
}
|
|
1127
|
+
else if (fromFile) {
|
|
1128
|
+
warnings.push(`the confirmed call is guarded by the revision this file was read at (${fromFile}): it is refused, not written, if the form changed since.`);
|
|
1129
|
+
}
|
|
1130
|
+
else if (revision) {
|
|
1030
1131
|
warnings.push(`pass expected_revision: "${revision}" on the confirmed call — it is then refused, not written, if the form changed since this preview.`);
|
|
1031
1132
|
}
|
|
1032
1133
|
return confirmRequired("save a form DRAFT (it never publishes)", { form_id: id, path: target }, {
|
|
1033
|
-
writes: ["schema", "settings", ...(draftVars ? ["variables"] : [])],
|
|
1134
|
+
writes: refused ? [] : ["schema", "settings", ...(draftVars ? ["variables"] : [])],
|
|
1034
1135
|
never_sent: NEVER_SENT,
|
|
1035
1136
|
publishes: false,
|
|
1036
1137
|
draft: preview,
|
|
@@ -1047,6 +1148,8 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
|
|
|
1047
1148
|
const read = readJson(target);
|
|
1048
1149
|
if (read.error)
|
|
1049
1150
|
return jsonResponse({ error: `the draft could not be read: ${read.error}` });
|
|
1151
|
+
if (isPublishedRead(read.value))
|
|
1152
|
+
return jsonResponse({ written: false, error: PUBLISHED_READ_REFUSAL });
|
|
1050
1153
|
// 1. NOTHING UNCHECKED IS EVER WRITTEN. The gate runs on the same file, with the same rules, and
|
|
1051
1154
|
// a refusal or any error stops the write. An envelope it cannot read at all is refused before
|
|
1052
1155
|
// the tenant is touched; everything else is judged against the form as the tenant holds it.
|
|
@@ -1130,6 +1233,12 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
|
|
|
1130
1233
|
}
|
|
1131
1234
|
if (gate.refused || !gate.ok)
|
|
1132
1235
|
return refusal(gate);
|
|
1236
|
+
// 3b. WHAT THE DRAFT MUST NOT DO TO THIS FORM — another form's file, a child's layer over a root form, a merged tree
|
|
1237
|
+
// over a child, every element removed. Judged against the live row, because the file can say anything.
|
|
1238
|
+
const guards = await writeRefusals(id, read.value, row, gate.draft?.schema);
|
|
1239
|
+
if (guards.refusals.length) {
|
|
1240
|
+
return jsonResponse({ written: false, error: guards.refusals.join(" "), refusals: guards.refusals, note: "Nothing was written." });
|
|
1241
|
+
}
|
|
1133
1242
|
// 4. SOMEONE ELSE HAS IT OPEN. The builder holds `lockedBy` while a form is being edited; writing
|
|
1134
1243
|
// under them means one of the two of you loses work without being told.
|
|
1135
1244
|
const lockedBy = row.lockedBy;
|
|
@@ -1199,7 +1308,11 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
|
|
|
1199
1308
|
if (existingSettings.isFormBuilderV2 === true && settings.isFormBuilderV2 !== true) {
|
|
1200
1309
|
settings.isFormBuilderV2 = true; // the host's routing flag — an edit must not drop it
|
|
1201
1310
|
}
|
|
1202
|
-
|
|
1311
|
+
// The guard is the revision the edit was BASED on: the caller's, else the one the file was read at (a suppa_get_form
|
|
1312
|
+
// answer carries it), and only else the row as read just now — which guards nothing about a save made in between.
|
|
1313
|
+
const fromFile = fileRevision(read.value);
|
|
1314
|
+
const revision = expectedRevision || fromFile || (typeof row.updatedAt === "string" ? row.updatedAt : null);
|
|
1315
|
+
const revisionFrom = expectedRevision ? "expected_revision" : fromFile ? "the file (the revision suppa_get_form read)" : "the row as read for this write";
|
|
1203
1316
|
const body = { schema: schemaColumn, settings };
|
|
1204
1317
|
if (draftVars)
|
|
1205
1318
|
body.variables = draftVars;
|
|
@@ -1217,8 +1330,9 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
|
|
|
1217
1330
|
// difference between a setting you decided to keep and one you did not know was still there.
|
|
1218
1331
|
settings_kept_because_the_draft_is_silent_about_them: Object.keys(existingSettings).filter((k) => !(k in (draft.settings ?? {}))),
|
|
1219
1332
|
guarded_by_revision: revision,
|
|
1333
|
+
revision_from: revisionFrom,
|
|
1220
1334
|
warnings: gate.warnings,
|
|
1221
|
-
notes: gate.notes,
|
|
1335
|
+
notes: [...(gate.notes ?? []), ...guards.notes],
|
|
1222
1336
|
...(gate.already_live.length ? { already_on_the_live_form: alreadyLive(gate.already_live) } : {}),
|
|
1223
1337
|
...(() => {
|
|
1224
1338
|
if (row.parent?.id)
|
package/dist/tools/forms.js
CHANGED
|
@@ -392,15 +392,29 @@ export async function listForms(entityName = null, formType = null, limit = 50)
|
|
|
392
392
|
const V2_FORM_TYPES = new Set(["create", "update", "custom", "workspace", "dashboard", "workspaceModule"]);
|
|
393
393
|
const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
394
394
|
const isEmpty = (v) => v == null || (Array.isArray(v) && v.length === 0);
|
|
395
|
-
|
|
396
|
-
|
|
395
|
+
const nonEmpty = (v) => Array.isArray(v) && v.length > 0;
|
|
396
|
+
/**
|
|
397
|
+
* What only a 2.x form has: elements in the schema column, a Code Form or its build, a mobile layout, the
|
|
398
|
+
* builder's flag, a parent (a child's own layer can be empty — its settings, elements and code inherited),
|
|
399
|
+
* overrides of a parent's elements, settings, connections or texts, or FormVariables rows.
|
|
400
|
+
*/
|
|
401
|
+
function hasV2Evidence(a) {
|
|
397
402
|
const schema = isObj(a.schema) ? a.schema : {};
|
|
398
|
-
return ((
|
|
399
|
-
(
|
|
403
|
+
return (nonEmpty(schema.components) ||
|
|
404
|
+
nonEmpty(schema.overrides) ||
|
|
405
|
+
nonEmpty(a.code) ||
|
|
406
|
+
a.codeArtifact != null ||
|
|
400
407
|
a.mobileSchema != null ||
|
|
401
408
|
(isObj(a.settings) && a.settings.isFormBuilderV2 === true) ||
|
|
402
|
-
|
|
409
|
+
a.parentForm != null ||
|
|
410
|
+
nonEmpty(a.settingsOverrides) ||
|
|
411
|
+
nonEmpty(a.connectionOverrides) ||
|
|
412
|
+
nonEmpty(a.localizationOverrides) ||
|
|
413
|
+
// FormVariables rows are 2.x only: measured on dev 2026-10-22, none of the 77 Suppa 1.0 forms has one
|
|
414
|
+
nonEmpty(a.variables));
|
|
403
415
|
}
|
|
416
|
+
/** An FB2 kind alone is weaker evidence: `Forms.type` is free text, and a 1.0 form can carry one. */
|
|
417
|
+
const hasV2Kind = (a) => typeof a.type === "string" && V2_FORM_TYPES.has(a.type);
|
|
404
418
|
/** A compiled bundle by its stamp and size — it is the build of `code`, ~the same size again. */
|
|
405
419
|
function artifactSummary(art) {
|
|
406
420
|
if (!isObj(art))
|
|
@@ -414,13 +428,21 @@ function artifactSummary(art) {
|
|
|
414
428
|
* Empty lists and nulls are dropped; the compiled bundle is summarized unless asked for.
|
|
415
429
|
*/
|
|
416
430
|
function v2FormAnswer(a, version, includeArtifact) {
|
|
417
|
-
|
|
431
|
+
// dataSources stays in `meta`: always [] today («Increment 2»), dropped as empty — but kept the day it is not.
|
|
432
|
+
const { schema, mobileSchema, settings, variables, localizations, code, codeArtifact, codeArtifacts, updatedAt, ...meta } = a;
|
|
418
433
|
const notes = [];
|
|
419
434
|
const parent = isObj(meta.parentForm) ? meta.parentForm : null;
|
|
420
435
|
if (parent && version === "draft") {
|
|
421
|
-
|
|
436
|
+
const pinned = meta.parentVersion != null ? `, pinned to its FormVersions row ${meta.parentVersion}` : "";
|
|
437
|
+
notes.push(`a child form: \`schema\` is its OWN layer over form ${parent.id ?? "?"}${pinned} — ` +
|
|
422
438
|
"`schema.overrides`, settingsOverrides and connectionOverrides — not what renders; " +
|
|
423
|
-
"version='published' is the merged form
|
|
439
|
+
"version='published' is the merged form this user sees.");
|
|
440
|
+
}
|
|
441
|
+
if (version === "published") {
|
|
442
|
+
// The published read leaves the sources out (entity-builder form-publish.service: code, inheritedCode,
|
|
443
|
+
// rawLayer are stripped) and names no parent — so it is neither a Code Form read nor a draft.
|
|
444
|
+
notes.push("a published read: the version THIS user sees, for reading only — suppa_write_form_draft refuses it. " +
|
|
445
|
+
"It carries no Code Form sources (only the compiled codeArtifact) and no parent; read the draft for those.");
|
|
424
446
|
}
|
|
425
447
|
if (!includeArtifact && isObj(codeArtifact)) {
|
|
426
448
|
notes.push("codeArtifact is the compiled build of `code`, summarized — include_artifact=true for its JS.");
|
|
@@ -437,7 +459,8 @@ function v2FormAnswer(a, version, includeArtifact) {
|
|
|
437
459
|
out.variables = variables ?? [];
|
|
438
460
|
if (!isEmpty(localizations))
|
|
439
461
|
out.localizations = localizations;
|
|
440
|
-
|
|
462
|
+
if (version === "draft")
|
|
463
|
+
out.code = code ?? [];
|
|
441
464
|
if (codeArtifact != null)
|
|
442
465
|
out.codeArtifact = includeArtifact ? codeArtifact : artifactSummary(codeArtifact);
|
|
443
466
|
const inherited = Array.isArray(codeArtifacts) ? codeArtifacts.filter((c) => isObj(c) && c.formId !== a.id) : [];
|
|
@@ -455,25 +478,54 @@ function v2FormAnswer(a, version, includeArtifact) {
|
|
|
455
478
|
* (formShema / formSettings / formModul).
|
|
456
479
|
*/
|
|
457
480
|
export async function getForm(formId, version = "draft", includeArtifact = false) {
|
|
481
|
+
const where = `GET /core/forms/${formId}/schema${version === "published" ? "?mode=published" : ""}`;
|
|
458
482
|
let assembled = null;
|
|
459
483
|
try {
|
|
460
484
|
const got = await makeRequest("GET", `/api/core/forms/${formId}/schema`, null, version === "published" ? { query: { mode: "published" } } : undefined);
|
|
461
|
-
|
|
485
|
+
// A 200 that is not a form is not «no builder read»: answering the row read instead would call a 2.x form 1.0.
|
|
486
|
+
if (!isObj(got))
|
|
487
|
+
throw new Error(`${where} answered 200 with ${got === null ? "null" : Array.isArray(got) ? "a list" : typeof got}, not a form`);
|
|
488
|
+
assembled = got;
|
|
462
489
|
}
|
|
463
490
|
catch (e) {
|
|
464
491
|
if (e?.status !== 404)
|
|
465
492
|
throw e;
|
|
493
|
+
// Only the platform's own «Form N not found» (data.not_found) means there is no such form for the builder; a
|
|
494
|
+
// 404 from anything else (a route this stand does not have, a proxy) is said, never read as «a 1.0 form».
|
|
495
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
496
|
+
// (every 404's text starts «HTTP 404 Not Found» — it is the platform's body that says which one this is)
|
|
497
|
+
if (!/data\.not_found|Form \d+ not found/.test(message)) {
|
|
498
|
+
throw new Error(`${where} answered a 404 that is not the platform's «form not found»: ${message}`);
|
|
499
|
+
}
|
|
466
500
|
if (version === "published") {
|
|
467
501
|
return jsonResponse({
|
|
468
502
|
error: `Form ${formId} has no published version this user sees (or does not exist). version='draft' reads the draft.`,
|
|
469
503
|
});
|
|
470
504
|
}
|
|
471
505
|
}
|
|
472
|
-
|
|
506
|
+
// A published version exists only for a 2.x form: whatever it holds, it is that form.
|
|
507
|
+
if (assembled && (version === "published" || hasV2Evidence(assembled))) {
|
|
508
|
+
return jsonResponse(v2FormAnswer(assembled, version, includeArtifact));
|
|
509
|
+
}
|
|
510
|
+
const result = (await selectEntity(ENTITY_FORMS, [makeFilter("id", formId)], FORM_DETAIL_FIELDS));
|
|
511
|
+
// An FB2 kind and nothing else: the row decides — a 1.0 layout in `data.formShema` is a 1.0 form, an
|
|
512
|
+
// empty one a 2.x form nobody has laid out yet.
|
|
513
|
+
const formShema = result && isObj(result.data) ? result.data.formShema : undefined;
|
|
514
|
+
if (assembled && hasV2Kind(assembled) && !nonEmpty(formShema)) {
|
|
473
515
|
return jsonResponse(v2FormAnswer(assembled, version, includeArtifact));
|
|
474
|
-
|
|
475
|
-
if (result === null)
|
|
516
|
+
}
|
|
517
|
+
if (result === null) {
|
|
518
|
+
// The builder read found the form, the row read did not: it is no deleted form — the row (a 1.0 form's layout)
|
|
519
|
+
// is what this user cannot read.
|
|
520
|
+
if (assembled) {
|
|
521
|
+
return jsonResponse({
|
|
522
|
+
error: `Form ${formId} exists (the builder read answered) but its Forms row could not be read — no access to the ` +
|
|
523
|
+
"row, most likely. The builder read holds no 2.x layout, so this is a Suppa 1.0 form whose `data` is in that row.",
|
|
524
|
+
type: assembled.type ?? null,
|
|
525
|
+
});
|
|
526
|
+
}
|
|
476
527
|
return notFoundAnswer(ENTITY_FORMS, formId, "form");
|
|
528
|
+
}
|
|
477
529
|
return jsonResponse({ generation: "1.0", ...result });
|
|
478
530
|
}
|
|
479
531
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suppa-mcp-2",
|
|
3
|
-
"version": "1.43.
|
|
3
|
+
"version": "1.43.5",
|
|
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": {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: suppa-form-v2
|
|
3
|
-
description: Author a Suppa 2.0/2.1 (entity-builder) FORM — the element canvas with
|
|
3
|
+
description: Author a Suppa 2.0/2.1 (entity-builder) FORM — the element canvas with 57 component types, grid/flex layout, data binding and conditions — and write it to a tenant. Use whenever the user wants to build, edit or lay out a form, a workspace, a dashboard or a record card in Suppa 2.0, or asks about form elements, form layout, binding a field to entity data, or a form's settings. NOT for Suppa 1.0 forms — those are suppa_create_form and the `formShema` blob, a different product. Trigger phrases (English) — "build a form", "create a form", "edit the form", "form layout", "add a field to the form", "record card", "workspace form", "dashboard", "bind this field"; (Ukrainian / Українська) — "зроби форму", "створи форму", "додай поле у форму", "виправ форму", "картка запису", "робочий простір", "дашборд", "прив'яжи поле".
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Suppa 2.x forms (the entity-builder canvas)
|
|
7
7
|
|
|
8
|
-
A form is a **flat array of elements**, rendered from
|
|
8
|
+
A form is a **flat array of elements**, rendered from 57 component types. Nesting, geometry and
|
|
9
9
|
every layout decision live inside each element's `layout` map, not in the array's order.
|
|
10
10
|
|
|
11
11
|
**Where it is stored changed in 2.1.** The live form is first-class columns on the `Forms` row —
|
|
@@ -48,14 +48,14 @@ record's card → `flat`. The gate judges it by the form's type.
|
|
|
48
48
|
| 7 | Write it | `suppa write-form-draft --form-id <id> --path <abs>` — see **The write path** |
|
|
49
49
|
| 8 | Look at it | `/form/<id>?version=draft` at 1600, 1366, 1000, 760, 600 and 375 px: every tab and accordion section open, each control hovered and Tab-focused. No sideways scroll, control rows ≥ 8px apart, no clipped focus ring. The gate sees none of this. |
|
|
50
50
|
|
|
51
|
-
Steps 2 and 3 are not optional reading. The catalog is
|
|
51
|
+
Steps 2 and 3 are not optional reading. The catalog is 57 types and the prop tables are ~14,200
|
|
52
52
|
tokens in total — which is exactly why they are fetched per type instead of carried. Skipping them
|
|
53
53
|
produces a form built out of `input` and `html` that passes every check and is the wrong form.
|
|
54
54
|
|
|
55
55
|
**Reading a form.** `suppa_get_form` is the builder's own read of the 2.x draft: schema, settings,
|
|
56
|
-
variables, localizations, the Code Form's `code` and `revision` (`version='published'`: what
|
|
57
|
-
|
|
58
|
-
an unpublished draft. Who has it open is `lockedBy` on `Forms` (`suppa_search_records`).
|
|
56
|
+
variables, localizations, the Code Form's `code` and `revision` (`version='published'`: what this user
|
|
57
|
+
sees, read-only). Save the answer to a file: it is the baseline the gate takes as it is, and the copy to
|
|
58
|
+
restore an unpublished draft. Who has it open is `lockedBy` on `Forms` (`suppa_search_records`).
|
|
59
59
|
|
|
60
60
|
## Rules
|
|
61
61
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"source": "suppa-ai-agent/packages/formbuilder-agent",
|
|
3
|
-
"sha": "
|
|
4
|
-
"pulledAt": "2026-10-
|
|
5
|
-
"components":
|
|
3
|
+
"sha": "821ee77fd96bb0510913f9c5824f1b14b4c91d2f",
|
|
4
|
+
"pulledAt": "2026-10-21",
|
|
5
|
+
"components": 57,
|
|
6
6
|
"templates": 8,
|
|
7
|
-
"coreBytes":
|
|
7
|
+
"coreBytes": 1259259,
|
|
8
8
|
"why": "Vendored, not depended on. Re-run scripts/sync-formbuilder.mjs after every frontend release: the manifest is a snapshot, and drift in the ACCEPT direction is silent."
|
|
9
9
|
}
|
|
@@ -2261,6 +2261,16 @@
|
|
|
2261
2261
|
"control": "unit",
|
|
2262
2262
|
"group": "style"
|
|
2263
2263
|
},
|
|
2264
|
+
{
|
|
2265
|
+
"path": "sectionStyle",
|
|
2266
|
+
"control": "segmented",
|
|
2267
|
+
"group": "style",
|
|
2268
|
+
"options": [
|
|
2269
|
+
"list",
|
|
2270
|
+
"cards"
|
|
2271
|
+
],
|
|
2272
|
+
"default": "list"
|
|
2273
|
+
},
|
|
2264
2274
|
{
|
|
2265
2275
|
"path": "borderWidth",
|
|
2266
2276
|
"control": "unit",
|
|
@@ -2331,6 +2341,12 @@
|
|
|
2331
2341
|
"path": "filterBy",
|
|
2332
2342
|
"control": "elementSelect",
|
|
2333
2343
|
"group": "state"
|
|
2344
|
+
},
|
|
2345
|
+
{
|
|
2346
|
+
"path": "hideWhenEmpty",
|
|
2347
|
+
"control": "checkbox",
|
|
2348
|
+
"group": "state",
|
|
2349
|
+
"default": false
|
|
2334
2350
|
}
|
|
2335
2351
|
],
|
|
2336
2352
|
"avatar": [
|
|
@@ -3074,11 +3090,12 @@
|
|
|
3074
3090
|
"control": "segmented",
|
|
3075
3091
|
"group": "data",
|
|
3076
3092
|
"options": [
|
|
3093
|
+
"auto",
|
|
3077
3094
|
"local",
|
|
3078
3095
|
"publish",
|
|
3079
3096
|
"off"
|
|
3080
3097
|
],
|
|
3081
|
-
"default": "
|
|
3098
|
+
"default": "auto"
|
|
3082
3099
|
},
|
|
3083
3100
|
{
|
|
3084
3101
|
"path": "recordForm",
|
|
@@ -3583,6 +3600,41 @@
|
|
|
3583
3600
|
"group": "data"
|
|
3584
3601
|
}
|
|
3585
3602
|
],
|
|
3603
|
+
"customFields": [
|
|
3604
|
+
{
|
|
3605
|
+
"path": "label",
|
|
3606
|
+
"control": "localizedText",
|
|
3607
|
+
"group": "content"
|
|
3608
|
+
},
|
|
3609
|
+
{
|
|
3610
|
+
"path": "showAllFields",
|
|
3611
|
+
"control": "checkbox",
|
|
3612
|
+
"group": "main",
|
|
3613
|
+
"default": true
|
|
3614
|
+
},
|
|
3615
|
+
{
|
|
3616
|
+
"path": "fieldColumns",
|
|
3617
|
+
"control": "segmented",
|
|
3618
|
+
"group": "layout",
|
|
3619
|
+
"options": [
|
|
3620
|
+
1,
|
|
3621
|
+
2,
|
|
3622
|
+
3
|
|
3623
|
+
],
|
|
3624
|
+
"default": 1
|
|
3625
|
+
},
|
|
3626
|
+
{
|
|
3627
|
+
"path": "filterBy",
|
|
3628
|
+
"control": "elementSelect",
|
|
3629
|
+
"group": "state"
|
|
3630
|
+
},
|
|
3631
|
+
{
|
|
3632
|
+
"path": "hideWhenEmpty",
|
|
3633
|
+
"control": "checkbox",
|
|
3634
|
+
"group": "state",
|
|
3635
|
+
"default": false
|
|
3636
|
+
}
|
|
3637
|
+
],
|
|
3586
3638
|
"approvals": [
|
|
3587
3639
|
{
|
|
3588
3640
|
"path": "label",
|
|
@@ -3995,7 +4047,7 @@
|
|
|
3995
4047
|
"path": "settings.style.outerBorder",
|
|
3996
4048
|
"control": "checkbox",
|
|
3997
4049
|
"group": "style",
|
|
3998
|
-
"default":
|
|
4050
|
+
"default": false
|
|
3999
4051
|
},
|
|
4000
4052
|
{
|
|
4001
4053
|
"path": "settings.style.rounded",
|
|
@@ -4383,7 +4435,7 @@
|
|
|
4383
4435
|
"none",
|
|
4384
4436
|
"zebra"
|
|
4385
4437
|
],
|
|
4386
|
-
"default": "
|
|
4438
|
+
"default": "rows"
|
|
4387
4439
|
},
|
|
4388
4440
|
{
|
|
4389
4441
|
"path": "dataSource.showUnsavedBar",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Choosing between element types that both validate
|
|
2
2
|
|
|
3
|
-
*Open when more than one of the
|
|
3
|
+
*Open when more than one of the 57 types could carry what the user asked for, or before authoring `date`, `code`, `buttonList`, `chips`, `comments`, `history`, `approvals`, `checklist`, or a decomposed workspace.*
|
|
4
4
|
|
|
5
5
|
**`textarea` / `richText` / `html`** — plain multi-line notes → `textarea`; formatted text the *user* edits → `richText` (value is an HTML string, bindable only to a string field); markup *you* author → `html`. `html` interpolates `{{path}}` tokens but is never a home for record data — bind an element instead. `richText.collapseAfterLines` is inert once the element has a definite height (`heightMode` `fixed`/`fill`, or any pinned height): pin the height or collapse, never both.
|
|
6
6
|
|
|
@@ -34,4 +34,4 @@ Four types hold a value and get **no** automatic key: `table` (its edited rows),
|
|
|
34
34
|
|
|
35
35
|
## A type you have not met
|
|
36
36
|
|
|
37
|
-
`suppa form-kb --mode components` lists all
|
|
37
|
+
`suppa form-kb --mode components` lists all 57 with their purpose; `--mode api --types <type> --types <type>` gives the prop tables (a list flag repeats — it takes no JSON array), `--mode note --topic <type>` the behaviour note. Never assemble something out of `input` + `html` because no type came to mind.
|
|
@@ -30,7 +30,7 @@ The live form is first-class columns on the `Forms` row:
|
|
|
30
30
|
**Reading the form** goes through the same server. `suppa_get_form` is the builder's own read (`GET /core/forms/:id/schema`):
|
|
31
31
|
- the draft's `schema`, `mobileSchema`, `settings`, `variables`, `localizations` and the Code Form's files (`code`);
|
|
32
32
|
- `revision` (the `expected_revision` of a write);
|
|
33
|
-
- with `version='published'`, the version
|
|
33
|
+
- with `version='published'`, the version this user sees (for a child form, the merged tree). It is for reading only: it carries no Code Form sources (only the compiled `codeArtifact`) and no parent, and `suppa_write_form_draft` refuses it. A published version comes back through `suppa_form_lifecycle` rollback.
|
|
34
34
|
|
|
35
35
|
The compiled bundle comes only with `include_artifact=true`. The answer is a `{ schema, settings, variables }` draft, so the gate and `suppa_write_form_draft` read it as it is. Who has the form open is `lockedBy` / `lockedAt` on `Forms` (`suppa_search_records`, filtered by `id`).
|
|
36
36
|
|