suppa-mcp-2 1.44.0 → 1.44.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suppa-mcp-2",
3
- "version": "1.44.0",
3
+ "version": "1.44.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": {
@@ -158,7 +158,7 @@ Confirm all 6 before writing anything:
158
158
  24. **Names the platform keeps for itself, and the index it already builds.** Read from entity-builder, the platform's own repository, each one a refusal or a broken migration when ignored:
159
159
 
160
160
  - An entity name must not END in a companion-table suffix — `Comments`, `CommentReactions`, `Reactions`, `Favorites`, `Approves`, `Approvers`, `Folders`, `Checklists`, `CustomFields`, `StateHistory`. The platform generates `<Entity><Suffix>` tables when the matching option is switched on and refuses the name outright. **E131.**
161
- - A field must not be named `parent`, `parents`, `children`, `multiChildren`, `comments`, `reactions`, `favorites`, `approves`, `approvers`, `folders`, `items`, `checklists`, `customFields`, `pinned`, `timeTracking`, `spentTime`, `spentTimeTotal` or `searchVector` — those are generated by entity options or owned by search — nor shaped like a multi-type synthetic column (`f12Type`). The platform's field-name guard answers HTTP 400. **E132.**
161
+ - A field must not be named `parent`, `parents`, `children`, `multiChildren`, `comments`, `reactions`, `favorites`, `approves`, `approvers`, `folders`, `items`, `checklists`, `customFields`, `pinned`, `timeTracking`, `spentTime`, `spentTimeTotal` or `searchVector` — those are generated by entity options or owned by search — nor shaped like a multi-type synthetic column (`f12Type`). The builder's field-name guard answers HTTP 400; an application's sync passes it, and once the option is switched on the platform keeps the declared field as its own, whatever its shape. **E132.** One exception is only advisory: `parent` as a `@ManyToOne` or `parents` as a `@ManyToMany` onto the entity itself — and its `children` (`@OneToMany`) / `multiChildren` (`@ManyToManyBackRef`) back reference — with no `hierarchy` option on the entity. That is the pair the option creates; switching `hierarchy` on later keeps it and adds nothing. Without the option nothing refuses a loop (A → B → A). **W641 (advisory).** For a new tree, prefer the option itself.
162
162
  - A relation, enum or file field `owner` is stored in a physical column `ownerId`; a scalar column named `ownerId` beside it claims the same column, and the two silently fought over it until the guard learned to refuse. **E133.**
163
163
  - **Never `@Index` a single `@ManyToOne`, `@Enum` or `@File` column, or a single `unique` column.** metadata-sync registers an index for every one of them on its own — an enum and a file are many-to-one references to `Enums`/`Files` (`ColumnBuilderUtils.isManyToOne`, entity-builder `column-builder.util.ts:37-43`); a declared duplicate produces the same `IndexMetadata` key, the bulk insert during sync fails with `23505`, and the tenant migration rolls back — the database does not come up. Composite indexes that include a relation column (`['owner', 'type']`) are a different key and are fine. **W628, and it fails the gate.**
164
164
  - **Never two `@Index` over the same column set with the same `unique`/`where`.** An `IndexMetadata` key is the entity, the SORTED column names, `unique` and `where` — not the name, not the order — so `['a', 'b']` and `['b', 'a']` are one key and the import keeps one of them. The physical index follows the declared order (entity-builder `d69f0ee1`); on an existing tenant, reordering the columns alone rebuilds nothing, because the import compares the set. **W634, and it fails the gate.**
@@ -446,6 +446,7 @@ The validator parses with the TypeScript compiler API, read from the app repo yo
446
446
  | An extension sets `title` / `representativeFieldName` / `importKeyFields` and nothing happens | Extension mode ignores every entity-level option — they belong to the owner | W618 (blocks the gate) |
447
447
  | The tenant migration fails with `23505 duplicate key value violates unique constraint "IndexMetadataKeyIndex"` and the database does not come up | An `@Index` over a single `@ManyToOne`, `@Enum`, `@File` or `unique` column — metadata-sync already indexes those | W628 (blocks the gate) |
448
448
  | `cannot declare field "X.parent"` / HTTP 400 from the field-name guard, or an entity name refused at start | A platform-owned field name, a multi-type-shaped name, a `<x>Id` scalar beside relation `<x>`, or a reserved entity suffix | E132 / E133 / E131 |
449
+ | `parent`/`parents` (or its `children`/`multiChildren` back reference) onto the entity itself, no `hierarchy` option, and the gate only warns | The pair the hierarchy option would create; switching the option on later keeps it | W641 (advisory) |
449
450
  | A label is blank in the Ukrainian UI, or a translation you wrote never appears | `title` was a plain string (stored as `en` only), used `ua` instead of `uk` (dropped silently), or carried an `id` (read as a reference) | W626 (blocks the gate); W627 for a title whose languages differ from the rest |
450
451
  | An extension declares `@OneToMany` / `@ManyToManyBackRef` | A reverse relation creates a field on the OTHER entity; declare the owning side here instead | E118 |
451
452
  | An extension declares `primary: true` | The owner's primary key is not yours to redefine | E119 |
@@ -96,7 +96,12 @@ wrong type too (**E503**):
96
96
  feature off you omit the key. Every option is a schema change rather than a preference — "Enabling
97
97
  an option creates the side table that backs it" (builder doc) — and the fields an option generates
98
98
  (`parent`, `parents`, `children`, `multiChildren`, `spentTime`, `comments`, …) are names you may not
99
- declare yourself (**E132**).
99
+ declare yourself (**E132**): an application's sync passes the field-name guard, and once the option is
100
+ switched on the platform keeps the declared field as its own, whatever its shape. The one advisory
101
+ case is `parent` (`@ManyToOne`) or `parents` (`@ManyToMany`) onto the entity itself — with its
102
+ `children` / `multiChildren` back reference — while `hierarchy` is off: it is the pair the option
103
+ would create, and switching the option on later keeps it rather than adding a second one
104
+ (**W641**). Without the option nothing refuses a loop.
100
105
 
101
106
  On an entity you do **not** own, extension mode ignores `options` wholesale (**W618**), so a feature
102
107
  cannot be switched on from a file there — and not at runtime either. Since entity-builder c165fc4d
@@ -41,7 +41,7 @@ export const BLOCKING_SUMMARY =
41
41
  "duplicate key aborts the tenant migration (W628); an enum titles map keyed by the stored VALUE, or the title is " +
42
42
  "never stored (W637); a platform entity's name (Users, Forms, …) only in <name>.extension.entity.ts, where " +
43
43
  "extension mode's rules apply (W636); no entity name ending in a reserved companion-table suffix " +
44
- "(E131), no platform-owned field name such as parent/comments/customFields/searchVector (E132), no " +
44
+ "(E131), no platform-owned field name such as parent/comments/customFields/searchVector (E132; a self-referencing parent/parents and its back reference with hierarchy off is only advisory, W641), no " +
45
45
  "scalar `<x>Id` beside a relation `<x>` (E133); and inside @Entity({ options }) only the platform's " +
46
46
  "feature options, each with the type it takes — hierarchy and folders are \"single\" or \"multi\", never " +
47
47
  "a boolean (E503); no two @Index over one column set with the same unique/where — name and order are not " +
@@ -137,6 +137,8 @@ export const RULE_WARNINGS = [
137
137
  // W638 (an enum value that is a field-option name) and W639 (definePermissions on a stand whose runner
138
138
  // has no such function) are ADVISORY: the first depends on a titles map the checker may not see whole,
139
139
  // the second on which stands the app deploys to, which nothing in the repo says.
140
+ // W641 (a self-referencing parent/parents, or its children/multiChildren back reference, with hierarchy
141
+ // off) is ADVISORY: it is the pair the option would create, and switching the option on keeps it.
140
142
  ];
141
143
  /**
142
144
  * The @suppa/sdk extension-runner ships, PER STAND — the copy an application's
@@ -1361,6 +1363,71 @@ function checkCustomFieldColumns(ts, info, cls, findings, model) {
1361
1363
  }
1362
1364
 
1363
1365
  // ── rules: tabular parts ──
1366
+ /**
1367
+ * The relation kind the hierarchy option creates under each name
1368
+ * (entity-builder hierarchy-option.service.ts: `parents` many-to-many for
1369
+ * "multi", `parent` many-to-one otherwise), always onto the entity itself.
1370
+ */
1371
+ const HIERARCHY_FIELD_KINDS = new Map([["parent", "many-to-one"], ["parents", "many-to-many"]]);
1372
+ /**
1373
+ * W641 — `parent`/`parents` declared as exactly the field the hierarchy option
1374
+ * would create, on an entity whose `hierarchy` is visibly off. The platform
1375
+ * takes it in its stride (entity-builder develop 3b05618cd; the files below
1376
+ * unchanged on develop bb7c35c4, 2026-10-27):
1377
+ *
1378
+ * - an application's sync never meets the field-name guard: the app's metadata
1379
+ * arrives as an import, whose writes carry importLogic, and the guard returns
1380
+ * under importLogic/migration (field-name-conflict-guard.extension.ts:101,
1381
+ * :151, :317); on update it checks reserved names only on a rename (:217);
1382
+ * - the hierarchy MACHINERY runs only with options.hierarchy — the loop and
1383
+ * depth guard (hierarchy-graph.service.ts:81, through hierarchy-depth-guard),
1384
+ * cascade remove (hierarchy-cascade-remove.extension.ts:57), the time-
1385
+ * tracking roll-up (time-tracking-spent-time-total.service.ts:42). Two READ
1386
+ * paths key on the name alone and treat such a field as a tree already — a
1387
+ * select that asks for `hierarchy` (modules/entity/hierarchy
1388
+ * resolveHierarchyField) and a manual order grouped by the field
1389
+ * (custom-order.service.ts isHierarchyField): harmless, and said;
1390
+ * - switching the option on later skips the option's setup when a field of
1391
+ * that name exists (entity-options.service.ts:448-460) — and that setup is
1392
+ * only the field and its back reference (hierarchy-option.service.ts).
1393
+ *
1394
+ * Renaming such a field is the expensive move — without a `key` it is a drop
1395
+ * and create of the relation's data — so the gate must not demand it. Off-
1396
+ * canonical spellings, another target, the other kind, extension mode, and
1397
+ * options that cannot be read all stay E132.
1398
+ */
1399
+ function isUnhierarchicalSelfParent(ts, info, name, prop) {
1400
+ if (info.isExtension || info.optionsUnreadable) return false;
1401
+ if (HIERARCHY_FIELD_KINDS.get(name) !== prop.kind) return false;
1402
+ if (prop.targetClass !== info.className) return false;
1403
+ if (spreadElements(ts, unwrapExpr(ts, info.optionsNode)).length) return false;
1404
+ const slot = info.options.get("options");
1405
+ if (!slot) return true;
1406
+ const obj = unwrapExpr(ts, slot);
1407
+ if (!ts.isObjectLiteralExpression(obj) || spreadElements(ts, obj).length) return false;
1408
+ return !objectMap(ts, obj).has("hierarchy");
1409
+ }
1410
+ /** The back reference the option pairs with each field (hierarchy-option.service.ts `backReference`). */
1411
+ const HIERARCHY_BACK_REFERENCES = new Map([
1412
+ ["children", { kind: "one-to-many", of: "parent" }],
1413
+ ["multiChildren", { kind: "many-to-many-backref", of: "parents" }],
1414
+ ]);
1415
+ /**
1416
+ * W641's back reference — `children` (@OneToMany) / `multiChildren`
1417
+ * (@ManyToManyBackRef) onto the entity itself whose inverse selects a W641
1418
+ * `parent` / `parents`: the pair the option would create, declared by hand
1419
+ * (crm Activities and Opportunities, 2026-10-27). Switching the option on later
1420
+ * skips its setup because the parent field exists, so no second back
1421
+ * reference appears; nothing keys on the back reference's name.
1422
+ */
1423
+ function isUnhierarchicalSelfChildren(ts, info, name, prop) {
1424
+ const back = HIERARCHY_BACK_REFERENCES.get(name);
1425
+ if (!back || prop.kind !== back.kind || prop.targetClass !== info.className) return false;
1426
+ const accessed = inverseAccessedProperty(ts, prop.inverseNode);
1427
+ const owner = accessed ? info.properties.get(accessed) : null;
1428
+ if (!owner || (stringValue(ts, owner.nameNode) ?? accessed) !== back.of) return false;
1429
+ return isUnhierarchicalSelfParent(ts, info, back.of, owner);
1430
+ }
1364
1431
  /**
1365
1432
  * E131 / E132 / E133 — names the platform will refuse or silently collide on.
1366
1433
  *
@@ -1375,6 +1442,8 @@ function checkCustomFieldColumns(ts, info, cls, findings, model) {
1375
1442
  * multi-type synthetic column (`f12Type`). The former is generated by the
1376
1443
  * platform when an option is enabled and the guard answers 400 on a client
1377
1444
  * field of that name; the latter collides with columns the platform mints.
1445
+ * The hierarchy pair is W641 instead when the option is off — see
1446
+ * isUnhierarchicalSelfParent and isUnhierarchicalSelfChildren.
1378
1447
  * - E133: a scalar column named `<x>Id` beside a relation/enum/file `<x>`
1379
1448
  * (or the reverse). The relation's PHYSICAL column is `<x>Id`; two fields
1380
1449
  * then claim one column, both sides of the DDL used to swallow it in
@@ -1405,12 +1474,35 @@ function checkReservedNames(ts, info, findings) {
1405
1474
  // with the platform's `parent` exactly as the canonical spelling does.
1406
1475
  const reserved = RESERVED_FIELD_NAMES_LOWER.get(name.toLowerCase());
1407
1476
  if (reserved) {
1477
+ if (isUnhierarchicalSelfParent(ts, info, name, prop)) {
1478
+ findings.push(finding(ts, sf, prop.nameNode ?? prop.node, "W641",
1479
+ `'${name}' on '${info.className}' is a ${prop.kind} onto the entity itself — the field the ` +
1480
+ `\`hierarchy\` option creates under that name, and the option is off here. The platform takes it as a ` +
1481
+ `plain relation: an application's sync is not subject to the field-name guard, and the hierarchy ` +
1482
+ `machinery (the loop and depth guard, cascade remove, the time-tracking roll-up) runs only with ` +
1483
+ `options.hierarchy — so nothing refuses a loop (A → B → A) here, while a select that asks for ` +
1484
+ `\`hierarchy\` and a manual order grouped by '${name}' already treat it as a tree. If \`hierarchy\` is ` +
1485
+ `switched on later, the platform keeps this field and skips its own setup, the ` +
1486
+ `${name === "parent" ? "children" : "multiChildren"} back reference with it. Advisory — for a new tree, ` +
1487
+ `switch the option on instead.`));
1488
+ continue;
1489
+ }
1490
+ if (isUnhierarchicalSelfChildren(ts, info, name, prop)) {
1491
+ const of = HIERARCHY_BACK_REFERENCES.get(name).of;
1492
+ findings.push(finding(ts, sf, prop.nameNode ?? prop.node, "W641",
1493
+ `'${name}' on '${info.className}' is the back reference of '${of}' — the pair the \`hierarchy\` option ` +
1494
+ `would create, declared by hand with the option off. It is a plain reverse relation, and switching the ` +
1495
+ `option on later adds no second one: the platform keeps '${of}' and skips its own setup. Advisory.`));
1496
+ continue;
1497
+ }
1408
1498
  findings.push(finding(ts, sf, prop.nameNode ?? prop.node, "E132",
1409
1499
  `'${name}' is a field name the platform owns${reserved !== name ? ` (its canonical spelling is '${reserved}')` : ""} — it is generated when the matching entity option is ` +
1410
1500
  `switched on (hierarchy → parent/children, comments, favorites, time tracking → spentTime, …) or held ` +
1411
- `by the search machinery (searchVector). The platform's field-name guard refuses a declared field of ` +
1412
- `that name with HTTP 400 on every builder and data write; a sync that carries schema authority passes ` +
1413
- `the guard and collides later, the moment the option is switched on. Rename it. ` +
1501
+ `by the search machinery (searchVector). The platform's field-name guard refuses a field of that ` +
1502
+ `name with HTTP 400 when the builder creates or renames one; an application's sync is not subject to ` +
1503
+ `the guard, so the declaration lands — and once the option is switched on, the platform keeps it as ` +
1504
+ `the option's own field whatever its shape (it creates a field of that name only when none exists), ` +
1505
+ `so the option runs on a field it did not shape. Rename it. ` +
1414
1506
  `Reserved: ${RESERVED_FIELD_NAMES.join(", ")}.`));
1415
1507
  continue;
1416
1508
  }