suppa-mcp-2 1.1.4 → 1.2.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/LICENSE +21 -21
- package/README.md +379 -342
- package/dist/auth.js +29 -25
- package/dist/server.js +91 -50
- package/dist/tools/entity.js +343 -40
- package/dist/tools/migrate.js +148 -11
- package/package.json +50 -50
- package/skills/suppa-entity-code/SKILL.md +122 -0
- package/skills/suppa-entity-code/references/entities.md +289 -0
- package/skills/suppa-entity-code/references/registration.md +174 -0
- package/skills/suppa-entity-code/references/seeds.md +134 -0
- package/skills/suppa-entity-code/references/v1-mapping.md +78 -0
- package/skills/suppa-entity-code/scripts/validate-suppa-schema.mjs +692 -0
- package/skills/suppa-entity-code/templates/entity.template.ts +79 -0
- package/skills/suppa-entity-code/templates/seed.template.ts +41 -0
package/dist/auth.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Two responsibilities, both transparent to tools:
|
|
5
5
|
*
|
|
6
6
|
* 1. `maybeRefresh` — called from `tenants.ensureValid` before every request.
|
|
7
|
-
* If the stored access token is near expiry it
|
|
7
|
+
* If the stored access token is near expiry it GETs the refresh endpoint
|
|
8
8
|
* (under a per-tenant single-flight guard), persists the *rotated* access
|
|
9
9
|
* *and* refresh tokens, and lets the request proceed. If the refresh token
|
|
10
10
|
* itself is gone/expired it throws {@link ReloginRequired}.
|
|
@@ -176,7 +176,7 @@ function readSetCookies(headers) {
|
|
|
176
176
|
return [];
|
|
177
177
|
}
|
|
178
178
|
const rawPost = async (url, opts) => {
|
|
179
|
-
const { cookie = "", body = null, timeout = 60 } = opts;
|
|
179
|
+
const { cookie = "", body = null, timeout = 60, method = "POST" } = opts;
|
|
180
180
|
const headers = {
|
|
181
181
|
Accept: "application/json, text/plain, */*",
|
|
182
182
|
};
|
|
@@ -193,7 +193,7 @@ const rawPost = async (url, opts) => {
|
|
|
193
193
|
let resp;
|
|
194
194
|
try {
|
|
195
195
|
resp = await fetch(url, {
|
|
196
|
-
method
|
|
196
|
+
method,
|
|
197
197
|
headers,
|
|
198
198
|
body: data,
|
|
199
199
|
signal: controller.signal,
|
|
@@ -365,8 +365,12 @@ export async function forceRefresh(ctx) {
|
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
export async function doRefresh(baseUrl, host, creds) {
|
|
368
|
+
// The platform exposes refresh as GET only (the web client does
|
|
369
|
+
// `axios.get('/auth/accounts/refresh-token', { withCredentials })`);
|
|
370
|
+
// a POST 404s on production backends.
|
|
368
371
|
const { body, cookies } = await authPost(baseUrl + REFRESH_PATH, {
|
|
369
372
|
cookie: `refreshToken=${creds.refreshToken}`,
|
|
373
|
+
method: "GET",
|
|
370
374
|
});
|
|
371
375
|
const fresh = extractCredentials(body, cookies);
|
|
372
376
|
if (!fresh.accessToken) {
|
|
@@ -384,28 +388,28 @@ export async function doRefresh(baseUrl, host, creds) {
|
|
|
384
388
|
// ---------------------------------------------------------------------------
|
|
385
389
|
// Google login (browser loopback + GIS)
|
|
386
390
|
// ---------------------------------------------------------------------------
|
|
387
|
-
const LOGIN_HTML = `<!doctype html>
|
|
388
|
-
<html><head><meta charset="utf-8"><title>Suppa login</title>
|
|
389
|
-
<script src="https://accounts.google.com/gsi/client" async></script>
|
|
390
|
-
<style>body{font-family:system-ui,sans-serif;display:flex;flex-direction:column;
|
|
391
|
-
align-items:center;justify-content:center;height:100vh;margin:0;gap:1.5rem}
|
|
392
|
-
#msg{color:#444}</style></head>
|
|
393
|
-
<body>
|
|
394
|
-
<h2>Sign in to Suppa — __HOST__</h2>
|
|
395
|
-
<div id="g_id_onload" data-client_id="__CLIENT_ID__" data-callback="onCred"
|
|
396
|
-
data-auto_select="false" data-ux_mode="popup"></div>
|
|
397
|
-
<div class="g_id_signin" data-type="standard" data-size="large"
|
|
398
|
-
data-text="signin_with" data-shape="rectangular"></div>
|
|
399
|
-
<div id="msg"></div>
|
|
400
|
-
<script>
|
|
401
|
-
function onCred(resp){
|
|
402
|
-
document.getElementById('msg').textContent='Signing in…';
|
|
403
|
-
fetch('/callback',{method:'POST',headers:{'Content-Type':'application/json'},
|
|
404
|
-
body:JSON.stringify({credential:resp.credential,state:"__STATE__"})})
|
|
405
|
-
.then(r=>r.text()).then(t=>{document.body.innerHTML=
|
|
406
|
-
'<h2>'+t+'</h2><p>You can close this tab and return to your agent.</p>';});
|
|
407
|
-
}
|
|
408
|
-
</script>
|
|
391
|
+
const LOGIN_HTML = `<!doctype html>
|
|
392
|
+
<html><head><meta charset="utf-8"><title>Suppa login</title>
|
|
393
|
+
<script src="https://accounts.google.com/gsi/client" async></script>
|
|
394
|
+
<style>body{font-family:system-ui,sans-serif;display:flex;flex-direction:column;
|
|
395
|
+
align-items:center;justify-content:center;height:100vh;margin:0;gap:1.5rem}
|
|
396
|
+
#msg{color:#444}</style></head>
|
|
397
|
+
<body>
|
|
398
|
+
<h2>Sign in to Suppa — __HOST__</h2>
|
|
399
|
+
<div id="g_id_onload" data-client_id="__CLIENT_ID__" data-callback="onCred"
|
|
400
|
+
data-auto_select="false" data-ux_mode="popup"></div>
|
|
401
|
+
<div class="g_id_signin" data-type="standard" data-size="large"
|
|
402
|
+
data-text="signin_with" data-shape="rectangular"></div>
|
|
403
|
+
<div id="msg"></div>
|
|
404
|
+
<script>
|
|
405
|
+
function onCred(resp){
|
|
406
|
+
document.getElementById('msg').textContent='Signing in…';
|
|
407
|
+
fetch('/callback',{method:'POST',headers:{'Content-Type':'application/json'},
|
|
408
|
+
body:JSON.stringify({credential:resp.credential,state:"__STATE__"})})
|
|
409
|
+
.then(r=>r.text()).then(t=>{document.body.innerHTML=
|
|
410
|
+
'<h2>'+t+'</h2><p>You can close this tab and return to your agent.</p>';});
|
|
411
|
+
}
|
|
412
|
+
</script>
|
|
409
413
|
</body></html>`;
|
|
410
414
|
/** HTML-escape text. Mirrors Python's html.escape (quote=True by default here). */
|
|
411
415
|
function htmlEscape(text, quote = true) {
|
package/dist/server.js
CHANGED
|
@@ -140,51 +140,53 @@ const EntityQuery = z
|
|
|
140
140
|
// ---------------------------------------------------------------------------
|
|
141
141
|
// Server instructions — reproduced VERBATIM from server.py.
|
|
142
142
|
// ---------------------------------------------------------------------------
|
|
143
|
-
const INSTRUCTIONS = `Suppa Platform MCP Server — manage Tasks, Docs/Pages, Entities, Forms, and file attachments on modern.suppa.me.
|
|
144
|
-
|
|
145
|
-
AUTHENTICATION — RESOLVE THIS BEFORE ANY OTHER SUPPA WORK
|
|
146
|
-
- Auth is an interactive Google browser sign-in. There is NO API key for an end user to find or paste — so NEVER ask the user for a token, key, or password. If you're tempted to ask for credentials, call suppa_login instead.
|
|
147
|
-
- At the start of Suppa work, if you don't already know the user is signed in, call suppa_list_tenants (cheap, read-only). Look at the ACTIVE tenant: if "authenticated": false or "needs_login": true, the user is not signed in.
|
|
148
|
-
- Whenever the user is not signed in — OR any tool returns "No Suppa credentials" / HTTP 401 / "session could not be refreshed" / a ReloginRequired error — DO NOT STOP and DO NOT ask for a key. Authenticate yourself:
|
|
149
|
-
1. Call suppa_login (or suppa_login(tenant="<alias|host|url>") to target a specific instance; default is the active tenant). This OPENS A GOOGLE SIGN-IN PAGE in the user's default browser — a local page served at http://localhost:8080.
|
|
150
|
-
2. Tell the user in plain words: "I've opened a Google sign-in page in your browser — pick your account to finish signing in." If the browser didn't open, the tool result carries the URL; give it to them to open manually.
|
|
151
|
-
3. suppa_login blocks until they finish and returns {"status":"ok"}. THEN retry the original action. Tokens are stored in the OS keychain and auto-refresh, so this is a one-time step per tenant — you won't need to repeat it next session.
|
|
152
|
-
- A static SUPPA_API_KEY in the client env is supported (CI / single-tenant) and, when present, means no login is needed — but it is optional and most users won't have one.
|
|
153
|
-
- Use suppa_diagnostics to validate the whole setup; it reports the login_origin that must be whitelisted. ONE-TIME ORG SETUP: the loopback origin (http://localhost:8080) must be added to the Google OAuth client's "Authorized JavaScript origins". If the sign-in page opens but never completes, that missing whitelist entry is almost always why — surface this to the user so an admin can add it.
|
|
154
|
-
- suppa_use_tenant switches the active instance for ALL later calls; suppa_list_tenants shows what's known and authenticated.
|
|
155
|
-
|
|
156
|
-
DATA BASICS
|
|
157
|
-
- IDs are integers (not UUIDs).
|
|
158
|
-
- Dates are ISO-8601 strings. A naive datetime (no offset) is treated as UTC — include an explicit offset (e.g. +03:00) or pre-convert local times to UTC to avoid a silent shift.
|
|
159
|
-
- Task deadlines also accept 'today', 'tomorrow', '+3d', '+2h', '+30m', '+1w'.
|
|
160
|
-
- WRITE relations as {"id": N} and enum fields as {"id": <enumValueId>} — a bare number/string would return 201 but silently store null; suppa_create_record/suppa_update_record therefore REFUSE malformed shapes with guidance.
|
|
161
|
-
-
|
|
162
|
-
-
|
|
163
|
-
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
-
|
|
168
|
-
-
|
|
169
|
-
-
|
|
170
|
-
-
|
|
171
|
-
-
|
|
172
|
-
-
|
|
173
|
-
-
|
|
174
|
-
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
-
|
|
179
|
-
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
-
|
|
184
|
-
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
143
|
+
const INSTRUCTIONS = `Suppa Platform MCP Server — manage Tasks, Docs/Pages, Entities, Forms, and file attachments on modern.suppa.me.
|
|
144
|
+
|
|
145
|
+
AUTHENTICATION — RESOLVE THIS BEFORE ANY OTHER SUPPA WORK
|
|
146
|
+
- Auth is an interactive Google browser sign-in. There is NO API key for an end user to find or paste — so NEVER ask the user for a token, key, or password. If you're tempted to ask for credentials, call suppa_login instead.
|
|
147
|
+
- At the start of Suppa work, if you don't already know the user is signed in, call suppa_list_tenants (cheap, read-only). Look at the ACTIVE tenant: if "authenticated": false or "needs_login": true, the user is not signed in.
|
|
148
|
+
- Whenever the user is not signed in — OR any tool returns "No Suppa credentials" / HTTP 401 / "session could not be refreshed" / a ReloginRequired error — DO NOT STOP and DO NOT ask for a key. Authenticate yourself:
|
|
149
|
+
1. Call suppa_login (or suppa_login(tenant="<alias|host|url>") to target a specific instance; default is the active tenant). This OPENS A GOOGLE SIGN-IN PAGE in the user's default browser — a local page served at http://localhost:8080.
|
|
150
|
+
2. Tell the user in plain words: "I've opened a Google sign-in page in your browser — pick your account to finish signing in." If the browser didn't open, the tool result carries the URL; give it to them to open manually.
|
|
151
|
+
3. suppa_login blocks until they finish and returns {"status":"ok"}. THEN retry the original action. Tokens are stored in the OS keychain and auto-refresh, so this is a one-time step per tenant — you won't need to repeat it next session.
|
|
152
|
+
- A static SUPPA_API_KEY in the client env is supported (CI / single-tenant) and, when present, means no login is needed — but it is optional and most users won't have one.
|
|
153
|
+
- Use suppa_diagnostics to validate the whole setup; it reports the login_origin that must be whitelisted. ONE-TIME ORG SETUP: the loopback origin (http://localhost:8080) must be added to the Google OAuth client's "Authorized JavaScript origins". If the sign-in page opens but never completes, that missing whitelist entry is almost always why — surface this to the user so an admin can add it.
|
|
154
|
+
- suppa_use_tenant switches the active instance for ALL later calls; suppa_list_tenants shows what's known and authenticated.
|
|
155
|
+
|
|
156
|
+
DATA BASICS
|
|
157
|
+
- IDs are integers (not UUIDs).
|
|
158
|
+
- Dates are ISO-8601 strings. A naive datetime (no offset) is treated as UTC — include an explicit offset (e.g. +03:00) or pre-convert local times to UTC to avoid a silent shift.
|
|
159
|
+
- Task deadlines also accept 'today', 'tomorrow', '+3d', '+2h', '+30m', '+1w'.
|
|
160
|
+
- WRITE relations as {"id": N} and enum fields as {"id": <enumValueId>} — a bare number/string would return 201 but silently store null; suppa_create_record/suppa_update_record therefore REFUSE malformed shapes with guidance.
|
|
161
|
+
- Record writes are validated against the live schema BEFORE writing: an unknown field name or a non-existent entity is REFUSED (the platform silently drops unknown keys → a record missing data). Use only real fields (suppa_describe_entity), or add the field first with suppa_add_field. Don't invent field names.
|
|
162
|
+
- READ enum fields back as objects: project {"myEnum": {"value": true}} and read .value, never as a bare string.
|
|
163
|
+
- HTML content (descriptions, comments, blocks): plain text is auto-wrapped in <p>…</p>; to pass raw HTML start the string with <.
|
|
164
|
+
- A document's LAST page cannot be deleted (platform rule) — delete the doc itself instead.
|
|
165
|
+
|
|
166
|
+
SEARCH & FILTERS
|
|
167
|
+
- Filters: {"field": "name", "value": "...", "comparator": "="} — comparators: =, !=, <, >, <=, >=, like, in, is null, is not null.
|
|
168
|
+
- 'like' requires SQL wildcards: %substring%. 'in' takes a JSON array value.
|
|
169
|
+
- Filters combine with AND by default; pass match_any=true (search_records) for OR.
|
|
170
|
+
- Dotted field paths work in filters: "stage.status.value", "owner.id".
|
|
171
|
+
- Magic value "$current-user" resolves to the authenticated user's ID.
|
|
172
|
+
- Project only the fields you need (fields_json) — it keeps responses small and fast.
|
|
173
|
+
- suppa_search_tasks / suppa_search_records return {…, "has_more", "next_offset"}: when has_more is true, re-call with offset=next_offset to page; never assume the first page is everything.
|
|
174
|
+
- One record by id: suppa_get_record (any entity) / suppa_get_task / suppa_get_doc — no filters needed.
|
|
175
|
+
- Discover schema first when unsure: suppa_list_entities → suppa_describe_entity, then suppa_search_records.
|
|
176
|
+
|
|
177
|
+
APPROVAL GATES (human-in-the-loop)
|
|
178
|
+
- Every update/move/close/delete tool returns {"status": "confirmation_required"} when called without confirm=true, and performs NOTHING.
|
|
179
|
+
- On that response: show the user what will change, get explicit approval, then re-call the same tool with confirm=true. Never set confirm=true on the first call without the user's go-ahead.
|
|
180
|
+
- Create/read tools (and comments) need no confirmation.
|
|
181
|
+
|
|
182
|
+
ENTITY BUILDER (add-only by design)
|
|
183
|
+
- Real field types only: text, numeric, integer, serial, boolean, timestamp, json, uuid, multi-language, icon, enum, multi-enum, file, multi-file, many-to-one, many-to-many, many-to-many-backref. There is NO date/datetime/richtext/email/url/phone type — use timestamp (+sub_type='date') or multi-language.
|
|
184
|
+
- OWNED CHILD COLLECTIONS ARE TABULAR PARTS. Repeating rows that belong to one parent record (e.g. a part's BOM items) → suppa_create_tabular_part(parent_entity, name), which auto-creates the child's 'owner' relation and the parent link. NEVER model this by hand as parent.one-to-many + child.owner: suppa_add_field REFUSES field_type='one-to-many'. Use 'many-to-many' only for a shared lookup referenced by many records.
|
|
185
|
+
- Relations need relation_entity; enums need enum_name (qualified 'Entity.field') with values added via suppa_add_enum_values.
|
|
186
|
+
- Removing/altering existing fields is UI-only by design — this server can only add.
|
|
187
|
+
|
|
188
|
+
MIGRATION (Suppa 1.0 → 2.0)
|
|
189
|
+
- Always dry-run first: suppa_migrate_entities_from_v1(dry_run=true, output_file="plan.json"), review/edit the plan, then execute with plan_file="plan.json", dry_run=false.
|
|
188
190
|
`;
|
|
189
191
|
// ---------------------------------------------------------------------------
|
|
190
192
|
// Registered tool + prompt names (tests assert the counts).
|
|
@@ -795,12 +797,16 @@ export function buildServer() {
|
|
|
795
797
|
description: "Add a field to an entity.\n\n" +
|
|
796
798
|
" field_type: a real Suppa 2.0 type — text, numeric, integer, serial, boolean,\n" +
|
|
797
799
|
" timestamp, json, uuid, multi-language, icon, enum, multi-enum, file, multi-file,\n" +
|
|
798
|
-
"
|
|
800
|
+
" many-to-one, many-to-many, many-to-many-backref. There is NO\n" +
|
|
799
801
|
" date/datetime/richtext/email/url/phone type — use timestamp (+sub_type='date'\n" +
|
|
800
802
|
" for date-only) and multi-language for localized text. 'relation' is accepted\n" +
|
|
801
803
|
" as an alias for many-to-one. Provide relation_entity for relations, enum_name\n" +
|
|
802
804
|
" for enums. Constraints: max_length/min_length (text), decimal_places /\n" +
|
|
803
|
-
" min_value / max_value / only_positive (numeric)
|
|
805
|
+
" min_value / max_value / only_positive (numeric).\n" +
|
|
806
|
+
" 'one-to-many' is REFUSED: an owned child collection is a TABULAR PART\n" +
|
|
807
|
+
" (suppa_create_tabular_part, which auto-creates the child's 'owner' and the\n" +
|
|
808
|
+
" parent link); never hand-build parent.one-to-many + child.owner. Use\n" +
|
|
809
|
+
" 'many-to-many' for a shared lookup referenced by many records.",
|
|
804
810
|
inputSchema: {
|
|
805
811
|
entity_name: EntityName,
|
|
806
812
|
field_name: z
|
|
@@ -808,7 +814,7 @@ export function buildServer() {
|
|
|
808
814
|
.describe("camelCase field name, e.g. 'orderDate'."),
|
|
809
815
|
field_type: z
|
|
810
816
|
.string()
|
|
811
|
-
.describe("A real Suppa 2.0 type (see suppa_list_field_types). NO date/richtext/email type exists — use 'timestamp' (+sub_type='date') or 'multi-language'."),
|
|
817
|
+
.describe("A real Suppa 2.0 type (see suppa_list_field_types). NO date/richtext/email type exists — use 'timestamp' (+sub_type='date') or 'multi-language'. 'one-to-many' is refused — use suppa_create_tabular_part for owned children, 'many-to-many' for shared lookups."),
|
|
812
818
|
title: z.string().nullable().default(null),
|
|
813
819
|
required: z.boolean().default(false),
|
|
814
820
|
unique: z.boolean().default(false),
|
|
@@ -1169,7 +1175,11 @@ export function buildServer() {
|
|
|
1169
1175
|
" include_builtin: include builtin/system entities (default: custom only).\n" +
|
|
1170
1176
|
" skip_relations: skip relation/foreign-key fields.\n" +
|
|
1171
1177
|
" output_file: write the plan as JSON to this path (for review/editing).\n" +
|
|
1172
|
-
" plan_file: load the plan from this JSON file instead of reading from Suppa 1.0.\n
|
|
1178
|
+
" plan_file: load the plan from this JSON file instead of reading from Suppa 1.0.\n" +
|
|
1179
|
+
" check_relation_instances: probe Suppa 1.0 to see whether each relation candidate is\n" +
|
|
1180
|
+
" actually populated in the source; annotates the plan with v1_populated + create.\n" +
|
|
1181
|
+
" skip_empty_relations: exclude relation fields that have no populated instances in v1\n" +
|
|
1182
|
+
" (create:false) — deciding the field isn't needed. Probe errors keep the field.\n ",
|
|
1173
1183
|
inputSchema: {
|
|
1174
1184
|
dry_run: z
|
|
1175
1185
|
.boolean()
|
|
@@ -1199,9 +1209,17 @@ export function buildServer() {
|
|
|
1199
1209
|
.string()
|
|
1200
1210
|
.default("create")
|
|
1201
1211
|
.describe("'create'/'gap-fill' (idempotent: skip existing) or 'reconcile' (read-only diff vs live 2.0, writes nothing)."),
|
|
1212
|
+
check_relation_instances: z
|
|
1213
|
+
.boolean()
|
|
1214
|
+
.default(true)
|
|
1215
|
+
.describe("Probe Suppa 1.0 (POST /api/search/{alias}) for whether each relation candidate is populated; annotates the plan with v1_populated + create."),
|
|
1216
|
+
skip_empty_relations: z
|
|
1217
|
+
.boolean()
|
|
1218
|
+
.default(true)
|
|
1219
|
+
.describe("Exclude relation fields with no populated instances in v1 (create:false). Probe errors keep the field; set false to keep every relation."),
|
|
1202
1220
|
},
|
|
1203
1221
|
annotations: _ADD,
|
|
1204
|
-
}, async (a) => text(await migrate.migrateEntities(a.dry_run, a.entity_names, a.include_builtin, a.skip_relations, a.output_file, a.plan_file, a.mode)));
|
|
1222
|
+
}, async (a) => text(await migrate.migrateEntities(a.dry_run, a.entity_names, a.include_builtin, a.skip_relations, a.output_file, a.plan_file, a.mode, a.check_relation_instances, a.skip_empty_relations)));
|
|
1205
1223
|
reg("suppa_read_v1_entities", {
|
|
1206
1224
|
description: "List entities on the configured Suppa 1.0 backend (read-only).",
|
|
1207
1225
|
inputSchema: {
|
|
@@ -1624,6 +1642,29 @@ export function buildServer() {
|
|
|
1624
1642
|
'4. Only after my explicit approval: suppa_migrate_entities_from_v1(dry_run=false, plan_file="migration_plan.json").\n' +
|
|
1625
1643
|
"5. Verify: suppa_describe_entity for each migrated entity; report failures from the execution report.");
|
|
1626
1644
|
});
|
|
1645
|
+
regPrompt("write_entity_code", {
|
|
1646
|
+
description: "Guided: write Suppa 2.0 application schema CODE (entity classes, seeds, EntityModule registration) instead of creating schema via API tools",
|
|
1647
|
+
argsSchema: {
|
|
1648
|
+
entity_purpose: z
|
|
1649
|
+
.string()
|
|
1650
|
+
.describe("What to build — the data model, or the name of a Suppa 1.0 entity to port to v2 code."),
|
|
1651
|
+
},
|
|
1652
|
+
}, (a) => `Write Suppa 2.0 application schema code for: ${a.entity_purpose}\n\n` +
|
|
1653
|
+
"Follow the bundled 'suppa-entity-code' skill (skills/suppa-entity-code/SKILL.md inside the installed suppa-mcp-2 package):\n" +
|
|
1654
|
+
"1. Pre-flight: the target app repo exists, uses @suppa/sdk@latest, and its tsconfig enables experimentalDecorators + emitDecoratorMetadata.\n" +
|
|
1655
|
+
"2. Resolve the blocking questions BEFORE writing any file: importKeyFields (the stable business key — wrong means duplicate seed rows on every restart), " +
|
|
1656
|
+
"representativeFieldName, and per-field nullable.\n" +
|
|
1657
|
+
"3. Write src/common/database/entities/*.entity.ts — @Entity class extending SystemBaseEntity; scalars via @Column({ type: FieldTypeEnum.X }); " +
|
|
1658
|
+
"relations via thunks (@ManyToOne(() => Target)); fixed choices via @Enum('Entity.field', ...); attachments via @File/@MultiFile; " +
|
|
1659
|
+
"'default' is a SQL expression STRING ('false', \"'draft'\") — never a JS value.\n" +
|
|
1660
|
+
"4. Write matching *.seed.ts with createSeed(): every importKeyField in every record (or $key); relations referenced by import key " +
|
|
1661
|
+
"({ name: 'Default' }) — never numeric ids; never system columns, access metadata, or reverse @OneToMany fields.\n" +
|
|
1662
|
+
"5. Register in EntityModule.forFeature([entities], { seeds }) — dependencies' seeds first.\n" +
|
|
1663
|
+
"6. Gate before claiming done: node node_modules/suppa-mcp-2/skills/suppa-entity-code/scripts/validate-suppa-schema.mjs <app-root> " +
|
|
1664
|
+
"(or the skills/ dir of a checkout) reports 0 errors; npx tsc --noEmit passes; " +
|
|
1665
|
+
"push, reload (POST /core/applications/:appId/reload), verify with suppa_describe_entity.\n" +
|
|
1666
|
+
"Porting from Suppa 1.0? Read the schema with suppa_read_v1_entity_props / suppa_read_v1_enum and map per references/v1-mapping.md — " +
|
|
1667
|
+
"never invent a mapping; record data stays with suppa_migrate_entities_from_v1.");
|
|
1627
1668
|
return server;
|
|
1628
1669
|
}
|
|
1629
1670
|
/**
|