suppa-mcp-2 1.41.0 → 1.42.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 +3 -3
- package/dist/server.js +6 -2
- package/dist/tools/formLifecycle.js +41 -3
- package/dist/tools/formV2.js +149 -59
- package/package.json +3 -1
- package/skills/suppa-form-v2/SKILL.md +3 -0
- package/skills/suppa-form-v2/VUE_COMPILER.json +9 -0
- package/skills/suppa-form-v2/notes/chart.md +2 -0
- package/skills/suppa-form-v2/references/charts.md +2 -1
- package/skills/suppa-form-v2/references/custom-chart.md +121 -0
- package/skills/suppa-form-v2/scripts/form-rules.mjs +7 -2
- package/skills/suppa-form-v2/scripts/validate-form-schema.mjs +140 -8
- package/skills/suppa-form-v2/scripts/vue-compiler.mjs +34 -0
- package/skills/suppa-form-v2/scripts/widget-code.mjs +404 -0
package/README.md
CHANGED
|
@@ -546,11 +546,11 @@ the `schema` column on the row since 2.1, 58 component types — and is served b
|
|
|
546
546
|
| Tool | Description |
|
|
547
547
|
|---|---|
|
|
548
548
|
| `suppa_form_kb` | The 2.0 form knowledge base: the 58 element types, one type's prop table, a behaviour note, a reference topic, a template |
|
|
549
|
-
| `suppa_validate_form_schema` | Run the 2.0 form gate over a draft before writing it — 37 structural error codes (the authoring lints live in the source agent, not here) |
|
|
550
|
-
| `suppa_write_form_draft` | Save a checked draft through the builder's own save (`PUT /core/forms/:id/schema`) — gated first, guarded by the form's revision, recorded in History; `variables` only when the draft lists some. It never publishes |
|
|
549
|
+
| `suppa_validate_form_schema` | Run the 2.0 form gate over a draft before writing it — 37 structural error codes (the authoring lints live in the source agent, not here), each chart's and each custom chart source's readiness, and widget code: every widget template is compiled with the builder's own compiler (`@vue/compiler-dom` 3.5.12, browser production build) into the `compiledRender` the runtime executes, and checked against the widget sandbox |
|
|
550
|
+
| `suppa_write_form_draft` | Save a checked draft through the builder's own save (`PUT /core/forms/:id/schema`) — gated first against the live form (what the form already has does not block), guarded by the form's revision, recorded in History; saves the widget renders the gate compiled, never a hand-written one; `variables` only when the draft lists some. It never publishes |
|
|
551
551
|
| `suppa_create_form_v2` | Create a 2.0 form (create / update / custom) with its draft in one transaction — the routing flag and default variable the builder adds, optionally filed into a folder (confirm-gated) |
|
|
552
552
|
| `suppa_form_versions` | A form's published versions, the component diff between two of them, and a summary of recent draft saves (read-only) |
|
|
553
|
-
| `suppa_form_lifecycle` | Publish, roll back (restore + publish), discard (unrecoverable) or promote — gated on the form gate and on the version belonging to the form (confirm-gated) |
|
|
553
|
+
| `suppa_form_lifecycle` | Publish, roll back (restore + publish), discard (unrecoverable) or promote — gated on the form gate (a stored widget with an empty render is refused) and on the version belonging to the form (confirm-gated) |
|
|
554
554
|
|
|
555
555
|
### Migration (Suppa 1.0 → 2.0) & workspace
|
|
556
556
|
|
package/dist/server.js
CHANGED
|
@@ -2569,7 +2569,8 @@ export function buildToolTable() {
|
|
|
2569
2569
|
description: "The Suppa 2.0 (entity-builder) FORM knowledge base. Offline; touches no tenant.\n\n" +
|
|
2570
2570
|
" components the 58 element types (start here) api prop table for the types you name\n" +
|
|
2571
2571
|
" base props every element supports note one type's BEHAVIOUR\n" +
|
|
2572
|
-
" ref layout|binding|tables|charts|conditions|styling|publishing
|
|
2572
|
+
" ref layout|binding|tables|charts|custom-chart|conditions|styling|publishing|\n" +
|
|
2573
|
+
" choosing-elements\n" +
|
|
2573
2574
|
" template a starting draft by name rules the nine rules and what blocks\n\n" +
|
|
2574
2575
|
" No mode returns all 58 prop tables: they are 13,412 tokens stripped, and not carrying\n" +
|
|
2575
2576
|
" them is what this skill is for. Full skill: skills/suppa-form-v2/SKILL.md.",
|
|
@@ -2618,7 +2619,9 @@ export function buildToolTable() {
|
|
|
2618
2619
|
description: "Save a Suppa 2.0 form as a DRAFT on the tenant, through the builder's own save\n" +
|
|
2619
2620
|
" (PUT /core/forms/:id/schema). It never publishes: what others see stays the published\n" +
|
|
2620
2621
|
" version; a published form reads `editing`. The save appears in the builder's History.\n\n" +
|
|
2621
|
-
" The gate runs first
|
|
2622
|
+
" The gate runs first, judged against the live form: what the form already has does not\n" +
|
|
2623
|
+
" block, a refusal or an error the draft adds and nothing is written. It compiles each\n" +
|
|
2624
|
+
" widget's compiledRender from its template; a hand-written one is never saved.\n" +
|
|
2622
2625
|
" The row is read first and a read that does not clearly succeed ABORTS — merging over a\n" +
|
|
2623
2626
|
" failed read is how a saved mobile layout and code-form vanish on a call returning 200.\n" +
|
|
2624
2627
|
" Writes schema and settings; `variables` only when the draft lists some — the list is the\n" +
|
|
@@ -2980,6 +2983,7 @@ async function healthCheck(deep = true) {
|
|
|
2980
2983
|
// first gate call.
|
|
2981
2984
|
form_v2_core: await formV2.coreStatus(),
|
|
2982
2985
|
form_v2_gate: formV2.skillFile("scripts", "validate-form-schema.mjs") ? "present" : "MISSING",
|
|
2986
|
+
form_v2_widget_compiler: await formV2.widgetCompilerStatus(),
|
|
2983
2987
|
entity_code_validator: await entityCode.validatorStatus(),
|
|
2984
2988
|
},
|
|
2985
2989
|
};
|
|
@@ -347,13 +347,51 @@ export async function formVersions(formId, diffFrom = null, diffTo = null, chang
|
|
|
347
347
|
}
|
|
348
348
|
// ---------------------------------------------------------------------------------------------
|
|
349
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) {
|
|
360
|
+
const errors = [];
|
|
361
|
+
const warnings = [];
|
|
362
|
+
for (const w of Array.isArray(compiled) ? compiled.filter(isObj) : []) {
|
|
363
|
+
const where = `${w.presentation === "mobileSchema" ? "mobileSchema — " : ""}\`${w.slot}.compiledRender\``;
|
|
364
|
+
if (w.why === "empty") {
|
|
365
|
+
errors.push({
|
|
366
|
+
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.`,
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
else if (w.why === "mismatch") {
|
|
371
|
+
// `equivalent` — the same template compiled by another build (a Node-side tool) — is not news.
|
|
372
|
+
warnings.push({
|
|
373
|
+
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.`,
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
return { errors, warnings };
|
|
379
|
+
}
|
|
350
380
|
async function gateOn(envelope, baseline) {
|
|
351
381
|
try {
|
|
352
382
|
const mod = await loadGate();
|
|
353
383
|
if (!mod)
|
|
354
384
|
return { ok: false, errors: [], warnings: [], checked: false, error: "the form gate is missing — reinstall suppa-mcp-2." };
|
|
355
385
|
const g = await mod.validateForm(envelope, baseline ? { baseline } : {});
|
|
356
|
-
|
|
386
|
+
const frozen = frozenWidgetFindings(g.compiled_widgets);
|
|
387
|
+
const errors = [...(g.errors ?? []), ...frozen.errors];
|
|
388
|
+
return {
|
|
389
|
+
ok: !g.refused && !!g.ok && frozen.errors.length === 0,
|
|
390
|
+
errors,
|
|
391
|
+
warnings: [...(g.warnings ?? []), ...frozen.warnings],
|
|
392
|
+
checked: true,
|
|
393
|
+
...(g.refused ? { error: "the gate refused the envelope" } : {}),
|
|
394
|
+
};
|
|
357
395
|
}
|
|
358
396
|
catch (e) {
|
|
359
397
|
return { ok: false, errors: [], warnings: [], checked: false, error: `${await checkerFailed()} (${msgOf(e)})` };
|
|
@@ -438,7 +476,7 @@ export async function formLifecycle(formId, action, versionId = null, confirm =
|
|
|
438
476
|
plan.freezes = { ...compare(liveSnap?.schema, draft.schema), status_now: draft.status };
|
|
439
477
|
const g = await gateAgainstLive(envelopeOf(draft), liveSnap);
|
|
440
478
|
plan.gate = g.checked ? { passes: g.ok, errors: g.errors.length, already_live: g.already_live, warnings: g.warnings.length } : g.error;
|
|
441
|
-
warnings.push(...gateErrorLines(g.errors));
|
|
479
|
+
warnings.push(...gateErrorLines(g.errors), ...gateErrorLines(g.warnings.filter((w) => w?.code === "widget_render_mismatch")));
|
|
442
480
|
plan.effect = "publish: a new default version";
|
|
443
481
|
warnings.push("publishing makes this draft the version every user of this tenant sees; the draft itself is unchanged.");
|
|
444
482
|
}
|
|
@@ -455,7 +493,7 @@ export async function formLifecycle(formId, action, versionId = null, confirm =
|
|
|
455
493
|
plan.restores = { version_id: vid, versionNumber: target?.versionNumber, elements: componentIds(snap.schema).length };
|
|
456
494
|
const g = await gateAgainstLive(envelopeOf(snap), liveSnap);
|
|
457
495
|
plan.gate = g.checked ? { passes: g.ok, errors: g.errors.length, already_live: g.already_live, warnings: g.warnings.length } : g.error;
|
|
458
|
-
warnings.push(...gateErrorLines(g.errors));
|
|
496
|
+
warnings.push(...gateErrorLines(g.errors), ...gateErrorLines(g.warnings.filter((w) => w?.code === "widget_render_mismatch")));
|
|
459
497
|
plan.effect = "rollback: restore, then publish";
|
|
460
498
|
warnings.push(`version ${vid} is restored OVER the current draft (overwriting it, unrecoverably — no change-set) and then ` +
|
|
461
499
|
"PUBLISHED as a new default version, live for every user.");
|
package/dist/tools/formV2.js
CHANGED
|
@@ -63,6 +63,27 @@ export async function coreStatus() {
|
|
|
63
63
|
return `UNUSABLE: ${e instanceof Error ? e.message : String(e)}`;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Is the vendored widget compiler USABLE? Loaded and run once: every widget a draft carries is
|
|
68
|
+
* compiled by it before the gate answers, so a missing or truncated bundle fails every such draft.
|
|
69
|
+
*/
|
|
70
|
+
export async function widgetCompilerStatus() {
|
|
71
|
+
const p = skillFile("scripts", "vue-compiler.mjs");
|
|
72
|
+
if (!p)
|
|
73
|
+
return "MISSING";
|
|
74
|
+
try {
|
|
75
|
+
const mod = await import(pathToFileURL(p).href);
|
|
76
|
+
const code = String(mod.compile?.("<div>{{ a }}</div>", { mode: "function" })?.code ?? "");
|
|
77
|
+
if (!code.includes("return function render("))
|
|
78
|
+
return "UNUSABLE: it does not compile a template to a render";
|
|
79
|
+
const stampPath = skillFile("VUE_COMPILER.json");
|
|
80
|
+
const version = stampPath ? readJson(stampPath).value?.version : undefined;
|
|
81
|
+
return `present (@vue/compiler-dom ${version ?? "version unknown"})`;
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
return `UNUSABLE: ${e instanceof Error ? e.message : String(e)}`;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
66
87
|
/** Why a checker failure is not a draft failure — read from the file that defines it. */
|
|
67
88
|
export async function checkerFailed() {
|
|
68
89
|
const p = skillFile("scripts", "form-rules.mjs");
|
|
@@ -504,6 +525,45 @@ export function gateErrorLines(errors, cap = 25) {
|
|
|
504
525
|
lines.push(`… and ${list.length - cap} more gate errors — suppa_validate_form_schema lists them all.`);
|
|
505
526
|
return lines;
|
|
506
527
|
}
|
|
528
|
+
/** The form on the tenant as the envelope the gate reads as its baseline. */
|
|
529
|
+
function liveEnvelope(row) {
|
|
530
|
+
return {
|
|
531
|
+
schema: row.schema ?? [],
|
|
532
|
+
settings: row.settings && typeof row.settings === "object" ? row.settings : {},
|
|
533
|
+
...(row.mobileSchema ? { mobileSchema: row.mobileSchema } : {}),
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
const findingKey = (f) => `${f?.code ?? "?"}|${f?.elementId ?? ""}`;
|
|
537
|
+
/**
|
|
538
|
+
* The gate on a draft EDIT, judged against the form as the tenant holds it now.
|
|
539
|
+
*
|
|
540
|
+
* Until 2026-10-02 the draft write ran the gate COLD, although it reads the form right after: an
|
|
541
|
+
* edit of a form whose live elements the vendored manifest does not know yet (form 292, a FB 2.1
|
|
542
|
+
* custom chart) was refused whatever it changed. Two things make an edit fair, and the publish gate
|
|
543
|
+
* already does both (formLifecycle.ts `gateAgainstLive`):
|
|
544
|
+
*
|
|
545
|
+
* - the live form is the BASELINE — the core downgrades the props and types it echoes, brand
|
|
546
|
+
* conformance and the widget compile leave its elements alone;
|
|
547
|
+
* - a finding the live form ALREADY carries does not block, because the baseline absorbs drift,
|
|
548
|
+
* 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.
|
|
552
|
+
*
|
|
553
|
+
* `already_live` lists what was subtracted, so the answer says it rather than going quiet.
|
|
554
|
+
*/
|
|
555
|
+
async function gateEdit(mod, draft, live, normalize) {
|
|
556
|
+
const baseline = live ? liveEnvelope(live) : null;
|
|
557
|
+
const g = await mod.validateForm(draft, baseline ? { baseline, normalize } : { normalize });
|
|
558
|
+
if (g.refused || g.ok || !baseline)
|
|
559
|
+
return { ...g, already_live: [] };
|
|
560
|
+
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)));
|
|
564
|
+
return { ...g, ok: added.length === 0, errors: added, already_live: already };
|
|
565
|
+
}
|
|
566
|
+
const alreadyLive = (list) => list.map((f) => ({ code: f?.code, elementId: f?.elementId ?? null }));
|
|
507
567
|
/** A 409 from the revision guard, in words, with the revision the row holds now. */
|
|
508
568
|
function staleAnswer(message, id) {
|
|
509
569
|
// The status, not a 409 anywhere in the text: a 400 whose body names form 409 is a 400.
|
|
@@ -523,13 +583,25 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
|
|
|
523
583
|
const target = String(path ?? "").trim();
|
|
524
584
|
// THE CONFIRM GATE COMES FIRST — before the path check and before any tenant read. A host reads
|
|
525
585
|
// destructiveHint:true as "ask the user", and a tool that answers anything else on the first call
|
|
526
|
-
// has quietly opted out of that. The
|
|
586
|
+
// has quietly opted out of that. The preview only READS the tenant: the form, to judge the draft
|
|
587
|
+
// against it and to say what the write would replace.
|
|
527
588
|
if (!confirm) {
|
|
528
589
|
let preview = "the draft is gated on the confirmed call";
|
|
529
590
|
let draftSettings = {};
|
|
530
591
|
let draftVars = null;
|
|
531
592
|
let gateLines = [];
|
|
532
593
|
let draftComponents = null;
|
|
594
|
+
// THE FORM AS IT IS — read FIRST, because the gate judges the draft against it. A `/select` is a
|
|
595
|
+
// read, and the confirm-gate contract permits it here. A tenant that cannot be reached must still
|
|
596
|
+
// leave this as confirmation_required, so every failure degrades to a sentence.
|
|
597
|
+
let row = null;
|
|
598
|
+
let rowError = null;
|
|
599
|
+
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 } });
|
|
601
|
+
}
|
|
602
|
+
catch (e) {
|
|
603
|
+
rowError = e instanceof Error ? e.message : String(e);
|
|
604
|
+
}
|
|
533
605
|
try {
|
|
534
606
|
const peek = readJson(target);
|
|
535
607
|
if (peek.error)
|
|
@@ -539,7 +611,7 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
|
|
|
539
611
|
const s = skillFile("scripts", "validate-form-schema.mjs");
|
|
540
612
|
if (s) {
|
|
541
613
|
const mod = await import(pathToFileURL(s).href);
|
|
542
|
-
const g = await mod
|
|
614
|
+
const g = await gateEdit(mod, peek.value, row && typeof row === "object" ? row : null, normalize);
|
|
543
615
|
draftSettings = (g.draft && typeof g.draft.settings === "object" && g.draft.settings) || {};
|
|
544
616
|
draftComponents = g.draft?.schema ?? null;
|
|
545
617
|
// The blocking findings travel in `warnings`, whole: a finding's detail is often longer
|
|
@@ -550,6 +622,7 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
|
|
|
550
622
|
elements: g.elements ?? 0,
|
|
551
623
|
errors: (g.errors ?? []).map((e) => ({ code: e.code, elementId: e.elementId })),
|
|
552
624
|
warnings: g.warnings,
|
|
625
|
+
...(g.already_live.length ? { already_on_the_live_form: alreadyLive(g.already_live) } : {}),
|
|
553
626
|
};
|
|
554
627
|
}
|
|
555
628
|
}
|
|
@@ -557,47 +630,43 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
|
|
|
557
630
|
catch (e) {
|
|
558
631
|
preview = `the draft could not be checked yet: ${e instanceof Error ? e.message : String(e)}`;
|
|
559
632
|
}
|
|
560
|
-
// WHAT IT WOULD REPLACE.
|
|
561
|
-
// them here. A tenant that cannot be reached must still leave this as confirmation_required, so
|
|
562
|
-
// every failure degrades to a sentence.
|
|
633
|
+
// WHAT IT WOULD REPLACE.
|
|
563
634
|
let replaces = "the form could not be read from here; the confirmed call reads it again and aborts if that fails";
|
|
564
635
|
let previewCodeWarning = null;
|
|
565
636
|
let revision = null;
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
if (!row)
|
|
569
|
-
replaces = `no form with id ${id} on this tenant`;
|
|
570
|
-
else {
|
|
571
|
-
// A child form's inherited elements live in the parent, not in this draft: not judged here.
|
|
572
|
-
if (draftComponents && !row.parent?.id) {
|
|
573
|
-
const missing = missingCodeRefs(row.code, draftComponents);
|
|
574
|
-
if (missing.length)
|
|
575
|
-
previewCodeWarning = codeRefsWarning(missing);
|
|
576
|
-
}
|
|
577
|
-
revision = typeof row.updatedAt === "string" ? row.updatedAt : null;
|
|
578
|
-
const col = (row.schema && typeof row.schema === "object" && !Array.isArray(row.schema) ? row.schema : {});
|
|
579
|
-
const rowSettings = (row.settings && typeof row.settings === "object" ? row.settings : {});
|
|
580
|
-
// The merge keeps a row key the draft does not mention. That is deliberate — dropping keys
|
|
581
|
-
// this tool does not understand would be worse — but it is invisible, and invisible is how
|
|
582
|
-
// a setting an author thought they had removed stays switched on.
|
|
583
|
-
const kept = Object.keys(rowSettings).filter((k) => !(k in draftSettings));
|
|
584
|
-
replaces = {
|
|
585
|
-
form: { id: row.id, name: row.name, type: row.type, status: row.status },
|
|
586
|
-
elements_now: Array.isArray(col.components) ? col.components.length : 0,
|
|
587
|
-
connections_now: Array.isArray(col.connections) ? col.connections.length : 0,
|
|
588
|
-
overrides_now: Array.isArray(col.overrides) ? col.overrides.length : 0,
|
|
589
|
-
settings_overwritten: Object.keys(draftSettings),
|
|
590
|
-
settings_kept_because_the_draft_is_silent_about_them: kept,
|
|
591
|
-
...(kept.length
|
|
592
|
-
? { warning: "a settings key the draft does not mention is KEPT, not removed — say it explicitly (e.g. showSubmitButton: false) if you meant to turn it off" }
|
|
593
|
-
: {}),
|
|
594
|
-
...(row.status === "published" ? { status_after: "editing — the published version keeps serving until someone publishes" } : {}),
|
|
595
|
-
...(row.lockedBy ? { locked_by: row.lockedBy } : {}),
|
|
596
|
-
};
|
|
597
|
-
}
|
|
637
|
+
if (rowError) {
|
|
638
|
+
replaces = `the form could not be read from here (${rowError}); the confirmed call reads it again and aborts if that fails`;
|
|
598
639
|
}
|
|
599
|
-
|
|
600
|
-
replaces = `
|
|
640
|
+
else if (!row) {
|
|
641
|
+
replaces = `no form with id ${id} on this tenant`;
|
|
642
|
+
}
|
|
643
|
+
else {
|
|
644
|
+
// A child form's inherited elements live in the parent, not in this draft: not judged here.
|
|
645
|
+
if (draftComponents && !row.parent?.id) {
|
|
646
|
+
const missing = missingCodeRefs(row.code, draftComponents);
|
|
647
|
+
if (missing.length)
|
|
648
|
+
previewCodeWarning = codeRefsWarning(missing);
|
|
649
|
+
}
|
|
650
|
+
revision = typeof row.updatedAt === "string" ? row.updatedAt : null;
|
|
651
|
+
const col = (row.schema && typeof row.schema === "object" && !Array.isArray(row.schema) ? row.schema : {});
|
|
652
|
+
const rowSettings = (row.settings && typeof row.settings === "object" ? row.settings : {});
|
|
653
|
+
// The merge keeps a row key the draft does not mention. That is deliberate — dropping keys
|
|
654
|
+
// this tool does not understand would be worse — but it is invisible, and invisible is how
|
|
655
|
+
// a setting an author thought they had removed stays switched on.
|
|
656
|
+
const kept = Object.keys(rowSettings).filter((k) => !(k in draftSettings));
|
|
657
|
+
replaces = {
|
|
658
|
+
form: { id: row.id, name: row.name, type: row.type, status: row.status },
|
|
659
|
+
elements_now: Array.isArray(col.components) ? col.components.length : 0,
|
|
660
|
+
connections_now: Array.isArray(col.connections) ? col.connections.length : 0,
|
|
661
|
+
overrides_now: Array.isArray(col.overrides) ? col.overrides.length : 0,
|
|
662
|
+
settings_overwritten: Object.keys(draftSettings),
|
|
663
|
+
settings_kept_because_the_draft_is_silent_about_them: kept,
|
|
664
|
+
...(kept.length
|
|
665
|
+
? { warning: "a settings key the draft does not mention is KEPT, not removed — say it explicitly (e.g. showSubmitButton: false) if you meant to turn it off" }
|
|
666
|
+
: {}),
|
|
667
|
+
...(row.status === "published" ? { status_after: "editing — the published version keeps serving until someone publishes" } : {}),
|
|
668
|
+
...(row.lockedBy ? { locked_by: row.lockedBy } : {}),
|
|
669
|
+
};
|
|
601
670
|
}
|
|
602
671
|
// The preview's own sentences go in `warnings`, which confirmRequired never shortens.
|
|
603
672
|
const warnings = [...gateLines, ...(previewCodeWarning ? [previewCodeWarning] : [])];
|
|
@@ -637,15 +706,15 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
|
|
|
637
706
|
const read = readJson(target);
|
|
638
707
|
if (read.error)
|
|
639
708
|
return jsonResponse({ error: `the draft could not be read: ${read.error}` });
|
|
640
|
-
// 1. NOTHING UNCHECKED IS EVER WRITTEN. The gate runs
|
|
641
|
-
//
|
|
709
|
+
// 1. NOTHING UNCHECKED IS EVER WRITTEN. The gate runs on the same file, with the same rules, and
|
|
710
|
+
// a refusal or any error stops the write. An envelope it cannot read at all is refused before
|
|
711
|
+
// the tenant is touched; everything else is judged against the form as the tenant holds it.
|
|
642
712
|
const script = skillFile("scripts", "validate-form-schema.mjs");
|
|
643
713
|
if (!script)
|
|
644
714
|
return jsonResponse({ error: "the form gate is missing — reinstall suppa-mcp-2." });
|
|
645
|
-
let
|
|
715
|
+
let mod;
|
|
646
716
|
try {
|
|
647
|
-
|
|
648
|
-
gate = await mod.validateForm(read.value, { normalize });
|
|
717
|
+
mod = await import(pathToFileURL(script).href);
|
|
649
718
|
}
|
|
650
719
|
catch (e) {
|
|
651
720
|
return jsonResponse({
|
|
@@ -653,22 +722,29 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
|
|
|
653
722
|
written: false,
|
|
654
723
|
});
|
|
655
724
|
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
725
|
+
const refusal = (gate) => jsonResponse({
|
|
726
|
+
written: false,
|
|
727
|
+
reason: gate.refused ? "the gate refused the draft" : "the gate found errors",
|
|
728
|
+
errors: gate.errors,
|
|
729
|
+
warnings: gate.warnings,
|
|
730
|
+
notes: gate.notes,
|
|
731
|
+
...(gate.already_live?.length
|
|
732
|
+
? {
|
|
733
|
+
already_on_the_live_form: alreadyLive(gate.already_live),
|
|
734
|
+
already_note: "these the form on the tenant already has — they do not block; the errors above are what this draft adds",
|
|
735
|
+
}
|
|
736
|
+
: {}),
|
|
737
|
+
note: "Nothing was written. Fix every entry and re-run — a form nobody checked is not a form that passed.",
|
|
738
|
+
});
|
|
739
|
+
const envelope = typeof mod.normalizeEnvelope === "function" ? mod.normalizeEnvelope(read.value) : null;
|
|
740
|
+
if (envelope?.error)
|
|
741
|
+
return refusal({ refused: true, errors: [envelope.error], warnings: [], notes: [] });
|
|
666
742
|
// 2. READ THE ROW, AND ABORT IF IT DOES NOT CLEARLY ARRIVE.
|
|
667
743
|
let row;
|
|
668
744
|
try {
|
|
669
745
|
row = await selectEntity("Forms", [{ field: "id", comparator: "=", value: id }], {
|
|
670
746
|
id: true, name: true, type: true, status: true,
|
|
671
|
-
schema: true, settings: true, updatedAt: true,
|
|
747
|
+
schema: true, mobileSchema: true, settings: true, updatedAt: true,
|
|
672
748
|
lockedBy: { id: true, fullName: true }, lockedAt: true,
|
|
673
749
|
entity: { id: true, name: true }, code: true, parent: { id: true },
|
|
674
750
|
});
|
|
@@ -684,7 +760,20 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
|
|
|
684
760
|
if (!row || typeof row !== "object") {
|
|
685
761
|
return jsonResponse({ written: false, error: `no form with id ${id} on this tenant.` });
|
|
686
762
|
}
|
|
687
|
-
// 3.
|
|
763
|
+
// 3. THE GATE, against that row.
|
|
764
|
+
let gate;
|
|
765
|
+
try {
|
|
766
|
+
gate = await gateEdit(mod, read.value, row, normalize);
|
|
767
|
+
}
|
|
768
|
+
catch (e) {
|
|
769
|
+
return jsonResponse({
|
|
770
|
+
error: `${await checkerFailed()} (${e instanceof Error ? e.message : String(e)})`,
|
|
771
|
+
written: false,
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
if (gate.refused || !gate.ok)
|
|
775
|
+
return refusal(gate);
|
|
776
|
+
// 4. SOMEONE ELSE HAS IT OPEN. The builder holds `lockedBy` while a form is being edited; writing
|
|
688
777
|
// under them means one of the two of you loses work without being told.
|
|
689
778
|
const lockedBy = row.lockedBy;
|
|
690
779
|
let lockNote = null;
|
|
@@ -729,7 +818,7 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
|
|
|
729
818
|
: {});
|
|
730
819
|
const existingSettings = (row.settings && typeof row.settings === "object" ? row.settings : {});
|
|
731
820
|
const draft = gate.draft ?? {};
|
|
732
|
-
//
|
|
821
|
+
// 5. THE VARIABLES — only the file's own non-empty list is sent, and only once the form's own were read.
|
|
733
822
|
const draftVars = sentVariables(read.value);
|
|
734
823
|
let variables = null;
|
|
735
824
|
if (draftVars) {
|
|
@@ -748,7 +837,7 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
|
|
|
748
837
|
return jsonResponse({ written: false, error: dropsDefaultError(String(variables.default_variable), variables.default_type), variables });
|
|
749
838
|
}
|
|
750
839
|
}
|
|
751
|
-
//
|
|
840
|
+
// 6. BUILD THE COLUMN. `components` is this draft; `connections` comes from the draft when it
|
|
752
841
|
// carries them and from the row otherwise; `overrides` — a child form's diff against its
|
|
753
842
|
// parent — is PRESERVED and never invented, because dropping it detaches the form.
|
|
754
843
|
const schemaColumn = { components: draft.schema ?? [] };
|
|
@@ -782,6 +871,7 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
|
|
|
782
871
|
settings_kept_because_the_draft_is_silent_about_them: Object.keys(existingSettings).filter((k) => !(k in (draft.settings ?? {}))),
|
|
783
872
|
guarded_by_revision: revision,
|
|
784
873
|
warnings: gate.warnings,
|
|
874
|
+
...(gate.already_live.length ? { already_on_the_live_form: alreadyLive(gate.already_live) } : {}),
|
|
785
875
|
...(() => {
|
|
786
876
|
if (row.parent?.id)
|
|
787
877
|
return {}; // inherited elements live in the parent
|
|
@@ -800,7 +890,7 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
|
|
|
800
890
|
return jsonResponse({ ...stale, plan });
|
|
801
891
|
return jsonResponse({ written: false, error: `the write failed: ${msg}`, plan });
|
|
802
892
|
}
|
|
803
|
-
//
|
|
893
|
+
// 7. READ BACK. A 200 is not evidence: the form is what the tenant now holds.
|
|
804
894
|
let after = null;
|
|
805
895
|
try {
|
|
806
896
|
after = await selectEntity("Forms", [{ field: "id", comparator: "=", value: id }], { id: true, schema: true, status: true, updatedAt: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suppa-mcp-2",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.42.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": {
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"schema:gate": "node skills/suppa-entity-code/scripts/entity-code-guard.mjs --ci .",
|
|
36
36
|
"form:gate": "node skills/suppa-form-v2/scripts/validate-form-schema.mjs",
|
|
37
37
|
"sync:formbuilder": "node scripts/sync-formbuilder.mjs",
|
|
38
|
+
"sync:vue-compiler": "node scripts/sync-vue-compiler.mjs",
|
|
38
39
|
"guards:install": "node skills/suppa-entity-code/scripts/install-entity-code-guards.mjs"
|
|
39
40
|
},
|
|
40
41
|
"keywords": [
|
|
@@ -63,6 +64,7 @@
|
|
|
63
64
|
},
|
|
64
65
|
"devDependencies": {
|
|
65
66
|
"@types/node": "^20.0.0",
|
|
67
|
+
"@vue/compiler-dom": "3.5.12",
|
|
66
68
|
"esbuild": "^0.21.5",
|
|
67
69
|
"typescript": "^5.6.0",
|
|
68
70
|
"vitest": "^2.1.0"
|
|
@@ -167,6 +167,8 @@ publishes; a new form is `suppa create-form-v2 --name <n> --type <t>`. A draft's
|
|
|
167
167
|
FULL list — an omitted one is deleted — so leave it out unless you mean to change them.
|
|
168
168
|
`suppa form-lifecycle --form-id <id> --action <a>` publishes, rolls back (which also publishes),
|
|
169
169
|
discards (unrecoverable) or promotes, each behind a confirmation. Say what you wrote.
|
|
170
|
+
Widget code (a custom chart's `customView`, a `dynamicComponent`'s `source`): write `template`,
|
|
171
|
+
`script`, `style` — the gate compiles `compiledRender`, the only part the runtime runs.
|
|
170
172
|
|
|
171
173
|
## References
|
|
172
174
|
|
|
@@ -179,6 +181,7 @@ Read on demand, never up front — `suppa form-kb --mode ref --topic <name>`.
|
|
|
179
181
|
| `references/binding.md` | `dataSource`, variables, filters, enum values |
|
|
180
182
|
| `references/tables.md` | Any `table` or `entityList` |
|
|
181
183
|
| `references/charts.md` | Any `chart` — the one tall element with no automatic height |
|
|
184
|
+
| `references/custom-chart.md` | `chartType: 'custom'` — named sources, the widget, `chart.*` |
|
|
182
185
|
| `references/conditions.md` | `visible`/`readonly`/`required`/`disabled`/`readMode` as rules |
|
|
183
186
|
| `references/styling.md` | `theme`, `styleIntent`, brand tokens, custom SCSS |
|
|
184
187
|
| `references/publishing.md` | The write path, metadata columns, entity plans |
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"package": "@vue/compiler-dom",
|
|
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",
|
|
5
|
+
"pulledAt": "2026-10-02",
|
|
6
|
+
"bytes": 214137,
|
|
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
|
+
"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
|
+
}
|
|
@@ -17,4 +17,6 @@ A `kind: 'formula'` row does not count as the measure; a `kpi` tile needs no `ca
|
|
|
17
17
|
|
|
18
18
|
**Right-looking, wrong question.** `limit: 10` alone takes the first ten of the alphabetical category order — "top 10" is `sortBy: 'value'` + `sortOrder: 'desc'` + `limit`, and `'value'` silently falls back to category order under `seriesField`. `categoryDateGranularity` buckets by date PART, so `quarter` merges Q1 2025 with Q1 2026. `chartType: 'pie'` draws a donut until `donut: false`. A `gauge` plots only the first value of the first series against `gaugeMax`, whose 200 is a mock-era placeholder. Money is stored in minor units and the chart is the one renderer that does not divide by 100 — `style: 'currency'` picks the symbol only, so add `centsToUnits: true`.
|
|
19
19
|
|
|
20
|
+
**`chartType: 'custom'` is another element in all but name**: it reads named `dataSources` (never `dataSource`) and draws an author-written Vue widget whose `compiledRender` the gate compiles — `suppa form-kb --mode ref --topic custom-chart`.
|
|
21
|
+
|
|
20
22
|
**Live vs frozen.** An `html` stat tile is a hard-coded number; a tile whose value is an aggregate is `chartType: 'kpi'`. `kpiSparkline: true` without a `categoryField` (or `sqlCategoryColumn`) is one bucket, so the line never draws — and that warning is builder-only.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# chart
|
|
2
2
|
|
|
3
|
-
*Open when the form needs a chart, a KPI tile, or a dashboard of either.*
|
|
3
|
+
*Open when the form needs a chart, a KPI tile, or a dashboard of either.* A tile no built-in type
|
|
4
|
+
draws is a CUSTOM chart (`chartType: 'custom'`: named sources + a widget) — `--topic custom-chart`.
|
|
4
5
|
|
|
5
6
|
## Size it yourself — nothing else will
|
|
6
7
|
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# The custom chart — named sources and an author-written widget
|
|
2
|
+
|
|
3
|
+
*Open before you author or edit a `chart` with `chartType: 'custom'` (FormBuilder 2.1). Sources:
|
|
4
|
+
platform-front-redesind `docs/formBuilder/features/chart-element.md` § Custom chart, the FE skills
|
|
5
|
+
`form-builder-2-custom-chart` and `form-builder-2-dynamic-component`, `elements/chart/custom/`.*
|
|
6
|
+
|
|
7
|
+
Use it only for a tile no built-in type draws — a KPI with a two-segment bar, a 100 % stacked bar
|
|
8
|
+
with a section per segment, numbers from several queries on one tile. Anything a built-in type does
|
|
9
|
+
(column … kpi) gets options, formats, fullscreen and click drill for free; a custom chart gets none
|
|
10
|
+
of them. There is **no `SuppaChart`** in the widget: bars are `div`s with `:style` widths.
|
|
11
|
+
|
|
12
|
+
## The schema
|
|
13
|
+
|
|
14
|
+
```jsonc
|
|
15
|
+
{ "type": "chart", "chartType": "custom", "name": "kpiRow",
|
|
16
|
+
"dataSources": { // Record<name, a chart dataSource>; `dataSource` is NOT read
|
|
17
|
+
"pipeline": { "kind": "entity", "entity": "Opportunities", "compare": "previousPeriod",
|
|
18
|
+
"values": [{ "id": "m1", "key": "won", "label": "Won", "field": "amount", "aggregation": "sum" }] },
|
|
19
|
+
"plan": { "kind": "suppaSql", "sqlQuery": "SELECT SUM(target) AS target FROM …",
|
|
20
|
+
"sqlValueColumns": [{ "key": "target" }] } },
|
|
21
|
+
"customView": { "template": "<div>…</div>", "script": "return { … };", "style": "",
|
|
22
|
+
"compiledRender": "", "translations": [{ "id": "t1", "key": "tile.won", "values": { "en": "Won", "uk": "Виграні" } }] },
|
|
23
|
+
"drillDowns": { "byStage": { "entity": "Opportunities", "formId": 42 } } }
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`customView.sourceSlots` is written by the builder at template save — never author it. Of the
|
|
27
|
+
chart's own options only number format and empty-state text still act (the empty text is what a
|
|
28
|
+
VIEWER sees when the widget fails); `legend`, `kpiIcon`, `drillDownEnabled`, a `dataSource`… persist
|
|
29
|
+
and nothing reads them.
|
|
30
|
+
|
|
31
|
+
**Names are code.** A source name, a measure `key` and a drill-down name match
|
|
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
|
|
36
|
+
source, a key or a drill-down breaks every `chart.sources.<old>` / `chart.drill('<old>')` that reads it.
|
|
37
|
+
|
|
38
|
+
## Each source loads on its own — or never
|
|
39
|
+
|
|
40
|
+
No category is required, but each source must be complete: an **entity** source needs `entity` and
|
|
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>`
|
|
44
|
+
stays not-ready and the widget shows its loading or empty state forever, with no error.
|
|
45
|
+
|
|
46
|
+
`compare: 'previousPeriod'` works only on an entity source without `seriesField`, and only when its
|
|
47
|
+
filter carries a date period that can be shifted (`$this_month`, `$this_year`, an explicit range).
|
|
48
|
+
Elsewhere `previous` stays `undefined` and `delta` `null` for good.
|
|
49
|
+
|
|
50
|
+
## The `chart` object (read-only, frozen, reactive)
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
chart.sources.<name>: { loading, error, ready, isMock, missingParams: string[],
|
|
54
|
+
measures: { <key>: { key, label, value: number|null, previous?: number, delta: { percent, direction: 'up'|'down'|'flat' }|null,
|
|
55
|
+
values: number[], color, failed: boolean } },
|
|
56
|
+
series: [{ name, values, color }], categories: string[], rows: [{ category, <key|series>: value }],
|
|
57
|
+
filters: [{ field, comparator, value, range? }] } // what the LAST load was sent with
|
|
58
|
+
chart.format(value, 'source.key') // the measure's number format, else the element's; null → '—'
|
|
59
|
+
chart.drill('name', { source, measure, category, series, conditions }) // → Promise<boolean>
|
|
60
|
+
chart.drill({ source, measure }) // the form is found by the measure's entity
|
|
61
|
+
chart.reload(source?) chart.field('element') /* ComputedRef, a copy */ chart.peer('otherChart') chart.theme
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- Print a number only when `src.ready` — while loading or after an error the old numbers may still
|
|
65
|
+
be there. A measure whose own request failed reads `failed: true`, `value: null`.
|
|
66
|
+
- `value` folds by aggregation: sum/count add, min/max take the extreme, a grouped `avg` — and a SQL
|
|
67
|
+
column over several rows — is `null`. Read `values` / `rows`, or add a source without a category.
|
|
68
|
+
- The builder shows deterministic MOCK data (`isMock: true`); live data loads in preview and at runtime.
|
|
69
|
+
- A caption of the period reads `sources.<s>.filters` (a `between` leaf's `range`), not
|
|
70
|
+
`chart.field()`, which changes before the numbers do.
|
|
71
|
+
- Writing into `chart` throws. Compute into your own `computed`.
|
|
72
|
+
|
|
73
|
+
## Drill-downs from code
|
|
74
|
+
|
|
75
|
+
A named drill-down needs a details form (`formId`) and opens only the drilled target's entity — the
|
|
76
|
+
source's, or the measure's own; another entity answers `false` with a toast. A SQL source drills only
|
|
77
|
+
through a named drill-down with your own `conditions`, and then any entity is allowed. There is no
|
|
78
|
+
click-on-mark drill: call `chart.drill` from the marks the widget draws
|
|
79
|
+
(`@click="chart.drill('byStage', { source: 'pipeline', measure: 'won' })"`).
|
|
80
|
+
|
|
81
|
+
## The widget — a setup body in a sandbox
|
|
82
|
+
|
|
83
|
+
- `script` is a setup-function BODY ending in `return { …bindings }` — no `import`, `export`,
|
|
84
|
+
`require`, Options API or top-level `await`. In scope already: `ref computed watch watchEffect
|
|
85
|
+
reactive onMounted onUnmounted nextTick …`, `formAPI`, `t`, `defineApi`, and `chart`.
|
|
86
|
+
- `window document fetch localStorage …` are `undefined` in the script and the template. Backend
|
|
87
|
+
reads go through `formAPI.services.api.*`.
|
|
88
|
+
- Tags only from the sandbox registry: `SuppaButton SuppaInput SuppaTextarea SuppaSelect
|
|
89
|
+
SuppaDatePicker SuppaCheckbox SuppaRadioControl SuppaToggle BaseSwitch BaseIcon BaseBadge BaseTag
|
|
90
|
+
BaseText BaseAvatar BaseLoader BaseAccordion BaseTabsWrapper BaseModalWindow BaseScrollbar
|
|
91
|
+
BaseTable TaskTypeSelect`. Anything else renders as an empty unknown tag.
|
|
92
|
+
- Plain Tailwind utilities only: an arbitrary value (`w-[37%]`, `text-[#ff0055]`) has no CSS. A
|
|
93
|
+
runtime width or colour goes through `:style`; static decoration into `style` (plain CSS, scoped).
|
|
94
|
+
- Every user-facing string is `t('key')`, with its text in `customView.translations`.
|
|
95
|
+
|
|
96
|
+
**`compiledRender` is the only thing the runtime executes**, and an empty one renders nothing. Write
|
|
97
|
+
`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
|
|
101
|
+
stored empty render — re-save such a draft with write-form-draft first.
|
|
102
|
+
|
|
103
|
+
## From the form's code
|
|
104
|
+
|
|
105
|
+
`formAPI.elements.<chart>.sources.<name>` (typed with exactly the declared sources and keys,
|
|
106
|
+
read-only), `.reload(name?)`, `.drill(…)`, and `.api` / `.whenApi()` for what the widget exposed with
|
|
107
|
+
`defineApi`. Wait for the STICKY `sourcesLoaded` (`{ sources }`), not a one-shot `dataLoaded` — and
|
|
108
|
+
only on a mounted chart: one in a collapsed tab never reports. `dataLoaded` / `dataError` carry
|
|
109
|
+
`source`; `drillDownOpened` carries `drill`.
|
|
110
|
+
|
|
111
|
+
## What the gate checks
|
|
112
|
+
|
|
113
|
+
Errors: `chart_source_incomplete` per named source; `widget_template_empty` / `_invalid`,
|
|
114
|
+
`widget_script_invalid`, `widget_unknown_component`, `widget_invalid`; on publish
|
|
115
|
+
`widget_render_missing`. Warnings: `custom_chart_drill_unreachable`, `widget_tailwind_arbitrary`,
|
|
116
|
+
`widget_component_off_registry`, and on publish `widget_render_mismatch`. Until the vendored component manifest is next
|
|
117
|
+
synced (it predates the custom chart), a NEW custom chart is also refused as `unknown_prop` /
|
|
118
|
+
`invalid_prop_value`; an edit of a form that already has one passes — the draft write and publish
|
|
119
|
+
judge against the live form. It does not run the widget:
|
|
120
|
+
a `chart.sources.<name>` the code reads but the schema lacks, or a typo in an expression, shows only
|
|
121
|
+
in the builder's preview.
|