suppa-mcp-2 1.35.0 → 1.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -600,11 +600,12 @@ string and is typed by shape — right there, W620 anywhere else.
600
600
  Those, plus
601
601
  `owner` first in a tabular part's `importKeyFields` (W607) and no `inverse` on
602
602
  `@ManyToOne`/`@ManyToMany` (W609), are the **rule violations** — W607, W609,
603
- W610, W611, W612, W613, W615, W616, W617, W618, W620 — and like errors they exit 1, because a
603
+ W610, W611, W612, W613, W615, W616, W617, W618, W619, W620, W621, W622, W623, W625 — and like errors they exit 1, because a
604
604
  rule that only warns is a rule that gets ignored. `--no-strict` demotes them for a legacy repo, and says so:
605
605
  they print as `[rule violation, demoted]` and the summary ends `NOT a clean
606
- run`. Advisory warnings — W601-W606, W608, W614 — never block; they report what
607
- the checker could not see.
606
+ run`. Advisory warnings — W601-W606, W608, W614, W624 — never block; they report what
607
+ the checker could not see. W624 is the one to read rather than skim: it names a
608
+ check that could NOT run, which is not the same as a check that passed.
608
609
 
609
610
  Tabular parts (owned child sub-tables like checklist items or order lines)
610
611
  and the remove-and-re-add-a-field semantics — a re-added field restores its
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suppa-mcp-2",
3
- "version": "1.35.0",
3
+ "version": "1.36.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": {
@@ -131,7 +131,9 @@ Confirm all 5 before writing anything:
131
131
 
132
132
  On an entity you do **not** own, the columns still come from your file — only the switch is out of reach: extension mode ignores entity options, so enable the feature once with `suppa_update_entity_options(entity_name, '{"customFields": true}')` (`POST /core/builder/<Entity>/update-options`). That is what W618 means when it fires on `options`.
133
133
 
134
- The gate enforces all of it — E124 (nested class registered, decorated or extending a base class), E125 (property name), E126 (primary / reverse relation), E127 (`nullable: false` without a default), E128 (half a context), E129 (SDK below 1.38.0), E130 (one class shared by two owners), W621 (column with no set), W622 (`contextField` not on the owner), W623 (the option written beside the decorator), W625 (a number as `contextValue` on an enum context field — that is an Enums row id copied off one tenant, not the stored value). Start from `templates/custom-fields.template.ts`.
134
+ **An extension whose only member is `@CustomFields` is complete** — it declares the columns of the generated table and nothing else, and the gate treats that as declaring plenty. W617 ("adds nothing") fires only on a class that declares neither columns nor `@CustomFields`; on a stub, `@CustomFields` is E117 like any other field, because the columns it names land on a tenant you do not own.
135
+
136
+ The gate enforces all of it — E124 (nested class registered, decorated or extending a base class), E125 (property name), E126 (primary / reverse relation), E127 (`nullable: false` without a default), E128 (half a context), E129 (SDK below 1.38.0), E130 (one class shared by two owners), W621 (column with no set), W622 (`contextField` not on the owner — owner mode only; in extension mode the owner's fields are declared elsewhere, so you get the advisory W624 instead of a block), W623 (the option written beside the decorator), W625 (a number as `contextValue` on an enum context field — that is an Enums row id copied off one tenant, not the stored value). Start from `templates/custom-fields.template.ts`.
135
137
 
136
138
  Two limits from the API reference: the extension table is capped at `CUSTOM_FIELDS_LIMIT` active custom fields (**default 200** — the cap guards the API, not migrations, so a long port can push a table past it and the API then stops serving it; the MCP tools that add fields report where the table stands), and a set declared for a context value applies to that value's **descendants** when the context field points at a hierarchical entity, so one entry covers a subtree.
137
139
 
@@ -238,9 +238,9 @@ The migrations page links to a separate [custom fields API reference](https://do
238
238
  | E129 | `@suppa/sdk` pinned below 1.38.0 in `package.json` |
239
239
  | E130 | one class named by `@CustomFields` on two owners |
240
240
  | W621 | a column with no `customFieldSets` — no record shows it |
241
- | W622 | `contextField` names no field on the owner |
241
+ | W622 | `contextField` names no field on the owner — **owner mode only**, where the file declares the whole entity. Inherited `SystemBaseEntity` columns (`id`, `createdAt`, `updatedAt`, `deletedAt`, `createdBy`, `removedBy`) count as fields on the owner and never trip it |
242
242
  | W623 | `options: { customFields: true }` written beside the decorator that implies it |
243
- | W624 | advisory: the nested class is declared in another file, or the SDK range cannot be read, so a check was skipped |
243
+ | W624 | advisory: the nested class is declared in another file, the SDK range cannot be read, or the class is an **extension** — there the owner's own fields are declared elsewhere, so `contextField` cannot be checked against them and W622 would be guesswork. Reported once per class, and never blocks |
244
244
  | W625 | a number as `contextValue` on an `@Enum` context field — an id, where the stored value belongs |
245
245
 
246
246
  ## Which route to take
@@ -769,6 +769,30 @@ function analyzeEntities(ts, sf, model, opts = {}) {
769
769
  });
770
770
  }
771
771
 
772
+ /**
773
+ * Every member the class DECLARES — which is NOT the same as `info.properties`.
774
+ *
775
+ * `info.properties` holds what became a COLUMN, and `@CustomFields` is
776
+ * deliberately kept out of it so no field rule treats it as one (see the
777
+ * CustomFields branch in collectEntities). Four rules then ask "does this class
778
+ * declare anything at all?" — W617 twice, E117 and W616 — and reading
779
+ * `properties.size` for that turned a class whose only member is `@CustomFields`
780
+ * into a class that declares nothing. That shipped: an extension holding one
781
+ * @CustomFields class, the exact form SKILL.md rule 22 prescribes for an entity
782
+ * you do not own, was told it "adds nothing" and the gate blocked it. The owner
783
+ * variant of the same class was told to rename itself to a stub, which would
784
+ * then have tripped E117.
785
+ *
786
+ * ANY future member kept off `properties` for the same reason must be added
787
+ * here, or those four rules go blind to it again. This is the one place that
788
+ * knows the difference between "declares no columns" and "declares nothing".
789
+ */
790
+ function declaredMembers(info) {
791
+ const names = [...info.properties.keys()];
792
+ if (info.customFieldsProp) names.push(info.customFieldsProp.propName);
793
+ return names;
794
+ }
795
+
772
796
  // ── rules: custom fields declared in code (@suppa/sdk 1.38.0) ──
773
797
  /**
774
798
  * `@CustomFields(() => Cls)` on an owner entity, with Cls a PLAIN class of
@@ -950,12 +974,22 @@ export function sdkFloorProblem(rootDir, floorText = "1.38.0") {
950
974
 
951
975
  /** Every property of the nested class is one custom field. */
952
976
  function checkCustomFieldColumns(ts, info, cls, findings) {
953
- const ownerFields = new Set();
977
+ // Seeded with the inherited columns: every entity extends SystemBaseEntity,
978
+ // so id/createdAt/updatedAt/deletedAt/createdBy/removedBy are fields ON THE
979
+ // OWNER that are never written in the file. Keying a context on one of them
980
+ // is legal, and comparing against declared properties alone called it a
981
+ // field the owner does not declare.
982
+ const ownerFields = new Set(SYSTEM_COLUMNS);
954
983
  for (const [propName, prop] of info.properties) {
955
984
  ownerFields.add(propName);
956
985
  const colName = stringValue(ts, prop.nameNode);
957
986
  if (colName) ownerFields.add(colName);
958
987
  }
988
+ // In extension mode the owner's field list is not in this file, so
989
+ // contextField cannot be checked against it. Collected here and reported ONCE
990
+ // per class: one advisory per column per set would drown the real findings.
991
+ const extensionMode = isExtensionFileName(info.sf.fileName);
992
+ const unverifiedContexts = new Set();
959
993
 
960
994
  for (const member of cls.members ?? []) {
961
995
  if (!member.name) continue;
@@ -1052,14 +1086,33 @@ function checkCustomFieldColumns(ts, info, cls, findings) {
1052
1086
  }
1053
1087
  // "contextField — Name of the field ON THE OWNER whose value decides the
1054
1088
  // context. It must exist on the owner."
1055
- if (cfName && ownerFields.size > 0 && !ownerFields.has(cfName)) {
1056
- findings.push(finding(ts, info.sf, cfNode, "W622",
1057
- `'${propName}' keys its context on '${cfName}', which '${info.className}' does not declare — ` +
1058
- `contextField must name a field ON THE OWNER. The migration resolves the context inside the ` +
1059
- `write transaction, so an unresolvable one fails the whole start, not just this field.`));
1089
+ //
1090
+ // Only decidable when this file describes the whole owner. An EXTENSION
1091
+ // declares its own columns on a table another application owns, so the
1092
+ // owner's other fields are not here to be found and their absence proves
1093
+ // nothing — blocking on it would fail the very shape rule 22 prescribes
1094
+ // for an entity you do not own. Report it as a check that could not run.
1095
+ if (cfName && !ownerFields.has(cfName)) {
1096
+ if (extensionMode) {
1097
+ unverifiedContexts.add(cfName);
1098
+ } else {
1099
+ findings.push(finding(ts, info.sf, cfNode, "W622",
1100
+ `'${propName}' keys its context on '${cfName}', which '${info.className}' does not declare — ` +
1101
+ `contextField must name a field ON THE OWNER. The migration resolves the context inside the ` +
1102
+ `write transaction, so an unresolvable one fails the whole start, not just this field.`));
1103
+ }
1060
1104
  }
1061
1105
  }
1062
1106
  }
1107
+
1108
+ if (unverifiedContexts.size > 0) {
1109
+ findings.push(finding(ts, info.sf, info.customFieldsProp.node, "W624",
1110
+ `'${info.className}' is an EXTENSION, so the owner's own fields are declared by whoever owns ` +
1111
+ `'${info.entityName}', not in this file — contextField ${[...unverifiedContexts].map((n) => `'${n}'`).join(", ")} ` +
1112
+ `could NOT be checked against them. Confirm each one exists on '${info.entityName}' ` +
1113
+ `(suppa_describe_entity("${info.entityName}")): the migration resolves the context inside the write ` +
1114
+ `transaction, so an unresolvable one fails the whole start, not just this field. Advisory — it does not block.`));
1115
+ }
1063
1116
  }
1064
1117
 
1065
1118
  // ── rules: tabular parts ──
@@ -2018,7 +2071,11 @@ function checkExtension(ts, info, findings) {
2018
2071
  : "")));
2019
2072
  }
2020
2073
 
2021
- if (info.properties.size === 0) {
2074
+ // declaredMembers, NOT properties.size: an extension whose only member is
2075
+ // @CustomFields contributes the columns of the nested class, and rule 22
2076
+ // prescribes exactly that shape for an entity you do not own — "the custom
2077
+ // field COLUMNS still come from your file, only the switch is an owner action".
2078
+ if (declaredMembers(info).length === 0) {
2022
2079
  findings.push(finding(ts, sf, anchor, "W617",
2023
2080
  `extension '${info.className}' declares no columns, so it adds nothing to ${target} — ` +
2024
2081
  `an extension exists to contribute fields. If you only need the entity as a RELATION TARGET, that is a ` +
@@ -2541,7 +2598,11 @@ function checkStubFiles(ts, model, findings) {
2541
2598
  const stubFile = isStubFileName(infos[0].sf.fileName);
2542
2599
  for (const info of infos) {
2543
2600
  const anchor = info.node.name ?? info.node;
2544
- const fields = info.properties.size;
2601
+ // declaredMembers, NOT properties.size — see its doc comment. A class
2602
+ // whose only member is @CustomFields declares plenty; counting columns
2603
+ // made it look empty to all three rules below at once.
2604
+ const members = declaredMembers(info);
2605
+ const fields = members.length;
2545
2606
 
2546
2607
  // The whole point of a stub is the EMPTY body: it names a table another
2547
2608
  // application owns, and any field it declares is a column the migration
@@ -2549,10 +2610,19 @@ function checkStubFiles(ts, model, findings) {
2549
2610
  // that KEPT its fields is the failure this catches — it used to pass.
2550
2611
  if (stubFile && fields > 0) {
2551
2612
  findings.push(finding(ts, info.sf, anchor, "E117",
2552
- `stub '${info.className}' declares ${fields} field(s) (${[...info.properties.keys()].slice(0, 4).join(", ")}` +
2613
+ `stub '${info.className}' declares ${fields} field(s) (${members.slice(0, 4).join(", ")}` +
2553
2614
  `${fields > 4 ? ", …" : ""}) — a stub stands in for a table this application does NOT own, and every ` +
2554
2615
  `field it declares is a column the migration will create or alter on that real table. The body must ` +
2555
- `be EMPTY. If this entity IS yours to describe, it is not a stub: move it to ` +
2616
+ `be EMPTY.` +
2617
+ // @CustomFields declares columns just as surely as @Column does, only
2618
+ // on the generated {Owner}CustomFields table — and it is the member a
2619
+ // stub is most likely to be given by mistake, because the columns sit
2620
+ // in a class one level down and do not look like the stub's own body.
2621
+ (info.customFieldsProp
2622
+ ? ` @CustomFields counts: the nested class it names becomes the columns of ` +
2623
+ `'${info.entityName}CustomFields', a table on that same tenant.`
2624
+ : "") +
2625
+ ` If this entity IS yours to describe, it is not a stub: move it to ` +
2556
2626
  `${kebabOf(info.className)}.entity.ts and describe it there. If you mean to ADD columns to an entity ` +
2557
2627
  `another application owns, that is an extension, not a stub — declare only your own columns in ` +
2558
2628
  `${kebabOf(info.entityName)}.extension.entity.ts (see SKILL.md rule 20)`));