@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.
- package/LICENSE +226 -95
- package/NOTICE +30 -0
- package/README.md +3 -2
- package/dist/analytics/analytics.cjs +1 -1
- package/dist/analytics/analytics.js +2 -2
- package/dist/analytics/log-build.cjs +43 -16
- package/dist/analytics/log-build.d.cts +6 -5
- package/dist/analytics/log-build.d.ts +6 -5
- package/dist/analytics/log-build.js +4 -3
- package/dist/{chunk-U4YJSTGV.js → chunk-AYNZXUB5.js} +2 -10
- package/dist/{chunk-IVVM67LN.js → chunk-CR6AK5LR.js} +1 -1
- package/dist/{chunk-GTIC4R74.js → chunk-LR7AGRHN.js} +13 -16
- package/dist/chunk-TQLRG35T.js +203 -0
- package/dist/{chunk-WK4J6FP3.js → chunk-TWN43V4T.js} +1 -1
- package/dist/{chunk-ZW3MYAWF.js → chunk-WAIADKQE.js} +1 -1
- package/dist/{chunk-RPVA2SZY.js → chunk-ZHKEARLJ.js} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/eventcatalog.cjs +407 -291
- package/dist/eventcatalog.config.d.cts +2 -3
- package/dist/eventcatalog.config.d.ts +2 -3
- package/dist/eventcatalog.js +30 -93
- package/dist/federation/content-cache.d.cts +0 -5
- package/dist/federation/content-cache.d.ts +0 -5
- package/dist/federation/diagnostics.d.cts +0 -5
- package/dist/federation/diagnostics.d.ts +0 -5
- package/dist/federation/federate.cjs +0 -9
- package/dist/federation/federate.d.cts +0 -5
- package/dist/federation/federate.d.ts +0 -5
- package/dist/federation/federate.js +2 -3
- package/dist/federation/filesystem-source-provider.d.cts +0 -5
- package/dist/federation/filesystem-source-provider.d.ts +0 -5
- package/dist/federation/github-source-provider.d.cts +0 -5
- package/dist/federation/github-source-provider.d.ts +0 -5
- package/dist/federation/output-transaction.d.cts +0 -4
- package/dist/federation/output-transaction.d.ts +0 -4
- package/dist/federation/public-assets.d.cts +0 -5
- package/dist/federation/public-assets.d.ts +0 -5
- package/dist/federation/source-provider.d.cts +0 -5
- package/dist/federation/source-provider.d.ts +0 -5
- package/dist/federation/types.d.cts +0 -5
- package/dist/federation/types.d.ts +0 -5
- package/dist/generate.cjs +1 -1
- package/dist/generate.js +3 -3
- package/dist/license-C1y-56bb.d.cts +23 -0
- package/dist/license-C1y-56bb.d.ts +23 -0
- package/dist/runtime-dependencies/@eventcatalog__visualiser__layout.mjs +3 -0
- package/dist/runtime-dependencies/@modelcontextprotocol__ext-apps.mjs +3 -0
- package/dist/runtime-dependencies/@modelcontextprotocol__ext-apps__react.mjs +3 -0
- package/dist/runtime-dependencies/@modelcontextprotocol__ext-apps__server.mjs +3 -0
- package/dist/runtime-dependencies/@modelcontextprotocol__sdk__types.js.mjs +3 -0
- package/dist/runtime-dependencies/manifest.json +12 -1
- package/dist/runtime-dependencies/react-syntax-highlighter__dist__esm__languages__prism__graphql.mjs +3 -0
- package/dist/runtime-dependencies/react-syntax-highlighter__dist__esm__languages__prism__json.mjs +3 -0
- package/dist/runtime-dependencies/react-syntax-highlighter__dist__esm__languages__prism__markup.mjs +3 -0
- package/dist/runtime-dependencies/react-syntax-highlighter__dist__esm__languages__prism__protobuf.mjs +3 -0
- package/dist/runtime-dependencies/react-syntax-highlighter__dist__esm__languages__prism__yaml.mjs +3 -0
- package/dist/runtime-dependencies/react-syntax-highlighter__dist__esm__styles__prism__one-dark.mjs +3 -0
- package/dist/runtime-dependencies/react-syntax-highlighter__dist__esm__styles__prism__one-light.mjs +3 -0
- package/dist/utils/cli-logger.cjs +1 -1
- package/dist/utils/cli-logger.js +2 -2
- package/dist/utils/license-status.cjs +240 -0
- package/dist/utils/license-status.d.cts +28 -0
- package/dist/utils/license-status.d.ts +28 -0
- package/dist/utils/license-status.js +12 -0
- package/eventcatalog/astro.config.mjs +1 -1
- package/eventcatalog/integrations/eventcatalog-runtime.mjs +1 -1
- package/eventcatalog/src/components/ChatPanel/ChatPanel.tsx +29 -19
- package/eventcatalog/src/components/ChatPanel/OfflineReply.tsx +74 -0
- package/eventcatalog/src/components/FieldsExplorer/FieldFilters.tsx +24 -28
- package/eventcatalog/src/components/FieldsExplorer/FieldNodeGraph.tsx +16 -11
- package/eventcatalog/src/components/FieldsExplorer/FieldsExplorer.tsx +4 -218
- package/eventcatalog/src/components/FieldsExplorer/FieldsTable.tsx +27 -36
- package/eventcatalog/src/components/Header.astro +43 -58
- package/eventcatalog/src/components/Lists/PillListFlat.styles.css +17 -17
- package/eventcatalog/src/components/MDX/EntityMap/EntityMap.astro +1 -1
- package/eventcatalog/src/components/MDX/Flow/Flow.astro +4 -0
- package/eventcatalog/src/components/MDX/NodeGraph/AstroNodeGraph.tsx +14 -0
- package/eventcatalog/src/components/MDX/NodeGraph/NodeGraph.astro +49 -18
- package/eventcatalog/src/components/MDX/RemoteFile.astro +2 -24
- package/eventcatalog/src/components/SchemaExplorer/ApiAccessSection.tsx +59 -93
- package/eventcatalog/src/components/SchemaExplorer/ApiContentViewer.tsx +1 -32
- package/eventcatalog/src/components/SchemaExplorer/DiffViewer.tsx +20 -67
- package/eventcatalog/src/components/SchemaExplorer/SchemaContentViewer.tsx +2 -11
- package/eventcatalog/src/components/SchemaExplorer/SchemaDetailsPanel.tsx +11 -60
- package/eventcatalog/src/components/SchemaExplorer/SchemaExplorer.tsx +1 -3
- package/eventcatalog/src/components/SchemaExplorer/SchemaPageViewer.tsx +0 -3
- package/eventcatalog/src/components/SchemaExplorer/VersionHistoryModal.tsx +2 -9
- package/eventcatalog/src/components/SchemaExplorer/parse-schema.ts +46 -0
- package/eventcatalog/src/components/SchemaExplorer/utils.ts +11 -0
- package/eventcatalog/src/components/Settings/AssistantSettingsForm.tsx +2 -9
- package/eventcatalog/src/components/Settings/LicenseSettings.tsx +288 -0
- package/eventcatalog/src/components/Settings/LlmAccessSettingsForm.tsx +3 -19
- package/eventcatalog/src/components/Settings/McpSettingsForm.tsx +85 -30
- package/eventcatalog/src/components/Settings/SettingsShared.tsx +7 -75
- package/eventcatalog/src/components/SideNav/CustomDocsNav.astro +2 -2
- package/eventcatalog/src/components/TrialBadge.astro +82 -0
- package/eventcatalog/src/content.config.ts +9 -90
- package/eventcatalog/src/{enterprise → features}/ai/chat-api.ts +22 -34
- package/eventcatalog/src/{enterprise → features}/analytics/adapters/ga4.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/analytics/adapters/gtm.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/analytics/adapters/posthog.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/analytics/components/AnalyticsHead.astro +2 -4
- package/eventcatalog/src/{enterprise → features}/analytics/components/AnalyticsTracker.astro +2 -4
- package/eventcatalog/src/{enterprise → features}/analytics/tracker.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/api/catalog.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/auth/[...auth].ts +0 -5
- package/eventcatalog/src/{enterprise → features}/auth/middleware/middleware-auth.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/auth/middleware/middleware.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/collections/custom-pages.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/collections/index.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/collections/resource-docs.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/custom-documentation/collection.ts +0 -5
- package/eventcatalog/src/features/custom-documentation/components/CustomDocsNav/CustomDocsNav.astro +9 -0
- package/eventcatalog/src/{enterprise → features}/custom-documentation/components/CustomDocsNav/CustomDocsNavWrapper.tsx +0 -5
- package/eventcatalog/src/{enterprise → features}/custom-documentation/components/CustomDocsNav/components/NestedItem.tsx +1 -6
- package/eventcatalog/src/{enterprise → features}/custom-documentation/components/CustomDocsNav/components/NoResultsFound.tsx +0 -5
- package/eventcatalog/src/{enterprise → features}/custom-documentation/components/CustomDocsNav/index.tsx +1 -6
- package/eventcatalog/src/{enterprise → features}/custom-documentation/components/CustomDocsNav/types.ts +0 -5
- package/eventcatalog/src/{enterprise/custom-documentation/pages/docs/custom/index.astro → features/custom-documentation/components/CustomDocumentationPage.astro} +5 -5
- package/eventcatalog/src/{enterprise → features}/custom-documentation/utils/badge-styles.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/custom-documentation/utils/custom-docs.ts +1 -6
- package/eventcatalog/src/{enterprise → features}/custom-documentation/utils/docs-search.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/custom-pages/routes.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/directory/user-team-directory.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/fields/field-extractor.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/fields/field-indexer.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/fields/fields-db.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/fields/pages/api/fields.ts +1 -6
- package/eventcatalog/src/{enterprise → features}/fields/pages/fields.astro +1 -2
- package/eventcatalog/src/{enterprise → features}/integrations/eventcatalog-features.ts +17 -75
- package/eventcatalog/src/features/mcp/apps/architecture-diagram/links.ts +59 -0
- package/eventcatalog/src/features/mcp/apps/architecture-diagram/node-chat.tsx +299 -0
- package/eventcatalog/src/features/mcp/apps/architecture-diagram/shared.ts +14 -0
- package/eventcatalog/src/features/mcp/apps/architecture-diagram/view.tsx +454 -0
- package/eventcatalog/src/features/mcp/apps/generated/viewer.html +432 -0
- package/eventcatalog/src/features/mcp/apps/mermaid-stub.ts +10 -0
- package/eventcatalog/src/features/mcp/apps/schema-viewer/schema-code.tsx +65 -0
- package/eventcatalog/src/features/mcp/apps/schema-viewer/shared.ts +23 -0
- package/eventcatalog/src/features/mcp/apps/schema-viewer/view.tsx +170 -0
- package/eventcatalog/src/features/mcp/apps/shared/app-view.tsx +98 -0
- package/eventcatalog/src/features/mcp/apps/shared/resource-types.ts +15 -0
- package/eventcatalog/src/features/mcp/apps/viewer/shared.ts +24 -0
- package/eventcatalog/src/features/mcp/apps/viewer/styles.css +25 -0
- package/eventcatalog/src/features/mcp/apps/viewer/view.tsx +59 -0
- package/eventcatalog/src/features/mcp/mcp-app-icons.ts +63 -0
- package/eventcatalog/src/features/mcp/mcp-apps.ts +160 -0
- package/eventcatalog/src/{enterprise → features}/mcp/mcp-auth.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/mcp/mcp-scope.ts +7 -7
- package/eventcatalog/src/{enterprise → features}/mcp/mcp-scoped-tools.ts +47 -40
- package/eventcatalog/src/{enterprise → features}/mcp/mcp-server.ts +347 -34
- package/eventcatalog/src/{enterprise → features}/mcp/oauth-protected-resource.ts +0 -5
- package/eventcatalog/src/features/mcp/schema-viewer.ts +24 -0
- package/eventcatalog/src/{enterprise → features}/tools/catalog-tools.ts +133 -102
- package/eventcatalog/src/features/tools/index.ts +5 -0
- package/eventcatalog/src/{enterprise → features}/visualizer-layout/reset.ts +0 -5
- package/eventcatalog/src/{enterprise → features}/visualizer-layout/save.ts +0 -5
- package/eventcatalog/src/layouts/BaseLayout.astro +2 -2
- package/eventcatalog/src/layouts/Footer.astro +31 -39
- package/eventcatalog/src/layouts/SettingsLayout.astro +6 -6
- package/eventcatalog/src/layouts/VerticalSideBarLayout.astro +7 -37
- package/eventcatalog/src/{enterprise → pages}/api/schemas/[collection]/[id]/[version]/index.ts +0 -22
- package/eventcatalog/src/{enterprise → pages}/api/schemas/services/[id]/[version]/[specification]/index.ts +0 -19
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/[docType]/[docId]/[docVersion]/_index.data.ts +2 -6
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/[docType]/[docId]/[docVersion]/index.astro +1 -5
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/[docType]/[docId]/_index.data.ts +2 -6
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/[docType]/[docId]/index.astro +1 -5
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/[docType]/[docId].md.ts +2 -6
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/[docType]/[docId].mdx.ts +2 -6
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/index.astro +9 -5
- package/eventcatalog/src/pages/docs/custom/[...path]/index.astro +12 -0
- package/eventcatalog/src/{enterprise/custom-documentation/pages/docs/custom/root-index.astro → pages/docs/custom/index.astro} +1 -23
- package/eventcatalog/src/pages/docs/llm/llms-full.txt.ts +4 -9
- package/eventcatalog/src/pages/docs/llm/llms.txt.ts +4 -4
- package/eventcatalog/src/pages/docs/llm/schemas.txt.ts +0 -11
- package/eventcatalog/src/pages/docs/services/[id]/[docType]/[docId]/index.astro +2 -2
- package/eventcatalog/src/pages/index.astro +2 -2
- package/eventcatalog/src/pages/schemas/[type]/[id]/[version]/index.astro +0 -3
- package/eventcatalog/src/pages/schemas/explorer/index.astro +1 -4
- package/eventcatalog/src/pages/settings/assistant.astro +2 -4
- package/eventcatalog/src/pages/settings/license.astro +18 -0
- package/eventcatalog/src/pages/settings/llm-access.astro +1 -4
- package/eventcatalog/src/pages/settings/mcp.astro +33 -4
- package/eventcatalog/src/pages/visualiser/[type]/[id]/[version]/_index.data.ts +1 -2
- package/eventcatalog/src/pages/visualiser/[type]/[id]/[version]/data/index.astro +2 -45
- package/eventcatalog/src/pages/visualiser/[type]/[id]/[version]/entity-map/index.astro +1 -1
- package/eventcatalog/src/pages/visualiser/[type]/[id]/[version].mermaid.ts +7 -109
- package/eventcatalog/src/pages/visualiser/_mermaid-route.ts +78 -0
- package/eventcatalog/src/pages/visualiser/domains/[id]/[version]/_index.data.ts +44 -0
- package/eventcatalog/src/pages/visualiser/domains/[id]/[version]/entity-map/index.astro +1 -1
- package/eventcatalog/src/pages/visualiser/domains/[id]/[version]/index.astro +56 -0
- package/eventcatalog/src/pages/visualiser/domains/[id]/[version]/systems-context/index.astro +3 -40
- package/eventcatalog/src/pages/visualiser/domains/[id]/[version].mermaid.ts +20 -0
- package/eventcatalog/src/pages/visualiser/systems/[id]/[version]/_index.data.ts +29 -0
- package/eventcatalog/src/pages/visualiser/systems/[id]/[version]/context/index.astro +3 -38
- package/eventcatalog/src/pages/visualiser/systems/[id]/[version]/index.astro +56 -0
- package/eventcatalog/src/pages/visualiser/systems/[id]/[version].mermaid.ts +20 -0
- package/eventcatalog/src/stores/sidebar-store/builders/agent.ts +1 -1
- package/eventcatalog/src/stores/sidebar-store/builders/container.ts +1 -1
- package/eventcatalog/src/stores/sidebar-store/builders/data-product.ts +1 -1
- package/eventcatalog/src/stores/sidebar-store/builders/domain.ts +7 -32
- package/eventcatalog/src/stores/sidebar-store/builders/entity.ts +1 -1
- package/eventcatalog/src/stores/sidebar-store/builders/message.ts +1 -1
- package/eventcatalog/src/stores/sidebar-store/builders/service.ts +2 -8
- package/eventcatalog/src/stores/sidebar-store/builders/system.ts +2 -12
- package/eventcatalog/src/stores/sidebar-store/custom-sidebar.ts +0 -10
- package/eventcatalog/src/stores/sidebar-store/state.ts +4 -6
- package/eventcatalog/src/styles/theme.css +22 -18
- package/eventcatalog/src/styles/themes/forest.css +8 -8
- package/eventcatalog/src/styles/themes/ocean.css +8 -8
- package/eventcatalog/src/styles/themes/sapphire.css +8 -8
- package/eventcatalog/src/styles/themes/sunset.css +8 -8
- package/eventcatalog/src/utils/clipboard.ts +4 -4
- package/eventcatalog/src/utils/collections/flow-step-schema.ts +117 -0
- package/eventcatalog/src/utils/collections/pointer-schema.ts +7 -0
- package/eventcatalog/src/utils/collections/resource-docs.ts +677 -14
- package/eventcatalog/src/utils/collections/schema-loader.ts +0 -5
- package/eventcatalog/src/utils/feature.ts +14 -23
- package/eventcatalog/src/utils/license.ts +114 -0
- package/eventcatalog/src/utils/node-graphs/architecture-diagram-types.ts +32 -0
- package/eventcatalog/src/utils/node-graphs/architecture-diagram.ts +84 -0
- package/eventcatalog/src/utils/node-graphs/catalog-force-graph.ts +1 -0
- package/eventcatalog/src/utils/node-graphs/channel-node-graph.ts +4 -25
- package/eventcatalog/src/utils/node-graphs/container-node-graph.ts +12 -39
- package/eventcatalog/src/utils/node-graphs/data-products-node-graph.ts +11 -27
- package/eventcatalog/src/utils/node-graphs/domain-levels-node-graph.ts +679 -0
- package/eventcatalog/src/utils/node-graphs/domains-node-graph.ts +3 -20
- package/eventcatalog/src/utils/node-graphs/export-mermaid.ts +62 -4
- package/eventcatalog/src/utils/node-graphs/field-node-graph.ts +8 -23
- package/eventcatalog/src/utils/node-graphs/flow-lanes.ts +119 -0
- package/eventcatalog/src/utils/node-graphs/flows-node-graph.ts +153 -45
- package/eventcatalog/src/utils/node-graphs/layout-node-graph.ts +28 -0
- package/eventcatalog/src/utils/node-graphs/layout-persistence.ts +3 -3
- package/eventcatalog/src/utils/node-graphs/message-node-graph.ts +16 -34
- package/eventcatalog/src/utils/node-graphs/services-node-graph.ts +11 -25
- package/eventcatalog/src/utils/node-graphs/system-context-node-graph.ts +18 -54
- package/eventcatalog/src/utils/node-graphs/system-levels-node-graph.ts +59 -0
- package/eventcatalog/src/utils/node-graphs/systems-node-graph.ts +20 -80
- package/eventcatalog/src/utils/node-graphs/utils/utils.ts +1 -78
- package/eventcatalog/src/utils/trial.ts +36 -0
- package/eventcatalog/tsconfig.json +1 -1
- package/package.json +11 -11
- package/dist/chunk-FV56YFM4.js +0 -7
- package/dist/federation/entitlement.cjs +0 -31
- package/dist/federation/entitlement.d.cts +0 -12
- package/dist/federation/entitlement.d.ts +0 -12
- package/dist/federation/entitlement.js +0 -6
- package/dist/runtime-dependencies/dagre.mjs +0 -3
- package/eventcatalog/src/components/Settings/BillingSettingsForm.tsx +0 -265
- package/eventcatalog/src/enterprise/LICENSE +0 -57
- package/eventcatalog/src/enterprise/README.md +0 -5
- package/eventcatalog/src/enterprise/collections/resource-docs-utils.ts +0 -691
- package/eventcatalog/src/enterprise/custom-documentation/components/CustomDocsNav/CustomDocsNav.astro +0 -9
- package/eventcatalog/src/enterprise/custom-documentation/pages/docs/custom/[...path]/index.astro +0 -18
- package/eventcatalog/src/enterprise/custom-documentation/pages/docs/custom/feature.astro +0 -171
- package/eventcatalog/src/enterprise/feature.ts +0 -75
- package/eventcatalog/src/enterprise/tools/index.ts +0 -10
- package/eventcatalog/src/hooks/eventcatalog-visualizer.ts +0 -126
- package/eventcatalog/src/pages/settings/billing.astro +0 -17
- package/eventcatalog/src/pages/visualiser/domain-integrations/index.astro +0 -26
- package/eventcatalog/src/types/mcp-modules.d.ts +0 -67
- package/eventcatalog/src/utils/node-graphs/domains-canvas.ts +0 -261
- package/eventcatalog/src/utils/node-graphs/export-node-graph.ts +0 -91
- /package/eventcatalog/src/{enterprise → features}/auth/error.astro +0 -0
- /package/eventcatalog/src/{enterprise → features}/auth/login.astro +0 -0
- /package/eventcatalog/src/{enterprise → features}/auth/unauthorized.astro +0 -0
- /package/eventcatalog/src/{enterprise/custom-documentation/pages → pages}/docs/custom/[...path]/_index.data.ts +0 -0
- /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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
233
|
+
step: stepForNode(step),
|
|
150
234
|
showTarget: true,
|
|
151
235
|
showSource: true,
|
|
152
236
|
},
|
|
153
|
-
position: { x:
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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,
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
226
|
-
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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,
|
|
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 = []
|
|
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 = []
|
|
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
|
-
|
|
665
|
-
nodes:
|
|
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
|
};
|