linkedEntities = {
const entitiesWithLinks = [];
for await (const entityResult of dossierCore.getAllNodesForConnection(
{},
(currentPaging) => adminClient.client.getEntities({}, currentPaging)
)) {
const entity = entityResult.valueOrThrow();
const links = [];
for (const node of dossierCore.traverseEntity(adminSchema, [], entity)) {
if (
node.type === "fieldItem" &&
dossierCore.isEntityItemField(node.fieldSpec, node.value) &&
node.value
) {
links.push(node.value.id);
}
}
entitiesWithLinks.push({ id: entity.id, name: entity.info.name, links });
}
const mermaidLines = ["graph TD"];
entitiesWithLinks.slice(0, 30).forEach((fromEntity, fromIndex) => {
if (fromEntity.links.length === 0) return;
mermaidLines.push(`n${fromIndex}[${fromEntity.name}]`);
fromEntity.links.forEach((toId) => {
const toIndex = entitiesWithLinks.findIndex((it) => it.id === toId);
const toEntity = entitiesWithLinks[toIndex];
mermaidLines.push(`n${toIndex}[${toEntity.name}]`);
mermaidLines.push(`n${fromIndex} --> n${toIndex}`);
});
});
return mermaid`${mermaidLines.join("\n")}`;
}