suppa-mcp-2 1.40.2 → 1.40.4
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/dist/auth.js +4 -1
- package/dist/server.js +1 -1
- package/dist/sessionDiag.js +17 -1
- package/dist/tenants.js +29 -4
- package/dist/tools/entity.js +12 -1
- package/package.json +1 -1
- package/skills/suppa-cli/SKILL.md +1 -1
- package/skills/suppa-entity-code/references/entities.md +38 -1
- package/skills/suppa-entity-code/scripts/house-rules.mjs +3 -1
- package/skills/suppa-entity-code/scripts/validate-suppa-schema.mjs +177 -4
- package/skills/suppa-form-v2/scripts/validate-form-schema.mjs +51 -1
package/dist/auth.js
CHANGED
|
@@ -491,7 +491,10 @@ export async function doRefresh(baseUrl, host, creds) {
|
|
|
491
491
|
({ body, cookies } = await callRefresh(baseUrl, host, creds));
|
|
492
492
|
}
|
|
493
493
|
catch (e) {
|
|
494
|
-
|
|
494
|
+
// Only a 401/403 means the platform REFUSED the token — the same line refreshFailureReason
|
|
495
|
+
// draws. Anything else (5xx, 429, a moved route) leaves the stored session as good as it was.
|
|
496
|
+
const refused = e instanceof AuthHttpError && (e.status === 401 || e.status === 403);
|
|
497
|
+
recordRefreshFailure(host, refreshFailureReason(e), { rejected: refused });
|
|
495
498
|
throw e;
|
|
496
499
|
}
|
|
497
500
|
const fresh = extractCredentials(body, cookies);
|
package/dist/server.js
CHANGED
|
@@ -292,7 +292,7 @@ const INSTRUCTIONS = `Suppa Platform MCP Server — Tasks, Docs/Pages, Entities,
|
|
|
292
292
|
|
|
293
293
|
AUTHENTICATION — RESOLVE THIS BEFORE ANY OTHER SUPPA WORK
|
|
294
294
|
- 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.
|
|
295
|
-
-
|
|
295
|
+
- Signed in? suppa_list_tenants shows the STORED "authenticated"/"needs_login" (no network; a revoked session still reads signed in); suppa_diagnostics makes the live call that settles it.
|
|
296
296
|
- When not signed in — or any tool answers "No credentials" / HTTP 401 / "session could not be refreshed" / ReloginRequired — DO NOT STOP and DO NOT ask for a key:
|
|
297
297
|
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:${config.LOGIN_PORT}.
|
|
298
298
|
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.
|
package/dist/sessionDiag.js
CHANGED
|
@@ -15,13 +15,29 @@
|
|
|
15
15
|
*/
|
|
16
16
|
/** host -> why its last refresh attempt failed. */
|
|
17
17
|
const reasons = new Map();
|
|
18
|
+
/**
|
|
19
|
+
* Hosts whose last refresh the PLATFORM refused (HTTP 401/403): the stored refresh token is dead,
|
|
20
|
+
* and signing in again is the one fix. Kept apart from `reasons` because most failures are not
|
|
21
|
+
* that — a 5xx, a 429 or a moved route leaves the session intact, and telling someone to log in
|
|
22
|
+
* over one of those sends them round in circles.
|
|
23
|
+
*/
|
|
24
|
+
const rejected = new Set();
|
|
18
25
|
/** Remember why `host` could not refresh, for the 401 that is about to follow. */
|
|
19
|
-
export function recordRefreshFailure(host, reason) {
|
|
26
|
+
export function recordRefreshFailure(host, reason, opts = {}) {
|
|
20
27
|
reasons.set(host, reason);
|
|
28
|
+
if (opts.rejected)
|
|
29
|
+
rejected.add(host);
|
|
30
|
+
else
|
|
31
|
+
rejected.delete(host);
|
|
21
32
|
}
|
|
22
33
|
/** Forget the last failure for `host` — called when a refresh succeeds. */
|
|
23
34
|
export function clearRefreshFailure(host) {
|
|
24
35
|
reasons.delete(host);
|
|
36
|
+
rejected.delete(host);
|
|
37
|
+
}
|
|
38
|
+
/** True when the platform refused `host`'s last refresh — the session is gone, not just unreachable. */
|
|
39
|
+
export function refreshRejected(host) {
|
|
40
|
+
return rejected.has(host);
|
|
25
41
|
}
|
|
26
42
|
/** The last refresh failure for `host`, or null if the last attempt worked. */
|
|
27
43
|
export function lastRefreshError(host) {
|
package/dist/tenants.js
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
import { config } from "./config.js";
|
|
25
25
|
import * as registry from "./registry.js";
|
|
26
26
|
import * as store from "./store.js";
|
|
27
|
+
import { lastRefreshError, refreshRejected } from "./sessionDiag.js";
|
|
27
28
|
import { jsonResponse } from "./utils.js";
|
|
28
29
|
/** Everything `httpClient` needs to talk to one Suppa tenant. */
|
|
29
30
|
export class TenantContext {
|
|
@@ -259,11 +260,26 @@ export function register(baseUrl, host = "") {
|
|
|
259
260
|
registry.add(host, alias, baseUrl);
|
|
260
261
|
return [alias, host];
|
|
261
262
|
}
|
|
262
|
-
/**
|
|
263
|
+
/**
|
|
264
|
+
* Auth + expiry status for a host, for display in listTenants.
|
|
265
|
+
*
|
|
266
|
+
* Read from what is STORED, plus one thing learned in this process: if the platform refused this
|
|
267
|
+
* host's refresh (401/403), the stored session is dead however far off its expiry reads, and the
|
|
268
|
+
* status says so. Without that, `diagnostics` printed `needs_login: false` in the very row that
|
|
269
|
+
* carried its own probe's "session could not be refreshed".
|
|
270
|
+
*/
|
|
263
271
|
export function sessionStatus(host) {
|
|
264
272
|
const creds = store.load(host);
|
|
265
273
|
if (creds && creds.accessToken) {
|
|
266
274
|
const exp = creds.refreshExp || 0.0;
|
|
275
|
+
if (refreshRejected(host)) {
|
|
276
|
+
return {
|
|
277
|
+
authenticated: true,
|
|
278
|
+
needs_login: true,
|
|
279
|
+
session_expires_at: exp || null,
|
|
280
|
+
session_error: lastRefreshError(host) ?? "the platform rejected the stored refresh token",
|
|
281
|
+
};
|
|
282
|
+
}
|
|
267
283
|
return {
|
|
268
284
|
authenticated: true,
|
|
269
285
|
needs_login: Boolean(exp) && Date.now() / 1000 >= exp,
|
|
@@ -301,7 +317,7 @@ export function useTenant(name) {
|
|
|
301
317
|
host,
|
|
302
318
|
base_url: baseUrl,
|
|
303
319
|
...status,
|
|
304
|
-
hint: status.
|
|
320
|
+
hint: status.needs_login ? "Run suppa_login to authenticate this tenant." : null,
|
|
305
321
|
});
|
|
306
322
|
}
|
|
307
323
|
/**
|
|
@@ -333,7 +349,13 @@ export function listTenants() {
|
|
|
333
349
|
default: def,
|
|
334
350
|
...sessionStatus(host),
|
|
335
351
|
}));
|
|
336
|
-
return jsonResponse({
|
|
352
|
+
return jsonResponse({
|
|
353
|
+
tenants: rows,
|
|
354
|
+
keychain_available: store.available(),
|
|
355
|
+
note: "authenticated / needs_login describe the session STORED on this machine, checked without a " +
|
|
356
|
+
"network call — a session the platform has revoked still reads authenticated here until a call " +
|
|
357
|
+
"fails. diagnostics makes a live call per tenant and is the check that settles it.",
|
|
358
|
+
});
|
|
337
359
|
}
|
|
338
360
|
export function logout(name = "") {
|
|
339
361
|
let host;
|
|
@@ -405,6 +427,9 @@ export async function diagnostics(deep = true) {
|
|
|
405
427
|
};
|
|
406
428
|
const tenantsReport = [];
|
|
407
429
|
for (const [alias, host, baseUrl, def] of allTenants()) {
|
|
430
|
+
// Probe FIRST: its live call exercises the refresh, so a session the platform refuses is
|
|
431
|
+
// known by the time the row reads sessionStatus — and the row agrees with its own evidence.
|
|
432
|
+
const connectivity = deep ? await probe(baseUrl, host) : undefined;
|
|
408
433
|
const row = {
|
|
409
434
|
alias,
|
|
410
435
|
host,
|
|
@@ -413,7 +438,7 @@ export async function diagnostics(deep = true) {
|
|
|
413
438
|
...sessionStatus(host),
|
|
414
439
|
};
|
|
415
440
|
if (deep) {
|
|
416
|
-
row.connectivity =
|
|
441
|
+
row.connectivity = connectivity;
|
|
417
442
|
}
|
|
418
443
|
tenantsReport.push(row);
|
|
419
444
|
}
|
package/dist/tools/entity.js
CHANGED
|
@@ -1736,6 +1736,15 @@ export async function buildFieldDef(entityName, fieldName, fieldType, title, opt
|
|
|
1736
1736
|
notApplicable.push(`defaultValue was NOT set: it does not apply to a unique field. The field was created ` +
|
|
1737
1737
|
"WITHOUT a default.");
|
|
1738
1738
|
}
|
|
1739
|
+
else if (defaultValue !== null && defaultValue !== undefined) {
|
|
1740
|
+
// The caller passed something that carries no value — "", " ", or []. The update path
|
|
1741
|
+
// REFUSES this outright; this path used to drop it without a word, which is the silent drop
|
|
1742
|
+
// the comment above says was already fixed for notNull and unique. Reporting it keeps the two
|
|
1743
|
+
// paths telling the caller the same thing about the same input.
|
|
1744
|
+
notApplicable.push(`defaultValue was NOT set: ${Array.isArray(defaultValue) ? "an empty array" : JSON.stringify(String(defaultValue))} carries no value, and the builder rejects one — suppa_update_field refuses the same input ` +
|
|
1745
|
+
"outright. The field was created WITHOUT a default. Pass the value every row without an " +
|
|
1746
|
+
'explicit one gets ("0", "\'draft\'", "now()"), or omit default_value.');
|
|
1747
|
+
}
|
|
1739
1748
|
// Sent exactly as validated: subTypeProblem() judged the TRIMMED value, and
|
|
1740
1749
|
// ' date ' used to pass that check and then go out with the spaces.
|
|
1741
1750
|
if (typeof subType === "string" && subType.trim() !== "") {
|
|
@@ -2020,8 +2029,10 @@ export async function updateField(entityName, fieldName, opts = {}) {
|
|
|
2020
2029
|
// Same rule as add-fields: an empty string is not a default and the builder
|
|
2021
2030
|
// rejects it. It used to be sent here verbatim.
|
|
2022
2031
|
if (String(opts.defaultValue).trim() === "") {
|
|
2032
|
+
// `[]` stringifies to "" too, and calling it "an empty string" names the wrong problem.
|
|
2033
|
+
const what = Array.isArray(opts.defaultValue) ? "an empty array" : "an empty string";
|
|
2023
2034
|
return jsonResponse({
|
|
2024
|
-
error: `Refused: default_value is
|
|
2035
|
+
error: `Refused: default_value is ${what} — that is not a default, and the builder ` +
|
|
2025
2036
|
`rejects one on '${entityName}.${fieldName}' just as it does on add-fields. Nothing was ` +
|
|
2026
2037
|
"sent. Pass the value every row without an explicit one gets (\"0\", \"'draft'\", " +
|
|
2027
2038
|
'"now()"), or omit default_value to leave the current default as it is.',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suppa-mcp-2",
|
|
3
|
-
"version": "1.40.
|
|
3
|
+
"version": "1.40.4",
|
|
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": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: suppa-cli
|
|
3
|
-
description: Use when working with a Suppa 2.0 tenant from a terminal — tasks, records, entities, custom fields, docs, forms, automations, file attachments. The `suppa` command carries all
|
|
3
|
+
description: Use when working with a Suppa 2.0 tenant from a terminal — tasks, records, entities, custom fields, docs, forms, automations, file attachments. The `suppa` command carries all 99 operations with browser-based login and token storage in the OS keychain. Prefer it over hand-written HTTP calls: validates arguments before sending and explains platform refusals.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Suppa 2.0 from the shell
|
|
@@ -62,7 +62,44 @@ Every entity must extend SystemBaseEntity. It contributes the standard columns,
|
|
|
62
62
|
|
|
63
63
|
See [references/tabular-parts.md](tabular-parts.md) for the full triad required to declare a tabular part (`type: 'tabular-part'` + `relationEntityName` + an `owner` relation).
|
|
64
64
|
|
|
65
|
-
options
|
|
65
|
+
`options` switches the platform's per-entity features. The migrations doc types it
|
|
66
|
+
`Record<string, any>` and shows nine keys underneath as an **example** — the example is not the
|
|
67
|
+
list. What the platform accepts is the builder's Entity Options table: sixteen keys, each with one
|
|
68
|
+
type. Anything else is dropped without complaint, so the gate refuses it, and refuses a value of the
|
|
69
|
+
wrong type too (**E503**):
|
|
70
|
+
|
|
71
|
+
| Option | Type | What it switches on |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| `comments` | boolean | comments |
|
|
74
|
+
| `reactions` | boolean | reactions |
|
|
75
|
+
| `hierarchy` | `"single" \| "multi"` | a tree over the entity's own records — `"single"` generates the self-relations `parent` and `children` (read off the live `Forms` entity); `"multi"` gives a record several parents, which the front end writes through `parents` |
|
|
76
|
+
| `folders` | `"single" \| "multi"` | folders to file records into |
|
|
77
|
+
| `trackChangeHistory` | boolean | change tracking |
|
|
78
|
+
| `browsingHistory` | boolean or number | browsing history |
|
|
79
|
+
| `globalSearch` | boolean | the entity in global search |
|
|
80
|
+
| `timeTracking` | boolean | time tracking — generates `spentTime` |
|
|
81
|
+
| `favorites` | boolean | favourites |
|
|
82
|
+
| `pinned` | boolean | pinned records |
|
|
83
|
+
| `approvals` | boolean | approvals |
|
|
84
|
+
| `checklists` | boolean | checklists |
|
|
85
|
+
| `recurrence` | boolean | recurrence |
|
|
86
|
+
| `reminders` | boolean | reminders |
|
|
87
|
+
| `notificationMutes` | boolean | notification mutes |
|
|
88
|
+
| `customFields` | boolean | per-context custom fields — see below |
|
|
89
|
+
|
|
90
|
+
`hierarchy` and `folders` are modes, not switches: `hierarchy: true` is wrong, and to leave either
|
|
91
|
+
feature off you omit the key. Every option is a schema change rather than a preference — "Enabling
|
|
92
|
+
an option creates the side table that backs it" (builder doc) — and the fields an option generates
|
|
93
|
+
(`parent`, `parents`, `children`, `multiChildren`, `spentTime`, `comments`, …) are names you may not
|
|
94
|
+
declare yourself (**E132**).
|
|
95
|
+
|
|
96
|
+
On an entity you do **not** own, extension mode ignores `options` wholesale (**W618**), so a feature
|
|
97
|
+
cannot be switched on from a file there. Do it once at runtime instead:
|
|
98
|
+
`suppa update-entity-options --entity-name Tasks --options-json '{"hierarchy":"single"}'`
|
|
99
|
+
(MCP: `suppa_update_entity_options`).
|
|
100
|
+
|
|
101
|
+
The migrations doc's own example, which switches off what an entity does not need — each enabled
|
|
102
|
+
feature adds side tables and processing:
|
|
66
103
|
|
|
67
104
|
```ts
|
|
68
105
|
@Entity({
|
|
@@ -40,4 +40,6 @@ export const BLOCKING_SUMMARY =
|
|
|
40
40
|
"no @Index over a single @ManyToOne or unique column, metadata-sync indexes those itself and the duplicate " +
|
|
41
41
|
"key aborts the tenant migration (W628); no entity name ending in a reserved companion-table suffix " +
|
|
42
42
|
"(E131), no platform-owned field name such as parent/comments/customFields/searchVector (E132), no " +
|
|
43
|
-
"scalar `<x>Id` beside a relation `<x>` (E133)"
|
|
43
|
+
"scalar `<x>Id` beside a relation `<x>` (E133); and inside @Entity({ options }) only the platform's " +
|
|
44
|
+
"feature options, each with the type it takes — hierarchy and folders are \"single\" or \"multi\", never " +
|
|
45
|
+
"a boolean (E503)";
|
|
@@ -32,6 +32,38 @@ import { pathToFileURL } from "node:url";
|
|
|
32
32
|
export const SYSTEM_COLUMNS = ["id", "createdAt", "updatedAt", "deletedAt", "createdBy", "removedBy"];
|
|
33
33
|
export const ACCESS_METADATA_KEYS = ["$readAccess", "$updateAccess", "$instanceAccess"];
|
|
34
34
|
export const DOC_ENTITY_OPTIONS = ["name", "title", "comment", "representativeFieldName", "importKeyFields", "key", "icon", "type", "relationEntityName", "options"];
|
|
35
|
+
/**
|
|
36
|
+
* What may go INSIDE `@Entity({ options: { … } })`, and the type each one takes.
|
|
37
|
+
*
|
|
38
|
+
* The builder doc's Entity Options table (api-entity-builder-builder.txt:76-90)
|
|
39
|
+
* plus `customFields`, which postdates that capture — the SAME closed set
|
|
40
|
+
* src/tools/entity.ts enforces on the MCP side (ENTITY_OPTION_KEYS), and a test
|
|
41
|
+
* pins the two equal. The migrations doc types the slot `Record<string, any>`
|
|
42
|
+
* and shows nine of these as an EXAMPLE under it; the example is not the list,
|
|
43
|
+
* and reading it as one is how `hierarchy` came to look like no option at all.
|
|
44
|
+
*
|
|
45
|
+
* `mode` is `"single" | "multi"`; `boolean-or-number` is browsingHistory alone.
|
|
46
|
+
*/
|
|
47
|
+
export const ENTITY_FEATURE_OPTIONS = Object.freeze({
|
|
48
|
+
comments: "boolean",
|
|
49
|
+
reactions: "boolean",
|
|
50
|
+
hierarchy: "mode",
|
|
51
|
+
folders: "mode",
|
|
52
|
+
trackChangeHistory: "boolean",
|
|
53
|
+
browsingHistory: "boolean-or-number",
|
|
54
|
+
globalSearch: "boolean",
|
|
55
|
+
timeTracking: "boolean",
|
|
56
|
+
favorites: "boolean",
|
|
57
|
+
pinned: "boolean",
|
|
58
|
+
approvals: "boolean",
|
|
59
|
+
checklists: "boolean",
|
|
60
|
+
recurrence: "boolean",
|
|
61
|
+
reminders: "boolean",
|
|
62
|
+
notificationMutes: "boolean",
|
|
63
|
+
customFields: "boolean",
|
|
64
|
+
});
|
|
65
|
+
/** builder.txt:78-79 — the closed value set of `hierarchy` and `folders`. */
|
|
66
|
+
export const ENTITY_FEATURE_MODES = ["single", "multi"];
|
|
35
67
|
/**
|
|
36
68
|
* The 24 languages a `title` can be stored in. They are the COLUMNS of the
|
|
37
69
|
* platform's `Localizations` table (entity-builder,
|
|
@@ -1543,6 +1575,122 @@ function checkTabularPart(ts, info, model, findings) {
|
|
|
1543
1575
|
}
|
|
1544
1576
|
}
|
|
1545
1577
|
|
|
1578
|
+
// ── rules: entity feature options (E503) ──
|
|
1579
|
+
/** A value this AST-only checker cannot see — a const, a call, an import. */
|
|
1580
|
+
const UNREADABLE = Symbol("unreadable");
|
|
1581
|
+
/** The literal a feature option's value is, or UNREADABLE. Objects and arrays are wrong-typed, not unreadable. */
|
|
1582
|
+
function featureLiteral(ts, node) {
|
|
1583
|
+
if (!node) return UNREADABLE;
|
|
1584
|
+
const b = booleanValue(ts, node);
|
|
1585
|
+
if (b !== null) return b;
|
|
1586
|
+
const s = stringValue(ts, node);
|
|
1587
|
+
if (s !== null) return s;
|
|
1588
|
+
if (ts.isNumericLiteral(node)) return Number(node.text);
|
|
1589
|
+
if (ts.isPrefixUnaryExpression(node) && node.operator === ts.SyntaxKind.MinusToken &&
|
|
1590
|
+
ts.isNumericLiteral(node.operand)) return -Number(node.operand.text);
|
|
1591
|
+
if (node.kind === ts.SyntaxKind.NullKeyword) return null;
|
|
1592
|
+
if (ts.isObjectLiteralExpression(node)) return {};
|
|
1593
|
+
if (ts.isArrayLiteralExpression(node)) return [];
|
|
1594
|
+
return UNREADABLE;
|
|
1595
|
+
}
|
|
1596
|
+
/** What is wrong with a feature option's value — a clause completing "'<key>' …" — or null. */
|
|
1597
|
+
function featureValueProblem(key, kind, value) {
|
|
1598
|
+
if (value === UNREADABLE) return null; // the key was checked; guessing a type is worse than silence
|
|
1599
|
+
const got = `got ${JSON.stringify(value)}`;
|
|
1600
|
+
if (kind === "mode") {
|
|
1601
|
+
if (typeof value === "string" && ENTITY_FEATURE_MODES.includes(value)) return null;
|
|
1602
|
+
const isOff = value === false || value === null;
|
|
1603
|
+
// Say what a mode MEANS only where that is on record: the front end writes a multi-parent
|
|
1604
|
+
// hierarchy through `parents`. Nothing says what "multi" means for folders, so nothing is said.
|
|
1605
|
+
const meaning = key === "hierarchy" ? `. "single" gives a record one parent, "multi" several` : "";
|
|
1606
|
+
return `is a mode — "single" or "multi" — ` +
|
|
1607
|
+
(typeof value === "boolean" ? `not a boolean: ${got}` : `${got}`) +
|
|
1608
|
+
meaning + (isOff ? `; to leave the feature off, omit the key` : "") + `.`;
|
|
1609
|
+
}
|
|
1610
|
+
if (kind === "boolean") {
|
|
1611
|
+
if (typeof value === "boolean") return null;
|
|
1612
|
+
return `is a switch and takes a boolean — ${got}. Write true or false.`;
|
|
1613
|
+
}
|
|
1614
|
+
if (kind === "boolean-or-number") {
|
|
1615
|
+
if (typeof value === "boolean" || (typeof value === "number" && Number.isFinite(value))) return null;
|
|
1616
|
+
return `takes a boolean or a number — ${got}` +
|
|
1617
|
+
(typeof value === "string" && value.trim() !== "" && Number.isFinite(Number(value))
|
|
1618
|
+
? `. A quoted number is a string: write ${Number(value)}.` : `.`);
|
|
1619
|
+
}
|
|
1620
|
+
return null;
|
|
1621
|
+
}
|
|
1622
|
+
/** The known name within two edits of `name`, for "did you mean" — or null. */
|
|
1623
|
+
function closestName(name, known) {
|
|
1624
|
+
const dist = (a, b) => {
|
|
1625
|
+
const row = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
1626
|
+
for (let i = 1; i <= a.length; i++) {
|
|
1627
|
+
let prev = row[0];
|
|
1628
|
+
row[0] = i;
|
|
1629
|
+
for (let j = 1; j <= b.length; j++) {
|
|
1630
|
+
const cur = row[j];
|
|
1631
|
+
row[j] = Math.min(row[j] + 1, row[j - 1] + 1, prev + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
1632
|
+
prev = cur;
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
return row[b.length];
|
|
1636
|
+
};
|
|
1637
|
+
let best = null;
|
|
1638
|
+
let bestD = 3;
|
|
1639
|
+
for (const k of known) {
|
|
1640
|
+
const d = dist(name.toLowerCase(), k.toLowerCase());
|
|
1641
|
+
if (d < bestD) { best = k; bestD = d; }
|
|
1642
|
+
}
|
|
1643
|
+
return best;
|
|
1644
|
+
}
|
|
1645
|
+
/**
|
|
1646
|
+
* E503 — the keys and values inside `@Entity({ options: { … } })`.
|
|
1647
|
+
*
|
|
1648
|
+
* E501 checks the TOP-LEVEL keys of @Entity() and never opened `options`, so
|
|
1649
|
+
* `hierachy: 'single'` or `hierarchy: true` passed in silence — and the builder
|
|
1650
|
+
* drops an unknown key without complaint, so that code reads as a feature
|
|
1651
|
+
* switched on while the platform switches nothing. Allowed keys are the builder
|
|
1652
|
+
* table (ENTITY_FEATURE_OPTIONS) plus any the SDK's own typings name, exactly as
|
|
1653
|
+
* E501 unions the SDK with the doc: a newer SDK must not be blocked by an older
|
|
1654
|
+
* table.
|
|
1655
|
+
*/
|
|
1656
|
+
function checkFeatureOptions(ts, sf, info, sdk, findings) {
|
|
1657
|
+
const slot = info.options.get("options");
|
|
1658
|
+
if (!slot) return;
|
|
1659
|
+
const obj = unwrapExpr(ts, slot);
|
|
1660
|
+
if (!ts.isObjectLiteralExpression(obj)) {
|
|
1661
|
+
if (isOpaqueExpression(ts, obj)) {
|
|
1662
|
+
findings.push(finding(ts, sf, slot, "W606",
|
|
1663
|
+
`@Entity() feature options for '${info.className}' arrive by reference, so none of them can be ` +
|
|
1664
|
+
`read here — the feature-option check (E503) is skipped for this entity. Inline the options ` +
|
|
1665
|
+
`object to restore it.`));
|
|
1666
|
+
}
|
|
1667
|
+
return;
|
|
1668
|
+
}
|
|
1669
|
+
for (const spread of spreadElements(ts, obj)) {
|
|
1670
|
+
findings.push(finding(ts, sf, spread, "W606",
|
|
1671
|
+
`@Entity() feature options for '${info.className}' spread another object, and spread content cannot ` +
|
|
1672
|
+
`be read statically — the feature-option check (E503) is skipped for whatever it carries. Inline ` +
|
|
1673
|
+
`the options to restore it.`));
|
|
1674
|
+
}
|
|
1675
|
+
const known = [...new Set([...Object.keys(ENTITY_FEATURE_OPTIONS), ...(sdk.featureOptions ?? [])])];
|
|
1676
|
+
for (const [key, valNode] of objectMap(ts, obj)) {
|
|
1677
|
+
if (!known.includes(key)) {
|
|
1678
|
+
const near = closestName(key, known);
|
|
1679
|
+
findings.push(finding(ts, sf, valNode, "E503",
|
|
1680
|
+
`unknown entity feature option '${key}' in @Entity({ options })` +
|
|
1681
|
+
(near ? ` — did you mean '${near}'?` : ".") +
|
|
1682
|
+
` The platform accepts ${known.join(", ")}; the builder drops anything else without complaint, ` +
|
|
1683
|
+
`so this line reads as a feature switched on while nothing is. The migrations doc shows nine of ` +
|
|
1684
|
+
`these as an example, not as the list — the full table, with types, is references/entities.md.`));
|
|
1685
|
+
continue;
|
|
1686
|
+
}
|
|
1687
|
+
const kind = ENTITY_FEATURE_OPTIONS[key];
|
|
1688
|
+
if (!kind) continue; // named only by the SDK: its type is the SDK's to state
|
|
1689
|
+
const problem = featureValueProblem(key, kind, featureLiteral(ts, unwrapExpr(ts, valNode)));
|
|
1690
|
+
if (problem) findings.push(finding(ts, sf, valNode, "E503", `'${key}' ${problem}`));
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1546
1694
|
// ── rules: entities ──
|
|
1547
1695
|
function checkEntity(ts, info, sdk, model, findings) {
|
|
1548
1696
|
const sf = info.sf;
|
|
@@ -1563,6 +1711,10 @@ function checkEntity(ts, info, sdk, model, findings) {
|
|
|
1563
1711
|
`unknown @Entity() option '${opt}' — valid options: ${sdk.entityOptions.join(", ")}. If it isn't in the table, it isn't an option.`));
|
|
1564
1712
|
}
|
|
1565
1713
|
}
|
|
1714
|
+
// …and what goes INSIDE `options`, which E501 never opened. An extension is
|
|
1715
|
+
// left to W618: the platform discards that whole object, so a typo in it is
|
|
1716
|
+
// not a second problem.
|
|
1717
|
+
if (!info.isExtension) checkFeatureOptions(ts, sf, info, sdk, findings);
|
|
1566
1718
|
|
|
1567
1719
|
// Options delivered by reference are read as no options at all, so E501, W602
|
|
1568
1720
|
// and E106 all stop applying at once — this file's convention is that content
|
|
@@ -3319,6 +3471,9 @@ function loadSdkCatalog(ts, rootDir) {
|
|
|
3319
3471
|
entityOptions: [...DOC_ENTITY_OPTIONS],
|
|
3320
3472
|
columnOptions: [...DOC_COLUMN_OPTIONS],
|
|
3321
3473
|
fieldTypes: { ...DOC_FIELD_TYPES },
|
|
3474
|
+
// Feature options the SDK's own typings name for `@Entity({ options })`. Empty
|
|
3475
|
+
// while the SDK types that slot `Record<string, any>`, as the doc says it does.
|
|
3476
|
+
featureOptions: [],
|
|
3322
3477
|
source: "doc",
|
|
3323
3478
|
};
|
|
3324
3479
|
if (!rootDir) return catalog;
|
|
@@ -3343,6 +3498,8 @@ function loadSdkCatalog(ts, rootDir) {
|
|
|
3343
3498
|
const fieldTypes = {};
|
|
3344
3499
|
let entityOptions = [];
|
|
3345
3500
|
let columnOptions = [];
|
|
3501
|
+
const interfaces = new Map();
|
|
3502
|
+
let featureType = null;
|
|
3346
3503
|
sf.forEachChild(function walk(node) {
|
|
3347
3504
|
if (ts.isEnumDeclaration(node) && node.name.text === "FieldTypeEnum") {
|
|
3348
3505
|
for (const m of node.members) {
|
|
@@ -3353,14 +3510,30 @@ function loadSdkCatalog(ts, rootDir) {
|
|
|
3353
3510
|
}
|
|
3354
3511
|
}
|
|
3355
3512
|
if (ts.isInterfaceDeclaration(node)) {
|
|
3356
|
-
const
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3513
|
+
const members = node.members.filter((mm) => ts.isPropertySignature(mm) && mm.name);
|
|
3514
|
+
const nameOf = (mm) => mm.name.getText(sf).replace(/['"]/g, "");
|
|
3515
|
+
const props = members.map(nameOf);
|
|
3516
|
+
interfaces.set(node.name.text, props);
|
|
3517
|
+
if (/EntityOptions$/i.test(node.name.text)) {
|
|
3518
|
+
entityOptions = props;
|
|
3519
|
+
// The type of its `options` member is where an SDK would name the
|
|
3520
|
+
// feature options — resolved after the walk, since the interface it
|
|
3521
|
+
// references may be declared further down the file.
|
|
3522
|
+
const slot = members.find((mm) => nameOf(mm) === "options");
|
|
3523
|
+
if (slot?.type) featureType = slot.type;
|
|
3524
|
+
}
|
|
3360
3525
|
if (/ColumnOptions$/i.test(node.name.text)) columnOptions = props;
|
|
3361
3526
|
}
|
|
3362
3527
|
ts.forEachChild(node, walk);
|
|
3363
3528
|
});
|
|
3529
|
+
if (featureType && ts.isTypeLiteralNode(featureType)) {
|
|
3530
|
+
catalog.featureOptions = featureType.members
|
|
3531
|
+
.filter((mm) => ts.isPropertySignature(mm) && mm.name)
|
|
3532
|
+
.map((mm) => mm.name.getText(sf).replace(/['"]/g, ""));
|
|
3533
|
+
} else if (featureType && ts.isTypeReferenceNode(featureType) && ts.isIdentifier(featureType.typeName)) {
|
|
3534
|
+
// `Record<string, any>` is a reference too, to no interface declared here — it names nothing.
|
|
3535
|
+
catalog.featureOptions = interfaces.get(featureType.typeName.text) ?? [];
|
|
3536
|
+
}
|
|
3364
3537
|
let got = 0;
|
|
3365
3538
|
// fieldTypes are enum VALUES, not option names — an older SDK enum member
|
|
3366
3539
|
// set is the true, current set for this install, so replace outright.
|
|
@@ -452,6 +452,27 @@ function offKitSpacing(schema, skipIds) {
|
|
|
452
452
|
return out;
|
|
453
453
|
}
|
|
454
454
|
|
|
455
|
+
/**
|
|
456
|
+
* Element types saved forms still carry that the platform no longer renders or lists — each with what
|
|
457
|
+
* the evidence says replaced it, and nothing past that.
|
|
458
|
+
*
|
|
459
|
+
* None of these is in the vendored manifest, and none is in the upstream one either (formbuilder-agent,
|
|
460
|
+
* at the vendored sha and at HEAD alike), so re-vendoring would not add them and adding them here would
|
|
461
|
+
* make the gate ACCEPT a type with no renderer. `entityMenu` is deliberately absent: nothing on record
|
|
462
|
+
* says what replaced it, and a guessed replacement is worse than the bare finding.
|
|
463
|
+
*/
|
|
464
|
+
const RETIRED_ELEMENT_TYPES = Object.freeze({
|
|
465
|
+
timeTracking:
|
|
466
|
+
"a RETIRED type with no renderer: the front end replaced the v1 `timeTracking` wrapper with three " +
|
|
467
|
+
"native widgets — `timeTracked` (compact readout), `timeTracker` (the panel) and `timeLog` (history) — " +
|
|
468
|
+
"and deleted it in FE 5dd595d0a2, so a saved form still carrying it shows nothing in that slot " +
|
|
469
|
+
"(formbuilder-agent v2-component-manifest.ts). Replace it with the widget you meant.",
|
|
470
|
+
tags:
|
|
471
|
+
"not a current type. Its props — `hashPrefix`, `allowCreate`, `allowPickExisting` and a `dataSource` " +
|
|
472
|
+
"over Tags — are exactly those of `chips`, the element the platform directs free-entry tag fields to; " +
|
|
473
|
+
"author `chips` with the same props.",
|
|
474
|
+
});
|
|
475
|
+
|
|
455
476
|
/** Container types whose children are placed in GRID cells and carry their own column count. */
|
|
456
477
|
const GRID_PARENT_TYPES = new Set(["container", "tabsContainer", "accordionContainer", "stepsContainer"]);
|
|
457
478
|
|
|
@@ -736,6 +757,24 @@ export async function validateForm(input, { baseline = null, normalize = false }
|
|
|
736
757
|
|
|
737
758
|
const res = validateV2Draft(draft, v2ComponentManifest, baseDraft ? { baseline: baseDraft } : {});
|
|
738
759
|
|
|
760
|
+
// A project-registered component (`<app>.<name>`) is skipped by the core BY DESIGN — its type
|
|
761
|
+
// cannot be known to any manifest. Passing it without a word reads as "checked", which it was not.
|
|
762
|
+
const customTypes = [...new Set(
|
|
763
|
+
[...(Array.isArray(draft.schema) ? draft.schema : []), ...(Array.isArray(draft.mobileSchema) ? draft.mobileSchema : [])]
|
|
764
|
+
.filter((el) => el && typeof el === "object" && typeof el.type === "string" && el.type.includes("."))
|
|
765
|
+
.map((el) => el.type),
|
|
766
|
+
)];
|
|
767
|
+
if (customTypes.length) {
|
|
768
|
+
const many = customTypes.length > 1;
|
|
769
|
+
notes.push(
|
|
770
|
+
`${customTypes.map((t) => `\`${t}\``).join(", ")} ${many ? "are" : "is a"} project-registered ` +
|
|
771
|
+
`component${many ? "s" : ""} (\`<app>.<name>\`): the validator skips such types by design, so the ` +
|
|
772
|
+
`gate checked nothing about ${many ? "them" : "it"} — not ${many ? "their" : "its"} props, not ` +
|
|
773
|
+
`${many ? "their" : "its"} bindings. ${many ? "They render" : "It renders"} only on a tenant where ` +
|
|
774
|
+
"that project registered the component.",
|
|
775
|
+
);
|
|
776
|
+
}
|
|
777
|
+
|
|
739
778
|
// WHAT THE REPAIR SWALLOWED. Measured: a malformed `connections` entry is `invalid_layout`
|
|
740
779
|
// without --normalize and nothing at all with it — the pipeline discards the bad wiring and the
|
|
741
780
|
// author, who was told to run that flag for kit conformance, never learns it existed.
|
|
@@ -760,6 +799,15 @@ export async function validateForm(input, { baseline = null, normalize = false }
|
|
|
760
799
|
}
|
|
761
800
|
}
|
|
762
801
|
|
|
802
|
+
// RETIRED element types. The refusal is right — upstream removed them — but a bare
|
|
803
|
+
// "unknown_type: timeTracking" cannot be told from a typo, and the author is usually echoing the
|
|
804
|
+
// tenant's own form. Done AFTER the silenced-findings comparison above, which keys on `detail`.
|
|
805
|
+
for (const f of [...res.errors, ...res.warnings]) {
|
|
806
|
+
if (f.code === "unknown_type" && Object.prototype.hasOwnProperty.call(RETIRED_ELEMENT_TYPES, f.detail)) {
|
|
807
|
+
f.detail = `${f.detail} — ${RETIRED_ELEMENT_TYPES[f.detail]}`;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
|
|
763
811
|
// `styleIntent` and `theme` are AUTHORING props the manifest does not carry, so they read as
|
|
764
812
|
// `unknown_prop`. An author who deletes them to silence the gate ships a form with no styling —
|
|
765
813
|
// the exact failure rule 6 warns about. Measured: this alone failed 6 of the 7 shipped templates.
|
|
@@ -856,7 +904,9 @@ export async function validateForm(input, { baseline = null, normalize = false }
|
|
|
856
904
|
|
|
857
905
|
function findingLine(f) {
|
|
858
906
|
const where = f.elementId ? ` [${f.elementId}]` : "";
|
|
859
|
-
|
|
907
|
+
// The core's findings carry `detail`; a refusal (E200-E202) carries `message`.
|
|
908
|
+
const text = f.detail || f.message;
|
|
909
|
+
return ` ${f.code}${where}${text ? `: ${text}` : ""}`;
|
|
860
910
|
}
|
|
861
911
|
|
|
862
912
|
async function main(argv) {
|