suppa-mcp-2 1.2.1 → 1.2.2

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
@@ -304,7 +304,9 @@ resolving to the right parent, and `owner` first in `importKeyFields`
304
304
  when resolvable, falling back to the doc tables otherwise
305
305
  (E101/E102/E107/E501/E502). Options/records/registration arrays delivered via
306
306
  spread or by reference can't be statically checked and fire a W606 warning
307
- instead. Exit code 1 on any error. Use the `write_entity_code` MCP prompt to
307
+ instead. An entity or seed left out of `EntityModule.forFeature()` fires
308
+ E301/E302, naming the module file to edit so the fix is a find-and-add, not a
309
+ search. Exit code 1 on any error. Use the `write_entity_code` MCP prompt to
308
310
  drive it from any client.
309
311
 
310
312
  Tabular parts (owned child sub-tables like checklist items or order lines)
package/dist/server.js CHANGED
@@ -1658,13 +1658,17 @@ export function buildServer() {
1658
1658
  "relations via thunks (@ManyToOne(() => Target)); fixed choices via @Enum('Entity.field', ...); attachments via @File/@MultiFile; " +
1659
1659
  "'default' is a SQL expression STRING ('false', \"'draft'\") — never a JS value. Repeating rows owned by one parent record " +
1660
1660
  "(checklist items, order lines) are a TABULAR PART, not a plain entity: type: 'tabular-part' + relationEntityName + a @ManyToOne " +
1661
- "field named owner, with owner first in importKeyFields (see references/tabular-parts.md).\n" +
1661
+ "field named owner, with owner first in importKeyFields (see references/tabular-parts.md). " +
1662
+ "Registering the class is part of writing it: add it to EntityModule.forFeature([...]) in the app module " +
1663
+ '(find it with grep -rn "EntityModule.forFeature" src/) in the same step — an unregistered class gets no table.\n' +
1662
1664
  "4. Write matching *.seed.ts with createSeed(): every importKeyField in every record (or $key); relations referenced by import key " +
1663
1665
  "({ name: 'Default' }) — never numeric ids; never system columns, access metadata, or reverse @OneToMany fields.\n" +
1664
- "5. Register in EntityModule.forFeature([entities], { seeds }) — dependencies' seeds first.\n" +
1666
+ "5. Export the entity and seed from their barrels (entities/index.ts, seeds/index.ts), and add the seed to " +
1667
+ "EntityModule.forFeature()'s seeds array, positioned after the seeds of everything it references — dependencies first.\n" +
1665
1668
  "6. Gate before claiming done: node node_modules/suppa-mcp-2/skills/suppa-entity-code/scripts/validate-suppa-schema.mjs <app-root> " +
1666
1669
  "(or the skills/ dir of a checkout) reports 0 errors; npx tsc --noEmit passes; " +
1667
- "push, reload (POST /core/applications/:appId/reload), verify with suppa_describe_entity.\n" +
1670
+ "push, reload (POST /core/applications/:appId/reload), verify with suppa_describe_entity — " +
1671
+ "the gate fails with E301 if anything is unregistered — run it, do not assume.\n" +
1668
1672
  "Porting from Suppa 1.0? Read the schema with suppa_read_v1_entity_props / suppa_read_v1_enum and map per references/v1-mapping.md — " +
1669
1673
  "never invent a mapping; record data stays with suppa_migrate_entities_from_v1.");
1670
1674
  return server;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suppa-mcp-2",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
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": { "suppa-mcp": "dist/bin.js" },
@@ -40,15 +40,16 @@ Confirm all 5 before writing anything:
40
40
  ## Hard rules
41
41
 
42
42
  1. Every entity extends `SystemBaseEntity`; never declare `id`, `createdAt`, `updatedAt`, `deletedAt`, `createdBy`, `removedBy` yourself — it already provides them.
43
- 2. `default` is a SQL expression string — `'false'`, `"'draft'"` — never a JS value; a JS value is rejected at migration time.
44
- 3. Scalars only via `@Column({ type: FieldTypeEnum.X })`; relations/enums/files are NEVER declared via `@Column` — use the `@ManyToOne`/`@ManyToMany`/`@OneToMany`/`@ManyToManyBackRef`/`@Enum`/`@MultiEnum`/`@File`/`@MultiFile` families.
45
- 4. Relation targets are thunks — `() => Target`, never the class itself — or circular imports break.
46
- 5. If an option isn't in the reference tables (`references/entities.md`, `references/seeds.md`, `references/registration.md`), it doesn't exist — stop and ask, don't guess.
47
- 6. Every entity class must appear in some `forFeature()`'s `entities` array; every seed in its `seeds` array, dependencies first — `workflowsSeed` before `stageWorkflowsSeed`.
48
- 7. Seeds: every record carries all `importKeyFields` (or `$key`); relations are referenced by the target's import-key object, never a numeric id; no system columns; no `$readAccess`/`$updateAccess`/`$instanceAccess`; no reverse `@OneToMany` field, even as `[]`.
49
- 8. Autoload paths (`entitiesPath`/`seedsPath`) point at `dist/`, never `src/` — autoloading reads compiled output.
50
- 9. Renames need `key` set on `@Entity()`/`@Column()` BEFORE the rename ships — otherwise it's a drop-and-create, not a rename.
51
- 10. Repeating rows owned by one parent record are a **tabular part**, never a plain entity: `type: 'tabular-part'` + `relationEntityName` (the parent's `@Entity()` name) + a `@ManyToOne` field named exactly `owner` pointing at the parent class — all three required, the platform infers none of them. Put `owner` FIRST in `importKeyFields` — it scopes the business key to the parent, or rows collide across different parents.
43
+ 2. An entity class that is not in `EntityModule.forFeature()` does not exist — the platform creates no table for it (doc: "An entity class that is never passed to forFeature() is invisible"). Write the entity and register it in the SAME step; never move on to the next entity, or report progress, with an unregistered class.
44
+ 3. `default` is a SQL expression string — `'false'`, `"'draft'"` — never a JS value; a JS value is rejected at migration time.
45
+ 4. Scalars only via `@Column({ type: FieldTypeEnum.X })`; relations/enums/files are NEVER declared via `@Column` — use the `@ManyToOne`/`@ManyToMany`/`@OneToMany`/`@ManyToManyBackRef`/`@Enum`/`@MultiEnum`/`@File`/`@MultiFile` families.
46
+ 5. Relation targets are thunks — `() => Target`, never the class itself — or circular imports break.
47
+ 6. If an option isn't in the reference tables (`references/entities.md`, `references/seeds.md`, `references/registration.md`), it doesn't exist — stop and ask, don't guess.
48
+ 7. Every entity class must appear in some `forFeature()`'s `entities` array; every seed in its `seeds` array, dependencies first — `workflowsSeed` before `stageWorkflowsSeed`.
49
+ 8. Seeds: every record carries all `importKeyFields` (or `$key`); relations are referenced by the target's import-key object, never a numeric id; no system columns; no `$readAccess`/`$updateAccess`/`$instanceAccess`; no reverse `@OneToMany` field, even as `[]`.
50
+ 9. Autoload paths (`entitiesPath`/`seedsPath`) point at `dist/`, never `src/` — autoloading reads compiled output.
51
+ 10. Renames need `key` set on `@Entity()`/`@Column()` BEFORE the rename ships — otherwise it's a drop-and-create, not a rename.
52
+ 11. Repeating rows owned by one parent record are a **tabular part**, never a plain entity: `type: 'tabular-part'` + `relationEntityName` (the parent's `@Entity()` name) + a `@ManyToOne` field named exactly `owner` pointing at the parent class — all three required, the platform infers none of them. Put `owner` FIRST in `importKeyFields` — it scopes the business key to the parent, or rows collide across different parents.
52
53
 
53
54
  ## Decorator decision table
54
55
 
@@ -84,10 +85,9 @@ Confirm all 5 before writing anything:
84
85
 
85
86
  1. Pre-flight (above) — confirm repo, SDK version, tsconfig, layout.
86
87
  2. Blocking questions (above) — get answers before writing any file.
87
- 3. Write the entity from `templates/entity.template.ts`, following `references/entities.md`.
88
- 4. Need default rows? Write the seed from `templates/seed.template.ts`, following `references/seeds.md`.
89
- 5. Update the `entities`/`seeds` barrels and the `EntityModule.forFeature()` call — `references/registration.md`.
90
- 6. Run the close-out gate (below) — do not report "done" before all 4 steps pass.
88
+ 3. Write the entity AND wire it in (one step, both files): write `*.entity.ts` from `templates/entity.template.ts` per `references/entities.md`, then immediately export it from the entities barrel and add it to `EntityModule.forFeature()`'s `entities` array — see "Wiring a new entity in" below. The class does not exist to the platform until this is done.
89
+ 4. Need default rows? Same deal for the seed: write it from `templates/seed.template.ts` per `references/seeds.md`, export it from the seeds barrel, and add it to the `seeds` array (dependencies first) in the same step. The seed is not done until it is in the `seeds` array.
90
+ 5. Run the close-out gate (below) — do not report "done" before all 4 steps pass.
91
91
 
92
92
  ## Flow B — port a Suppa 1.0 entity to v2 code
93
93
 
@@ -95,9 +95,47 @@ Confirm all 5 before writing anything:
95
95
  2. `suppa_read_v1_entity_props` (+ `suppa_read_v1_enum` for enum fields) -> read its fields.
96
96
  3. Map every field per `references/v1-mapping.md` — the same authority (`classifyV1Field`) as the API migration path.
97
97
  4. Never silently drop a field: anything unmapped or unsupported gets `// SKIPPED: <field> — <reason>` inside the class body.
98
- 5. Continue with Flow A from the blocking questions onward (steps 2-6 above).
98
+ 5. Continue with Flow A from the blocking questions onward (steps 2-5 above).
99
99
  6. Record data migrates separately, via `suppa_migrate_entities_from_v1` — this skill only produces schema code.
100
100
 
101
+ ## Wiring a new entity in (same step as writing it)
102
+
103
+ **Locate the registration first.** The entity and seed files are new files written from templates; registration is an edit to an existing module file you have not seen yet, so find it before you start.
104
+
105
+ ```
106
+ grep -rn "EntityModule.forFeature" src/
107
+ ```
108
+
109
+ Fallback: `src/app/app.module.ts`. If the call you find uses `entitiesPath`/`seedsPath` (autoload) instead of explicit arrays, there is nothing to edit here — the class is picked up from `dist/` — so verify the build output path instead.
110
+
111
+ Four edits, every time:
112
+
113
+ 1. Export the class from the entities barrel — `src/common/database/entities/index.ts`.
114
+ 2. Export the seed from the seeds barrel — `src/common/database/seeds/index.ts`.
115
+ 3. Import the class in the module and add it to the `entities` array.
116
+ 4. Add the seed to the `seeds` array, positioned AFTER the seeds of everything it references.
117
+
118
+ ```ts
119
+ // before
120
+ EntityModule.forFeature([Workflows], { seeds: [workflowsSeed] });
121
+
122
+ // after — new import, new entity, new seed
123
+ import { MyNewEntity } from '../common/database/entities';
124
+ import { myNewEntitySeed } from '../common/database/seeds';
125
+
126
+ EntityModule.forFeature([Workflows, MyNewEntity], {
127
+ seeds: [workflowsSeed, myNewEntitySeed],
128
+ });
129
+ ```
130
+
131
+ Self-check, no tooling required:
132
+
133
+ ```
134
+ grep -rn "MyNewEntity" src/ | grep -i module
135
+ ```
136
+
137
+ If that prints nothing, the entity is not registered.
138
+
101
139
  ## Close-out gate (all steps, in order — no "done" before all pass)
102
140
 
103
141
  ```
@@ -108,6 +146,8 @@ Confirm all 5 before writing anything:
108
146
  4. verify the tenant converged: suppa_describe_entity('<EntityName>')
109
147
  ```
110
148
 
149
+ Step 1 exists to catch exactly this: an unregistered class is E301 and the gate fails. Never report done on an unrun gate.
150
+
111
151
  `validate-suppa-schema.mjs` exits `0` on a clean run, `1` when errors are found, `2` on a usage error or a missing path. The gate requires exit `0` — warnings alone do not block.
112
152
 
113
153
  ## Troubleshooting
@@ -756,7 +756,29 @@ function analyzeModules(ts, sf, model) {
756
756
  }
757
757
 
758
758
  // ── rules: registration ──
759
- function checkRegistration(ts, model, findings) {
759
+ /**
760
+ * E301/E302 fire on the entity/seed source file, far from the module file
761
+ * that actually needs the edit — name it explicitly so the finding is
762
+ * actionable instead of just "unregistered". `side` selects which half of
763
+ * forFeature() (`entities` or `seeds`) determines the classes-shape modules;
764
+ * paths are shown relative to rootDir when derivable, else just the basename,
765
+ * deduped, capped at 3 so the message stays short.
766
+ */
767
+ function classShapeModulePaths(modules, side, rootDir) {
768
+ const shapeModules = modules.filter((m) => m[side].mode === "explicit");
769
+ if (shapeModules.length === 0) return "";
770
+ const root = rootDir ? resolve(rootDir).replace(/\\/g, "/") : null;
771
+ const raw = [...new Set(shapeModules.map((m) => m.sf.fileName))];
772
+ const shown = raw.map((p) => {
773
+ const norm = p.replace(/\\/g, "/");
774
+ if (root && norm.startsWith(`${root}/`)) return norm.slice(root.length + 1);
775
+ const parts = norm.split("/");
776
+ return parts[parts.length - 1];
777
+ });
778
+ return shown.slice(0, 3).join(", ");
779
+ }
780
+
781
+ function checkRegistration(ts, model, findings, rootDir) {
760
782
  // E303/W606 on autoload paths — only for the side that actually autoloads:
761
783
  // a path the resolution order ignores is dead config, not a mistake.
762
784
  for (const m of model.modules) {
@@ -810,19 +832,23 @@ function checkRegistration(ts, model, findings) {
810
832
 
811
833
  if (!entitiesUnknown) {
812
834
  const registeredEntities = new Set(model.modules.flatMap((m) => m.entities.names));
835
+ const modulePaths = classShapeModulePaths(model.modules, "entities", rootDir);
813
836
  for (const [className, info] of model.entities) {
814
837
  if (!registeredEntities.has(className)) {
815
838
  findings.push(finding(ts, info.sf, info.node.name ?? info.node, "E301",
816
- `entity class '${className}' is not in any forFeature() entities array — no table will be created for it`));
839
+ `entity class '${className}' is not in any forFeature() entities array — no table will be created for it` +
840
+ (modulePaths ? ` — add it to the entities array in ${modulePaths}` : "")));
817
841
  }
818
842
  }
819
843
  }
820
844
  if (!seedsUnknown) {
821
845
  const registeredSeeds = new Set(model.modules.flatMap((m) => m.seeds.names));
846
+ const modulePaths = classShapeModulePaths(model.modules, "seeds", rootDir);
822
847
  for (const seed of model.seeds) {
823
848
  if (!registeredSeeds.has(seed.exportName)) {
824
849
  findings.push(finding(ts, seed.sf, seed.node, "E302",
825
- `seed '${seed.exportName}' is not in any forFeature() seeds array — it will never run`));
850
+ `seed '${seed.exportName}' is not in any forFeature() seeds array — it will never run` +
851
+ (modulePaths ? ` — add it to the seeds array in ${modulePaths}` : "")));
826
852
  }
827
853
  }
828
854
  }
@@ -996,7 +1022,7 @@ export function validateSchema({ files = [], rootDir = null } = {}) {
996
1022
  }
997
1023
  for (const info of model.entities.values()) checkEntity(ts, info, sdk, model, findings);
998
1024
  for (const seed of model.seeds) checkSeed(ts, seed, model, findings);
999
- checkRegistration(ts, model, findings);
1025
+ checkRegistration(ts, model, findings, rootDir);
1000
1026
  checkTsconfig(ts, rootDir, findings);
1001
1027
  findings.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.col - b.col);
1002
1028
  return {