suppa-mcp-2 1.44.5 → 1.45.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 +5 -3
- package/dist/codeForm/api.js +150 -0
- package/dist/codeForm/typecheck.js +324 -0
- package/dist/codeForm/workspace.js +356 -0
- package/dist/server.js +49 -3
- package/dist/toolTable.js +1 -1
- package/dist/tools/formCode.js +644 -0
- package/dist/tools/formV2.js +53 -41
- package/dist/tools/forms.js +2 -2
- package/package.json +4 -3
- package/skills/suppa-cli/SKILL.md +1 -1
- package/skills/suppa-form-v2/SKILL.md +7 -0
- package/skills/suppa-form-v2/code-form/SOURCE.json +19 -0
- package/skills/suppa-form-v2/code-form/sdk/index.d.ts +55926 -0
- package/skills/suppa-form-v2/references/code-form.md +174 -0
- package/skills/suppa-form-v2/scripts/code-form/code-form-core.mjs +562 -0
package/dist/tools/formV2.js
CHANGED
|
@@ -871,8 +871,55 @@ async function gateEdit(mod, draft, live, normalize) {
|
|
|
871
871
|
return { ...g, ok: added.length === 0, errors: added, already_live: already };
|
|
872
872
|
}
|
|
873
873
|
const alreadyLive = (list) => list.map((f) => ({ code: f?.code, elementId: f?.elementId ?? null }));
|
|
874
|
+
/**
|
|
875
|
+
* SOMEONE ELSE HAS IT OPEN. The builder holds `lockedBy` while a form is being edited; writing under them means
|
|
876
|
+
* one of the two of you loses work without being told — a refusal. The caller's OWN lock is a note: that tab's
|
|
877
|
+
* next save overwrites this write. `row` needs lockedBy { id, fullName } and lockedAt.
|
|
878
|
+
*/
|
|
879
|
+
export async function formLock(id, row) {
|
|
880
|
+
const lockedBy = row.lockedBy;
|
|
881
|
+
if (!lockedBy?.id)
|
|
882
|
+
return { note: null };
|
|
883
|
+
let mine = null;
|
|
884
|
+
try {
|
|
885
|
+
const me = JSON.parse(await tasks.getMe());
|
|
886
|
+
mine = typeof me?.id === "number" ? me.id : null;
|
|
887
|
+
}
|
|
888
|
+
catch {
|
|
889
|
+
mine = null;
|
|
890
|
+
}
|
|
891
|
+
if (mine === null || lockedBy.id !== mine) {
|
|
892
|
+
// The lock is sticky BY DESIGN: there is no heartbeat, so a killed tab leaves it held
|
|
893
|
+
// forever and there is nobody to ask. The platform's own takeover modal answers this by
|
|
894
|
+
// stating the lock's age; so does this refusal, for the same reason.
|
|
895
|
+
const heldSince = typeof row.lockedAt === "string" ? row.lockedAt : null;
|
|
896
|
+
const ageMs = heldSince ? Date.now() - Date.parse(heldSince) : NaN;
|
|
897
|
+
const age = Number.isFinite(ageMs)
|
|
898
|
+
? (ageMs > 36e5 ? `${Math.round(ageMs / 36e5)}h` : `${Math.max(1, Math.round(ageMs / 6e4))}min`)
|
|
899
|
+
: null;
|
|
900
|
+
return {
|
|
901
|
+
note: null,
|
|
902
|
+
refusal: {
|
|
903
|
+
locked_by: lockedBy,
|
|
904
|
+
locked_at: heldSince,
|
|
905
|
+
error: `form ${id} is open in the builder by ${lockedBy.fullName ?? `user ${lockedBy.id}`}` +
|
|
906
|
+
`${age ? `, held for ${age}` : ""}. Writing under them would silently lose one of the two ` +
|
|
907
|
+
"edits. A lock has no heartbeat, so a crashed tab holds one forever and there may be " +
|
|
908
|
+
"nobody to ask: if it looks dead, a human opens the form and presses Take over in the " +
|
|
909
|
+
"lock banner — always available, always asks, and it discards the holder's unsaved work.",
|
|
910
|
+
},
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
// The lock is the CALLER's: its own builder tab is open on this form. That tab's next save goes
|
|
914
|
+
// out with no revision guard (the builder sends none until the draft payload carries updatedAt,
|
|
915
|
+
// FE base-forms-inheritance.md), so it would overwrite this write without a 409.
|
|
916
|
+
return {
|
|
917
|
+
note: `form ${id} is locked by your own account — a builder tab of yours has it open. That tab's next ` +
|
|
918
|
+
"save overwrites this write with no warning: reload or close the builder tab before anyone saves there.",
|
|
919
|
+
};
|
|
920
|
+
}
|
|
874
921
|
/** A 409 from the revision guard, in words, with the revision the row holds now. */
|
|
875
|
-
function staleAnswer(message, id) {
|
|
922
|
+
export function staleAnswer(message, id) {
|
|
876
923
|
// The status, not a 409 anywhere in the text: a 400 whose body names form 409 is a 400.
|
|
877
924
|
if (!/^HTTP 409\b/.test(message) && !/changed since it was loaded/i.test(message))
|
|
878
925
|
return null;
|
|
@@ -1239,46 +1286,11 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
|
|
|
1239
1286
|
if (guards.refusals.length) {
|
|
1240
1287
|
return jsonResponse({ written: false, error: guards.refusals.join(" "), refusals: guards.refusals, note: "Nothing was written." });
|
|
1241
1288
|
}
|
|
1242
|
-
// 4. SOMEONE ELSE HAS IT OPEN
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
let mine = null;
|
|
1248
|
-
try {
|
|
1249
|
-
const me = JSON.parse(await tasks.getMe());
|
|
1250
|
-
mine = typeof me?.id === "number" ? me.id : null;
|
|
1251
|
-
}
|
|
1252
|
-
catch {
|
|
1253
|
-
mine = null;
|
|
1254
|
-
}
|
|
1255
|
-
if (mine === null || lockedBy.id !== mine) {
|
|
1256
|
-
// The lock is sticky BY DESIGN: there is no heartbeat, so a killed tab leaves it held
|
|
1257
|
-
// forever and there is nobody to ask. The platform's own takeover modal answers this by
|
|
1258
|
-
// stating the lock's age; so does this refusal, for the same reason.
|
|
1259
|
-
const heldSince = typeof row.lockedAt === "string" ? row.lockedAt : null;
|
|
1260
|
-
const ageMs = heldSince ? Date.now() - Date.parse(heldSince) : NaN;
|
|
1261
|
-
const age = Number.isFinite(ageMs)
|
|
1262
|
-
? (ageMs > 36e5 ? `${Math.round(ageMs / 36e5)}h` : `${Math.max(1, Math.round(ageMs / 6e4))}min`)
|
|
1263
|
-
: null;
|
|
1264
|
-
return jsonResponse({
|
|
1265
|
-
written: false,
|
|
1266
|
-
locked_by: lockedBy,
|
|
1267
|
-
locked_at: heldSince,
|
|
1268
|
-
error: `form ${id} is open in the builder by ${lockedBy.fullName ?? `user ${lockedBy.id}`}` +
|
|
1269
|
-
`${age ? `, held for ${age}` : ""}. Writing under them would silently lose one of the two ` +
|
|
1270
|
-
"edits. A lock has no heartbeat, so a crashed tab holds one forever and there may be " +
|
|
1271
|
-
"nobody to ask: if it looks dead, a human opens the form and presses Take over in the " +
|
|
1272
|
-
"lock banner — always available, always asks, and it discards the holder's unsaved work.",
|
|
1273
|
-
});
|
|
1274
|
-
}
|
|
1275
|
-
// The lock is the CALLER's: its own builder tab is open on this form. That tab's next save goes
|
|
1276
|
-
// out with no revision guard (the builder sends none until the draft payload carries updatedAt,
|
|
1277
|
-
// FE base-forms-inheritance.md), so it would overwrite this write without a 409.
|
|
1278
|
-
lockNote =
|
|
1279
|
-
`form ${id} is locked by your own account — a builder tab of yours has it open. That tab's next ` +
|
|
1280
|
-
"save overwrites this write with no warning: reload or close the builder tab before anyone saves there.";
|
|
1281
|
-
}
|
|
1289
|
+
// 4. SOMEONE ELSE HAS IT OPEN — see formLock.
|
|
1290
|
+
const lock = await formLock(id, row);
|
|
1291
|
+
if (lock.refusal)
|
|
1292
|
+
return jsonResponse({ written: false, ...lock.refusal });
|
|
1293
|
+
const lockNote = lock.note;
|
|
1282
1294
|
const existingSchema = (row.schema && typeof row.schema === "object" && !Array.isArray(row.schema)
|
|
1283
1295
|
? row.schema
|
|
1284
1296
|
: {});
|
package/dist/tools/forms.js
CHANGED
|
@@ -399,7 +399,7 @@ const nonEmpty = (v) => Array.isArray(v) && v.length > 0;
|
|
|
399
399
|
* builder's flag, a parent (a child's own layer can be empty — its settings, elements and code inherited),
|
|
400
400
|
* overrides of a parent's elements, settings, connections or texts, or FormVariables rows.
|
|
401
401
|
*/
|
|
402
|
-
function hasV2Evidence(a) {
|
|
402
|
+
export function hasV2Evidence(a) {
|
|
403
403
|
const schema = isObj(a.schema) ? a.schema : {};
|
|
404
404
|
return (nonEmpty(schema.components) ||
|
|
405
405
|
nonEmpty(schema.overrides) ||
|
|
@@ -415,7 +415,7 @@ function hasV2Evidence(a) {
|
|
|
415
415
|
nonEmpty(a.variables));
|
|
416
416
|
}
|
|
417
417
|
/** An FB2 kind alone is weaker evidence: `Forms.type` is free text, and a 1.0 form can carry one. */
|
|
418
|
-
const hasV2Kind = (a) => typeof a.type === "string" && V2_FORM_TYPES.has(a.type);
|
|
418
|
+
export const hasV2Kind = (a) => typeof a.type === "string" && V2_FORM_TYPES.has(a.type);
|
|
419
419
|
/** A compiled bundle by its stamp and size — it is the build of `code`, ~the same size again. */
|
|
420
420
|
function artifactSummary(art) {
|
|
421
421
|
if (!isObj(art))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suppa-mcp-2",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.45.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
6
|
"bin": {
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
"sync:formbuilder": "node scripts/sync-formbuilder.mjs",
|
|
43
43
|
"sync:vue-compiler": "node scripts/sync-vue-compiler.mjs",
|
|
44
44
|
"guards:install": "node skills/suppa-entity-code/scripts/install-entity-code-guards.mjs",
|
|
45
|
-
"check:projections": "node scripts/check-own-projections.mjs"
|
|
45
|
+
"check:projections": "node scripts/check-own-projections.mjs",
|
|
46
|
+
"sync:code-form": "node scripts/sync-code-form.mjs"
|
|
46
47
|
},
|
|
47
48
|
"keywords": [
|
|
48
49
|
"mcp",
|
|
@@ -66,6 +67,7 @@
|
|
|
66
67
|
"dependencies": {
|
|
67
68
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
68
69
|
"@napi-rs/keyring": "^1.1.0",
|
|
70
|
+
"typescript": "~5.9.3",
|
|
69
71
|
"zod": "^3.23.8"
|
|
70
72
|
},
|
|
71
73
|
"devDependencies": {
|
|
@@ -73,7 +75,6 @@
|
|
|
73
75
|
"@vue/compiler-dom": "3.5.12",
|
|
74
76
|
"acorn": "8.15.0",
|
|
75
77
|
"esbuild": "^0.21.5",
|
|
76
|
-
"typescript": "^5.6.0",
|
|
77
78
|
"vitest": "^2.1.0"
|
|
78
79
|
}
|
|
79
80
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: suppa-cli
|
|
3
|
-
description: Use when working with a Suppa 2.0 tenant from a terminal — tasks, records, entities, custom fields, docs, forms, automations, file attachments. The `suppa` command carries all
|
|
3
|
+
description: Use when working with a Suppa 2.0 tenant from a terminal — tasks, records, entities, custom fields, docs, forms, automations, file attachments. The `suppa` command carries all 108 operations with browser-based login and token storage in the OS keychain. Prefer it over hand-written HTTP calls: validates arguments before sending and explains platform refusals.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Suppa 2.0 from the shell
|
|
@@ -182,6 +182,12 @@ and the write compile `compiledRender` (the browser production build the builder
|
|
|
182
182
|
stored render canonically, never byte for byte. Contract:
|
|
183
183
|
`suppa form-kb --mode note --topic dynamicComponent`; custom chart: `--mode ref --topic custom-chart`.
|
|
184
184
|
|
|
185
|
+
## The form's code (Code Form)
|
|
186
|
+
|
|
187
|
+
`code` (TypeScript against `formAPI`) is never written by `write-form-draft`:
|
|
188
|
+
`suppa form-code --mode <rules|pull|api|check>`, then `suppa push-form-code --form-id <id>`.
|
|
189
|
+
Rules: `references/code-form.md`.
|
|
190
|
+
|
|
185
191
|
## References
|
|
186
192
|
|
|
187
193
|
Read on demand, never up front — `suppa form-kb --mode ref --topic <name>`.
|
|
@@ -198,5 +204,6 @@ Read on demand, never up front — `suppa form-kb --mode ref --topic <name>`.
|
|
|
198
204
|
| `references/styling.md` | Contrast, options before CSS, `theme`/`styleIntent`, custom SCSS |
|
|
199
205
|
| `references/card-kit.md` | The record-card kit: a record card, a create form, a window |
|
|
200
206
|
| `references/publishing.md` | The write path, metadata columns, the Localizations registry, entity plans |
|
|
207
|
+
| `references/code-form.md` | The form's code: `formAPI`, events, imports, the build on save, conflicts |
|
|
201
208
|
| `notes/dynamicComponent.md` | Any dynamicComponent: sandbox, formAPI, styles, translations |
|
|
202
209
|
| `notes/<type>.md` | Behaviour of one type — `suppa form-kb --mode note --topic <type>` |
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "platform-front (suppa front)",
|
|
3
|
+
"ref": "origin/backend2/develop",
|
|
4
|
+
"commit": "41a0f90a2e426b8a745353cf29685feab24202aa",
|
|
5
|
+
"committed": "2026-11-12",
|
|
6
|
+
"pulledAt": "2026-11-12",
|
|
7
|
+
"files": {
|
|
8
|
+
"code-form/sdk/index.d.ts": {
|
|
9
|
+
"from": "src/formBuilderV2/codeForm/virtualProject/generatedSdkDts.ts (CODE_FORM_SDK_DTS)",
|
|
10
|
+
"bytes": 7179872,
|
|
11
|
+
"sha256": "8b52fdbb860ed921942fb89d3925848e674e433e6199381e83368c30f9bf50f7"
|
|
12
|
+
},
|
|
13
|
+
"scripts/code-form/code-form-core.mjs": {
|
|
14
|
+
"from": "codeForm/typeGen, codeForm/virtualProject, codeForm/diagnostics, codeForm/files, chart/custom/customChartSchema, shared/dynamicWidget/widgetApiKeys",
|
|
15
|
+
"bytes": 22840
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"why": "Vendored, not depended on. The backend builds a form's code against ITS OWN SDK copy, so a check against a stale snapshot can pass here and fail on save (or the reverse) — re-run scripts/sync-code-form.mjs after every front release that touches Code Form."
|
|
19
|
+
}
|