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
|
@@ -35,8 +35,13 @@ export const BLOCKING_SUMMARY =
|
|
|
35
35
|
"orphan_panel/dangling_parent), bad condition and prop and setting values (invalid_condition/" +
|
|
36
36
|
"invalid_prop_value/invalid_setting_value/invalid_variable_hydrate), collisions (duplicate_id/" +
|
|
37
37
|
"duplicate_name/duplicate_variable), a chart whose data source is not ready, so it would render " +
|
|
38
|
-
"the built-in demo series
|
|
39
|
-
"
|
|
38
|
+
"the built-in demo series — or a custom chart's named source that would never load " +
|
|
39
|
+
"(chart_source_incomplete), a table whose source can never run, so it " +
|
|
40
|
+
"would show skeleton rows forever (table_source_incomplete), and widget code that would not run: " +
|
|
41
|
+
"an empty or uncompilable template, a script that is not a setup body, a tag outside the widget " +
|
|
42
|
+
"sandbox (widget_template_empty/widget_template_invalid/widget_script_invalid/widget_unknown_component/" +
|
|
43
|
+
"widget_invalid; a publish also refuses a stored empty render, widget_render_missing). The gate " +
|
|
44
|
+
"compiles every widget's compiledRender itself. What it does NOT block on are the 57 authoring lints for the forms that validate and are " +
|
|
40
45
|
"still wrong. THOSE 57 LINTS ARE NOT IN THIS GATE: they live in the source agent's uxVerify pass " +
|
|
41
46
|
"and are not vendored here — measured, a draft with an empty container, a select bound to nothing, " +
|
|
42
47
|
"an unlabelled input, a chart with no height and a second Save beside the platform's own passes " +
|
|
@@ -57,6 +57,11 @@
|
|
|
57
57
|
* so out loud when it is validating a draft that plainly came from an existing form and none was
|
|
58
58
|
* given.
|
|
59
59
|
*
|
|
60
|
+
* ── 3. WIDGET CODE (widget-code.mjs). ──────────────────────────────────────────────────────────
|
|
61
|
+
* A widget's `compiledRender` is what the runtime executes, and nothing else — so every widget
|
|
62
|
+
* template is compiled HERE with the frontend's own compiler, and the returned draft carries that
|
|
63
|
+
* render, never a hand-written one. A widget the baseline already has is left alone.
|
|
64
|
+
*
|
|
60
65
|
* Exit codes match the package's other gates: 0 clean, 1 findings, 2 refused before checking.
|
|
61
66
|
*/
|
|
62
67
|
|
|
@@ -66,6 +71,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
66
71
|
|
|
67
72
|
import { BLOCKING_SUMMARY, CHECKER_FAILED, COULD_NOT_RUN, FORM_RULES_DIGEST } from "./form-rules.mjs";
|
|
68
73
|
import { applyManifestCorrections } from "./manifest-corrections.mjs";
|
|
74
|
+
import { checkWidgets, sameValue } from "./widget-code.mjs";
|
|
69
75
|
|
|
70
76
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
71
77
|
const SKILL = resolve(HERE, "..");
|
|
@@ -668,6 +674,36 @@ function connectionsWithoutId(connections) {
|
|
|
668
674
|
const CHART_AGGREGATIONS = Object.freeze(["sum", "count", "avg", "min", "max"]);
|
|
669
675
|
const filled = (v) => typeof v === "string" && v.trim().length > 0;
|
|
670
676
|
|
|
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`).
|
|
681
|
+
*/
|
|
682
|
+
function isSqlNamedSource(src) {
|
|
683
|
+
if (src.kind === "suppaSql") return true;
|
|
684
|
+
return !filled(src.kind) && filled(src.sqlQuery) && !filled(src.entity);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
/** A custom chart's named sources as `[name, source]` — own entries, objects only. */
|
|
688
|
+
function namedSourcesOf(el) {
|
|
689
|
+
const map = el && el.dataSources;
|
|
690
|
+
if (!map || typeof map !== "object" || Array.isArray(map)) return [];
|
|
691
|
+
return Object.entries(map).filter(([, src]) => src && typeof src === "object" && !Array.isArray(src));
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* What keeps one NAMED source from loading. The FE asks of each the question it asks of a built-in
|
|
696
|
+
* chart's source, with no category required — `isChartDataSourceReady(source, { requireCategory:
|
|
697
|
+
* false })` (data/chartDataSource.ts; custom/useChartDataSources.ts loads each source on its own):
|
|
698
|
+
* a SQL source needs its query and a value column with a `key`, an entity source its entity and a
|
|
699
|
+
* measure it can fetch. `chartType: 'kpi'` is chartSourceGaps' spelling of "no category".
|
|
700
|
+
*/
|
|
701
|
+
function namedSourceGaps(name, src) {
|
|
702
|
+
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\``));
|
|
705
|
+
}
|
|
706
|
+
|
|
671
707
|
/** What keeps one chart on demo data, as short phrases — empty when the FE would fetch live data. */
|
|
672
708
|
function chartSourceGaps(el) {
|
|
673
709
|
const kpi = el.chartType === "kpi";
|
|
@@ -723,6 +759,29 @@ function chartReadiness(schema, baselineById, presentation = "schema") {
|
|
|
723
759
|
const where = presentation === "mobileSchema" ? "mobileSchema — " : "";
|
|
724
760
|
for (const el of Array.isArray(schema) ? schema : []) {
|
|
725
761
|
if (!el || typeof el !== "object" || el.type !== "chart") continue;
|
|
762
|
+
// A CUSTOM chart reads its named `dataSources` and never `dataSource` (FE custom/
|
|
763
|
+
// useChartDataSources.ts) — judging the one it does not read is how every custom chart was
|
|
764
|
+
// refused as incomplete (reported 2026-10-02). Each named source is judged on its own, and the
|
|
765
|
+
// baseline downgrade is per source: the live form's same-named source with every one of the gaps.
|
|
766
|
+
if (el.chartType === "custom") {
|
|
767
|
+
const base = el.id !== undefined ? baselineById.get(el.id) : undefined;
|
|
768
|
+
const before = new Map(base && base.type === "chart" && base.chartType === "custom" ? namedSourcesOf(base) : []);
|
|
769
|
+
for (const [name, src] of namedSourcesOf(el)) {
|
|
770
|
+
const gaps = namedSourceGaps(name, src);
|
|
771
|
+
if (!gaps.length) continue;
|
|
772
|
+
const was = before.get(name);
|
|
773
|
+
const echoed = !!was && liveHasEveryGap(gaps, namedSourceGaps(name, was));
|
|
774
|
+
(echoed ? warnings : errors).push({
|
|
775
|
+
code: "chart_source_incomplete",
|
|
776
|
+
elementId: el.id ?? el.name,
|
|
777
|
+
detail:
|
|
778
|
+
`${where}${echoed ? "already incomplete on the live form — " : ""}source '${name}' of this custom chart is not ` +
|
|
779
|
+
`ready: ${gaps.join("; ")}. The FE never loads it, so \`chart.sources.${name}\` never becomes ready and the ` +
|
|
780
|
+
"widget shows its loading or empty state forever — no request, no error.",
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
continue;
|
|
784
|
+
}
|
|
726
785
|
const gaps = chartSourceGaps(el);
|
|
727
786
|
if (!gaps.length) continue;
|
|
728
787
|
const base = el.id !== undefined ? baselineById.get(el.id) : undefined;
|
|
@@ -745,6 +804,7 @@ function sqlChartDrillIgnored(schema, presentation = "schema") {
|
|
|
745
804
|
const where = presentation === "mobileSchema" ? "mobileSchema — " : "";
|
|
746
805
|
for (const el of Array.isArray(schema) ? schema : []) {
|
|
747
806
|
if (!el || typeof el !== "object" || el.type !== "chart") continue;
|
|
807
|
+
if (el.chartType === "custom") continue; // drills only through its named drillDowns + chart.drill
|
|
748
808
|
if (!el.dataSource || el.dataSource.kind !== "suppaSql") continue;
|
|
749
809
|
const set = [];
|
|
750
810
|
if (el.drillOpenSingleRecord === true) set.push("drillOpenSingleRecord");
|
|
@@ -765,6 +825,55 @@ function sqlChartDrillIgnored(schema, presentation = "schema") {
|
|
|
765
825
|
return out;
|
|
766
826
|
}
|
|
767
827
|
|
|
828
|
+
/**
|
|
829
|
+
* A custom chart's named drill-down that can never open (`custom_chart_drill_unreachable`, advisory).
|
|
830
|
+
* The FE skips one without a details form as if it were absent, and opens a NAMED one only when its
|
|
831
|
+
* entity is the drilled target's — the source's, or the measure's own (custom/customDrill.ts
|
|
832
|
+
* `pickDrillDown`, 'entityMismatch'); `chart.drill('<name>')` then answers false with a toast. A SQL
|
|
833
|
+
* source names no entity, so its drill opens the drill-down's own entity — any entity is reachable
|
|
834
|
+
* while the chart has one. An element whose sources and drill-downs both echo the baseline is the
|
|
835
|
+
* person's own config and is not re-reported.
|
|
836
|
+
*/
|
|
837
|
+
function customChartDrills(schema, baselineById, presentation = "schema") {
|
|
838
|
+
const out = [];
|
|
839
|
+
const where = presentation === "mobileSchema" ? "mobileSchema — " : "";
|
|
840
|
+
for (const el of Array.isArray(schema) ? schema : []) {
|
|
841
|
+
if (!el || typeof el !== "object" || el.type !== "chart" || el.chartType !== "custom") continue;
|
|
842
|
+
const map = el.drillDowns;
|
|
843
|
+
if (!map || typeof map !== "object" || Array.isArray(map)) continue;
|
|
844
|
+
const base = el.id !== undefined ? baselineById.get(el.id) : undefined;
|
|
845
|
+
if (base && sameValue(base.drillDowns, el.drillDowns) && sameValue(base.dataSources, el.dataSources)) continue;
|
|
846
|
+
const sources = namedSourcesOf(el);
|
|
847
|
+
const anySql = sources.some(([, src]) => isSqlNamedSource(src));
|
|
848
|
+
const counted = new Set();
|
|
849
|
+
for (const [, src] of sources) {
|
|
850
|
+
if (isSqlNamedSource(src)) continue;
|
|
851
|
+
if (filled(src.entity)) counted.add(src.entity);
|
|
852
|
+
for (const v of Array.isArray(src.values) ? src.values : []) if (v && typeof v === "object" && filled(v.entity)) counted.add(v.entity);
|
|
853
|
+
}
|
|
854
|
+
for (const [name, drill] of Object.entries(map)) {
|
|
855
|
+
if (!drill || typeof drill !== "object" || Array.isArray(drill)) continue;
|
|
856
|
+
let problem = null;
|
|
857
|
+
if (typeof drill.formId !== "number") {
|
|
858
|
+
problem = "has no details form (`formId`) — the FE skips a drill-down without one as if it were absent";
|
|
859
|
+
} else if (!filled(drill.entity)) {
|
|
860
|
+
problem = "names no `entity`";
|
|
861
|
+
} else if (!anySql && !counted.has(drill.entity)) {
|
|
862
|
+
problem =
|
|
863
|
+
`opens ${drill.entity}, but no source of this chart counts ${drill.entity} (they count ` +
|
|
864
|
+
`${counted.size ? [...counted].join(", ") : "nothing yet"}) — a named drill-down opens only the drilled source's entity`;
|
|
865
|
+
}
|
|
866
|
+
if (!problem) continue;
|
|
867
|
+
out.push({
|
|
868
|
+
code: "custom_chart_drill_unreachable",
|
|
869
|
+
elementId: el.id ?? el.name,
|
|
870
|
+
detail: `${where}drill-down '${name}' ${problem}, so \`chart.drill('${name}')\` answers false with a toast and opens nothing (FE custom/customDrill.ts pickDrillDown).`,
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
return out;
|
|
875
|
+
}
|
|
876
|
+
|
|
768
877
|
/**
|
|
769
878
|
* A table whose source can never run shows animated skeleton rows FOREVER — a table has no datasource
|
|
770
879
|
* error state. Mirrors the FE (platform-front-redesind e4b28b0792): `suppaSql` runs only with a
|
|
@@ -905,6 +1014,27 @@ export async function validateForm(input, { baseline = null, normalize = false }
|
|
|
905
1014
|
}
|
|
906
1015
|
}
|
|
907
1016
|
|
|
1017
|
+
// The baseline matched by id across BOTH presentations: an id is unique across them
|
|
1018
|
+
// (crossPresentationIds), so one map serves both.
|
|
1019
|
+
const baselineById = new Map();
|
|
1020
|
+
for (const list of [baseDraft && baseDraft.schema, baseDraft && baseDraft.mobileSchema]) {
|
|
1021
|
+
for (const e of Array.isArray(list) ? list : []) {
|
|
1022
|
+
if (e && typeof e === "object" && e.id !== undefined) baselineById.set(e.id, e);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
// WIDGET CODE. Compiled before the core runs, so the draft it checks — and the one returned to the
|
|
1027
|
+
// writer — carries the render the runtime will execute (widget-code.mjs). Not a --normalize step:
|
|
1028
|
+
// a compiledRender this gate did not compile is never handed on, repaired or not.
|
|
1029
|
+
const widgets = await checkWidgets(draft.schema, baselineById);
|
|
1030
|
+
const mobileWidgets = await checkWidgets(draft.mobileSchema, baselineById, "mobileSchema");
|
|
1031
|
+
draft = {
|
|
1032
|
+
...draft,
|
|
1033
|
+
schema: widgets.schema,
|
|
1034
|
+
...(Array.isArray(draft.mobileSchema) ? { mobileSchema: mobileWidgets.schema } : {}),
|
|
1035
|
+
};
|
|
1036
|
+
notes.push(...widgets.notes, ...mobileWidgets.notes);
|
|
1037
|
+
|
|
908
1038
|
// The downgrade is keyed on element `id`. An element without one cannot be matched to its twin in
|
|
909
1039
|
// the baseline, so a caller who passed a baseline and stripped the ids gets no downgrade at all —
|
|
910
1040
|
// silently, which is the failure mode this gate exists to refuse. Measured: the same element with
|
|
@@ -1027,14 +1157,7 @@ export async function validateForm(input, { baseline = null, normalize = false }
|
|
|
1027
1157
|
for (const w of kitWarnings) notes.push(`kit: ${w.code} — ${w.detail}`);
|
|
1028
1158
|
}
|
|
1029
1159
|
|
|
1030
|
-
// Charts that will render demo data.
|
|
1031
|
-
// is unique across them (crossPresentationIds), so one map serves both.
|
|
1032
|
-
const baselineById = new Map();
|
|
1033
|
-
for (const list of [baseDraft && baseDraft.schema, baseDraft && baseDraft.mobileSchema]) {
|
|
1034
|
-
for (const e of Array.isArray(list) ? list : []) {
|
|
1035
|
-
if (e && typeof e === "object" && e.id !== undefined) baselineById.set(e.id, e);
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1160
|
+
// Charts that will render demo data.
|
|
1038
1161
|
const charts = chartReadiness(draft.schema, baselineById);
|
|
1039
1162
|
const mobileCharts = chartReadiness(draft.mobileSchema, baselineById, "mobileSchema");
|
|
1040
1163
|
const tables = tableReadiness(draft.schema, baselineById);
|
|
@@ -1044,6 +1167,8 @@ export async function validateForm(input, { baseline = null, normalize = false }
|
|
|
1044
1167
|
// on the FINAL draft, so `--normalize` gets credit for what it actually repairs (it backfills
|
|
1045
1168
|
// missing breakpoint records) and none for what it does not.
|
|
1046
1169
|
const docErrors = [
|
|
1170
|
+
...widgets.errors,
|
|
1171
|
+
...mobileWidgets.errors,
|
|
1047
1172
|
...charts.errors,
|
|
1048
1173
|
...mobileCharts.errors,
|
|
1049
1174
|
...tables.errors,
|
|
@@ -1063,6 +1188,10 @@ export async function validateForm(input, { baseline = null, normalize = false }
|
|
|
1063
1188
|
...connectionsWithoutId(draft.connections),
|
|
1064
1189
|
];
|
|
1065
1190
|
const docWarnings = [
|
|
1191
|
+
...widgets.warnings,
|
|
1192
|
+
...mobileWidgets.warnings,
|
|
1193
|
+
...customChartDrills(draft.schema, baselineById),
|
|
1194
|
+
...customChartDrills(draft.mobileSchema, baselineById, "mobileSchema"),
|
|
1066
1195
|
...charts.warnings,
|
|
1067
1196
|
...mobileCharts.warnings,
|
|
1068
1197
|
...tables.warnings,
|
|
@@ -1084,6 +1213,9 @@ export async function validateForm(input, { baseline = null, normalize = false }
|
|
|
1084
1213
|
// The draft AS CHECKED — normalized envelope, and repaired when --normalize ran. A writer must
|
|
1085
1214
|
// save what was verified, not what was handed in; returning it is how the two stay the same.
|
|
1086
1215
|
draft,
|
|
1216
|
+
// Every widget render the gate replaced in `draft`. A caller that writes `draft` needs nothing
|
|
1217
|
+
// from this; one that freezes a STORED draft (publish) learns the stored render is not the one.
|
|
1218
|
+
compiled_widgets: [...widgets.compiled, ...mobileWidgets.compiled],
|
|
1087
1219
|
source: sourceStamp(),
|
|
1088
1220
|
};
|
|
1089
1221
|
}
|