suppa-mcp-2 1.3.2 → 1.4.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 +1 -1
- package/package.json +1 -1
- package/skills/suppa-entity-code/SKILL.md +64 -10
- package/skills/suppa-entity-code/scripts/validate-suppa-schema.mjs +1550 -1284
- package/skills/suppa-entity-code/templates/entity.template.ts +29 -1
- package/skills/suppa-entity-code/templates/tabular-part.template.ts +99 -94
package/dist/server.js
CHANGED
|
@@ -297,7 +297,7 @@ export function buildServer() {
|
|
|
297
297
|
// Reset so repeated buildServer() calls (e.g. in tests) do not double-count.
|
|
298
298
|
TOOL_NAMES.length = 0;
|
|
299
299
|
PROMPT_NAMES.length = 0;
|
|
300
|
-
const server = new McpServer({ name: "suppa-2.0", version: "1.
|
|
300
|
+
const server = new McpServer({ name: "suppa-2.0", version: "1.4.1" }, { instructions: INSTRUCTIONS });
|
|
301
301
|
const reg = (name, cfg, handler) => {
|
|
302
302
|
server.registerTool(name, {
|
|
303
303
|
description: cfg.description,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suppa-mcp-2",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.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": {
|
|
@@ -46,13 +46,18 @@ Confirm all 5 before writing anything:
|
|
|
46
46
|
5. Relation targets are thunks — `() => Target`, never the class itself — or circular imports break.
|
|
47
47
|
6. Do not pass the optional `inverse` selector to `@ManyToOne`/`@ManyToMany` — write `@ManyToOne(() => Target, { … })`. Add one only when the target class declares the paired back-reference and you are deliberately linking the two sides. An `inverse` must select a RELATION property on the target (`(task) => task.project`); `(e) => e.id` is always wrong — `id` is a system column, not a back-reference.
|
|
48
48
|
7. 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.
|
|
49
|
-
8. Every entity class must appear in
|
|
49
|
+
8. Every entity class must appear in the class array passed as `forFeature()`'s FIRST argument (there is no `entities` option — rule 19); every seed in the options object's `seeds` array, dependencies first — `workflowsSeed` before `stageWorkflowsSeed`.
|
|
50
50
|
9. 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 `[]`.
|
|
51
51
|
10. Autoload paths (`entitiesPath`/`seedsPath`) point at `dist/`, never `src/` — autoloading reads compiled output.
|
|
52
52
|
11. Renames need `key` set on `@Entity()`/`@Column()` BEFORE the rename ships — otherwise it's a drop-and-create, not a rename.
|
|
53
53
|
12. `subType` refines `type` and means three unrelated things depending on the base type — `Timestamp` → `'date' | 'time' | 'timestamp'`, `Text` → `'encrypted'`, `Enum`/`MultiEnum` → the enum's global name. Never pass `subType` by hand on an `@Enum`/`@MultiEnum` field: the decorator fills it from its first argument (or derives `<ClassName>.<propertyName>`), and a hand-written one either duplicates that or silently disagrees with the value that resolves `{ value: 'active' }` on insert. Any other `(type, subType)` pair does not exist.
|
|
54
54
|
13. `subType` is **immutable after creation**, with one exception: toggling `'encrypted'` on or off. The Builder API answers `Field subType cannot be changed.` to anything else — so choosing `Timestamp` where you needed `subType: 'date'` is not a conversion you can ship later, it is a NEW field plus a removal of the old one (see `references/registration.md` for what removal leaves behind). Get date-vs-timestamp right the first time. To CLEAR a subtype you must write `subType: null` explicitly — deleting the line does nothing, because an omitted key is dropped from the sync payload and the stored subtype survives.
|
|
55
|
-
14.
|
|
55
|
+
14. **Every relation property carries its TypeScript type, and the type says what the decorator says.** `@ManyToOne` holds ONE row — `owner: ProductMatrixEntity;` — while `@ManyToMany`, `@OneToMany` and `@ManyToManyBackRef` hold many — `envs: ApplicationEnvsEntity[];`. Type it optional (`owner?: Target`) unless the relation is `nullable: false`. An untyped relation property is `any` to every consumer of the entity. E114/E115/W610.
|
|
56
|
+
15. **Enum member keys are PascalCase** — `NotFilled = 'Not filled'`. The key is the identifier the code reads; the string on the right is what the platform stores, and the two need not match. W611.
|
|
57
|
+
16. **Never write an option that already holds its default value.** The platform applies `canGroup: true`, `canSort: true`, `showInTable: true`, `editFromTable: true`, `canFilter: true`, `readOnly: false`, `searchable: false` on its own. Declare one of these ONLY where the field departs from it; repeating defaults on every field buries the one option that actually differs. W612.
|
|
58
|
+
17. **`@Enum`/`@MultiEnum` take the global name only when the enum is global.** Default is local: `@Enum(StageStatusEnum, StageStatus, { nullable: false })` — the decorator derives `<ClassName>.<propertyName>`. Pass the name as the FIRST argument only when the value set is shared across entities or referenced from a seed: `@Enum('StageWorkflows.status', StageStatusEnum, StageStatus, { … })`. W613.
|
|
59
|
+
18. 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.
|
|
60
|
+
19. **`EntityModule.forFeature()` has exactly two shapes** (`references/registration.md`): `forFeature([A, B], { seeds: [...] })` — classes FIRST, options second — or `forFeature({ entitiesPath, seedsPath })` for autoloading. The options object accepts only `seeds`, `entitiesPath` and `seedsPath`. `forFeature({ entities: [...] })` looks reasonable and registers NOTHING: the classes are dropped with the unknown option and no table is created for any of them. E306.
|
|
56
61
|
|
|
57
62
|
## Decorator decision table
|
|
58
63
|
|
|
@@ -64,17 +69,47 @@ Confirm all 5 before writing anything:
|
|
|
64
69
|
| Time-only column | `@Column({ type: FieldTypeEnum.Timestamp, subType: 'time' })` — there is **no** `FieldTypeEnum.Time` |
|
|
65
70
|
| Date **and** time | `@Column({ type: FieldTypeEnum.Timestamp })` — omitted `subType` already means `timestamp` |
|
|
66
71
|
| Text encrypted at rest | `@Column({ type: FieldTypeEnum.Text, subType: 'encrypted' })` — Text only; see rule 13 for what it costs |
|
|
67
|
-
| Fixed single-select value set | `@Enum(
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
|
72
|
-
| Reverse side of a `@
|
|
72
|
+
| Fixed single-select value set, used by this field only | `@Enum(<Field>Enum, <Field>Titles?, options?)` → `field: <Field>Enum;` |
|
|
73
|
+
| …the same, but shared across entities or referenced from a seed | `@Enum('<Entity>.<field>', <Field>Enum, <Field>Titles?, options?)` |
|
|
74
|
+
| Fixed multi-select value set | `@MultiEnum(...)` — same signatures as `@Enum` |
|
|
75
|
+
| Foreign key on this entity | `@ManyToOne(() => Target, options?)` → `prop: Target;` — **no inverse** |
|
|
76
|
+
| Pivot table between two entities | `@ManyToMany(() => Target, options?)` → `prop: Target[];` — **no inverse** |
|
|
77
|
+
| Reverse side of a `@ManyToMany` | `@ManyToManyBackRef(() => Target, (t) => t.<thisRelationProp>, options?)` → `prop: Target[];` |
|
|
78
|
+
| Reverse side of a `@ManyToOne` | `@OneToMany(() => Target, (t) => t.<thisRelationProp>, options?)` → `prop: Target[];` |
|
|
73
79
|
| Single attachment | `@File({ title })` |
|
|
74
80
|
| Multiple attachments | `@MultiFile({ title })` |
|
|
75
81
|
|
|
76
82
|
`target` is always a thunk, `() => Target`. The `inverse` selector is REQUIRED on `@OneToMany`/`@ManyToManyBackRef` and OPTIONAL on `@ManyToOne`/`@ManyToMany` — omit it there by default. When you do write one, it must select the property on the TARGET class that holds the other side of this relation (e.g. `(task) => task.project`) — never `.id`, never a scalar column.
|
|
77
83
|
|
|
84
|
+
**Typing the property (rule 14).** The decorator declares the relation; the TypeScript type declares its shape, and the two must agree:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
@ManyToOne(() => ProductMatrixEntity, {
|
|
88
|
+
name: 'owner',
|
|
89
|
+
key: 'ProductMatrixItem.owner',
|
|
90
|
+
nullable: false,
|
|
91
|
+
title: { en: 'Owner' },
|
|
92
|
+
})
|
|
93
|
+
owner: ProductMatrixEntity; // ONE row; no '?' because nullable: false
|
|
94
|
+
|
|
95
|
+
@ManyToMany(() => ProductMatrixEntity, { name: 'peers', title: { en: 'Peers' } })
|
|
96
|
+
peers: ProductMatrixEntity[]; // MANY rows
|
|
97
|
+
|
|
98
|
+
@OneToMany(() => ApplicationEnvsEntity, (entity) => entity.owner, {
|
|
99
|
+
title: getFieldTitle(EntityNamesEnum.Applications, 'envs'),
|
|
100
|
+
})
|
|
101
|
+
envs: ApplicationEnvsEntity[]; // MANY rows, inverse REQUIRED
|
|
102
|
+
|
|
103
|
+
@ManyToManyBackRef(() => ApplicationEnvsEntity, (entity) => entity.owner, {
|
|
104
|
+
title: getFieldTitle(EntityNamesEnum.Applications, 'envs'),
|
|
105
|
+
})
|
|
106
|
+
envs: ApplicationEnvsEntity[]; // MANY rows, inverse REQUIRED
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
A `@ManyToOne` without `nullable: false` is written `owner?: ProductMatrixEntity` — the column may be empty and callers must handle it.
|
|
110
|
+
|
|
111
|
+
**Field options (rule 16).** `canGroup`, `canSort`, `showInTable`, `editFromTable` and `canFilter` default to `true`; `readOnly` and `searchable` default to `false`. Write one only to depart from that — `searchable: true` on the field users actually search, and nothing on the rest.
|
|
112
|
+
|
|
78
113
|
**What `subType: 'encrypted'` costs.** The platform forces the column's `unique`, `searchable`, `canFilter`, `canSort` and `canGroup` to `false` and clears `maxLength`, `minLength` and `mask`, whatever you declared — the ciphertext envelope can't satisfy a plaintext constraint or be read by an index. So an encrypted column cannot be searched, filtered, sorted or grouped: if users need any of that, split the field and keep the searchable part in a separate plaintext column. It is also rejected inside a `MultiType` field and on any non-Text type.
|
|
79
114
|
|
|
80
115
|
## Naming conventions
|
|
@@ -85,6 +120,7 @@ Confirm all 5 before writing anything:
|
|
|
85
120
|
| Entity class | PascalCase, plural = `@Entity()`'s `name` | `StageWorkflows` |
|
|
86
121
|
| Seed export | camelCase plural + `Seed` | `stageWorkflowsSeed` |
|
|
87
122
|
| Enum | PascalCase + `Enum` | `StageStatusEnum` |
|
|
123
|
+
| Enum member key | PascalCase — the stored value is the string on the right and need not match | `NotFilled = 'Not filled'` |
|
|
88
124
|
| Titles map | PascalCase + `Titles` suffix — this doc's own worked examples drop the suffix (`StageStatus`); either is acceptable if used consistently within a repo | `StageStatusTitles` (or `StageStatus`) |
|
|
89
125
|
| Enum global name | `'<EntityName>.<field>'` | `'StageWorkflows.status'` |
|
|
90
126
|
| Index name | `idx_<table>_<cols>` | `idx_tasks_project` |
|
|
@@ -94,7 +130,7 @@ Confirm all 5 before writing anything:
|
|
|
94
130
|
|
|
95
131
|
1. Pre-flight (above) — confirm repo, SDK version, tsconfig, layout.
|
|
96
132
|
2. Blocking questions (above) — get answers before writing any file.
|
|
97
|
-
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
|
|
133
|
+
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 the class array passed as `EntityModule.forFeature()`'s first argument — see "Wiring a new entity in" below. The class does not exist to the platform until this is done.
|
|
98
134
|
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.
|
|
99
135
|
5. Run the close-out gate (below) — do not report "done" before all 4 steps pass.
|
|
100
136
|
|
|
@@ -121,7 +157,7 @@ Four edits, every time:
|
|
|
121
157
|
|
|
122
158
|
1. Export the class from the entities barrel — `src/common/database/entities/index.ts`.
|
|
123
159
|
2. Export the seed from the seeds barrel — `src/common/database/seeds/index.ts`.
|
|
124
|
-
3. Import the class in the module and add it to the `
|
|
160
|
+
3. Import the class in the module and add it to the class array — `forFeature()`'s FIRST argument.
|
|
125
161
|
4. Add the seed to the `seeds` array, positioned AFTER the seeds of everything it references.
|
|
126
162
|
|
|
127
163
|
```ts
|
|
@@ -137,6 +173,16 @@ EntityModule.forFeature([Workflows, MyNewEntity], {
|
|
|
137
173
|
});
|
|
138
174
|
```
|
|
139
175
|
|
|
176
|
+
**The shape is not negotiable.** There are exactly two (`references/registration.md`): the classes as the FIRST argument with an options object second, or an options object alone that autoloads from `entitiesPath`/`seedsPath`. The options object accepts only `seeds`, `entitiesPath` and `seedsPath` — there is no `entities` option:
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
EntityModule.forFeature([A, B], { seeds: [aSeed] }); // correct
|
|
180
|
+
EntityModule.forFeature({ entitiesPath: 'dist/…/entities' }); // correct
|
|
181
|
+
EntityModule.forFeature({ entities: [A, B], seeds: [aSeed] }); // WRONG — E306
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
The third form looks reasonable and registers nothing: the classes are dropped with the unknown option, and no table is created for any of them.
|
|
185
|
+
|
|
140
186
|
Self-check, no tooling required:
|
|
141
187
|
|
|
142
188
|
```
|
|
@@ -166,6 +212,8 @@ The validator parses with the TypeScript compiler API, read from the app repo yo
|
|
|
166
212
|
| Symptom | Cause | Validator code |
|
|
167
213
|
|---|---|---|
|
|
168
214
|
| No table is created for an entity | The class was not passed to `EntityModule.forFeature()` | E301 |
|
|
215
|
+
| No table is created for ANY entity, and the registration looks right | `forFeature({ entities: [...] })` — an invented shape; the classes go in the FIRST argument and the options object has no `entities` key | E306 |
|
|
216
|
+
| E301 never fires even though an entity is clearly unregistered | A `forFeature()` names neither a class array nor `entitiesPath`, so membership is unknown and the check is skipped for the whole run | W614 |
|
|
169
217
|
| Autoloading finds nothing | `entitiesPath` / `seedsPath` points at `src/` instead of compiled `dist/` | E303 |
|
|
170
218
|
| Duplicate seed rows after a restart | Record is missing one or more `importKeyFields` | E205 |
|
|
171
219
|
| Seed relation is empty or fails to resolve | Relation referenced by numeric id, or the target seed runs later | E203 + E304 |
|
|
@@ -173,6 +221,12 @@ The validator parses with the TypeScript compiler API, read from the app repo yo
|
|
|
173
221
|
| A renamed entity or field appears as a new one | No `key` option was set | W602 |
|
|
174
222
|
| `default` value is rejected | A JavaScript value was passed instead of a SQL expression string | E103 |
|
|
175
223
|
| Generated relation has an inverse selector that fails to typecheck | An `inverse` was passed to `@ManyToOne`/`@ManyToMany`, where it's optional and usually omitted | W609/E111 — drop the selector, write `@ManyToOne(() => Target, { … })` |
|
|
224
|
+
| A relation reads as `any`; nothing catches using it as the wrong shape | The property has no TypeScript type | E114 — write `owner: Target;` (`Target[]` for the to-many decorators) |
|
|
225
|
+
| A to-many relation is used as a single record (or the reverse) | The property's type contradicts the decorator's arity, or names a different class than the thunk | E115 — `@ManyToOne` → `Target`; `@ManyToMany`/`@OneToMany`/`@ManyToManyBackRef` → `Target[]` |
|
|
226
|
+
| Callers never null-check a relation that can be empty | A nullable `@ManyToOne` is typed as always present (or a `nullable: false` one as optional) | W610 — `owner?: Target` when nullable, `owner: Target` when `nullable: false` |
|
|
227
|
+
| Enum members read as data rather than identifiers | Member keys are not PascalCase | W611 — `NotFilled = 'Not filled'` |
|
|
228
|
+
| Every field repeats the same five option lines | Options were written at their default values | W612 — delete them; declare an option only where it departs from the default |
|
|
229
|
+
| An enum name is invented for a field nothing else references | The optional global name was passed to `@Enum`/`@MultiEnum` when the enum is local | W613 — omit the first argument; the decorator derives `<ClassName>.<propertyName>` |
|
|
176
230
|
| Migration rejects the column, or a date field ships as a full `timestamp` | The `(type, subType)` pair isn't one the doc allows — `Timestamp` takes `'date'`/`'time'`/`'timestamp'`, `Text` takes `'encrypted'`, nothing else | E112 |
|
|
177
231
|
| `Encrypted subtype is only allowed on text fields` | `subType: 'encrypted'` on a non-Text column | E112 |
|
|
178
232
|
| An enum field resolves to the wrong enum, or its values fail to insert | `subType` was written by hand on `@Enum`/`@MultiEnum` instead of being left to the decorator | E113 |
|