suppa-mcp-2 1.44.4 → 1.45.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.
@@ -871,8 +871,55 @@ async function gateEdit(mod, draft, live, normalize) {
871
871
  return { ...g, ok: added.length === 0, errors: added, already_live: already };
872
872
  }
873
873
  const alreadyLive = (list) => list.map((f) => ({ code: f?.code, elementId: f?.elementId ?? null }));
874
+ /**
875
+ * SOMEONE ELSE HAS IT OPEN. The builder holds `lockedBy` while a form is being edited; writing under them means
876
+ * one of the two of you loses work without being told — a refusal. The caller's OWN lock is a note: that tab's
877
+ * next save overwrites this write. `row` needs lockedBy { id, fullName } and lockedAt.
878
+ */
879
+ export async function formLock(id, row) {
880
+ const lockedBy = row.lockedBy;
881
+ if (!lockedBy?.id)
882
+ return { note: null };
883
+ let mine = null;
884
+ try {
885
+ const me = JSON.parse(await tasks.getMe());
886
+ mine = typeof me?.id === "number" ? me.id : null;
887
+ }
888
+ catch {
889
+ mine = null;
890
+ }
891
+ if (mine === null || lockedBy.id !== mine) {
892
+ // The lock is sticky BY DESIGN: there is no heartbeat, so a killed tab leaves it held
893
+ // forever and there is nobody to ask. The platform's own takeover modal answers this by
894
+ // stating the lock's age; so does this refusal, for the same reason.
895
+ const heldSince = typeof row.lockedAt === "string" ? row.lockedAt : null;
896
+ const ageMs = heldSince ? Date.now() - Date.parse(heldSince) : NaN;
897
+ const age = Number.isFinite(ageMs)
898
+ ? (ageMs > 36e5 ? `${Math.round(ageMs / 36e5)}h` : `${Math.max(1, Math.round(ageMs / 6e4))}min`)
899
+ : null;
900
+ return {
901
+ note: null,
902
+ refusal: {
903
+ locked_by: lockedBy,
904
+ locked_at: heldSince,
905
+ error: `form ${id} is open in the builder by ${lockedBy.fullName ?? `user ${lockedBy.id}`}` +
906
+ `${age ? `, held for ${age}` : ""}. Writing under them would silently lose one of the two ` +
907
+ "edits. A lock has no heartbeat, so a crashed tab holds one forever and there may be " +
908
+ "nobody to ask: if it looks dead, a human opens the form and presses Take over in the " +
909
+ "lock banner — always available, always asks, and it discards the holder's unsaved work.",
910
+ },
911
+ };
912
+ }
913
+ // The lock is the CALLER's: its own builder tab is open on this form. That tab's next save goes
914
+ // out with no revision guard (the builder sends none until the draft payload carries updatedAt,
915
+ // FE base-forms-inheritance.md), so it would overwrite this write without a 409.
916
+ return {
917
+ note: `form ${id} is locked by your own account — a builder tab of yours has it open. That tab's next ` +
918
+ "save overwrites this write with no warning: reload or close the builder tab before anyone saves there.",
919
+ };
920
+ }
874
921
  /** A 409 from the revision guard, in words, with the revision the row holds now. */
875
- function staleAnswer(message, id) {
922
+ export function staleAnswer(message, id) {
876
923
  // The status, not a 409 anywhere in the text: a 400 whose body names form 409 is a 400.
877
924
  if (!/^HTTP 409\b/.test(message) && !/changed since it was loaded/i.test(message))
878
925
  return null;
@@ -1239,46 +1286,11 @@ export async function writeFormDraft(formId, path, confirm = false, normalize =
1239
1286
  if (guards.refusals.length) {
1240
1287
  return jsonResponse({ written: false, error: guards.refusals.join(" "), refusals: guards.refusals, note: "Nothing was written." });
1241
1288
  }
1242
- // 4. SOMEONE ELSE HAS IT OPEN. The builder holds `lockedBy` while a form is being edited; writing
1243
- // under them means one of the two of you loses work without being told.
1244
- const lockedBy = row.lockedBy;
1245
- let lockNote = null;
1246
- if (lockedBy?.id) {
1247
- let mine = null;
1248
- try {
1249
- const me = JSON.parse(await tasks.getMe());
1250
- mine = typeof me?.id === "number" ? me.id : null;
1251
- }
1252
- catch {
1253
- mine = null;
1254
- }
1255
- if (mine === null || lockedBy.id !== mine) {
1256
- // The lock is sticky BY DESIGN: there is no heartbeat, so a killed tab leaves it held
1257
- // forever and there is nobody to ask. The platform's own takeover modal answers this by
1258
- // stating the lock's age; so does this refusal, for the same reason.
1259
- const heldSince = typeof row.lockedAt === "string" ? row.lockedAt : null;
1260
- const ageMs = heldSince ? Date.now() - Date.parse(heldSince) : NaN;
1261
- const age = Number.isFinite(ageMs)
1262
- ? (ageMs > 36e5 ? `${Math.round(ageMs / 36e5)}h` : `${Math.max(1, Math.round(ageMs / 6e4))}min`)
1263
- : null;
1264
- return jsonResponse({
1265
- written: false,
1266
- locked_by: lockedBy,
1267
- locked_at: heldSince,
1268
- error: `form ${id} is open in the builder by ${lockedBy.fullName ?? `user ${lockedBy.id}`}` +
1269
- `${age ? `, held for ${age}` : ""}. Writing under them would silently lose one of the two ` +
1270
- "edits. A lock has no heartbeat, so a crashed tab holds one forever and there may be " +
1271
- "nobody to ask: if it looks dead, a human opens the form and presses Take over in the " +
1272
- "lock banner — always available, always asks, and it discards the holder's unsaved work.",
1273
- });
1274
- }
1275
- // The lock is the CALLER's: its own builder tab is open on this form. That tab's next save goes
1276
- // out with no revision guard (the builder sends none until the draft payload carries updatedAt,
1277
- // FE base-forms-inheritance.md), so it would overwrite this write without a 409.
1278
- lockNote =
1279
- `form ${id} is locked by your own account — a builder tab of yours has it open. That tab's next ` +
1280
- "save overwrites this write with no warning: reload or close the builder tab before anyone saves there.";
1281
- }
1289
+ // 4. SOMEONE ELSE HAS IT OPEN — see formLock.
1290
+ const lock = await formLock(id, row);
1291
+ if (lock.refusal)
1292
+ return jsonResponse({ written: false, ...lock.refusal });
1293
+ const lockNote = lock.note;
1282
1294
  const existingSchema = (row.schema && typeof row.schema === "object" && !Array.isArray(row.schema)
1283
1295
  ? row.schema
1284
1296
  : {});
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import { randomUUID } from "node:crypto";
11
11
  import { makeRequest, searchEntity, selectEntity, insertEntity, } from "../httpClient.js";
12
- import { ownProjection } from "../projection.js";
12
+ import { ownProjection, registerOwnProjections } from "../projection.js";
13
13
  import { makeFilter, jsonResponse, parseJsonParam, notFoundAnswer } from "../utils.js";
14
14
  // ---------------------------------------------------------------------------
15
15
  // Constants
@@ -30,6 +30,7 @@ export const FORM_DETAIL_FIELDS = ownProjection({
30
30
  ...FORM_LIST_FIELDS,
31
31
  data: true,
32
32
  });
33
+ registerOwnProjections(ENTITY_FORMS, { FORM_LIST_FIELDS, FORM_DETAIL_FIELDS });
33
34
  export const DEFAULT_FORM_SETTINGS = {
34
35
  id: 0,
35
36
  size: "md",
@@ -398,7 +399,7 @@ const nonEmpty = (v) => Array.isArray(v) && v.length > 0;
398
399
  * builder's flag, a parent (a child's own layer can be empty — its settings, elements and code inherited),
399
400
  * overrides of a parent's elements, settings, connections or texts, or FormVariables rows.
400
401
  */
401
- function hasV2Evidence(a) {
402
+ export function hasV2Evidence(a) {
402
403
  const schema = isObj(a.schema) ? a.schema : {};
403
404
  return (nonEmpty(schema.components) ||
404
405
  nonEmpty(schema.overrides) ||
@@ -414,7 +415,7 @@ function hasV2Evidence(a) {
414
415
  nonEmpty(a.variables));
415
416
  }
416
417
  /** An FB2 kind alone is weaker evidence: `Forms.type` is free text, and a 1.0 form can carry one. */
417
- const hasV2Kind = (a) => typeof a.type === "string" && V2_FORM_TYPES.has(a.type);
418
+ export const hasV2Kind = (a) => typeof a.type === "string" && V2_FORM_TYPES.has(a.type);
418
419
  /** A compiled bundle by its stamp and size — it is the build of `code`, ~the same size again. */
419
420
  function artifactSummary(art) {
420
421
  if (!isObj(art))
@@ -8,7 +8,7 @@
8
8
  * mutations lives one layer up (server.ts, mirroring server.py) — NOT here.
9
9
  */
10
10
  import { searchEntity, selectEntity, insertEntity, updateEntity, removeEntity, } from "../httpClient.js";
11
- import { ownProjection } from "../projection.js";
11
+ import { ownProjection, registerOwnProjections } from "../projection.js";
12
12
  import { dropDerivablePlainDescription, statusValue } from "../readEconomy.js";
13
13
  import { makeFilter, parseDeadline, parseProjectionParam, wrapHtml, jsonResponse, localDayRange, writeOutcome, notFoundAnswer, } from "../utils.js";
14
14
  import * as tenants from "../tenants.js";
@@ -16,11 +16,11 @@ import { config } from "../config.js";
16
16
  // ---------------------------------------------------------------------------
17
17
  // Field projections
18
18
  // ---------------------------------------------------------------------------
19
- // `ownProjection` marks these as THIS SERVER's, not the caller's: a tenant
20
- // that does not have one of these fields gets it pruned on first use instead of
21
- // failing every task read. Both spellings of the person who filed the task are
22
- // listed on purpose — tenants renamed `author` to `createdBy`, and whichever is
23
- // absent here is dropped once, per tenant.
19
+ // `ownProjection` marks these as THIS SERVER's, not the caller's: a field a
20
+ // tenant lacks is dropped before the read is sent (httpClient postEntityRead,
21
+ // checked with select/validate). The person who filed the task is `createdBy`:
22
+ // `author` is gone on every tenant, and asking for both put one 400 per process
23
+ // start per user in entity-builder's log (79 in 36 h, 2026-11-10/11).
24
24
  export const TASK_LIST_FIELDS = ownProjection({
25
25
  id: true,
26
26
  title: true,
@@ -30,7 +30,6 @@ export const TASK_LIST_FIELDS = ownProjection({
30
30
  updatedAt: true,
31
31
  estimatedDuration: true,
32
32
  assignedTo: { id: true, firstName: true, lastName: true, fullName: true },
33
- author: { id: true, fullName: true },
34
33
  createdBy: { id: true, fullName: true },
35
34
  project: { id: true, title: true },
36
35
  parent: { id: true, title: true },
@@ -57,6 +56,7 @@ export const TASK_DETAIL_FIELDS = ownProjection({
57
56
  children: { id: true, title: true },
58
57
  attachments: { id: true, fileName: true, filePath: true },
59
58
  });
59
+ registerOwnProjections("Tasks", { TASK_LIST_FIELDS, TASK_DETAIL_FIELDS });
60
60
  const _ACTIVE_STATES = ["active", "inprogress"];
61
61
  /** Build the Tasks filter list shared by searchTasks and countTasks. */
62
62
  function _taskFilters(my = false, active = false, overdue = false, dueToday = false, projectId = null, workflowId = null, stageId = null, assignedToId = null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suppa-mcp-2",
3
- "version": "1.44.4",
3
+ "version": "1.45.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": {
@@ -41,7 +41,9 @@
41
41
  "form:gate": "node skills/suppa-form-v2/scripts/validate-form-schema.mjs",
42
42
  "sync:formbuilder": "node scripts/sync-formbuilder.mjs",
43
43
  "sync:vue-compiler": "node scripts/sync-vue-compiler.mjs",
44
- "guards:install": "node skills/suppa-entity-code/scripts/install-entity-code-guards.mjs"
44
+ "guards:install": "node skills/suppa-entity-code/scripts/install-entity-code-guards.mjs",
45
+ "check:projections": "node scripts/check-own-projections.mjs",
46
+ "sync:code-form": "node scripts/sync-code-form.mjs"
45
47
  },
46
48
  "keywords": [
47
49
  "mcp",
@@ -65,6 +67,7 @@
65
67
  "dependencies": {
66
68
  "@modelcontextprotocol/sdk": "^1.30.0",
67
69
  "@napi-rs/keyring": "^1.1.0",
70
+ "typescript": "~5.9.3",
68
71
  "zod": "^3.23.8"
69
72
  },
70
73
  "devDependencies": {
@@ -72,7 +75,6 @@
72
75
  "@vue/compiler-dom": "3.5.12",
73
76
  "acorn": "8.15.0",
74
77
  "esbuild": "^0.21.5",
75
- "typescript": "^5.6.0",
76
78
  "vitest": "^2.1.0"
77
79
  }
78
80
  }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: suppa-cli
3
- description: Use when working with a Suppa 2.0 tenant from a terminal — tasks, records, entities, custom fields, docs, forms, automations, file attachments. The `suppa` command carries all 106 operations with browser-based login and token storage in the OS keychain. Prefer it over hand-written HTTP calls: validates arguments before sending and explains platform refusals.
3
+ description: Use when working with a Suppa 2.0 tenant from a terminal — tasks, records, entities, custom fields, docs, forms, automations, file attachments. The `suppa` command carries all 108 operations with browser-based login and token storage in the OS keychain. Prefer it over hand-written HTTP calls: validates arguments before sending and explains platform refusals.
4
4
  ---
5
5
 
6
6
  # Suppa 2.0 from the shell
@@ -182,6 +182,12 @@ and the write compile `compiledRender` (the browser production build the builder
182
182
  stored render canonically, never byte for byte. Contract:
183
183
  `suppa form-kb --mode note --topic dynamicComponent`; custom chart: `--mode ref --topic custom-chart`.
184
184
 
185
+ ## The form's code (Code Form)
186
+
187
+ `code` (TypeScript against `formAPI`) is never written by `write-form-draft`:
188
+ `suppa form-code --mode <rules|pull|api|check>`, then `suppa push-form-code --form-id <id>`.
189
+ Rules: `references/code-form.md`.
190
+
185
191
  ## References
186
192
 
187
193
  Read on demand, never up front — `suppa form-kb --mode ref --topic <name>`.
@@ -198,5 +204,6 @@ Read on demand, never up front — `suppa form-kb --mode ref --topic <name>`.
198
204
  | `references/styling.md` | Contrast, options before CSS, `theme`/`styleIntent`, custom SCSS |
199
205
  | `references/card-kit.md` | The record-card kit: a record card, a create form, a window |
200
206
  | `references/publishing.md` | The write path, metadata columns, the Localizations registry, entity plans |
207
+ | `references/code-form.md` | The form's code: `formAPI`, events, imports, the build on save, conflicts |
201
208
  | `notes/dynamicComponent.md` | Any dynamicComponent: sandbox, formAPI, styles, translations |
202
209
  | `notes/<type>.md` | Behaviour of one type — `suppa form-kb --mode note --topic <type>` |
@@ -0,0 +1,19 @@
1
+ {
2
+ "source": "platform-front (suppa front)",
3
+ "ref": "origin/backend2/develop",
4
+ "commit": "41a0f90a2e426b8a745353cf29685feab24202aa",
5
+ "committed": "2026-11-12",
6
+ "pulledAt": "2026-11-12",
7
+ "files": {
8
+ "code-form/sdk/index.d.ts": {
9
+ "from": "src/formBuilderV2/codeForm/virtualProject/generatedSdkDts.ts (CODE_FORM_SDK_DTS)",
10
+ "bytes": 7179872,
11
+ "sha256": "8b52fdbb860ed921942fb89d3925848e674e433e6199381e83368c30f9bf50f7"
12
+ },
13
+ "scripts/code-form/code-form-core.mjs": {
14
+ "from": "codeForm/typeGen, codeForm/virtualProject, codeForm/diagnostics, codeForm/files, chart/custom/customChartSchema, shared/dynamicWidget/widgetApiKeys",
15
+ "bytes": 22840
16
+ }
17
+ },
18
+ "why": "Vendored, not depended on. The backend builds a form's code against ITS OWN SDK copy, so a check against a stale snapshot can pass here and fail on save (or the reverse) — re-run scripts/sync-code-form.mjs after every front release that touches Code Form."
19
+ }