@eventcatalog/core 2.33.0 → 2.33.2

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 (30) 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-TNU27WQF.js → chunk-DDOQCYNI.js} +1 -1
  6. package/dist/{chunk-MC6EBL4I.js → chunk-ESJAFFBK.js} +1 -1
  7. package/dist/{chunk-MXEVMOGW.js → chunk-QXRF5XEW.js} +1 -1
  8. package/dist/constants.cjs +1 -1
  9. package/dist/constants.js +1 -1
  10. package/dist/eventcatalog.cjs +1 -1
  11. package/dist/eventcatalog.js +3 -3
  12. package/eventcatalog/src/components/Lists/CustomSideBarSectionList.astro +1 -13
  13. package/eventcatalog/src/components/MDX/ResourceGroupTable/ResourceGroupTable.astro +1 -13
  14. package/eventcatalog/src/components/MDX/ResourceLink/ResourceLink.astro +1 -12
  15. package/eventcatalog/src/components/MDX/SchemaViewer/SchemaProperty.astro +161 -0
  16. package/eventcatalog/src/components/MDX/SchemaViewer/SchemaViewer.astro +36 -95
  17. package/eventcatalog/src/components/MDX/SchemaViewer/SchemaViewerPortal.tsx +1 -1
  18. package/eventcatalog/src/components/MDX/SchemaViewer/SchemaViewerRoot.astro +98 -0
  19. package/eventcatalog/src/components/MDX/components.tsx +1 -1
  20. package/eventcatalog/src/enterprise/custom-documentation/pages/docs/custom/index.astro +26 -1
  21. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/index.astro +3 -2
  22. package/eventcatalog/src/pages/docs/custom/[...path].mdx.ts +32 -0
  23. package/eventcatalog/src/pages/docs/llm/llms-full.txt.ts +19 -2
  24. package/eventcatalog/src/pages/docs/llm/llms.txt.ts +10 -0
  25. package/eventcatalog/src/utils/collections/util.ts +12 -0
  26. package/eventcatalog/src/utils/markdown.ts +30 -0
  27. package/package.json +1 -3
  28. package/eventcatalog/src/components/MDX/SchemaViewer/SchemaViewer.tsx +0 -62
  29. package/eventcatalog/src/components/MDX/SchemaViewer/css/stoplight-mosaic-styles.css +0 -29609
  30. package/eventcatalog/src/components/MDX/SchemaViewer/css/stoplight-mosaic-theme-default.css +0 -333
@@ -4,7 +4,7 @@ import Footer from '@layouts/Footer.astro';
4
4
 
5
5
  import components from '@components/MDX/components';
6
6
  import NodeGraph from '@components/MDX/NodeGraph/NodeGraph.astro';
7
- import SchemaViewer from '@components/MDX/SchemaViewer/SchemaViewer.astro';
7
+ import SchemaViewer from '@components/MDX/SchemaViewer/SchemaViewerRoot.astro';
8
8
 
9
9
  // SideBars
10
10
  import ServiceSideBar from '@components/SideBars/ServiceSideBar.astro';
@@ -202,7 +202,8 @@ const pagefindAttributes =
202
202
  </div>
203
203
  <div data-pagefind-ignore>
204
204
  <!-- @ts-ignore -->
205
- <SchemaViewer id={props.data.id} catalog={props.catalog} filePath={props.filePath} />
205
+ <!-- <SchemaViewer id={props.data.id} catalog={props.catalog} filePath={props.filePath} /> -->
206
+ <SchemaViewer id={props.data.id} filePath={props.filePath} />
206
207
  <NodeGraph
207
208
  id={props.data.id}
208
209
  collection={props.collection}
@@ -0,0 +1,32 @@
1
+ // This file exposes the markdown for EventCatalog in the Url
2
+ // For example http://localhost:3000/docs/events/OrderAmended/0.0.1 loads the Page and http://localhost:3000/docs/events/OrderAmended/0.0.1.md loads the markdown
3
+ // This is used for the LLMs to load the markdown for the given item (llms.txt);
4
+
5
+ import type { APIRoute, GetStaticPaths } from 'astro';
6
+ import { getCollection } from 'astro:content';
7
+ import config from '@config';
8
+ import fs from 'fs';
9
+
10
+ export const getStaticPaths = (async () => {
11
+ const docs = await getCollection('customPages');
12
+ const paths = docs.map((doc) => ({
13
+ params: { path: doc.id.replace('docs/', '') },
14
+ props: doc,
15
+ type: 'custom',
16
+ }));
17
+ return paths;
18
+ }) satisfies GetStaticPaths;
19
+
20
+ export const GET: APIRoute = async ({ params, props }) => {
21
+ // Just return empty array if LLMs are not enabled
22
+ if (!config.llmsTxt?.enabled) {
23
+ return new Response('llms.txt is not enabled for this Catalog.', { status: 404 });
24
+ }
25
+
26
+ if (props.filePath) {
27
+ const file = fs.readFileSync(props.filePath, 'utf8');
28
+ return new Response(file, { status: 200 });
29
+ }
30
+
31
+ return new Response('Not found', { status: 404 });
32
+ };
@@ -1,7 +1,10 @@
1
- import { getCollection } from 'astro:content';
1
+ import { getCollection, type CollectionEntry } from 'astro:content';
2
2
  import config from '@config';
3
3
  import type { APIRoute } from 'astro';
4
4
  import fs from 'fs';
5
+ import { isCustomDocsEnabled } from '@utils/feature';
6
+
7
+ type AllowedCollections = 'events' | 'commands' | 'queries' | 'services' | 'domains' | 'teams' | 'users' | 'customPages';
5
8
 
6
9
  const events = await getCollection('events');
7
10
  const commands = await getCollection('commands');
@@ -11,12 +14,26 @@ const domains = await getCollection('domains');
11
14
  const teams = await getCollection('teams');
12
15
  const users = await getCollection('users');
13
16
 
17
+ const customDocs = await getCollection('customPages');
18
+
14
19
  export const GET: APIRoute = async ({ params, request }) => {
15
20
  if (!config.llmsTxt?.enabled) {
16
21
  return new Response('llms.txt is not enabled for this Catalog.', { status: 404 });
17
22
  }
18
23
 
19
- const resources = [...events, ...commands, ...queries, ...services, ...domains, ...teams, ...users];
24
+ const resources: CollectionEntry<AllowedCollections>[] = [
25
+ ...events,
26
+ ...commands,
27
+ ...queries,
28
+ ...services,
29
+ ...domains,
30
+ ...teams,
31
+ ...users,
32
+ ];
33
+
34
+ if (isCustomDocsEnabled()) {
35
+ resources.push(...(customDocs as CollectionEntry<AllowedCollections>[]));
36
+ }
20
37
 
21
38
  const content = resources
22
39
  .map((item) => {
@@ -2,6 +2,8 @@ import { getCollection } from 'astro:content';
2
2
  import config from '@config';
3
3
  import type { APIRoute } from 'astro';
4
4
 
5
+ import { isCustomDocsEnabled } from '@utils/feature';
6
+
5
7
  const events = await getCollection('events');
6
8
  const commands = await getCollection('commands');
7
9
  const queries = await getCollection('queries');
@@ -12,6 +14,8 @@ const domains = await getCollection('domains');
12
14
  const teams = await getCollection('teams');
13
15
  const users = await getCollection('users');
14
16
 
17
+ const customDocs = await getCollection('customPages');
18
+
15
19
  export const GET: APIRoute = async ({ params, request }) => {
16
20
  const url = new URL(request.url);
17
21
  const baseUrl = `${url.protocol}//${url.host}`;
@@ -22,6 +26,9 @@ export const GET: APIRoute = async ({ params, request }) => {
22
26
  const formatSimpleItem = (item: any, type: string) =>
23
27
  `- [${item.id.replace('.mdx', '')}](${baseUrl}/docs/${type}/${item.data.id}.mdx) - ${item.data.name}`;
24
28
 
29
+ const formatCustomDoc = (item: any, route: string) =>
30
+ `- [${item.data.title}](${baseUrl}/${route}/${item.id.replace('docs\/', '')}.mdx) - ${item.data.summary || ''}`;
31
+
25
32
  const content = [
26
33
  `# ${config.organizationName} EventCatalog Documentation\n`,
27
34
  `> ${config.tagline}`,
@@ -39,6 +46,9 @@ export const GET: APIRoute = async ({ params, request }) => {
39
46
  teams.map((item) => formatSimpleItem(item, 'teams')).join('\n'),
40
47
  '\n## Users',
41
48
  users.map((item) => formatSimpleItem(item, 'users')).join('\n'),
49
+ ...(isCustomDocsEnabled()
50
+ ? ['\n## Custom Docs', customDocs.map((item) => formatCustomDoc(item, 'docs/custom')).join('\n')]
51
+ : []),
42
52
  ].join('\n');
43
53
 
44
54
  return new Response(content, {
@@ -97,3 +97,15 @@ export const findMatchingNodes = (
97
97
  });
98
98
  });
99
99
  };
100
+
101
+ export const resourceToCollectionMap = {
102
+ service: 'services',
103
+ event: 'events',
104
+ command: 'commands',
105
+ query: 'queries',
106
+ domain: 'domains',
107
+ flow: 'flows',
108
+ channel: 'channels',
109
+ user: 'users',
110
+ team: 'teams',
111
+ } as const;
@@ -0,0 +1,30 @@
1
+ // Method returns MDX components and there props in markdown files
2
+ // rarely used, but useful for components that need to know how many times
3
+ // the user wants to render a component in a markdown file
4
+ export const getMDXComponentsByName = (document: string, componentName: string) => {
5
+ // Define regex pattern to match <SchemaViewer ... />
6
+ const pattern = new RegExp(`<${componentName}\\s+([^>]*)\\/>`, 'g');
7
+
8
+ // Find all matches of the pattern
9
+ const matches = [...document.matchAll(pattern)];
10
+
11
+ // Extract the properties of each SchemaViewer
12
+ const components = matches.map((match) => {
13
+ const propsString = match[1];
14
+ const props = {};
15
+
16
+ // Use regex to extract key-value pairs from propsString
17
+ const propsPattern = /(\w+)=["']([^"']+)["']/g;
18
+ let propMatch;
19
+ while ((propMatch = propsPattern.exec(propsString)) !== null) {
20
+ const key = propMatch[1];
21
+ const value = propMatch[2];
22
+ // @ts-ignore
23
+ props[key] = value;
24
+ }
25
+
26
+ return props;
27
+ });
28
+
29
+ return components;
30
+ };
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": "2.33.0",
9
+ "version": "2.33.2",
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
@@ -42,7 +42,6 @@
42
42
  "@radix-ui/react-dialog": "^1.1.6",
43
43
  "@radix-ui/react-tooltip": "^1.1.8",
44
44
  "@scalar/api-reference-react": "^0.4.37",
45
- "@stoplight/json-schema-viewer": "^4.16.4",
46
45
  "@tailwindcss/typography": "^0.5.13",
47
46
  "@tanstack/react-table": "^8.17.3",
48
47
  "@xyflow/react": "^12.3.6",
@@ -69,7 +68,6 @@
69
68
  "lucide-react": "^0.453.0",
70
69
  "marked": "^15.0.6",
71
70
  "mermaid": "^11.4.1",
72
- "prismjs": "^1.29.0",
73
71
  "react": "^18.3.1",
74
72
  "react-dom": "^18.3.1",
75
73
  "rehype-slug": "^6.0.0",
@@ -1,62 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
-
3
- import 'prismjs';
4
- // @ts-ignore
5
- import { JsonSchemaViewer } from '@stoplight/json-schema-viewer';
6
- import './css/stoplight-mosaic-styles.css';
7
- import './css/stoplight-mosaic-theme-default.css';
8
-
9
- import { createPortal } from 'react-dom';
10
-
11
- type Props = {
12
- id: string;
13
- file: string;
14
- renderRootTreeLines?: boolean;
15
- hideExamples?: boolean;
16
- defaultExpandedDepth?: number;
17
- maxHeight?: string;
18
- schema: any;
19
- catalog: any;
20
- title?: string;
21
- };
22
-
23
- const SchemaViewer = ({
24
- id,
25
- maxHeight = '500',
26
- renderRootTreeLines = true,
27
- hideExamples = false,
28
- defaultExpandedDepth = 3,
29
- title,
30
- schema,
31
- }: Props) => {
32
- const [elem, setElem] = useState(null);
33
- useEffect(() => {
34
- // @ts-ignore
35
- setElem(document.getElementById(`${id}-SchemaViewer-portal`));
36
- }, []);
37
-
38
- if (!elem) return null;
39
-
40
- return (
41
- <div>
42
- {createPortal(
43
- <section className="not-prose space-y-2 ">
44
- {title && <h2 className="text-3xl font-bold">{title}</h2>}
45
- <div className="border border-gray-100 p-2 schemaViewer">
46
- <JsonSchemaViewer
47
- schema={schema}
48
- emptyText="No schema defined"
49
- maxHeight={parseInt(maxHeight, 10)}
50
- defaultExpandedDepth={defaultExpandedDepth}
51
- renderRootTreeLines={renderRootTreeLines}
52
- hideExamples={hideExamples}
53
- />
54
- </div>
55
- </section>,
56
- elem
57
- )}
58
- </div>
59
- );
60
- };
61
-
62
- export default SchemaViewer;