suppa-mcp-2 1.44.4 → 1.45.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.
@@ -12,7 +12,8 @@ import { makeRequest, searchEntity, selectEntity, insertEntity, updateEntity, re
12
12
  import { existsSync } from "node:fs";
13
13
  import { dirname, join } from "node:path";
14
14
  import { fileURLToPath } from "node:url";
15
- import { ownProjection } from "../projection.js";
15
+ import { ownProjection, registerOwnProjections } from "../projection.js";
16
+ import { current as currentTenant } from "../tenants.js";
16
17
  import { makeFilter, jsonResponse, parseJsonParam, ACCESS_METADATA_KEYS, confirmRequired } from "../utils.js";
17
18
  /**
18
19
  * The bundled building-suppa-automations skill folder, from dist/tools/ or src/tools/ alike — what
@@ -74,6 +75,8 @@ const _RUN_FIELDS = ownProjection({
74
75
  triggerEntityName: true,
75
76
  error: true,
76
77
  });
78
+ registerOwnProjections(WORKFLOW_ENTITY, { _LIST_FIELDS, _GRAPH_FIELDS });
79
+ registerOwnProjections(EXECUTE_ENTITY, { _RUN_FIELDS });
77
80
  function isPlainObject(v) {
78
81
  return typeof v === "object" && v !== null && !Array.isArray(v);
79
82
  }
@@ -435,6 +438,11 @@ async function _scanWorkflows() {
435
438
  * fallback signal. Non-404 errors (e.g. 401) propagate.
436
439
  */
437
440
  export async function _fetchNodeCatalog() {
441
+ // A stand without the route answers 404 to every create / update / publish preview that asks; once is enough to
442
+ // know, for the rest of the process — a 404 the platform is certain to give is not asked for again.
443
+ const host = currentTenant().host;
444
+ if (_catalogAbsent.has(host))
445
+ return null;
438
446
  let cat;
439
447
  try {
440
448
  cat = await makeRequest("GET", NODE_CATALOG_PATH);
@@ -445,12 +453,19 @@ export async function _fetchNodeCatalog() {
445
453
  // must NOT be misread as "route absent" (and 401 must still surface).
446
454
  const msg = ex instanceof Error ? ex.message : String(ex);
447
455
  if (msg.startsWith("HTTP 404")) {
456
+ _catalogAbsent.add(host);
448
457
  return null;
449
458
  }
450
459
  throw ex;
451
460
  }
452
461
  return Array.isArray(cat) ? cat : null;
453
462
  }
463
+ /** Tenant hosts whose build has no /api/automation/nodes (answered 404), for this process. */
464
+ const _catalogAbsent = new Set();
465
+ /** Forget which stands lack the catalog — for tests that play several stands under one host. */
466
+ export function _forgetCatalogAbsence() {
467
+ _catalogAbsent.clear();
468
+ }
454
469
  /**
455
470
  * {node type: occurrences} across live graphs. Best-effort enrichment —
456
471
  * never raises (returns {} on any failure).
@@ -9,7 +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
+ import { ownProjection, registerOwnProjections } from "../projection.js";
13
13
  import { makeFilter, writeOutcome, stripHtml, jsonResponse, wrapHtml, unescapeUnicode, parseJsonParam, parseProjectionParam, notFoundAnswer, } from "../utils.js";
14
14
  // ---------------------------------------------------------------------------
15
15
  // Constants
@@ -74,6 +74,9 @@ export const BLOCK_FIELDS = ownProjection({
74
74
  children: "#expand_tree(10)",
75
75
  createdAt: true,
76
76
  });
77
+ registerOwnProjections(ENTITY_DOCS, { DOC_FIELDS });
78
+ registerOwnProjections(ENTITY_PAGES, { PAGE_FIELDS });
79
+ registerOwnProjections(ENTITY_PAGE_BLOCKS, { BLOCK_FIELDS });
77
80
  // ---------------------------------------------------------------------------
78
81
  // Block content helpers
79
82
  // ---------------------------------------------------------------------------
@@ -296,6 +299,7 @@ const DOC_DETAIL_FIELDS = ownProjection({
296
299
  ...DOC_FIELDS,
297
300
  pages: { id: true, title: true, status: true, parent: { id: true } },
298
301
  });
302
+ registerOwnProjections(ENTITY_DOCS, { DOC_DETAIL_FIELDS });
299
303
  /** Get a document by ID, including its pages. */
300
304
  export async function getDoc(docId, fieldsJson = null) {
301
305
  const fields = _projection(fieldsJson, DOC_DETAIL_FIELDS);
@@ -901,11 +901,14 @@ export async function searchRecords(entityName, filtersJson = "[]", fieldsJson =
901
901
  return ent.error;
902
902
  }
903
903
  }
904
+ // A read refused before sending already carries the validator's answer (httpClient postEntityRead).
905
+ const body = e?.parsedBody;
906
+ const known = body?.checkedBeforeSending === true && Array.isArray(body.invalidFields) ? body.invalidFields : undefined;
904
907
  const diag = await _selectDiagnostic(entityName, {
905
908
  fields: fields,
906
909
  conditions,
907
910
  orderBy: order,
908
- });
911
+ }, known);
909
912
  if (!diag) {
910
913
  throw e;
911
914
  }
@@ -942,13 +945,20 @@ export async function searchRecords(entityName, filtersJson = "[]", fieldsJson =
942
945
  * check itself fails — a diagnostic must never turn a legitimate empty result
943
946
  * into an error.
944
947
  */
945
- async function _selectDiagnostic(entityName, payload) {
948
+ async function _selectDiagnostic(entityName, payload,
949
+ /** The validator's answer when it is already in hand — no second request for it. */
950
+ known) {
946
951
  let result;
947
- try {
948
- result = await validateSelect(entityName, payload);
952
+ if (known !== undefined) {
953
+ result = { valid: known.length === 0, invalidFields: known };
949
954
  }
950
- catch {
951
- return null;
955
+ else {
956
+ try {
957
+ result = await validateSelect(entityName, payload);
958
+ }
959
+ catch {
960
+ return null;
961
+ }
952
962
  }
953
963
  if (!result || result.valid !== false) {
954
964
  return null;