suppa-mcp-2 1.24.0 → 1.25.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/README.md +9 -2
- package/dist/httpClient.js +6 -2
- package/dist/readEconomy.js +200 -0
- package/dist/server.js +127 -131
- package/dist/tools/docs.js +17 -10
- package/dist/tools/entity.js +20 -2
- package/dist/tools/tasks.js +11 -3
- package/dist/toolsListEconomy.js +70 -0
- package/package.json +1 -1
- package/skills/suppa-entity-code/scripts/house-rules.mjs +8 -8
package/README.md
CHANGED
|
@@ -168,7 +168,7 @@ When an AI agent connects, the server provides built-in instructions describing
|
|
|
168
168
|
|
|
169
169
|
### What the server does not send back
|
|
170
170
|
|
|
171
|
-
A tool result is not paid once: the whole conversation is re-sent on every turn, so a long string returned early is charged again on every later turn and is still occupying the window when compaction fires.
|
|
171
|
+
A tool result is not paid once: the whole conversation is re-sent on every turn, so a long string returned early is charged again on every later turn and is still occupying the window when compaction fires. These bytes are therefore removed on the way out — each chosen because it carries nothing the reader does not already hold or is not told:
|
|
172
172
|
|
|
173
173
|
| Removed | Why it is safe |
|
|
174
174
|
|---|---|
|
|
@@ -176,8 +176,15 @@ A tool result is not paid once: the whole conversation is re-sent on every turn,
|
|
|
176
176
|
| Long values in a **confirmation preview** | `proposed_changes` was built by copying the tool's own arguments back out. The value is verbatim in the same tool call, so it is named and sized instead: `<4231 chars — unchanged from this call's arguments>`. Short values stay verbatim, and `target` — the half that says *what* is about to change — is never touched. |
|
|
177
177
|
| Long values a **write echoed back** | An insert with no `returning` projection answers with the whole stored record, so the HTML just uploaded returns with it. Replaced only when byte-identical to what was sent, and the marker says what was checked — `<4231 chars — identical to the value this call wrote>`, not a claim about what you typed (a task description passes through `wrapHtml()` on the way out). If the platform normalised the markup or filled a default, the stored value differs — that difference is real information and comes back in full. |
|
|
178
178
|
|
|
179
|
+
| **Schema reads** (`suppa_describe_entity`) | A field lists only what departs from the platform defaults: constraints that are `null`, flags that are `false`/`0` and options at their default (`canGroup`/`canSort`/`showInTable`/`editFromTable`/`canFilter` true, `readOnly`/`searchable` false) are omitted, and a title keeps its language keys only. The result leads with a `_legend` stating exactly that rule, and `full=true` returns the platform's raw schema. Measured on a live tenant: Tasks 43,316 → 16,687 characters, Users 14,829 → 4,858. `suppa_list_entities` reduces each title the same way (24,840 → 13,132 for 202 entities; `full=true` keeps it whole). |
|
|
180
|
+
| `deletedAt: null` **on expanded relations** | The platform adds `deletedAt` to every relation it expands — `null` on every live row, nine times per task. Dropped only inside relations named by a projection **this server wrote** (tasks, docs, forms, automations), never inside a `json` value and never where the projection asked for it; a non-null value — the related row *is* deleted — always comes back. A projection the caller supplied (`suppa_search_records`) is returned as sent. |
|
|
181
|
+
| **A stage's status object** | `suppa_list_workflows` / `suppa_list_stages` return `status` as its value (`"completed"`) instead of the expanded enum row; the value is the one word every stage decision reads. 68,565 → 41,119 characters for 162 workflows. |
|
|
182
|
+
| **A task's second description** | `suppa_get_task` drops `plainDescription` when it is exactly `htmlDescription` with the tags removed — the HTML is what an edit has to send back, and the text is one strip away. When the two differ, both come back. |
|
|
183
|
+
|
|
179
184
|
The key is always kept, so "the field was written" is never in doubt. A marker is not the stored text: quote the value to the user from your own arguments.
|
|
180
185
|
|
|
186
|
+
The same discipline applies to what every session pays before the first call. The `instructions` block is budgeted (`test/instructionsBudget.test.ts`), and `tools/list` goes out without the JSON-Schema boilerplate no model reads — the `$schema` URI on each tool, `"default": null` on optional parameters, the two-branch `anyOf` where a type array says the same — while every property, `required` list, enum, non-null default and description is kept and compared against the SDK's own output in `test/toolsListEconomy.test.ts` (103,058 → about 93,000 characters for 89 tools).
|
|
187
|
+
|
|
181
188
|
|
|
182
189
|
### Deletes are reversible — permanent delete is blocked
|
|
183
190
|
|
|
@@ -268,7 +275,7 @@ work normally. Erasing data for good is an admin action in the platform's own UI
|
|
|
268
275
|
| Tool | Description |
|
|
269
276
|
|---|---|
|
|
270
277
|
| `suppa_list_entities` | List entities (tables) |
|
|
271
|
-
| `suppa_describe_entity` | Field definitions + types for an entity |
|
|
278
|
+
| `suppa_describe_entity` | Field definitions + types for an entity (compact by default; `full=true` for the raw schema) |
|
|
272
279
|
| `suppa_list_tabular_parts` | List tabular parts (ТЧ) of an entity |
|
|
273
280
|
| `suppa_search_records` | Search / filter records in any entity — nested AND/OR groups, auto-diagnoses an empty result (`deleted_scope` finds soft-deleted rows) |
|
|
274
281
|
| `suppa_validate_select` | Check a select/filter payload against the entity without running it — names the field that does not resolve |
|
package/dist/httpClient.js
CHANGED
|
@@ -9,6 +9,7 @@ import { assertMergeLists, elideEchoedResponse, stripAccessMetadata } from "./ut
|
|
|
9
9
|
import * as tenants from "./tenants.js";
|
|
10
10
|
import { lastRefreshError } from "./sessionDiag.js";
|
|
11
11
|
import { isOwnProjection, withoutPaths } from "./projection.js";
|
|
12
|
+
import { dropNullDeletedAt } from "./readEconomy.js";
|
|
12
13
|
// Re-exported so the transport stays the single import for entity reads.
|
|
13
14
|
export { ownProjection, isOwnProjection } from "./projection.js";
|
|
14
15
|
// HTTP statuses that signal a transient upstream problem worth one retry.
|
|
@@ -660,8 +661,11 @@ async function postEntityRead(entity, path, body, fields, opts = {}) {
|
|
|
660
661
|
payload = { ...body, fields: withoutPaths(fields, known) };
|
|
661
662
|
}
|
|
662
663
|
}
|
|
664
|
+
// A projection this server wrote also comes back without the platform's
|
|
665
|
+
// `deletedAt: null` on every relation it expanded — see dropNullDeletedAt.
|
|
666
|
+
const shaped = (result) => (own ? dropNullDeletedAt(result, fields) : result);
|
|
663
667
|
try {
|
|
664
|
-
return await makeRequest("POST", path, payload, opts);
|
|
668
|
+
return shaped(await makeRequest("POST", path, payload, opts));
|
|
665
669
|
}
|
|
666
670
|
catch (e) {
|
|
667
671
|
if (!own) {
|
|
@@ -682,7 +686,7 @@ async function postEntityRead(entity, path, body, fields, opts = {}) {
|
|
|
682
686
|
throw e; // the retry named the same fields — the problem is elsewhere
|
|
683
687
|
}
|
|
684
688
|
debug(`${entity}: this tenant has no ${bad.join(", ")} — retrying without them`);
|
|
685
|
-
return await makeRequest("POST", path, { ...body, fields: withoutPaths(fields, known) }, opts);
|
|
689
|
+
return shaped(await makeRequest("POST", path, { ...body, fields: withoutPaths(fields, known) }, opts));
|
|
686
690
|
}
|
|
687
691
|
}
|
|
688
692
|
export async function searchEntity(entity, filters = null, fields = null, limit = 50, offset = 0, orderBy = null, searchValue = "", operator = "and", deletedScope = DEFAULT_DELETED_SCOPE, includeDeletedRelations = DEFAULT_INCLUDE_DELETED_RELATIONS) {
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read results, minus the bytes that carry no information.
|
|
3
|
+
*
|
|
4
|
+
* A read is re-sent on every later turn of the conversation, so a schema read
|
|
5
|
+
* of 43,000 characters is not paid once. Measured on a live tenant, one
|
|
6
|
+
* `describe_entity` on Tasks spent 339 keys on `null`, 69 copies of each of the
|
|
7
|
+
* seven field options at their platform default, and a 110-character
|
|
8
|
+
* localisation record per field of which the model reads one word.
|
|
9
|
+
*
|
|
10
|
+
* Every reduction here is reversible in the reader's head, and the reader is
|
|
11
|
+
* told the rule (the `_legend` key on a schema): an absent constraint is null,
|
|
12
|
+
* an absent flag is false, an absent option is at its default, an absent
|
|
13
|
+
* deletedAt on a relation is a live row. Nothing that DIFFERS from the default
|
|
14
|
+
* is ever removed, so no field is misdescribed — the compact form says exactly
|
|
15
|
+
* what the full one says. The full form stays one flag away (`full=true`).
|
|
16
|
+
*
|
|
17
|
+
* Only the server's OWN reads are shaped: the schema tools and the projections
|
|
18
|
+
* this server wrote (tasks, forms, automations). A projection the caller wrote
|
|
19
|
+
* is returned as the platform sent it — they asked for those keys.
|
|
20
|
+
*
|
|
21
|
+
* Dependency-light on purpose (utils only), so tool modules and the transport
|
|
22
|
+
* can both import it without a cycle.
|
|
23
|
+
*/
|
|
24
|
+
import { stripHtml } from "./utils.js";
|
|
25
|
+
const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
26
|
+
/**
|
|
27
|
+
* The field options the platform applies when none is given (verified on a live
|
|
28
|
+
* tenant 2026-08-17; the builder doc lists them as false, which the platform
|
|
29
|
+
* contradicts). House rule 3 says never to WRITE one of these; the same fact
|
|
30
|
+
* says there is nothing to READ in one either.
|
|
31
|
+
*/
|
|
32
|
+
export const PLATFORM_OPTION_DEFAULTS = Object.freeze({
|
|
33
|
+
canGroup: true,
|
|
34
|
+
canSort: true,
|
|
35
|
+
showInTable: true,
|
|
36
|
+
editFromTable: true,
|
|
37
|
+
canFilter: true,
|
|
38
|
+
readOnly: false,
|
|
39
|
+
searchable: false,
|
|
40
|
+
});
|
|
41
|
+
/** Field flags at the value the platform stores when nothing was asked for. */
|
|
42
|
+
const FIELD_FLAG_DEFAULTS = Object.freeze({
|
|
43
|
+
isArray: false,
|
|
44
|
+
isPrimary: false,
|
|
45
|
+
isOnlyPositive: false,
|
|
46
|
+
isCustom: false,
|
|
47
|
+
unique: false,
|
|
48
|
+
notNull: false,
|
|
49
|
+
decimalPlaces: 0,
|
|
50
|
+
});
|
|
51
|
+
/** The keys of a platform localisation record that are bookkeeping, not text. */
|
|
52
|
+
const I18N_BOOKKEEPING = new Set(["id", "key", "name"]);
|
|
53
|
+
export const SCHEMA_LEGEND = "Compact schema: a field omits constraints that are null, flags that are false/0 " +
|
|
54
|
+
"(isArray, isPrimary, isOnlyPositive, unique, notNull, decimalPlaces) and options at the " +
|
|
55
|
+
"platform defaults (canGroup/canSort/showInTable/editFromTable/canFilter true; " +
|
|
56
|
+
"readOnly/searchable false); titles keep language keys only. Absent means default, " +
|
|
57
|
+
"not unknown. full=true returns the platform's raw schema.";
|
|
58
|
+
/**
|
|
59
|
+
* A localisation record `{id, key, name, en, uk, …}` reduced to its language
|
|
60
|
+
* keys. The bookkeeping names the i18n row and the entity it was declared on —
|
|
61
|
+
* nothing a reader of the schema acts on, and 90 characters per field.
|
|
62
|
+
*/
|
|
63
|
+
export function slimTitle(title) {
|
|
64
|
+
if (!isObj(title))
|
|
65
|
+
return title;
|
|
66
|
+
const out = {};
|
|
67
|
+
for (const [k, v] of Object.entries(title)) {
|
|
68
|
+
if (I18N_BOOKKEEPING.has(k) || v === null || v === undefined)
|
|
69
|
+
continue;
|
|
70
|
+
out[k] = v;
|
|
71
|
+
}
|
|
72
|
+
return Object.keys(out).length > 0 ? out : title;
|
|
73
|
+
}
|
|
74
|
+
/** Field options with the platform defaults removed. */
|
|
75
|
+
export function compactOptions(options) {
|
|
76
|
+
const out = {};
|
|
77
|
+
for (const [k, v] of Object.entries(options)) {
|
|
78
|
+
if (v === null || v === undefined)
|
|
79
|
+
continue;
|
|
80
|
+
if (k in PLATFORM_OPTION_DEFAULTS && v === PLATFORM_OPTION_DEFAULTS[k])
|
|
81
|
+
continue;
|
|
82
|
+
out[k] = v;
|
|
83
|
+
}
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
/** One field of an entity schema in compact form (see SCHEMA_LEGEND). */
|
|
87
|
+
export function compactField(field) {
|
|
88
|
+
if (!isObj(field))
|
|
89
|
+
return field;
|
|
90
|
+
const out = {};
|
|
91
|
+
for (const [k, v] of Object.entries(field)) {
|
|
92
|
+
if (v === null || v === undefined)
|
|
93
|
+
continue;
|
|
94
|
+
if (k in FIELD_FLAG_DEFAULTS && v === FIELD_FLAG_DEFAULTS[k])
|
|
95
|
+
continue;
|
|
96
|
+
if (k === "options" && isObj(v)) {
|
|
97
|
+
const o = compactOptions(v);
|
|
98
|
+
if (Object.keys(o).length > 0)
|
|
99
|
+
out.options = o;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (k === "title") {
|
|
103
|
+
out.title = slimTitle(v);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
out[k] = v;
|
|
107
|
+
}
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* An entity schema (GET /api/core/schema/<name>) in compact form. Every key the
|
|
112
|
+
* platform sent at the entity level is kept except nulls; `fields` and
|
|
113
|
+
* `customFields` are compacted per field; the legend goes first so it is read
|
|
114
|
+
* before the fields it explains.
|
|
115
|
+
*/
|
|
116
|
+
export function compactEntitySchema(raw) {
|
|
117
|
+
if (!isObj(raw))
|
|
118
|
+
return raw;
|
|
119
|
+
const out = { _legend: SCHEMA_LEGEND };
|
|
120
|
+
for (const [k, v] of Object.entries(raw)) {
|
|
121
|
+
if (v === null || v === undefined)
|
|
122
|
+
continue;
|
|
123
|
+
if ((k === "fields" || k === "customFields") && Array.isArray(v)) {
|
|
124
|
+
out[k] = v.map(compactField);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (k === "title") {
|
|
128
|
+
out.title = slimTitle(v);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
out[k] = v;
|
|
132
|
+
}
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Relation expansions come back with the platform's own `deletedAt` on each —
|
|
137
|
+
* null on every live row, nine times per task, on every task. Removed where
|
|
138
|
+
* null, only inside the relation objects the PROJECTION itself names (so a
|
|
139
|
+
* `json` field's contents are never walked), and never where the projection
|
|
140
|
+
* asked for deletedAt. A non-null value — the related row IS deleted — is
|
|
141
|
+
* information and stays. The row's own top-level deletedAt is never touched.
|
|
142
|
+
*
|
|
143
|
+
* Mutates in place: the input is a response body this process just parsed.
|
|
144
|
+
*/
|
|
145
|
+
export function dropNullDeletedAt(result, projection) {
|
|
146
|
+
if (Array.isArray(result)) {
|
|
147
|
+
for (const row of result)
|
|
148
|
+
dropNullDeletedAt(row, projection);
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
if (!isObj(result))
|
|
152
|
+
return result;
|
|
153
|
+
for (const [key, sub] of Object.entries(projection)) {
|
|
154
|
+
if (!isObj(sub))
|
|
155
|
+
continue; // a leaf — never descend into a value
|
|
156
|
+
const value = result[key];
|
|
157
|
+
const related = Array.isArray(value) ? value : [value];
|
|
158
|
+
for (const row of related) {
|
|
159
|
+
if (!isObj(row))
|
|
160
|
+
continue;
|
|
161
|
+
if (row.deletedAt === null && sub.deletedAt !== true)
|
|
162
|
+
delete row.deletedAt;
|
|
163
|
+
dropNullDeletedAt(row, sub);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return result;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* A stage's status as the one word that matters. The platform expands the
|
|
170
|
+
* enum reference into `{id, value, title, deletedAt}`; `value` is what every
|
|
171
|
+
* stage decision in this server (active? completed?) reads, and `title` is its
|
|
172
|
+
* capitalised twin.
|
|
173
|
+
*/
|
|
174
|
+
export function statusValue(status) {
|
|
175
|
+
return isObj(status) && typeof status.value === "string" ? status.value : status;
|
|
176
|
+
}
|
|
177
|
+
const collapseWs = (s) => s.replace(/\s+/g, " ").trim();
|
|
178
|
+
/**
|
|
179
|
+
* A task carries its description twice — as HTML and as the platform's plain
|
|
180
|
+
* rendering of the same HTML — and on a real task that is the whole payload
|
|
181
|
+
* (51,000 characters, of which half is the other half without tags). When the
|
|
182
|
+
* plain text is exactly the HTML with its tags removed, it is dropped and the
|
|
183
|
+
* HTML kept: HTML is what an edit has to send back, and the text is one
|
|
184
|
+
* tag-strip away. When they differ — the platform rendered something the strip
|
|
185
|
+
* does not — both come back, because the difference is information.
|
|
186
|
+
*/
|
|
187
|
+
export function dropDerivablePlainDescription(row) {
|
|
188
|
+
if (Array.isArray(row))
|
|
189
|
+
return row.map(dropDerivablePlainDescription);
|
|
190
|
+
if (!isObj(row))
|
|
191
|
+
return row;
|
|
192
|
+
const html = row.htmlDescription;
|
|
193
|
+
const plain = row.plainDescription;
|
|
194
|
+
if (typeof html !== "string" || typeof plain !== "string" || !html || !plain)
|
|
195
|
+
return row;
|
|
196
|
+
if (collapseWs(stripHtml(html)) !== collapseWs(plain))
|
|
197
|
+
return row;
|
|
198
|
+
const { plainDescription: _derivable, ...rest } = row;
|
|
199
|
+
return rest;
|
|
200
|
+
}
|
package/dist/server.js
CHANGED
|
@@ -21,6 +21,7 @@ import * as automation from "./tools/automation.js";
|
|
|
21
21
|
import * as auth from "./auth.js";
|
|
22
22
|
import * as tenants from "./tenants.js";
|
|
23
23
|
import { confirmRequired, jsonResponse } from "./utils.js";
|
|
24
|
+
import { installToolsListEconomy } from "./toolsListEconomy.js";
|
|
24
25
|
import { PACKAGE_NAME, PACKAGE_VERSION, knownLatest, isOutdated, refreshLatestVersion, upgradeNotice, } from "./version.js";
|
|
25
26
|
export { PACKAGE_VERSION };
|
|
26
27
|
// ---------------------------------------------------------------------------
|
|
@@ -232,51 +233,70 @@ const EntityQuery = z
|
|
|
232
233
|
// ---------------------------------------------------------------------------
|
|
233
234
|
/** Read once, from the one file that states the rules (see houseRulesDigest). */
|
|
234
235
|
const HOUSE_RULES_DIGEST = houseRulesDigest();
|
|
235
|
-
const INSTRUCTIONS = `Suppa Platform MCP Server —
|
|
236
|
+
const INSTRUCTIONS = `Suppa Platform MCP Server — Tasks, Docs/Pages, Entities, Forms, Automations and file attachments on Suppa tenants.
|
|
236
237
|
|
|
237
238
|
AUTHENTICATION — RESOLVE THIS BEFORE ANY OTHER SUPPA WORK
|
|
238
|
-
-
|
|
239
|
-
-
|
|
240
|
-
-
|
|
241
|
-
1. Call suppa_login
|
|
242
|
-
2. Tell the user
|
|
243
|
-
3.
|
|
244
|
-
- A static SUPPA_API_KEY in the client env
|
|
245
|
-
-
|
|
246
|
-
- suppa_use_tenant switches the active instance for ALL later calls; suppa_list_tenants shows what
|
|
239
|
+
- Sign-in is an interactive Google flow in the browser. There is NO API key for a user to find or paste — NEVER ask for a token, key or password; call suppa_login instead.
|
|
240
|
+
- Unsure whether the user is signed in? Call suppa_list_tenants (cheap, read-only): the ACTIVE tenant shows "authenticated": false or "needs_login": true when not.
|
|
241
|
+
- When not signed in — or any tool answers "No Suppa credentials" / HTTP 401 / "session could not be refreshed" / ReloginRequired — DO NOT STOP and DO NOT ask for a key:
|
|
242
|
+
1. Call suppa_login (suppa_login(tenant="<alias|host|url>") targets another instance; default is the active tenant). It OPENS A GOOGLE SIGN-IN PAGE in the default browser, served locally at http://localhost:8080.
|
|
243
|
+
2. Tell the user: "I've opened a Google sign-in page in your browser — pick your account to finish signing in." If the browser did not open, the result carries the URL for them to open by hand.
|
|
244
|
+
3. It blocks until they finish and returns {"status":"ok"} — THEN retry the original action. Tokens go to the OS keychain and auto-refresh: one login per tenant, not per session.
|
|
245
|
+
- A static SUPPA_API_KEY in the client env (CI / single tenant) means no login is needed; it is optional and most users have none.
|
|
246
|
+
- suppa_diagnostics validates the whole setup and reports the login_origin to whitelist. ONE-TIME ORG SETUP: http://localhost:8080 must be in the Google OAuth client's "Authorized JavaScript origins" — a sign-in page that opens but never completes is almost always this; tell the user so an admin can add it.
|
|
247
|
+
- suppa_use_tenant switches the active instance for ALL later calls; suppa_list_tenants shows what is known and authenticated.
|
|
247
248
|
|
|
248
249
|
DATA BASICS
|
|
249
|
-
- IDs are integers
|
|
250
|
-
-
|
|
251
|
-
- DELETE IS A SOFT DELETE — every delete tool
|
|
252
|
-
- PERMANENT DELETE IS UNAVAILABLE HERE, BY DESIGN — this server performs REVERSIBLE deletes only. The platform's PERMANENT delete (POST /core/data/:entityName/delete
|
|
250
|
+
- IDs are integers, not UUIDs. Dates are ISO-8601; a naive datetime (no offset) is read as UTC, so pass an explicit offset (+03:00) or convert local times yourself. Task deadlines also accept 'today', 'tomorrow', '+3d', '+2h', '+30m', '+1w'.
|
|
251
|
+
- Each write tool's description states the shapes it demands — relations and enums as {"id": N}, list fields REPLACED unless merge_json says otherwise — and validates against the live schema before writing. Read it before calling: a bare number where a reference belongs returns 201 and stores null.
|
|
252
|
+
- DELETE IS A SOFT DELETE — every delete tool sets deletedAt and leaves the row in place, reversible with suppa_restore_record(entity_name, record_id); never tell the user their data was destroyed. It still needs confirm=true because the row leaves all normal reads; find it again with deleted_scope='deleted'.
|
|
253
|
+
- PERMANENT DELETE IS UNAVAILABLE HERE, BY DESIGN — this server performs REVERSIBLE deletes only. The platform's PERMANENT delete (POST /core/data/:entityName/delete — rows leave the table and cannot be restored) is BLOCKED in the HTTP client itself: no tool, flag, confirm=true or direct call reaches it, and an attempt is refused before any request is sent. Do not look for a tool, a parameter or a workaround — there is none. Asked to erase data for good, say so plainly and offer the soft delete (suppa_delete_record → /remove, undone by suppa_restore_record); permanent removal is an admin action in the platform's own UI.
|
|
254
|
+
- Reads are compact: relation objects omit deletedAt when null (a live row); schema reads omit nulls, false flags and default options and carry a _legend (full=true returns the raw form).
|
|
253
255
|
|
|
254
256
|
SEARCH & FILTERS — suppa_search_records' description carries the comparators, nested AND/OR groups, dotted field paths, "$current-user", paging and the auto-diagnosis of an empty result. Read it before your first search.
|
|
255
|
-
- PROJECT ONLY THE FIELDS YOU NEED (fields_json)
|
|
256
|
-
-
|
|
257
|
+
- PROJECT ONLY THE FIELDS YOU NEED (fields_json): a 600-character answer instead of a 50 000-character one, and every answer is re-sent on every later turn of the conversation.
|
|
258
|
+
- Unsure of the schema: suppa_list_entities → suppa_describe_entity → suppa_search_records. One record by id needs no filters: suppa_get_record / suppa_get_task / suppa_get_doc.
|
|
257
259
|
|
|
258
260
|
APPROVAL GATES (human-in-the-loop)
|
|
259
|
-
- Every update/move/close/delete tool returns {"status": "confirmation_required"}
|
|
260
|
-
-
|
|
261
|
-
- Create/read tools (and comments) need no confirmation.
|
|
262
|
-
- A value shown as <N chars — exactly as sent / unchanged from this call's arguments> is NOT the stored text: it is the long string you yourself supplied in this same call, named instead of repeated. Quote it to the user from your own arguments; never report the marker as the record's content.
|
|
261
|
+
- Every update/move/close/delete tool called without confirm=true returns {"status": "confirmation_required"} and performs NOTHING. Show the user what will change, get explicit approval, then re-call the same tool with confirm=true — never set it on the first call without their go-ahead. Create/read tools and comments need no confirmation.
|
|
262
|
+
- A value shown as <N chars — exactly as sent / unchanged from this call's arguments> is NOT the stored text: it names the long string you yourself supplied in this same call. Quote it to the user from your own arguments; never report the marker as the record's content.
|
|
263
263
|
|
|
264
264
|
ENTITY BUILDER (create + edit fields; removal is UI-only) — suppa_add_field's description carries the real field types, the sub_type matrix and the field options; suppa_update_field's carries what may still be changed on a field that exists. Two things those cannot decide for you:
|
|
265
|
-
- OWNED CHILD COLLECTIONS ARE TABULAR PARTS
|
|
266
|
-
- An enum value on a RECORD is a reference,
|
|
265
|
+
- OWNED CHILD COLLECTIONS ARE TABULAR PARTS: repeating rows that belong to ONE parent record (a part's BOM items) go through suppa_create_tabular_part(parent_entity, name), which creates the child's 'owner' relation and the parent link. Never model it by hand — suppa_add_field REFUSES field_type='one-to-many'; 'many-to-many' is for a shared lookup referenced by many records.
|
|
266
|
+
- An enum value on a RECORD is a reference, {"id": <Enums row id>} (an array of those for multi-enum), never a bare code like "red" — that is refused. Read the ids with suppa_search_records on 'Enums' filtered by name.
|
|
267
267
|
|
|
268
268
|
${HOUSE_RULES_DIGEST}
|
|
269
269
|
|
|
270
|
-
ATTACHMENTS
|
|
270
|
+
ATTACHMENTS — an entity holds files only through a 'file' or 'multi-file' field (add one with suppa_add_field). suppa_attach_file_to_record uploads from local disk and returns the file_ids that are the only handle to the bytes; suppa_list_record_files lists what a record carries; suppa_download_file and suppa_download_files_zip fetch them. Those descriptions carry the rest.
|
|
271
271
|
|
|
272
|
-
MIGRATION (Suppa 1.0 → 2.0)
|
|
273
|
-
- 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.
|
|
272
|
+
MIGRATION (Suppa 1.0 → 2.0) — 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.
|
|
274
273
|
`;
|
|
275
274
|
// ---------------------------------------------------------------------------
|
|
276
275
|
// Registered tool + prompt names (tests assert the counts).
|
|
277
276
|
// ---------------------------------------------------------------------------
|
|
278
277
|
export const TOOL_NAMES = [];
|
|
279
278
|
export const PROMPT_NAMES = [];
|
|
279
|
+
/**
|
|
280
|
+
* Tool descriptions were ported from Python docstrings and kept their four-space
|
|
281
|
+
* continuation indent — thousands of characters of leading whitespace across the
|
|
282
|
+
* listing that no reader needs. Stripped at registration; the words are unchanged.
|
|
283
|
+
*/
|
|
284
|
+
export function compactDescription(description) {
|
|
285
|
+
const lines = description.split("\n");
|
|
286
|
+
if (lines.length < 2)
|
|
287
|
+
return description;
|
|
288
|
+
let common = Infinity;
|
|
289
|
+
for (const line of lines.slice(1)) {
|
|
290
|
+
if (!line.trim())
|
|
291
|
+
continue;
|
|
292
|
+
const indent = line.length - line.trimStart().length;
|
|
293
|
+
if (indent < common)
|
|
294
|
+
common = indent;
|
|
295
|
+
}
|
|
296
|
+
if (!Number.isFinite(common) || common === 0)
|
|
297
|
+
return description;
|
|
298
|
+
return [lines[0], ...lines.slice(1).map((l) => (l.trim() ? l.slice(common) : ""))].join("\n");
|
|
299
|
+
}
|
|
280
300
|
/** Wrap a tool-module call result (a JSON string) into an MCP text content. */
|
|
281
301
|
function text(result) {
|
|
282
302
|
return { content: [{ type: "text", text: result }] };
|
|
@@ -310,7 +330,7 @@ export function buildServer() {
|
|
|
310
330
|
const server = new McpServer({ name: "suppa-2.0", version: PACKAGE_VERSION }, { instructions: INSTRUCTIONS + upgradeNotice() });
|
|
311
331
|
const reg = (name, cfg, handler) => {
|
|
312
332
|
server.registerTool(name, {
|
|
313
|
-
description: cfg.description,
|
|
333
|
+
description: compactDescription(cfg.description),
|
|
314
334
|
inputSchema: (cfg.inputSchema ?? {}),
|
|
315
335
|
annotations: cfg.annotations,
|
|
316
336
|
}, handler);
|
|
@@ -354,7 +374,8 @@ export function buildServer() {
|
|
|
354
374
|
annotations: _READ,
|
|
355
375
|
}, async (a) => text(await tasks.countTasks(a.my, a.active, a.project_id, a.workflow_id, a.search, a.overdue, a.due_today)));
|
|
356
376
|
reg("suppa_get_task", {
|
|
357
|
-
description: "Get full details of a task by its ID."
|
|
377
|
+
description: "Get full details of a task by its ID. The description is htmlDescription;\n" +
|
|
378
|
+
" plainDescription is included only when it differs from that HTML with the tags removed.",
|
|
358
379
|
inputSchema: { task_id: z.number().int() },
|
|
359
380
|
annotations: _READ,
|
|
360
381
|
}, async (a) => text(await tasks.getTask(a.task_id)));
|
|
@@ -386,8 +407,7 @@ export function buildServer() {
|
|
|
386
407
|
" Any list-valued field written here is REPLACED wholesale — this tool has no\n" +
|
|
387
408
|
" merge option. To ADD to / REMOVE from a task's list field, use\n" +
|
|
388
409
|
' suppa_update_record("Tasks", ...) with merge_json / unmerge_json.\n\n' +
|
|
389
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and
|
|
390
|
-
" changes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
410
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and changes nothing.",
|
|
391
411
|
inputSchema: {
|
|
392
412
|
task_id: z.number().int(),
|
|
393
413
|
title: z.string().nullable().default(null),
|
|
@@ -426,14 +446,12 @@ export function buildServer() {
|
|
|
426
446
|
});
|
|
427
447
|
reg("suppa_delete_task", {
|
|
428
448
|
description: "Soft-delete a task.\n\n" +
|
|
429
|
-
" SOFT DELETE: sets deletedAt — the row remains
|
|
430
|
-
"
|
|
431
|
-
"
|
|
432
|
-
"
|
|
433
|
-
"
|
|
434
|
-
"
|
|
435
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and\n" +
|
|
436
|
-
" deletes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
449
|
+
" SOFT DELETE: sets deletedAt — the row remains and the delete is reversible with\n" +
|
|
450
|
+
" suppa_restore_record('Tasks', task_id); it drops out of normal reads, so find it again\n" +
|
|
451
|
+
" with suppa_search_records('Tasks', deleted_scope='deleted'). Not the platform's\n" +
|
|
452
|
+
" permanent delete (rows leave the table and cannot be restored), which this server\n" +
|
|
453
|
+
" does not expose.\n\n" +
|
|
454
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and deletes nothing.",
|
|
437
455
|
inputSchema: { task_id: z.number().int(), confirm: Confirm },
|
|
438
456
|
annotations: _MUT,
|
|
439
457
|
}, async (a) => {
|
|
@@ -444,8 +462,7 @@ export function buildServer() {
|
|
|
444
462
|
});
|
|
445
463
|
reg("suppa_move_task", {
|
|
446
464
|
description: "Move a task to a different workflow stage.\n\n" +
|
|
447
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and
|
|
448
|
-
" changes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
465
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and changes nothing.",
|
|
449
466
|
inputSchema: {
|
|
450
467
|
task_id: z.number().int(),
|
|
451
468
|
stage_id: z
|
|
@@ -463,8 +480,7 @@ export function buildServer() {
|
|
|
463
480
|
});
|
|
464
481
|
reg("suppa_close_task", {
|
|
465
482
|
description: "Close a task by moving it to the workflow's completed stage.\n\n" +
|
|
466
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and
|
|
467
|
-
" changes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
483
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and changes nothing.",
|
|
468
484
|
inputSchema: { task_id: z.number().int(), confirm: Confirm },
|
|
469
485
|
annotations: _MUT,
|
|
470
486
|
}, async (a) => {
|
|
@@ -509,12 +525,13 @@ export function buildServer() {
|
|
|
509
525
|
annotations: _ADD,
|
|
510
526
|
}, async (a) => text(await tasks.attachFile(a.task_id, a.file_path)));
|
|
511
527
|
reg("suppa_list_workflows", {
|
|
512
|
-
description: "List all workflows. Optionally filter by name."
|
|
528
|
+
description: "List all workflows with their stages in order. Optionally filter by name. A stage's\n" +
|
|
529
|
+
" status is the enum value ('active', 'completed', …).",
|
|
513
530
|
inputSchema: { name: z.string().nullable().default(null) },
|
|
514
531
|
annotations: _READ,
|
|
515
532
|
}, async (a) => text(await tasks.listWorkflows(a.name)));
|
|
516
533
|
reg("suppa_list_stages", {
|
|
517
|
-
description: "List all stages in a specific workflow.",
|
|
534
|
+
description: "List all stages in a specific workflow, in order. status is the enum value ('active', 'completed', …).",
|
|
518
535
|
inputSchema: {
|
|
519
536
|
workflow_id: z
|
|
520
537
|
.number()
|
|
@@ -569,8 +586,7 @@ export function buildServer() {
|
|
|
569
586
|
description: "Update a document's title or visibility.\n\n" +
|
|
570
587
|
" Any list-valued field written here is REPLACED wholesale — this tool has no\n" +
|
|
571
588
|
' merge option; use suppa_update_record("Docs", ...) with merge_json to add.\n\n' +
|
|
572
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and
|
|
573
|
-
" changes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
589
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and changes nothing.",
|
|
574
590
|
inputSchema: {
|
|
575
591
|
doc_id: z.number().int(),
|
|
576
592
|
title: z.string().nullable().default(null),
|
|
@@ -591,14 +607,12 @@ export function buildServer() {
|
|
|
591
607
|
});
|
|
592
608
|
reg("suppa_delete_doc", {
|
|
593
609
|
description: "Soft-delete a document (and its pages).\n\n" +
|
|
594
|
-
" SOFT DELETE: sets deletedAt — the row remains
|
|
595
|
-
"
|
|
596
|
-
"
|
|
597
|
-
"
|
|
598
|
-
"
|
|
599
|
-
"
|
|
600
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and\n" +
|
|
601
|
-
" deletes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
610
|
+
" SOFT DELETE: sets deletedAt — the row remains and the delete is reversible with\n" +
|
|
611
|
+
" suppa_restore_record('Docs', doc_id); it drops out of normal reads, so find it again\n" +
|
|
612
|
+
" with suppa_search_records('Docs', deleted_scope='deleted'). Not the platform's\n" +
|
|
613
|
+
" permanent delete (rows leave the table and cannot be restored), which this server\n" +
|
|
614
|
+
" does not expose.\n\n" +
|
|
615
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and deletes nothing.",
|
|
602
616
|
inputSchema: { doc_id: z.number().int(), confirm: Confirm },
|
|
603
617
|
annotations: _MUT,
|
|
604
618
|
}, async (a) => {
|
|
@@ -644,8 +658,7 @@ export function buildServer() {
|
|
|
644
658
|
description: "Update a page's metadata.\n\n" +
|
|
645
659
|
" Any list-valued field written here is REPLACED wholesale — this tool has no\n" +
|
|
646
660
|
' merge option; use suppa_update_record("Pages", ...) with merge_json to add.\n\n' +
|
|
647
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and
|
|
648
|
-
" changes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
661
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and changes nothing.",
|
|
649
662
|
inputSchema: {
|
|
650
663
|
page_id: z.number().int(),
|
|
651
664
|
title: z.string().nullable().default(null),
|
|
@@ -675,14 +688,12 @@ export function buildServer() {
|
|
|
675
688
|
reg("suppa_delete_page", {
|
|
676
689
|
description: "Soft-delete a page. The platform refuses to delete a document's LAST page\n" +
|
|
677
690
|
" (HTTP 400) — delete the whole doc instead (suppa_delete_doc).\n\n" +
|
|
678
|
-
" SOFT DELETE: sets deletedAt — the row remains
|
|
679
|
-
"
|
|
680
|
-
"
|
|
681
|
-
"
|
|
682
|
-
"
|
|
683
|
-
"
|
|
684
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and\n" +
|
|
685
|
-
" deletes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
691
|
+
" SOFT DELETE: sets deletedAt — the row remains and the delete is reversible with\n" +
|
|
692
|
+
" suppa_restore_record('Pages', page_id); it drops out of normal reads, so find it again\n" +
|
|
693
|
+
" with suppa_search_records('Pages', deleted_scope='deleted'). Not the platform's\n" +
|
|
694
|
+
" permanent delete (rows leave the table and cannot be restored), which this server\n" +
|
|
695
|
+
" does not expose.\n\n" +
|
|
696
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and deletes nothing.",
|
|
686
697
|
inputSchema: { page_id: z.number().int(), confirm: Confirm },
|
|
687
698
|
annotations: _MUT,
|
|
688
699
|
}, async (a) => {
|
|
@@ -737,8 +748,7 @@ export function buildServer() {
|
|
|
737
748
|
" properties_json REPLACES the block's properties wholesale (as does any\n" +
|
|
738
749
|
" list-valued field) — this tool has no merge option; read the current\n" +
|
|
739
750
|
" properties with suppa_get_blocks first and re-send them in full.\n\n" +
|
|
740
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and
|
|
741
|
-
" changes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
751
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and changes nothing.",
|
|
742
752
|
inputSchema: {
|
|
743
753
|
block_id: z.number().int(),
|
|
744
754
|
title: z
|
|
@@ -767,14 +777,12 @@ export function buildServer() {
|
|
|
767
777
|
});
|
|
768
778
|
reg("suppa_delete_block", {
|
|
769
779
|
description: "Soft-delete a content block.\n\n" +
|
|
770
|
-
" SOFT DELETE: sets deletedAt — the row remains
|
|
771
|
-
"
|
|
772
|
-
"
|
|
773
|
-
"
|
|
774
|
-
"
|
|
775
|
-
"
|
|
776
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and\n" +
|
|
777
|
-
" deletes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
780
|
+
" SOFT DELETE: sets deletedAt — the row remains and the delete is reversible with\n" +
|
|
781
|
+
" suppa_restore_record('PageBlocks', block_id); it drops out of normal reads, so find it again\n" +
|
|
782
|
+
" with suppa_search_records('PageBlocks', deleted_scope='deleted'). Not the platform's\n" +
|
|
783
|
+
" permanent delete (rows leave the table and cannot be restored), which this server\n" +
|
|
784
|
+
" does not expose.\n\n" +
|
|
785
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and deletes nothing.",
|
|
778
786
|
inputSchema: { block_id: z.number().int(), confirm: Confirm },
|
|
779
787
|
annotations: _MUT,
|
|
780
788
|
}, async (a) => {
|
|
@@ -786,8 +794,7 @@ export function buildServer() {
|
|
|
786
794
|
reg("suppa_reorder_blocks", {
|
|
787
795
|
description: "Reorder blocks on a page. block_ids: comma-separated IDs to move. Provide after_id or before_id as anchor.\n" +
|
|
788
796
|
"\n" +
|
|
789
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and
|
|
790
|
-
" changes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
797
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and changes nothing.",
|
|
791
798
|
inputSchema: {
|
|
792
799
|
page_id: z.number().int(),
|
|
793
800
|
block_ids: z
|
|
@@ -835,15 +842,24 @@ export function buildServer() {
|
|
|
835
842
|
full: z
|
|
836
843
|
.boolean()
|
|
837
844
|
.default(false)
|
|
838
|
-
.describe("true = raw schema rows; default returns a slim summary per entity."),
|
|
845
|
+
.describe("true = raw schema rows; default returns a slim summary per entity (title reduced to its language keys)."),
|
|
839
846
|
},
|
|
840
847
|
annotations: _READ,
|
|
841
848
|
}, async (a) => text(await entity.listEntities(a.search, a.full)));
|
|
842
849
|
reg("suppa_describe_entity", {
|
|
843
|
-
description: "Get the
|
|
844
|
-
|
|
850
|
+
description: "Get the schema of an entity — all fields, types, relations, and constraints.\n" +
|
|
851
|
+
" Compact by default: a field lists only what departs from the platform defaults, and\n" +
|
|
852
|
+
" the result's _legend says exactly what an absent key means — a quarter of the raw\n" +
|
|
853
|
+
" size. full=true returns the platform's raw schema.",
|
|
854
|
+
inputSchema: {
|
|
855
|
+
entity_name: EntityName,
|
|
856
|
+
full: z
|
|
857
|
+
.boolean()
|
|
858
|
+
.default(false)
|
|
859
|
+
.describe("true = the platform's raw schema (every null, default and localisation record)."),
|
|
860
|
+
},
|
|
845
861
|
annotations: _READ,
|
|
846
|
-
}, async (a) => text(await entity.
|
|
862
|
+
}, async (a) => text(await entity.describeEntityCompact(a.entity_name, a.full)));
|
|
847
863
|
reg("suppa_list_tabular_parts", {
|
|
848
864
|
description: 'List an entity\'s tabular parts (owned child sub-tables / "таблична частина").\n' +
|
|
849
865
|
" Each result has type='tabular-part' and a relationEntity pointing back to the parent.",
|
|
@@ -985,8 +1001,7 @@ export function buildServer() {
|
|
|
985
1001
|
" checklists is forbidden; the docs do not list the suffixes, so that one can only\n" +
|
|
986
1002
|
" be reported as a warning. The platform answers with the APPLIED options, which\n" +
|
|
987
1003
|
" may be a subset of the request — anything missing is called out in the result.\n\n" +
|
|
988
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and
|
|
989
|
-
" changes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
1004
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and changes nothing.",
|
|
990
1005
|
inputSchema: {
|
|
991
1006
|
entity_name: EntityName,
|
|
992
1007
|
options_json: z
|
|
@@ -1058,18 +1073,12 @@ export function buildServer() {
|
|
|
1058
1073
|
" There is NO date/datetime/richtext/email/url/phone type — use timestamp\n" +
|
|
1059
1074
|
" (+sub_type='date' for date-only) and multi-language for localized text.\n" +
|
|
1060
1075
|
" 'relation' is accepted as an alias for many-to-one. Provide relation_entity for\n" +
|
|
1061
|
-
" relations, enum_name for enums. sub_type matrix
|
|
1062
|
-
"
|
|
1063
|
-
"
|
|
1064
|
-
"
|
|
1065
|
-
" decimal_places / min_value / max_value / only_positive (numeric)
|
|
1066
|
-
"
|
|
1067
|
-
" editFromTable, readOnly, searchable + searchPriority (1-4). Omitted, the\n" +
|
|
1068
|
-
" platform fills its own defaults in — visible, sortable, groupable, filterable,\n" +
|
|
1069
|
-
" editable, not read-only, and NOT searchable. So searchable (+searchPriority) is\n" +
|
|
1070
|
-
" the one worth setting: without it the field cannot be found by free-text\n" +
|
|
1071
|
-
" search. All of them can be changed later with suppa_update_field; the field's\n" +
|
|
1072
|
-
" TYPE never can.\n" +
|
|
1076
|
+
" relations, enum_name for enums. The sub_type matrix and the field options (searchable +\n" +
|
|
1077
|
+
" searchPriority is the one usually worth setting) live on the sub_type and options_json\n" +
|
|
1078
|
+
" parameters — read them; enum/multi-enum take no sub_type (the platform sets it).\n" +
|
|
1079
|
+
" Constraints: max_length/min_length (text),\n" +
|
|
1080
|
+
" decimal_places / min_value / max_value / only_positive (numeric). Options can be\n" +
|
|
1081
|
+
" changed later with suppa_update_field; the field's TYPE never can.\n" +
|
|
1073
1082
|
" required=true makes the column NOT NULL. Where a defaultValue APPLIES it is\n" +
|
|
1074
1083
|
" also required, and the call is refused before any request if missing — no\n" +
|
|
1075
1084
|
" default is ever invented for you. defaultValue does NOT apply to relations,\n" +
|
|
@@ -1207,8 +1216,7 @@ export function buildServer() {
|
|
|
1207
1216
|
" - A SYSTEM field (initiator='system') accepts only title and options.{canGroup,\n" +
|
|
1208
1217
|
" canSort, showInTable, editFromTable, canFilter, readOnly, searchable}.\n" +
|
|
1209
1218
|
" Removing a field is still UI-only — this server has no remove-field call.\n\n" +
|
|
1210
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and
|
|
1211
|
-
" changes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
1219
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and changes nothing.",
|
|
1212
1220
|
inputSchema: {
|
|
1213
1221
|
entity_name: EntityName,
|
|
1214
1222
|
field_name: z
|
|
@@ -1337,8 +1345,7 @@ export function buildServer() {
|
|
|
1337
1345
|
"\n" +
|
|
1338
1346
|
" This CHANGES what every existing record of the entity displays as its label,\n" +
|
|
1339
1347
|
" so it is confirm-gated like any other edit to live data.\n" +
|
|
1340
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and
|
|
1341
|
-
" changes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
1348
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and changes nothing.",
|
|
1342
1349
|
inputSchema: {
|
|
1343
1350
|
entity_name: EntityName,
|
|
1344
1351
|
field_name: z
|
|
@@ -1382,8 +1389,7 @@ export function buildServer() {
|
|
|
1382
1389
|
' [{"id": 15}]} makes 15 the ONLY watcher — every other watcher is dropped.\n' +
|
|
1383
1390
|
' To ADD the listed items instead, pass merge_json=["watchers"]; to REMOVE\n' +
|
|
1384
1391
|
' only the listed items, pass unmerge_json=["watchers"].\n\n' +
|
|
1385
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and
|
|
1386
|
-
" changes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
1392
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and changes nothing.",
|
|
1387
1393
|
inputSchema: {
|
|
1388
1394
|
entity_name: EntityName,
|
|
1389
1395
|
record_id: z.number().int(),
|
|
@@ -1427,20 +1433,16 @@ export function buildServer() {
|
|
|
1427
1433
|
});
|
|
1428
1434
|
reg("suppa_delete_record", {
|
|
1429
1435
|
description: "Soft-delete a record (instance) from any entity.\n\n" +
|
|
1430
|
-
" SOFT DELETE:
|
|
1431
|
-
"
|
|
1432
|
-
"
|
|
1433
|
-
"
|
|
1434
|
-
"
|
|
1435
|
-
" endpoint (/core/data/<entity>/delete) where the rows leave the table and\n" +
|
|
1436
|
-
" cannot be restored. This server deliberately does not expose it — every\n" +
|
|
1437
|
-
" delete tool here is the reversible one.\n\n" +
|
|
1436
|
+
" SOFT DELETE: sets deletedAt — the row remains and the delete is reversible with\n" +
|
|
1437
|
+
" suppa_restore_record; it disappears from normal reads, so find it again with\n" +
|
|
1438
|
+
" suppa_search_records(deleted_scope='deleted'). Not the platform's permanent delete\n" +
|
|
1439
|
+
" (/core/data/<entity>/delete — rows leave the table and cannot be restored), which\n" +
|
|
1440
|
+
" this server does not expose; every delete tool here is the reversible one.\n\n" +
|
|
1438
1441
|
" Removes a single instance, not the entity/schema. Entities and fields are\n" +
|
|
1439
1442
|
" created with suppa_create_entity / suppa_add_field and edited with\n" +
|
|
1440
1443
|
" suppa_update_field (a field's type is never changeable); REMOVING a field is\n" +
|
|
1441
1444
|
" UI-only — this server has no remove-field call.\n\n" +
|
|
1442
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and
|
|
1443
|
-
" deletes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
1445
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and deletes nothing.",
|
|
1444
1446
|
inputSchema: {
|
|
1445
1447
|
entity_name: EntityName,
|
|
1446
1448
|
record_id: z.number().int(),
|
|
@@ -1470,8 +1472,7 @@ export function buildServer() {
|
|
|
1470
1472
|
" deletedAt IS NOT NULL, so calling this on a live record changes nothing and\n" +
|
|
1471
1473
|
" returns restored=false. A record removed with the platform's PERMANENT\n" +
|
|
1472
1474
|
" delete cannot be restored — but this server never issues that call.\n\n" +
|
|
1473
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and
|
|
1474
|
-
" restores nothing. Get the user's approval, then re-call with confirm=true.",
|
|
1475
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and restores nothing.",
|
|
1475
1476
|
inputSchema: {
|
|
1476
1477
|
entity_name: EntityName,
|
|
1477
1478
|
record_id: z.number().int(),
|
|
@@ -1716,8 +1717,7 @@ export function buildServer() {
|
|
|
1716
1717
|
" change; settings is merged over the stored value (pinData and untouched keys\n" +
|
|
1717
1718
|
" preserved); nodes/connections are whole-document replaces. Runs pre-flight\n" +
|
|
1718
1719
|
" validation on the resulting graph.\n\n" +
|
|
1719
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and
|
|
1720
|
-
" changes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
1720
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and changes nothing.",
|
|
1721
1721
|
inputSchema: {
|
|
1722
1722
|
automation_id: AutomationId,
|
|
1723
1723
|
name: z.string().nullable().default(null).describe("New automation name."),
|
|
@@ -1758,16 +1758,13 @@ export function buildServer() {
|
|
|
1758
1758
|
});
|
|
1759
1759
|
reg("suppa_delete_automation", {
|
|
1760
1760
|
description: "Soft-delete an automation workflow.\n\n" +
|
|
1761
|
-
" SOFT DELETE:
|
|
1762
|
-
"
|
|
1763
|
-
"
|
|
1764
|
-
"
|
|
1765
|
-
"
|
|
1766
|
-
"
|
|
1767
|
-
"
|
|
1768
|
-
" the table and cannot be restored); that one is deliberately not exposed here.\n\n" +
|
|
1769
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and\n" +
|
|
1770
|
-
" deletes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
1761
|
+
" SOFT DELETE: sets deletedAt — the row remains and the delete is reversible with\n" +
|
|
1762
|
+
" suppa_restore_record('AutomationWorkflow', automation_id). It disappears from normal\n" +
|
|
1763
|
+
" reads and STOPS RUNNING, so treat it as gone for further work; find it again with\n" +
|
|
1764
|
+
" suppa_search_records('AutomationWorkflow', deleted_scope='deleted'). Not the\n" +
|
|
1765
|
+
" platform's permanent delete (rows leave the table and cannot be restored), which this\n" +
|
|
1766
|
+
" server does not expose.\n\n" +
|
|
1767
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and deletes nothing.",
|
|
1771
1768
|
inputSchema: { automation_id: AutomationId, confirm: Confirm },
|
|
1772
1769
|
annotations: _MUT,
|
|
1773
1770
|
}, async (a) => {
|
|
@@ -1781,8 +1778,7 @@ export function buildServer() {
|
|
|
1781
1778
|
" the automation-service. Requires the automation-service deployed on the tenant;\n" +
|
|
1782
1779
|
" if absent the call 404s and the error is returned (never crashes). A typed 400\n" +
|
|
1783
1780
|
" returns {published:false, errors, warnings, message}.\n\n" +
|
|
1784
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and
|
|
1785
|
-
" changes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
1781
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and changes nothing.",
|
|
1786
1782
|
inputSchema: { automation_id: AutomationId, confirm: Confirm },
|
|
1787
1783
|
annotations: _MUT,
|
|
1788
1784
|
}, async (a) => {
|
|
@@ -1795,8 +1791,7 @@ export function buildServer() {
|
|
|
1795
1791
|
description: "Unpublish (deactivate) an automation — clears the live snapshot via the\n" +
|
|
1796
1792
|
" automation-service. Requires the automation-service deployed (else 404,\n" +
|
|
1797
1793
|
" returned as an error).\n\n" +
|
|
1798
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and
|
|
1799
|
-
" changes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
1794
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and changes nothing.",
|
|
1800
1795
|
inputSchema: { automation_id: AutomationId, confirm: Confirm },
|
|
1801
1796
|
annotations: _MUT,
|
|
1802
1797
|
}, async (a) => {
|
|
@@ -2069,8 +2064,7 @@ export function buildServer() {
|
|
|
2069
2064
|
reg("suppa_update_form", {
|
|
2070
2065
|
description: "Update a form's name, schema (data.formShema), settings, or module code.\n" +
|
|
2071
2066
|
" Form names are UNIQUE platform-wide — renaming to an existing name fails.\n\n" +
|
|
2072
|
-
" APPROVAL GATE: without confirm=true this returns a confirmation request and
|
|
2073
|
-
" changes nothing. Get the user's approval, then re-call with confirm=true.",
|
|
2067
|
+
" APPROVAL GATE: without confirm=true this returns a confirmation request and changes nothing.",
|
|
2074
2068
|
inputSchema: {
|
|
2075
2069
|
form_id: z.number().int(),
|
|
2076
2070
|
name: z.string().nullable().default(null),
|
|
@@ -2122,8 +2116,7 @@ export function buildServer() {
|
|
|
2122
2116
|
reg("suppa_add_field_to_form", {
|
|
2123
2117
|
description: "Append a field to a form's schema. Types: text, textarea, richtext, date, select, userSelect, files, toogle, etc.\n\n" +
|
|
2124
2118
|
" This modifies an existing form (data.formShema). APPROVAL GATE: without\n" +
|
|
2125
|
-
" confirm=true this returns a confirmation request and changes nothing.
|
|
2126
|
-
" the user's approval, then re-call with confirm=true.",
|
|
2119
|
+
" confirm=true this returns a confirmation request and changes nothing.",
|
|
2127
2120
|
inputSchema: {
|
|
2128
2121
|
form_id: z.number().int(),
|
|
2129
2122
|
field_name: z
|
|
@@ -2423,6 +2416,9 @@ export function buildServer() {
|
|
|
2423
2416
|
"the gate fails with E301 if anything is unregistered — run it, do not assume.\n" +
|
|
2424
2417
|
"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 — " +
|
|
2425
2418
|
"never invent a mapping; record data stays with suppa_migrate_entities_from_v1.");
|
|
2419
|
+
// Every tools/list goes out without the schema boilerplate no model reads —
|
|
2420
|
+
// see toolsListEconomy.ts. Installed last so it wraps the SDK's own handler.
|
|
2421
|
+
installToolsListEconomy(server);
|
|
2426
2422
|
return server;
|
|
2427
2423
|
}
|
|
2428
2424
|
/**
|
package/dist/tools/docs.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* Python's server.py), so it is applied uniformly across all tools.
|
|
10
10
|
*/
|
|
11
11
|
import { makeRequest, dataUrl, customOrderUrl, searchEntity, selectEntity, insertEntity, updateEntity, removeEntity, } from "../httpClient.js";
|
|
12
|
+
import { ownProjection } from "../projection.js";
|
|
12
13
|
import { makeFilter, stripHtml, jsonResponse, wrapHtml, unescapeUnicode, parseJsonParam, } from "../utils.js";
|
|
13
14
|
// ---------------------------------------------------------------------------
|
|
14
15
|
// Constants
|
|
@@ -16,7 +17,11 @@ import { makeFilter, stripHtml, jsonResponse, wrapHtml, unescapeUnicode, parseJs
|
|
|
16
17
|
export const ENTITY_DOCS = "Docs";
|
|
17
18
|
export const ENTITY_PAGES = "Pages";
|
|
18
19
|
export const ENTITY_PAGE_BLOCKS = "PageBlocks";
|
|
19
|
-
|
|
20
|
+
// `ownProjection`: these are THIS SERVER's field lists, not a caller's — a
|
|
21
|
+
// tenant that lacks one of the fields gets it pruned on first use, and the
|
|
22
|
+
// platform's `deletedAt: null` on each expanded relation is dropped (see
|
|
23
|
+
// projection.ts and readEconomy.ts).
|
|
24
|
+
export const DOC_FIELDS = ownProjection({
|
|
20
25
|
id: true,
|
|
21
26
|
title: true,
|
|
22
27
|
createdAt: true,
|
|
@@ -24,8 +29,8 @@ export const DOC_FIELDS = {
|
|
|
24
29
|
createdBy: { id: true, fullName: true },
|
|
25
30
|
isPublic: true,
|
|
26
31
|
icon: true,
|
|
27
|
-
};
|
|
28
|
-
export const PAGE_FIELDS = {
|
|
32
|
+
});
|
|
33
|
+
export const PAGE_FIELDS = ownProjection({
|
|
29
34
|
id: true,
|
|
30
35
|
title: true,
|
|
31
36
|
description: true,
|
|
@@ -38,7 +43,7 @@ export const PAGE_FIELDS = {
|
|
|
38
43
|
isArchived: true,
|
|
39
44
|
icon: true,
|
|
40
45
|
createdBy: { id: true, fullName: true },
|
|
41
|
-
};
|
|
46
|
+
});
|
|
42
47
|
/**
|
|
43
48
|
* The block types suppa_create_blocks documents (server.ts, tool description).
|
|
44
49
|
* Anything else is refused before it reaches the platform: an unknown type
|
|
@@ -60,7 +65,7 @@ export const BLOCK_TYPES = [
|
|
|
60
65
|
"table",
|
|
61
66
|
"toggle",
|
|
62
67
|
];
|
|
63
|
-
export const BLOCK_FIELDS = {
|
|
68
|
+
export const BLOCK_FIELDS = ownProjection({
|
|
64
69
|
id: true,
|
|
65
70
|
type: true,
|
|
66
71
|
properties: true,
|
|
@@ -68,7 +73,7 @@ export const BLOCK_FIELDS = {
|
|
|
68
73
|
parent: { id: true },
|
|
69
74
|
children: "#expand_tree(10)",
|
|
70
75
|
createdAt: true,
|
|
71
|
-
};
|
|
76
|
+
});
|
|
72
77
|
// ---------------------------------------------------------------------------
|
|
73
78
|
// Block content helpers
|
|
74
79
|
// ---------------------------------------------------------------------------
|
|
@@ -266,12 +271,14 @@ export async function listDocs(search = "", limit = 20) {
|
|
|
266
271
|
const results = await searchEntity(ENTITY_DOCS, filters, DOC_FIELDS, limit);
|
|
267
272
|
return jsonResponse(results);
|
|
268
273
|
}
|
|
274
|
+
/** The list projection plus the document's pages — tagged once, at module load. */
|
|
275
|
+
const DOC_DETAIL_FIELDS = ownProjection({
|
|
276
|
+
...DOC_FIELDS,
|
|
277
|
+
pages: { id: true, title: true, status: true, parent: { id: true } },
|
|
278
|
+
});
|
|
269
279
|
/** Get a document by ID, including its pages. */
|
|
270
280
|
export async function getDoc(docId) {
|
|
271
|
-
const result = await selectEntity(ENTITY_DOCS, [makeFilter("id", docId)],
|
|
272
|
-
...DOC_FIELDS,
|
|
273
|
-
pages: { id: true, title: true, status: true, parent: { id: true } },
|
|
274
|
-
});
|
|
281
|
+
const result = await selectEntity(ENTITY_DOCS, [makeFilter("id", docId)], DOC_DETAIL_FIELDS);
|
|
275
282
|
return jsonResponse(result);
|
|
276
283
|
}
|
|
277
284
|
/** Create a new document. */
|
package/dist/tools/entity.js
CHANGED
|
@@ -17,6 +17,7 @@ import { config } from "../config.js";
|
|
|
17
17
|
import * as tenants from "../tenants.js";
|
|
18
18
|
import { makeRequest, makeRequestRawBytes, searchEntity, selectEntity, insertEntity, updateEntity, removeEntity, restoreEntity, copyEntity, validateSelect, DELETED_SCOPES, DEFAULT_DELETED_SCOPE, DEFAULT_INCLUDE_DELETED_RELATIONS, } from "../httpClient.js";
|
|
19
19
|
import { buildFileUpload, makeFilter, jsonResponse, parseJsonParam, mergeListProblems, normalizeConditionNodes, } from "../utils.js";
|
|
20
|
+
import { compactEntitySchema, slimTitle } from "../readEconomy.js";
|
|
20
21
|
// Builder field types that accept file uploads.
|
|
21
22
|
export const FILE_FIELD_TYPES = ["file", "multi-file"];
|
|
22
23
|
export const RELATION_FIELD_TYPES = [
|
|
@@ -490,7 +491,9 @@ export async function listEntities(search = "", full = false) {
|
|
|
490
491
|
const slim = {};
|
|
491
492
|
for (const k of _ENTITY_SUMMARY_KEYS) {
|
|
492
493
|
if (k in src) {
|
|
493
|
-
|
|
494
|
+
// The localisation record is 90 characters of bookkeeping per entity
|
|
495
|
+
// (id, key, name) around one word of text; full=true keeps it whole.
|
|
496
|
+
slim[k] = k === "title" ? slimTitle(src[k]) : src[k];
|
|
494
497
|
}
|
|
495
498
|
}
|
|
496
499
|
return slim;
|
|
@@ -532,11 +535,26 @@ function _projectionFromList(fields) {
|
|
|
532
535
|
}
|
|
533
536
|
return { fields: proj };
|
|
534
537
|
}
|
|
535
|
-
/**
|
|
538
|
+
/**
|
|
539
|
+
* Get full schema of an entity including all fields, relations, and their types.
|
|
540
|
+
*
|
|
541
|
+
* The platform's shape, untouched: the migration tools parse this. The TOOL
|
|
542
|
+
* answers with describeEntityCompact, which is the same schema minus the bytes
|
|
543
|
+
* that say nothing (see readEconomy.ts).
|
|
544
|
+
*/
|
|
536
545
|
export async function describeEntity(entityName) {
|
|
537
546
|
const result = await makeRequest("GET", `/api/core/schema/${entityName}`);
|
|
538
547
|
return jsonResponse(result);
|
|
539
548
|
}
|
|
549
|
+
/**
|
|
550
|
+
* The schema as suppa_describe_entity returns it: compact by default (nulls,
|
|
551
|
+
* false flags, default options and i18n bookkeeping removed, a legend on top),
|
|
552
|
+
* or the raw platform shape with full=true.
|
|
553
|
+
*/
|
|
554
|
+
export async function describeEntityCompact(entityName, full = false) {
|
|
555
|
+
const result = await makeRequest("GET", `/api/core/schema/${entityName}`);
|
|
556
|
+
return jsonResponse(full ? result : compactEntitySchema(result));
|
|
557
|
+
}
|
|
540
558
|
/**
|
|
541
559
|
* Normalise a deleted_scope argument. Returns the scope, or an error string for
|
|
542
560
|
* anything the platform would reject — the enum is closed (data.txt:76).
|
package/dist/tools/tasks.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { searchEntity, selectEntity, insertEntity, updateEntity, removeEntity, } from "../httpClient.js";
|
|
11
11
|
import { ownProjection } from "../projection.js";
|
|
12
|
+
import { dropDerivablePlainDescription, statusValue } from "../readEconomy.js";
|
|
12
13
|
import { makeFilter, parseDeadline, wrapHtml, jsonResponse, localDayRange } from "../utils.js";
|
|
13
14
|
import * as tenants from "../tenants.js";
|
|
14
15
|
import { config } from "../config.js";
|
|
@@ -164,7 +165,9 @@ export async function countTasks(my = false, active = false, projectId = null, w
|
|
|
164
165
|
/** Get full details of a single task by ID. */
|
|
165
166
|
export async function getTask(taskId) {
|
|
166
167
|
const result = await selectEntity("Tasks", [makeFilter("id", taskId)], TASK_DETAIL_FIELDS);
|
|
167
|
-
|
|
168
|
+
// plainDescription is dropped only when it is htmlDescription with the tags
|
|
169
|
+
// removed — see readEconomy.ts; when they differ, both come back.
|
|
170
|
+
return jsonResponse(dropDerivablePlainDescription(result));
|
|
168
171
|
}
|
|
169
172
|
/** Create a new task. Description supports HTML. Deadline accepts 'today', 'tomorrow', '+3d', or ISO datetime. */
|
|
170
173
|
export async function createTask(title, description = "", assignedToId = null, projectId = null, workflowId = null, stageId = null, typeId = null, priorityId = null, deadline = null, parentId = null) {
|
|
@@ -429,7 +432,7 @@ export async function listWorkflows(name = null) {
|
|
|
429
432
|
entryVal.stages.push({
|
|
430
433
|
id: row.id,
|
|
431
434
|
name: row.name,
|
|
432
|
-
status: row.status,
|
|
435
|
+
status: statusValue(row.status),
|
|
433
436
|
order: row.order,
|
|
434
437
|
});
|
|
435
438
|
}
|
|
@@ -438,7 +441,12 @@ export async function listWorkflows(name = null) {
|
|
|
438
441
|
/** List all stages in a workflow. */
|
|
439
442
|
export async function listStages(workflowId) {
|
|
440
443
|
const results = await searchEntity("StageWorkflows", [makeFilter("workflow", { id: workflowId })], { id: true, name: true, status: { id: true, value: true }, order: true }, 100, 0, [{ field: "order", order: "asc" }]);
|
|
441
|
-
|
|
444
|
+
const stages = Array.isArray(results)
|
|
445
|
+
? results.map((r) => r !== null && typeof r === "object" && !Array.isArray(r)
|
|
446
|
+
? { ...r, status: statusValue(r.status) }
|
|
447
|
+
: r)
|
|
448
|
+
: results;
|
|
449
|
+
return jsonResponse(stages);
|
|
442
450
|
}
|
|
443
451
|
/** List all available task types. */
|
|
444
452
|
export async function listTaskTypes() {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
2
|
+
/**
|
|
3
|
+
* `anyOf: [{type: X}, {type: "null"}]` collapsed into `type: [X, "null"]` — the
|
|
4
|
+
* form zod already emits for `.string().nullable()`, so the listing becomes
|
|
5
|
+
* consistent as well as shorter. Any other anyOf is left exactly as it is.
|
|
6
|
+
*/
|
|
7
|
+
function collapseNullableAnyOf(p) {
|
|
8
|
+
if (!Array.isArray(p.anyOf) || p.anyOf.length !== 2)
|
|
9
|
+
return p;
|
|
10
|
+
const [a, b] = p.anyOf;
|
|
11
|
+
const isBareNull = (x) => isObj(x) && x.type === "null" && Object.keys(x).length === 1;
|
|
12
|
+
const nul = isBareNull(a) ? a : isBareNull(b) ? b : null;
|
|
13
|
+
if (nul === null)
|
|
14
|
+
return p;
|
|
15
|
+
const other = nul === a ? b : a;
|
|
16
|
+
if (!isObj(other) || typeof other.type !== "string" || "anyOf" in other)
|
|
17
|
+
return p;
|
|
18
|
+
const { anyOf: _drop, ...rest } = p;
|
|
19
|
+
return { ...other, ...rest, type: [other.type, "null"] };
|
|
20
|
+
}
|
|
21
|
+
function compactProperty(p) {
|
|
22
|
+
if (!isObj(p))
|
|
23
|
+
return p;
|
|
24
|
+
let out = { ...p };
|
|
25
|
+
if ("default" in out && out.default === null)
|
|
26
|
+
delete out.default;
|
|
27
|
+
out = collapseNullableAnyOf(out);
|
|
28
|
+
if (isObj(out.items))
|
|
29
|
+
out.items = compactProperty(out.items);
|
|
30
|
+
if (isObj(out.properties))
|
|
31
|
+
out.properties = compactProperties(out.properties);
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
function compactProperties(props) {
|
|
35
|
+
const out = {};
|
|
36
|
+
for (const [k, v] of Object.entries(props))
|
|
37
|
+
out[k] = compactProperty(v);
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
/** The compact form of one tool's inputSchema. Pure — the input is not mutated. */
|
|
41
|
+
export function compactInputSchema(schema) {
|
|
42
|
+
if (!isObj(schema))
|
|
43
|
+
return schema;
|
|
44
|
+
const { $schema: _drop, ...out } = schema;
|
|
45
|
+
if (isObj(out.properties))
|
|
46
|
+
out.properties = compactProperties(out.properties);
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Wrap the SDK's tools/list handler so every listing goes out compact.
|
|
51
|
+
*
|
|
52
|
+
* Returns false when the SDK no longer keeps its handlers where this looks. The
|
|
53
|
+
* wire test asserts true, so an SDK upgrade that moves them fails the suite at
|
|
54
|
+
* upgrade time instead of silently shipping the long form again.
|
|
55
|
+
*/
|
|
56
|
+
export function installToolsListEconomy(server) {
|
|
57
|
+
const proto = server.server;
|
|
58
|
+
const handlers = proto._requestHandlers;
|
|
59
|
+
const inner = handlers?.get("tools/list");
|
|
60
|
+
if (!handlers || !inner)
|
|
61
|
+
return false;
|
|
62
|
+
handlers.set("tools/list", async (request, extra) => {
|
|
63
|
+
const result = (await inner(request, extra));
|
|
64
|
+
if (result && Array.isArray(result.tools)) {
|
|
65
|
+
result.tools = result.tools.map((t) => isObj(t) ? { ...t, inputSchema: compactInputSchema(t.inputSchema) } : t);
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
});
|
|
69
|
+
return true;
|
|
70
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suppa-mcp-2",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.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": {
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
export const HOUSE_RULES_DIGEST = `WRITING ENTITY CODE (*.entity.ts in an application repo — NOT the API tools above)
|
|
17
|
-
These six rules are house rules of this platform. They OVERRIDE the platform's own migrations doc
|
|
18
|
-
1. TYPE EVERY RELATION PROPERTY to match its decorator: @ManyToOne -> \`owner: Target;\` (\`owner?: Target\` when the relation is nullable)
|
|
19
|
-
2. ENUM MEMBER KEYS ARE PascalCase — \`NotFilled = 'Not filled'
|
|
20
|
-
3. NEVER WRITE A FIELD OPTION AT ITS DEFAULT
|
|
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
|
|
22
|
-
5. A RELATION TARGET THAT ALREADY EXISTS on the tenant (created earlier, or owned by another application) gets a STUB
|
|
23
|
-
6. TO ADD COLUMNS TO AN ENTITY YOU DO NOT OWN, DECLARE AN EXTENSION — not a stub
|
|
24
|
-
Before reporting the file done, run the gate:
|
|
17
|
+
These six rules are house rules of this platform. They OVERRIDE the platform's own migrations doc (which contradicts two of them) and the style of the entities already in the repo you are editing — a file that breaks them is the habit these rules exist to stop, not a convention to match. Full skill: skills/suppa-entity-code/SKILL.md in the installed suppa-mcp-2 package; the six bind whether or not you open it.
|
|
18
|
+
1. TYPE EVERY RELATION PROPERTY to match its decorator: @ManyToOne -> \`owner: Target;\` (\`owner?: Target\` when the relation is nullable); @ManyToMany/@OneToMany/@ManyToManyBackRef -> \`peers: Target[];\`. Never \`any\`.
|
|
19
|
+
2. ENUM MEMBER KEYS ARE PascalCase — \`NotFilled = 'Not filled'\` — the stored value is the string on the right and need not match the key.
|
|
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
|
+
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
|
+
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).
|
|
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. */
|
|
27
27
|
export const BLOCKING_SUMMARY =
|