@eventcatalog/core 2.8.4 → 2.8.6

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.
@@ -410,6 +410,15 @@
410
410
  "contributions": [
411
411
  "doc"
412
412
  ]
413
+ },
414
+ {
415
+ "login": "d-o-h",
416
+ "name": "d-o-h",
417
+ "avatar_url": "https://avatars.githubusercontent.com/u/23699653?v=4",
418
+ "profile": "https://github.com/d-o-h",
419
+ "contributions": [
420
+ "code"
421
+ ]
413
422
  }
414
423
  ],
415
424
  "contributorsPerLine": 7,
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @eventcatalog/core
2
2
 
3
+ ## 2.8.6
4
+
5
+ ### Patch Changes
6
+
7
+ - b4c49ef: feat(core): added links to the landing page and fixed resource counter values
8
+
9
+ ## 2.8.5
10
+
11
+ ### Patch Changes
12
+
13
+ - db41392: fix(core): flows now work with latest semver for services
14
+ - 8376da8: chore(core): fixed url builder for server/client components
15
+
3
16
  ## 2.8.4
4
17
 
5
18
  ### Patch Changes
package/README.md CHANGED
@@ -29,7 +29,7 @@
29
29
  <h4>Features: Documentation generator for Event Driven Architectures, Markdown driven, Document Domains/Services/Messages/Schemas and more, Content versioning, Assign Owners, Schemas, OpenAPI, MDX Components and more...</h4>
30
30
 
31
31
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
32
- [![All Contributors](https://img.shields.io/badge/all_contributors-43-orange.svg?style=flat-square)](#contributors-)
32
+ [![All Contributors](https://img.shields.io/badge/all_contributors-44-orange.svg?style=flat-square)](#contributors-)
33
33
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
34
34
 
35
35
  [Read the Docs](https://eventcatalog.dev/) | [Edit the Docs](https://github.com/event-catalog/docs) | [View Demo](https://demo.eventcatalog.dev/docs)
@@ -228,6 +228,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
228
228
  </tr>
229
229
  <tr>
230
230
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/hpatoio"><img src="https://avatars.githubusercontent.com/u/249948?v=4?s=100" width="100px;" alt="Simone Fumagalli"/><br /><sub><b>Simone Fumagalli</b></sub></a><br /><a href="https://github.com/event-catalog/eventcatalog/commits?author=hpatoio" title="Documentation">📖</a></td>
231
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/d-o-h"><img src="https://avatars.githubusercontent.com/u/23699653?v=4?s=100" width="100px;" alt="d-o-h"/><br /><sub><b>d-o-h</b></sub></a><br /><a href="https://github.com/event-catalog/eventcatalog/commits?author=d-o-h" title="Code">💻</a></td>
231
232
  </tr>
232
233
  </tbody>
233
234
  </table>
package/astro.config.mjs CHANGED
@@ -48,6 +48,15 @@ export default defineConfig({
48
48
  pagefind(),
49
49
  ],
50
50
  vite: {
51
+ define: {
52
+ /**
53
+ * Trailing slash is exposed as global variable here principally for `@utils/url-builder`.
54
+ * The utility is used by client components and because of that it can't direct import
55
+ * the eventcatalog.config, as the config use packages that only run in node environments,
56
+ * such as `node:path`.
57
+ */
58
+ '__EC_TRAILING_SLASH__': config.trailingSlash || false,
59
+ },
51
60
  build: {
52
61
  commonjsOptions: {
53
62
  transformMixedEsModules: true,
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.8.4",
9
+ "version": "2.8.6",
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
@@ -41,7 +41,6 @@
41
41
  "@astrojs/react": "^3.6.2",
42
42
  "@astrojs/tailwind": "^5.1.2",
43
43
  "@asyncapi/react-component": "^2.2.2",
44
- "@changesets/cli": "^2.27.5",
45
44
  "@headlessui/react": "^2.0.3",
46
45
  "@heroicons/react": "^2.1.3",
47
46
  "@parcel/watcher": "^2.4.1",
@@ -82,6 +81,7 @@
82
81
  "@types/semver": "^7.5.8"
83
82
  },
84
83
  "devDependencies": {
84
+ "@changesets/cli": "^2.27.5",
85
85
  "@types/react": "^18.3.3",
86
86
  "@types/react-dom": "^18.3.0",
87
87
  "prettier": "^3.3.3",
@@ -0,0 +1,52 @@
1
+ ---
2
+ import { buildUrl } from '@utils/url-builder';
3
+ import type React from 'react';
4
+
5
+ interface Props {
6
+ color: string;
7
+ dataTarget: number;
8
+ icon: React.ElementType;
9
+ label: 'domains' | 'services' | 'commands' | 'events' | 'flows';
10
+ }
11
+
12
+ const { color, dataTarget, icon: Icon, label } = Astro.props;
13
+ ---
14
+
15
+ <div class={`relative text-center ${color}`}>
16
+ <div class="flex justify-center mb-2">
17
+ <Icon className="w-8 h-8" />
18
+ </div>
19
+
20
+ <div class="text-2xl font-bold mb-1">
21
+ <span class="statistic" data-target={dataTarget}>0</span>
22
+ </div>
23
+
24
+ <a
25
+ href={buildUrl(`/discover/${label}`)}
26
+ class="static before:block before:absolute before:top-0 before:left-0 before:z-0 before:w-full before:h-full hover:underline underline-offset-8 text-sm text-gray-600 capitalize"
27
+ >
28
+ {label}
29
+ </a>
30
+ </div>
31
+
32
+ <script>
33
+ function animateStatistics() {
34
+ const statistics = document.querySelectorAll('.statistic');
35
+ statistics.forEach((statistic) => {
36
+ let target = parseInt(statistic.getAttribute('data-target')!);
37
+ let current = 0;
38
+ const increment = target / 50;
39
+ const timer = setInterval(() => {
40
+ current += increment;
41
+ if (current >= target) {
42
+ clearInterval(timer);
43
+ statistic.textContent = target.toString();
44
+ } else {
45
+ statistic.textContent = Math.round(current).toString();
46
+ }
47
+ }, 20);
48
+ });
49
+ }
50
+
51
+ window.addEventListener('load', animateStatistics);
52
+ </script>
@@ -5,8 +5,6 @@ import { getNodesAndEdges as getNodesAndEdgesForEvent } from '@utils/events/node
5
5
  import { getNodesAndEdges as getNodesAndEdgesForCommand } from '@utils/commands/node-graph';
6
6
  import { getNodesAndEdges as getNodesAndEdgesForDomain } from '@utils/domains/node-graph';
7
7
  import { getNodesAndEdges as getNodesAndEdgesForFlows } from '@utils/flows/node-graph';
8
- import { buildUrl } from '@utils/url-builder';
9
- import config from '@eventcatalog';
10
8
 
11
9
  interface Props {
12
10
  id: string;
@@ -80,13 +78,6 @@ if (collection === 'flows') {
80
78
  nodes = eventNodes;
81
79
  edges = eventEdges;
82
80
  }
83
-
84
- const getDocUrlForCollection = () => {
85
- return buildUrl(`/docs/${collection}/${id}/${version}`);
86
- };
87
- const getVisualiserUrlForCollection = () => {
88
- return buildUrl(`/visualiser/${collection}/${id}/${version}`);
89
- };
90
81
  ---
91
82
 
92
83
  <div>
@@ -99,7 +90,6 @@ const getVisualiserUrlForCollection = () => {
99
90
  href={href.url}
100
91
  linkTo={linkTo}
101
92
  client:only="react"
102
- urlHasTrailingSlash={config.trailingSlash}
103
93
  linksToVisualiser={linksToVisualiser}
104
94
  />
105
95
  </div>
@@ -23,7 +23,7 @@ import type { CollectionEntry } from 'astro:content';
23
23
  import { navigate } from 'astro:transitions/client';
24
24
  import type { CollectionTypes } from '@types';
25
25
  import DownloadButton from './DownloadButton';
26
- import { buildUrl } from '@utils/url-builder-client';
26
+ import { buildUrl } from '@utils/url-builder';
27
27
 
28
28
  interface Props {
29
29
  nodes: any;
@@ -34,18 +34,14 @@ interface Props {
34
34
  includeControls?: boolean;
35
35
  linkTo: 'docs' | 'visualiser';
36
36
  includeKey?: boolean;
37
- urlHasTrailingSlash?: boolean;
38
37
  linksToVisualiser?: boolean;
39
38
  }
40
39
 
41
- const getDocUrlForCollection = (collectionItem: CollectionEntry<CollectionTypes>, trailingSlash?: boolean) => {
42
- return buildUrl(`/docs/${collectionItem.collection}/${collectionItem.data.id}/${collectionItem.data.version}`, trailingSlash);
40
+ const getDocUrlForCollection = (collectionItem: CollectionEntry<CollectionTypes>) => {
41
+ return buildUrl(`/docs/${collectionItem.collection}/${collectionItem.data.id}/${collectionItem.data.version}`);
43
42
  };
44
- const getVisualiserUrlForCollection = (collectionItem: CollectionEntry<CollectionTypes>, trailingSlash?: boolean) => {
45
- return buildUrl(
46
- `/visualiser/${collectionItem.collection}/${collectionItem.data.id}/${collectionItem.data.version}`,
47
- trailingSlash
48
- );
43
+ const getVisualiserUrlForCollection = (collectionItem: CollectionEntry<CollectionTypes>) => {
44
+ return buildUrl(`/visualiser/${collectionItem.collection}/${collectionItem.data.id}/${collectionItem.data.version}`);
49
45
  };
50
46
 
51
47
  const NodeGraphBuilder = ({
@@ -55,7 +51,6 @@ const NodeGraphBuilder = ({
55
51
  includeBackground = true,
56
52
  linkTo = 'docs',
57
53
  includeKey = true,
58
- urlHasTrailingSlash,
59
54
  linksToVisualiser = false,
60
55
  }: Props) => {
61
56
  const nodeTypes = useMemo(
@@ -93,10 +88,10 @@ const NodeGraphBuilder = ({
93
88
  (_: any, node: Node) => {
94
89
  if (linksToVisualiser) {
95
90
  if (node.type === 'events' || node.type === 'commands') {
96
- navigate(getVisualiserUrlForCollection(node.data.message, urlHasTrailingSlash));
91
+ navigate(getVisualiserUrlForCollection(node.data.message));
97
92
  }
98
93
  if (node.type === 'services') {
99
- navigate(getVisualiserUrlForCollection(node.data.service, urlHasTrailingSlash));
94
+ navigate(getVisualiserUrlForCollection(node.data.service));
100
95
  }
101
96
  return;
102
97
  }
@@ -198,7 +193,6 @@ interface NodeGraphProps {
198
193
  linkTo: 'docs' | 'visualiser';
199
194
  includeKey?: boolean;
200
195
  footerLabel?: string;
201
- urlHasTrailingSlash?: boolean;
202
196
  linksToVisualiser?: boolean;
203
197
  }
204
198
 
@@ -212,7 +206,6 @@ const NodeGraph = ({
212
206
  hrefLabel = 'Open in visualizer',
213
207
  includeKey = true,
214
208
  footerLabel,
215
- urlHasTrailingSlash,
216
209
  linksToVisualiser = false,
217
210
  }: NodeGraphProps) => {
218
211
  const [elem, setElem] = useState(null);
@@ -234,7 +227,6 @@ const NodeGraph = ({
234
227
  title={title}
235
228
  linkTo={linkTo}
236
229
  includeKey={includeKey}
237
- urlHasTrailingSlash={urlHasTrailingSlash}
238
230
  linksToVisualiser={linksToVisualiser}
239
231
  />
240
232
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  import type { ComponentType } from 'react';
3
3
  import * as Icons from '@heroicons/react/24/solid';
4
- import { buildUrl } from '@utils/url-builder-client';
4
+ import { buildUrl } from '@utils/url-builder';
5
5
 
6
6
  interface Props {
7
7
  href: string;
package/src/env.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  /// <reference path="../.astro/types.d.ts" />
2
2
  /// <reference types="astro/client" />
3
+
4
+ declare const __EC_TRAILING_SLASH__: boolean;
@@ -8,6 +8,7 @@ import { getMessages } from '@utils/messages';
8
8
  import { getDomains } from '@utils/domains/domains';
9
9
  import { getServices } from '@utils/services/services';
10
10
  import { getFlows } from '@utils/flows/flows';
11
+ import DiscoverInsight from '@components/DiscoverInsight.astro';
11
12
 
12
13
  const { commands = [], events = [] } = await getMessages();
13
14
  const domains = await getDomains();
@@ -30,138 +31,61 @@ const flows = await getFlows();
30
31
  <h2 class="text-center text-xl font-bold">Architecture insights</h2>
31
32
  <section class="mb-16 bg-white rounded-xl shadow-lg p-6">
32
33
  <div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4">
33
- <div class="text-center">
34
- <div class="flex justify-center mb-2">
35
- <RectangleGroupIcon className="w-8 h-8 text-yellow-600" />
36
- </div>
37
- <div class="text-2xl font-bold text-yellow-600 mb-1">
38
- <span class="statistic" data-target="5">0</span>
39
- </div>
40
- <div class="text-sm text-gray-600">Domains</div>
41
- </div>
42
- <div class="text-center">
43
- <div class="flex justify-center mb-2">
44
- <ServerIcon className="w-8 h-8 text-pink-500" />
45
- </div>
46
- <div class="text-2xl font-bold text-pink-500 mb-1">
47
- <span class="statistic" data-target="12">0</span>
48
- </div>
49
- <div class="text-sm text-gray-600">Services</div>
50
- </div>
51
- <div class="text-center">
52
- <div class="flex justify-center mb-2">
53
- <ChatBubbleLeftIcon className="w-8 h-8 text-blue-500" />
54
- </div>
55
- <div class="text-2xl font-bold text-blue-500 mb-1">
56
- <span class="statistic" data-target="30">0</span>
57
- </div>
58
- <div class="text-sm text-gray-600">Commands</div>
59
- </div>
60
- <div class="text-center">
61
- <div class="flex justify-center mb-2">
62
- <BoltIcon className="w-8 h-8 text-orange-400" />
63
- </div>
64
- <div class="text-2xl font-bold text-orange-400 mb-1">
65
- <span class="statistic" data-target="20">0</span>
66
- </div>
67
- <div class="text-sm text-gray-600">Events</div>
68
- </div>
34
+ <DiscoverInsight color="text-yellow-600" dataTarget={domains.length} icon={RectangleGroupIcon} label="domains" />
69
35
 
70
- <div class="text-center">
71
- <div class="flex justify-center mb-2">
72
- <QueueListIcon className="w-8 h-8 text-green-800" />
73
- </div>
74
- <div class="text-2xl font-bold text-green-800 mb-1">
75
- <span class="statistic" data-target="8">0</span>
76
- </div>
77
- <div class="text-sm text-gray-600">Flows</div>
78
- </div>
36
+ <DiscoverInsight color="text-pink-500" dataTarget={services.length} icon={ServerIcon} label="services" />
37
+
38
+ <DiscoverInsight color="text-blue-500" dataTarget={commands.length} icon={ChatBubbleLeftIcon} label="commands" />
39
+
40
+ <DiscoverInsight color="text-orange-400" dataTarget={events.length} icon={BoltIcon} label="events" />
41
+
42
+ <DiscoverInsight color="text-green-800" dataTarget={flows.length} icon={QueueListIcon} label="flows" />
79
43
  </div>
80
44
  </section>
81
- </div>
82
45
 
83
- <section class="grid grid-cols-1 md:grid-cols-3 gap-8 mb-16">
84
- <div
85
- class="bg-white rounded-xl shadow-lg overflow-hidden hover:shadow-xl transition duration-300 transform hover:-translate-y-1"
86
- >
87
- <div class="h-2 bg-blue-400"></div>
88
- <div class="p-6">
89
- <h2 class="text-2xl font-semibold mb-4 text-blue-700">Documentation</h2>
90
- <p class="text-gray-600 mb-4">
91
- Create and maintain comprehensive documentation for your events, including schemas, examples, and versioning.
92
- </p>
93
- <a href={buildUrl('/docs')} class="text-blue-600 hover:text-blue-800 font-semibold">Explore docs →</a>
46
+ <section class="grid grid-cols-1 md:grid-cols-3 gap-8 mb-16">
47
+ <div
48
+ class="bg-white rounded-xl shadow-lg overflow-hidden hover:shadow-xl transition duration-300 transform hover:-translate-y-1"
49
+ >
50
+ <div class="h-2 bg-blue-400"></div>
51
+ <div class="p-6">
52
+ <h2 class="text-2xl font-semibold mb-4 text-blue-700">Documentation</h2>
53
+ <p class="text-gray-600 mb-4">
54
+ Create and maintain comprehensive documentation for your events, including schemas, examples, and versioning.
55
+ </p>
56
+ <a href={buildUrl('/docs')} class="text-blue-600 hover:text-blue-800 font-semibold">Explore docs →</a>
57
+ </div>
94
58
  </div>
95
- </div>
96
- <div
97
- class="bg-white rounded-xl shadow-lg overflow-hidden hover:shadow-xl transition duration-300 transform hover:-translate-y-1"
98
- >
99
- <div class="h-2 bg-teal-400"></div>
100
- <div class="p-6">
101
- <h2 class="text-2xl font-semibold mb-4 text-teal-700">Visualiser</h2>
102
- <p class="text-gray-600 mb-4">
103
- Transform complex event flows into clear, interactive diagrams. Gain insights at a glance and communicate
104
- effectively across teams.
105
- </p>
106
- <a href={buildUrl('/visualiser')} class="text-teal-600 hover:text-teal-800 font-semibold">Explore visualiser →</a>
59
+ <div
60
+ class="bg-white rounded-xl shadow-lg overflow-hidden hover:shadow-xl transition duration-300 transform hover:-translate-y-1"
61
+ >
62
+ <div class="h-2 bg-teal-400"></div>
63
+ <div class="p-6">
64
+ <h2 class="text-2xl font-semibold mb-4 text-teal-700">Visualiser</h2>
65
+ <p class="text-gray-600 mb-4">
66
+ Transform complex event flows into clear, interactive diagrams. Gain insights at a glance and communicate
67
+ effectively across teams.
68
+ </p>
69
+ <a href={buildUrl('/visualiser')} class="text-teal-600 hover:text-teal-800 font-semibold">Explore visualiser →</a>
70
+ </div>
107
71
  </div>
108
- </div>
109
72
 
110
- <div
111
- class="bg-white rounded-xl shadow-lg overflow-hidden hover:shadow-xl transition duration-300 transform hover:-translate-y-1"
112
- >
113
- <div class="h-2 bg-red-700"></div>
114
- <div class="p-6">
115
- <h2 class="text-2xl font-semibold mb-4 text-red-700">Discover</h2>
116
- <p class="text-gray-600 mb-4">
117
- Dive deep into your event catalog. Search, filter, and analyze your events to gain insights and improve your
118
- architecture.
119
- </p>
120
- <a href={buildUrl('/discover/events')} class="text-red-600 hover:text-red-800 font-semibold">Start exploring →</a>
73
+ <div
74
+ class="bg-white rounded-xl shadow-lg overflow-hidden hover:shadow-xl transition duration-300 transform hover:-translate-y-1"
75
+ >
76
+ <div class="h-2 bg-red-700"></div>
77
+ <div class="p-6">
78
+ <h2 class="text-2xl font-semibold mb-4 text-red-700">Discover</h2>
79
+ <p class="text-gray-600 mb-4">
80
+ Dive deep into your event catalog. Search, filter, and analyze your events to gain insights and improve your
81
+ architecture.
82
+ </p>
83
+ <a href={buildUrl('/discover/events')} class="text-red-600 hover:text-red-800 font-semibold">Start exploring →</a>
84
+ </div>
121
85
  </div>
122
- </div>
123
- </section>
86
+ </section>
87
+ </div>
124
88
  </main>
125
-
126
- <script define:vars={{ domains, services, commands, events, flows }}>
127
- function animateStatistics() {
128
- const statistics = document.querySelectorAll('.statistic');
129
- statistics.forEach((statistic) => {
130
- let target;
131
- switch (statistic.parentElement.nextElementSibling.textContent.trim()) {
132
- case 'Domains':
133
- target = domains.length;
134
- break;
135
- case 'Services':
136
- target = services.length;
137
- break;
138
- case 'Commands':
139
- target = commands.length;
140
- break;
141
- case 'Events':
142
- target = events.length;
143
- break;
144
- case 'Flows':
145
- target = flows.length;
146
- break;
147
- default:
148
- target = parseInt(statistic.getAttribute('data-target'));
149
- }
150
- let current = 0;
151
- const increment = target / 50;
152
- const timer = setInterval(() => {
153
- current += increment;
154
- statistic.textContent = Math.round(current);
155
- if (current >= target) {
156
- clearInterval(timer);
157
- statistic.textContent = target;
158
- }
159
- }, 20);
160
- });
161
- }
162
-
163
- window.addEventListener('load', animateStatistics);
164
- </script>
165
89
  </body>
166
90
  </PlainPage>
167
91
 
@@ -16,9 +16,8 @@ interface Props {
16
16
  }
17
17
 
18
18
  const getServiceNode = (step: any, services: CollectionEntry<'services'>[]) => {
19
- const service = services.find(
20
- (service) => service.data.id === step.service.id && service.data.version === step.service.version
21
- );
19
+ const servicesForVersion = getItemsFromCollectionByIdAndSemverOrLatest(services, step.service.id, step.service.version);
20
+ const service = servicesForVersion?.[0];
22
21
  return {
23
22
  ...step,
24
23
  type: service ? service.collection : 'step',
@@ -1,5 +1,3 @@
1
- import config from '@eventcatalog';
2
-
3
1
  const cleanUrl = (url: string) => {
4
2
  return url.replace(/\/+/g, '/');
5
3
  };
@@ -7,7 +5,7 @@ const cleanUrl = (url: string) => {
7
5
  // Custom URL builder as Astro does not support this stuff out the box
8
6
  export const buildUrl = (url: string, ignoreTrailingSlash = false) => {
9
7
  // Should a trailingSlash be added to urls?
10
- const trailingSlash = config.trailingSlash || false;
8
+ const trailingSlash = __EC_TRAILING_SLASH__;
11
9
 
12
10
  let newUrl = url;
13
11
 
@@ -1,22 +0,0 @@
1
- const cleanUrl = (url: string) => {
2
- return url.replace(/\/+/g, '/');
3
- };
4
-
5
- // Custom URL builder as Astro does not support this stuff out the box.
6
- // Used on client components to build URLs
7
- export const buildUrl = (url: string, trailingSlash = false, ignoreTrailingSlash = false) => {
8
- let newUrl = url;
9
-
10
- // If the base URL is not the root, we need to append it
11
- if (import.meta.env.BASE_URL !== '/') {
12
- newUrl = `${import.meta.env.BASE_URL}${url}`;
13
- }
14
-
15
- // Should we add a trailing slash to the url?
16
- if (trailingSlash && !ignoreTrailingSlash) {
17
- if (url.endsWith('/')) return newUrl;
18
- return cleanUrl(`${newUrl}/`);
19
- }
20
-
21
- return cleanUrl(newUrl);
22
- };