@eventcatalog/core 2.8.3 → 2.8.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @eventcatalog/core
2
2
 
3
+ ## 2.8.5
4
+
5
+ ### Patch Changes
6
+
7
+ - db41392: fix(core): flows now work with latest semver for services
8
+ - 8376da8: chore(core): fixed url builder for server/client components
9
+
10
+ ## 2.8.4
11
+
12
+ ### Patch Changes
13
+
14
+ - 95ca9aa: chore(core): removed type checks for consuming catalogs
15
+
3
16
  ## 2.8.3
4
17
 
5
18
  ### Patch Changes
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.3",
9
+ "version": "2.8.5",
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
@@ -21,7 +21,7 @@
21
21
  "test": "vitest --config vitest.config.ts",
22
22
  "test:ci": "node scripts/ci/test.js",
23
23
  "start": "astro dev",
24
- "build": "npm run scripts:hydrate-content && node scripts/analytics/log-build.js && astro check --minimumSeverity error && astro build",
24
+ "build": "npm run scripts:hydrate-content && node scripts/analytics/log-build.js && astro build",
25
25
  "build:cd": "node scripts/build-ci.js",
26
26
  "preview": "astro preview",
27
27
  "astro": "astro",
@@ -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",
@@ -16,7 +16,10 @@ fs.copyFileSync(join(projectDIR, 'eventcatalog.config.js'), join(catalogDir, 'ev
16
16
 
17
17
  fs.copyFileSync(join(projectDIR, 'eventcatalog.styles.css'), join(catalogDir, 'eventcatalog.styles.css'));
18
18
 
19
- execSync(`cross-env NODE_ENV=CI PROJECT_DIR=${projectDIR} CATALOG_DIR=${catalogDir} npm run build`, {
20
- cwd: catalogDir,
21
- stdio: 'inherit',
22
- });
19
+ execSync(
20
+ `cross-env NODE_ENV=CI PROJECT_DIR=${projectDIR} CATALOG_DIR=${catalogDir} npm run build && astro check --minimumSeverity error`,
21
+ {
22
+ cwd: catalogDir,
23
+ stdio: 'inherit',
24
+ }
25
+ );
@@ -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;
@@ -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
- };