suppa-mcp-2 1.31.0 → 1.31.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.31.0",
3
+ "version": "1.31.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": {
@@ -78,6 +78,8 @@ Confirm all 5 before writing anything:
78
78
  ```
79
79
 
80
80
  `.stub.entity.ts` still ends in `.entity.ts`, so discovery and `entitiesPath` autoload are unchanged. **Registration is not what protects the real table — the empty body is.** Leaving a stub out of `forFeature()` to "keep the migration away from it" only makes the relation unresolvable (E301); a *fielded* stub that is registered is the actual disaster, and E117 is the rule that stops it. Platform system entities (`Users`, `Files`, `Icons`, …) need no stub at all — import `UsersEntity`/`FilesEntity`/`IconsEntity` from `@suppa/sdk`. Template: `templates/relation-target-stub.template.ts`.
81
+
82
+ **"ALREADY EXISTS" is a precondition, not a description — check it.** A stub is still a declaration, so if the entity is NOT on the tenant the platform creates it: an empty table, owned by YOU. The platform stamps `application` on an entity created by your migrations, which is exactly what a stub for a missing entity is. Confirm each target first — `suppa_describe_entity("Accounts")` answers in one call and reports the owning `application` (absent = nobody owns it). An entity that is not there is not a stub case: either it belongs in this package as a real entity, or the relation is pointing at the wrong name.
81
83
  20. **To ADD columns to an entity you do not own, declare an EXTENSION — a stub cannot do it.** A stub stands in for a table so a relation can point at it, and its body stays empty (rule 19). An extension is the opposite: it exists to contribute columns to an entity the platform or another application owns — `accountId` on `Users`, `plan` on another application's `Tasks` — "without touching that entity or the fields someone else declared on it". There is no separate API: declare `@Entity({ name: 'Users' })` by the entity's existing name, list ONLY the columns you are adding, and register it in `forFeature()` like any other class. The platform decides the mode by ownership at start — yours or nobody's → own mode (create/update in full); someone else's → extension mode (only your fields are applied).
82
84
  Because nothing in the code says which mode you will get, **the filename does**: `<entity-name>.extension.entity.ts`, class `<EntityName>Extension`. That is what makes the mode's restrictions checkable before the build:
83
85
 
@@ -92,7 +94,7 @@ Confirm all 5 before writing anything:
92
94
 
93
95
  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.
94
96
  **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.
95
- **Point a relation at an entity you do not own by NAME**: `@ManyToOne('Invoices', { … })` → `invoice?: { id: number }` — there is no class to import, so the string form is right here and only here (W620 everywhere else). Template: `templates/entity-extension.template.ts`; the doc's own section is transcribed in `references/extensions.md`.
97
+ **Point a relation at an entity you do not own**: the SDK takes NO string target — `@ManyToOne` is typed `() => Target` and *calls* it at registration, so `@ManyToOne('Invoices')` fails tsc and would throw. Name the entity on a raw column: `@Column({ type: RelationTypeEnum.ManyToOne, relationEntityName: 'Invoices', relationFieldName: 'id', nullable: true }) invoice?: { id: number }` — registration reads `relationEntityName` instead of calling a thunk. A string target is W620 everywhere. Template: `templates/entity-extension.template.ts`; the doc's own section is transcribed in `references/extensions.md`.
96
98
  **Prefer an entity-scoped enum in an extension.** A global enum name has no owning entity, so two applications using the same name write to the same rows — which is rule 18's default anyway: pass no name.
97
99
  21. **`EntityModule.forFeature()` must be consumed by an `@Module`, and has exactly two shapes.** It RETURNS a module: put it in `@Module({ imports: [...] })` and export that class from `src/index.ts` as `AppModule` — a bare `EntityModule.forFeature(...);` statement discards the result and registers nothing (E307). The two shapes (`references/registration.md`) are `forFeature([A, B], { seeds: [...] })` — classes FIRST, options second — and `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.
98
100
 
@@ -347,7 +349,7 @@ The validator parses with the TypeScript compiler API, read from the app repo yo
347
349
  | Two entity classes share a name across files | The checker keys entities by class name, so only the first is analyzed and the other is schema code nothing checked. Rename one class — the table's name is the `@Entity({ name })` option and does not change | W619 (blocks the gate) |
348
350
  | 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 |
349
351
  | 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 |
350
- | 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) |
352
+ | A relation names its target with a string (`@ManyToOne('Invoices', …)`), anywhere | The SDK types the target `() => Target` and calls it at registration — a string fails tsc and would throw. Use a thunk, or `@Column({ relationEntityName: 'Invoices', … })` for an entity you cannot import | W620 (blocks the gate) |
351
353
  | A stub kept its fields, and the migration altered a table another application owns | The empty body is the whole point of a stub — a fielded one converges columns onto the real table | E117 |
352
354
  | A field-less entity that is really a stub, in an ordinary `*.entity.ts` | Nothing marks it as a stub, so E117 cannot apply — rename to `<name>.stub.entity.ts` | W617 (blocks the gate) |
353
355
  | Several stubs piled into one `relation-targets.ts` | Each existing-entity stub lives in its OWN file | W616 (blocks the gate) |
@@ -109,7 +109,7 @@ import {
109
109
  Entity,
110
110
  FieldTypeEnum,
111
111
  Index,
112
- ManyToOne,
112
+ RelationTypeEnum,
113
113
  SystemBaseEntity,
114
114
  } from '@suppa/sdk';
115
115
 
@@ -123,7 +123,11 @@ export class TasksBillingExtension extends SystemBaseEntity {
123
123
  })
124
124
  plan?: string;
125
125
 
126
- @ManyToOne('Invoices', {
126
+ @Column({
127
+ type: RelationTypeEnum.ManyToOne,
128
+ relationEntityName: 'Invoices',
129
+ relationFieldName: 'id',
130
+ nullable: true,
127
131
  title: { en: 'Invoice', uk: 'Рахунок' },
128
132
  })
129
133
  invoice?: { id: number };
@@ -135,4 +139,4 @@ After both applications start, the `Tasks` table has `name`, `plan` and `invoice
135
139
  > **HOUSE RULE — the filename declares the intent (SKILL.md rule 20).**
136
140
  > 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). The same holds for the options objects themselves: `@Entity(OPTS)` or `@Column(OPTS)` hides `primary`, `nullable` and even which entity is being extended, so an extension writes them out literally (E123).
137
141
  >
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.
142
+ > Note the relation form. There is no class to import for an entity another application owns — and the SDK takes **no string target**: `@ManyToOne` is typed `() => Target` and *calls* it at registration (`const entityClass = lazyTarget()`), so `@ManyToOne('Invoices')` fails to compile and would throw if it did. Name the entity on a raw column instead: registration reads `relationEntityName` and never calls a thunk. The property is still typed by shape — `invoice?: { id: number }`. A string target is W620 everywhere, this section included.
@@ -715,8 +715,8 @@ function analyzeEntities(ts, sf, model, opts = {}) {
715
715
  kind: RELATION_KIND_BY_DECORATOR[d.name],
716
716
  node: member, decorator: d,
717
717
  targetClass: thunkTarget(ts, sf, d.args[0]),
718
- // @ManyToOne('Invoices', { ... }) — there is no class to import
719
- // for an entity another application owns.
718
+ // Captured only so W620 can report it: a string target is
719
+ // not a form the SDK accepts, here or anywhere.
720
720
  targetName: stringValue(ts, unwrapExpr(ts, d.args[0])),
721
721
  targetLocalText: thunkLocalText(ts, d.args[0]),
722
722
  nameNode: relOptions.get("name") ?? null,
@@ -20,6 +20,13 @@
20
20
  * invisible to the platform (E301), and the empty body, not the missing
21
21
  * registration, is what keeps the migration off the real table.
22
22
  *
23
+ * BEFORE YOU WRITE ONE: confirm the entity is actually on the tenant.
24
+ * A stub is a declaration like any other, so for an entity that is NOT
25
+ * there the platform CREATES it — an empty table, stamped with YOUR
26
+ * application as its owner, because it came from your migrations.
27
+ * suppa_describe_entity("<Name>") answers in one call and reports the
28
+ * owning application (absent means nobody owns it).
29
+ *
23
30
  * One stub per file (W616). Platform system entities need no stub at all —
24
31
  * import UsersEntity/FilesEntity/IconsEntity from '@suppa/sdk' instead.
25
32
  */