@eventcatalog/core 2.18.7 → 2.19.1

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 (29) 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-7GHQF4IY.js → chunk-BKWJZFAQ.js} +1 -1
  6. package/dist/{chunk-3B32CY7F.js → chunk-G3WSEVOS.js} +1 -1
  7. package/dist/{chunk-KIJRG7DY.js → chunk-HICY5YZU.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/package-lock.json +1074 -142
  13. package/eventcatalog/package.json +5 -4
  14. package/eventcatalog/src/components/MDX/Tabs/Tabs.astro +7 -3
  15. package/eventcatalog/src/components/SideBars/ChannelSideBar.astro +3 -2
  16. package/eventcatalog/src/components/SideBars/DomainSideBar.astro +4 -2
  17. package/eventcatalog/src/components/SideBars/MessageSideBar.astro +4 -2
  18. package/eventcatalog/src/components/SideBars/ServiceSideBar.astro +4 -2
  19. package/eventcatalog/src/content/config.ts +15 -1
  20. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/changelog/index.astro +2 -2
  21. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/index.astro +2 -2
  22. package/eventcatalog/src/pages/docs/[type]/[id]/language/[dictionaryId]/index.astro +232 -0
  23. package/eventcatalog/src/pages/docs/[type]/[id]/language.astro +19 -60
  24. package/eventcatalog/src/pages/visualiser/[type]/[id]/[version]/index.astro +2 -2
  25. package/eventcatalog/src/pages/visualiser/context-map/index.astro +2 -2
  26. package/eventcatalog/src/utils/collections/changelogs.ts +1 -1
  27. package/eventcatalog/src/utils/collections/owners.ts +43 -0
  28. package/eventcatalog/src/utils/collections/util.ts +31 -23
  29. package/package.json +6 -5
@@ -1,6 +1,6 @@
1
1
  import type { CollectionTypes } from '@types';
2
2
  import type { CollectionEntry } from 'astro:content';
3
- import { coerce, satisfies as satisfiesRange, compare } from 'semver';
3
+ import { coerce, compare, satisfies as satisfiesRange } from 'semver';
4
4
 
5
5
  export const getPreviousVersion = (version: string, versions: string[]) => {
6
6
  const index = versions.indexOf(version);
@@ -8,33 +8,43 @@ export const getPreviousVersion = (version: string, versions: string[]) => {
8
8
  };
9
9
 
10
10
  export const getVersions = (data: CollectionEntry<CollectionTypes>[]) => {
11
- const allVersions = data.map((item) => item.data.version).sort();
12
- const versions = [...new Set(allVersions)].reverse();
13
- const latestVersion = versions[0];
14
- return { versions, latestVersion };
11
+ const allVersions = data.map((item) => item.data.version);
12
+ const versions = [...new Set(allVersions)];
13
+ return sortStringVersions(versions);
15
14
  };
16
15
 
16
+ /**
17
+ * Sorts versioned items. Latest version first.
18
+ */
19
+ export function sortVersioned<T>(versioned: T[], versionExtractor: (e: T) => string): T[] {
20
+ // try to coerce semver versions from input version
21
+ const semverVersions = versioned.map((v) => ({ original: v, semver: coerce(versionExtractor(v)) }));
22
+
23
+ // if all versions are semver'ish, use semver to sort them
24
+ if (semverVersions.every((v) => v.semver != null)) {
25
+ const sorted = semverVersions.sort((a, b) => compare(b.semver!, a.semver!));
26
+
27
+ return sorted.map((v) => v.original);
28
+ } else {
29
+ // fallback to default sort
30
+ return versioned.sort((a, b) => versionExtractor(b).localeCompare(versionExtractor(a)));
31
+ }
32
+ }
33
+
17
34
  export const getVersionForCollectionItem = (
18
35
  item: CollectionEntry<CollectionTypes>,
19
36
  collection: CollectionEntry<CollectionTypes>[]
20
37
  ) => {
21
- const allVersionsForItem = collection
22
- .filter((i) => i.data.id === item.data.id)
23
- .map((i) => i.data.version)
24
- .sort();
38
+ const allVersionsForItem = collection.filter((i) => i.data.id === item.data.id);
25
39
 
26
- // unique versions
27
- const versions = [...new Set(allVersionsForItem)];
40
+ return getVersions(allVersionsForItem);
41
+ };
28
42
 
29
- // Use semver to order the versions
30
- const orderedVersions = versions.sort((a, b) => {
31
- return compare(b, a);
32
- });
43
+ export function sortStringVersions(versions: string[]) {
44
+ const sorted = sortVersioned(versions, (v) => v);
33
45
 
34
- const latestVersion = orderedVersions[0];
35
-
36
- return { versions, latestVersion };
37
- };
46
+ return { latestVersion: sorted[0], versions: sorted };
47
+ }
38
48
 
39
49
  /**
40
50
  * @param {string} version A valid version (number | v{\d+} | semver)
@@ -59,12 +69,10 @@ export const getItemsFromCollectionByIdAndSemverOrLatest = <T extends { data: {
59
69
  }
60
70
 
61
71
  // Order by version
62
- const sorted = filteredCollection.sort((a, b) => {
63
- return a.data.version.localeCompare(b.data.version);
64
- });
72
+ const sorted = sortVersioned(filteredCollection, (item) => item.data.version);
65
73
 
66
74
  // latest version
67
- return sorted.length > 0 ? [sorted[sorted.length - 1]] : [];
75
+ return sorted[0] != null ? [sorted[0]] : [];
68
76
  };
69
77
 
70
78
  export const findMatchingNodes = (
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.18.7",
9
+ "version": "2.19.1",
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
@@ -42,9 +42,9 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@astrojs/markdown-remark": "^6.0.1",
45
- "@astrojs/mdx": "^4.0.2",
46
- "@astrojs/react": "^4.1.0",
47
- "@astrojs/tailwind": "^5.1.3",
45
+ "@astrojs/mdx": "^4.0.5",
46
+ "@astrojs/react": "^4.1.3",
47
+ "@astrojs/tailwind": "^5.1.4",
48
48
  "@asyncapi/avro-schema-parser": "^3.0.24",
49
49
  "@asyncapi/react-component": "^2.4.3",
50
50
  "@headlessui/react": "^2.0.3",
@@ -56,7 +56,7 @@
56
56
  "@tailwindcss/typography": "^0.5.13",
57
57
  "@tanstack/react-table": "^8.17.3",
58
58
  "@xyflow/react": "^12.3.6",
59
- "astro": "^5.1.2",
59
+ "astro": "^5.1.5",
60
60
  "astro-expressive-code": "^0.38.3",
61
61
  "astro-pagefind": "^1.6.0",
62
62
  "astro-seo": "^0.8.4",
@@ -74,6 +74,7 @@
74
74
  "lodash.debounce": "^4.0.8",
75
75
  "lodash.merge": "4.6.2",
76
76
  "lucide-react": "^0.453.0",
77
+ "marked": "^15.0.6",
77
78
  "mermaid": "^11.4.1",
78
79
  "rapidoc": "^9.3.4",
79
80
  "react": "^18.3.1",