@eventcatalog/core 3.3.0 → 3.4.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 (32) hide show
  1. package/dist/analytics/analytics.cjs +1 -1
  2. package/dist/analytics/analytics.js +2 -2
  3. package/dist/analytics/log-build.cjs +1 -1
  4. package/dist/analytics/log-build.js +3 -3
  5. package/dist/{chunk-I4CMEOEN.js → chunk-GLMX3ZTY.js} +1 -1
  6. package/dist/{chunk-NGKYYZZP.js → chunk-KFZIBXRQ.js} +1 -1
  7. package/dist/{chunk-QZF5ZYJB.js → chunk-MJRHV77M.js} +1 -1
  8. package/dist/{chunk-UPSN5H7S.js → chunk-Q4DKMESA.js} +1 -1
  9. package/dist/{chunk-OAUYXPXT.js → chunk-VAGFX36R.js} +1 -1
  10. package/dist/constants.cjs +1 -1
  11. package/dist/constants.js +1 -1
  12. package/dist/eventcatalog.cjs +4 -3
  13. package/dist/eventcatalog.js +8 -7
  14. package/dist/generate.cjs +1 -1
  15. package/dist/generate.js +3 -3
  16. package/dist/utils/cli-logger.cjs +1 -1
  17. package/dist/utils/cli-logger.js +2 -2
  18. package/eventcatalog/integrations/eventcatalog-features.ts +9 -0
  19. package/eventcatalog/src/content.config.ts +9 -6
  20. package/eventcatalog/src/enterprise/ai/chat-api.ts +27 -83
  21. package/eventcatalog/src/enterprise/custom-documentation/pages/docs/custom/index.astro +1 -0
  22. package/eventcatalog/src/enterprise/mcp/mcp-server.ts +512 -0
  23. package/eventcatalog/src/enterprise/tools/catalog-tools.ts +690 -0
  24. package/eventcatalog/src/enterprise/tools/index.ts +5 -0
  25. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/asyncapi/[filename].astro +24 -1
  26. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/index.astro +2 -0
  27. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/spec/[filename].astro +22 -1
  28. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/spec/_OpenAPI.tsx +28 -4
  29. package/eventcatalog/src/pages/docs/[type]/[id]/[version].mdx.ts +0 -4
  30. package/eventcatalog/src/utils/feature.ts +2 -0
  31. package/eventcatalog/tsconfig.json +1 -1
  32. package/package.json +4 -2
@@ -9,6 +9,8 @@ import '@asyncapi/react-component/styles/default.min.css';
9
9
  import js from '@asyncapi/react-component/browser/standalone/without-parser.js?url';
10
10
  import { AsyncApiComponentWP, type ConfigInterface } from '@asyncapi/react-component';
11
11
  import VerticalSideBarLayout from '@layouts/VerticalSideBarLayout.astro';
12
+ import CopyAsMarkdown from '@components/CopyAsMarkdown';
13
+ import { isEventCatalogChatEnabled } from '@utils/feature';
12
14
  import Config from '@utils/eventcatalog-config/catalog';
13
15
  import { Page } from './_[filename].data';
14
16
  import { getAbsoluteFilePathForAstroFile } from '@utils/files';
@@ -46,6 +48,10 @@ const renderedComponent = renderToString(component);
46
48
  // Capitalize the first letter of a string
47
49
  const pageTitle = `${collection} | ${data.name} | AsyncApi Spec`.replace(/^\w/, (c) => c.toUpperCase());
48
50
 
51
+ // Chat configuration
52
+ const chatEnabled = isEventCatalogChatEnabled();
53
+ const chatQuery = `Tell me about the AsyncAPI specification for "${data.name}" (version ${data.version})`;
54
+
49
55
  // Index only the latest version
50
56
  const pagefindAttributes =
51
57
  data.version === data.latestVersion
@@ -57,13 +63,30 @@ const pagefindAttributes =
57
63
  ---
58
64
 
59
65
  <VerticalSideBarLayout title={pageTitle}>
60
- <div {...pagefindAttributes}>
66
+ <div {...pagefindAttributes} class="relative">
61
67
  {
62
68
  // Currently, Pagefind does not index metadata (such as the title),
63
69
  // so we need to ensure it is included as text on the page.
64
70
  // https://github.com/CloudCannon/pagefind/issues/437
65
71
  }
66
72
  <h2 class="hidden">{pageTitle}</h2>
73
+ {
74
+ chatEnabled && (
75
+ <div class="absolute top-3 right-4 z-10">
76
+ <CopyAsMarkdown
77
+ client:only="react"
78
+ schemas={[]}
79
+ chatQuery={chatQuery}
80
+ chatEnabled={chatEnabled}
81
+ editUrl=""
82
+ markdownDownloadEnabled={false}
83
+ rssFeedEnabled={false}
84
+ preferChatAsDefault={true}
85
+ chatButtonText="Ask about this specification"
86
+ />
87
+ </div>
88
+ )
89
+ }
67
90
  <div id="asyncapi" class="md:pr-14" set:html={renderedComponent} />
68
91
  </div>
69
92
  </VerticalSideBarLayout>
@@ -586,8 +586,10 @@ nodeGraphs.push({
586
586
  async function renderDiagrams(graphs: any) {
587
587
  const { default: mermaid } = await import('mermaid');
588
588
 
589
+ // @ts-ignore
589
590
  if (window.eventcatalog.mermaid) {
590
591
  const { icons } = await import('@iconify-json/logos');
592
+ // @ts-ignore
591
593
  const { iconPacks = [], enableSupportForElkLayout = false } = window.eventcatalog.mermaid ?? {};
592
594
 
593
595
  if (iconPacks.length > 0) {
@@ -4,6 +4,8 @@ import OpenAPISpec from './_OpenAPI.tsx';
4
4
 
5
5
  import { DocumentMinusIcon } from '@heroicons/react/24/outline';
6
6
  import VerticalSideBarLayout from '@layouts/VerticalSideBarLayout.astro';
7
+ import CopyAsMarkdown from '@components/CopyAsMarkdown';
8
+ import { isEventCatalogChatEnabled } from '@utils/feature';
7
9
  import './_styles.css';
8
10
  import { Page } from './_[filename].data.ts';
9
11
  import { getAbsoluteFilePathForAstroFile } from '@utils/files';
@@ -27,6 +29,10 @@ let content = '';
27
29
  // Capitalize the first letter of a string
28
30
  const pageTitle = `${collection} | ${data.name} | OpenAPI Spec`.replace(/^\w/, (c) => c.toUpperCase());
29
31
 
32
+ // Chat configuration
33
+ const chatEnabled = isEventCatalogChatEnabled();
34
+ const chatQuery = `Tell me about the OpenAPI specification for "${data.name}" (version ${data.version})`;
35
+
30
36
  // Index only the latest version
31
37
  const pagefindAttributes =
32
38
  data.version === data.latestVersion
@@ -57,13 +63,28 @@ if (isRemote) {
57
63
  </p>
58
64
  </div>
59
65
  ) : (
60
- <div {...pagefindAttributes}>
66
+ <div {...pagefindAttributes} class="relative">
61
67
  {
62
68
  // Currently, Pagefind does not index metadata (such as the title),
63
69
  // so we need to ensure it is included as text on the page.
64
70
  // https://github.com/CloudCannon/pagefind/issues/437
65
71
  }
66
72
  <h2 class="hidden">{pageTitle}</h2>
73
+ {chatEnabled && (
74
+ <div class="absolute top-3 right-14 z-10">
75
+ <CopyAsMarkdown
76
+ client:only="react"
77
+ schemas={[]}
78
+ chatQuery={chatQuery}
79
+ chatEnabled={chatEnabled}
80
+ editUrl=""
81
+ markdownDownloadEnabled={false}
82
+ rssFeedEnabled={false}
83
+ preferChatAsDefault={true}
84
+ chatButtonText="Ask about this specification"
85
+ />
86
+ </div>
87
+ )}
67
88
  <OpenAPISpec client:only="react" spec={content} />
68
89
  </div>
69
90
  )
@@ -1,13 +1,38 @@
1
- import { useState } from 'react';
1
+ import { useState, useEffect } from 'react';
2
2
  import { ApiReferenceReact } from '@scalar/api-reference-react';
3
3
  import '@scalar/api-reference-react/style.css';
4
4
  import './_styles.css';
5
+
5
6
  const OpenAPISpec = ({ spec }: { spec: string }) => {
6
7
  const [loaded, setLoaded] = useState(false);
8
+ const [isDarkMode, setIsDarkMode] = useState(() => {
9
+ return document.documentElement.getAttribute('data-theme') === 'dark';
10
+ });
11
+
12
+ useEffect(() => {
13
+ // Watch for theme changes
14
+ const observer = new MutationObserver((mutations) => {
15
+ mutations.forEach((mutation) => {
16
+ if (mutation.attributeName === 'data-theme') {
17
+ const theme = document.documentElement.getAttribute('data-theme');
18
+ setIsDarkMode(theme === 'dark');
19
+ }
20
+ });
21
+ });
22
+
23
+ observer.observe(document.documentElement, {
24
+ attributes: true,
25
+ attributeFilter: ['data-theme'],
26
+ });
27
+
28
+ return () => observer.disconnect();
29
+ }, []);
30
+
7
31
  return (
8
32
  <div>
9
33
  {!loaded && <div>Loading...</div>}
10
34
  <ApiReferenceReact
35
+ key={isDarkMode ? 'dark' : 'light'}
11
36
  configuration={{
12
37
  spec: {
13
38
  content: spec,
@@ -17,13 +42,12 @@ const OpenAPISpec = ({ spec }: { spec: string }) => {
17
42
  onLoaded: () => {
18
43
  setLoaded(true);
19
44
  },
20
- forceDarkModeState: 'light',
21
- darkMode: false,
45
+ forceDarkModeState: isDarkMode ? 'dark' : 'light',
46
+ darkMode: isDarkMode,
22
47
  defaultOpenAllTags: true,
23
48
  hideDarkModeToggle: true,
24
49
  searchHotKey: 'p',
25
50
  showSidebar: true,
26
- customCss: 'bg-red-500',
27
51
  }}
28
52
  />
29
53
  </div>
@@ -45,15 +45,11 @@ export async function getStaticPaths() {
45
45
  }
46
46
 
47
47
  export const GET: APIRoute = async ({ params, props }) => {
48
- console.log('props', props);
49
-
50
48
  // Just return empty array if LLMs are not enabled
51
49
  if (!isLLMSTxtEnabled()) {
52
50
  return new Response('llms.txt is not enabled for this Catalog.', { status: 404 });
53
51
  }
54
52
 
55
- console.log('params', params);
56
-
57
53
  if (isSSR()) {
58
54
  const { getResourcePath } = utils(process.env.PROJECT_DIR ?? '');
59
55
  const filePath = await getResourcePath(process.env.PROJECT_DIR ?? '', params.id ?? '', params.version ?? '');
@@ -69,3 +69,5 @@ export const isCustomStylesEnabled = () => {
69
69
  };
70
70
 
71
71
  export const isDiagramComparisonEnabled = () => isEventCatalogScaleEnabled();
72
+
73
+ export const isEventCatalogMCPEnabled = () => isEventCatalogScaleEnabled() && isSSR();
@@ -22,5 +22,5 @@
22
22
  "jsxImportSource": "react",
23
23
  "types": ["vitest/globals"]
24
24
  },
25
- "exclude": ["**/*.spec.ts", "**/*.test.ts"]
25
+ "include": ["src/**/*", "*.config.*"]
26
26
  }
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "url": "https://github.com/event-catalog/eventcatalog.git"
7
7
  },
8
8
  "type": "module",
9
- "version": "3.3.0",
9
+ "version": "3.4.0",
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
@@ -41,6 +41,7 @@
41
41
  "@heroicons/react": "^2.1.3",
42
42
  "@iconify-json/logos": "^1.2.4",
43
43
  "@mermaid-js/layout-elk": "^0.2.0",
44
+ "@modelcontextprotocol/sdk": "^1.25.2",
44
45
  "@nanostores/react": "^1.0.0",
45
46
  "@parcel/watcher": "^2.4.1",
46
47
  "@radix-ui/react-context-menu": "^2.2.6",
@@ -54,7 +55,7 @@
54
55
  "@tanstack/react-table": "^8.17.3",
55
56
  "@xyflow/react": "^12.3.6",
56
57
  "ai": "^6.0.17",
57
- "astro": "^5.16.7",
58
+ "astro": "^5.16.8",
58
59
  "astro-compress": "^2.3.8",
59
60
  "astro-expressive-code": "^0.41.3",
60
61
  "astro-seo": "^0.8.4",
@@ -72,6 +73,7 @@
72
73
  "elkjs": "^0.10.0",
73
74
  "glob": "^10.5.0",
74
75
  "gray-matter": "^4.0.3",
76
+ "hono": "^4.11.3",
75
77
  "html-to-image": "^1.11.11",
76
78
  "js-yaml": "^4.1.1",
77
79
  "jsonpath": "^1.1.1",