suppa-mcp-2 1.30.1 → 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.
|
|
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
|
|
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', { ... })
|
|
929
|
-
//
|
|
930
|
-
//
|
|
931
|
-
//
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
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`));
|
|
@@ -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
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
|
|
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 };
|