@eventcatalog/core 4.12.2 → 5.0.0-beta.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.
Files changed (268) hide show
  1. package/LICENSE +226 -95
  2. package/NOTICE +30 -0
  3. package/README.md +3 -2
  4. package/dist/analytics/analytics.cjs +1 -1
  5. package/dist/analytics/analytics.js +2 -2
  6. package/dist/analytics/log-build.cjs +43 -16
  7. package/dist/analytics/log-build.d.cts +6 -5
  8. package/dist/analytics/log-build.d.ts +6 -5
  9. package/dist/analytics/log-build.js +4 -3
  10. package/dist/{chunk-U4YJSTGV.js → chunk-AYNZXUB5.js} +2 -10
  11. package/dist/{chunk-IVVM67LN.js → chunk-CR6AK5LR.js} +1 -1
  12. package/dist/{chunk-GTIC4R74.js → chunk-LR7AGRHN.js} +13 -16
  13. package/dist/chunk-TQLRG35T.js +203 -0
  14. package/dist/{chunk-WK4J6FP3.js → chunk-TWN43V4T.js} +1 -1
  15. package/dist/{chunk-ZW3MYAWF.js → chunk-WAIADKQE.js} +1 -1
  16. package/dist/{chunk-RPVA2SZY.js → chunk-ZHKEARLJ.js} +1 -1
  17. package/dist/constants.cjs +1 -1
  18. package/dist/constants.js +1 -1
  19. package/dist/eventcatalog.cjs +407 -291
  20. package/dist/eventcatalog.config.d.cts +2 -3
  21. package/dist/eventcatalog.config.d.ts +2 -3
  22. package/dist/eventcatalog.js +30 -93
  23. package/dist/federation/content-cache.d.cts +0 -5
  24. package/dist/federation/content-cache.d.ts +0 -5
  25. package/dist/federation/diagnostics.d.cts +0 -5
  26. package/dist/federation/diagnostics.d.ts +0 -5
  27. package/dist/federation/federate.cjs +0 -9
  28. package/dist/federation/federate.d.cts +0 -5
  29. package/dist/federation/federate.d.ts +0 -5
  30. package/dist/federation/federate.js +2 -3
  31. package/dist/federation/filesystem-source-provider.d.cts +0 -5
  32. package/dist/federation/filesystem-source-provider.d.ts +0 -5
  33. package/dist/federation/github-source-provider.d.cts +0 -5
  34. package/dist/federation/github-source-provider.d.ts +0 -5
  35. package/dist/federation/output-transaction.d.cts +0 -4
  36. package/dist/federation/output-transaction.d.ts +0 -4
  37. package/dist/federation/public-assets.d.cts +0 -5
  38. package/dist/federation/public-assets.d.ts +0 -5
  39. package/dist/federation/source-provider.d.cts +0 -5
  40. package/dist/federation/source-provider.d.ts +0 -5
  41. package/dist/federation/types.d.cts +0 -5
  42. package/dist/federation/types.d.ts +0 -5
  43. package/dist/generate.cjs +1 -1
  44. package/dist/generate.js +3 -3
  45. package/dist/license-C1y-56bb.d.cts +23 -0
  46. package/dist/license-C1y-56bb.d.ts +23 -0
  47. package/dist/runtime-dependencies/@eventcatalog__visualiser__layout.mjs +3 -0
  48. package/dist/runtime-dependencies/@modelcontextprotocol__ext-apps.mjs +3 -0
  49. package/dist/runtime-dependencies/@modelcontextprotocol__ext-apps__react.mjs +3 -0
  50. package/dist/runtime-dependencies/@modelcontextprotocol__ext-apps__server.mjs +3 -0
  51. package/dist/runtime-dependencies/@modelcontextprotocol__sdk__types.js.mjs +3 -0
  52. package/dist/runtime-dependencies/manifest.json +12 -1
  53. package/dist/runtime-dependencies/react-syntax-highlighter__dist__esm__languages__prism__graphql.mjs +3 -0
  54. package/dist/runtime-dependencies/react-syntax-highlighter__dist__esm__languages__prism__json.mjs +3 -0
  55. package/dist/runtime-dependencies/react-syntax-highlighter__dist__esm__languages__prism__markup.mjs +3 -0
  56. package/dist/runtime-dependencies/react-syntax-highlighter__dist__esm__languages__prism__protobuf.mjs +3 -0
  57. package/dist/runtime-dependencies/react-syntax-highlighter__dist__esm__languages__prism__yaml.mjs +3 -0
  58. package/dist/runtime-dependencies/react-syntax-highlighter__dist__esm__styles__prism__one-dark.mjs +3 -0
  59. package/dist/runtime-dependencies/react-syntax-highlighter__dist__esm__styles__prism__one-light.mjs +3 -0
  60. package/dist/utils/cli-logger.cjs +1 -1
  61. package/dist/utils/cli-logger.js +2 -2
  62. package/dist/utils/license-status.cjs +240 -0
  63. package/dist/utils/license-status.d.cts +28 -0
  64. package/dist/utils/license-status.d.ts +28 -0
  65. package/dist/utils/license-status.js +12 -0
  66. package/eventcatalog/astro.config.mjs +1 -1
  67. package/eventcatalog/integrations/eventcatalog-runtime.mjs +1 -1
  68. package/eventcatalog/src/components/ChatPanel/ChatPanel.tsx +29 -19
  69. package/eventcatalog/src/components/ChatPanel/OfflineReply.tsx +74 -0
  70. package/eventcatalog/src/components/FieldsExplorer/FieldFilters.tsx +24 -28
  71. package/eventcatalog/src/components/FieldsExplorer/FieldNodeGraph.tsx +16 -11
  72. package/eventcatalog/src/components/FieldsExplorer/FieldsExplorer.tsx +4 -218
  73. package/eventcatalog/src/components/FieldsExplorer/FieldsTable.tsx +27 -36
  74. package/eventcatalog/src/components/Header.astro +43 -58
  75. package/eventcatalog/src/components/Lists/PillListFlat.styles.css +17 -17
  76. package/eventcatalog/src/components/MDX/EntityMap/EntityMap.astro +1 -1
  77. package/eventcatalog/src/components/MDX/Flow/Flow.astro +4 -0
  78. package/eventcatalog/src/components/MDX/NodeGraph/AstroNodeGraph.tsx +14 -0
  79. package/eventcatalog/src/components/MDX/NodeGraph/NodeGraph.astro +49 -18
  80. package/eventcatalog/src/components/MDX/RemoteFile.astro +2 -24
  81. package/eventcatalog/src/components/SchemaExplorer/ApiAccessSection.tsx +59 -93
  82. package/eventcatalog/src/components/SchemaExplorer/ApiContentViewer.tsx +1 -32
  83. package/eventcatalog/src/components/SchemaExplorer/DiffViewer.tsx +20 -67
  84. package/eventcatalog/src/components/SchemaExplorer/SchemaContentViewer.tsx +2 -11
  85. package/eventcatalog/src/components/SchemaExplorer/SchemaDetailsPanel.tsx +11 -60
  86. package/eventcatalog/src/components/SchemaExplorer/SchemaExplorer.tsx +1 -3
  87. package/eventcatalog/src/components/SchemaExplorer/SchemaPageViewer.tsx +0 -3
  88. package/eventcatalog/src/components/SchemaExplorer/VersionHistoryModal.tsx +2 -9
  89. package/eventcatalog/src/components/SchemaExplorer/parse-schema.ts +46 -0
  90. package/eventcatalog/src/components/SchemaExplorer/utils.ts +11 -0
  91. package/eventcatalog/src/components/Settings/AssistantSettingsForm.tsx +2 -9
  92. package/eventcatalog/src/components/Settings/LicenseSettings.tsx +288 -0
  93. package/eventcatalog/src/components/Settings/LlmAccessSettingsForm.tsx +3 -19
  94. package/eventcatalog/src/components/Settings/McpSettingsForm.tsx +85 -30
  95. package/eventcatalog/src/components/Settings/SettingsShared.tsx +7 -75
  96. package/eventcatalog/src/components/SideNav/CustomDocsNav.astro +2 -2
  97. package/eventcatalog/src/components/TrialBadge.astro +82 -0
  98. package/eventcatalog/src/content.config.ts +9 -90
  99. package/eventcatalog/src/{enterprise → features}/ai/chat-api.ts +22 -34
  100. package/eventcatalog/src/{enterprise → features}/analytics/adapters/ga4.ts +0 -5
  101. package/eventcatalog/src/{enterprise → features}/analytics/adapters/gtm.ts +0 -5
  102. package/eventcatalog/src/{enterprise → features}/analytics/adapters/posthog.ts +0 -5
  103. package/eventcatalog/src/{enterprise → features}/analytics/components/AnalyticsHead.astro +2 -4
  104. package/eventcatalog/src/{enterprise → features}/analytics/components/AnalyticsTracker.astro +2 -4
  105. package/eventcatalog/src/{enterprise → features}/analytics/tracker.ts +0 -5
  106. package/eventcatalog/src/{enterprise → features}/api/catalog.ts +0 -5
  107. package/eventcatalog/src/{enterprise → features}/auth/[...auth].ts +0 -5
  108. package/eventcatalog/src/{enterprise → features}/auth/middleware/middleware-auth.ts +0 -5
  109. package/eventcatalog/src/{enterprise → features}/auth/middleware/middleware.ts +0 -5
  110. package/eventcatalog/src/{enterprise → features}/collections/custom-pages.ts +0 -5
  111. package/eventcatalog/src/{enterprise → features}/collections/index.ts +0 -5
  112. package/eventcatalog/src/{enterprise → features}/collections/resource-docs.ts +0 -5
  113. package/eventcatalog/src/{enterprise → features}/custom-documentation/collection.ts +0 -5
  114. package/eventcatalog/src/features/custom-documentation/components/CustomDocsNav/CustomDocsNav.astro +9 -0
  115. package/eventcatalog/src/{enterprise → features}/custom-documentation/components/CustomDocsNav/CustomDocsNavWrapper.tsx +0 -5
  116. package/eventcatalog/src/{enterprise → features}/custom-documentation/components/CustomDocsNav/components/NestedItem.tsx +1 -6
  117. package/eventcatalog/src/{enterprise → features}/custom-documentation/components/CustomDocsNav/components/NoResultsFound.tsx +0 -5
  118. package/eventcatalog/src/{enterprise → features}/custom-documentation/components/CustomDocsNav/index.tsx +1 -6
  119. package/eventcatalog/src/{enterprise → features}/custom-documentation/components/CustomDocsNav/types.ts +0 -5
  120. package/eventcatalog/src/{enterprise/custom-documentation/pages/docs/custom/index.astro → features/custom-documentation/components/CustomDocumentationPage.astro} +5 -5
  121. package/eventcatalog/src/{enterprise → features}/custom-documentation/utils/badge-styles.ts +0 -5
  122. package/eventcatalog/src/{enterprise → features}/custom-documentation/utils/custom-docs.ts +1 -6
  123. package/eventcatalog/src/{enterprise → features}/custom-documentation/utils/docs-search.ts +0 -5
  124. package/eventcatalog/src/{enterprise → features}/custom-pages/routes.ts +0 -5
  125. package/eventcatalog/src/{enterprise → features}/directory/user-team-directory.ts +0 -5
  126. package/eventcatalog/src/{enterprise → features}/fields/field-extractor.ts +0 -5
  127. package/eventcatalog/src/{enterprise → features}/fields/field-indexer.ts +0 -5
  128. package/eventcatalog/src/{enterprise → features}/fields/fields-db.ts +0 -5
  129. package/eventcatalog/src/{enterprise → features}/fields/pages/api/fields.ts +1 -6
  130. package/eventcatalog/src/{enterprise → features}/fields/pages/fields.astro +1 -2
  131. package/eventcatalog/src/{enterprise → features}/integrations/eventcatalog-features.ts +17 -75
  132. package/eventcatalog/src/features/mcp/apps/architecture-diagram/links.ts +59 -0
  133. package/eventcatalog/src/features/mcp/apps/architecture-diagram/node-chat.tsx +299 -0
  134. package/eventcatalog/src/features/mcp/apps/architecture-diagram/shared.ts +14 -0
  135. package/eventcatalog/src/features/mcp/apps/architecture-diagram/view.tsx +454 -0
  136. package/eventcatalog/src/features/mcp/apps/generated/viewer.html +432 -0
  137. package/eventcatalog/src/features/mcp/apps/mermaid-stub.ts +10 -0
  138. package/eventcatalog/src/features/mcp/apps/schema-viewer/schema-code.tsx +65 -0
  139. package/eventcatalog/src/features/mcp/apps/schema-viewer/shared.ts +23 -0
  140. package/eventcatalog/src/features/mcp/apps/schema-viewer/view.tsx +170 -0
  141. package/eventcatalog/src/features/mcp/apps/shared/app-view.tsx +98 -0
  142. package/eventcatalog/src/features/mcp/apps/shared/resource-types.ts +15 -0
  143. package/eventcatalog/src/features/mcp/apps/viewer/shared.ts +24 -0
  144. package/eventcatalog/src/features/mcp/apps/viewer/styles.css +25 -0
  145. package/eventcatalog/src/features/mcp/apps/viewer/view.tsx +59 -0
  146. package/eventcatalog/src/features/mcp/mcp-app-icons.ts +63 -0
  147. package/eventcatalog/src/features/mcp/mcp-apps.ts +160 -0
  148. package/eventcatalog/src/{enterprise → features}/mcp/mcp-auth.ts +0 -5
  149. package/eventcatalog/src/{enterprise → features}/mcp/mcp-scope.ts +7 -7
  150. package/eventcatalog/src/{enterprise → features}/mcp/mcp-scoped-tools.ts +47 -40
  151. package/eventcatalog/src/{enterprise → features}/mcp/mcp-server.ts +347 -34
  152. package/eventcatalog/src/{enterprise → features}/mcp/oauth-protected-resource.ts +0 -5
  153. package/eventcatalog/src/features/mcp/schema-viewer.ts +24 -0
  154. package/eventcatalog/src/{enterprise → features}/tools/catalog-tools.ts +133 -102
  155. package/eventcatalog/src/features/tools/index.ts +5 -0
  156. package/eventcatalog/src/{enterprise → features}/visualizer-layout/reset.ts +0 -5
  157. package/eventcatalog/src/{enterprise → features}/visualizer-layout/save.ts +0 -5
  158. package/eventcatalog/src/layouts/BaseLayout.astro +2 -2
  159. package/eventcatalog/src/layouts/Footer.astro +31 -39
  160. package/eventcatalog/src/layouts/SettingsLayout.astro +6 -6
  161. package/eventcatalog/src/layouts/VerticalSideBarLayout.astro +7 -37
  162. package/eventcatalog/src/{enterprise → pages}/api/schemas/[collection]/[id]/[version]/index.ts +0 -22
  163. package/eventcatalog/src/{enterprise → pages}/api/schemas/services/[id]/[version]/[specification]/index.ts +0 -19
  164. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/[docType]/[docId]/[docVersion]/_index.data.ts +2 -6
  165. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/[docType]/[docId]/[docVersion]/index.astro +1 -5
  166. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/[docType]/[docId]/_index.data.ts +2 -6
  167. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/[docType]/[docId]/index.astro +1 -5
  168. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/[docType]/[docId].md.ts +2 -6
  169. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/[docType]/[docId].mdx.ts +2 -6
  170. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/index.astro +9 -5
  171. package/eventcatalog/src/pages/docs/custom/[...path]/index.astro +12 -0
  172. package/eventcatalog/src/{enterprise/custom-documentation/pages/docs/custom/root-index.astro → pages/docs/custom/index.astro} +1 -23
  173. package/eventcatalog/src/pages/docs/llm/llms-full.txt.ts +4 -9
  174. package/eventcatalog/src/pages/docs/llm/llms.txt.ts +4 -4
  175. package/eventcatalog/src/pages/docs/llm/schemas.txt.ts +0 -11
  176. package/eventcatalog/src/pages/docs/services/[id]/[docType]/[docId]/index.astro +2 -2
  177. package/eventcatalog/src/pages/index.astro +2 -2
  178. package/eventcatalog/src/pages/schemas/[type]/[id]/[version]/index.astro +0 -3
  179. package/eventcatalog/src/pages/schemas/explorer/index.astro +1 -4
  180. package/eventcatalog/src/pages/settings/assistant.astro +2 -4
  181. package/eventcatalog/src/pages/settings/license.astro +18 -0
  182. package/eventcatalog/src/pages/settings/llm-access.astro +1 -4
  183. package/eventcatalog/src/pages/settings/mcp.astro +33 -4
  184. package/eventcatalog/src/pages/visualiser/[type]/[id]/[version]/_index.data.ts +1 -2
  185. package/eventcatalog/src/pages/visualiser/[type]/[id]/[version]/data/index.astro +2 -45
  186. package/eventcatalog/src/pages/visualiser/[type]/[id]/[version]/entity-map/index.astro +1 -1
  187. package/eventcatalog/src/pages/visualiser/[type]/[id]/[version].mermaid.ts +7 -109
  188. package/eventcatalog/src/pages/visualiser/_mermaid-route.ts +78 -0
  189. package/eventcatalog/src/pages/visualiser/domains/[id]/[version]/_index.data.ts +44 -0
  190. package/eventcatalog/src/pages/visualiser/domains/[id]/[version]/entity-map/index.astro +1 -1
  191. package/eventcatalog/src/pages/visualiser/domains/[id]/[version]/index.astro +56 -0
  192. package/eventcatalog/src/pages/visualiser/domains/[id]/[version]/systems-context/index.astro +3 -40
  193. package/eventcatalog/src/pages/visualiser/domains/[id]/[version].mermaid.ts +20 -0
  194. package/eventcatalog/src/pages/visualiser/systems/[id]/[version]/_index.data.ts +29 -0
  195. package/eventcatalog/src/pages/visualiser/systems/[id]/[version]/context/index.astro +3 -38
  196. package/eventcatalog/src/pages/visualiser/systems/[id]/[version]/index.astro +56 -0
  197. package/eventcatalog/src/pages/visualiser/systems/[id]/[version].mermaid.ts +20 -0
  198. package/eventcatalog/src/stores/sidebar-store/builders/agent.ts +1 -1
  199. package/eventcatalog/src/stores/sidebar-store/builders/container.ts +1 -1
  200. package/eventcatalog/src/stores/sidebar-store/builders/data-product.ts +1 -1
  201. package/eventcatalog/src/stores/sidebar-store/builders/domain.ts +7 -32
  202. package/eventcatalog/src/stores/sidebar-store/builders/entity.ts +1 -1
  203. package/eventcatalog/src/stores/sidebar-store/builders/message.ts +1 -1
  204. package/eventcatalog/src/stores/sidebar-store/builders/service.ts +2 -8
  205. package/eventcatalog/src/stores/sidebar-store/builders/system.ts +2 -12
  206. package/eventcatalog/src/stores/sidebar-store/custom-sidebar.ts +0 -10
  207. package/eventcatalog/src/stores/sidebar-store/state.ts +4 -6
  208. package/eventcatalog/src/styles/theme.css +22 -18
  209. package/eventcatalog/src/styles/themes/forest.css +8 -8
  210. package/eventcatalog/src/styles/themes/ocean.css +8 -8
  211. package/eventcatalog/src/styles/themes/sapphire.css +8 -8
  212. package/eventcatalog/src/styles/themes/sunset.css +8 -8
  213. package/eventcatalog/src/utils/clipboard.ts +4 -4
  214. package/eventcatalog/src/utils/collections/flow-step-schema.ts +117 -0
  215. package/eventcatalog/src/utils/collections/pointer-schema.ts +7 -0
  216. package/eventcatalog/src/utils/collections/resource-docs.ts +677 -14
  217. package/eventcatalog/src/utils/collections/schema-loader.ts +0 -5
  218. package/eventcatalog/src/utils/feature.ts +14 -23
  219. package/eventcatalog/src/utils/license.ts +114 -0
  220. package/eventcatalog/src/utils/node-graphs/architecture-diagram-types.ts +32 -0
  221. package/eventcatalog/src/utils/node-graphs/architecture-diagram.ts +84 -0
  222. package/eventcatalog/src/utils/node-graphs/catalog-force-graph.ts +1 -0
  223. package/eventcatalog/src/utils/node-graphs/channel-node-graph.ts +4 -25
  224. package/eventcatalog/src/utils/node-graphs/container-node-graph.ts +12 -39
  225. package/eventcatalog/src/utils/node-graphs/data-products-node-graph.ts +11 -27
  226. package/eventcatalog/src/utils/node-graphs/domain-levels-node-graph.ts +679 -0
  227. package/eventcatalog/src/utils/node-graphs/domains-node-graph.ts +3 -20
  228. package/eventcatalog/src/utils/node-graphs/export-mermaid.ts +62 -4
  229. package/eventcatalog/src/utils/node-graphs/field-node-graph.ts +8 -23
  230. package/eventcatalog/src/utils/node-graphs/flow-lanes.ts +119 -0
  231. package/eventcatalog/src/utils/node-graphs/flows-node-graph.ts +153 -45
  232. package/eventcatalog/src/utils/node-graphs/layout-node-graph.ts +28 -0
  233. package/eventcatalog/src/utils/node-graphs/layout-persistence.ts +3 -3
  234. package/eventcatalog/src/utils/node-graphs/message-node-graph.ts +16 -34
  235. package/eventcatalog/src/utils/node-graphs/services-node-graph.ts +11 -25
  236. package/eventcatalog/src/utils/node-graphs/system-context-node-graph.ts +18 -54
  237. package/eventcatalog/src/utils/node-graphs/system-levels-node-graph.ts +59 -0
  238. package/eventcatalog/src/utils/node-graphs/systems-node-graph.ts +20 -80
  239. package/eventcatalog/src/utils/node-graphs/utils/utils.ts +1 -78
  240. package/eventcatalog/src/utils/trial.ts +36 -0
  241. package/eventcatalog/tsconfig.json +1 -1
  242. package/package.json +11 -11
  243. package/dist/chunk-FV56YFM4.js +0 -7
  244. package/dist/federation/entitlement.cjs +0 -31
  245. package/dist/federation/entitlement.d.cts +0 -12
  246. package/dist/federation/entitlement.d.ts +0 -12
  247. package/dist/federation/entitlement.js +0 -6
  248. package/dist/runtime-dependencies/dagre.mjs +0 -3
  249. package/eventcatalog/src/components/Settings/BillingSettingsForm.tsx +0 -265
  250. package/eventcatalog/src/enterprise/LICENSE +0 -57
  251. package/eventcatalog/src/enterprise/README.md +0 -5
  252. package/eventcatalog/src/enterprise/collections/resource-docs-utils.ts +0 -691
  253. package/eventcatalog/src/enterprise/custom-documentation/components/CustomDocsNav/CustomDocsNav.astro +0 -9
  254. package/eventcatalog/src/enterprise/custom-documentation/pages/docs/custom/[...path]/index.astro +0 -18
  255. package/eventcatalog/src/enterprise/custom-documentation/pages/docs/custom/feature.astro +0 -171
  256. package/eventcatalog/src/enterprise/feature.ts +0 -75
  257. package/eventcatalog/src/enterprise/tools/index.ts +0 -10
  258. package/eventcatalog/src/hooks/eventcatalog-visualizer.ts +0 -126
  259. package/eventcatalog/src/pages/settings/billing.astro +0 -17
  260. package/eventcatalog/src/pages/visualiser/domain-integrations/index.astro +0 -26
  261. package/eventcatalog/src/types/mcp-modules.d.ts +0 -67
  262. package/eventcatalog/src/utils/node-graphs/domains-canvas.ts +0 -261
  263. package/eventcatalog/src/utils/node-graphs/export-node-graph.ts +0 -91
  264. /package/eventcatalog/src/{enterprise → features}/auth/error.astro +0 -0
  265. /package/eventcatalog/src/{enterprise → features}/auth/login.astro +0 -0
  266. /package/eventcatalog/src/{enterprise → features}/auth/unauthorized.astro +0 -0
  267. /package/eventcatalog/src/{enterprise/custom-documentation/pages → pages}/docs/custom/[...path]/_index.data.ts +0 -0
  268. /package/eventcatalog/src/{enterprise/custom-documentation/pages → pages}/docs/custom/[...path].mdx.ts +0 -0
@@ -1,25 +1,20 @@
1
1
  import { getCollection, type CollectionEntry } from 'astro:content';
2
2
  import {
3
- createDagreGraph,
4
- calculatedNodes,
5
- DEFAULT_NODE_WIDTH,
6
- DEFAULT_NODE_HEIGHT,
7
3
  buildContextMenuForResource,
8
4
  buildContextMenuForService,
9
- layoutDagreGraph,
5
+ buildContextMenuForSystem,
10
6
  } from '@utils/node-graphs/utils/utils';
7
+ import { layoutNodeGraph } from '@utils/node-graphs/layout-node-graph';
11
8
  import { MarkerType } from '@xyflow/react';
12
9
  import type { Node as NodeType } from '@xyflow/react';
13
10
  import { createVersionedMap, findInMap } from '@utils/collections/util';
14
-
15
- type DagreGraph = any;
11
+ import { createLaneIndex, type LaneIndex } from '@utils/node-graphs/flow-lanes';
16
12
 
17
13
  interface Props {
18
14
  id: string;
19
15
  version: string;
20
- defaultFlow?: DagreGraph;
21
16
  mode?: 'simple' | 'full';
22
- renderAllEdges?: boolean;
17
+ layout?: boolean;
23
18
  }
24
19
 
25
20
  interface Maps {
@@ -29,6 +24,9 @@ interface Maps {
29
24
  flowMap: Map<string, any[]>;
30
25
  containerMap: Map<string, any[]>;
31
26
  dataProductMap: Map<string, any[]>;
27
+ systemMap: Map<string, any[]>;
28
+ channelMap: Map<string, any[]>;
29
+ laneIndex: LaneIndex;
32
30
  }
33
31
 
34
32
  const getServiceNode = (step: any, serviceMap: Map<string, any[]>) => {
@@ -78,6 +76,25 @@ const getDataProductNode = (step: any, dataProductMap: Map<string, any[]>) => {
78
76
  };
79
77
  };
80
78
 
79
+ const getSystemNode = (step: any, systemMap: Map<string, any[]>) => {
80
+ const pointer = step.systems || step.system;
81
+ const system = findInMap(systemMap, pointer.id, pointer.version);
82
+ return {
83
+ ...step,
84
+ type: system ? 'systems' : 'step',
85
+ system,
86
+ };
87
+ };
88
+
89
+ const getChannelNode = (step: any, channelMap: Map<string, any[]>) => {
90
+ const channel = findInMap(channelMap, step.channel.id, step.channel.version);
91
+ return {
92
+ ...step,
93
+ type: channel ? 'channels' : 'step',
94
+ channel,
95
+ };
96
+ };
97
+
81
98
  const getMessageNode = (step: any, messageMap: Map<string, any[]>) => {
82
99
  const message = findInMap(messageMap, step.message.id, step.message.version);
83
100
  return {
@@ -87,6 +104,68 @@ const getMessageNode = (step: any, messageMap: Map<string, any[]>) => {
87
104
  };
88
105
  };
89
106
 
107
+ // The whole graph is sent to the browser, so a step's resource is in its node's
108
+ // data once (e.g. `data.service`), without what's only needed to build the
109
+ // catalog (its markdown body, file path, ...), and the step is just the step
110
+ const RESOURCE_KEYS = ['message', 'agent', 'service', 'flow', 'container', 'dataProduct', 'system', 'channel'];
111
+ const resourceForNode = (entry: any) => {
112
+ // Only what the nodes read: its id, collection and frontmatter (nested, as
113
+ // e.g. the sub-flow node reads `flow.data`, and spread on top)
114
+ const { id, collection, data } = entry;
115
+ return { id, collection, data, ...data };
116
+ };
117
+ const stepForNode = (step: any) => {
118
+ const own = { ...step, ...step.data };
119
+ RESOURCE_KEYS.forEach((key) => delete own[key]);
120
+ return { ...own, title: titleOf(step) };
121
+ };
122
+
123
+ // A step without a title is named after what it points at (or its id). A
124
+ // custom step is labelled with its own title first, as its node is.
125
+ const titleOf = (step: any): string => {
126
+ if (step.custom?.title) return step.custom.title;
127
+ if (step.title) return step.title;
128
+ const resource = RESOURCE_KEYS.map((key) => step[key]).find((entry) => entry?.data);
129
+ return resource?.data.name || resource?.data.id || step.actor?.name || step.externalSystem?.name || String(step.id);
130
+ };
131
+
132
+ // Mistakes in a flow (a typo in a next step, a resource that was renamed)
133
+ // would otherwise just drop an arrow or draw a plain box, so they're logged,
134
+ // once each (a flow is drawn on several pages). Once per process on purpose:
135
+ // in `astro dev` a problem that's fixed and then made again isn't logged again
136
+ // until the server restarts, which is fine for a warning.
137
+ const warned = new Set<string>();
138
+ const warnOnce = (flow: any, problem: string) => {
139
+ const message = `[flows] Flow "${flow.data.id}" (${flow.data.version}): ${problem}`;
140
+ if (warned.has(message)) return;
141
+ warned.add(message);
142
+ console.warn(message);
143
+ };
144
+
145
+ // The keys a step points at a resource with, as authors write them
146
+ const POINTER_KEYS: Record<string, string> = {
147
+ message: 'message',
148
+ agent: 'agent',
149
+ service: 'service',
150
+ systems: 'system',
151
+ system: 'system',
152
+ channel: 'channel',
153
+ flow: 'flow',
154
+ container: 'container',
155
+ dataProduct: 'data product',
156
+ };
157
+ const warnAboutMissingResource = (flow: any, step: any, hydrated: any) => {
158
+ for (const [key, kind] of Object.entries(POINTER_KEYS)) {
159
+ const pointer = step[key];
160
+ const resourceKey = key === 'systems' ? 'system' : key;
161
+ if (!pointer || hydrated[resourceKey]) continue;
162
+ warnOnce(
163
+ flow,
164
+ `step "${step.id}" points at ${kind} "${pointer.id}" (${pointer.version ?? 'latest'}), which is not in the catalog, so it is shown as a plain step.`
165
+ );
166
+ }
167
+ };
168
+
90
169
  // Rewrite every id/source/target in a precomputed sub-flow graph with a
91
170
  // namespace prefix so inlined copies don't collide with the parent. Nested
92
171
  // `data.expandedNodes` / `data.expandedEdges` payloads are rewritten too so
@@ -129,9 +208,11 @@ const buildFlowGraphInternal = (
129
208
  const hydratedSteps = steps.map((step: any) => {
130
209
  if (step.agent) return getAgentNode(step, maps.agentMap);
131
210
  if (step.service) return getServiceNode(step, maps.serviceMap);
211
+ if (step.systems || step.system) return getSystemNode(step, maps.systemMap);
132
212
  if (step.flow) return getFlowNode(step, maps.flowMap);
133
213
  if (step.container) return getContainerNode(step, maps.containerMap);
134
214
  if (step.dataProduct) return getDataProductNode(step, maps.dataProductMap);
215
+ if (step.channel) return getChannelNode(step, maps.channelMap);
135
216
  if (step.message) return getMessageNode(step, maps.messageMap);
136
217
  if (step.actor) return { ...step, type: 'actor', actor: step.actor };
137
218
  if (step.custom) return { ...step, type: 'custom', custom: step.custom };
@@ -139,23 +220,26 @@ const buildFlowGraphInternal = (
139
220
  return { ...step, type: 'step' };
140
221
  });
141
222
 
142
- hydratedSteps.forEach((step: any, index: number) => {
223
+ steps.forEach((step: any, index: number) => warnAboutMissingResource(flow, step, hydratedSteps[index]));
224
+ const stepIds = new Set(steps.map((step: any) => String(step.id)));
225
+
226
+ hydratedSteps.forEach((step: any) => {
143
227
  const node: NodeType = {
144
228
  id: stepNodeId(step.id),
145
229
  sourcePosition: 'right',
146
230
  targetPosition: 'left',
147
231
  data: {
148
232
  mode,
149
- step: { ...step, ...step.data },
233
+ step: stepForNode(step),
150
234
  showTarget: true,
151
235
  showSource: true,
152
236
  },
153
- position: { x: 250, y: index * 150 },
237
+ position: { x: 0, y: 0 },
154
238
  type: step.type,
155
239
  } as NodeType;
156
240
 
157
241
  if (step.agent) {
158
- node.data.agent = { ...step.agent, ...step.agent.data };
242
+ node.data.agent = resourceForNode(step.agent);
159
243
  node.data.contextMenu = buildContextMenuForResource({
160
244
  collection: 'agents',
161
245
  id: step.agent.data.id,
@@ -163,7 +247,7 @@ const buildFlowGraphInternal = (
163
247
  });
164
248
  }
165
249
  if (step.service) {
166
- node.data.service = { ...step.service, ...step.service.data };
250
+ node.data.service = resourceForNode(step.service);
167
251
  node.data.contextMenu = buildContextMenuForService({
168
252
  id: step.service.data.id,
169
253
  version: step.service.data.version,
@@ -171,8 +255,15 @@ const buildFlowGraphInternal = (
171
255
  repository: step.service.data.repository,
172
256
  });
173
257
  }
258
+ if (step.system?.data) {
259
+ node.data.system = resourceForNode(step.system);
260
+ node.data.contextMenu = buildContextMenuForSystem({
261
+ id: step.system.data.id,
262
+ version: step.system.data.version,
263
+ });
264
+ }
174
265
  if (step.flow) {
175
- node.data.flow = { ...step.flow, ...step.flow.data };
266
+ node.data.flow = resourceForNode(step.flow);
176
267
  node.data.contextMenu = buildContextMenuForResource({
177
268
  collection: 'flows',
178
269
  id: step.flow.data.id,
@@ -195,7 +286,7 @@ const buildFlowGraphInternal = (
195
286
  }
196
287
  }
197
288
  if (step.message) {
198
- node.data.message = { ...step.message, ...step.message.data };
289
+ node.data.message = resourceForNode(step.message);
199
290
  node.data.contextMenu = buildContextMenuForResource({
200
291
  collection: step.message.collection,
201
292
  id: step.message.data.id,
@@ -204,15 +295,23 @@ const buildFlowGraphInternal = (
204
295
  }
205
296
  if (step.container?.data) {
206
297
  node.data.data = { ...step.container.data };
207
- node.data.container = { ...step.container, ...step.container.data };
298
+ node.data.container = resourceForNode(step.container);
208
299
  node.data.contextMenu = buildContextMenuForResource({
209
300
  collection: 'containers',
210
301
  id: step.container.data.id,
211
302
  version: step.container.data.version,
212
303
  });
213
304
  }
305
+ if (step.channel?.data) {
306
+ node.data.channel = resourceForNode(step.channel);
307
+ node.data.contextMenu = buildContextMenuForResource({
308
+ collection: 'channels',
309
+ id: step.channel.data.id,
310
+ version: step.channel.data.version,
311
+ });
312
+ }
214
313
  if (step.dataProduct?.data) {
215
- node.data.dataProduct = { ...step.dataProduct, ...step.dataProduct.data };
314
+ node.data.dataProduct = resourceForNode(step.dataProduct);
216
315
  node.data.contextMenu = buildContextMenuForResource({
217
316
  collection: 'data-products',
218
317
  id: step.dataProduct.data.id,
@@ -225,6 +324,17 @@ const buildFlowGraphInternal = (
225
324
  }
226
325
  if (step.externalSystem) node.data.externalSystem = { ...step.externalSystem, ...step.externalSystem.data };
227
326
  if (step.custom) node.data.custom = { ...step.custom, ...step.custom.data };
327
+
328
+ // Which domain, system and team the step belongs to, for swimlanes
329
+ const resource = step.agent || step.service || step.container || step.dataProduct;
330
+ const lanes =
331
+ step.actor || step.externalSystem
332
+ ? { external: true }
333
+ : step.system?.data
334
+ ? maps.laneIndex.lanesForSystem(step.system)
335
+ : resource && maps.laneIndex.lanesFor(resource);
336
+ if (lanes) node.data.lanes = lanes;
337
+
228
338
  nodes.push(node);
229
339
  });
230
340
 
@@ -247,6 +357,10 @@ const buildFlowGraphInternal = (
247
357
  });
248
358
 
249
359
  paths.forEach((path: any) => {
360
+ if (!stepIds.has(String(path.id))) {
361
+ warnOnce(flow, `step "${step.id}" leads to step "${path.id}", but the flow has no step with that id.`);
362
+ return;
363
+ }
250
364
  edges.push({
251
365
  id: `step-${step.id}-step-${path.id}`,
252
366
  source: stepNodeId(step.id),
@@ -271,19 +385,23 @@ const buildFlowGraphInternal = (
271
385
  return { nodes, edges };
272
386
  };
273
387
 
274
- export const getNodesAndEdges = async ({ id, defaultFlow, version, mode = 'simple', renderAllEdges = false }: Props) => {
275
- const graph = defaultFlow || createDagreGraph({ ranksep: 360, nodesep: 200 });
276
-
277
- const [flows, events, commands, queries, agents, services, containers, dataProducts] = await Promise.all([
278
- getCollection('flows'),
279
- getCollection('events'),
280
- getCollection('commands'),
281
- getCollection('queries'),
282
- getCollection('agents'),
283
- getCollection('services'),
284
- getCollection('containers'),
285
- getCollection('data-products'),
286
- ]);
388
+ export const getNodesAndEdges = async ({ id, version, mode = 'simple', layout = true }: Props) => {
389
+ const [flows, events, commands, queries, agents, services, containers, dataProducts, domains, systems, channels, teams, users] =
390
+ await Promise.all([
391
+ getCollection('flows'),
392
+ getCollection('events'),
393
+ getCollection('commands'),
394
+ getCollection('queries'),
395
+ getCollection('agents'),
396
+ getCollection('services'),
397
+ getCollection('containers'),
398
+ getCollection('data-products'),
399
+ getCollection('domains'),
400
+ getCollection('systems'),
401
+ getCollection('channels'),
402
+ getCollection('teams'),
403
+ getCollection('users'),
404
+ ]);
287
405
 
288
406
  const flow = flows.find((flow) => flow.data.id === id && flow.data.version === version);
289
407
 
@@ -302,6 +420,9 @@ export const getNodesAndEdges = async ({ id, defaultFlow, version, mode = 'simpl
302
420
  flowMap: createVersionedMap(flows),
303
421
  containerMap: createVersionedMap(containers),
304
422
  dataProductMap: createVersionedMap(dataProducts),
423
+ systemMap: createVersionedMap(systems),
424
+ channelMap: createVersionedMap(channels),
425
+ laneIndex: createLaneIndex({ domains, systems, teams, users }),
305
426
  };
306
427
 
307
428
  const subFlowCache = new Map<string, { nodes: any[]; edges: any[] }>();
@@ -313,18 +434,5 @@ export const getNodesAndEdges = async ({ id, defaultFlow, version, mode = 'simpl
313
434
  new Set([`${flow.data.id}@${flow.data.version}`])
314
435
  );
315
436
 
316
- nodes.forEach((node: any) => {
317
- graph.setNode(node.id, { width: DEFAULT_NODE_WIDTH, height: DEFAULT_NODE_HEIGHT });
318
- });
319
-
320
- edges.forEach((edge: any) => {
321
- graph.setEdge(edge.source, edge.target);
322
- });
323
-
324
- layoutDagreGraph(graph);
325
-
326
- return {
327
- nodes: calculatedNodes(graph, nodes),
328
- edges: edges,
329
- };
437
+ return layout ? await layoutNodeGraph({ nodes, edges }) : { nodes, edges };
330
438
  };
@@ -0,0 +1,28 @@
1
+ import { hideMessageNodes, layoutWithElk } from '@eventcatalog/visualiser/layout';
2
+
3
+ type Graph = { nodes: any[]; edges: any[] };
4
+
5
+ /**
6
+ * Lays a node graph out for the visualiser (with ELK, left to right). Builders
7
+ * create their nodes and edges without positions and lay the finished graph
8
+ * out once with this. Nodes get top-left positions (`origin: [0, 0]`), groups
9
+ * (nodes with children) are sized to fit them, and edges get the route they're
10
+ * drawn along (`data.route`), with room for their labels.
11
+ */
12
+ export const layoutNodeGraph = async <G extends Graph>(graph: G): Promise<G> => (await layoutWithElk(graph)) as unknown as G;
13
+
14
+ /**
15
+ * Lays out the graphs of a levels page: level 1 (`overview`: domains, systems
16
+ * and their relationships), level 3 (the detailed graph, with messages and
17
+ * channels) and level 2 in between, the detailed graph with its messages and
18
+ * channels hidden (`hiddenMessages`), so the browser doesn't have to lay it out
19
+ * again. Without an overview there's no level 1.
20
+ */
21
+ export const layoutLevels = async (detailed: Graph, overview?: Graph) => {
22
+ const [laidOut, laidOutOverview, hiddenMessages] = await Promise.all([
23
+ layoutNodeGraph(detailed),
24
+ overview && layoutNodeGraph(overview),
25
+ layoutNodeGraph(hideMessageNodes(detailed.nodes, detailed.edges)),
26
+ ]);
27
+ return { ...laidOut, overview: laidOutOverview, hiddenMessages };
28
+ };
@@ -55,7 +55,7 @@ export async function loadSavedLayout(resourceKey: string): Promise<SavedLayout
55
55
 
56
56
  /**
57
57
  * Applies saved positions to nodes. Nodes with saved positions get them applied,
58
- * nodes without saved positions keep their Dagre-calculated positions.
58
+ * nodes without saved positions keep their laid out positions.
59
59
  */
60
60
  export function applyLayoutToNodes<T extends { id: string; position: { x: number; y: number } }>(
61
61
  nodes: T[],
@@ -63,7 +63,7 @@ export function applyLayoutToNodes<T extends { id: string; position: { x: number
63
63
  ): T[];
64
64
  export function applyLayoutToNodes(nodes: any[], savedLayout: SavedLayout | null): any[] {
65
65
  if (!savedLayout) {
66
- return nodes; // No saved layout, use original Dagre positions
66
+ return nodes; // No saved layout, use the laid out positions
67
67
  }
68
68
 
69
69
  return nodes.map((node) => {
@@ -75,7 +75,7 @@ export function applyLayoutToNodes(nodes: any[], savedLayout: SavedLayout | null
75
75
  position: { x: savedPosition.x, y: savedPosition.y },
76
76
  };
77
77
  }
78
- // Keep Dagre-calculated position for new/unmatched nodes
78
+ // Keep the laid out position for new/unmatched nodes
79
79
  return node;
80
80
  });
81
81
  }
@@ -2,8 +2,6 @@
2
2
  import { getEvents } from '@utils/collections/events';
3
3
  import { getCollection, type CollectionEntry } from 'astro:content';
4
4
  import {
5
- calculatedNodes,
6
- createDagreGraph,
7
5
  createEdge,
8
6
  generatedIdForEdge,
9
7
  generateIdForNode,
@@ -11,8 +9,8 @@ import {
11
9
  getEdgeLabelForMessageAsSource,
12
10
  getEdgeLabelForServiceAsTarget,
13
11
  versionMatches,
14
- layoutDagreGraph,
15
12
  } from './utils/utils';
13
+ import { layoutNodeGraph } from '@utils/node-graphs/layout-node-graph';
16
14
  import { MarkerType, type Node, type Edge } from '@xyflow/react';
17
15
  import {
18
16
  findMatchingNodes,
@@ -31,8 +29,6 @@ import {
31
29
  buildContextMenuForService,
32
30
  buildContextMenuForResource,
33
31
  getOperationFields,
34
- DEFAULT_NODE_WIDTH,
35
- DEFAULT_NODE_HEIGHT,
36
32
  } from './utils/utils';
37
33
  import { getConsumersOfMessage, getProducersOfMessage } from '@utils/collections/services';
38
34
  import {
@@ -44,16 +40,15 @@ import { getChannelChain, isChannelsConnected } from '@utils/collections/channel
44
40
  import { getChannels } from '@utils/collections/channels';
45
41
  import { getTriggeredByOfMessage, getTriggersOfMessage, type MessageReceiver } from '@utils/collections/message-triggers';
46
42
 
47
- type DagreGraph = any;
48
43
  type RoutableResource = CollectionEntry<'agents'> | CollectionEntry<'services'>;
49
44
  type ProducerConsumerResource = RoutableResource | CollectionEntry<'data-products'>;
50
45
 
51
46
  interface Props {
52
47
  id: string;
53
48
  version: string;
54
- defaultFlow?: DagreGraph;
55
49
  mode?: 'simple' | 'full';
56
50
  channelRenderMode?: 'flat' | 'single';
51
+ layout?: boolean;
57
52
  collection?: CollectionEntry<CollectionMessageTypes>[];
58
53
  channels?: CollectionEntry<'channels'>[];
59
54
  }
@@ -216,15 +211,14 @@ export const createTriggerMessageNode = (
216
211
  const getNodesAndEdges = async ({
217
212
  id,
218
213
  version,
219
- defaultFlow,
220
214
  mode = 'simple',
221
215
  channelRenderMode = 'flat',
222
216
  collection = [],
223
217
  channels = [],
218
+ layout = true,
224
219
  }: Props) => {
225
- const flow = defaultFlow || createDagreGraph({ ranksep: 300, nodesep: 50 });
226
- const nodes = [] as any,
227
- edges = [] as any;
220
+ const nodes: any[] = [],
221
+ edges: any[] = [];
228
222
 
229
223
  const message = collection.find((message) => {
230
224
  return message.data.id === id && message.data.version === version;
@@ -297,7 +291,7 @@ const getNodesAndEdges = async ({
297
291
  sourcePosition: 'right',
298
292
  targetPosition: 'left',
299
293
  data: isDataProduct(producer) ? getDataProductNodeData(producer, mode) : getRoutableNodeData(producer, mode),
300
- position: { x: 250, y: 0 },
294
+ position: { x: 0, y: 0 },
301
295
  });
302
296
  if (!isDataProduct(producer)) {
303
297
  appendAgentToolNodesAndEdges({ agent: producer, nodes, edges, mode });
@@ -684,54 +678,42 @@ const getNodesAndEdges = async ({
684
678
  appendEdge(relation.receiver, relation.message, getEdgeLabelForServiceAsTarget(relation.message), relation.message);
685
679
  }
686
680
 
687
- nodes.forEach((node: any) => {
688
- flow.setNode(node.id, { width: DEFAULT_NODE_WIDTH, height: DEFAULT_NODE_HEIGHT });
689
- });
690
-
691
- edges.forEach((edge: any) => {
692
- flow.setEdge(edge.source, edge.target);
693
- });
681
+ if (!layout) return { nodes, edges };
694
682
 
695
- // Render the diagram in memory getting hte X and Y
696
- layoutDagreGraph(flow);
697
-
698
- return {
699
- nodes: calculatedNodes(flow, nodes),
700
- edges,
701
- };
683
+ return layoutNodeGraph({ nodes, edges });
702
684
  };
703
685
 
704
686
  export const getNodesAndEdgesForQueries = async ({
705
687
  id,
706
688
  version,
707
- defaultFlow,
708
689
  mode = 'simple',
709
690
  channelRenderMode = 'flat',
691
+ layout = true,
710
692
  }: Props) => {
711
693
  const [queries, channels] = await Promise.all([getQueries(), getChannels()]);
712
- return getNodesAndEdges({ id, version, defaultFlow, mode, channelRenderMode, collection: queries, channels });
694
+ return getNodesAndEdges({ id, version, mode, channelRenderMode, collection: queries, channels, layout });
713
695
  };
714
696
 
715
697
  export const getNodesAndEdgesForCommands = async ({
716
698
  id,
717
699
  version,
718
- defaultFlow,
719
700
  mode = 'simple',
720
701
  channelRenderMode = 'flat',
702
+ layout = true,
721
703
  }: Props) => {
722
704
  const [commands, channels] = await Promise.all([getCommands(), getChannels()]);
723
- return getNodesAndEdges({ id, version, defaultFlow, mode, channelRenderMode, collection: commands, channels });
705
+ return getNodesAndEdges({ id, version, mode, channelRenderMode, collection: commands, channels, layout });
724
706
  };
725
707
 
726
708
  export const getNodesAndEdgesForEvents = async ({
727
709
  id,
728
710
  version,
729
- defaultFlow,
730
711
  mode = 'simple',
731
712
  channelRenderMode = 'flat',
713
+ layout = true,
732
714
  }: Props) => {
733
715
  const [events, channels] = await Promise.all([getEvents(), getChannels()]);
734
- return getNodesAndEdges({ id, version, defaultFlow, mode, channelRenderMode, collection: events, channels });
716
+ return getNodesAndEdges({ id, version, mode, channelRenderMode, collection: events, channels, layout });
735
717
  };
736
718
 
737
719
  export const getNodesAndEdgesForConsumedMessage = ({
@@ -756,7 +738,7 @@ export const getNodesAndEdgesForConsumedMessage = ({
756
738
  channelMap?: Map<string, CollectionEntry<'channels'>[]>;
757
739
  }) => {
758
740
  let nodes = [] as Node[],
759
- edges = [] as any;
741
+ edges: any[] = [];
760
742
 
761
743
  // Use the provided map or create one if missing
762
744
  const map = channelMap || createVersionedMap(channels);
@@ -1092,7 +1074,7 @@ export const getNodesAndEdgesForProducedMessage = ({
1092
1074
  channelMap?: Map<string, CollectionEntry<'channels'>[]>;
1093
1075
  }) => {
1094
1076
  let nodes = [] as Node[],
1095
- edges = [] as any;
1077
+ edges: any[] = [];
1096
1078
 
1097
1079
  // Use provided map or create one
1098
1080
  const map = channelMap || createVersionedMap(channels);
@@ -1,20 +1,16 @@
1
1
  import { getCollection, type CollectionEntry } from 'astro:content';
2
2
  import {
3
- createDagreGraph,
4
3
  generateIdForNode,
5
4
  generatedIdForEdge,
6
- calculatedNodes,
7
5
  createEdge,
8
6
  buildContextMenuForAgent,
9
7
  buildContextMenuForService,
10
8
  buildContextMenuForResource,
11
9
  versionMatches,
12
- DEFAULT_NODE_WIDTH,
13
- DEFAULT_NODE_HEIGHT,
14
10
  partitionMessagesByGroup,
15
11
  getOperationFields,
16
- layoutDagreGraph,
17
12
  } from '@utils/node-graphs/utils/utils';
13
+ import { layoutNodeGraph } from '@utils/node-graphs/layout-node-graph';
18
14
 
19
15
  const sanitizeGroupId = (name: string) => name.replace(/[^a-zA-Z0-9]/g, '-').toLowerCase();
20
16
  const sanitizeToolId = (name: string) =>
@@ -108,12 +104,9 @@ const precomputeGroupExpansion = (
108
104
  return { expandedNodes, expandedEdges };
109
105
  };
110
106
 
111
- type DagreGraph = any;
112
-
113
107
  interface Props {
114
108
  id: string;
115
109
  version: string;
116
- defaultFlow?: DagreGraph;
117
110
  mode?: 'simple' | 'full';
118
111
  renderAllEdges?: boolean;
119
112
  channelRenderMode?: 'single' | 'flat';
@@ -172,7 +165,6 @@ const getReceivesMessageByMessageType = (messageType: string) => {
172
165
 
173
166
  export const getNodesAndEdges = async ({
174
167
  id,
175
- defaultFlow,
176
168
  version,
177
169
  mode = 'simple',
178
170
  renderAllEdges = false,
@@ -181,7 +173,6 @@ export const getNodesAndEdges = async ({
181
173
  collection = 'services',
182
174
  layout = true,
183
175
  }: Props) => {
184
- const flow = defaultFlow || createDagreGraph({ ranksep: 300, nodesep: 50 });
185
176
  let nodes = [] as any,
186
177
  edges = [] as any;
187
178
 
@@ -282,6 +273,7 @@ export const getNodesAndEdges = async ({
282
273
 
283
274
  nodes.push({
284
275
  id: groupNodeId,
276
+ position: { x: 0, y: 0 },
285
277
  sourcePosition: 'right',
286
278
  targetPosition: 'left',
287
279
  type: 'messageGroup',
@@ -345,6 +337,7 @@ export const getNodesAndEdges = async ({
345
337
  // The service itself
346
338
  nodes.push({
347
339
  id: generateIdForNode(service),
340
+ position: { x: 0, y: 0 },
348
341
  sourcePosition: 'right',
349
342
  targetPosition: 'left',
350
343
  data: {
@@ -358,6 +351,7 @@ export const getNodesAndEdges = async ({
358
351
  writesTo.forEach((writeTo) => {
359
352
  nodes.push({
360
353
  id: generateIdForNode(writeTo),
354
+ position: { x: 0, y: 0 },
361
355
  sourcePosition: 'right',
362
356
  targetPosition: 'left',
363
357
  data: {
@@ -398,6 +392,7 @@ export const getNodesAndEdges = async ({
398
392
 
399
393
  nodes.push({
400
394
  id: toolNodeId,
395
+ position: { x: 0, y: 0 },
401
396
  sourcePosition: 'right',
402
397
  targetPosition: 'left',
403
398
  data: {
@@ -447,6 +442,7 @@ export const getNodesAndEdges = async ({
447
442
  readsFrom.forEach((readFrom) => {
448
443
  nodes.push({
449
444
  id: generateIdForNode(readFrom),
445
+ position: { x: 0, y: 0 },
450
446
  sourcePosition: 'right',
451
447
  targetPosition: 'left',
452
448
  data: {
@@ -500,6 +496,7 @@ export const getNodesAndEdges = async ({
500
496
 
501
497
  nodes.push({
502
498
  id: groupNodeId,
499
+ position: { x: 0, y: 0 },
503
500
  sourcePosition: 'right',
504
501
  targetPosition: 'left',
505
502
  type: 'messageGroup',
@@ -626,19 +623,6 @@ export const getNodesAndEdges = async ({
626
623
 
627
624
  const uniqueNodes = Array.from(uniqueNodesById.values());
628
625
 
629
- uniqueNodes.forEach((node: any) => {
630
- flow.setNode(node.id, { width: DEFAULT_NODE_WIDTH, height: DEFAULT_NODE_HEIGHT });
631
- });
632
-
633
- edges.forEach((edge: any) => {
634
- flow.setEdge(edge.source, edge.target);
635
- });
636
-
637
- if (layout) {
638
- // Render the diagram in memory getting the X and Y
639
- layoutDagreGraph(flow);
640
- }
641
-
642
626
  // Find any duplicated edges, and merge them into one edge
643
627
  const uniqueEdgesById = new Map<string, any>();
644
628
  edges.forEach((edge: any) => {
@@ -661,8 +645,10 @@ export const getNodesAndEdges = async ({
661
645
  });
662
646
  const uniqueEdges = Array.from(uniqueEdgesById.values());
663
647
 
664
- return {
665
- nodes: calculatedNodes(flow, uniqueNodes),
648
+ const graph = {
649
+ nodes: uniqueNodes.map((node: any) => ({ ...node, position: node.position ?? { x: 0, y: 0 } })),
666
650
  edges: uniqueEdges,
667
651
  };
652
+
653
+ return layout ? await layoutNodeGraph(graph) : graph;
668
654
  };