@eventcatalog/core 4.11.2 → 4.12.0-beta.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 (243) 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 +17 -11
  4. package/dist/analytics/log-build.js +4 -4
  5. package/dist/astro-config-path.cjs +51 -0
  6. package/dist/astro-config-path.d.cts +6 -0
  7. package/dist/astro-config-path.d.ts +6 -0
  8. package/dist/astro-config-path.js +6 -0
  9. package/dist/catalog-runtime.cjs +136 -0
  10. package/dist/catalog-runtime.d.cts +12 -0
  11. package/dist/catalog-runtime.d.ts +12 -0
  12. package/dist/catalog-runtime.js +8 -0
  13. package/dist/{chunk-B7HCX5HM.js → chunk-3SJDIENM.js} +1 -1
  14. package/dist/{chunk-AFPH6ERZ.js → chunk-5QRWGO2E.js} +1 -1
  15. package/dist/{chunk-6U72KINX.js → chunk-DJCOJ77J.js} +1 -0
  16. package/dist/{chunk-LHR4G2UO.js → chunk-EEZXGNF6.js} +1 -1
  17. package/dist/{chunk-XMRPNDXB.js → chunk-ISBBAOCD.js} +1 -1
  18. package/dist/{chunk-Z6OKCHWL.js → chunk-IUPFEQMU.js} +2 -2
  19. package/dist/{chunk-6QENHZZP.js → chunk-JE6RX7SJ.js} +11 -5
  20. package/dist/{chunk-LAWEGSJH.js → chunk-LU4GFIHH.js} +1 -1
  21. package/dist/{chunk-2YJRF4ZX.js → chunk-RYPZGCRN.js} +1 -1
  22. package/dist/chunk-SAN4U2WU.js +96 -0
  23. package/dist/{chunk-EGH3ALRY.js → chunk-TVLJNFDW.js} +4 -4
  24. package/dist/chunk-U63GDPPY.js +14 -0
  25. package/dist/chunk-VIJJ7JKH.js +17 -0
  26. package/dist/constants.cjs +1 -1
  27. package/dist/constants.js +1 -1
  28. package/dist/eventcatalog-config-file-utils.cjs +13 -7
  29. package/dist/eventcatalog-config-file-utils.d.cts +86 -2
  30. package/dist/eventcatalog-config-file-utils.d.ts +86 -2
  31. package/dist/eventcatalog-config-file-utils.js +1 -1
  32. package/dist/eventcatalog.cjs +227 -561
  33. package/dist/eventcatalog.js +62 -71
  34. package/dist/features.cjs +10 -6
  35. package/dist/features.js +2 -2
  36. package/dist/federation/federate.cjs +110 -106
  37. package/dist/federation/federate.js +4 -4
  38. package/dist/generate.cjs +11 -7
  39. package/dist/generate.js +4 -4
  40. package/dist/resolve-catalog-dependencies.cjs +12 -8
  41. package/dist/resolve-catalog-dependencies.js +2 -2
  42. package/dist/runtime-dependencies/@ai-sdk__react.mjs +3 -0
  43. package/dist/runtime-dependencies/@astrojs__markdown-remark.mjs +3 -0
  44. package/dist/runtime-dependencies/@astrojs__mdx.mjs +3 -0
  45. package/dist/runtime-dependencies/@astrojs__node.mjs +3 -0
  46. package/dist/runtime-dependencies/@astrojs__react.mjs +3 -0
  47. package/dist/runtime-dependencies/@astrojs__rss.mjs +3 -0
  48. package/dist/runtime-dependencies/@asyncapi__avro-schema-parser.mjs +3 -0
  49. package/dist/runtime-dependencies/@asyncapi__parser.mjs +3 -0
  50. package/dist/runtime-dependencies/@asyncapi__react-component.mjs +3 -0
  51. package/dist/runtime-dependencies/@asyncapi__react-component__styles__default.min.css.mjs +3 -0
  52. package/dist/runtime-dependencies/@auth__core.mjs +3 -0
  53. package/dist/runtime-dependencies/@auth__core__providers__auth0.mjs +3 -0
  54. package/dist/runtime-dependencies/@auth__core__providers__github.mjs +3 -0
  55. package/dist/runtime-dependencies/@auth__core__providers__google.mjs +3 -0
  56. package/dist/runtime-dependencies/@auth__core__providers__microsoft-entra-id.mjs +3 -0
  57. package/dist/runtime-dependencies/@auth__core__providers__okta.mjs +3 -0
  58. package/dist/runtime-dependencies/@auth__core__types.mjs +3 -0
  59. package/dist/runtime-dependencies/@eventcatalog__license.mjs +3 -0
  60. package/dist/runtime-dependencies/@eventcatalog__linter.mjs +3 -0
  61. package/dist/runtime-dependencies/@eventcatalog__sdk.mjs +3 -0
  62. package/dist/runtime-dependencies/@eventcatalog__visualiser.mjs +3 -0
  63. package/dist/runtime-dependencies/@eventcatalog__visualiser__styles-core.css.mjs +3 -0
  64. package/dist/runtime-dependencies/@fontsource__inter.mjs +3 -0
  65. package/dist/runtime-dependencies/@fontsource__inter__400.css.mjs +3 -0
  66. package/dist/runtime-dependencies/@fontsource__inter__700.css.mjs +3 -0
  67. package/dist/runtime-dependencies/@headlessui__react.mjs +3 -0
  68. package/dist/runtime-dependencies/@heroicons__react.mjs +3 -0
  69. package/dist/runtime-dependencies/@heroicons__react__16__solid__EnvelopeIcon.mjs +3 -0
  70. package/dist/runtime-dependencies/@heroicons__react__20__solid.mjs +3 -0
  71. package/dist/runtime-dependencies/@heroicons__react__24__outline.mjs +3 -0
  72. package/dist/runtime-dependencies/@heroicons__react__24__outline__MagnifyingGlassIcon.mjs +3 -0
  73. package/dist/runtime-dependencies/@heroicons__react__24__outline__RectangleGroupIcon.mjs +3 -0
  74. package/dist/runtime-dependencies/@heroicons__react__24__outline__ServerIcon.mjs +3 -0
  75. package/dist/runtime-dependencies/@heroicons__react__24__solid.mjs +3 -0
  76. package/dist/runtime-dependencies/@iconify-json__logos.mjs +3 -0
  77. package/dist/runtime-dependencies/@mermaid-js__layout-elk.mjs +3 -0
  78. package/dist/runtime-dependencies/@mermaid-js__layout-elk__dist__mermaid-layout-elk.core.mjs.mjs +3 -0
  79. package/dist/runtime-dependencies/@modelcontextprotocol__sdk.mjs +3 -0
  80. package/dist/runtime-dependencies/@modelcontextprotocol__sdk__server__mcp.js.mjs +3 -0
  81. package/dist/runtime-dependencies/@modelcontextprotocol__sdk__server__webStandardStreamableHttp.js.mjs +3 -0
  82. package/dist/runtime-dependencies/@nanostores__react.mjs +3 -0
  83. package/dist/runtime-dependencies/@parcel__watcher.mjs +3 -0
  84. package/dist/runtime-dependencies/@radix-ui__react-context-menu.mjs +3 -0
  85. package/dist/runtime-dependencies/@radix-ui__react-dialog.mjs +3 -0
  86. package/dist/runtime-dependencies/@radix-ui__react-dropdown-menu.mjs +3 -0
  87. package/dist/runtime-dependencies/@radix-ui__react-popover.mjs +3 -0
  88. package/dist/runtime-dependencies/@radix-ui__react-tooltip.mjs +3 -0
  89. package/dist/runtime-dependencies/@scalar__api-reference-react.mjs +3 -0
  90. package/dist/runtime-dependencies/@scalar__api-reference-react__style.css.mjs +3 -0
  91. package/dist/runtime-dependencies/@tailwindcss__typography.mjs +3 -0
  92. package/dist/runtime-dependencies/@tailwindcss__vite.mjs +3 -0
  93. package/dist/runtime-dependencies/@tanstack__react-table.mjs +3 -0
  94. package/dist/runtime-dependencies/@xyflow__react.mjs +3 -0
  95. package/dist/runtime-dependencies/@xyflow__react__dist__style.css.mjs +3 -0
  96. package/dist/runtime-dependencies/ai.mjs +3 -0
  97. package/dist/runtime-dependencies/astro-expressive-code.mjs +3 -0
  98. package/dist/runtime-dependencies/astro-expressive-code__components.mjs +3 -0
  99. package/dist/runtime-dependencies/astro-seo.mjs +3 -0
  100. package/dist/runtime-dependencies/astro.mjs +3 -0
  101. package/dist/runtime-dependencies/astro__assets__services__sharp.mjs +3 -0
  102. package/dist/runtime-dependencies/astro__config.mjs +3 -0
  103. package/dist/runtime-dependencies/astro__jsx-runtime.mjs +3 -0
  104. package/dist/runtime-dependencies/astro__loaders.mjs +3 -0
  105. package/dist/runtime-dependencies/astro__logger__node.mjs +3 -0
  106. package/dist/runtime-dependencies/astro__types.mjs +3 -0
  107. package/dist/runtime-dependencies/astro__zod.mjs +3 -0
  108. package/dist/runtime-dependencies/auth-astro.mjs +3 -0
  109. package/dist/runtime-dependencies/auth-astro__client.mjs +3 -0
  110. package/dist/runtime-dependencies/auth-astro__server.mjs +3 -0
  111. package/dist/runtime-dependencies/boxen.mjs +3 -0
  112. package/dist/runtime-dependencies/commander.mjs +3 -0
  113. package/dist/runtime-dependencies/cross-env.mjs +3 -0
  114. package/dist/runtime-dependencies/d3-drag.mjs +3 -0
  115. package/dist/runtime-dependencies/d3-force.mjs +3 -0
  116. package/dist/runtime-dependencies/d3-selection.mjs +3 -0
  117. package/dist/runtime-dependencies/d3-zoom.mjs +3 -0
  118. package/dist/runtime-dependencies/dagre.mjs +3 -0
  119. package/dist/runtime-dependencies/diff.mjs +3 -0
  120. package/dist/runtime-dependencies/diff2html.mjs +3 -0
  121. package/dist/runtime-dependencies/diff2html__bundles__css__diff2html.min.css.mjs +3 -0
  122. package/dist/runtime-dependencies/dotenv.mjs +3 -0
  123. package/dist/runtime-dependencies/elkjs.mjs +3 -0
  124. package/dist/runtime-dependencies/elkjs__lib__elk.bundled.js.mjs +3 -0
  125. package/dist/runtime-dependencies/glob.mjs +3 -0
  126. package/dist/runtime-dependencies/gray-matter.mjs +3 -0
  127. package/dist/runtime-dependencies/hono.mjs +3 -0
  128. package/dist/runtime-dependencies/html-to-image.mjs +3 -0
  129. package/dist/runtime-dependencies/js-yaml.mjs +3 -0
  130. package/dist/runtime-dependencies/jsonpath-plus.mjs +3 -0
  131. package/dist/runtime-dependencies/jsonwebtoken.mjs +3 -0
  132. package/dist/runtime-dependencies/lodash.debounce.mjs +3 -0
  133. package/dist/runtime-dependencies/lodash.merge.mjs +3 -0
  134. package/dist/runtime-dependencies/lucide-react.mjs +3 -0
  135. package/dist/runtime-dependencies/manifest.json +136 -0
  136. package/dist/runtime-dependencies/marked.mjs +3 -0
  137. package/dist/runtime-dependencies/mdast-util-find-and-replace.mjs +3 -0
  138. package/dist/runtime-dependencies/mermaid.mjs +3 -0
  139. package/dist/runtime-dependencies/minisearch.mjs +3 -0
  140. package/dist/runtime-dependencies/nanostores.mjs +3 -0
  141. package/dist/runtime-dependencies/pagefind.mjs +3 -0
  142. package/dist/runtime-dependencies/pako.mjs +3 -0
  143. package/dist/runtime-dependencies/parse5.mjs +3 -0
  144. package/dist/runtime-dependencies/picocolors.mjs +3 -0
  145. package/dist/runtime-dependencies/picomatch.mjs +3 -0
  146. package/dist/runtime-dependencies/react-dom.mjs +3 -0
  147. package/dist/runtime-dependencies/react-dom__client.mjs +3 -0
  148. package/dist/runtime-dependencies/react-dom__server.mjs +3 -0
  149. package/dist/runtime-dependencies/react-markdown.mjs +3 -0
  150. package/dist/runtime-dependencies/react-syntax-highlighter.mjs +3 -0
  151. package/dist/runtime-dependencies/react-syntax-highlighter__dist__cjs__styles__prism.mjs +3 -0
  152. package/dist/runtime-dependencies/react-syntax-highlighter__dist__cjs__styles__prism__index.js.mjs +3 -0
  153. package/dist/runtime-dependencies/react.mjs +3 -0
  154. package/dist/runtime-dependencies/react__jsx-dev-runtime.mjs +3 -0
  155. package/dist/runtime-dependencies/react__jsx-runtime.mjs +3 -0
  156. package/dist/runtime-dependencies/recast.mjs +3 -0
  157. package/dist/runtime-dependencies/recast__parsers__babel.js.mjs +3 -0
  158. package/dist/runtime-dependencies/rehype-autolink-headings.mjs +3 -0
  159. package/dist/runtime-dependencies/rehype-expressive-code.mjs +3 -0
  160. package/dist/runtime-dependencies/rehype-expressive-code__hast.mjs +3 -0
  161. package/dist/runtime-dependencies/rehype-slug.mjs +3 -0
  162. package/dist/runtime-dependencies/remark-comment.mjs +3 -0
  163. package/dist/runtime-dependencies/remark-directive.mjs +3 -0
  164. package/dist/runtime-dependencies/remark-gfm.mjs +3 -0
  165. package/dist/runtime-dependencies/rimraf.mjs +3 -0
  166. package/dist/runtime-dependencies/semver.mjs +3 -0
  167. package/dist/runtime-dependencies/shelljs.mjs +3 -0
  168. package/dist/runtime-dependencies/sonner.mjs +3 -0
  169. package/dist/runtime-dependencies/sql.js.mjs +3 -0
  170. package/dist/runtime-dependencies/tailwindcss.mjs +3 -0
  171. package/dist/runtime-dependencies/typescript.mjs +3 -0
  172. package/dist/runtime-dependencies/unist-util-visit.mjs +3 -0
  173. package/dist/runtime-dependencies/update-notifier.mjs +3 -0
  174. package/dist/runtime-dependencies/uuid.mjs +3 -0
  175. package/dist/runtime-dependencies/zod.mjs +3 -0
  176. package/dist/runtime-dependencies/zod__v4.mjs +3 -0
  177. package/dist/search-indexer.cjs +1 -0
  178. package/dist/search-indexer.js +1 -1
  179. package/dist/utils/cli-logger.cjs +1 -1
  180. package/dist/utils/cli-logger.js +2 -2
  181. package/dist/watcher.cjs +5 -204
  182. package/dist/watcher.js +1 -2
  183. package/eventcatalog/astro.config.mjs +57 -31
  184. package/eventcatalog/integrations/catalog-assets.mjs +204 -0
  185. package/eventcatalog/integrations/config-loader.mjs +85 -0
  186. package/eventcatalog/integrations/ecstudio-watcher.mjs +11 -9
  187. package/eventcatalog/integrations/eventcatalog-runtime.mjs +252 -0
  188. package/eventcatalog/integrations/expressive-code-config.mjs +6 -0
  189. package/eventcatalog/integrations/runtime-dependencies.mjs +49 -0
  190. package/eventcatalog/integrations/runtime-dependency-manifest.mjs +15 -0
  191. package/eventcatalog/integrations/runtime-paths.mjs +16 -0
  192. package/eventcatalog/src/content.config.ts +33 -46
  193. package/eventcatalog/src/enterprise/custom-pages/routes.ts +3 -2
  194. package/eventcatalog/src/enterprise/feature.ts +2 -1
  195. package/eventcatalog/src/enterprise/fields/field-indexer.ts +5 -2
  196. package/eventcatalog/src/enterprise/fields/pages/api/fields.ts +4 -3
  197. package/eventcatalog/src/enterprise/integrations/eventcatalog-features.ts +32 -32
  198. package/eventcatalog/src/enterprise/mcp/mcp-auth.ts +1 -1
  199. package/eventcatalog/src/env.d.ts +7 -1
  200. package/eventcatalog/src/layouts/VerticalSideBarLayout.astro +15 -3
  201. package/eventcatalog/src/pages/architecture/[type]/[id]/[version]/index.astro +1 -1
  202. package/eventcatalog/src/pages/diagrams/[id]/[version]/index.astro +2 -2
  203. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/[docType]/[docId]/[docVersion]/index.astro +2 -2
  204. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/[docType]/[docId]/index.astro +2 -2
  205. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/graphql/[filename].astro +1 -1
  206. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/index.astro +2 -2
  207. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/resources/index.astro +1 -1
  208. package/eventcatalog/src/pages/docs/[type]/[id]/language/[dictionaryId]/index.astro +1 -1
  209. package/eventcatalog/src/pages/docs/[type]/[id]/language/index.astro +1 -1
  210. package/eventcatalog/src/pages/docs/teams/[id]/index.astro +2 -2
  211. package/eventcatalog/src/pages/docs/users/[id]/index.astro +2 -2
  212. package/eventcatalog/src/pages/index.astro +2 -3
  213. package/eventcatalog/src/styles/tailwind.css +3 -0
  214. package/eventcatalog/src/utils/eventcatalog-config/source.ts +9 -0
  215. package/eventcatalog/src/utils/feature.ts +2 -1
  216. package/eventcatalog/tsconfig.json +1 -4
  217. package/package.json +17 -4
  218. package/dist/catalog-to-astro-content-directory.cjs +0 -382
  219. package/dist/catalog-to-astro-content-directory.d.cts +0 -3
  220. package/dist/catalog-to-astro-content-directory.d.ts +0 -3
  221. package/dist/catalog-to-astro-content-directory.js +0 -9
  222. package/dist/chunk-BWN544LB.js +0 -73
  223. package/dist/chunk-DHH5U5PF.js +0 -53
  224. package/dist/chunk-KLOHNCNF.js +0 -101
  225. package/dist/chunk-T4RVWPIQ.js +0 -85
  226. package/dist/chunk-T5IUG523.js +0 -54
  227. package/dist/chunk-W5JQON7Z.js +0 -117
  228. package/dist/copy-core.cjs +0 -88
  229. package/dist/copy-core.d.cts +0 -4
  230. package/dist/copy-core.d.ts +0 -4
  231. package/dist/copy-core.js +0 -8
  232. package/dist/core-node-modules.cjs +0 -108
  233. package/dist/core-node-modules.d.cts +0 -7
  234. package/dist/core-node-modules.d.ts +0 -7
  235. package/dist/core-node-modules.js +0 -8
  236. package/dist/custom-components.cjs +0 -89
  237. package/dist/custom-components.d.cts +0 -4
  238. package/dist/custom-components.d.ts +0 -4
  239. package/dist/custom-components.js +0 -8
  240. package/dist/map-catalog-to-astro.cjs +0 -151
  241. package/dist/map-catalog-to-astro.d.cts +0 -28
  242. package/dist/map-catalog-to-astro.d.ts +0 -28
  243. package/dist/map-catalog-to-astro.js +0 -6
@@ -3,7 +3,6 @@ import { unified } from '@astrojs/markdown-remark';
3
3
  import tailwindcss from '@tailwindcss/vite';
4
4
  import mdx from '@astrojs/mdx';
5
5
  import react from '@astrojs/react';
6
- import { searchForWorkspaceRoot } from 'vite';
7
6
  import { mermaid } from './src/remark-plugins/mermaid';
8
7
  import { plantuml } from './src/remark-plugins/plantuml';
9
8
  import { join } from 'node:path';
@@ -22,24 +21,36 @@ import { linkValidation } from './src/plugins/link-validation';
22
21
 
23
22
  import rehypeExpressiveCode from 'rehype-expressive-code';
24
23
 
25
- /** @type {import('bin/eventcatalog.config').Config} */
26
- import config from './eventcatalog.config';
27
24
  import expressiveCode from 'astro-expressive-code';
28
25
  // Expressive Code options (including the non-serializable `themeCssSelector`
29
- // function) live in ec.config.mjs. The `expressiveCode()` integration loads that
30
- // file automatically; the rehype plugin used by mdx() below needs it passed
31
- // explicitly, so we import it here to keep a single source of truth.
26
+ // function) live in the package's ec.config.mjs. Both the integration's
27
+ // preprocessors and the rehype plugin below load those same package defaults.
32
28
  import expressiveCodeConfig from './ec.config.mjs';
33
29
  import ecstudioWatcher from './integrations/ecstudio-watcher.mjs';
34
30
  import eventCatalogIntegration from './src/enterprise/integrations/eventcatalog-features.ts';
31
+ import eventCatalogRuntime, { getDevServerFileSystem, packageDirectory } from './integrations/eventcatalog-runtime.mjs';
32
+ import config from './src/utils/eventcatalog-config/source.ts';
33
+ import preprocessExpressiveCodeConfig from './integrations/expressive-code-config.mjs';
34
+ import catalogAssets from './integrations/catalog-assets.mjs';
35
+ import runtimeDependencies from './integrations/runtime-dependencies.mjs';
36
+ import { getRuntimePaths } from './integrations/runtime-paths.mjs';
35
37
 
36
38
  const projectDirectory = process.env.PROJECT_DIR || process.cwd();
39
+ const { runtimeDirectory } = getRuntimePaths(projectDirectory, process.env.CATALOG_DIR);
37
40
  const base = config.base || '/';
38
41
  const host = config.host || false;
39
42
  const compress = config.compress ?? false;
40
43
  const isDevMode = process.env.EVENTCATALOG_DEV_MODE === 'true';
41
44
  const effectiveOutput = isDevMode ? 'server' : config.output || 'static';
42
45
  const searchType = config.search?.type || 'resource';
46
+ const bundledRuntimeDependencies = [
47
+ '@xyflow/react',
48
+ '@eventcatalog/core',
49
+ '@astrojs/react',
50
+ '@astrojs/node',
51
+ '@astrojs/internal-helpers',
52
+ ];
53
+ const externalRuntimeDependencies = ['astro/assets/services/sharp'];
43
54
 
44
55
  const markdownRemarkPlugins = [remarkDirective, remarkDirectives, remarkComment, mermaid, plantuml];
45
56
  const mdxRemarkPlugins = [...markdownRemarkPlugins, remarkResourceRef, remarkCodeGroup];
@@ -62,6 +73,9 @@ const mdxRehypePlugins = [
62
73
 
63
74
  // https://astro.build/config
64
75
  export default defineConfig({
76
+ root: projectDirectory,
77
+ srcDir: runtimeDirectory,
78
+ publicDir: join(projectDirectory, 'public'),
65
79
  base,
66
80
  server: {
67
81
  port: config.port || 3000,
@@ -105,9 +119,14 @@ export default defineConfig({
105
119
  entrypoint: new URL('./src/plugins/quiet-empty-collections-logger.mjs', import.meta.url),
106
120
  },
107
121
  integrations: [
122
+ eventCatalogRuntime({ projectDirectory, runtimeDirectory }),
108
123
  react(),
109
- // Options are loaded automatically from ec.config.mjs.
110
- expressiveCode(),
124
+ expressiveCode({
125
+ customConfigPreprocessors: {
126
+ preprocessAstroIntegrationConfig: preprocessExpressiveCodeConfig,
127
+ preprocessComponentConfig: `export { default } from ${JSON.stringify(join(packageDirectory, 'integrations/expressive-code-config.mjs'))};`,
128
+ },
129
+ }),
111
130
  mdx({
112
131
  // https://docs.astro.build/en/guides/integrations-guide/mdx/#optimize
113
132
  optimize: config.mdxOptimize || false,
@@ -116,13 +135,31 @@ export default defineConfig({
116
135
  rehypePlugins: mdxRehypePlugins,
117
136
  }),
118
137
  }),
138
+ catalogAssets({ projectDirectory, generatedDirectory: join(runtimeDirectory, 'public') }),
119
139
  effectiveOutput !== 'server' && compress && (await loadAstroCompressIntegration(projectDirectory)),
120
140
  ecstudioWatcher(),
121
141
  eventCatalogIntegration(),
122
142
  linkValidation(config.linkValidation),
123
143
  ].filter(Boolean),
124
144
  vite: {
145
+ // Resolve Core's private dependencies from the installed package (including
146
+ // strict pnpm layouts), while Astro owns the user's project and content.
147
+ root: packageDirectory,
148
+ // User components must share the renderer's React, even if the catalog has
149
+ // installed its own version. Preserve the former copied-component contract.
150
+ resolve: { dedupe: ['react', 'react-dom'] },
151
+ envDir: projectDirectory,
152
+ cacheDir: join(runtimeDirectory, 'vite'),
153
+ environments: {
154
+ prerender: {
155
+ resolve: {
156
+ noExternal: bundledRuntimeDependencies,
157
+ external: externalRuntimeDependencies,
158
+ },
159
+ },
160
+ },
125
161
  plugins: [
162
+ runtimeDependencies(),
126
163
  tailwindcss(),
127
164
  ...(await eventCatalogLikeC4(projectDirectory)),
128
165
  ...(config.trailingSlash === true ? [astroTrailingSlashEndpointFix()] : []),
@@ -139,34 +176,23 @@ export default defineConfig({
139
176
  __EC_SEARCH_TYPE__: JSON.stringify(searchType),
140
177
  },
141
178
  server: {
142
- fs: {
143
- allow: ['..', './node_modules/@fontsource', projectDirectory, searchForWorkspaceRoot(process.cwd())],
144
- },
145
- // Prevent stale FSEvents from triggering a config-dependency restart on first run.
146
- // During startup, catalogToAstro copies eventcatalog.config.js into .eventcatalog-core
147
- // shortly before Astro/Vite begins watching. On macOS, FSEvents can deliver buffered
148
- // notifications for those recent writes, causing Vite to restart mid-dep-scan.
149
- // awaitWriteFinish makes chokidar verify the file is stable before emitting events,
150
- // filtering out those stale notifications.
151
- watch: {
152
- awaitWriteFinish: {
153
- stabilityThreshold: 100,
154
- pollInterval: 50,
155
- },
156
- },
179
+ fs: getDevServerFileSystem({ projectDirectory }),
157
180
  ...(config.server?.allowedHosts ? { allowedHosts: config.server?.allowedHosts } : {}),
158
181
  // Pre-transform critical modules during startup so they're ready when
159
182
  // the first page request arrives. Without this, Vite transforms each
160
183
  // module on-demand during the first request, adding seconds to TTFB.
161
184
  warmup: {
162
185
  ssrFiles: [
163
- './src/pages/index.astro',
164
- './src/pages/_index.astro',
165
- './src/layouts/VerticalSideBarLayout.astro',
166
- './src/components/Header.astro',
167
- './src/components/SideNav/SideNav.astro',
186
+ join(packageDirectory, 'src/pages/index.astro'),
187
+ join(packageDirectory, 'src/pages/_index.astro'),
188
+ join(packageDirectory, 'src/layouts/VerticalSideBarLayout.astro'),
189
+ join(packageDirectory, 'src/components/Header.astro'),
190
+ join(packageDirectory, 'src/components/SideNav/SideNav.astro'),
191
+ ],
192
+ clientFiles: [
193
+ join(packageDirectory, 'src/components/SideNav/NestedSideBar/index.tsx'),
194
+ join(packageDirectory, 'src/components/Search/SearchModal.tsx'),
168
195
  ],
169
- clientFiles: ['./src/components/SideNav/NestedSideBar/index.tsx', './src/components/Search/SearchModal.tsx'],
170
196
  },
171
197
  },
172
198
  worker: {
@@ -178,8 +204,8 @@ export default defineConfig({
178
204
  },
179
205
  },
180
206
  ssr: {
181
- noExternal: ['@xyflow/react'],
182
- external: ['eventcatalog.auth.js', 'eventcatalog.chat.js'],
207
+ noExternal: bundledRuntimeDependencies,
208
+ external: ['eventcatalog.auth.js', 'eventcatalog.chat.js', ...externalRuntimeDependencies],
183
209
  },
184
210
  optimizeDeps: {
185
211
  exclude: [],
@@ -0,0 +1,204 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ const defaultCoreDirectory = fileURLToPath(new URL('../', import.meta.url));
6
+ // This is the legacy public-asset URL contract, not the content collection list.
7
+ // entities, containers, data-products, teams and users were never mirrored here.
8
+ // Adding them would publish new files/URLs and needs a separate compatibility
9
+ // review; do not substitute the full content-collection registry.
10
+ const collectionDirectories = new Set([
11
+ 'agents',
12
+ 'events',
13
+ 'commands',
14
+ 'services',
15
+ 'domains',
16
+ 'flows',
17
+ 'pages',
18
+ 'changelogs',
19
+ 'queries',
20
+ 'channels',
21
+ 'ubiquitousLanguages',
22
+ 'dependencies',
23
+ ]);
24
+ const sourceExtensions = /\.(?:md|mdx|astro|[cm]?js|[cm]?ts|jsx|tsx|c4|likec4)$/i;
25
+ const contentTypes = {
26
+ '.json': 'application/json',
27
+ '.yaml': 'application/yaml',
28
+ '.yml': 'application/yaml',
29
+ '.xml': 'application/xml',
30
+ '.xsl': 'application/xml',
31
+ '.svg': 'image/svg+xml',
32
+ '.png': 'image/png',
33
+ '.jpg': 'image/jpeg',
34
+ '.jpeg': 'image/jpeg',
35
+ '.gif': 'image/gif',
36
+ '.webp': 'image/webp',
37
+ '.avif': 'image/avif',
38
+ '.ico': 'image/x-icon',
39
+ '.css': 'text/css',
40
+ '.js': 'text/javascript',
41
+ '.mjs': 'text/javascript',
42
+ '.html': 'text/html',
43
+ '.txt': 'text/plain',
44
+ '.csv': 'text/csv',
45
+ '.pdf': 'application/pdf',
46
+ '.wasm': 'application/wasm',
47
+ '.woff': 'font/woff',
48
+ '.woff2': 'font/woff2',
49
+ };
50
+
51
+ function listFiles(directory, excludedDirectories = new Set()) {
52
+ if (!fs.existsSync(directory)) return [];
53
+ const files = [];
54
+ const visit = (current, segments = []) => {
55
+ for (const entry of fs.readdirSync(current, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
56
+ if (entry.name.startsWith('.')) continue;
57
+ const relative = [...segments, entry.name];
58
+ if (entry.isDirectory() && !excludedDirectories.has(entry.name)) visit(path.join(current, entry.name), relative);
59
+ // Never follow symlinks out of the selected source directories.
60
+ if (entry.isFile()) files.push(relative.join('/'));
61
+ }
62
+ };
63
+ visit(directory);
64
+ return files;
65
+ }
66
+
67
+ // Keep the existing generated URL convention: nested resources are rooted at
68
+ // their nearest collection directory (domains/.../events/Foo -> events/Foo).
69
+ export function getResourceAssetPath(relativePath) {
70
+ const parts = relativePath.split(/[\\/]/);
71
+ if (!collectionDirectories.has(parts[0]) || parts.some((part) => part.startsWith('.'))) return;
72
+ if (sourceExtensions.test(relativePath) || ['package.json', 'Dockerfile'].includes(parts.at(-1))) return;
73
+ if (parts[0] === 'pages') return `/generated/${parts.join('/')}`;
74
+ let collectionIndex = 0;
75
+ for (let index = 1; index < parts.length - 1; index++) {
76
+ if (collectionDirectories.has(parts[index])) collectionIndex = index;
77
+ }
78
+ return `/generated/${parts.slice(collectionIndex).join('/')}`;
79
+ }
80
+
81
+ export function createAssetManifest({ projectDirectory, coreDirectory = defaultCoreDirectory, generatedDirectory }) {
82
+ const assets = new Map();
83
+ const publicDirectory = path.join(coreDirectory, 'public');
84
+ for (const file of listFiles(publicDirectory, new Set(['generated', 'pagefind']))) {
85
+ assets.set(`/${file}`, path.join(publicDirectory, file));
86
+ }
87
+ for (const collection of collectionDirectories) {
88
+ const directory = path.join(projectDirectory, collection);
89
+ for (const file of listFiles(directory, new Set(['node_modules', 'dist']))) {
90
+ const resourcePath = `${collection}/${file}`;
91
+ const url = getResourceAssetPath(resourcePath);
92
+ if (url) assets.set(url, path.join(projectDirectory, resourcePath));
93
+ }
94
+ }
95
+ if (generatedDirectory) {
96
+ for (const file of listFiles(generatedDirectory)) assets.set(`/${file}`, path.join(generatedDirectory, file));
97
+ }
98
+ return assets;
99
+ }
100
+
101
+ function decodeAssetUrl(requestUrl, base) {
102
+ let pathname;
103
+ try {
104
+ pathname = decodeURIComponent((requestUrl || '').split('?')[0]);
105
+ } catch {
106
+ return;
107
+ }
108
+ if (pathname.includes('\\') || pathname.includes('\0') || pathname.split('/').some((part) => part === '..' || part === '.'))
109
+ return;
110
+ const prefix = `/${base.split('/').filter(Boolean).join('/')}`;
111
+ if (prefix !== '/') {
112
+ if (!pathname.startsWith(`${prefix}/`)) return;
113
+ pathname = pathname.slice(prefix.length);
114
+ }
115
+ return pathname;
116
+ }
117
+
118
+ export function createAssetMiddleware({ getAssets, projectDirectory, base = '/' }) {
119
+ return (request, response, next) => {
120
+ if (request.method !== 'GET' && request.method !== 'HEAD') return next();
121
+ // Astro strips the configured base before integration middleware runs.
122
+ // Connect preserves the incoming URL so matching also works under /docs/.
123
+ const pathname = decodeAssetUrl(request.originalUrl || request.url, base);
124
+ if (!pathname) return next();
125
+ // Astro owns the user's public directory, including deliberate overrides.
126
+ const publicFile = path.join(projectDirectory, 'public', pathname.slice(1));
127
+ if (fs.existsSync(publicFile) && fs.statSync(publicFile).isFile()) return next();
128
+ const file = getAssets().get(pathname);
129
+ if (!file) return next();
130
+ let stats;
131
+ try {
132
+ stats = fs.statSync(file);
133
+ if (!stats.isFile()) return next();
134
+ } catch (error) {
135
+ if (error.code === 'ENOENT') return next();
136
+ return next(error);
137
+ }
138
+ response.statusCode = 200;
139
+ response.setHeader('Content-Type', contentTypes[path.extname(file).toLowerCase()] || 'application/octet-stream');
140
+ response.setHeader('Content-Length', stats.size);
141
+ response.setHeader('Cache-Control', 'no-cache');
142
+ if (request.method === 'HEAD') return response.end();
143
+ const stream = fs.createReadStream(file);
144
+ stream.on('error', (error) => response.destroy(error));
145
+ stream.pipe(response);
146
+ };
147
+ }
148
+
149
+ export function emitCatalogAssets(assets, outputDirectory, projectDirectory) {
150
+ for (const [url, source] of assets) {
151
+ const relative = url.slice(1);
152
+ if (fs.existsSync(path.join(projectDirectory, 'public', relative))) continue;
153
+ const target = path.join(outputDirectory, relative);
154
+ fs.mkdirSync(path.dirname(target), { recursive: true });
155
+ fs.copyFileSync(source, target);
156
+ }
157
+ }
158
+
159
+ export default function catalogAssets(options) {
160
+ let base = '/';
161
+ return {
162
+ name: 'eventcatalog:assets',
163
+ hooks: {
164
+ 'astro:config:done': ({ config }) => {
165
+ base = config.base;
166
+ },
167
+ 'astro:server:setup': ({ server }) => {
168
+ let assets = createAssetManifest(options);
169
+ let dirty = false;
170
+ const roots = [...collectionDirectories].map((collection) => path.join(options.projectDirectory, collection));
171
+ if (options.generatedDirectory) roots.push(options.generatedDirectory);
172
+ server.watcher.add(roots);
173
+ const refresh = (file) => {
174
+ if (!roots.some((root) => file === root || file.startsWith(`${root}${path.sep}`))) return;
175
+ dirty = true;
176
+ };
177
+ server.watcher.on('add', refresh);
178
+ server.watcher.on('unlink', refresh);
179
+ server.watcher.on('unlinkDir', refresh);
180
+ server.httpServer?.once('close', () => {
181
+ server.watcher.off('add', refresh);
182
+ server.watcher.off('unlink', refresh);
183
+ server.watcher.off('unlinkDir', refresh);
184
+ });
185
+ server.middlewares.use(
186
+ createAssetMiddleware({
187
+ getAssets: () => {
188
+ if (dirty) {
189
+ assets = createAssetManifest(options);
190
+ dirty = false;
191
+ }
192
+ return assets;
193
+ },
194
+ projectDirectory: options.projectDirectory,
195
+ base,
196
+ })
197
+ );
198
+ },
199
+ 'astro:build:done': ({ dir }) => {
200
+ emitCatalogAssets(createAssetManifest(options), fileURLToPath(dir), options.projectDirectory);
201
+ },
202
+ },
203
+ };
204
+ }
@@ -0,0 +1,85 @@
1
+ import { readFile, rm, copyFile, mkdtemp, symlink } from 'node:fs/promises';
2
+ import { existsSync } from 'node:fs';
3
+ import path from 'node:path';
4
+ import { pathToFileURL } from 'node:url';
5
+ import { tmpdir } from 'node:os';
6
+
7
+ export async function cleanup(projectDirectory) {
8
+ const filePath = path.join(projectDirectory, 'eventcatalog.config.mjs');
9
+ if (existsSync(filePath)) {
10
+ await rm(filePath);
11
+ }
12
+ }
13
+
14
+ const findNodeModulesDirectory = (directory) => {
15
+ let currentDirectory = directory;
16
+
17
+ while (true) {
18
+ const nodeModulesDirectory = path.join(currentDirectory, 'node_modules');
19
+
20
+ if (existsSync(nodeModulesDirectory)) {
21
+ return nodeModulesDirectory;
22
+ }
23
+
24
+ const parentDirectory = path.dirname(currentDirectory);
25
+
26
+ if (parentDirectory === currentDirectory) {
27
+ return undefined;
28
+ }
29
+
30
+ currentDirectory = parentDirectory;
31
+ }
32
+ };
33
+
34
+ const linkNodeModulesIntoTempDirectory = async ({ projectDirectory, tempDir }) => {
35
+ const nodeModulesDirectory = findNodeModulesDirectory(projectDirectory);
36
+
37
+ if (!nodeModulesDirectory) {
38
+ return;
39
+ }
40
+
41
+ await symlink(nodeModulesDirectory, path.join(tempDir, 'node_modules'), 'dir');
42
+ };
43
+
44
+ const createTemporaryConfigDirectory = async (projectDirectory) => {
45
+ const nodeModulesDirectory = findNodeModulesDirectory(projectDirectory);
46
+
47
+ if (nodeModulesDirectory) {
48
+ return mkdtemp(path.join(nodeModulesDirectory, '.eventcatalog-config-'));
49
+ }
50
+
51
+ const tempDir = await mkdtemp(path.join(tmpdir(), 'eventcatalog-config-'));
52
+ await linkNodeModulesIntoTempDirectory({ projectDirectory, tempDir });
53
+ return tempDir;
54
+ };
55
+
56
+ export const getEventCatalogConfigFile = async (projectDirectory) => {
57
+ let tempDir;
58
+
59
+ try {
60
+ let configFilePath = path.join(projectDirectory, 'eventcatalog.config.js');
61
+
62
+ const filePath = path.join(projectDirectory, 'package.json');
63
+ const packageJson = JSON.parse(await readFile(filePath, 'utf-8'));
64
+
65
+ if (packageJson?.type !== 'module') {
66
+ // Importing CommonJS config via ESM import requires an .mjs file.
67
+ // Keep this temp copy outside the project directory so Astro/Vite
68
+ // file watchers do not trigger a dev-server restart during startup.
69
+ tempDir = await createTemporaryConfigDirectory(projectDirectory);
70
+ configFilePath = path.join(tempDir, 'eventcatalog.config.mjs');
71
+ await copyFile(path.join(projectDirectory, 'eventcatalog.config.js'), configFilePath);
72
+ }
73
+
74
+ const configFileURL = `${pathToFileURL(configFilePath).href}?t=${Date.now()}`;
75
+ const config = await import(/* @vite-ignore */ configFileURL);
76
+
77
+ return config.default;
78
+ } finally {
79
+ await cleanup(projectDirectory);
80
+
81
+ if (tempDir) {
82
+ await rm(tempDir, { recursive: true, force: true });
83
+ }
84
+ }
85
+ };
@@ -8,19 +8,21 @@ export default function ecstudioWatcher() {
8
8
  return;
9
9
  }
10
10
 
11
- // Get the project root directory - server.config.root is already a string path
12
- const rootDir = server.config.root;
13
- const isEcstudioFile = (path) => path.endsWith('.ecstudio') && !path.includes('public/generated') && !path.includes('public\\generated');
14
-
11
+ // Vite resolves dependencies from Core's package, while designs belong
12
+ // to the user's catalog and must be watched at their original paths.
13
+ const rootDir = process.env.PROJECT_DIR || process.cwd();
14
+ const isEcstudioFile = (path) =>
15
+ path.endsWith('.ecstudio') && !path.includes('public/generated') && !path.includes('public\\generated');
16
+
15
17
  // Set up chokidar to watch for new .ecstudio files
16
18
  server.watcher
17
19
  .on('add', async (path) => {
18
20
  if (isEcstudioFile(path)) {
19
21
  console.log(`New .ecstudio file detected: ${path}`);
20
-
22
+
21
23
  // Add the new file to the watcher and refresh content
22
24
  server.watcher.add(path);
23
-
25
+
24
26
  if (refreshContent) {
25
27
  try {
26
28
  await refreshContent();
@@ -34,7 +36,7 @@ export default function ecstudioWatcher() {
34
36
  .on('unlink', async (path) => {
35
37
  if (isEcstudioFile(path)) {
36
38
  console.log(`Removed .ecstudio file: ${path}`);
37
-
39
+
38
40
  if (refreshContent) {
39
41
  try {
40
42
  await refreshContent();
@@ -54,9 +56,9 @@ export default function ecstudioWatcher() {
54
56
 
55
57
  // Also add the root directory to watch for new files
56
58
  server.watcher.add(rootDir);
57
-
59
+
58
60
  // console.log('Set up dynamic .ecstudio file watcher with content refresh');
59
61
  },
60
62
  },
61
63
  };
62
- }
64
+ }