suppa-mcp-2 1.30.0 → 1.31.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suppa-mcp-2",
3
- "version": "1.30.0",
3
+ "version": "1.31.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": {
@@ -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\`); 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: \`@Enum(StatusEnum, StatusTitles, { … })\` 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 — 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 — it only lets a relation 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; there is no separate API. Declare the entity by its EXISTING name with only your own columns, in \`<owner-entity>.extension.entity.ts\` (class \`<OwnerEntity>Extension\`), registered 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); @Index/@Check only over your own columns, listed as a literal array (E121/E122). Write @Entity()/@Column() options as literal objects — one passed by reference or through a spread cannot be read, so none of this can be checked on it (E123). A relation to an entity you do not own is named by STRING and typed by shape — \`@ManyToOne('Invoices', { … }) invoice?: { id: number };\` — there and nowhere else (W620).
23
+ 6. TO ADD COLUMNS TO AN ENTITY YOU DO NOT OWN, DECLARE AN EXTENSION — not a stub; there is no separate API. Declare the entity by its EXISTING name with only your own columns, in \`<owner-entity>.extension.entity.ts\` (class \`<OwnerEntity>Extension\`), registered 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); @Index/@Check only over your own columns, listed as a literal array (E121/E122). Write @Entity()/@Column() options as literal objects — one passed by reference or through a spread cannot be read, so none of this can be checked on it (E123). A relation to an entity you do not own takes NO string target - name it on a raw column (W620): \`@Column({ type: RelationTypeEnum.ManyToOne, relationEntityName: 'Invoices', relationFieldName: 'id' }) invoice?: { id: number };\`.
24
24
  Before reporting the file done, run the gate: 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". (CLI: 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. */
@@ -79,6 +79,13 @@ export const RULE_WARNINGS = [
79
79
  */
80
80
  export const RULE_WARNINGS_NEEDING_WHOLE_REPO = ["W613"];
81
81
  export const DOC_COLUMN_OPTIONS = ["type", "subType", "name", "nullable", "primary", "unique", "default", "length", "title", "comment", "key", "minLength", "minValue", "maxValue", "decimalPlaces", "isOnlyPositive", "mask",
82
+ // The only supported way to point at an entity you cannot import. The
83
+ // relation decorators deliberately Omit both from their options type
84
+ // (RelationDecoratorOptions), so the raw column is where they belong —
85
+ // and registration reads relationEntityName INSTEAD of calling a thunk
86
+ // (system-entity-decorator-registry.util.ts). Verified against the SDK
87
+ // source at 1.37.1, not inferred.
88
+ "relationEntityName", "relationFieldName",
82
89
  // Field options. The decorator tables do not list them, but migrations.txt:245
83
90
  // names four of them as options a column carries — encryption makes "the
84
91
  // searchable, canFilter, canSort and canGroup options become false" — and the
@@ -925,17 +932,28 @@ function checkEntity(ts, info, sdk, model, findings) {
925
932
  if (RELATION_KINDS.has(prop.kind)) {
926
933
  checkRelationTyping(ts, sf, propName, prop, findings);
927
934
  if (prop.targetClass === null && prop.targetName !== null) {
928
- // @ManyToOne('Invoices', { ... }) — naming the target by string is how
929
- // you point at an entity you do not own, since there is no class to
930
- // import. Outside an extension it hides a target this checker could
931
- // have verified.
932
- if (!info.isExtension) {
933
- findings.push(finding(ts, sf, prop.node, "W620",
934
- `relation '${propName}' names its target by string ('${prop.targetName}') instead of a thunk — ` +
935
- `that form is for extension declarations, where the target belongs to another application and there ` +
936
- `is no class to import. In your own entity write @${prop.decorator.name}(() => ${prop.targetName}) so ` +
937
- `the target is resolved and checked`));
938
- }
935
+ // @ManyToOne('Invoices', { ... }) does not work ANYWHERE, and this
936
+ // checker used to bless it inside extensions. Read against the SDK
937
+ // source (git.modern-expo.com/suppa/sdk, 1.37.1): the decorator is
938
+ // typed `target: () => { new (...args): T }`, so a string fails tsc;
939
+ // and registration does `const entityClass = lazyTarget()`, so a
940
+ // string that got past tsc throws "lazyTarget is not a function".
941
+ // There is no string branch in the SDK at all.
942
+ //
943
+ // The supported way to name a target with no class to import is the
944
+ // raw column: registration only calls the thunk when
945
+ // relationEntityName is absent.
946
+ findings.push(finding(ts, sf, prop.node, "W620",
947
+ info.isExtension
948
+ ? `relation '${propName}' names its target by string ('${prop.targetName}'). The SDK accepts no ` +
949
+ `string target: @${prop.decorator.name} is typed () => Target, and registration CALLS it, so a ` +
950
+ `string throws "lazyTarget is not a function". For a target you cannot import, write the raw ` +
951
+ `column instead: @Column({ type: RelationTypeEnum.${prop.decorator.name}, relationEntityName: ` +
952
+ `'${prop.targetName}', relationFieldName: 'id', nullable: true }) ${propName}?: { id: number };`
953
+ : `relation '${propName}' names its target by string ('${prop.targetName}') instead of a thunk — ` +
954
+ `the SDK is typed () => Target and calls it at registration, so a string fails to compile and ` +
955
+ `would throw if it did. Write @${prop.decorator.name}(() => ${prop.targetName}) so the target is ` +
956
+ `resolved and checked`));
939
957
  } else if (prop.targetClass === null) {
940
958
  findings.push(finding(ts, sf, prop.node, "E105",
941
959
  `relation '${propName}' must receive a thunk returning the target class — write @${prop.decorator.name}(() => Target); a direct class reference breaks circular imports`));
@@ -1680,7 +1698,17 @@ function checkExtension(ts, info, findings) {
1680
1698
  `extension '${info.className}' sets the entity option '${opt}', which extension mode IGNORES — ` +
1681
1699
  `title, icon, type, options, representativeFieldName, importKeyFields and the entity's localization ` +
1682
1700
  `belong to whoever owns ${target}. Delete it: code the platform discards reads as a promise ` +
1683
- `it does not keep. Only @Entity({ name: ${named ? `'${info.entityName}'` : "…"} }) and your own columns belong here`));
1701
+ `it does not keep. Only @Entity({ name: ${named ? `'${info.entityName}'` : "…"} }) and your own columns belong here` +
1702
+ // Deleting the line is only half an answer when the developer actually
1703
+ // needed the option ON. Ownership makes this a runtime operation, not a
1704
+ // gap in the tooling — say so here rather than leaving them to guess.
1705
+ (opt === "options"
1706
+ ? `. If you need an option ENABLED on an entity you do not own — customFields, comments, ` +
1707
+ `trackChangeHistory — that is an owner action and cannot come from a file: call ` +
1708
+ `suppa_update_entity_options(entity_name, options_json) once. It is a schema change ` +
1709
+ `(enabling customFields creates the {Entity}CustomFields side table), so record it in the ` +
1710
+ `plan beside the code that depends on it`
1711
+ : "")));
1684
1712
  }
1685
1713
 
1686
1714
  if (info.properties.size === 0) {
@@ -54,10 +54,15 @@ export class __OwnerEntity__Extension extends SystemBaseEntity {
54
54
  // @Column({ type: FieldTypeEnum.Boolean, nullable: false, default: 'false' })
55
55
  // __flag__: boolean;
56
56
 
57
- // A relation to an entity you do not own has no class to import, so the
58
- // target is named by STRING and the property is typed by shape. This is the
59
- // one place that form is right; in your own entities it is a thunk (W620).
60
- @ManyToOne('__TargetEntityName__', {
57
+ // A relation to an entity you do not own has no class to import. The SDK
58
+ // accepts NO string target — @ManyToOne is typed () => Target and calls it
59
+ // at registration — so name the entity on a raw column instead. The thunk
60
+ // is only consulted when relationEntityName is absent (W620).
61
+ @Column({
62
+ type: RelationTypeEnum.ManyToOne,
63
+ relationEntityName: '__TargetEntityName__',
64
+ relationFieldName: 'id',
65
+ nullable: true,
61
66
  title: { en: '__Target title__', uk: '__Назва звʼязку__' },
62
67
  })
63
68
  __target__?: { id: number };