suppa-mcp-2 1.13.0 → 1.13.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 +2 -1
- package/package.json +1 -1
- package/skills/suppa-entity-code/SKILL.md +2 -1
- package/skills/suppa-entity-code/references/extensions.md +1 -1
- package/skills/suppa-entity-code/scripts/house-rules.mjs +2 -2
- package/skills/suppa-entity-code/scripts/validate-suppa-schema.mjs +25 -5
- package/skills/suppa-entity-code/templates/entity-extension.template.ts +3 -1
package/dist/server.js
CHANGED
|
@@ -2187,7 +2187,8 @@ export function buildServer() {
|
|
|
2187
2187
|
" columns, in <owner>.extension.entity.ts. Extension mode ignores entity options\n" +
|
|
2188
2188
|
" (W618), refuses @OneToMany/@ManyToManyBackRef (E118) and primary: true (E119),\n" +
|
|
2189
2189
|
" requires a default with nullable: false (E120), and allows @Index/@Check over your\n" +
|
|
2190
|
-
" own columns only (E121). A relation there names its
|
|
2190
|
+
" own columns only, listed literally (E121/E122). A relation there names its\n" +
|
|
2191
|
+
" target by string and is typed\n" +
|
|
2191
2192
|
" by shape — that form is W620 anywhere else;\n" +
|
|
2192
2193
|
" * 'owner' comes first in a tabular part's importKeyFields, and no 'inverse' is passed\n" +
|
|
2193
2194
|
" to @ManyToOne/@ManyToMany.\n" +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suppa-mcp-2",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.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": {
|
|
@@ -87,7 +87,7 @@ Confirm all 5 before writing anything:
|
|
|
87
87
|
| No `@OneToMany` / `@ManyToManyBackRef` | "a reverse relation creates a field on the other entity" | **E118** |
|
|
88
88
|
| No `primary: true` | "the owner's primary key is not yours to redefine" | **E119** |
|
|
89
89
|
| No `nullable: false` without a `default` | the table already has rows, and each needs a value | **E120** |
|
|
90
|
-
| `@Index` / `@Check` only over columns YOU declare | anything else reaches into another owner's schema | **E121** |
|
|
90
|
+
| `@Index` / `@Check` only over columns YOU declare, and spelled out as a literal array | anything else reaches into another owner's schema — and a column list passed by reference cannot be checked at all | **E121** / **E122** |
|
|
91
91
|
|
|
92
92
|
Allowed, and unchanged from your own entities: `@Column()` of any type, `@ManyToOne`, `@ManyToMany`, `@Enum`, `@MultiEnum`, `@File`, `@MultiFile`. Your columns are real columns on the owner's table — selectable, filterable, in metadata, in history — and they follow the same remove/restore semantics as your own. You cannot remove a field you do not own; it is not in your declaration to begin with.
|
|
93
93
|
**A name collision fails the build and applies nothing** — `cannot declare field "Tasks.plan": it already exists and is owned by application "Planner"` — by NAME, not by key, and a soft-deleted field keeps its name reserved. A field a user added through the UI is *not* an owner: your declaration takes it over, data and all.
|
|
@@ -311,6 +311,7 @@ The validator parses with the TypeScript compiler API, read from the app repo yo
|
|
|
311
311
|
| An extension declares `primary: true` | The owner's primary key is not yours to redefine | E119 |
|
|
312
312
|
| `nullable: false` on an extension column | The table already has rows; each needs a value, so a `default` is mandatory (and on a big table, ship it nullable and backfill separately) | E120 |
|
|
313
313
|
| An extension's `@Index`/`@Check` names a column it does not declare | An extension may only index or constrain its OWN columns | E121 |
|
|
314
|
+
| An extension's `@Index`/`@Check` gets its columns from a const, a spread or an options object | The documented shape is `@Index('<name>', ['<column>'])`. A list the checker cannot read leaves E121 unchecked — and it compiles, so it ships | E122 |
|
|
314
315
|
| The build stops with `cannot declare field "X.y": it already exists and is owned by application "Z"` | Field names have exactly one owner, matched by NAME (not key) — and a soft-deleted field keeps its name reserved. Nothing is applied. Rename yours, or agree with that team | not statically checkable |
|
|
315
316
|
| The build stops with `refusing to build system metadata: this is an application build but applicationId is missing` | The platform is older than extension mode, or the runner does not pass the application id. Update the platform — there is nothing to change in the code | not statically checkable |
|
|
316
317
|
| A relation names its target with a string (`@ManyToOne('Invoices', …)`) in an ordinary entity | That form is for extensions, where the target belongs to another application and there is no class to import | W620 (blocks the gate) |
|
|
@@ -133,6 +133,6 @@ export class TasksBillingExtension extends SystemBaseEntity {
|
|
|
133
133
|
After both applications start, the `Tasks` table has `name`, `plan` and `invoiceId`. Planner's declaration is unchanged and unaware of the two extra columns; Billing owns them and can alter, remove or restore them. Neither application can modify the other's fields, and `Tasks` itself — its title, its representative field — still belongs to Planner.
|
|
134
134
|
|
|
135
135
|
> **HOUSE RULE — the filename declares the intent (SKILL.md rule 20).**
|
|
136
|
-
> Nothing in the code above says which mode it will get: the platform decides by ownership at start. Name the file `<owner-entity>.extension.entity.ts` and the class `<EntityName>Extension`, as the doc's own examples do. That is what lets the validator apply the restrictions in this section BEFORE the build refuses them — W618, E118, E119, E120, E121 — instead of after.
|
|
136
|
+
> Nothing in the code above says which mode it will get: the platform decides by ownership at start. Name the file `<owner-entity>.extension.entity.ts` and the class `<EntityName>Extension`, as the doc's own examples do. That is what lets the validator apply the restrictions in this section BEFORE the build refuses them — W618, E118, E119, E120, E121 — instead of after. Write an index's column list as a literal array while you are here: `@Index('idx', COLUMNS)` compiles and therefore ships, and nothing can then tell whether it reaches into the owner's schema (E122).
|
|
137
137
|
>
|
|
138
138
|
> Note the relation form: `@ManyToOne('Invoices', …)` names the target by STRING, because there is no class to import for an entity another application owns, and the property is typed by shape — `invoice?: { id: number }`. That is right here and only here; in your own entities a relation target is a thunk (rule 5), and the string form is W620.
|
|
@@ -20,7 +20,7 @@ These six rules are house rules of this platform. They OVERRIDE the platform's o
|
|
|
20
20
|
3. NEVER WRITE A FIELD OPTION AT ITS DEFAULT. canGroup, canSort, showInTable, editFromTable and canFilter are already true; readOnly and searchable are already false. Write one ONLY where the field departs from that (usually just \`searchable: true\`). A field with all seven spelled out is wrong even though it works.
|
|
21
21
|
4. @Enum/@MultiEnum TAKE THE GLOBAL NAME ONLY WHEN THE ENUM IS GLOBAL — shared by another entity, or referenced from a seed record. Otherwise omit the first argument entirely: \`@Enum(StatusEnum, StatusTitles, { … })\`, and the decorator derives <ClassName>.<propertyName>. A field's own \`key: 'Entity.field'\` is the rename key, NOT a reference, and does not make the enum global.
|
|
22
22
|
5. A RELATION TARGET THAT ALREADY EXISTS on the tenant (created earlier, or owned by another application) gets a STUB, and a stub is three things at once: \`@Entity({ name: 'Accounts', key: 'Accounts' }) export class Accounts extends SystemBaseEntity {}\` with an EMPTY body, ALONE in a file named \`accounts.stub.entity.ts\`, and REGISTERED in forFeature() with the entities you create. Never a bare \`export class Accounts {}\` — it satisfies the thunk but registers nothing, so the platform cannot resolve the relation (E116). Never fields on a stub — a stub only stands in so a relation can point at the table (E117); to ADD columns there, see rule 6. Platform system entities need no stub — import UsersEntity/FilesEntity/IconsEntity from @suppa/sdk.
|
|
23
|
-
6. TO ADD COLUMNS TO AN ENTITY YOU DO NOT OWN, DECLARE AN EXTENSION — not a stub, and there is no separate API. Declare the entity by its EXISTING name with only your own columns, in a file named \`<owner-entity>.extension.entity.ts\` (class \`<OwnerEntity>Extension\`), and register it like any other entity: \`@Entity({ name: 'Users' }) export class UsersExtension extends SystemBaseEntity { @Column({ type: FieldTypeEnum.Numeric, nullable: true }) accountId?: number; }\`. The platform picks the mode by OWNERSHIP at start. In extension mode: entity options are IGNORED (title/icon/type/options/representativeFieldName/importKeyFields — W618), no @OneToMany or @ManyToManyBackRef (E118), no \`primary: true\` (E119), no \`nullable: false\` without a default (E120), and @Index/@Check only over your own columns (E121). A relation to an entity you do not own is named by STRING and typed by shape — \`@ManyToOne('Invoices', { … }) invoice?: { id: number };\` — which is right there and nowhere else (W620).
|
|
23
|
+
6. TO ADD COLUMNS TO AN ENTITY YOU DO NOT OWN, DECLARE AN EXTENSION — not a stub, and there is no separate API. Declare the entity by its EXISTING name with only your own columns, in a file named \`<owner-entity>.extension.entity.ts\` (class \`<OwnerEntity>Extension\`), and register it like any other entity: \`@Entity({ name: 'Users' }) export class UsersExtension extends SystemBaseEntity { @Column({ type: FieldTypeEnum.Numeric, nullable: true }) accountId?: number; }\`. The platform picks the mode by OWNERSHIP at start. In extension mode: entity options are IGNORED (title/icon/type/options/representativeFieldName/importKeyFields — W618), no @OneToMany or @ManyToManyBackRef (E118), no \`primary: true\` (E119), no \`nullable: false\` without a default (E120), and @Index/@Check only over your own columns, listed as a literal array (E121/E122). A relation to an entity you do not own is named by STRING and typed by shape — \`@ManyToOne('Invoices', { … }) invoice?: { id: number };\` — which is right there and nowhere else (W620).
|
|
24
24
|
Before reporting the file done, run the gate: call suppa_validate_entity_code(path=<app-root>). It fails on every one of the six and names file:line. passed=false means fix and re-run, not "note and move on". (Same checker on the command line: node node_modules/suppa-mcp-2/skills/suppa-entity-code/scripts/validate-suppa-schema.mjs <app-root>.)`;
|
|
25
25
|
|
|
26
26
|
/** What the gate blocks on, for a message that must not understate it. */
|
|
@@ -28,6 +28,6 @@ export const BLOCKING_SUMMARY =
|
|
|
28
28
|
"relation typing (E114/E115/W610/W615), PascalCase enum keys (W611), no option written at its " +
|
|
29
29
|
"default (W612), no global enum name on a local enum (W613), existing-entity stubs " +
|
|
30
30
|
"(E116/E117/W616/W617), extension mode — ignored entity options, no reverse relations, no primary, " +
|
|
31
|
-
"no NOT NULL without a default, indexes over your own columns only (W618/E118/E119/E120/E121/W620), " +
|
|
31
|
+
"no NOT NULL without a default, indexes over your own columns only (W618/E118/E119/E120/E121/E122/W620), " +
|
|
32
32
|
"`owner` first in a tabular part's importKeyFields (W607), and no " +
|
|
33
33
|
"`inverse` on @ManyToOne/@ManyToMany (W609)";
|
|
@@ -566,11 +566,22 @@ function analyzeEntities(ts, sf, model, opts = {}) {
|
|
|
566
566
|
// class: in extension mode these may only cover columns you declare.
|
|
567
567
|
classIndexes: decs
|
|
568
568
|
.filter((d) => d.name === "Index" || d.name === "Check")
|
|
569
|
-
.map((d) =>
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
569
|
+
.map((d) => {
|
|
570
|
+
const list = d.args.find((a) => ts.isArrayLiteralExpression(a));
|
|
571
|
+
const columns = stringArray(ts, list);
|
|
572
|
+
return {
|
|
573
|
+
name: d.name,
|
|
574
|
+
node: d.args[0] ?? node,
|
|
575
|
+
columns: columns ?? [],
|
|
576
|
+
// "no columns" and "columns I cannot read" are not the same
|
|
577
|
+
// answer, and collapsing them into [] made E121 pass silently
|
|
578
|
+
// on `@Index('i', COLS)` — a column list delivered by
|
|
579
|
+
// reference, which tsc accepts and which therefore ships. An
|
|
580
|
+
// extension indexing a column it does not own is exactly what
|
|
581
|
+
// that rule exists to stop, so an unreadable list has to speak.
|
|
582
|
+
columnsUnreadable: d.args.length > 0 && columns === null,
|
|
583
|
+
};
|
|
584
|
+
}),
|
|
574
585
|
// Reached by following a relation target rather than by being handed
|
|
575
586
|
// to this run; `outOfScope` marks one that is not the app's own code,
|
|
576
587
|
// and every rule skips those (see chaseRelationTargets' inScope).
|
|
@@ -1621,6 +1632,15 @@ function checkExtension(ts, info, findings) {
|
|
|
1621
1632
|
|
|
1622
1633
|
// "@Index() / @Check() covering a field you do not own" is not allowed.
|
|
1623
1634
|
for (const idx of info.classIndexes ?? []) {
|
|
1635
|
+
if (idx.columnsUnreadable) {
|
|
1636
|
+
findings.push(finding(ts, sf, idx.node, "E122",
|
|
1637
|
+
`@${idx.name} on extension '${info.className}' does not spell its columns out — the documented ` +
|
|
1638
|
+
`shape is @${idx.name}('<name>', ['<column>', …]), and a list delivered any other way (a const, a ` +
|
|
1639
|
+
`spread, an options object) cannot be read here. That leaves the one restriction extension mode ` +
|
|
1640
|
+
`turns on unchecked: an extension may only index or constrain the columns it declares itself. ` +
|
|
1641
|
+
`Write the array literally, in the decorator`));
|
|
1642
|
+
continue;
|
|
1643
|
+
}
|
|
1624
1644
|
for (const col of idx.columns) {
|
|
1625
1645
|
if (info.properties.has(col) || info.columnNames.has(col)) continue;
|
|
1626
1646
|
findings.push(finding(ts, sf, idx.node, "E121",
|
|
@@ -28,7 +28,9 @@ import {
|
|
|
28
28
|
// writing them here is a promise the platform does not keep (W618).
|
|
29
29
|
@Entity({ name: '__OwnerEntityName__' })
|
|
30
30
|
// Indexes and checks may cover only the columns declared BELOW — never one of
|
|
31
|
-
// the owner's (E121)
|
|
31
|
+
// the owner's (E121), and the column list is written out here as a literal
|
|
32
|
+
// array: one handed over as a const compiles, so it ships, and nothing can
|
|
33
|
+
// check what it covers (E122).
|
|
32
34
|
@Index('idx___owner_table_____field__', ['__field__'])
|
|
33
35
|
export class __OwnerEntity__Extension extends SystemBaseEntity {
|
|
34
36
|
// Your own columns, and only yours. The owner's fields are never part of
|