@unified-product-graph/cloud-server 0.9.16 → 0.9.17
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/index.js +1 -142
- package/dist/index.js.map +1 -1
- package/dist/tools-manifest.json +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -998,148 +998,6 @@ function textError(s) {
|
|
|
998
998
|
return { content: [{ type: "text", text: s }], isError: true };
|
|
999
999
|
}
|
|
1000
1000
|
|
|
1001
|
-
// ../upg-mcp-tooling/dist/tree-assemble.js
|
|
1002
|
-
var DEFAULT_MAX_NODES = 400;
|
|
1003
|
-
function shell(reader, id, includeProps) {
|
|
1004
|
-
const n = reader.getNode(id);
|
|
1005
|
-
if (!n)
|
|
1006
|
-
return void 0;
|
|
1007
|
-
const node = { id: n.id, type: n.type, title: n.title, children: [] };
|
|
1008
|
-
if (n.status)
|
|
1009
|
-
node.status = n.status;
|
|
1010
|
-
if (includeProps && includeProps.length > 0 && n.properties) {
|
|
1011
|
-
const picked = {};
|
|
1012
|
-
for (const k of includeProps) {
|
|
1013
|
-
if (k in n.properties)
|
|
1014
|
-
picked[k] = n.properties[k];
|
|
1015
|
-
}
|
|
1016
|
-
if (Object.keys(picked).length > 0)
|
|
1017
|
-
node.properties = picked;
|
|
1018
|
-
}
|
|
1019
|
-
return node;
|
|
1020
|
-
}
|
|
1021
|
-
function childrenOf(reader, nodeId2, childTypes) {
|
|
1022
|
-
if (childTypes.length === 0)
|
|
1023
|
-
return [];
|
|
1024
|
-
const allow = new Set(childTypes);
|
|
1025
|
-
const out = [];
|
|
1026
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1027
|
-
for (const e of reader.getEdgesForNode(nodeId2)) {
|
|
1028
|
-
if (e.source !== nodeId2)
|
|
1029
|
-
continue;
|
|
1030
|
-
if (seen.has(e.target))
|
|
1031
|
-
continue;
|
|
1032
|
-
const t = reader.getNode(e.target);
|
|
1033
|
-
if (t && allow.has(t.type)) {
|
|
1034
|
-
out.push(e.target);
|
|
1035
|
-
seen.add(e.target);
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
|
-
return out;
|
|
1039
|
-
}
|
|
1040
|
-
function assembleTree(reader, pattern, opts) {
|
|
1041
|
-
const maxNodes = Math.min(Math.max(opts.max_nodes ?? DEFAULT_MAX_NODES, 1), 2e3);
|
|
1042
|
-
const maxDepth = Math.min(Math.max(opts.depth ?? pattern.natural_depth, 1), 12);
|
|
1043
|
-
const includeProps = opts.include_properties;
|
|
1044
|
-
const buildFrom = (rootIds, anchorType) => {
|
|
1045
|
-
const visited = /* @__PURE__ */ new Set();
|
|
1046
|
-
const gaps = [];
|
|
1047
|
-
let nodes = 0;
|
|
1048
|
-
let levels = 0;
|
|
1049
|
-
let truncated = false;
|
|
1050
|
-
let childCount = 0;
|
|
1051
|
-
const expand = (node, depth) => {
|
|
1052
|
-
if (depth > levels)
|
|
1053
|
-
levels = depth;
|
|
1054
|
-
const childTypes = pattern.child_map[node.type] ?? [];
|
|
1055
|
-
if (depth >= maxDepth) {
|
|
1056
|
-
if (childTypes.length > 0 && childrenOf(reader, node.id, childTypes).length > 0)
|
|
1057
|
-
truncated = true;
|
|
1058
|
-
return;
|
|
1059
|
-
}
|
|
1060
|
-
const childIds = childrenOf(reader, node.id, childTypes);
|
|
1061
|
-
if (childTypes.length > 0 && childIds.length === 0) {
|
|
1062
|
-
gaps.push({ node_id: node.id, type: node.type, title: node.title, missing: childTypes });
|
|
1063
|
-
return;
|
|
1064
|
-
}
|
|
1065
|
-
for (const cid of childIds) {
|
|
1066
|
-
if (visited.has(cid))
|
|
1067
|
-
continue;
|
|
1068
|
-
if (nodes >= maxNodes) {
|
|
1069
|
-
truncated = true;
|
|
1070
|
-
return;
|
|
1071
|
-
}
|
|
1072
|
-
const child = shell(reader, cid, includeProps);
|
|
1073
|
-
if (!child)
|
|
1074
|
-
continue;
|
|
1075
|
-
visited.add(cid);
|
|
1076
|
-
nodes++;
|
|
1077
|
-
childCount++;
|
|
1078
|
-
node.children.push(child);
|
|
1079
|
-
expand(child, depth + 1);
|
|
1080
|
-
}
|
|
1081
|
-
};
|
|
1082
|
-
const roots = [];
|
|
1083
|
-
for (const rid of rootIds) {
|
|
1084
|
-
if (visited.has(rid))
|
|
1085
|
-
continue;
|
|
1086
|
-
if (nodes >= maxNodes) {
|
|
1087
|
-
truncated = true;
|
|
1088
|
-
break;
|
|
1089
|
-
}
|
|
1090
|
-
const root = shell(reader, rid, includeProps);
|
|
1091
|
-
if (!root)
|
|
1092
|
-
continue;
|
|
1093
|
-
visited.add(rid);
|
|
1094
|
-
nodes++;
|
|
1095
|
-
roots.push(root);
|
|
1096
|
-
expand(root, 1);
|
|
1097
|
-
}
|
|
1098
|
-
return { anchorType, roots, nodes, levels, truncated, gaps, childCount };
|
|
1099
|
-
};
|
|
1100
|
-
if (opts.from_id) {
|
|
1101
|
-
const n = reader.getNode(opts.from_id);
|
|
1102
|
-
const anchorType = n?.type ?? pattern.anchor_type;
|
|
1103
|
-
const b = buildFrom([opts.from_id], anchorType);
|
|
1104
|
-
return {
|
|
1105
|
-
pattern: pattern.id,
|
|
1106
|
-
framework_id: pattern.framework_id,
|
|
1107
|
-
anchor_type: pattern.anchor_type,
|
|
1108
|
-
anchor_used: anchorType,
|
|
1109
|
-
roots: b.roots,
|
|
1110
|
-
stats: { nodes: b.nodes, levels: b.levels, truncated: b.truncated },
|
|
1111
|
-
gaps: b.gaps
|
|
1112
|
-
};
|
|
1113
|
-
}
|
|
1114
|
-
const candidates = [pattern.anchor_type, ...pattern.fallback_anchors];
|
|
1115
|
-
const idsOfType = (type) => reader.getAllNodes().filter((n) => n.type === type).map((n) => n.id);
|
|
1116
|
-
let chosen;
|
|
1117
|
-
for (const cand of candidates) {
|
|
1118
|
-
const rootIds = idsOfType(cand);
|
|
1119
|
-
if (rootIds.length === 0)
|
|
1120
|
-
continue;
|
|
1121
|
-
const b = buildFrom(rootIds, cand);
|
|
1122
|
-
chosen = b;
|
|
1123
|
-
if (b.childCount > 0)
|
|
1124
|
-
break;
|
|
1125
|
-
}
|
|
1126
|
-
if (!chosen) {
|
|
1127
|
-
chosen = { anchorType: pattern.anchor_type, roots: [], nodes: 0, levels: 0, truncated: false, gaps: [], childCount: 0 };
|
|
1128
|
-
}
|
|
1129
|
-
const result = {
|
|
1130
|
-
pattern: pattern.id,
|
|
1131
|
-
framework_id: pattern.framework_id,
|
|
1132
|
-
anchor_type: pattern.anchor_type,
|
|
1133
|
-
anchor_used: chosen.anchorType,
|
|
1134
|
-
roots: chosen.roots,
|
|
1135
|
-
stats: { nodes: chosen.nodes, levels: chosen.levels, truncated: chosen.truncated },
|
|
1136
|
-
gaps: chosen.gaps
|
|
1137
|
-
};
|
|
1138
|
-
if (chosen.anchorType !== pattern.anchor_type)
|
|
1139
|
-
result.anchor_resolved_from = pattern.anchor_type;
|
|
1140
|
-
return result;
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
1001
|
// ../upg-mcp-tooling/dist/catalog.js
|
|
1144
1002
|
import { UPG_EDGE_CATALOG, UPG_PROPERTY_SCHEMA, getDomainForType, getGuideForDomain, getLifecycleForType, getPropertySchema, resolveEntityType, UnknownEntityTypeError } from "@unified-product-graph/core";
|
|
1145
1003
|
function buildEntitySchema(rawType, options = {}) {
|
|
@@ -1476,6 +1334,7 @@ var getChanges = async (args, { store }) => {
|
|
|
1476
1334
|
|
|
1477
1335
|
// src/tools/tree.ts
|
|
1478
1336
|
import { getTreePattern, UPG_TREE_PATTERNS } from "@unified-product-graph/core";
|
|
1337
|
+
import { assembleTree } from "@unified-product-graph/sdk";
|
|
1479
1338
|
var getTree = async (args, { store }) => {
|
|
1480
1339
|
if (!args.product_id) return textError("Missing required parameter: product_id");
|
|
1481
1340
|
const productId = args.product_id;
|