suppa-mcp-2 1.43.4 → 1.44.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.
@@ -0,0 +1,207 @@
1
+ // Finds what makes an automation wrong at runtime, hard to read, or heavier than it needs to be.
2
+ // usage: node lint-graph.mjs <graph.json> [--previous published.json]
3
+ // graph.json: the stored { nodes, connections, settings? } or a suppa_get_automation answer as is (its draft side).
4
+ // --previous: the graph that is published now (a suppa_get_automation answer: its `published` side) — names approval
5
+ // nodes the new graph drops, which strands waiting runs.
6
+ // Prints ERROR / WARN / NOTE lines; exits 1 when there is an ERROR.
7
+ import fs from 'node:fs';
8
+ import { fileURLToPath } from 'node:url';
9
+ import { readGraph } from './graph.mjs';
10
+
11
+ const TRIGGERS = new Set(['formSubmission', 'triggerEntity', 'triggerWebhook', 'triggerSchedule', 'triggerManual']);
12
+ const STEP_NAME = /^(?:([A-Z])(?=\d))?(\d+)((?:\.\d+)*)(\.?)\s+\S/;
13
+ const REF = /\$\('([^']*)'\)/g;
14
+ const QUOTED_STEP = /«((?:[A-Z])?\d+(?:\.\d+)*\.?\s[^»]+)»/g;
15
+
16
+ export const lint = (graph, { previous } = {}) => {
17
+ const { nodes, connections = {} } = graph;
18
+ const out = [];
19
+ const seen = new Set();
20
+ const add = (level, msg) => { if (!seen.has(msg)) { seen.add(msg); out.push({ level, msg }); } };
21
+ const by = Object.fromEntries(nodes.map((n) => [n.id, n]));
22
+ const byName = Object.fromEntries(nodes.map((n) => [n.name, n]));
23
+
24
+ // --- edges and handles
25
+ const succ = Object.fromEntries(nodes.map((n) => [n.id, []]));
26
+ const pred = Object.fromEntries(nodes.map((n) => [n.id, []]));
27
+ const validHandles = (n) => {
28
+ const err = n.onError === 'continueErrorOutput' ? ['error'] : [];
29
+ if (n.type === 'if') return ['true', 'false', ...err];
30
+ if (n.type === 'approval') return ['approved', 'rejected', ...err];
31
+ if (n.type === 'switch') return [...(n.parameters?.rules || []).map((r) => r.output), ...(n.parameters?.fallbackEnabled ? ['fallback'] : []), ...err];
32
+ return ['main', ...err];
33
+ };
34
+ for (const [from, handles] of Object.entries(connections)) {
35
+ if (!by[from]) { add('ERROR', `connections from unknown node ${from}`); continue; }
36
+ for (const [h, targets] of Object.entries(handles)) {
37
+ if (!validHandles(by[from]).includes(h)) add('ERROR', `${from}: output "${h}" does not exist on a ${by[from].type} (has ${validHandles(by[from]).join(', ')})`);
38
+ for (const t of targets) {
39
+ if (!by[t.node]) { add('ERROR', `${from} → unknown node ${t.node}`); continue; }
40
+ succ[from].push({ to: t.node, handle: h, index: t.index ?? 0 });
41
+ pred[t.node].push({ from, handle: h });
42
+ }
43
+ }
44
+ }
45
+
46
+ // --- reachability and flows
47
+ const triggers = nodes.filter((n) => TRIGGERS.has(n.type));
48
+ if (!triggers.length) add('ERROR', 'no trigger node');
49
+ const flowOf = {};
50
+ for (const t of triggers) {
51
+ const stack = [t.id];
52
+ while (stack.length) {
53
+ const id = stack.pop();
54
+ (flowOf[id] ??= new Set()).add(t.id);
55
+ for (const s of succ[id]) if (!flowOf[s.to]?.has(t.id)) stack.push(s.to);
56
+ }
57
+ }
58
+ for (const n of nodes) if (!flowOf[n.id]) add('ERROR', `${n.id} is not reachable from any trigger`);
59
+ for (const n of nodes) if (TRIGGERS.has(n.type) && pred[n.id].length) add('ERROR', `trigger ${n.id} has incoming edges`);
60
+
61
+ const ancestors = (id) => {
62
+ const seen = new Set();
63
+ const stack = [id];
64
+ while (stack.length) for (const p of pred[stack.pop()]) if (!seen.has(p.from)) { seen.add(p.from); stack.push(p.from); }
65
+ return seen;
66
+ };
67
+
68
+ // --- ids and names
69
+ const multiFlow = triggers.length > 1;
70
+ const seenNames = new Map();
71
+ for (const n of nodes) {
72
+ if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(n.id)) add('WARN', `id "${n.id}": use readable kebab-case (create-task), connections are read by id`);
73
+ if (seenNames.has(n.name)) add('ERROR', `name "${n.name}" is used by ${seenNames.get(n.name)} and ${n.id}: $('…') would be ambiguous`);
74
+ seenNames.set(n.name, n.id);
75
+ if (n.name.includes("'")) add('ERROR', `${n.id}: ASCII apostrophe in the name breaks $('…') — use ʼ`);
76
+ if (/[Ѐ-ӿ]/.test(n.name)) add('WARN', `${n.id}: node names are English ("${n.name}")`);
77
+ const m = STEP_NAME.exec(n.name);
78
+ if (!m) add('WARN', `${n.id}: name "${n.name}" has no step number (A4. Create task / A5.1 Wait for head approval)`);
79
+ else if (multiFlow && !m[1]) add('WARN', `${n.id}: several flows — prefix the step with the flow letter (A…, B…)`);
80
+ else if (multiFlow && m[1] && flowOf[n.id]?.size === 1) {
81
+ const trig = by[[...flowOf[n.id]][0]];
82
+ const letter = STEP_NAME.exec(trig.name)?.[1];
83
+ if (letter && letter !== m[1]) add('WARN', `${n.id}: belongs to flow ${letter} (trigger ${trig.id}) but is named ${m[1]}…`);
84
+ }
85
+ }
86
+
87
+ // --- expressions: a node may only read nodes that ran before it
88
+ for (const n of nodes) {
89
+ const text = JSON.stringify(n.parameters ?? {});
90
+ const anc = ancestors(n.id);
91
+ for (const [, ref] of text.matchAll(REF)) {
92
+ const target = byName[ref];
93
+ if (!target) add('ERROR', `${n.id}: $('${ref}') names no node`);
94
+ else if (!anc.has(target.id)) add('ERROR', `${n.id}: $('${ref}') is not upstream of this node — it is undefined at runtime`);
95
+ }
96
+ for (const [, ref] of text.matchAll(QUOTED_STEP)) if (!byName[ref]) add('WARN', `${n.id}: comment or text mentions «${ref}», which is no node name (stale after a rename?)`);
97
+ if (n.type === 'code' && /\$\('/.test(n.parameters?.code ?? '')) add('ERROR', `${n.id}: a code node has no $() — feed it through a set node`);
98
+ }
99
+
100
+ // --- node-specific checks
101
+ for (const n of nodes) {
102
+ const p = n.parameters ?? {};
103
+ const outs = succ[n.id];
104
+ const has = (h) => outs.some((e) => e.handle === h);
105
+ if (n.type === 'approval') {
106
+ if (Array.isArray(p.approvers) && !p.approvers.length) add('ERROR', `${n.id}: approvers is [] (the builder UI wipes expression approvers — rebuild from source)`);
107
+ if (!has('rejected')) add('NOTE', `${n.id}: a rejection ends the run here — intended?`);
108
+ if (!has('approved')) add('NOTE', `${n.id}: an approval ends the run here — intended?`);
109
+ }
110
+ if (n.type === 'if' && (!has('true') || !has('false'))) add('NOTE', `${n.id}: ${has('true') ? 'false ends' : has('false') ? 'true ends' : 'true and false end'} the run — intended?`);
111
+ if (n.type === 'switch') for (const r of p.rules || []) if (!has(r.output)) add('NOTE', `${n.id}: output "${r.output}" is not connected`);
112
+ if (n.type === 'switch') for (const r of p.rules || []) if (/^\d+$/.test(r.output) || /^[a-z]+[A-Z]/.test(r.output)) add('NOTE', `${n.id}: output "${r.output}" — name outputs by the business case (equipment, 1c-rights), they label the lines on the canvas`);
113
+ if (n.type === 'suppa' && p.action === 'select') {
114
+ if (p.limit == null) add('WARN', `${n.id}: select without limit`);
115
+ if (!p.fields) add('WARN', `${n.id}: select without fields loads whole rows`);
116
+ if (!pred[n.id].some((e) => by[e.from].type === 'if') && !outs.some((e) => by[e.to].type === 'merge')) add('NOTE', `${n.id}: 0 rows ends the branch — guard with an if, or fan out to a merge, unless stopping is intended`);
117
+ }
118
+ // Request / form flows: the formSubmission trigger already emits the submission row.
119
+ const formFlow = [...(flowOf[n.id] ?? [])].some((t) => by[t].type === 'formSubmission');
120
+ if (formFlow && n.type === 'suppa' && (p.action === 'getById' || p.action === 'select')) {
121
+ const text = JSON.stringify(p);
122
+ const fieldKeys = Object.keys(p.fields ?? {});
123
+ if (p.entityName === 'FormSubmissions') add('WARN', `${n.id}: re-reads FormSubmissions — the formSubmission trigger already emits the request row (formData, number, requestType, createdBy)`);
124
+ else if (p.entityName === 'Users' && /createdBy/.test(text) && fieldKeys.length && fieldKeys.every((k) => k === 'id' || k === 'fullName')) add('WARN', `${n.id}: reads the submitter's id / fullName — the trigger's createdBy already carries both`);
125
+ else if (/formData/.test(text) && fieldKeys.length && fieldKeys.every((k) => k === 'id')) add('WARN', `${n.id}: reads only id of a record picked in the form — formData already has { id }`);
126
+ }
127
+ if (n.type === 'suppa' && p.entityName === 'AutomationWorkflow' && p.action === 'getById' && !/\$workflow\.id/.test(String(p.id))) add('WARN', `${n.id}: reads another automation's settings by literal id — keep settings in this automation ($workflow.id)`);
128
+ if (n.type === 'triggerEntity') {
129
+ const upd = (p.events || []).some((e) => /update/.test(e));
130
+ if (upd && !(p.watchFields || []).length) add('WARN', `${n.id}: update trigger without watchFields starts a run on every edit`);
131
+ if (!p.conditions || !(p.conditions.filters || []).length) add('WARN', `${n.id}: no conditions — every record of ${p.entityName} starts a run; filter in the trigger`);
132
+ }
133
+ // A set whose every value is a bare reference only reshapes data; one that computes (a rule set:
134
+ // comparisons, ternaries, defaults) is a visible business rule and earns its node.
135
+ const reshapesOnly = (s) => (s.parameters?.assignments || []).every((a) => /^=\{\{\s*(\$json|\$\('[^']*'\)\.(first|item)\(\)\.json)(\??\.[\w$]+)*\s*\}\}$/.test(String(a.value)));
136
+ if (n.type === 'set' && pred[n.id].length === 1 && reshapesOnly(n)) {
137
+ const feedsCode = outs.some((e) => by[e.to].type === 'code' || (by[e.to].type === 'merge' && succ[e.to].some((x) => by[x.to].type === 'code')));
138
+ if (!feedsCode) add('WARN', `${n.id}: a set that feeds no code node only reshapes data — let the next nodes read $('…') directly (a set with several inputs, a join point, is fine)`);
139
+ if (outs.some((e) => by[e.to].type === 'set')) add('WARN', `${n.id}: set → set — fold them into one`);
140
+ }
141
+ if (n.type === 'suppa' && p.action === 'updateById') for (const e of outs) {
142
+ const q = by[e.to].parameters ?? {};
143
+ if (by[e.to].type === 'suppa' && q.action === 'updateById' && q.entityName === p.entityName && String(q.id) === String(p.id)) add('WARN', `${n.id} → ${e.to}: two updates of the same ${p.entityName} record in a row — merge them into one write`);
144
+ }
145
+ }
146
+
147
+ // --- one read per entity per flow: reads of one entity on the same path are one query split in parts,
148
+ // unless a later read needs the earlier one's result (a task, then its parent) — exclusive branches never pair.
149
+ const isRead = (n) => n.type === 'suppa' && (n.parameters?.action === 'getById' || n.parameters?.action === 'select') && n.parameters?.entityName;
150
+ for (const t of triggers) {
151
+ const groups = {};
152
+ for (const n of nodes) if (flowOf[n.id]?.has(t.id) && isRead(n)) (groups[n.parameters.entityName] ??= []).push(n);
153
+ for (const [entity, list] of Object.entries(groups)) {
154
+ if (list.length < 2) continue;
155
+ const anc = Object.fromEntries(list.map((n) => [n.id, ancestors(n.id)]));
156
+ const needs = (b, a) => JSON.stringify(b.parameters).includes(`$('${a.name}')`);
157
+ const split = new Set();
158
+ for (const a of list) for (const b of list) if (a !== b && anc[b.id].has(a.id) && !needs(b, a)) { split.add(a.id); split.add(b.id); }
159
+ if (split.size >= 2) add('WARN', `flow of ${t.id}: ${split.size} reads of ${entity} (${[...split].join(', ')}) — fold into one query: one getById with nested fields, or one select with id in [...] and rows picked by id`);
160
+ }
161
+ }
162
+
163
+ // --- safe runs and data in expressions
164
+ const TITLE_COMPARE = /\.title\??\s*(?:===|!==|==|!=)|\.title\??\.(?:startsWith|endsWith|includes|indexOf)\(/;
165
+ const FIXED_OFFSET = /T\d{2}:\d{2}(?::\d{2})?[+-]\d{2}:\d{2}/;
166
+ const BARE_ID = /^=\{\{[^{}[\]]*(?:\.id|Id)\s*\}\}$/;
167
+ for (const n of nodes) {
168
+ const p = n.parameters ?? {};
169
+ const text = n.type === 'code' ? String(p.code ?? '') : JSON.stringify(p);
170
+ if (TITLE_COMPARE.test(text)) add('WARN', `${n.id}: compares a title — titles are localized and may be null; compare value / id / code`);
171
+ if (FIXED_OFFSET.test(text)) add('WARN', `${n.id}: a datetime with a fixed UTC offset — wrong for half the year; compute it with references/tenant-time.md`);
172
+ if (n.type === 'code' && /return\s*\[\s*\]/.test(text) && /settings|cfg|config/i.test(text) && !/\bthrow\b/.test(text)) add('NOTE', `${n.id}: returns [] and never throws — if that [] means a missing setting, throw 'Not configured: …' so the run fails visibly`);
173
+ if (n.type === 'suppa' && (p.action === 'insert' || p.action === 'updateById')) {
174
+ for (const [k, v] of Object.entries(p.fields ?? {})) if (typeof v === 'string' && BARE_ID.test(v.trim())) add('WARN', `${n.id}: field ${k} gets a bare id — a relation is written as { id } (a bare id stores null); a plain number field can ignore this`);
175
+ }
176
+ if (n.type === 'notification') for (const key of ['subjectTemplate', 'bodyTemplate']) {
177
+ const t = p[key];
178
+ if (t && typeof t === 'object' && !('uk' in t)) add('WARN', `${n.id}: ${key} has no uk — notifications carry the users' language next to en`);
179
+ }
180
+ }
181
+ if (previous) {
182
+ const now = new Set(nodes.map((n) => n.id));
183
+ for (const n of previous.nodes ?? []) if (n.type === 'approval' && !now.has(n.id)) add('WARN', `approval ${n.id} («${n.name}») is published now and missing from the new graph — runs waiting there cannot continue; keep its id, or check status:"waiting" runs before publishing`);
184
+ }
185
+
186
+ // --- size
187
+ for (const t of triggers) {
188
+ const members = nodes.filter((n) => flowOf[n.id]?.has(t.id));
189
+ if (members.length > 25) add('NOTE', `flow of ${t.id}: ${members.length} nodes — over ~25, check each node earns its place`);
190
+ const cols = new Set(members.filter((n) => n.position).map((n) => Math.round(n.position.x / 340)));
191
+ if (cols.size > 20) add('NOTE', `flow of ${t.id}: ${cols.size} columns wide — over ~20 the canvas no longer reads at a glance`);
192
+ }
193
+ return out;
194
+ };
195
+
196
+ if (process.argv[1] && fs.realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) {
197
+ const args = process.argv.slice(2);
198
+ const prevAt = args.indexOf('--previous');
199
+ const previous = prevAt >= 0 ? readGraph(args[prevAt + 1], { side: 'published' }) : undefined;
200
+ const res = lint(readGraph(args[0]), { previous });
201
+ const order = { ERROR: 0, WARN: 1, NOTE: 2 };
202
+ res.sort((a, b) => order[a.level] - order[b.level]);
203
+ for (const r of res) console.log(`${r.level.padEnd(5)} ${r.msg}`);
204
+ const count = (l) => res.filter((r) => r.level === l).length;
205
+ console.log(`\n${count('ERROR')} errors, ${count('WARN')} warnings, ${count('NOTE')} notes`);
206
+ process.exit(count('ERROR') ? 1 : 0);
207
+ }
@@ -0,0 +1,77 @@
1
+ // Draws the canvas the way the builder will (same node geometry, step lines, handle colours) so the layout
2
+ // can be reviewed before publishing — without opening the builder, which autosaves its own copy.
3
+ // usage: node render-graph.mjs <graph.json> <out.svg> [--png out.png] [--width 2400]
4
+ // graph.json: the stored shape or a suppa_get_automation answer.
5
+ // --png renders through headless Chrome / Chromium / Edge (macOS, Linux, Windows), falling back to macOS Quick Look;
6
+ // with none of them it says so and exits 2 — the SVG is written either way.
7
+ import fs from 'node:fs';
8
+ import path from 'node:path';
9
+ import { execFileSync } from 'node:child_process';
10
+ import { fileURLToPath, pathToFileURL } from 'node:url';
11
+ import { MAX_WIDTH, height, inOffset, outOffset } from './geometry.mjs';
12
+ import { edges } from './edges.mjs';
13
+ import { readGraph } from './graph.mjs';
14
+
15
+ const FILL = { formSubmission: '#e0f2fe', triggerEntity: '#e0f2fe', triggerWebhook: '#e0f2fe', triggerSchedule: '#e0f2fe', triggerManual: '#e0f2fe', suppa: '#eef2ff', set: '#f3e8ff', code: '#dcfce7', if: '#fef3c7', switch: '#fef3c7', approval: '#ffe4e6', merge: '#f1f5f9', notification: '#fae8ff' };
16
+ const LINE = (h) => (h === 'false' || h === 'rejected' ? '#ef4444' : h === 'true' || h === 'approved' ? '#16a34a' : h === 'error' ? '#f97316' : '#94a3b8');
17
+ const esc = (s) => String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
18
+ const fit = (s, px) => { const max = Math.floor(px / 6.4); return s.length > max ? s.slice(0, max - 1) + '…' : s; };
19
+ const outputs = (n) => (n.type === 'if' ? ['true', 'false'] : n.type === 'approval' ? ['approved', 'rejected'] : n.type === 'switch' ? (n.parameters?.rules || []).map((r) => r.output) : []);
20
+
21
+ export const renderSvg = (graph, width = 2400) => {
22
+ const { nodes } = graph;
23
+ const xs = nodes.flatMap((n) => [n.position.x, n.position.x + MAX_WIDTH]);
24
+ const ys = nodes.flatMap((n) => [n.position.y, n.position.y + height(n)]);
25
+ const pad = 60;
26
+ const minX = Math.min(...xs) - pad, minY = Math.min(...ys) - pad;
27
+ const W = Math.max(...xs) + pad - minX, H = Math.max(...ys) + pad - minY;
28
+ const parts = [];
29
+ for (const e of edges(graph)) {
30
+ const mx = (e.sx + e.tx) / 2;
31
+ parts.push(`<path d="M${e.sx} ${e.sy} H${mx} V${e.ty} H${e.tx}" fill="none" stroke="${LINE(e.handle)}" stroke-width="2"/>`);
32
+ }
33
+ for (const n of nodes) {
34
+ const { x, y } = n.position, h = height(n);
35
+ parts.push(`<rect x="${x}" y="${y}" width="${MAX_WIDTH}" height="${h}" rx="8" fill="${FILL[n.type] ?? '#ffffff'}" stroke="#94a3b8" stroke-width="1.5"/>`);
36
+ parts.push(`<text x="${x + 12}" y="${y + 20}" font-family="Helvetica, Arial, sans-serif" font-size="13" font-weight="600" fill="#1e293b">${esc(fit(n.name, MAX_WIDTH - 24))}</text>`);
37
+ parts.push(`<text x="${x + 12}" y="${y + 37}" font-family="Helvetica, Arial, sans-serif" font-size="10" fill="#64748b">${esc(n.type)}${n.parameters?.action ? ' · ' + esc(n.parameters.action) : ''}${n.parameters?.entityName ? ' · ' + esc(n.parameters.entityName) : ''}</text>`);
38
+ if (!/^(formSubmission|trigger)/.test(n.type)) parts.push(`<circle cx="${x}" cy="${y + inOffset(n)}" r="4" fill="#fff" stroke="#64748b"/>`);
39
+ const outs = outputs(n);
40
+ if (outs.length) for (const o of outs) {
41
+ const oy = y + outOffset(n, o);
42
+ parts.push(`<text x="${x + MAX_WIDTH - 12}" y="${oy + 3}" text-anchor="end" font-family="Helvetica, Arial, sans-serif" font-size="9" fill="${LINE(o)}">${esc(o)}</text>`);
43
+ parts.push(`<circle cx="${x + MAX_WIDTH - 16}" cy="${oy}" r="4" fill="#fff" stroke="${LINE(o)}"/>`);
44
+ } else parts.push(`<circle cx="${x + MAX_WIDTH - 16}" cy="${y + outOffset(n, 'main')}" r="4" fill="#fff" stroke="#64748b"/>`);
45
+ }
46
+ const outH = Math.round((width * H) / W);
47
+ return { svg: `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${outH}" viewBox="${minX} ${minY} ${W} ${H}"><rect x="${minX}" y="${minY}" width="${W}" height="${H}" fill="#f8fafc"/>${parts.join('')}</svg>`, width, height: outH };
48
+ };
49
+
50
+ // Where a headless-capable browser lives on each OS; Edge ships with every Windows.
51
+ export const browserCandidates = (env = process.env) => [
52
+ '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',
53
+ ...[env.PROGRAMFILES, env['PROGRAMFILES(X86)'], env.LOCALAPPDATA].filter(Boolean).flatMap((dir) => [
54
+ path.join(dir, 'Google', 'Chrome', 'Application', 'chrome.exe'),
55
+ path.join(dir, 'Microsoft', 'Edge', 'Application', 'msedge.exe'),
56
+ ]),
57
+ ];
58
+
59
+ if (process.argv[1] && fs.realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) {
60
+ const [graphFile, svgFile, ...rest] = process.argv.slice(2);
61
+ if (!graphFile || !svgFile) { console.error('usage: node render-graph.mjs <graph.json> <out.svg> [--png out.png] [--width 2400]'); process.exit(2); }
62
+ const opt = (k) => { const i = rest.indexOf(`--${k}`); return i >= 0 ? rest[i + 1] : undefined; };
63
+ const { svg, width, height: h } = renderSvg(readGraph(graphFile), Number(opt('width') ?? 2400));
64
+ fs.writeFileSync(svgFile, svg);
65
+ console.log(`svg ${svgFile} (${width}×${h})`);
66
+ const png = opt('png');
67
+ if (png) {
68
+ const bin = browserCandidates().find((p) => fs.existsSync(p));
69
+ const abs = path.resolve(svgFile);
70
+ const out = path.resolve(png);
71
+ if (bin) execFileSync(bin, ['--headless=new', '--disable-gpu', '--hide-scrollbars', `--window-size=${width},${h}`, `--screenshot=${out}`, pathToFileURL(abs).href], { stdio: 'ignore' });
72
+ else if (process.platform === 'darwin') { execFileSync('qlmanage', ['-t', '-s', String(width), '-o', path.dirname(out), abs], { stdio: 'ignore' }); fs.renameSync(path.join(path.dirname(out), path.basename(abs) + '.png'), out); }
73
+ else { console.error(`no Chrome, Chromium or Edge found for --png — open ${svgFile} in a browser instead`); process.exit(2); }
74
+ if (!fs.existsSync(out)) { console.error(`the browser wrote no ${png}`); process.exit(1); }
75
+ console.log(`png ${png}`);
76
+ }
77
+ }
@@ -230,14 +230,19 @@ export function normalizeEnvelope(input) {
230
230
  // is not optional.
231
231
  // An EMPTY `overrides` array does not make a child: measured on dev, 3 parentless forms carry
232
232
  // `schema.overrides: []` while 12 of the 16 real children carry a populated one. Only a declared
233
- // parent, or overrides with something in them, is evidence.
233
+ // parent, or overrides with something in them, is evidence — and a parent counts only as a REAL reference: a
234
+ // positive id, or an object holding one. `parentForm: {}` / `{ id: null }` / `0` / `"none"` declared nothing, and
235
+ // taking them for a parent let an empty layer through (review of 1.43.4).
236
+ const isRef = (v) =>
237
+ (Number.isInteger(v) && v > 0) ||
238
+ (v !== null && typeof v === "object" && !Array.isArray(v) && Number.isInteger(v.id) && v.id > 0);
234
239
  const childForm = Boolean(
235
240
  (Array.isArray(overrides) && overrides.length) ||
236
241
  (col && Array.isArray(col.overrides) && col.overrides.length) ||
237
- (input.parent !== undefined && input.parent !== null) ||
242
+ isRef(input.parent) ||
238
243
  // suppa_get_form names the parent `parentForm`, as GET /core/forms/:id/schema does
239
- (input.parentForm !== undefined && input.parentForm !== null) ||
240
- (input.parentVersion !== undefined && input.parentVersion !== null),
244
+ isRef(input.parentForm) ||
245
+ isRef(input.parentVersion),
241
246
  );
242
247
 
243
248
  if (!schema && emptyAt.length && !childForm) {