@eventcatalog/core 2.14.3 → 2.15.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 (229) hide show
  1. package/README.md +2 -1
  2. package/bin/eventcatalog.js +2 -0
  3. package/dist/analytics/analytics.cjs +71 -0
  4. package/dist/analytics/analytics.d.cts +3 -0
  5. package/dist/analytics/analytics.d.ts +3 -0
  6. package/dist/analytics/analytics.js +7 -0
  7. package/dist/analytics/log-build.cjs +155 -0
  8. package/dist/analytics/log-build.d.cts +7 -0
  9. package/dist/analytics/log-build.d.ts +7 -0
  10. package/dist/analytics/log-build.js +9 -0
  11. package/dist/catalog-to-astro-content-directory.cjs +277 -0
  12. package/dist/catalog-to-astro-content-directory.d.cts +3 -0
  13. package/dist/catalog-to-astro-content-directory.d.ts +3 -0
  14. package/dist/catalog-to-astro-content-directory.js +8 -0
  15. package/dist/chunk-65VQIGAP.js +33 -0
  16. package/{scripts/watcher.js → dist/chunk-7HYM3M5I.js} +29 -52
  17. package/dist/chunk-E7TXTI7G.js +78 -0
  18. package/dist/chunk-KI4KAUWW.js +30 -0
  19. package/dist/chunk-O6BGVVOW.js +86 -0
  20. package/dist/chunk-PK2EQVPD.js +89 -0
  21. package/dist/chunk-TGOUSS6C.js +9 -0
  22. package/dist/chunk-YEQVKHST.js +56 -0
  23. package/dist/constants.cjs +35 -0
  24. package/dist/constants.d.cts +3 -0
  25. package/dist/constants.d.ts +3 -0
  26. package/dist/constants.js +6 -0
  27. package/dist/eventcatalog-config-file-utils.cjs +116 -0
  28. package/dist/eventcatalog-config-file-utils.d.cts +7 -0
  29. package/dist/eventcatalog-config-file-utils.d.ts +7 -0
  30. package/dist/eventcatalog-config-file-utils.js +14 -0
  31. package/{bin/dist → dist}/eventcatalog.cjs +23 -33
  32. package/{bin/dist → dist}/eventcatalog.config.cjs +1 -1
  33. package/dist/eventcatalog.config.js +0 -0
  34. package/dist/eventcatalog.d.cts +2 -0
  35. package/dist/eventcatalog.d.ts +2 -0
  36. package/dist/eventcatalog.js +116 -0
  37. package/dist/generate.cjs +121 -0
  38. package/dist/generate.d.cts +3 -0
  39. package/dist/generate.d.ts +3 -0
  40. package/dist/generate.js +7 -0
  41. package/dist/map-catalog-to-astro.cjs +123 -0
  42. package/dist/map-catalog-to-astro.d.cts +28 -0
  43. package/dist/map-catalog-to-astro.d.ts +28 -0
  44. package/dist/map-catalog-to-astro.js +6 -0
  45. package/dist/watcher.cjs +223 -0
  46. package/dist/watcher.d.cts +21 -0
  47. package/dist/watcher.d.ts +21 -0
  48. package/dist/watcher.js +8 -0
  49. package/{src → eventcatalog/src}/components/MDX/NodeGraph/NodeGraph.tsx +27 -38
  50. package/eventcatalog/src/hooks/eventcatalog-visualizer.ts +89 -0
  51. package/{src → eventcatalog/src}/utils/node-graphs/message-node-graph.ts +2 -27
  52. package/{src → eventcatalog/src}/utils/node-graphs/utils/utils.ts +60 -3
  53. package/package.json +10 -3
  54. package/.all-contributorsrc +0 -436
  55. package/.changeset/config.json +0 -11
  56. package/.github/CODEOWNERS +0 -3
  57. package/.github/ISSUE_TEMPLATE/bug.yml +0 -84
  58. package/.github/ISSUE_TEMPLATE/config.yml +0 -5
  59. package/.github/ISSUE_TEMPLATE/feature.yml +0 -48
  60. package/.github/PULL_REQUEST_TEMPLATE.md +0 -14
  61. package/.github/funding.yml +0 -1
  62. package/.github/workflows/lint.yml +0 -22
  63. package/.github/workflows/release.yml +0 -34
  64. package/.github/workflows/test-bin.yml +0 -29
  65. package/.github/workflows/test-e2e.yml +0 -27
  66. package/.github/workflows/verify-build.yml +0 -28
  67. package/.prettierignore +0 -7
  68. package/.prettierrc +0 -18
  69. package/CHANGELOG.md +0 -1296
  70. package/bin/dist/eventcatalog.d.cts +0 -1
  71. package/bin/dist/eventcatalog.d.ts +0 -1
  72. package/bin/dist/eventcatalog.js +0 -531
  73. package/bin/eventcatalog.config.ts +0 -34
  74. package/images/example.png +0 -0
  75. package/images/sponsors/gravitee-logo-black.svg +0 -54
  76. package/images/sponsors/hookdeck.svg +0 -11
  77. package/images/sponsors/oso-logo-green.png +0 -0
  78. package/scripts/analytics/analytics.js +0 -31
  79. package/scripts/analytics/log-build.js +0 -26
  80. package/scripts/build-ci.js +0 -27
  81. package/scripts/catalog-to-astro-content-directory.js +0 -115
  82. package/scripts/ci/test.js +0 -24
  83. package/scripts/constants.ts +0 -3
  84. package/scripts/eventcatalog-config-file-utils.js +0 -89
  85. package/scripts/generate.js +0 -65
  86. package/scripts/map-catalog-to-astro.js +0 -174
  87. package/scripts/start-catalog-locally.js +0 -26
  88. /package/{bin/dist → dist}/eventcatalog.config.d.cts +0 -0
  89. /package/{bin/dist → dist}/eventcatalog.config.d.ts +0 -0
  90. /package/{astro.config.mjs → eventcatalog/astro.config.mjs} +0 -0
  91. /package/{global.d.ts → eventcatalog/global.d.ts} +0 -0
  92. /package/{public → eventcatalog/public}/favicon.ico +0 -0
  93. /package/{public → eventcatalog/public}/icons/asyncapi.svg +0 -0
  94. /package/{public → eventcatalog/public}/icons/discord.svg +0 -0
  95. /package/{public → eventcatalog/public}/icons/github-purple.svg +0 -0
  96. /package/{public → eventcatalog/public}/icons/github.svg +0 -0
  97. /package/{public → eventcatalog/public}/icons/ms-teams.svg +0 -0
  98. /package/{public → eventcatalog/public}/icons/openapi.svg +0 -0
  99. /package/{public → eventcatalog/public}/icons/protocols/kafka.svg +0 -0
  100. /package/{public → eventcatalog/public}/icons/x-twitter.svg +0 -0
  101. /package/{public → eventcatalog/public}/icons/youtube.svg +0 -0
  102. /package/{public → eventcatalog/public}/logo.png +0 -0
  103. /package/{public → eventcatalog/public}/openapi.yml +0 -0
  104. /package/{public → eventcatalog/public}/opengraph.png +0 -0
  105. /package/{public → eventcatalog/public}/slack-icon.svg +0 -0
  106. /package/{src → eventcatalog/src}/components/DiscoverInsight.astro +0 -0
  107. /package/{src → eventcatalog/src}/components/DocsNavigation.astro +0 -0
  108. /package/{src → eventcatalog/src}/components/Header.astro +0 -0
  109. /package/{src → eventcatalog/src}/components/Lists/OwnersList.tsx +0 -0
  110. /package/{src → eventcatalog/src}/components/Lists/PillList.tsx +0 -0
  111. /package/{src → eventcatalog/src}/components/Lists/PillListFlat.styles.css +0 -0
  112. /package/{src → eventcatalog/src}/components/Lists/PillListFlat.tsx +0 -0
  113. /package/{src → eventcatalog/src}/components/Lists/ProtocolList.tsx +0 -0
  114. /package/{src → eventcatalog/src}/components/Lists/RepositoryList.astro +0 -0
  115. /package/{src → eventcatalog/src}/components/Lists/SpecificationsList.astro +0 -0
  116. /package/{src → eventcatalog/src}/components/Lists/VersionList.astro +0 -0
  117. /package/{src → eventcatalog/src}/components/MDX/Accordion/Accordion.astro +0 -0
  118. /package/{src → eventcatalog/src}/components/MDX/Accordion/Accordion.tsx +0 -0
  119. /package/{src → eventcatalog/src}/components/MDX/Accordion/AccordionGroup.astro +0 -0
  120. /package/{src → eventcatalog/src}/components/MDX/Admonition.tsx +0 -0
  121. /package/{src → eventcatalog/src}/components/MDX/AsyncAPI/AsyncAPI.astro +0 -0
  122. /package/{src → eventcatalog/src}/components/MDX/ChannelInformation/ChannelInformation.tsx +0 -0
  123. /package/{src → eventcatalog/src}/components/MDX/File.tsx +0 -0
  124. /package/{src → eventcatalog/src}/components/MDX/Flow/Flow.astro +0 -0
  125. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/DownloadButton.tsx +0 -0
  126. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Edges/AnimatedMessageEdge.tsx +0 -0
  127. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/NodeGraph.astro +0 -0
  128. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/NodeGraphPortal.tsx +0 -0
  129. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Channel.tsx +0 -0
  130. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Command.tsx +0 -0
  131. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Event.tsx +0 -0
  132. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/ExternalSystem.tsx +0 -0
  133. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Query.tsx +0 -0
  134. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Service.tsx +0 -0
  135. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/Step.tsx +0 -0
  136. /package/{src → eventcatalog/src}/components/MDX/NodeGraph/Nodes/User.tsx +0 -0
  137. /package/{src → eventcatalog/src}/components/MDX/OpenAPI/OpenAPI.astro +0 -0
  138. /package/{src → eventcatalog/src}/components/MDX/Schema.astro +0 -0
  139. /package/{src → eventcatalog/src}/components/MDX/SchemaViewer/SchemaViewer.astro +0 -0
  140. /package/{src → eventcatalog/src}/components/MDX/SchemaViewer/SchemaViewer.tsx +0 -0
  141. /package/{src → eventcatalog/src}/components/MDX/SchemaViewer/SchemaViewerPortal.tsx +0 -0
  142. /package/{src → eventcatalog/src}/components/MDX/Steps/Step.astro +0 -0
  143. /package/{src → eventcatalog/src}/components/MDX/Steps/Steps.astro +0 -0
  144. /package/{src → eventcatalog/src}/components/MDX/Tiles/Tile.astro +0 -0
  145. /package/{src → eventcatalog/src}/components/MDX/Tiles/Tiles.astro +0 -0
  146. /package/{src → eventcatalog/src}/components/MDX/components.tsx +0 -0
  147. /package/{src → eventcatalog/src}/components/MDX/page-components.tsx +0 -0
  148. /package/{src → eventcatalog/src}/components/Search.astro +0 -0
  149. /package/{src → eventcatalog/src}/components/Seo.astro +0 -0
  150. /package/{src → eventcatalog/src}/components/SideBars/CatalogResourcesSideBar/index.tsx +0 -0
  151. /package/{src → eventcatalog/src}/components/SideBars/CatalogResourcesSideBar/styles.css +0 -0
  152. /package/{src → eventcatalog/src}/components/SideBars/ChannelSideBar.astro +0 -0
  153. /package/{src → eventcatalog/src}/components/SideBars/DomainSideBar.astro +0 -0
  154. /package/{src → eventcatalog/src}/components/SideBars/MessageSideBar.astro +0 -0
  155. /package/{src → eventcatalog/src}/components/SideBars/ServiceSideBar.astro +0 -0
  156. /package/{src → eventcatalog/src}/components/Tables/DebouncedInput.tsx +0 -0
  157. /package/{src → eventcatalog/src}/components/Tables/Table.tsx +0 -0
  158. /package/{src → eventcatalog/src}/components/Tables/columns/DomainTableColumns.tsx +0 -0
  159. /package/{src → eventcatalog/src}/components/Tables/columns/FlowTableColumns.tsx +0 -0
  160. /package/{src → eventcatalog/src}/components/Tables/columns/MessageTableColumns.tsx +0 -0
  161. /package/{src → eventcatalog/src}/components/Tables/columns/ServiceTableColumns.tsx +0 -0
  162. /package/{src → eventcatalog/src}/components/Tables/columns/index.tsx +0 -0
  163. /package/{src → eventcatalog/src}/components/Tables/filters/custom-filters.ts +0 -0
  164. /package/{src → eventcatalog/src}/content/config.ts +0 -0
  165. /package/{src → eventcatalog/src}/env.d.ts +0 -0
  166. /package/{src → eventcatalog/src}/icons/protocols/WebSocket.svg +0 -0
  167. /package/{src → eventcatalog/src}/icons/protocols/amqp.svg +0 -0
  168. /package/{src → eventcatalog/src}/icons/protocols/eventbridge.svg +0 -0
  169. /package/{src → eventcatalog/src}/icons/protocols/googlepubsub.svg +0 -0
  170. /package/{src → eventcatalog/src}/icons/protocols/http.svg +0 -0
  171. /package/{src → eventcatalog/src}/icons/protocols/index.ts +0 -0
  172. /package/{src → eventcatalog/src}/icons/protocols/jms.svg +0 -0
  173. /package/{src → eventcatalog/src}/icons/protocols/kafka.svg +0 -0
  174. /package/{src → eventcatalog/src}/icons/protocols/mercure.svg +0 -0
  175. /package/{src → eventcatalog/src}/icons/protocols/mqtt.svg +0 -0
  176. /package/{src → eventcatalog/src}/icons/protocols/nats.svg +0 -0
  177. /package/{src → eventcatalog/src}/icons/protocols/pulsar.svg +0 -0
  178. /package/{src → eventcatalog/src}/icons/protocols/redis.svg +0 -0
  179. /package/{src → eventcatalog/src}/icons/protocols/sns.svg +0 -0
  180. /package/{src → eventcatalog/src}/icons/protocols/solace.svg +0 -0
  181. /package/{src → eventcatalog/src}/icons/protocols/sqs.svg +0 -0
  182. /package/{src → eventcatalog/src}/icons/protocols/ws.svg +0 -0
  183. /package/{src → eventcatalog/src}/layouts/CustomDocsPageLayout.astro +0 -0
  184. /package/{src → eventcatalog/src}/layouts/DiscoverLayout.astro +0 -0
  185. /package/{src → eventcatalog/src}/layouts/Footer.astro +0 -0
  186. /package/{src → eventcatalog/src}/layouts/PlainPage.astro +0 -0
  187. /package/{src → eventcatalog/src}/layouts/VerticalSideBarLayout.astro +0 -0
  188. /package/{src → eventcatalog/src}/layouts/VisualiserLayout.astro +0 -0
  189. /package/{src → eventcatalog/src}/pages/discover/[type]/index.astro +0 -0
  190. /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/asyncapi/index.astro +0 -0
  191. /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/changelog/index.astro +0 -0
  192. /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/index.astro +0 -0
  193. /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/spec/_styles.css +0 -0
  194. /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/[version]/spec/index.astro +0 -0
  195. /package/{src → eventcatalog/src}/pages/docs/[type]/[id]/index.astro +0 -0
  196. /package/{src → eventcatalog/src}/pages/docs/index.astro +0 -0
  197. /package/{src → eventcatalog/src}/pages/docs/teams/[id]/index.astro +0 -0
  198. /package/{src → eventcatalog/src}/pages/docs/users/[id]/index.astro +0 -0
  199. /package/{src → eventcatalog/src}/pages/index.astro +0 -0
  200. /package/{src → eventcatalog/src}/pages/visualiser/[type]/[id]/[version]/index.astro +0 -0
  201. /package/{src → eventcatalog/src}/pages/visualiser/[type]/[id]/index.astro +0 -0
  202. /package/{src → eventcatalog/src}/remark-plugins/mermaid.ts +0 -0
  203. /package/{src → eventcatalog/src}/types/index.ts +0 -0
  204. /package/{src → eventcatalog/src}/utils/channels.ts +0 -0
  205. /package/{src → eventcatalog/src}/utils/collections/changelogs.ts +0 -0
  206. /package/{src → eventcatalog/src}/utils/collections/domains.ts +0 -0
  207. /package/{src → eventcatalog/src}/utils/collections/file-diffs.ts +0 -0
  208. /package/{src → eventcatalog/src}/utils/collections/flows.ts +0 -0
  209. /package/{src → eventcatalog/src}/utils/collections/icons.ts +0 -0
  210. /package/{src → eventcatalog/src}/utils/collections/services.ts +0 -0
  211. /package/{src → eventcatalog/src}/utils/collections/util.ts +0 -0
  212. /package/{src → eventcatalog/src}/utils/collections/versions.ts +0 -0
  213. /package/{src → eventcatalog/src}/utils/colors.ts +0 -0
  214. /package/{src → eventcatalog/src}/utils/commands.ts +0 -0
  215. /package/{src → eventcatalog/src}/utils/eventcatalog-config/catalog.ts +0 -0
  216. /package/{src → eventcatalog/src}/utils/events.ts +0 -0
  217. /package/{src → eventcatalog/src}/utils/example-remark-plugin.mjs +0 -0
  218. /package/{src → eventcatalog/src}/utils/messages.ts +0 -0
  219. /package/{src → eventcatalog/src}/utils/node-graphs/domains-node-graph.ts +0 -0
  220. /package/{src → eventcatalog/src}/utils/node-graphs/flows-node-graph.ts +0 -0
  221. /package/{src → eventcatalog/src}/utils/node-graphs/services-node-graph.ts +0 -0
  222. /package/{src → eventcatalog/src}/utils/page-loaders/page-data-loader.ts +0 -0
  223. /package/{src → eventcatalog/src}/utils/pages.ts +0 -0
  224. /package/{src → eventcatalog/src}/utils/queries.ts +0 -0
  225. /package/{src → eventcatalog/src}/utils/teams.ts +0 -0
  226. /package/{src → eventcatalog/src}/utils/url-builder.ts +0 -0
  227. /package/{src → eventcatalog/src}/utils/users.ts +0 -0
  228. /package/{tailwind.config.mjs → eventcatalog/tailwind.config.mjs} +0 -0
  229. /package/{tsconfig.json → eventcatalog/tsconfig.json} +0 -0
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/watcher.js
31
+ var watcher_exports = {};
32
+ __export(watcher_exports, {
33
+ watch: () => watch
34
+ });
35
+ module.exports = __toCommonJS(watcher_exports);
36
+ var import_watcher = __toESM(require("@parcel/watcher"), 1);
37
+ var import_node_fs2 = __toESM(require("fs"), 1);
38
+
39
+ // src/map-catalog-to-astro.js
40
+ var import_node_path = __toESM(require("path"), 1);
41
+ var COLLECTION_KEYS = [
42
+ "events",
43
+ "commands",
44
+ "services",
45
+ "users",
46
+ "teams",
47
+ "domains",
48
+ "flows",
49
+ "pages",
50
+ "changelogs",
51
+ "queries",
52
+ "channels"
53
+ ];
54
+ function mapCatalogToAstro({ filePath, astroDir, projectDir }) {
55
+ const relativeFilePath = removeBasePath(filePath, projectDir);
56
+ if (!isCatalogRelated(relativeFilePath)) {
57
+ return [];
58
+ }
59
+ const baseTargetPaths = getBaseTargetPaths(relativeFilePath);
60
+ const relativeTargetPath = getRelativeTargetPath(relativeFilePath);
61
+ return baseTargetPaths.map(
62
+ (base) => import_node_path.default.join(astroDir, base, relativeTargetPath.replace("index.md", "index.mdx").replace("changelog.md", "changelog.mdx"))
63
+ );
64
+ }
65
+ function removeBasePath(fullPath, basePath) {
66
+ const relativePath = import_node_path.default.relative(basePath, fullPath);
67
+ return relativePath.startsWith("..") ? fullPath : relativePath;
68
+ }
69
+ function isCollectionKey(key) {
70
+ return COLLECTION_KEYS.includes(key);
71
+ }
72
+ function isCatalogRelated(filePath) {
73
+ const filePathArr = filePath.split(import_node_path.default.sep).filter(Boolean);
74
+ if ([
75
+ "eventcatalog.config.js",
76
+ // config file at root
77
+ "eventcatalog.styles.css",
78
+ // custom styles file at root
79
+ "components",
80
+ // custom components
81
+ "public",
82
+ // public assets
83
+ ...COLLECTION_KEYS
84
+ ].includes(filePathArr[0])) {
85
+ return true;
86
+ }
87
+ return false;
88
+ }
89
+ function getBaseTargetPaths(filePath) {
90
+ const filePathArr = filePath.split(import_node_path.default.sep).filter(Boolean);
91
+ if (isCollectionKey(filePathArr[0])) {
92
+ if (filePathArr[filePathArr.length - 1] == "changelog.md") {
93
+ return [import_node_path.default.join("src", "content", "changelogs")];
94
+ }
95
+ if (filePathArr[filePathArr.length - 1].match(/\.md$/)) {
96
+ return [import_node_path.default.join("src", "content")];
97
+ }
98
+ const hasExtension = (str) => /\.[a-zA-Z0-9]{2,}$/.test(str);
99
+ if (hasExtension(filePath)) {
100
+ return [import_node_path.default.join("public", "generated"), import_node_path.default.join("src", "catalog-files")];
101
+ }
102
+ return [import_node_path.default.join("public", "generated"), import_node_path.default.join("src", "catalog-files"), import_node_path.default.join("src", "content")];
103
+ }
104
+ if (filePathArr[0] == "components") {
105
+ return [import_node_path.default.join("src", "custom-defined-components")];
106
+ }
107
+ if (filePathArr[0] == "public") {
108
+ return [import_node_path.default.join("public")];
109
+ }
110
+ return [import_node_path.default.join("/")];
111
+ }
112
+ function getRelativeTargetPath(filePath) {
113
+ const filePathArr = filePath.split(import_node_path.default.sep).filter(Boolean);
114
+ if (filePathArr[0] == "public" || filePathArr[0] == "components") {
115
+ filePathArr.shift();
116
+ }
117
+ const relativePath = [];
118
+ for (let i = filePathArr.length - 1; i >= 0; i--) {
119
+ relativePath.unshift(filePathArr[i]);
120
+ if (isCollectionKey(filePathArr[i])) break;
121
+ }
122
+ return import_node_path.default.join(...relativePath);
123
+ }
124
+
125
+ // src/watcher.js
126
+ var import_rimraf = require("rimraf");
127
+
128
+ // src/eventcatalog-config-file-utils.js
129
+ var import_promises = require("fs/promises");
130
+ var import_node_fs = require("fs");
131
+ var import_promises2 = require("fs/promises");
132
+ var import_node_path2 = __toESM(require("path"), 1);
133
+ var import_uuid = require("uuid");
134
+ var import_gray_matter = __toESM(require("gray-matter"), 1);
135
+ function addPropertyToFrontMatter(input, newProperty, newValue) {
136
+ const file = (0, import_gray_matter.default)(input);
137
+ return import_gray_matter.default.stringify(file.content, { ...file.data, [newProperty]: newValue });
138
+ }
139
+
140
+ // src/watcher.js
141
+ async function watch(projectDirectory, catalogDirectory, callback = void 0) {
142
+ const subscription = await import_watcher.default.subscribe(
143
+ projectDirectory,
144
+ compose(
145
+ /**
146
+ * @param {Error|null} err
147
+ * @param {Event[]} events
148
+ * @returns {unknown}
149
+ */
150
+ (err, events) => {
151
+ if (err) {
152
+ return;
153
+ }
154
+ for (let event of events) {
155
+ const { path: filePath, type } = event;
156
+ const astroPaths = mapCatalogToAstro({
157
+ filePath,
158
+ astroDir: catalogDirectory,
159
+ projectDir: projectDirectory
160
+ });
161
+ for (const astroPath of astroPaths) {
162
+ switch (type) {
163
+ case "create":
164
+ case "update":
165
+ try {
166
+ if (astroPath.endsWith(".mdx")) {
167
+ const content = import_node_fs2.default.readFileSync(astroPath, "utf-8");
168
+ const frontmatter = addPropertyToFrontMatter(content, "pathToFile", filePath);
169
+ import_node_fs2.default.writeFileSync(astroPath, frontmatter);
170
+ }
171
+ } catch (error) {
172
+ }
173
+ if (import_node_fs2.default.statSync(filePath).isDirectory()) import_node_fs2.default.mkdirSync(astroPath, { recursive: true });
174
+ else retryEPERM(import_node_fs2.default.cpSync)(filePath, astroPath);
175
+ break;
176
+ case "delete":
177
+ retryEPERM(import_rimraf.rimrafSync)(astroPath);
178
+ break;
179
+ }
180
+ }
181
+ }
182
+ },
183
+ callback
184
+ ),
185
+ {
186
+ ignore: [`**/${catalogDirectory}/!(${projectDirectory})**`]
187
+ }
188
+ );
189
+ return () => subscription.unsubscribe();
190
+ }
191
+ function compose(...fns) {
192
+ return function(err, events) {
193
+ fns.filter(Boolean).forEach((fn, i) => {
194
+ try {
195
+ fn(err, events);
196
+ } catch (error) {
197
+ console.error({ error });
198
+ throw error;
199
+ }
200
+ });
201
+ };
202
+ }
203
+ var MAX_RETRIES = 5;
204
+ var DELAY_MS = 100;
205
+ function retryEPERM(fn) {
206
+ return (...args) => {
207
+ let retries = 0;
208
+ while (retries < MAX_RETRIES) {
209
+ try {
210
+ return fn(...args);
211
+ } catch (err) {
212
+ if (err.code !== "EPERM") throw err;
213
+ setTimeout(() => {
214
+ }, DELAY_MS);
215
+ retries += 1;
216
+ }
217
+ }
218
+ };
219
+ }
220
+ // Annotate the CommonJS export names for ESM import in node:
221
+ 0 && (module.exports = {
222
+ watch
223
+ });
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @typedef {Object} Event
3
+ * @property {string} path
4
+ * @property {"create"|"update"|"delete"} type
5
+ *
6
+ * @typedef {(err: Error | null, events: Event[]) => unknown} SubscribeCallback
7
+ */
8
+ /**
9
+ *
10
+ * @param {string} projectDirectory
11
+ * @param {string} catalogDirectory
12
+ * @param {SubscribeCallback|undefined} callback
13
+ */
14
+ declare function watch(projectDirectory: string, catalogDirectory: string, callback?: SubscribeCallback | undefined): Promise<() => Promise<void>>;
15
+ type Event = {
16
+ path: string;
17
+ type: "create" | "update" | "delete";
18
+ };
19
+ type SubscribeCallback = (err: Error | null, events: Event[]) => unknown;
20
+
21
+ export { type Event, type SubscribeCallback, watch };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @typedef {Object} Event
3
+ * @property {string} path
4
+ * @property {"create"|"update"|"delete"} type
5
+ *
6
+ * @typedef {(err: Error | null, events: Event[]) => unknown} SubscribeCallback
7
+ */
8
+ /**
9
+ *
10
+ * @param {string} projectDirectory
11
+ * @param {string} catalogDirectory
12
+ * @param {SubscribeCallback|undefined} callback
13
+ */
14
+ declare function watch(projectDirectory: string, catalogDirectory: string, callback?: SubscribeCallback | undefined): Promise<() => Promise<void>>;
15
+ type Event = {
16
+ path: string;
17
+ type: "create" | "update" | "delete";
18
+ };
19
+ type SubscribeCallback = (err: Error | null, events: Event[]) => unknown;
20
+
21
+ export { type Event, type SubscribeCallback, watch };
@@ -0,0 +1,8 @@
1
+ import {
2
+ watch
3
+ } from "./chunk-7HYM3M5I.js";
4
+ import "./chunk-E7TXTI7G.js";
5
+ import "./chunk-PK2EQVPD.js";
6
+ export {
7
+ watch
8
+ };
@@ -11,9 +11,6 @@ import ReactFlow, {
11
11
  type Edge,
12
12
  type Node,
13
13
  useReactFlow,
14
- getBezierPath,
15
- BaseEdge,
16
- SmoothStepEdge,
17
14
  } from 'reactflow';
18
15
  import 'reactflow/dist/style.css';
19
16
 
@@ -34,7 +31,7 @@ import DownloadButton from './DownloadButton';
34
31
  import { buildUrl } from '@utils/url-builder';
35
32
  import ChannelNode from './Nodes/Channel';
36
33
  import { CogIcon } from '@heroicons/react/20/solid';
37
-
34
+ import { useEventCatalogVisualiser } from 'src/hooks/eventcatalog-visualizer';
38
35
  interface Props {
39
36
  nodes: any;
40
37
  edges: any;
@@ -85,7 +82,7 @@ const NodeGraphBuilder = ({
85
82
  const [isSettingsOpen, setIsSettingsOpen] = useState(false);
86
83
  const [isAnimated, setIsAnimated] = useState(false);
87
84
  const [animateMessages, setAnimateMessages] = useState(false);
88
-
85
+ const { hideChannels, toggleChannelsVisibility } = useEventCatalogVisualiser({ nodes, edges, setNodes, setEdges });
89
86
  const { fitView } = useReactFlow();
90
87
 
91
88
  const resetNodesAndEdges = useCallback(() => {
@@ -162,16 +159,6 @@ const NodeGraphBuilder = ({
162
159
  [nodes, edges, setNodes, setEdges, resetNodesAndEdges, fitView]
163
160
  );
164
161
 
165
- const toggleAnimation = () => {
166
- setIsAnimated(!isAnimated);
167
- setEdges((eds) =>
168
- eds.map((edge) => ({
169
- ...edge,
170
- animated: !isAnimated,
171
- }))
172
- );
173
- };
174
-
175
162
  const toggleAnimateMessages = () => {
176
163
  setAnimateMessages(!animateMessages);
177
164
  localStorage.setItem('EventCatalog:animateMessages', JSON.stringify(!animateMessages));
@@ -196,6 +183,10 @@ const NodeGraphBuilder = ({
196
183
  );
197
184
  }, [animateMessages]);
198
185
 
186
+ useEffect(() => {
187
+ fitView({ duration: 800 });
188
+ }, [nodes, edges]);
189
+
199
190
  const handlePaneClick = useCallback(() => {
200
191
  setIsSettingsOpen(false);
201
192
  resetNodesAndEdges();
@@ -319,6 +310,27 @@ const NodeGraphBuilder = ({
319
310
  </div>
320
311
  <p className="text-[10px] text-gray-500">Animate events, queries and commands.</p>
321
312
  </div>
313
+ <div>
314
+ <div className="flex items-center justify-between">
315
+ <label htmlFor="message-animation-toggle" className="text-sm font-medium text-gray-700">
316
+ Hide Channels
317
+ </label>
318
+ <button
319
+ id="message-animation-toggle"
320
+ onClick={toggleChannelsVisibility}
321
+ className={`${
322
+ hideChannels ? 'bg-purple-600' : 'bg-gray-200'
323
+ } relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-purple-500 focus:ring-offset-2`}
324
+ >
325
+ <span
326
+ className={`${
327
+ hideChannels ? 'translate-x-6' : 'translate-x-1'
328
+ } inline-block h-4 w-4 transform rounded-full bg-white transition-transform`}
329
+ />
330
+ </button>
331
+ </div>
332
+ <p className="text-[10px] text-gray-500">Show or hide channels in the visualizer.</p>
333
+ </div>
322
334
  </div>
323
335
  </div>
324
336
  )}
@@ -341,29 +353,6 @@ const NodeGraphBuilder = ({
341
353
  </li>
342
354
  ))}
343
355
  </ul>
344
- {/* <span className="font-bold">Key</span> */}
345
- {/* <ul className="m-0 p-0">
346
- <li className="flex space-x-2 items-center text-[10px]">
347
- <span className="w-2 h-2 bg-orange-500 block" />
348
- <span className="block">Events</span>
349
- </li>
350
- <li className="flex space-x-2 items-center text-[10px]">
351
- <span className="w-2 h-2 bg-pink-500 block" />
352
- <span className="block">Service</span>
353
- </li>
354
- <li className="flex space-x-2 items-center text-[10px]">
355
- <span className="w-2 h-2 bg-blue-500 block" />
356
- <span className="block">Command</span>
357
- </li>
358
- <li className="flex space-x-2 items-center text-[10px]">
359
- <span className="w-2 h-2 bg-green-500 block" />
360
- <span className="block">Query</span>
361
- </li>
362
- <li className="flex space-x-2 items-center text-[10px]">
363
- <span className="w-2 h-2 bg-gray-500 block" />
364
- <span className="block">Channel</span>
365
- </li>
366
- </ul> */}
367
356
  </div>
368
357
  </Panel>
369
358
  )}
@@ -0,0 +1,89 @@
1
+ import { useCallback, useMemo, useState, useEffect } from 'react';
2
+ import { type Edge, type Node } from 'reactflow';
3
+ import {
4
+ createEdge,
5
+ generatedIdForEdge,
6
+ generateIdForNode,
7
+ getEdgeLabelForMessageAsSource,
8
+ getEdgeLabelForServiceAsTarget,
9
+ getNodesAndEdgesFromDagre,
10
+ } from '@utils/node-graphs/utils/utils';
11
+
12
+ interface EventCatalogVisualizerProps {
13
+ nodes: Node[];
14
+ edges: Edge[];
15
+ setNodes: (nodes: Node[]) => void;
16
+ setEdges: (edges: Edge[]) => void;
17
+ }
18
+
19
+ export const useEventCatalogVisualiser = ({ nodes, edges, setNodes, setEdges }: EventCatalogVisualizerProps) => {
20
+ const [hideChannels, setHideChannels] = useState(false);
21
+ const [initialNodes] = useState(nodes);
22
+ const [initialEdges] = useState(edges);
23
+
24
+ // Initialize hideChannels from localStorage
25
+ useEffect(() => {
26
+ const storedHideChannels = localStorage.getItem('EventCatalog:hideChannels');
27
+ if (storedHideChannels !== null) {
28
+ setHideChannels(storedHideChannels === 'true');
29
+ }
30
+ }, []);
31
+
32
+ const toggleChannelsVisibility = useCallback(() => {
33
+ setHideChannels((prev) => {
34
+ const newValue = !prev;
35
+ localStorage.setItem('EventCatalog:hideChannels', JSON.stringify(newValue));
36
+ return newValue;
37
+ });
38
+ }, []);
39
+
40
+ const channels = useMemo(() => nodes.filter((node) => node.type === 'channels'), [nodes]);
41
+ const updatedNodes = useMemo(() => nodes.filter((node) => node.type !== 'channels'), [nodes]);
42
+
43
+ const updatedEdges = useMemo(() => {
44
+ return edges.reduce<Edge[]>((acc, edge) => {
45
+ const { source, target, data } = edge;
46
+ const targetIsChannel = channels.some((channel) => channel.id === target);
47
+ const sourceIsChannel = channels.some((channel) => channel.id === source);
48
+
49
+ if (!sourceIsChannel && !targetIsChannel) {
50
+ return [...acc, edge];
51
+ }
52
+
53
+ if (sourceIsChannel) {
54
+ const edgeLabel =
55
+ data.target.collection === 'services'
56
+ ? getEdgeLabelForMessageAsSource(data.source)
57
+ : getEdgeLabelForServiceAsTarget(data.target);
58
+
59
+ return [
60
+ ...acc,
61
+ createEdge({
62
+ id: generatedIdForEdge(data.source, data.target),
63
+ source: generateIdForNode(data.source),
64
+ target: generateIdForNode(data.target),
65
+ label: edgeLabel,
66
+ }),
67
+ ];
68
+ }
69
+
70
+ return [...acc, edge];
71
+ }, []);
72
+ }, [edges, channels]);
73
+
74
+ useEffect(() => {
75
+ if (hideChannels) {
76
+ const { nodes: newNodes, edges: newEdges } = getNodesAndEdgesFromDagre({ nodes: updatedNodes, edges: updatedEdges });
77
+ setNodes(newNodes);
78
+ setEdges(newEdges);
79
+ } else {
80
+ setNodes(initialNodes);
81
+ setEdges(initialEdges);
82
+ }
83
+ }, [hideChannels]);
84
+
85
+ return {
86
+ hideChannels,
87
+ toggleChannelsVisibility,
88
+ };
89
+ };
@@ -9,6 +9,8 @@ import {
9
9
  generatedIdForEdge,
10
10
  generateIdForNode,
11
11
  getChannelNodesAndEdges,
12
+ getEdgeLabelForMessageAsSource,
13
+ getEdgeLabelForServiceAsTarget,
12
14
  } from './utils/utils';
13
15
  import { MarkerType } from 'reactflow';
14
16
  import { findMatchingNodes } from '@utils/collections/util';
@@ -26,33 +28,6 @@ interface Props {
26
28
  collection?: CollectionEntry<CollectionMessageTypes>[];
27
29
  }
28
30
 
29
- const getEdgeLabelForServiceAsTarget = (data: CollectionEntry<CollectionMessageTypes>) => {
30
- const type = data.collection;
31
- switch (type) {
32
- case 'commands':
33
- return 'invokes';
34
- case 'events':
35
- return 'publishes event';
36
- case 'queries':
37
- return 'requests';
38
- default:
39
- return 'sends to';
40
- }
41
- };
42
- const getEdgeLabelForMessageAsSource = (data: CollectionEntry<CollectionMessageTypes>) => {
43
- const type = data.collection;
44
- switch (type) {
45
- case 'commands':
46
- return 'accepts';
47
- case 'events':
48
- return 'subscribed by';
49
- case 'queries':
50
- return 'accepts';
51
- default:
52
- return 'sends to';
53
- }
54
- };
55
-
56
31
  const getNodesAndEdges = async ({ id, version, defaultFlow, mode = 'simple', collection = [] }: Props) => {
57
32
  const flow = defaultFlow || createDagreGraph({ ranksep: 300, nodesep: 50 });
58
33
  const nodes = [] as any,
@@ -2,7 +2,7 @@ import { getCollection, type CollectionEntry } from 'astro:content';
2
2
  import { MarkerType, Position, type Edge, type Node } from 'reactflow';
3
3
  import dagre from 'dagre';
4
4
  import { getItemsFromCollectionByIdAndSemverOrLatest } from '@utils/collections/util';
5
- import type { CollectionTypes } from '@types';
5
+ import type { CollectionMessageTypes, CollectionTypes } from '@types';
6
6
 
7
7
  export const generateIdForNode = (node: CollectionEntry<CollectionTypes>) => {
8
8
  return `${node.data.id}-${node.data.version}`;
@@ -14,6 +14,33 @@ export const generatedIdForEdge = (source: CollectionEntry<CollectionTypes>, tar
14
14
  return `${source.data.id}-${source.data.version}-${target.data.id}-${target.data.version}`;
15
15
  };
16
16
 
17
+ export const getEdgeLabelForServiceAsTarget = (data: CollectionEntry<CollectionMessageTypes>) => {
18
+ const type = data.collection;
19
+ switch (type) {
20
+ case 'commands':
21
+ return 'invokes';
22
+ case 'events':
23
+ return 'publishes event';
24
+ case 'queries':
25
+ return 'requests';
26
+ default:
27
+ return 'sends to';
28
+ }
29
+ };
30
+ export const getEdgeLabelForMessageAsSource = (data: CollectionEntry<CollectionMessageTypes>) => {
31
+ const type = data.collection;
32
+ switch (type) {
33
+ case 'commands':
34
+ return 'accepts';
35
+ case 'events':
36
+ return 'subscribed by';
37
+ case 'queries':
38
+ return 'accepts';
39
+ default:
40
+ return 'sends to';
41
+ }
42
+ };
43
+
17
44
  export const calculatedNodes = (flow: dagre.graphlib.Graph, nodes: Node[]) => {
18
45
  return nodes.map((node: any) => {
19
46
  const { x, y } = flow.node(node.id);
@@ -107,7 +134,7 @@ export const getChannelNodesAndEdges = ({
107
134
  target: channelId,
108
135
  label: '',
109
136
  // label: sourceToChannelLabel,
110
- data: { message: edgeMessage },
137
+ data: { message: edgeMessage, source: edgeMessage, channel, target },
111
138
  })
112
139
  );
113
140
 
@@ -119,10 +146,40 @@ export const getChannelNodesAndEdges = ({
119
146
  source: channelId,
120
147
  target: generateIdForNode(target),
121
148
  label: channelToTargetLabel,
122
- data: { message: edgeMessage },
149
+ data: { message: edgeMessage, source, channel, target },
123
150
  })
124
151
  );
125
152
  });
126
153
 
127
154
  return { nodes, edges };
128
155
  };
156
+
157
+ type DagreGraph = any;
158
+
159
+ export const getNodesAndEdgesFromDagre = ({
160
+ nodes,
161
+ edges,
162
+ defaultFlow,
163
+ }: {
164
+ nodes: Node[];
165
+ edges: Edge[];
166
+ defaultFlow?: DagreGraph;
167
+ }) => {
168
+ const flow = defaultFlow || createDagreGraph({ ranksep: 300, nodesep: 50 });
169
+
170
+ nodes.forEach((node: any) => {
171
+ flow.setNode(node.id, { width: 150, height: 100 });
172
+ });
173
+
174
+ edges.forEach((edge: any) => {
175
+ flow.setEdge(edge.source, edge.target);
176
+ });
177
+
178
+ // Render the diagram in memory getting hte X and Y
179
+ dagre.layout(flow);
180
+
181
+ return {
182
+ nodes: calculatedNodes(flow, nodes),
183
+ edges,
184
+ };
185
+ };
package/package.json CHANGED
@@ -6,18 +6,25 @@
6
6
  "url": "https://github.com/event-catalog/eventcatalog.git"
7
7
  },
8
8
  "type": "module",
9
- "version": "2.14.3",
9
+ "version": "2.15.0",
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
13
  "bin": {
14
- "eventcatalog": "bin/dist/eventcatalog.cjs"
14
+ "eventcatalog": "bin/eventcatalog.js"
15
15
  },
16
+ "files": [
17
+ "eventcatalog/",
18
+ "!eventcatalog/**/__tests__/",
19
+ "bin/",
20
+ "dist/",
21
+ "default-files-for-collections/"
22
+ ],
16
23
  "scripts": {
17
24
  "dev": "astro dev",
18
25
  "build:bin": "tsup",
19
26
  "prepublishOnly": "npm run build:bin",
20
- "test": "vitest --config vitest.config.ts",
27
+ "test": "vitest",
21
28
  "test:ci": "node scripts/ci/test.js",
22
29
  "test:e2e": "playwright test",
23
30
  "start": "astro dev",