suppa-mcp-2 1.39.0 → 1.40.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -1204,15 +1204,19 @@ export function buildToolTable() {
1204
1204
  .default(null)
1205
1205
  .describe('Field options as a JSON object, e.g. {"searchable": true, "searchPriority": 3}. ' +
1206
1206
  "Keys: searchable, searchPriority (1-4, higher = stronger weight), readOnly, " +
1207
- "canGroup, canSort, showInTable, editFromTable, canFilter. Pass ONLY the ones " +
1208
- "that differ from the defaults the platform already applies — canGroup, canSort, " +
1209
- "showInTable, editFromTable and canFilter are true; readOnly and searchable are " +
1210
- "false (verified on a live tenant 2026-08-17; the Field Options table in " +
1211
- "builder.txt:66-73 lists them as false, which the platform contradicts). So the " +
1212
- "one usually worth passing is searchable (+searchPriority): free-text search " +
1213
- "(suppa_search_records search=...) only covers fields marked searchable. " +
1214
- "Restating a default changes nothing and buries the option that does. Unknown " +
1215
- "keys are refused here (the platform would silently drop them)."),
1207
+ "canGroup, canSort, showInTable, editFromTable, canFilter. The one usually worth " +
1208
+ "passing is searchable (+searchPriority): free-text search " +
1209
+ "(suppa_search_records search=...) only covers fields marked searchable; " +
1210
+ "readOnly and searchable default to false. THE FIVE DISPLAY FLAGS ARE " +
1211
+ "UNSETTLED: reading a field back on a live tenant shows canGroup, canSort, " +
1212
+ "showInTable, editFromTable and canFilter as true (2026-08-17), but the " +
1213
+ "platform's own docs say the backend never defaults them and every consumer " +
1214
+ "reads an absent key as FALSE — which is how agent-created fields ended up " +
1215
+ "non-groupable, unsortable and hidden from tables. The stored shape does look " +
1216
+ "sparse: of 70 Tasks fields, 15 carry no options object at all. So if the new " +
1217
+ "field MUST be visible and sortable, pass the five explicitly rather than " +
1218
+ "trusting a default — it costs nothing — and read the field back afterwards. " +
1219
+ "Unknown keys are refused here (the platform would silently drop them)."),
1216
1220
  max_length: z
1217
1221
  .number()
1218
1222
  .int()
@@ -70,10 +70,20 @@ export const RELATION_LIKE_FIELD_TYPES = [
70
70
  "file",
71
71
  "multi-file",
72
72
  ];
73
- // Where `defaultValue` does NOT apply. builder.txt:43 — "defaultValue | string |
74
- // false | Default value. Not applicable to relations, enums, or unique fields."
75
- // So: every relation-like type above, plus ANY type when unique is set.
76
- export const NO_DEFAULT_VALUE_FIELD_TYPES = RELATION_LIKE_FIELD_TYPES;
73
+ // Types where `notNull` does NOT drag a `defaultValue` requirement with it. builder.txt:43
74
+ // reads "Not applicable to relations, enums, or unique fields", and that is true of the
75
+ // REQUIREMENT: measured, the builder answers 400 "`defaultValue` is required when creating a
76
+ // field with `notNull: true`" for the other types and accepts `notNull` alone for these.
77
+ //
78
+ // It is NOT true that these types cannot HOLD a default — we read that line too broadly and
79
+ // silently deleted a caller's default on update-field. Two live fields on the dev tenant say
80
+ // otherwise: `Tasks.priority` (enum) carries `defaultValue: 1557` (an Enums row id) and
81
+ // `Tasks.createdBy` (many-to-one) carries `"$current-user"`. The platform's Entity Builder doc
82
+ // gives the wire shape for the very endpoints these tools call: a REFERENCE — `{ id }`, or
83
+ // `[{ id }, …]` for a multi — "on add-fields, update-field and create-entity's columns".
84
+ export const NO_DEFAULT_REQUIRED_FIELD_TYPES = RELATION_LIKE_FIELD_TYPES;
85
+ /** @deprecated the old name, kept so nothing silently reads a list that changed meaning. */
86
+ export const NO_DEFAULT_VALUE_FIELD_TYPES = NO_DEFAULT_REQUIRED_FIELD_TYPES;
77
87
  // Where `notNull` does NOT apply — its own, narrower exclusion. builder.txt:41 —
78
88
  // "notNull | boolean | false | Field is required. Not applicable to many-to-many
79
89
  // / multi-enum." The comment above used to claim this exclusion was honoured
@@ -85,16 +95,28 @@ export function notNullApplies(fieldType) {
85
95
  return !NO_NOT_NULL_FIELD_TYPES.includes(fieldType);
86
96
  }
87
97
  /**
88
- * True when `defaultValue` is applicable to this field — and therefore when
89
- * `notNull` on it also demands one. Recorded evidence for that demand, on the
90
- * types where the default DOES apply: the builder answers HTTP 400
91
- * "`defaultValue` is required when creating a field with `notNull: true`" (an
92
- * empty string is rejected too). Where the default does not apply the builder
93
- * takes `notNull` alone, so no default is required — and none is sent.
98
+ * True when a `notNull` on this field also DEMANDS a `defaultValue`. Recorded evidence: the
99
+ * builder answers HTTP 400 "`defaultValue` is required when creating a field with `notNull: true`"
100
+ * (an empty string is rejected too). On a relation-like type it takes `notNull` alone.
101
+ *
102
+ * This is about the requirement, never about whether a default may be sent — see
103
+ * `defaultValueMayBeSent`.
94
104
  */
95
105
  export function defaultValueApplies(fieldType, unique = false) {
96
106
  return !unique && !RELATION_LIKE_FIELD_TYPES.includes(fieldType);
97
107
  }
108
+ /**
109
+ * True when a caller's `defaultValue` should be forwarded to the builder.
110
+ *
111
+ * Everything except a unique field, where the capture's exclusion is the only half still standing.
112
+ * A relation / enum / file default is a REFERENCE, not a literal: `{ id }` (or `[{ id }, …]` for a
113
+ * multi), never the option's value string or the enum name; a Users relation also takes the
114
+ * `$current-user` token. If the builder ever refuses one it answers 400 naming the field, which is
115
+ * a better outcome than this server deciding the request was inapplicable and dropping it.
116
+ */
117
+ export function defaultValueMayBeSent(unique = false) {
118
+ return !unique;
119
+ }
98
120
  // ---------------------------------------------------------------------------
99
121
  // Field options (the `options` object of a field body)
100
122
  // ---------------------------------------------------------------------------
@@ -113,6 +135,21 @@ export function defaultValueApplies(fieldType, unique = false) {
113
135
  // the searchable option participate."). `searchable` (and searchPriority) are
114
136
  // therefore the ones worth setting deliberately; the rest already hold the
115
137
  // value most fields want.
138
+ /**
139
+ * The display flags the platform's own client sends on every field it creates
140
+ * (`fieldDraft.DEFAULT_TRUE_OPTIONS` in the entity builder, `setDefaultTrueOptions` in the legacy
141
+ * admin). They are NOT defaulted by the backend, and a consumer that reads the stored options
142
+ * object treats an absent key as false — which is how agent-created fields ended up non-groupable,
143
+ * unsortable and hidden from tables. `searchable` and `readOnly` are deliberately absent: they
144
+ * default to false and are the two worth setting deliberately.
145
+ */
146
+ export const DEFAULT_TRUE_FIELD_OPTIONS = {
147
+ canGroup: true,
148
+ canSort: true,
149
+ canFilter: true,
150
+ showInTable: true,
151
+ editFromTable: true,
152
+ };
116
153
  /** Boolean members of the Field Options object. */
117
154
  export const FIELD_OPTION_BOOLEAN_KEYS = [
118
155
  "searchable", // builder.txt:66 — "Available for search."
@@ -1622,8 +1659,10 @@ export async function buildFieldDef(entityName, fieldName, fieldType, title, opt
1622
1659
  `field_type="${resolvedType}", required=true, default_value="now()") # SQL expression ` +
1623
1660
  "(quote text literals inside the string: \"'draft'\")",
1624
1661
  ],
1625
- no_default_needed_for: [...NO_DEFAULT_VALUE_FIELD_TYPES],
1662
+ no_default_needed_for: [...NO_DEFAULT_REQUIRED_FIELD_TYPES],
1626
1663
  no_default_needed_when: "unique=true (defaultValue does not apply to a unique field)",
1664
+ note_these_types_may_still_HOLD_a_default: "A relation / enum / file field does not REQUIRE a default, but it can carry one — as a " +
1665
+ "reference (`{ id }`, `[{ id }, …]`), or `$current-user` on a Users relation.",
1627
1666
  });
1628
1667
  }
1629
1668
  // Relation pre-flight: verify the target exists and the field is new, so we
@@ -1687,13 +1726,24 @@ export async function buildFieldDef(entityName, fieldName, fieldType, title, opt
1687
1726
  // sending it there is at best ignored, so it is never emitted. A default the
1688
1727
  // caller ASKED for and did not get is reported, like the other two — dropping
1689
1728
  // it silently was the same defect notNull and unique already had fixed.
1690
- if (defaultText.trim() !== "" && typeNeedsDefault) {
1691
- fieldDef.defaultValue = defaultText;
1729
+ if (defaultText.trim() !== "" && defaultValueMayBeSent(unique)) {
1730
+ // Objects and arrays go out AS THEY CAME: a reference default is `{ id }` / `[{ id }, …]`,
1731
+ // and `String()` would ship the literal text "[object Object]".
1732
+ fieldDef.defaultValue = typeof defaultValue === "object" && defaultValue !== null
1733
+ ? defaultValue
1734
+ : defaultText;
1735
+ if (RELATION_LIKE_FIELD_TYPES.includes(resolvedType) &&
1736
+ typeof defaultValue === "string" &&
1737
+ defaultValue !== "$current-user") {
1738
+ notApplicable.push(`defaultValue went out as the plain string ${JSON.stringify(defaultValue)} on a ` +
1739
+ `'${resolvedType}' field — a default on a relation/enum/file field is a REFERENCE: ` +
1740
+ "`{ id }`, or `[{ id }, …]` for a multi (a Users relation also takes `$current-user`). " +
1741
+ "Read the field back to check what was stored.");
1742
+ }
1692
1743
  }
1693
1744
  else if (defaultText.trim() !== "") {
1694
- notApplicable.push(`defaultValue was NOT set: builder.txt:43 — "Not applicable to relations, enums, or unique ` +
1695
- `fields" (this field is '${resolvedType}'${unique ? " and unique" : ""}). The field was ` +
1696
- "created WITHOUT a default.");
1745
+ notApplicable.push(`defaultValue was NOT set: it does not apply to a unique field. The field was created ` +
1746
+ "WITHOUT a default.");
1697
1747
  }
1698
1748
  // Sent exactly as validated: subTypeProblem() judged the TRIMMED value, and
1699
1749
  // ' date ' used to pass that check and then go out with the spaces.
@@ -1740,9 +1790,20 @@ export async function buildFieldDef(entityName, fieldName, fieldType, title, opt
1740
1790
  }
1741
1791
  // builder.txt:60 — "options | object | false | Field options configuration."
1742
1792
  // (example body: builder.txt:127-132).
1793
+ //
1743
1794
  if (fieldOptions) {
1744
1795
  fieldDef.options = fieldOptions;
1745
1796
  }
1797
+ else {
1798
+ // UNSETTLED, and it decides whether a new field is visible in tables at all. Our own read-back
1799
+ // (2026-08-05, live) says the platform fills these in; the platform's AI-assistant page says
1800
+ // the opposite — "never defaulted by the backend … every consumer reads an absent key as
1801
+ // false … an agent-created field was silently non-groupable, unsortable and hidden from
1802
+ // tables" — and today's read of the stored shape supports it (15 of 70 Tasks fields carry no
1803
+ // `options` at all). Only a write settles it, so nothing is forced here; the caller is told.
1804
+ // Deliberately NOT reported: an omission is the normal call, and a warning on every one of
1805
+ // them is the noise that teaches people to stop reading warnings.
1806
+ }
1746
1807
  return { fieldDef, notApplicable, resolvedType };
1747
1808
  }
1748
1809
  /**
@@ -1975,7 +2036,10 @@ export async function updateField(entityName, fieldName, opts = {}) {
1975
2036
  '"now()"), or omit default_value to leave the current default as it is.',
1976
2037
  });
1977
2038
  }
1978
- body.defaultValue = String(opts.defaultValue); // builder.txt:358
2039
+ // Same rule as the add path: a reference default is an object and must survive verbatim.
2040
+ body.defaultValue = typeof opts.defaultValue === "object" && opts.defaultValue !== null
2041
+ ? opts.defaultValue
2042
+ : String(opts.defaultValue); // builder.txt:358
1979
2043
  }
1980
2044
  if (opts.relationEntity !== undefined && opts.relationEntity !== null && String(opts.relationEntity).trim() !== "") {
1981
2045
  body.relationTarget = String(opts.relationEntity).trim(); // builder.txt:359
@@ -2081,12 +2145,24 @@ export async function updateField(entityName, fieldName, opts = {}) {
2081
2145
  // the live metadata. The check used to read body.unique only, so a default
2082
2146
  // went out on a field that was already unique on the tenant.
2083
2147
  const willBeUnique = "unique" in body ? body.unique === true : meta?.unique === true;
2084
- if ("defaultValue" in body && !defaultValueApplies(liveType, willBeUnique)) {
2148
+ if ("defaultValue" in body && !defaultValueMayBeSent(willBeUnique)) {
2085
2149
  delete body.defaultValue;
2086
- notApplicable.push(`defaultValue was NOT sent: builder.txt:43 — "Not applicable to relations, enums, or ` +
2087
- `unique fields" ('${fieldName}' is '${liveType}'${willBeUnique ? " and unique" : ""}). ` +
2150
+ notApplicable.push(`defaultValue was NOT sent: it does not apply to a unique field ('${fieldName}'). ` +
2088
2151
  "The default is unchanged.");
2089
2152
  }
2153
+ else if ("defaultValue" in body &&
2154
+ RELATION_LIKE_FIELD_TYPES.includes(liveType) &&
2155
+ typeof body.defaultValue === "string" &&
2156
+ body.defaultValue !== "$current-user") {
2157
+ // Forwarded, not dropped — but a bare string on a reference field is almost always the
2158
+ // option's value or the target's name, which the builder stores as nothing recognisable.
2159
+ notApplicable.push(`defaultValue was sent as the plain string ${JSON.stringify(body.defaultValue)} on ` +
2160
+ `'${fieldName}', which is a '${liveType}' — a default on a relation/enum/file field is a ` +
2161
+ "REFERENCE: `{ id }`, or `[{ id }, …]` for a multi (a Users relation also takes the " +
2162
+ "`$current-user` token). Live examples on a tenant: `Tasks.priority` (enum) holds the " +
2163
+ "Enums row id, `Tasks.createdBy` (many-to-one) holds `$current-user`. Read the field " +
2164
+ "back to check what was stored.");
2165
+ }
2090
2166
  }
2091
2167
  if (Object.keys(body).length === 0) {
2092
2168
  return jsonResponse({
@@ -336,6 +336,7 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
336
336
  // costs no network call and cannot fail for a reason the user did not ask about.
337
337
  if (!confirm) {
338
338
  let preview = "the draft is gated on the confirmed call";
339
+ let draftSettings = {};
339
340
  try {
340
341
  const peek = readJson(target);
341
342
  if (peek.error)
@@ -345,6 +346,7 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
345
346
  if (s) {
346
347
  const mod = await import(pathToFileURL(s).href);
347
348
  const g = await mod.validateForm(peek.value, { normalize });
349
+ draftSettings = (g.draft && typeof g.draft.settings === "object" && g.draft.settings) || {};
348
350
  preview = {
349
351
  gate: g.refused ? "REFUSED" : g.ok ? "passes" : "has errors",
350
352
  elements: g.elements ?? 0,
@@ -357,11 +359,45 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
357
359
  catch (e) {
358
360
  preview = `the draft could not be checked yet: ${e instanceof Error ? e.message : String(e)}`;
359
361
  }
362
+ // WHAT IT WOULD REPLACE. A `/select` is a read, and the confirm-gate contract permits one here
363
+ // — a preview that describes only the draft is the half that does not matter for a call whose
364
+ // job is to overwrite two columns. A tenant that cannot be reached must still leave this as
365
+ // confirmation_required, so every failure degrades to a sentence.
366
+ let replaces = "the form could not be read from here; the confirmed call reads it again and aborts if that fails";
367
+ try {
368
+ const row = await selectEntity("Forms", [{ field: "id", comparator: "=", value: id }], { id: true, name: true, type: true, status: true, schema: true, settings: true, lockedBy: { id: true, fullName: true } });
369
+ if (!row)
370
+ replaces = `no form with id ${id} on this tenant`;
371
+ else {
372
+ const col = (row.schema && typeof row.schema === "object" && !Array.isArray(row.schema) ? row.schema : {});
373
+ const rowSettings = (row.settings && typeof row.settings === "object" ? row.settings : {});
374
+ // The merge keeps a row key the draft does not mention. That is deliberate — dropping keys
375
+ // this tool does not understand would be worse — but it is invisible, and invisible is how
376
+ // a setting an author thought they had removed stays switched on.
377
+ const kept = Object.keys(rowSettings).filter((k) => !(k in draftSettings));
378
+ replaces = {
379
+ form: { id: row.id, name: row.name, type: row.type, status: row.status },
380
+ elements_now: Array.isArray(col.components) ? col.components.length : 0,
381
+ connections_now: Array.isArray(col.connections) ? col.connections.length : 0,
382
+ overrides_now: Array.isArray(col.overrides) ? col.overrides.length : 0,
383
+ settings_overwritten: Object.keys(draftSettings),
384
+ settings_kept_because_the_draft_is_silent_about_them: kept,
385
+ ...(kept.length
386
+ ? { 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" }
387
+ : {}),
388
+ ...(row.lockedBy ? { locked_by: row.lockedBy } : {}),
389
+ };
390
+ }
391
+ }
392
+ catch (e) {
393
+ replaces = `the form could not be read from here (${e instanceof Error ? e.message : String(e)}); the confirmed call reads it again and aborts if that fails`;
394
+ }
360
395
  return confirmRequired("save a form DRAFT (it never publishes)", { form_id: id, path: target }, {
361
396
  writes: ["schema", "settings"],
362
397
  never_written: ["status", "mobileSchema", "code", "variables", "localizations", "entity", "alias", "parent", "parentVersion"],
363
398
  publishes: false,
364
399
  draft: preview,
400
+ replaces,
365
401
  });
366
402
  }
367
403
  if (!Number.isInteger(id) || id <= 0) {
@@ -404,7 +440,7 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
404
440
  row = await selectEntity("Forms", [{ field: "id", comparator: "=", value: id }], {
405
441
  id: true, name: true, type: true, status: true, alias: true,
406
442
  schema: true, settings: true, data: true,
407
- lockedBy: { id: true, fullName: true },
443
+ lockedBy: { id: true, fullName: true }, lockedAt: true,
408
444
  entity: { id: true, name: true },
409
445
  parent: { id: true }, parentVersion: { id: true, versionNumber: true },
410
446
  });
@@ -433,10 +469,23 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
433
469
  mine = null;
434
470
  }
435
471
  if (mine === null || lockedBy.id !== mine) {
472
+ // The lock is sticky BY DESIGN: there is no heartbeat, so a killed tab leaves it held
473
+ // forever and there is nobody to ask. The platform's own takeover modal answers this by
474
+ // stating the lock's age; so does this refusal, for the same reason.
475
+ const heldSince = typeof row.lockedAt === "string" ? row.lockedAt : null;
476
+ const ageMs = heldSince ? Date.now() - Date.parse(heldSince) : NaN;
477
+ const age = Number.isFinite(ageMs)
478
+ ? (ageMs > 36e5 ? `${Math.round(ageMs / 36e5)}h` : `${Math.max(1, Math.round(ageMs / 6e4))}min`)
479
+ : null;
436
480
  return jsonResponse({
437
481
  written: false,
438
- error: `form ${id} is open in the builder by ${lockedBy.fullName ?? `user ${lockedBy.id}`}. ` +
439
- "Writing under them would silently lose one of the two edits — ask them to close it.",
482
+ locked_by: lockedBy,
483
+ locked_at: heldSince,
484
+ error: `form ${id} is open in the builder by ${lockedBy.fullName ?? `user ${lockedBy.id}`}` +
485
+ `${age ? `, held for ${age}` : ""}. Writing under them would silently lose one of the two ` +
486
+ "edits. A lock has no heartbeat, so a crashed tab holds one forever and there may be " +
487
+ "nobody to ask: if it looks dead, a human opens the form and presses Take over in the " +
488
+ "lock banner — always available, always asks, and it discards the holder's unsaved work.",
440
489
  });
441
490
  }
442
491
  }
@@ -468,6 +517,9 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
468
517
  elements: { before: Array.isArray(existingSchema.components) ? existingSchema.components.length : 0, after: schemaColumn.components ? schemaColumn.components.length : 0 },
469
518
  connections: Array.isArray(schemaColumn.connections) ? schemaColumn.connections.length : 0,
470
519
  overrides_preserved: Array.isArray(schemaColumn.overrides) ? schemaColumn.overrides.length : 0,
520
+ // Keys the row carries that the draft says nothing about survive the merge. Naming them is the
521
+ // difference between a setting you decided to keep and one you did not know was still there.
522
+ settings_kept_because_the_draft_is_silent_about_them: Object.keys(existingSettings).filter((k) => !(k in (draft.settings ?? {}))),
471
523
  warnings: gate.warnings,
472
524
  };
473
525
  let result;
@@ -502,7 +554,11 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
502
554
  : `READ-BACK MISMATCH: wrote ${plan.elements.after} elements, the row now holds ${savedCount ?? "unknown"} — check the form before trusting this`,
503
555
  note: "Saved as a DRAFT. No FormVersions row was created and `status` was not touched, so this is " +
504
556
  "not published: what other people see is still the last published version. Publishing is a " +
505
- "human action in the builder.",
557
+ "human action in the builder. This write goes through the generic data endpoint, not the " +
558
+ "builder's own `PUT /forms/:id/schema`, so it writes NO change-set: the edit will not appear " +
559
+ "in the History panel, and later change-set diffs are reconstructed from a log that does not " +
560
+ "contain it. Nothing is lost — but an edit somebody will need to read the history of belongs " +
561
+ "in the builder.",
506
562
  result,
507
563
  });
508
564
  }
@@ -1169,7 +1169,13 @@ async function _runWrite(action, fn) {
1169
1169
  // "Relation types" group, whose values live in a join/side table
1170
1170
  // (docs/superpowers/specs/captures/api-entity-builder-builder.txt:43 —
1171
1171
  // "defaultValue ... Not applicable to relations, enums, or unique fields";
1172
- // :63 lists the group). Mirrors NO_DEFAULT_VALUE_FIELD_TYPES in tools/entity.ts,
1172
+ // :63 lists the group). That line governs the REQUIREMENT only — these types can
1173
+ // still HOLD a default, as a reference (`{ id }` / `[{ id }, …]`, or
1174
+ // `$current-user` on a Users relation): measured on a live tenant, `Tasks.priority`
1175
+ // (enum) carries an Enums row id and `Tasks.createdBy` (many-to-one) carries the
1176
+ // token. This set is therefore "no default REQUIRED", not "no default allowed" —
1177
+ // the migrator writes none of its own either way.
1178
+ // Mirrors NO_DEFAULT_REQUIRED_FIELD_TYPES in tools/entity.ts,
1173
1179
  // kept local so the migrator decides before the write instead of learning from a
1174
1180
  // failed one — entity.js is module-mocked in the migrator's tests.
1175
1181
  const _NO_DEFAULT_VALUE_TYPES = new Set([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suppa-mcp-2",
3
- "version": "1.39.0",
3
+ "version": "1.40.1",
4
4
  "description": "MCP server for the Suppa platform (modern.suppa.me) — Tasks, Docs/Pages, Entities & Schema, Forms, Automations, and file attachments, with multi-tenant Google auth. Node port of PyPI suppa-mcp.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -52,15 +52,17 @@ rules — plus your own reading of the warnings — are what stands between that
52
52
  1. **Nesting is `layout[bp].parentId`**, set to the parent element's `id` (its uuid, never its
53
53
  `name`). The array is flat and its order is not structure. A child of a grid `container` writes
54
54
  `{x, y, width, height}` in **1-based cells**; a child of a `flexContainer` writes `{order}`.
55
- Give every element an `lg` entry — an undeclared breakpoint is dead schema at runtime.
55
+ **Every element needs an explicit `layout[bp]` for every key in `settings.breakpoints` — there
56
+ is no fallback**, and an element with no record for a declared breakpoint is invisible there.
56
57
  2. **`layout[bp].height` is a row span, and the only thing that makes an element taller.**
57
58
  `containerSettings.size.heightMode` (`auto` | `fixed` | `fill`) is scroll behaviour. `fill` on a
58
59
  table or a leaf field does not enlarge it; it makes it share leftover height with its siblings.
59
60
  Both keys are legal on the same element, so nothing can flag the mix-up.
60
61
  3. **A grid child spans its parent's columns, not the form's.** Inside a 12-column section, full
61
- width is `width: 12`; inside a 2-column container it is `width: 2`. A new form ships
62
- `settings.columnsNumber: 1` as an "unset" sentinel — treat the working grid as 12, and if you
63
- raise `columnsNumber`, re-span the elements already on the form in the same turn.
62
+ width is `width: 12`; inside a 2-column container it is `width: 2`. **Column count defaults to
63
+ 1, and 1 is a real count, not an "unset" flag** — the root grid reads `settings.columnsNumber`,
64
+ a grid container its own (1–12). Write the count you intend *before* you lay out spans; change
65
+ it and you re-span its children in the same turn.
64
66
  4. **There are 58 dedicated types.** Never assemble something out of `input` + `html` because no
65
67
  type came to mind. `html` is author-written static markup and is never a home for record data —
66
68
  bind an element instead. Six pairs where both choices validate are in
@@ -76,17 +78,21 @@ rules — plus your own reading of the warnings — are what stands between that
76
78
  with them and pushed to the platform **unexpanded** ships with no styling at all, and validates
77
79
  clean. Either gate it with `--normalize` and take the repaired draft, or write the real settings
78
80
  yourself.
79
- 7. **Style is one value across all breakpoints.** There is no per-breakpoint styling; only `layout`
80
- is per-breakpoint. A mobile presentation silently wears the desktop styling.
81
+ 7. **Style is one value across breakpoints — but not across presentations.** Only `layout` is
82
+ per-breakpoint. `mobileSchema` is an independent component set with its **own** component
83
+ config, so mobile styling is authored there; editing the desktop element changes nothing on the
84
+ phone. Its elements keep their `name` and take **fresh uuids** — ids must not overlap.
81
85
  8. **Schema writes come first, and they are not transactional.** When the form needs a field or an
82
86
  entity that does not exist: every `create-entity`, then every `add-field`, then `update-field`,
83
87
  then enum values last. A half-applied plan leaves real tables behind. Then write the form.
84
- 9. **A write replaces a whole column — and `FormVersions` is the undo.** Every publish snapshots
85
- the form, so a bad write on a versioned form is recoverable: restore the version. What history
86
- does not cover is a write that lands where nothing reads. Writing `data.formSchema` on a 2.1
87
- tenant returns 200, changes the row, and changes **nothing the builder renders**. Write `schema`;
88
- read the row first; and remember `variables` and `localizations` are separate rows, not part of
89
- the column.
88
+ 9. **A write replaces a whole column — and `FormVersions` is a PARTIAL undo.** A publish snapshots
89
+ `schema`, `mobileSchema`, `settings`, `variables`, `localizations`, `globalLocalizationKeys`,
90
+ `codeArtifact`, `sharedModuleRefs` — and nothing else. `type`, `isPublic`, `priority`,
91
+ `condition` and the access lists are unversioned *and* have no draft stage: written, they are
92
+ live for everyone at once, with no version to restore. Treat a metadata write as a production
93
+ change. History also cannot cover a write that lands where nothing reads: `data.formSchema` on
94
+ a 2.1 tenant returns 200 and changes **nothing the builder renders**. Write `schema`; read the
95
+ row first; `variables` and `localizations` are separate rows.
90
96
 
91
97
  ## Inherited forms
92
98
 
@@ -132,9 +138,10 @@ the key it read, and refuses the rest.
132
138
  `workspaceModule`. `custom` is the only kind allowed with no bound entity; `custom` and `workspace`
133
139
  are submitless. The v1 names (`elementForm`, `createForm`, `table`, …) still sit on old rows and are
134
140
  ignored by the 2.x builder. `formSettings.isFormBuilderV2: true` is the host's routing
135
- discriminator — a new form must carry it, and an edit must not drop it. `Forms.status`
136
- (`draft` | `editing` | `published`) is what the builder publishes through, and `lockedBy`/`lockedAt`
137
- mean someone has the form open.
141
+ discriminator — a new form must carry it, and an edit must not drop it. `lockedBy`/`lockedAt` mean
142
+ someone has the form open. `Forms.status` (`draft` | `editing` | `published`) is **not** the
143
+ publish switch — it is one more unversioned metadata column; publishing is a computed diff. See
144
+ `references/publishing.md`.
138
145
 
139
146
  The bound entity is set when the row is created and never changed. Its default variable's name **is
140
147
  the entity's system name verbatim**, and every `dataSource.fieldPath` is rooted at it:
@@ -0,0 +1,48 @@
1
+ # `embeddedForm` behaviour
2
+
3
+ *Open when a form is to render another form inside it — a record card with its own content form, a
4
+ side panel, a wizard step that reuses an existing form.*
5
+
6
+ `form` is `{ id, alias?, entity? }` — the whole reference the form picker emits, not a bare id. Two
7
+ modes: `source: 'record'` mounts a **full `FormHost`** for the active record (projection, hydration,
8
+ autosave, realtime, dirty guard — none of which the bare nested-runtime path has), and standalone
9
+ renders the form on its own. The builder always draws a dashed placeholder instead: there is no
10
+ design-time recursion.
11
+
12
+ ## The content form must be `update`, and non-transactional
13
+
14
+ **`type: 'update'` with `settings.isTransactionMode: false`.** `FormHost` arms autosave only for
15
+ `record && !submitless && !transaction`, and `custom` / `workspace` are submitless — so a `custom`
16
+ content form inside an embed **saves nothing**. Edits sit in the runtime and a record swap discards
17
+ them, with no error and no prompt. Measured by the platform on forms 219 and 218 of this dev
18
+ tenant. With `update` + non-transaction each field edit diff-PATCHes the active record.
19
+
20
+ Keep the content form `isPublic: false`. A second `update` form on the entity does not hijack the
21
+ card's own resolve (probed at priority 0, 1 and 100), but that is the tested configuration.
22
+
23
+ An edit that never left its input — typed, no blur, then a programmatic record swap — is still
24
+ dropped, exactly as in v1. A *committed* edit is safe: the host flushes a debounced autosave in
25
+ `onBeforeUnmount`, and the persist closure owns the old record id, so it can never land on the new
26
+ record.
27
+
28
+ ## Two traps for a form authored through the API instead of the builder
29
+
30
+ Both apply to this skill, because this skill writes rows rather than clicking the builder:
31
+
32
+ - **The default relation variable is not seeded for you.** `POST /core/forms/schema` creates the
33
+ form without it, and then every `{{Entity.*}}` path in the form dies silently. Write it in the
34
+ first update: `variables: [{ name: '<Entity>', type: 'relation', isDefault: true }]`.
35
+ - **`PUT /core/forms/:id/schema` must resend `code`** — omit it and the server **nulls
36
+ `codeArtifact`**. (This skill's `write_form_draft` avoids the hazard by using the generic data
37
+ endpoint and naming only `schema` and `settings`, so `code` and `codeArtifact` are untouched. The
38
+ trap is live the moment anything switches to the platform's own save-draft endpoint.)
39
+
40
+ ## Cross-form messaging
41
+
42
+ An embedded form talks to its host through the element's `formEvent`, scoped by **ownership**, not
43
+ by ids — two stacked cards on the same record stay independent. Never reach for `window` events:
44
+ they are global, they leak, and any form can spoof any other.
45
+
46
+ Failure states are explicit, never a blank: `embeddedFormRequired` (no form picked),
47
+ `embeddedFormEntityRequired` (record mode, no entity resolves), `embeddedFormRecordRequired`
48
+ (runtime only, no active record) and `formLoadFailed` (deleted, no access, or no published version).
@@ -2,7 +2,16 @@
2
2
 
3
3
  *Open when you are placing a record list / workspace over an entity, or a view tab on one is not showing what you configured.*
4
4
 
5
- One element draws the whole workspace: breadcrumb, toolbar (search, filters, Create), the view-tab strip, and the active data view over `dataSource.entity`'s records. Its children are toolbar slots the runtime injects, not layout you author; `slots` and `namedViews` are runtime-managed — never write them.
5
+ One element draws the whole workspace: breadcrumb, toolbar (search, filters, Create), the view-tab strip, and the active data view over `dataSource.entity`'s records. Its children are toolbar slots the runtime injects, not layout you author — `slots` is runtime-managed, never write it.
6
+
7
+ **`namedViews` is yours, though.** It is the tab strip's *builder-mode* source — an array of seeds on `EntityListElementSchema` that the builder mutates directly, with no backend call, and the form authoring guide lists it among `entityList`'s authorable props beside `views` / `defaultView` / `availableViewTypes`. A seed is `{ title, icon, type: 'system' }` plus its own filter; `title` is `LocalizedText` and `icon` takes the **IconValue object** (`{ name, color?, size?, bgColor?, … }`), never a bare glyph string. The platform's own defaults are *All* (no filter) and *Created by me* (`author.id = $currentUser.id`). At **runtime** the same strip is backed by per-user backend `Layout[]` records instead — those are the reader's and must not be authored, which is what makes the two halves easy to confuse.
8
+
9
+ **Its columns are not in the form.** `entityList` is the one element that refuses the builder's
10
+ column drill-in (`supportsColumnDrillIn()` is `true` on every other runtime): a list's visible
11
+ fields, widths, pinning, sort, grouping and filters live in an entity-scoped `Layout` record, saved
12
+ through *Save view*, and its per-column options are edited in **Entity Builder → Views → Table**.
13
+ Authoring `settings.columns` here configures nothing. (A standalone `table` element is the
14
+ opposite: it owns its columns in its own schema — see `references/tables.md`.)
6
15
 
7
16
  `availableViewTypes` is the only switch that makes a view type *reachable*. The runtime takes it when non-empty, else the enabled `views[]` presets' types, else `table` + `list`. A `cards` or `dashboard` block whose type is missing from it is dead config — authored, validated, never rendered.
8
17
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  *Open when a form has a sidebar navigation — a menuPanel, its items, or the pane it drives.*
4
4
 
5
- The panel's navigation **is** its `menuPanelItem` children, attached by `layout[bp].parentId`. Its value is the selected ITEM's `name`, not the entity. A `workspaceViewport` mirrors it by `menuComponent` (the menu's `name`) and opens that item's `entity` with that item's `filter`.
5
+ The panel's navigation **is** its `menuPanelItem` children, attached by `layout[bp].parentId`. **Its value is the selected item's `entity`** — an item is active when `owningPanel.value === entity`, and the URL sync is `?<urlParam>=<entity>`. A `workspaceViewport` mirrors it by `menuComponent` (the menu's `name`) and opens that entity with that item's `filter`.
6
6
 
7
7
  Nothing else consumes the selection. A panel no viewport names and no code-form reads is a list of rows that highlight and do nothing. Only a `menuComponent` naming the *wrong* element is caught here; an absent one is not.
8
8
 
@@ -10,4 +10,6 @@ Only items with `kind: 'entity'` **and** a non-empty `entity` are selectable. A
10
10
 
11
11
  Landing entry, in precedence order: the URL `?<urlParam>=` (a base prop; an empty string publishes nothing), then the user's remembered choice, then `defaultItem`. `rememberLastChoice` is true when absent, so `defaultItem` alone is a no-op for every returning user — to pin a landing row, set both.
12
12
 
13
+ **`defaultItem` takes either spelling.** `resolveMenuSelection` matches the item's own `name` first and falls back to an item's `entity` for back-compat; the platform's own module seeder writes the **entity** system name, which is the spelling its documentation describes. Either way it must land on a `kind: 'entity'` item with a non-empty `entity` — a `link` or `button` row can never be the landing entry, and a token matching nothing falls through to the first entity item with nothing reported. The gate catches both misses.
14
+
13
15
  `selectionScope` fuses several panels into one navigation: at most one highlighted row across all of them, one shared remembered choice, and only the first panel to mount seeds the default. The value is trimmed, so whitespace equals absent — and two menus that must stay independent must not share a tag.