suppa-mcp-2 1.43.1 → 1.43.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -2456,11 +2456,16 @@ export function buildToolTable() {
2456
2456
  annotations: _READ,
2457
2457
  }, async (a) => text(await forms.listForms(a.entity_name, a.form_type, a.limit)));
2458
2458
  reg("suppa_get_form", {
2459
- description: "Get a SUPPA 1.0 form by ID (data.formShema, settings). A 2.x form's draft is the schema\n" +
2460
- " COLUMN: read Forms or FormVersions (snapshot) with suppa_search_records.",
2461
- inputSchema: { form_id: z.number().int() },
2459
+ description: "Get a form by ID. 2.x: the builder's read — schema, settings, variables, localizations, the\n" +
2460
+ " Code Form's files (`code`), `revision`; saved to a file, the gate's baseline and a\n" +
2461
+ " suppa_write_form_draft draft. Suppa 1.0: the row's `data` (formShema).",
2462
+ inputSchema: {
2463
+ form_id: z.number().int(),
2464
+ version: z.enum(["draft", "published"]).default("draft").describe("2.x: published = what users see."),
2465
+ include_artifact: z.boolean().default(false).describe("2.x: also the compiled JS of `code`."),
2466
+ },
2462
2467
  annotations: _READ,
2463
- }, async (a) => text(await forms.getForm(a.form_id)));
2468
+ }, async (a) => text(await forms.getForm(a.form_id, a.version ?? "draft", a.include_artifact ?? false)));
2464
2469
  reg("suppa_create_form", {
2465
2470
  description: "Create a new form. Provide schema_json (array of fields or {formShema}), or set\n" +
2466
2471
  " generate_from_entity=true WITH entity_name to auto-build fields from the entity\n" +
@@ -510,8 +510,19 @@ async function cardKit(topic) {
510
510
  }),
511
511
  schema,
512
512
  canvas: {
513
- note: "A NEW card starts on the kit page's canvas; merging into an existing form, keep that form's settings.",
514
- settings: { backgroundColor: kit.form.settings?.backgroundColor, xGap: kit.form.settings?.xGap, yGap: kit.form.settings?.yGap },
513
+ note: "A NEW card starts on the kit page's canvas — its grid too: the patterns are laid out on its 12 columns and its " +
514
+ "lg / md / sm breakpoints, and without them the gate refuses them (span_exceeds_parent_columns) and drops their " +
515
+ "md / sm layouts. Merging into an existing form, keep that form's settings and re-place the patterns on its grid.",
516
+ // The page's grid and canvas, as the plugin's kit-extract carries them — NOT its showSubmitButton (the kit is a showcase,
517
+ // a create form needs the platform's Save) nor its 24px page padding (a card's blocks sit 12px from the edge).
518
+ settings: {
519
+ isFormBuilderV2: true,
520
+ columnsNumber: kit.form.settings?.columnsNumber,
521
+ breakpoints: kit.form.settings?.breakpoints,
522
+ backgroundColor: kit.form.settings?.backgroundColor,
523
+ xGap: kit.form.settings?.xGap,
524
+ yGap: kit.form.settings?.yGap,
525
+ },
515
526
  },
516
527
  todo,
517
528
  keep: "Change DATA only — bindings, picker sources, texts and translations, layout x / y / width. The LOOK keys stay as the kit has them: containerSettings, labelSettings, labelLocation, variant, transparent, icon, tab colours, Custom CSS.",
@@ -386,12 +386,95 @@ export async function listForms(entityName = null, formType = null, limit = 50)
386
386
  const results = await searchEntity(ENTITY_FORMS, filters, FORM_LIST_FIELDS, limit);
387
387
  return jsonResponse(results);
388
388
  }
389
- /** Get a form by ID including its full schema (data.formShema) and settings. */
390
- export async function getForm(formId) {
389
+ // The Form Builder 2 kinds. A Suppa 1.0 form is elementForm / createForm / customForm / moreButtonForm /
390
+ // selectForm, and its layout is the `data` blob; measured on dev 2026-10-21, 286 of 409 rows carry
391
+ // `settings.isFormBuilderV2` and 240 a Code Form — while form 378, an `update` with code, has no flag.
392
+ const V2_FORM_TYPES = new Set(["create", "update", "custom", "workspace", "dashboard", "workspaceModule"]);
393
+ const isObj = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
394
+ const isEmpty = (v) => v == null || (Array.isArray(v) && v.length === 0);
395
+ /** A 2.x form: elements in the schema column, a Code Form, a mobile layout, the builder's flag or an FB2 kind. */
396
+ function isV2Form(a) {
397
+ const schema = isObj(a.schema) ? a.schema : {};
398
+ return ((Array.isArray(schema.components) && schema.components.length > 0) ||
399
+ (Array.isArray(a.code) && a.code.length > 0) ||
400
+ a.mobileSchema != null ||
401
+ (isObj(a.settings) && a.settings.isFormBuilderV2 === true) ||
402
+ (typeof a.type === "string" && V2_FORM_TYPES.has(a.type)));
403
+ }
404
+ /** A compiled bundle by its stamp and size — it is the build of `code`, ~the same size again. */
405
+ function artifactSummary(art) {
406
+ if (!isObj(art))
407
+ return art ?? null;
408
+ const { code, ...stamp } = art;
409
+ return { ...stamp, bytes: typeof code === "string" ? code.length : 0 };
410
+ }
411
+ /**
412
+ * The 2.x answer: the builder's own read, shaped as the { schema, settings, variables } draft the
413
+ * gate and suppa_write_form_draft take as they are — saved to a file it is an edit's baseline.
414
+ * Empty lists and nulls are dropped; the compiled bundle is summarized unless asked for.
415
+ */
416
+ function v2FormAnswer(a, version, includeArtifact) {
417
+ const { schema, mobileSchema, settings, variables, localizations, code, codeArtifact, codeArtifacts, dataSources, updatedAt, ...meta } = a;
418
+ const notes = [];
419
+ const parent = isObj(meta.parentForm) ? meta.parentForm : null;
420
+ if (parent && version === "draft") {
421
+ notes.push(`a child form: \`schema\` is its OWN layer over form ${parent.id ?? "?"} v${meta.parentVersion ?? "?"} — ` +
422
+ "`schema.overrides`, settingsOverrides and connectionOverrides — not what renders; " +
423
+ "version='published' is the merged form users see.");
424
+ }
425
+ if (!includeArtifact && isObj(codeArtifact)) {
426
+ notes.push("codeArtifact is the compiled build of `code`, summarized — include_artifact=true for its JS.");
427
+ }
428
+ const out = { generation: "2.x", read: version };
429
+ for (const [k, v] of Object.entries(meta))
430
+ if (!isEmpty(v))
431
+ out[k] = v;
432
+ if (typeof updatedAt === "string")
433
+ out.revision = updatedAt;
434
+ if (notes.length)
435
+ out.notes = notes;
436
+ out.settings = settings ?? {};
437
+ out.variables = variables ?? [];
438
+ if (!isEmpty(localizations))
439
+ out.localizations = localizations;
440
+ out.code = code ?? [];
441
+ if (codeArtifact != null)
442
+ out.codeArtifact = includeArtifact ? codeArtifact : artifactSummary(codeArtifact);
443
+ const inherited = Array.isArray(codeArtifacts) ? codeArtifacts.filter((c) => isObj(c) && c.formId !== a.id) : [];
444
+ if (inherited.length)
445
+ out.inheritedCodeArtifacts = includeArtifact ? inherited : inherited.map(artifactSummary);
446
+ out.schema = schema ?? { components: [] };
447
+ if (mobileSchema != null)
448
+ out.mobileSchema = mobileSchema;
449
+ return out;
450
+ }
451
+ /**
452
+ * Get a form by ID. A Suppa 2.x form comes from the builder's own read (GET /core/forms/:id/schema):
453
+ * schema, mobileSchema, settings, variables, localizations and the Code Form's files — the draft, or
454
+ * with version='published' the version users see. A Suppa 1.0 form is its row with the `data` blob
455
+ * (formShema / formSettings / formModul).
456
+ */
457
+ export async function getForm(formId, version = "draft", includeArtifact = false) {
458
+ let assembled = null;
459
+ try {
460
+ const got = await makeRequest("GET", `/api/core/forms/${formId}/schema`, null, version === "published" ? { query: { mode: "published" } } : undefined);
461
+ assembled = isObj(got) ? got : null;
462
+ }
463
+ catch (e) {
464
+ if (e?.status !== 404)
465
+ throw e;
466
+ if (version === "published") {
467
+ return jsonResponse({
468
+ error: `Form ${formId} has no published version this user sees (or does not exist). version='draft' reads the draft.`,
469
+ });
470
+ }
471
+ }
472
+ if (assembled && isV2Form(assembled))
473
+ return jsonResponse(v2FormAnswer(assembled, version, includeArtifact));
391
474
  const result = await selectEntity(ENTITY_FORMS, [makeFilter("id", formId)], FORM_DETAIL_FIELDS);
392
475
  if (result === null)
393
476
  return notFoundAnswer(ENTITY_FORMS, formId, "form");
394
- return jsonResponse(result);
477
+ return jsonResponse({ generation: "1.0", ...result });
395
478
  }
396
479
  /**
397
480
  * Create a new form.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suppa-mcp-2",
3
- "version": "1.43.1",
3
+ "version": "1.43.3",
4
4
  "description": "MCP server for the Suppa platform (modern.suppa.me) — Tasks, Docs/Pages, Entities & Schema, Forms, Automations, and file attachments, with multi-tenant Google auth. Node port of PyPI suppa-mcp.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -52,10 +52,10 @@ Steps 2 and 3 are not optional reading. The catalog is 56 types and the prop tab
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
- **Reading a form.** `suppa_get_form` is the 1.0 blob. The 2.x draft is `suppa_search_records` on
56
- `Forms` (filter `id`; fields `schema`, `settings`, `updatedAt`, `lockedBy {id fullName}`), the
57
- published one `FormVersions` (filter `form.id`, `isDefault: true`; field `snapshot`). Save the answer
58
- to a file: it is the baseline the gate takes as it is, and the copy to restore an unpublished draft.
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 users
57
+ see). Save the answer to a file: it is the baseline the gate takes as it is, and the copy to restore
58
+ an unpublished draft. Who has it open is `lockedBy` on `Forms` (`suppa_search_records`).
59
59
 
60
60
  ## Rules
61
61
 
@@ -27,7 +27,14 @@ The live form is first-class columns on the `Forms` row:
27
27
  | `suppa form-versions --form-id <id>` | `GET /core/forms/:id/versions`, `…/versions/:v/diff?from=`, `…/change-sets` | Read-only. The diff is component ids added and removed. |
28
28
  | `suppa form-lifecycle --form-id <id> --action <a>` | `POST /core/forms/:id/publish` · `rollback/:v` · `discard` · `promote/:v` | publish freezes the EFFECTIVE schema as the new default version. **rollback restores the version over the draft AND publishes it.** **discard overwrites the draft with the live version and writes no change-set — unrecoverable.** promote changes which version users see. rollback and promote check the version against the form in the URL: a version of another form answers **404 `Version <v> is not a version of form <id>`** (entity-builder `form-publish.service.ts` `loadVersion`, since 167db88a, 2026-09-18), and the tool refuses one before sending. publish and rollback are gated against the live version. |
29
29
 
30
- **Reading the form** goes through the same server: `suppa_search_records` on `Forms` filtered by `id`, fields `schema`, `settings`, `updatedAt`, `lockedBy { id fullName }`, `lockedAt` (the draft, who holds it, and the revision), and on `FormVersions` filtered by `form.id` and `isDefault: true`, field `snapshot` (what users see). Save the answer to a file: the gate reads it as it is — a one-record `records` answer or a `snapshot` — as the baseline of an edit, and it is the only copy of an unpublished draft you are about to overwrite (a draft write leaves no version). `suppa_get_form` is the Suppa 1.0 `data` blob and shows nothing of a 2.x form.
30
+ **Reading the form** goes through the same server. `suppa_get_form` is the builder's own read (`GET /core/forms/:id/schema`):
31
+ - the draft's `schema`, `mobileSchema`, `settings`, `variables`, `localizations` and the Code Form's files (`code`);
32
+ - `revision` (the `expected_revision` of a write);
33
+ - with `version='published'`, the version users see (for a child form, the merged tree).
34
+
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
+
37
+ A one-record `suppa_search_records` answer and a FormVersions `snapshot` are read as they are too. Save the read to a file. It is the baseline of an edit, and it is the only copy of an unpublished draft you are about to overwrite (a draft write leaves no version). A Suppa 1.0 form answers `generation: "1.0"` with its row's `data` blob.
31
38
 
32
39
  ## Writing by hand: the generic update replaces whatever column it names
33
40