suppa-mcp-2 1.42.0 → 1.42.2

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.
@@ -26,7 +26,7 @@ import { isAbsolute } from "node:path";
26
26
  import { pathToFileURL } from "node:url";
27
27
  import { makeRequest, searchEntity, selectEntity } from "../httpClient.js";
28
28
  import { confirmRequired, jsonResponse } from "../utils.js";
29
- import { checkerFailed, gateErrorLines, readJson, sentVariables, skillFile } from "./formV2.js";
29
+ import { checkerFailed, gateErrorLines, readJson, sentVariables, skillFile, subtractLiveFindings } from "./formV2.js";
30
30
  /** The FB2 kinds this can create. `workspace` inherits the base workspace form (setParent). */
31
31
  export const CREATABLE_FORM_TYPES = ["create", "update", "custom"];
32
32
  export const LIFECYCLE_ACTIONS = ["publish", "rollback", "discard", "promote"];
@@ -345,45 +345,43 @@ export async function formVersions(formId, diffFrom = null, diffTo = null, chang
345
345
  }
346
346
  return jsonResponse(out);
347
347
  }
348
- // ---------------------------------------------------------------------------------------------
349
- // lifecycle
350
- /**
351
- * A widget render the gate had to replace, in something a publish or a rollback FREEZES. The gate
352
- * compiles every changed widget template and hands the compiled render on — but these actions write
353
- * nothing of ours, they freeze what the tenant stores, so the stored render is what will run. An EMPTY
354
- * one renders nothing for every viewer (the runtime executes only compiledRender): an error. One that
355
- * is not what the frontend's compiler makes of its template is hand-written, or compiled by another
356
- * compiler version — not proof of harm, so a warning, but it is the JavaScript that will run in every
357
- * viewer's browser.
358
- */
359
- function frozenWidgetFindings(compiled) {
348
+ function frozenWidgetFindings(compiled, what) {
360
349
  const errors = [];
361
350
  const warnings = [];
351
+ const inWhat = what.kind === "draft" ? "in the stored draft" : `in version ${what.versionId}`;
352
+ // A rollback freezes that version as stored: re-saving the CURRENT draft does not change it.
353
+ const wayOut = what.kind === "draft"
354
+ ? "Re-save the draft with suppa_write_form_draft (it compiles the template) or in the builder, then publish."
355
+ : "Roll back to another version, or fix the widget in the current draft (suppa_write_form_draft compiles it) and publish that instead.";
362
356
  for (const w of Array.isArray(compiled) ? compiled.filter(isObj) : []) {
363
357
  const where = `${w.presentation === "mobileSchema" ? "mobileSchema — " : ""}\`${w.slot}.compiledRender\``;
364
358
  if (w.why === "empty") {
365
359
  errors.push({
366
360
  code: "widget_render_missing", elementId: w.elementId,
367
- detail: `${where} is EMPTY in the stored draft: frozen like that, the widget renders nothing for every viewer, with no error. Re-save the draft with suppa_write_form_draft (it compiles the template) or in the builder, then publish.`,
361
+ detail: `${where} is EMPTY ${inWhat}: frozen like that, the widget renders nothing for every viewer, with no error. ${wayOut}`,
368
362
  });
369
363
  }
370
364
  else if (w.why === "mismatch") {
371
365
  // `equivalent` — the same template compiled by another build (a Node-side tool) — is not news.
372
366
  warnings.push({
373
367
  code: "widget_render_mismatch", elementId: w.elementId,
374
- detail: `${where} in the stored draft is not what the frontend's compiler makes of its template — hand-written, or compiled by another version. It is the code that will run in every viewer's browser; re-save the draft with suppa_write_form_draft to freeze the compiled template instead.`,
368
+ detail: `${where} ${inWhat} is not what the frontend's compiler makes of its template — hand-written, or compiled by another version. It is the code that will run in every viewer's browser. ${wayOut}`,
375
369
  });
376
370
  }
377
371
  }
378
372
  return { errors, warnings };
379
373
  }
380
- async function gateOn(envelope, baseline) {
374
+ /** Gate warnings worth reading whole in a preview — said as warnings, so none reads as a refusal. */
375
+ const warningLines = (warnings) => warnings
376
+ .filter((w) => w?.code === "widget_render_mismatch")
377
+ .map((w) => `warning ${w.code}${w.elementId ? ` on ${w.elementId}` : ""}: ${w.detail ?? ""}`.trim());
378
+ async function gateOn(envelope, baseline, what = { kind: "draft" }) {
381
379
  try {
382
380
  const mod = await loadGate();
383
381
  if (!mod)
384
382
  return { ok: false, errors: [], warnings: [], checked: false, error: "the form gate is missing — reinstall suppa-mcp-2." };
385
383
  const g = await mod.validateForm(envelope, baseline ? { baseline } : {});
386
- const frozen = frozenWidgetFindings(g.compiled_widgets);
384
+ const frozen = frozenWidgetFindings(g.compiled_widgets, what);
387
385
  const errors = [...(g.errors ?? []), ...frozen.errors];
388
386
  return {
389
387
  ok: !g.refused && !!g.ok && frozen.errors.length === 0,
@@ -404,7 +402,6 @@ const envelopeOf = (o) => ({
404
402
  // The mobile presentation is frozen too, and the gate checks charts, spans and ids there.
405
403
  ...(o.mobileSchema ? { mobileSchema: o.mobileSchema } : {}),
406
404
  });
407
- const findingKey = (e) => `${e?.code ?? "?"}|${e?.elementId ?? ""}`;
408
405
  /**
409
406
  * The gate on what would be frozen, against what is live now: a finding the live version ALREADY
410
407
  * carries does not block — only one the new version would add. The baseline alone does not give
@@ -412,14 +409,15 @@ const findingKey = (e) => `${e?.code ?? "?"}|${e?.elementId ?? ""}`;
412
409
  * so an unchanged draft of a quarter of the tenant's forms would be refused (found by review
413
410
  * before 1.40.6). So the live version is gated on its own and its findings are subtracted.
414
411
  */
415
- async function gateAgainstLive(envelope, live) {
412
+ async function gateAgainstLive(envelope, live, what = { kind: "draft" }) {
416
413
  const liveEnv = live ? envelopeOf(live) : null;
417
- const g = await gateOn(envelope, liveEnv);
414
+ const g = await gateOn(envelope, liveEnv, what);
418
415
  if (!liveEnv || !g.checked)
419
416
  return { ...g, already_live: 0 };
420
417
  const base = await gateOn(liveEnv, liveEnv);
421
- const known = new Set(base.checked ? base.errors.map(findingKey) : []);
422
- const added = g.errors.filter((e) => !known.has(findingKey(e)));
418
+ // One for one, by code, element and detail (formV2.ts subtractLiveFindings): matched by code and
419
+ // element alone, one live connection finding vouched for every new one of its code.
420
+ const { added } = subtractLiveFindings(g.errors, base.checked ? base.errors : []);
423
421
  return { ...g, ok: added.length === 0, errors: added, already_live: g.errors.length - added.length };
424
422
  }
425
423
  export async function formLifecycle(formId, action, versionId = null, confirm = false) {
@@ -476,7 +474,7 @@ export async function formLifecycle(formId, action, versionId = null, confirm =
476
474
  plan.freezes = { ...compare(liveSnap?.schema, draft.schema), status_now: draft.status };
477
475
  const g = await gateAgainstLive(envelopeOf(draft), liveSnap);
478
476
  plan.gate = g.checked ? { passes: g.ok, errors: g.errors.length, already_live: g.already_live, warnings: g.warnings.length } : g.error;
479
- warnings.push(...gateErrorLines(g.errors), ...gateErrorLines(g.warnings.filter((w) => w?.code === "widget_render_mismatch")));
477
+ warnings.push(...gateErrorLines(g.errors), ...warningLines(g.warnings));
480
478
  plan.effect = "publish: a new default version";
481
479
  warnings.push("publishing makes this draft the version every user of this tenant sees; the draft itself is unchanged.");
482
480
  }
@@ -491,9 +489,9 @@ export async function formLifecycle(formId, action, versionId = null, confirm =
491
489
  const target = await readSnapshot(vid);
492
490
  const snap = (target?.snapshot ?? {});
493
491
  plan.restores = { version_id: vid, versionNumber: target?.versionNumber, elements: componentIds(snap.schema).length };
494
- const g = await gateAgainstLive(envelopeOf(snap), liveSnap);
492
+ const g = await gateAgainstLive(envelopeOf(snap), liveSnap, { kind: "version", versionId: vid });
495
493
  plan.gate = g.checked ? { passes: g.ok, errors: g.errors.length, already_live: g.already_live, warnings: g.warnings.length } : g.error;
496
- warnings.push(...gateErrorLines(g.errors), ...gateErrorLines(g.warnings.filter((w) => w?.code === "widget_render_mismatch")));
494
+ warnings.push(...gateErrorLines(g.errors), ...warningLines(g.warnings));
497
495
  plan.effect = "rollback: restore, then publish";
498
496
  warnings.push(`version ${vid} is restored OVER the current draft (overwriting it, unrecoverably — no change-set) and then ` +
499
497
  "PUBLISHED as a new default version, live for every user.");
@@ -531,7 +529,7 @@ export async function formLifecycle(formId, action, versionId = null, confirm =
531
529
  catch (e) {
532
530
  return jsonResponse({ done: false, published: false, error: `what would be frozen could not be read (${msgOf(e)}), so nothing was published: nothing unchecked is.` });
533
531
  }
534
- const g = await gateAgainstLive(envelope, baseline);
532
+ const g = await gateAgainstLive(envelope, baseline, act === "rollback" ? { kind: "version", versionId: vid } : { kind: "draft" });
535
533
  if (!g.ok) {
536
534
  return jsonResponse({
537
535
  done: false,
@@ -531,9 +531,42 @@ function liveEnvelope(row) {
531
531
  schema: row.schema ?? [],
532
532
  settings: row.settings && typeof row.settings === "object" ? row.settings : {},
533
533
  ...(row.mobileSchema ? { mobileSchema: row.mobileSchema } : {}),
534
+ // The form's own variables (FormVariables rows, read separately): the gate checks a draft's
535
+ // variables against the baseline's, and an empty list there turns an echoed hydrate it only warns
536
+ // about into an error blamed on the draft (found by review before release).
537
+ ...(Array.isArray(row.variables) ? { variables: row.variables } : {}),
538
+ // A CHILD form's own component list is empty by design; without `parent` the gate refused the
539
+ // baseline as an empty form and judged the draft as if there were no live form at all.
540
+ ...(row.parent != null ? { parent: row.parent } : {}),
541
+ ...(row.parentVersion != null ? { parentVersion: row.parentVersion } : {}),
534
542
  };
535
543
  }
536
- const findingKey = (f) => `${f?.code ?? "?"}|${f?.elementId ?? ""}`;
544
+ /**
545
+ * The findings of `errors` the live form ALREADY carries, set aside one for one: matched by code,
546
+ * element AND detail, and each live finding cancels at most one. Matched by code and element alone,
547
+ * one live finding with no element — every connection check is one — vouched for every new one of its
548
+ * code: a draft that added two broken wires to a form that had one passed with all three "already
549
+ * live" (found by review before release). Shared with the publish gate (formLifecycle.ts).
550
+ */
551
+ export function subtractLiveFindings(errors, live) {
552
+ const key = (f) => `${f?.code ?? "?"}|${f?.elementId ?? ""}|${f?.detail ?? f?.message ?? ""}`;
553
+ const left = new Map();
554
+ for (const f of live)
555
+ left.set(key(f), (left.get(key(f)) ?? 0) + 1);
556
+ const added = [];
557
+ const already = [];
558
+ for (const f of errors) {
559
+ const n = left.get(key(f)) ?? 0;
560
+ if (n > 0) {
561
+ left.set(key(f), n - 1);
562
+ already.push(f);
563
+ }
564
+ else {
565
+ added.push(f);
566
+ }
567
+ }
568
+ return { added, already };
569
+ }
537
570
  /**
538
571
  * The gate on a draft EDIT, judged against the form as the tenant holds it now.
539
572
  *
@@ -546,9 +579,8 @@ const findingKey = (f) => `${f?.code ?? "?"}|${f?.elementId ?? ""}`;
546
579
  * conformance and the widget compile leave its elements alone;
547
580
  * - a finding the live form ALREADY carries does not block, because the baseline absorbs drift,
548
581
  * not structure: a `dangling_parent` the form has had for months is an error either way. So the
549
- * live form is gated on its own and its findings are subtracted. Matched by code and element, so
550
- * a second instance of the same code on the same element is not told apart — the price of a rule
551
- * that never blocks an edit for the form's own state.
582
+ * live form is gated on its own and its findings are subtracted, one for one
583
+ * ({@link subtractLiveFindings}).
552
584
  *
553
585
  * `already_live` lists what was subtracted, so the answer says it rather than going quiet.
554
586
  */
@@ -558,9 +590,7 @@ async function gateEdit(mod, draft, live, normalize) {
558
590
  if (g.refused || g.ok || !baseline)
559
591
  return { ...g, already_live: [] };
560
592
  const own = await mod.validateForm(baseline, { baseline });
561
- const known = new Set(own.refused ? [] : (own.errors ?? []).map(findingKey));
562
- const added = (g.errors ?? []).filter((e) => !known.has(findingKey(e)));
563
- const already = (g.errors ?? []).filter((e) => known.has(findingKey(e)));
593
+ const { added, already } = subtractLiveFindings(g.errors ?? [], own.refused ? [] : (own.errors ?? []));
564
594
  return { ...g, ok: added.length === 0, errors: added, already_live: already };
565
595
  }
566
596
  const alreadyLive = (list) => list.map((f) => ({ code: f?.code, elementId: f?.elementId ?? null }));
@@ -597,11 +627,23 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
597
627
  let row = null;
598
628
  let rowError = null;
599
629
  try {
600
- row = await selectEntity("Forms", [{ field: "id", comparator: "=", value: id }], { id: true, name: true, type: true, status: true, schema: true, mobileSchema: true, settings: true, updatedAt: true, lockedBy: { id: true, fullName: true }, code: true, parent: { id: true } });
630
+ row = await selectEntity("Forms", [{ field: "id", comparator: "=", value: id }], { id: true, name: true, type: true, status: true, schema: true, mobileSchema: true, settings: true, updatedAt: true, lockedBy: { id: true, fullName: true }, code: true, parent: { id: true }, parentVersion: true });
601
631
  }
602
632
  catch (e) {
603
633
  rowError = e instanceof Error ? e.message : String(e);
604
634
  }
635
+ // The form's own variables, when the draft brings a list the gate will judge against them.
636
+ let liveVars = null;
637
+ let liveVarsError = null;
638
+ const peeked = readJson(target);
639
+ if (row && !peeked.error && sentVariables(peeked.value)) {
640
+ try {
641
+ liveVars = await currentVariables(id);
642
+ }
643
+ catch (e) {
644
+ liveVarsError = e instanceof Error ? e.message : String(e);
645
+ }
646
+ }
605
647
  try {
606
648
  const peek = readJson(target);
607
649
  if (peek.error)
@@ -611,18 +653,29 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
611
653
  const s = skillFile("scripts", "validate-form-schema.mjs");
612
654
  if (s) {
613
655
  const mod = await import(pathToFileURL(s).href);
614
- const g = await gateEdit(mod, peek.value, row && typeof row === "object" ? row : null, normalize);
656
+ const live = row && typeof row === "object" ? { ...row, ...(liveVars ? { variables: liveVars } : {}) } : null;
657
+ const g = await gateEdit(mod, peek.value, live, normalize);
615
658
  draftSettings = (g.draft && typeof g.draft.settings === "object" && g.draft.settings) || {};
616
659
  draftComponents = g.draft?.schema ?? null;
617
660
  // The blocking findings travel in `warnings`, whole: a finding's detail is often longer
618
661
  // than the 200 characters `proposed_changes` keeps, and there it would read as a size.
619
662
  gateLines = gateErrorLines(g.errors);
663
+ // Said in `warnings`, which the preview never shortens: the gate's notes are long, and
664
+ // `proposed_changes` replaces any string over 200 characters with its length.
665
+ for (const w of Array.isArray(g.compiled_widgets) ? g.compiled_widgets : []) {
666
+ gateLines.push(`note: ${w.elementId} ${w.slot}.compiledRender is compiled from its template on write (${w.why}) — ` +
667
+ "the runtime runs only that, and a hand-written render is never kept.");
668
+ }
620
669
  preview = {
621
670
  gate: g.refused ? "REFUSED" : g.ok ? "passes" : "has errors",
622
671
  elements: g.elements ?? 0,
623
672
  errors: (g.errors ?? []).map((e) => ({ code: e.code, elementId: e.elementId })),
624
673
  warnings: g.warnings,
674
+ notes: g.notes,
625
675
  ...(g.already_live.length ? { already_on_the_live_form: alreadyLive(g.already_live) } : {}),
676
+ ...(!live
677
+ ? { judged: "without the live form (it could not be read here), so drift findings may be false — the confirmed call judges against the live form" }
678
+ : {}),
626
679
  };
627
680
  }
628
681
  }
@@ -673,7 +726,9 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
673
726
  let variables = "not sent — the draft carries no variables, so the form's variables are left as they are";
674
727
  if (draftVars) {
675
728
  try {
676
- const eff = variableEffect(await currentVariables(id), draftVars);
729
+ if (liveVarsError)
730
+ throw new Error(liveVarsError);
731
+ const eff = variableEffect(liveVars ?? (await currentVariables(id)), draftVars);
677
732
  variables = { sent_as_the_full_state: true, ...eff };
678
733
  if (eff.drops_default)
679
734
  warnings.push(`the confirmed call will REFUSE this draft: ${dropsDefaultError(String(eff.default_variable), eff.default_type)}`);
@@ -746,7 +801,7 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
746
801
  id: true, name: true, type: true, status: true,
747
802
  schema: true, mobileSchema: true, settings: true, updatedAt: true,
748
803
  lockedBy: { id: true, fullName: true }, lockedAt: true,
749
- entity: { id: true, name: true }, code: true, parent: { id: true },
804
+ entity: { id: true, name: true }, code: true, parent: { id: true }, parentVersion: true,
750
805
  });
751
806
  }
752
807
  catch (e) {
@@ -760,10 +815,26 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
760
815
  if (!row || typeof row !== "object") {
761
816
  return jsonResponse({ written: false, error: `no form with id ${id} on this tenant.` });
762
817
  }
763
- // 3. THE GATE, against that row.
818
+ // 3. THE GATE, against that row — and, when the draft brings variables, against the form's own: the
819
+ // list is the FULL state, so it is read here once and the write below diffs against the same read.
820
+ const draftVars = sentVariables(read.value);
821
+ let liveVars = null;
822
+ if (draftVars) {
823
+ try {
824
+ liveVars = await currentVariables(id);
825
+ }
826
+ catch (e) {
827
+ return jsonResponse({
828
+ written: false,
829
+ error: `the form's variables could not be read (${e instanceof Error ? e.message : String(e)}), so ` +
830
+ "nothing was written: the draft's list replaces them wholesale, and a replacement built over " +
831
+ "an unread state deletes whatever it did not know about.",
832
+ });
833
+ }
834
+ }
764
835
  let gate;
765
836
  try {
766
- gate = await gateEdit(mod, read.value, row, normalize);
837
+ gate = await gateEdit(mod, read.value, liveVars ? { ...row, variables: liveVars } : row, normalize);
767
838
  }
768
839
  catch (e) {
769
840
  return jsonResponse({
@@ -819,20 +890,9 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
819
890
  const existingSettings = (row.settings && typeof row.settings === "object" ? row.settings : {});
820
891
  const draft = gate.draft ?? {};
821
892
  // 5. THE VARIABLES — only the file's own non-empty list is sent, and only once the form's own were read.
822
- const draftVars = sentVariables(read.value);
823
893
  let variables = null;
824
- if (draftVars) {
825
- try {
826
- variables = variableEffect(await currentVariables(id), draftVars);
827
- }
828
- catch (e) {
829
- return jsonResponse({
830
- written: false,
831
- error: `the form's variables could not be read (${e instanceof Error ? e.message : String(e)}), so ` +
832
- "nothing was written: the draft's list replaces them wholesale, and a replacement built over " +
833
- "an unread state deletes whatever it did not know about.",
834
- });
835
- }
894
+ if (draftVars && liveVars) {
895
+ variables = variableEffect(liveVars, draftVars);
836
896
  if (variables.drops_default) {
837
897
  return jsonResponse({ written: false, error: dropsDefaultError(String(variables.default_variable), variables.default_type), variables });
838
898
  }
@@ -871,6 +931,7 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
871
931
  settings_kept_because_the_draft_is_silent_about_them: Object.keys(existingSettings).filter((k) => !(k in (draft.settings ?? {}))),
872
932
  guarded_by_revision: revision,
873
933
  warnings: gate.warnings,
934
+ notes: gate.notes,
874
935
  ...(gate.already_live.length ? { already_on_the_live_form: alreadyLive(gate.already_live) } : {}),
875
936
  ...(() => {
876
937
  if (row.parent?.id)
@@ -183,7 +183,11 @@ export function prepareQuery(query, limit = QUERY_DEFAULT_LIMIT) {
183
183
  limitNote: `LIMIT ${raw} was clamped to ${cap}: this tool shows at most ${limit} rows (limit can go to ${QUERY_MAX_LIMIT}).`,
184
184
  };
185
185
  }
186
- /** The keys a SQL table column or `sqlValueColumns[].key` must use: nested objects as dot paths. */
186
+ /**
187
+ * The result keys, nested objects as dot paths — what a SQL TABLE column's key must use (FE
188
+ * sqlSourceColumns.ts keys a column by where its value sits). A CHART key is the alias or the
189
+ * path's last segment instead (FE suppaSql/analyzer.ts), which is not derived here.
190
+ */
187
191
  function resultColumns(row, prefix = "") {
188
192
  if (!row || typeof row !== "object" || Array.isArray(row))
189
193
  return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suppa-mcp-2",
3
- "version": "1.42.0",
3
+ "version": "1.42.2",
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": {
@@ -55,10 +55,10 @@ rules — plus your own reading of the warnings — are what stands between that
55
55
  **Every element needs an explicit `layout[bp]` for every key in `settings.breakpoints` — there
56
56
  is no fallback**: the form switches only to a breakpoint every element has, so one missing
57
57
  record turns that layout off for the whole form.
58
- 2. **`layout[bp].height` is a row span, and the only thing that makes an element taller.**
59
- `containerSettings.size.heightMode` (`auto` | `fixed` | `fill`) is scroll behaviour. `fill` on a
60
- table or a leaf field does not enlarge it; it makes it share leftover height with its siblings.
61
- Both keys are legal on the same element, so nothing can flag the mix-up.
58
+ 2. **Height is `containerSettings.size.height` (px, `heightMode: 'fixed'`); `layout[bp].height`
59
+ only places.** Grid rows are `min-content`: a longer span adds no pixels, a chart with no
60
+ height is 0px. `fill` shares leftover height with siblings, it does not grow. Both keys are
61
+ legal together, so nothing flags the mix-up.
62
62
  3. **A grid child spans its parent's columns, not the form's.** Inside a 12-column section, full
63
63
  width is `width: 12`; inside a 2-column container it is `width: 2`. **Column count defaults to
64
64
  1, and 1 is a real count, not an "unset" flag** — the root grid reads `settings.columnsNumber`,
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "package": "@vue/compiler-dom",
3
3
  "version": "3.5.12",
4
- "build": "dist/compiler-dom.esm-browser.prod.js (the build the builder runs) for the render, dist/compiler-dom.esm-browser.js for the diagnostics only, entities.decodeHTMLStrict for decodeEntities",
4
+ "build": "dist/compiler-dom.esm-bundler.js resolved as Vite does, NODE_ENV=production (scripts/vue-compiler.mjs, the render and what is refused) and NODE_ENV=development (scripts/vue-compiler-diagnostics.mjs, words and warnings only); entities.decodeHTMLStrict for decodeEntities",
5
5
  "pulledAt": "2026-10-02",
6
- "bytes": 214137,
6
+ "bytes": 216717,
7
7
  "frontend": "platform-front-redesind pins @vue/compiler-dom 3.5.12 (package.json) and compiles with compile(template, { mode: 'function', decodeEntities: decodeTemplateEntities }) — shared/dynamicWidget/compiler/compileTemplate.ts",
8
8
  "why": "The runtime renders only compiledRender. The gate compiles every widget template it is handed the way the builder does, and never writes a compiledRender it did not produce. Re-run after the frontend moves its pin."
9
9
  }
@@ -5,9 +5,11 @@ draws is a CUSTOM chart (`chartType: 'custom'`: named sources + a widget) — `-
5
5
 
6
6
  ## Size it yourself — nothing else will
7
7
 
8
- `chart` is the only large widget with **no automatic full width and no minimum row span**. `table`, `cards`, `calendar`, `kanban`, `entityLinks` are force-widened to the row and floored at 6 rows; `chart` is deliberately excluded (a KPI tile is a 3-column cell and dashboards place charts 2-up). So `layout.lg.height: 1` ships as one row, widened only to the ~3-column minimum readable width. Write `height: 6`–`8` and a real `width` on every non-KPI chart.
8
+ `chart` has **no automatic full width**: `table`, `cards`, `calendar`, `kanban`, `entityLinks` are force-widened to the row; `chart` is deliberately excluded (a KPI tile is a 3-column cell and dashboards place charts 2-up). Write a real `width` on every chart.
9
9
 
10
- `containerSettings` is seeded **only while you leave it unwritten** — 400px for the canvas types, 140px + `widthMode: 'fill'` for `chartType: 'kpi'`. A `containerSettings.size` you author is kept verbatim and nothing re-sizes it, so a hand-written 400px KPI ships 2.9× the design height. On a KPI: omit the key, or write exactly `{ size: { widthMode: 'fill', heightMode: 'fixed', height: '140px' } }`. The px height is never converted into row span; the two are independent.
10
+ A chart's height is **`containerSettings.size.height` in px with `heightMode: 'fixed'`**, and nothing else. `layout.lg.height` only places it: grid rows are `min-content` (FE `canvasGridResolver.ts:62`), so a 6-row span adds no pixels, and `layout.lg.height: 1` is fine. With no size height the chart draws an auto-height canvas, which collapses to 0px (FE `ChartElementRuntime.ts:696`).
11
+
12
+ `containerSettings` is seeded **only by the builder** — a palette drop or its own AI draft (FE `materializeDraftSchema.ts`) — at 400px for the canvas types and 140px + `widthMode: 'fill'` for `chartType: 'kpi'`. Nothing seeds it for a form written through this server, so write it: `{ size: { heightMode: 'fixed', height: '320px' } }` or so on a canvas chart, and on a KPI exactly `{ size: { widthMode: 'fill', heightMode: 'fixed', height: '140px' } }` (an unwritten KPI is as tall as its content). A `containerSettings.size` you author is kept verbatim and nothing re-sizes it, so a hand-written 400px KPI ships 2.9× the design height.
11
13
 
12
14
  ## Real data
13
15
 
@@ -17,7 +19,7 @@ An **incomplete source renders the built-in DEMO series with no error** — inve
17
19
 
18
20
  Several series and a breakdown are mutually exclusive: multiple `values[]` rows = multiple named series; `dataSource.seriesField` = one measure split per distinct value, and with it set **only the first `values` row is aggregated**. Won/Lost is one entity, two rows, a per-row `filter`. A cross-entity row needs its own `entity` **and** its own `categoryField` — one without the other is silently not fetched.
19
21
 
20
- Writing a SuppaSQL query means `kind: 'suppaSql'` too; an entity source ignores every `sql*` key. Run the query with `suppa_query` before writing it. The `columns` in its answer are the keys `sqlCategoryColumn` and `sqlValueColumns[].key` must name.
22
+ Writing a SuppaSQL query means `kind: 'suppaSql'` too; an entity source ignores every `sql*` key. Run the query with `suppa_query` before writing it. `sqlCategoryColumn` and `sqlValueColumns[].key` name the FE analyzer's key: the alias, else the path's last segment (`"owner.firstName"` → `firstName`; FE `suppaSql/analyzer.ts:230-232`). The dot paths in `suppa_query`'s `columns` are table keys — on a chart one matches no column and the chart shows demo data (`suppaSqlChartDataProvider.ts:88`).
21
23
 
22
24
  The gate enforces "complete" as **`chart_source_incomplete`**. It is an error, or a warning when the live form's own chart is already incomplete, and it mirrors the frontend's own readiness check:
23
25
  - **SuppaSQL source:** `sqlQuery`, `sqlCategoryColumn`, and at least one `sqlValueColumns[].key`.
@@ -30,17 +30,18 @@ and nothing reads them.
30
30
 
31
31
  **Names are code.** A source name, a measure `key` and a drill-down name match
32
32
  `^[a-z][A-Za-z0-9_]*$` and are never an `Object.prototype` member (`constructor`, `toString`, …).
33
- Keys are unique within a source. Write every key yourself: a measure without one gets a key derived
34
- from its label (transliterated, `Виграні угоди` → `vyhraniUhody`), which code written against the
35
- name you had in mind will not match. A SQL source's keys are its `sqlValueColumns[].key`. Renaming a
33
+ Keys are unique within a source. Write every key yourself: at runtime a measure without one is read
34
+ under its row `id` (`m1`), and the builder derives one from the label (`Виграні угоди` →
35
+ `vyhraniUhody`) only when a person opens the panel — code written against either name breaks. A SQL source's keys are its `sqlValueColumns[].key`. Renaming a
36
36
  source, a key or a drill-down breaks every `chart.sources.<old>` / `chart.drill('<old>')` that reads it.
37
37
 
38
38
  ## Each source loads on its own — or never
39
39
 
40
40
  No category is required, but each source must be complete: an **entity** source needs `entity` and
41
41
  one measure with a `field` and `aggregation` sum|count|avg|min|max (a formula row alone computes
42
- nothing); a **SQL** source needs `sqlQuery` and one `sqlValueColumns` entry with a `key`. A
43
- query-only source with no `kind` is SQL. An incomplete source is never loaded: `chart.sources.<s>`
42
+ nothing); a **SQL** source needs `kind: 'suppaSql'`, `sqlQuery` and one `sqlValueColumns` entry with a
43
+ `key` — without the kind the runtime reads an entity source and ignores every `sql*` key (only the
44
+ builder's AI normalizer adds it). An incomplete source is never loaded: `chart.sources.<s>`
44
45
  stays not-ready and the widget shows its loading or empty state forever, with no error.
45
46
 
46
47
  `compare: 'previousPeriod'` works only on an entity source without `seriesField`, and only when its
@@ -95,9 +96,9 @@ click-on-mark drill: call `chart.drill` from the marks the widget draws
95
96
 
96
97
  **`compiledRender` is the only thing the runtime executes**, and an empty one renders nothing. Write
97
98
  `template`, `script` and `style`; the gate compiles the template with the frontend's own compiler
98
- (`@vue/compiler-dom` 3.5.12) and the draft write saves THAT render — a `compiledRender` you write is
99
- replaced, because a hand-written one is JavaScript outside the sandbox. A widget the live form
100
- already has, unchanged, is left as it is. A publish freezes what the tenant stores and refuses a
99
+ (`@vue/compiler-dom` 3.5.12, the build the builder runs) and the draft write saves THAT render — a
100
+ `compiledRender` you write is replaced, because a hand-written one is JavaScript outside the sandbox.
101
+ A widget the live form already runs, unchanged, is left as it is. A publish freezes what the tenant stores and refuses a
101
102
  stored empty render — re-save such a draft with write-form-draft first.
102
103
 
103
104
  ## From the form's code
@@ -112,7 +113,8 @@ only on a mounted chart: one in a collapsed tab never reports. `dataLoaded` / `d
112
113
 
113
114
  Errors: `chart_source_incomplete` per named source; `widget_template_empty` / `_invalid`,
114
115
  `widget_script_invalid`, `widget_unknown_component`, `widget_invalid`; on publish
115
- `widget_render_missing`. Warnings: `custom_chart_drill_unreachable`, `widget_tailwind_arbitrary`,
116
+ `widget_render_missing`. Warnings: `custom_chart_no_sources`, `custom_chart_drill_unreachable`,
117
+ `widget_template_warning` (what only Vue's development build reports), `widget_tailwind_arbitrary`,
116
118
  `widget_component_off_registry`, and on publish `widget_render_mismatch`. Until the vendored component manifest is next
117
119
  synced (it predates the custom chart), a NEW custom chart is also refused as `unknown_prop` /
118
120
  `invalid_prop_value`; an edit of a form that already has one passes — the draft write and publish
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## Height is two unrelated keys
6
6
 
7
- `layout[bp].height` is a grid ROW SPAN and the only thing that makes an element taller; `containerSettings.size.heightMode` (`'auto' | 'fixed' | 'fill'`) is scroll/fill behaviour only. Both are legal on one element, so nothing flags the mix-up.
7
+ Height is `containerSettings.size.height` (px) with `heightMode: 'fixed'`. `layout[bp].height` is a grid ROW SPAN for placement only: canvas and container rows are `min-content` (FE `canvasGridResolver.ts:62`, `containerLayout.ts:67`; `SizeResolver.ts`: "a row span is never the author's height lever"), so a longer span adds no pixels. `heightMode: 'fill'` shares leftover height and collapses the span to one growable track. Both are legal on one element, so nothing flags the mix-up.
8
8
 
9
9
  Row height is not pixels: `settings.gridAutoRows` defaults to `'min-content'`, so a row is as tall as its content. A workspace that must fill the viewport sets `settings.gridAutoRows: '1fr'`.
10
10
 
@@ -12,7 +12,7 @@
12
12
  - **`suppaSql`** — `sqlQuery` + `sqlParams`. Run the query with `suppa_query` first: the `columns` in its answer are the nested dot-path keys a column's `key` must be. The chart keys `sqlCategoryColumn`/`sqlValueColumns` do nothing here. A column's `key` is **where its value is, not what the analyzer called it**: a relation path is keyed by the whole dotted read path (`SELECT "owner.firstName"` → `key: "owner.firstName"`), because the backend answers it nested — a leaf-keyed `firstName` column reads a key that does not exist and renders **permanently blank**. An alias on a relation path renames the *last segment* (`"owner.firstName" AS "fn"` → `owner.fn`); a flat alias stays flat. The query must select an **`id`**, must not use `SELECT *` (the star column is dropped with an `starColumnDropped` warning), and needs its relation paths quoted. One silent one: a **multi-statement paste keeps statement 1** and drops the rest with nothing said. Sorting is honest now: only the query's own flat result keys can be ordered by, and a dotted, relation or synthetic column gets **no sort control** in the header (FE `useSuppaTable.ts` `applySortability`).
13
13
  - **`aggregation`** — `entity` + `values: [{ id, field, aggregation: 'sum'|'count'|'avg'|'min'|'max' }]`; `categoryField` optional (without it, one row of totals). Columns are **derived**, keyed `g:category` and `m:<index>` **by measure position**. Restyle one with a `settings.columns` entry keyed exactly that: every column prop it carries wins over the derived one — `title`, `renderer`, `rendererParams`, `style`, width, alignment, cell style rules, `visibleWhen` — and an absent prop keeps the derived value (FE `aggregationColumns.ts` `applyAggregationColumnOverrides`). Never set `dataType`, `computed` or `tileFields` there. A `dataType` in the entry wins over the derived `'number'`, so the measure stops being a numeric column. An entry carrying `computed` or `tileFields` is not an override at all: it is a synthetic column of its own, appended after the derived set under the same `m:<i>` key — the retitle is lost and the key appears twice (FE `aggregationColumns.ts`, `TableLayoutController.ts`). Keyed `amount` instead of `m:0` the entry matches nothing and is dropped on read — no column, no error, the retitle lost.
14
14
 
15
- **Both read-only kinds have no grouping and no hierarchy**, and row drag-reorder is forced off — by design, Stage 1; the source declares `supportsGrouping: false`, which is what takes the Group control away (FE `TableSourceModel.ts` `sourceCapabilities`). Do not author grouping onto one. **Both do have a footer** over the WHOLE result, not the loaded page — for the metrics each can compute. `aggregation` holds its full set and aggregates it locally, so every metric works there, `median`, `range` and the date ranges included. `suppaSql` answers the footer through the same wrapped query (`getSummary`, FE `sqlTableDataSource.ts`, 2026-09-28), which serves only what a backend aggregate can express: `median`, `range` and `date_range_*` get no server value, so the cell computes them over the rows it has loaded — **a page-local number shown as a total** (FE `SummaryCell.vue` → `computeColumnSummary`) — and when they are the only metrics the whole footer is hidden (`summaryStrategy.ts` `hasServerSummaryMetric`). The builder does not offer them on a server-side table; do not write them on a `suppaSql` one.
15
+ **Both read-only kinds have no grouping and no hierarchy**, and row drag-reorder is forced off — by design, Stage 1; the source declares `supportsGrouping: false`, which is what takes the Group control away (FE `TableSourceModel.ts` `sourceCapabilities`). Do not author grouping onto one. **Both do have a footer** over the WHOLE result, not the loaded page — for the metrics each can compute. `aggregation` holds its full set and aggregates it locally, so every metric works there, `median`, `range` and the date ranges included. `suppaSql` answers the footer through the same wrapped query (`getSummary`, FE `sqlTableDataSource.ts`, 2026-09-28), which serves only what a backend aggregate can express: `median`, `range` and `date_range_*` get no server value, so the cell computes them over the rows it has loaded — **a page-local number shown as a total** (FE `SummaryCell.vue` → `computeColumnSummary`) — and when they are the only metrics the whole footer is hidden (`summaryStrategy.ts` `hasServerSummaryMetric`). The builder does not offer them on a server-side table; do not write them on a `suppaSql` one. A `suppaSql` footer also aggregates only flat, non-relation columns: its whitelist is the sort one, so a dotted or relation column's footer cell stays empty (`sqlTableDataSource.ts` `allowed`).
16
16
 
17
17
  `dataSource.entityFrom: 'formScope'` binds the host form's entity at runtime: then no `entity`, no `parentEntity`, `settings.columns: []` (an authored set outranks per-entity derivation forever), no `filter`/`requestFields`. The `'field'` + `entityField` mode was **removed 2026-09-15** — a table authored that way binds to nothing. `loadOnMount` is ON when absent; `realtime` is an entity record subscription, inert on `suppaSql`/`aggregation`.
18
18
 
@@ -14,7 +14,7 @@
14
14
  export const FORM_RULES_DIGEST = `WRITING A SUPPA 2.0 FORM (the entity-builder canvas — NOT suppa_create_form)
15
15
  1. suppa_create_form / suppa_update_form / suppa_add_field_to_form write \`data.formShema\` — the Suppa 1.0 form. The 2.x builder reads the \`schema\` COLUMN on the Forms row (\`{components, connections, overrides}\`; \`data.formSchema\` is the pre-2.1 blob, empty on every migrated row) and a DIFFERENT set of 58 element types. Use the suppa-form-v2 skill and its commands; the v1 tools cannot author a 2.0 form at all.
16
16
  2. The schema is a FLAT array. Nesting lives in \`layout[breakpoint].parentId\` = the parent element's \`id\` (its uuid, never its name). A grid child writes {x,y,width,height} in 1-based CELLS; a flex child writes {order}. Give every element a \`layout[bp]\` record for EVERY key in \`settings.breakpoints\` — there is no fallback: the form switches only to a breakpoint EVERY element carries, so one element without \`md\` turns the \`md\` layout off for the whole form.
17
- 3. \`layout[bp].height\` is a ROW SPAN and is the only thing that makes an element taller. \`containerSettings.size.heightMode\` ('auto'|'fixed'|'fill') is scroll behaviour, never a sizer — 'fill' on a table or a leaf field makes it share leftover height, not grow.
17
+ 3. Height is \`containerSettings.size.height\` (px) with heightMode 'fixed'. \`layout[bp].height\` is a ROW SPAN for placement only: grid rows are content-sized (min-content), so a longer span adds no pixels, and a chart with no size height renders at 0px. 'fill' on a table or a leaf field makes it share leftover height, not grow.
18
18
  4. A grid child spans its PARENT container's columns, not the form's. Column count DEFAULTS TO 1 and 1 is a real count: write the count you intend (\`settings.columnsNumber\` for the root grid, a container's own \`columnsNumber\`, range 1-12) BEFORE laying out spans — a width of 12 inside a 1-column grid overflows its parent.
19
19
  5. There are 58 DEDICATED element types. Never build something out of \`input\` + \`html\` because no type came to mind — read the component index first. \`html\` is author-written markup and is never a home for record data.
20
20
  6. The prop table is the options PANEL, not the runtime: a prop that validates is not a prop that works. Never invent a prop name or an option value, and read a type's note before setting a behavioural prop.
@@ -675,15 +675,19 @@ const CHART_AGGREGATIONS = Object.freeze(["sum", "count", "avg", "min", "max"]);
675
675
  const filled = (v) => typeof v === "string" && v.trim().length > 0;
676
676
 
677
677
  /**
678
- * A named source the FE runs as SuppaSQL: `kind: 'suppaSql'`, or no kind beside a query and no entity —
679
- * the FE draft normalizer stamps that (elements/chart/chartAgentSchema.ts; formbuilder-agent
680
- * schema/customChart.ts `isSqlNamedSource`).
678
+ * A named source the RUNTIME runs as SuppaSQL: `kind: 'suppaSql'`, and nothing else
679
+ * (data/chartDataSource.ts isChartDataSourceReady, the loader's gate). The builder's AI-draft
680
+ * normalizer also stamps the kind on a query-only source, but a draft written through the API never
681
+ * passes it, so here a query with no kind is what the runtime makes of it: an entity source that
682
+ * ignores every `sql*` key (found by review before release — the gate called it ready).
681
683
  */
682
684
  function isSqlNamedSource(src) {
683
- if (src.kind === "suppaSql") return true;
684
- return !filled(src.kind) && filled(src.sqlQuery) && !filled(src.entity);
685
+ return src.kind === "suppaSql";
685
686
  }
686
687
 
688
+ /** A source that carries a query but would not be read as SuppaSQL. */
689
+ const queryWithoutKind = (src) => !filled(src.kind) && filled(src.sqlQuery) && !filled(src.entity);
690
+
687
691
  /** A custom chart's named sources as `[name, source]` — own entries, objects only. */
688
692
  function namedSourcesOf(el) {
689
693
  const map = el && el.dataSources;
@@ -700,8 +704,12 @@ function namedSourcesOf(el) {
700
704
  */
701
705
  function namedSourceGaps(name, src) {
702
706
  const sql = isSqlNamedSource(src);
703
- const gaps = chartSourceGaps({ chartType: "kpi", dataSource: { ...src, kind: sql ? "suppaSql" : undefined } });
704
- return gaps.map((g) => g.replace("`dataSource.entity`", `\`dataSources.${name}.entity\``));
707
+ const gaps = chartSourceGaps({ chartType: "kpi", dataSource: { ...src, kind: sql ? "suppaSql" : undefined } })
708
+ .map((g) => g.replace("`dataSource.entity`", `\`dataSources.${name}.entity\``));
709
+ if (queryWithoutKind(src)) {
710
+ gaps.unshift("a `sqlQuery` but no `kind: 'suppaSql'` — without it the runtime reads an entity source and ignores every sql* key");
711
+ }
712
+ return gaps;
705
713
  }
706
714
 
707
715
  /** What keeps one chart on demo data, as short phrases — empty when the FE would fetch live data. */
@@ -766,6 +774,15 @@ function chartReadiness(schema, baselineById, presentation = "schema") {
766
774
  if (el.chartType === "custom") {
767
775
  const base = el.id !== undefined ? baselineById.get(el.id) : undefined;
768
776
  const before = new Map(base && base.type === "chart" && base.chartType === "custom" ? namedSourcesOf(base) : []);
777
+ if (!namedSourcesOf(el).length) {
778
+ // FE draftConfigIssues `chartCustomNoSources`: `chart.sources` is empty, so the widget reads
779
+ // nothing — fine for a static tile, rarely what was meant.
780
+ warnings.push({
781
+ code: "custom_chart_no_sources",
782
+ elementId: el.id ?? el.name,
783
+ detail: `${where}this custom chart has no named source (\`dataSources\`), so \`chart.sources\` is empty and the widget has no numbers to draw.`,
784
+ });
785
+ }
769
786
  for (const [name, src] of namedSourcesOf(el)) {
770
787
  const gaps = namedSourceGaps(name, src);
771
788
  if (!gaps.length) continue;