@eventcatalog/core 2.29.3 → 2.30.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 (51) 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/catalog-to-astro-content-directory.cjs +24 -64
  6. package/dist/catalog-to-astro-content-directory.d.cts +2 -1
  7. package/dist/catalog-to-astro-content-directory.d.ts +2 -1
  8. package/dist/catalog-to-astro-content-directory.js +6 -4
  9. package/dist/{chunk-KCR7LC5R.js → chunk-4Q54XOED.js} +1 -1
  10. package/dist/chunk-DE2TXYKB.js +59 -0
  11. package/dist/{chunk-FIY5JLSQ.js → chunk-HAYFEAB4.js} +3 -18
  12. package/dist/{chunk-BA6XXQEM.js → chunk-MZLYNODU.js} +1 -1
  13. package/dist/{chunk-7LKTKQLT.js → chunk-T2XS2ZVB.js} +1 -1
  14. package/dist/{chunk-WUCY3QHK.js → chunk-UKJ7F5WR.js} +4 -12
  15. package/dist/constants.cjs +1 -1
  16. package/dist/constants.js +1 -1
  17. package/dist/eventcatalog.cjs +59 -88
  18. package/dist/eventcatalog.js +43 -24
  19. package/dist/map-catalog-to-astro.cjs +3 -18
  20. package/dist/map-catalog-to-astro.js +1 -1
  21. package/dist/watcher.cjs +6 -30
  22. package/dist/watcher.js +2 -2
  23. package/eventcatalog/astro.config.mjs +5 -0
  24. package/eventcatalog/src/components/MDX/Schema.astro +4 -3
  25. package/eventcatalog/src/components/MDX/SchemaViewer/SchemaViewer.astro +3 -3
  26. package/eventcatalog/src/components/SideBars/MessageSideBar.astro +1 -0
  27. package/eventcatalog/src/components/SideNav/TreeView/getTreeView.ts +2 -2
  28. package/eventcatalog/src/content.config.ts +94 -34
  29. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/asyncapi/index.astro +11 -6
  30. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/changelog/index.astro +7 -1
  31. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/index.astro +4 -2
  32. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/spec/_OpenAPI.tsx +1 -1
  33. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/spec/index.astro +12 -5
  34. package/eventcatalog/src/pages/docs/[type]/[id]/[version].md.ts +2 -2
  35. package/eventcatalog/src/pages/docs/[type]/[id]/[version].mdx.ts +55 -0
  36. package/eventcatalog/src/pages/docs/llm/llms-full.txt.ts +2 -2
  37. package/eventcatalog/src/pages/docs/llm/llms.txt.ts +2 -2
  38. package/eventcatalog/src/pages/docs/teams/[id].md.ts +2 -2
  39. package/eventcatalog/src/pages/docs/users/[id].md.ts +2 -2
  40. package/eventcatalog/src/pages/rss/[resource]/rss.xml.js +3 -1
  41. package/eventcatalog/src/utils/channels.ts +2 -2
  42. package/eventcatalog/src/utils/collections/changelogs.ts +6 -2
  43. package/eventcatalog/src/utils/collections/domains.ts +5 -3
  44. package/eventcatalog/src/utils/collections/file-diffs.ts +1 -1
  45. package/eventcatalog/src/utils/collections/flows.ts +2 -2
  46. package/eventcatalog/src/utils/collections/services.ts +8 -6
  47. package/eventcatalog/src/utils/commands.ts +2 -2
  48. package/eventcatalog/src/utils/events.ts +2 -2
  49. package/eventcatalog/src/utils/queries.ts +2 -2
  50. package/package.json +6 -5
  51. package/dist/chunk-R2NILSWL.js +0 -82
@@ -3,17 +3,18 @@ import {
3
3
  } from "./chunk-BLDONK5J.js";
4
4
  import {
5
5
  watch
6
- } from "./chunk-WUCY3QHK.js";
6
+ } from "./chunk-UKJ7F5WR.js";
7
7
  import {
8
8
  log_build_default
9
- } from "./chunk-BA6XXQEM.js";
10
- import "./chunk-7LKTKQLT.js";
9
+ } from "./chunk-MZLYNODU.js";
10
+ import "./chunk-T2XS2ZVB.js";
11
11
  import {
12
- catalogToAstro
13
- } from "./chunk-R2NILSWL.js";
12
+ catalogToAstro,
13
+ checkAndConvertMdToMdx
14
+ } from "./chunk-DE2TXYKB.js";
14
15
  import {
15
16
  VERSION
16
- } from "./chunk-KCR7LC5R.js";
17
+ } from "./chunk-4Q54XOED.js";
17
18
  import {
18
19
  isBackstagePluginEnabled
19
20
  } from "./chunk-XMDPVKIJ.js";
@@ -21,7 +22,7 @@ import {
21
22
  generate
22
23
  } from "./chunk-YEQVKHST.js";
23
24
  import "./chunk-E7TXTI7G.js";
24
- import "./chunk-FIY5JLSQ.js";
25
+ import "./chunk-HAYFEAB4.js";
25
26
 
26
27
  // src/eventcatalog.ts
27
28
  import { Command } from "commander";
@@ -33,6 +34,7 @@ import { fileURLToPath } from "node:url";
33
34
  import concurrently from "concurrently";
34
35
  import boxen from "boxen";
35
36
  import updateNotifier from "update-notifier";
37
+ import stream from "stream";
36
38
  var currentDir = path.dirname(fileURLToPath(import.meta.url));
37
39
  var program = new Command().version(VERSION);
38
40
  var dir = path.resolve(process.env.PROJECT_DIR || process.cwd());
@@ -106,24 +108,40 @@ program.command("dev").description("Run development server of EventCatalog").opt
106
108
  if (options.forceRecreate) clearCore();
107
109
  copyCore();
108
110
  await resolve_catalog_dependencies_default(dir, core);
111
+ await checkAndConvertMdToMdx(dir, core);
109
112
  await catalogToAstro(dir, core);
110
113
  const canEmbedPages = await isBackstagePluginEnabled();
111
114
  checkForUpdate();
112
115
  let watchUnsub;
113
116
  try {
114
117
  watchUnsub = await watch(dir, core);
115
- const { result } = concurrently([
116
- {
117
- name: "astro",
118
- command: `npx astro dev ${command.args.join(" ").trim()}`,
119
- cwd: core,
120
- env: {
121
- PROJECT_DIR: dir,
122
- CATALOG_DIR: core,
123
- ENABLE_EMBED: canEmbedPages
118
+ const { result } = concurrently(
119
+ [
120
+ {
121
+ name: "astro",
122
+ // Ignore any "Empty collection" messages
123
+ command: process.platform === "win32" ? `npx astro dev ${command.args.join(" ").trim()} | findstr /V "The collection"` : `npx astro dev ${command.args.join(" ").trim()} 2>&1 | grep -v "The collection.*does not exist"`,
124
+ cwd: core,
125
+ env: {
126
+ PROJECT_DIR: dir,
127
+ CATALOG_DIR: core,
128
+ ENABLE_EMBED: canEmbedPages
129
+ }
124
130
  }
131
+ ],
132
+ {
133
+ raw: true,
134
+ outputStream: new stream.Writable({
135
+ write(chunk, encoding, callback) {
136
+ const text = chunk.toString();
137
+ if (!(text.includes("The collection") && text.includes("does not exist"))) {
138
+ process.stdout.write(chunk);
139
+ }
140
+ callback();
141
+ }
142
+ })
125
143
  }
126
- ]);
144
+ );
127
145
  await result;
128
146
  } catch (err) {
129
147
  console.error(err);
@@ -136,16 +154,17 @@ program.command("build").description("Run build of EventCatalog").action(async (
136
154
  copyCore();
137
155
  await log_build_default(dir);
138
156
  await resolve_catalog_dependencies_default(dir, core);
157
+ await checkAndConvertMdToMdx(dir, core);
139
158
  await catalogToAstro(dir, core);
140
159
  const canEmbedPages = await isBackstagePluginEnabled();
141
160
  checkForUpdate();
142
- execSync(
143
- `cross-env PROJECT_DIR='${dir}' CATALOG_DIR='${core}' ENABLE_EMBED=${canEmbedPages} npx astro build ${command.args.join(" ").trim()}`,
144
- {
145
- cwd: core,
146
- stdio: "inherit"
147
- }
148
- );
161
+ const windowsCommand = `npx astro build ${command.args.join(" ").trim()} | findstr /V "The collection"`;
162
+ const unixCommand = `npx astro build ${command.args.join(" ").trim()} 2>&1 | grep -v "The collection.*does not exist"`;
163
+ const buildCommand = process.platform === "win32" ? windowsCommand : unixCommand;
164
+ execSync(`cross-env PROJECT_DIR='${dir}' CATALOG_DIR='${core}' ENABLE_EMBED=${canEmbedPages} ${buildCommand}`, {
165
+ cwd: core,
166
+ stdio: "inherit"
167
+ });
149
168
  });
150
169
  var previewCatalog = ({ command, canEmbedPages = false }) => {
151
170
  execSync(
@@ -54,13 +54,7 @@ function mapCatalogToAstro({ filePath, astroDir, projectDir }) {
54
54
  }
55
55
  const baseTargetPaths = getBaseTargetPaths(relativeFilePath);
56
56
  const relativeTargetPath = getRelativeTargetPath(relativeFilePath);
57
- return baseTargetPaths.map(
58
- (base) => import_node_path.default.join(
59
- astroDir,
60
- base,
61
- relativeTargetPath.replace("index.md", "index.mdx").replace("changelog.md", "changelog.mdx").replace("ubiquitous-language.md", "ubiquitous-language.mdx")
62
- )
63
- );
57
+ return baseTargetPaths.map((base) => import_node_path.default.join(astroDir, base, relativeTargetPath));
64
58
  }
65
59
  function removeBasePath(fullPath, basePath) {
66
60
  const relativePath = import_node_path.default.relative(basePath, fullPath);
@@ -89,20 +83,11 @@ function isCatalogRelated(filePath) {
89
83
  function getBaseTargetPaths(filePath) {
90
84
  const filePathArr = filePath.split(import_node_path.default.sep).filter(Boolean);
91
85
  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] == "ubiquitous-language.md") {
96
- return [import_node_path.default.join("src", "content", "ubiquitousLanguages")];
97
- }
98
- if (filePathArr[filePathArr.length - 1].match(/\.md$/)) {
99
- return [import_node_path.default.join("src", "content")];
100
- }
101
86
  const hasExtension = (str) => /\.[a-zA-Z0-9]{2,}$/.test(str);
102
87
  if (hasExtension(filePath)) {
103
- return [import_node_path.default.join("public", "generated"), import_node_path.default.join("src", "catalog-files")];
88
+ return [import_node_path.default.join("public", "generated")];
104
89
  }
105
- return [import_node_path.default.join("public", "generated"), import_node_path.default.join("src", "catalog-files"), import_node_path.default.join("src", "content")];
90
+ return [import_node_path.default.join("public", "generated")];
106
91
  }
107
92
  if (filePathArr[0] == "components") {
108
93
  return [import_node_path.default.join("src", "custom-defined-components")];
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  mapCatalogToAstro
3
- } from "./chunk-FIY5JLSQ.js";
3
+ } from "./chunk-HAYFEAB4.js";
4
4
  export {
5
5
  mapCatalogToAstro
6
6
  };
package/dist/watcher.cjs CHANGED
@@ -58,13 +58,7 @@ function mapCatalogToAstro({ filePath, astroDir, projectDir }) {
58
58
  }
59
59
  const baseTargetPaths = getBaseTargetPaths(relativeFilePath);
60
60
  const relativeTargetPath = getRelativeTargetPath(relativeFilePath);
61
- return baseTargetPaths.map(
62
- (base) => import_node_path.default.join(
63
- astroDir,
64
- base,
65
- relativeTargetPath.replace("index.md", "index.mdx").replace("changelog.md", "changelog.mdx").replace("ubiquitous-language.md", "ubiquitous-language.mdx")
66
- )
67
- );
61
+ return baseTargetPaths.map((base) => import_node_path.default.join(astroDir, base, relativeTargetPath));
68
62
  }
69
63
  function removeBasePath(fullPath, basePath) {
70
64
  const relativePath = import_node_path.default.relative(basePath, fullPath);
@@ -93,20 +87,11 @@ function isCatalogRelated(filePath) {
93
87
  function getBaseTargetPaths(filePath) {
94
88
  const filePathArr = filePath.split(import_node_path.default.sep).filter(Boolean);
95
89
  if (isCollectionKey(filePathArr[0])) {
96
- if (filePathArr[filePathArr.length - 1] == "changelog.md") {
97
- return [import_node_path.default.join("src", "content", "changelogs")];
98
- }
99
- if (filePathArr[filePathArr.length - 1] == "ubiquitous-language.md") {
100
- return [import_node_path.default.join("src", "content", "ubiquitousLanguages")];
101
- }
102
- if (filePathArr[filePathArr.length - 1].match(/\.md$/)) {
103
- return [import_node_path.default.join("src", "content")];
104
- }
105
90
  const hasExtension = (str) => /\.[a-zA-Z0-9]{2,}$/.test(str);
106
91
  if (hasExtension(filePath)) {
107
- return [import_node_path.default.join("public", "generated"), import_node_path.default.join("src", "catalog-files")];
92
+ return [import_node_path.default.join("public", "generated")];
108
93
  }
109
- return [import_node_path.default.join("public", "generated"), import_node_path.default.join("src", "catalog-files"), import_node_path.default.join("src", "content")];
94
+ return [import_node_path.default.join("public", "generated")];
110
95
  }
111
96
  if (filePathArr[0] == "components") {
112
97
  return [import_node_path.default.join("src", "custom-defined-components")];
@@ -139,10 +124,6 @@ var import_promises2 = require("fs/promises");
139
124
  var import_node_path2 = __toESM(require("path"), 1);
140
125
  var import_uuid = require("uuid");
141
126
  var import_gray_matter = __toESM(require("gray-matter"), 1);
142
- function addPropertyToFrontMatter(input, newProperty, newValue) {
143
- const file = (0, import_gray_matter.default)(input);
144
- return import_gray_matter.default.stringify(file.content, { ...file.data, [newProperty]: newValue });
145
- }
146
127
 
147
128
  // src/watcher.js
148
129
  var import_node_path3 = __toESM(require("path"), 1);
@@ -161,6 +142,9 @@ async function watch(projectDirectory, catalogDirectory, callback = void 0) {
161
142
  }
162
143
  for (let event of events) {
163
144
  const { path: filePath, type } = event;
145
+ if (filePath.endsWith(".mdx") || filePath.endsWith(".md")) {
146
+ continue;
147
+ }
164
148
  const astroPaths = mapCatalogToAstro({
165
149
  filePath,
166
150
  astroDir: catalogDirectory,
@@ -175,14 +159,6 @@ async function watch(projectDirectory, catalogDirectory, callback = void 0) {
175
159
  } else {
176
160
  retryEPERM(import_node_fs2.default.cpSync)(filePath, astroPath);
177
161
  }
178
- try {
179
- if (astroPath.endsWith(".mdx")) {
180
- const content = import_node_fs2.default.readFileSync(astroPath, "utf-8");
181
- const frontmatter = addPropertyToFrontMatter(content, "pathToFile", filePath);
182
- import_node_fs2.default.writeFileSync(astroPath, frontmatter);
183
- }
184
- } catch (error) {
185
- }
186
162
  break;
187
163
  case "delete":
188
164
  retryEPERM(import_rimraf.rimrafSync)(astroPath);
package/dist/watcher.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  watch
3
- } from "./chunk-WUCY3QHK.js";
3
+ } from "./chunk-UKJ7F5WR.js";
4
4
  import "./chunk-E7TXTI7G.js";
5
- import "./chunk-FIY5JLSQ.js";
5
+ import "./chunk-HAYFEAB4.js";
6
6
  export {
7
7
  watch
8
8
  };
@@ -30,6 +30,11 @@ export default defineConfig({
30
30
  // https://docs.astro.build/en/reference/configuration-reference/#trailingslash
31
31
  trailingSlash: config.trailingSlash === true ? "always" : "ignore",
32
32
 
33
+ experimental: {
34
+ contentIntellisense: true,
35
+ },
36
+
37
+
33
38
  // just turn this off for all users (for now...)
34
39
  devToolbar: { enabled: false },
35
40
  integrations: [
@@ -9,15 +9,16 @@ interface Props {
9
9
  filePath: string;
10
10
  };
11
11
  title?: string;
12
+ filePath: string;
12
13
  }
13
14
 
14
- const { file = 'schema.json', catalog, title } = Astro.props;
15
+ const { file = 'schema.json', catalog, title, filePath } = Astro.props;
15
16
 
16
17
  let code: string | null = null;
17
18
 
18
- const exists = fs.existsSync(path.join(catalog.filePath, file));
19
+ const exists = fs.existsSync(path.join(path.dirname(filePath), file));
19
20
  if (exists) {
20
- code = fs.readFileSync(path.join(catalog.filePath, file), 'utf-8');
21
+ code = fs.readFileSync(path.join(path.dirname(filePath), file), 'utf-8');
21
22
  }
22
23
  ---
23
24
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- const { catalog, id } = Astro.props;
2
+ const { catalog, id, filePath } = Astro.props;
3
3
  import fs from 'node:fs/promises';
4
4
  import { existsSync } from 'fs';
5
5
  import yaml from 'js-yaml';
@@ -37,12 +37,12 @@ function findSchemaViewers(document: string) {
37
37
  }
38
38
 
39
39
  try {
40
- const file = await fs.readFile(catalog.astroContentFilePath, 'utf-8');
40
+ const file = await fs.readFile(filePath, 'utf-8');
41
41
  const schemaViewers = findSchemaViewers(file);
42
42
 
43
43
  // Loop around all the possible SchemaViewers in the file.
44
44
  const getAllComponents = schemaViewers.map(async (schemaViewerProps: any) => {
45
- const schemaPath = path.join(catalog.filePath, schemaViewerProps.file);
45
+ const schemaPath = path.join(path.dirname(filePath), schemaViewerProps.file);
46
46
  const exists = existsSync(schemaPath);
47
47
  let schema;
48
48
  let render = true;
@@ -91,6 +91,7 @@ const isRSSEnabled = config.rss?.enabled;
91
91
 
92
92
  // @ts-ignore
93
93
  const publicPath = message?.catalog?.publicPath;
94
+
94
95
  const schemaFilePath = message?.data?.schemaPath;
95
96
  const schemaURL = path.join(publicPath, schemaFilePath || '');
96
97
  ---
@@ -50,11 +50,11 @@ function buildTreeOfDir(directory: string, parentNode: TreeNode, options: { igno
50
50
 
51
51
  const resourceType = getResourceType(directory);
52
52
 
53
- const markdownFiles = globSync(path.join(directory, '/*.md'), { windowsPathsNoEscape: os.platform() === 'win32' });
53
+ const markdownFiles = globSync(path.join(directory, '/*.mdx'), { windowsPathsNoEscape: os.platform() === 'win32' });
54
54
  const isResourceIgnored = options?.ignore && resourceType && options.ignore.includes(resourceType);
55
55
 
56
56
  if (markdownFiles.length > 0 && !isResourceIgnored) {
57
- const resourceFilePath = markdownFiles.find((md) => md.endsWith('index.md'));
57
+ const resourceFilePath = markdownFiles.find((md) => md.endsWith('index.mdx'));
58
58
  if (resourceFilePath) {
59
59
  const resourceDef = gm.read(resourceFilePath);
60
60
  node = {
@@ -1,6 +1,14 @@
1
1
  import { z, defineCollection, reference } from 'astro:content';
2
2
  import { glob } from 'astro/loaders';
3
- import { join } from 'node:path';
3
+ import { v4 as uuidv4 } from 'uuid';
4
+
5
+ const projectDirBase = (() => {
6
+ if (process.platform === 'win32') {
7
+ const projectDirPath = process.env.PROJECT_DIR!.replace(/\\/g, '/');
8
+ return projectDirPath.startsWith('/') ? projectDirPath : `/${projectDirPath}`;
9
+ }
10
+ return process.env.PROJECT_DIR;
11
+ })();
4
12
 
5
13
  const badge = z.object({
6
14
  content: z.string(),
@@ -10,9 +18,11 @@ const badge = z.object({
10
18
 
11
19
  const pages = defineCollection({
12
20
  type: 'content',
13
- schema: z.object({
14
- id: z.string(),
15
- }),
21
+ schema: z
22
+ .object({
23
+ id: z.string(),
24
+ })
25
+ .optional(),
16
26
  });
17
27
 
18
28
  const pointer = z.object({
@@ -27,7 +37,10 @@ const channelPointer = z
27
37
  .merge(pointer);
28
38
 
29
39
  const changelogs = defineCollection({
30
- type: 'content',
40
+ loader: glob({
41
+ pattern: ['**/changelog.(md|mdx)'],
42
+ base: projectDirBase,
43
+ }),
31
44
  schema: z.object({
32
45
  createdAt: z.date().optional(),
33
46
  badges: z.array(badge).optional(),
@@ -95,7 +108,6 @@ const baseSchema = z.object({
95
108
  // Used by eventcatalog
96
109
  versions: z.array(z.string()).optional(),
97
110
  latestVersion: z.string().optional(),
98
- pathToFile: z.string().optional(),
99
111
  catalog: z
100
112
  .object({
101
113
  path: z.string(),
@@ -121,7 +133,13 @@ const flowStep = z
121
133
  .optional();
122
134
 
123
135
  const flows = defineCollection({
124
- type: 'content',
136
+ loader: glob({
137
+ pattern: ['**/flows/*/index.(md|mdx)', '**/flows/*/versioned/*/index.(md|mdx)'],
138
+ base: projectDirBase,
139
+ generateId: ({ data }) => {
140
+ return `${data.id}-${data.version}`;
141
+ },
142
+ }),
125
143
  schema: z
126
144
  .object({
127
145
  steps: z.array(
@@ -165,7 +183,13 @@ const flows = defineCollection({
165
183
  });
166
184
 
167
185
  const events = defineCollection({
168
- type: 'content',
186
+ loader: glob({
187
+ pattern: ['**/events/*/index.(md|mdx)', '**/events/*/versioned/*/index.(md|mdx)'],
188
+ base: projectDirBase,
189
+ generateId: ({ data, ...rest }) => {
190
+ return `${data.id}-${data.version}`;
191
+ },
192
+ }),
169
193
  schema: z
170
194
  .object({
171
195
  producers: z.array(reference('services')).optional(),
@@ -178,7 +202,13 @@ const events = defineCollection({
178
202
  });
179
203
 
180
204
  const commands = defineCollection({
181
- type: 'content',
205
+ loader: glob({
206
+ pattern: ['**/commands/*/index.(md|mdx)', '**/commands/*/versioned/*/index.(md|mdx)'],
207
+ base: projectDirBase,
208
+ generateId: ({ data }) => {
209
+ return `${data.id}-${data.version}`;
210
+ },
211
+ }),
182
212
  schema: z
183
213
  .object({
184
214
  producers: z.array(reference('services')).optional(),
@@ -191,7 +221,13 @@ const commands = defineCollection({
191
221
  });
192
222
 
193
223
  const queries = defineCollection({
194
- type: 'content',
224
+ loader: glob({
225
+ pattern: ['**/queries/*/index.(md|mdx)', '**/queries/*/versioned/*/index.(md|mdx)'],
226
+ base: projectDirBase,
227
+ generateId: ({ data }) => {
228
+ return `${data.id}-${data.version}`;
229
+ },
230
+ }),
195
231
  schema: z
196
232
  .object({
197
233
  producers: z.array(reference('services')).optional(),
@@ -204,7 +240,18 @@ const queries = defineCollection({
204
240
  });
205
241
 
206
242
  const services = defineCollection({
207
- type: 'content',
243
+ loader: glob({
244
+ pattern: [
245
+ 'domains/*/services/*/index.(md|mdx)',
246
+ 'domains/*/services/*/versioned/*/index.(md|mdx)',
247
+ 'services/*/index.(md|mdx)', // ✅ Capture only services markdown files
248
+ 'services/*/versioned/*/index.(md|mdx)', // ✅ Capture versioned files inside services
249
+ ],
250
+ base: projectDirBase,
251
+ generateId: ({ data, ...rest }) => {
252
+ return `${data.id}-${data.version}`;
253
+ },
254
+ }),
208
255
  schema: z
209
256
  .object({
210
257
  sends: z.array(pointer).optional(),
@@ -213,8 +260,33 @@ const services = defineCollection({
213
260
  .merge(baseSchema),
214
261
  });
215
262
 
263
+ const domains = defineCollection({
264
+ loader: glob({
265
+ pattern: [
266
+ // ✅ Strictly include only index.md at the expected levels
267
+ 'domains/*/index.(md|mdx)',
268
+ 'domains/*/versioned/*/index.(md|mdx)',
269
+ ],
270
+ base: projectDirBase,
271
+ generateId: ({ data, ...rest }) => {
272
+ return `${data.id}-${data.version}`;
273
+ },
274
+ }),
275
+ schema: z
276
+ .object({
277
+ services: z.array(pointer).optional(),
278
+ })
279
+ .merge(baseSchema),
280
+ });
281
+
216
282
  const channels = defineCollection({
217
- type: 'content',
283
+ loader: glob({
284
+ pattern: ['**/channels/*/index.(md|mdx)', '**/channels/*/versioned/*/index.(md|mdx)'],
285
+ base: projectDirBase,
286
+ generateId: ({ data }) => {
287
+ return `${data.id}-${data.version}`;
288
+ },
289
+ }),
218
290
  schema: z
219
291
  .object({
220
292
  address: z.string().optional(),
@@ -234,17 +306,15 @@ const channels = defineCollection({
234
306
  .merge(baseSchema),
235
307
  });
236
308
 
237
- const domains = defineCollection({
238
- type: 'content',
239
- schema: z
240
- .object({
241
- services: z.array(pointer).optional(),
242
- })
243
- .merge(baseSchema),
244
- });
245
-
246
309
  const ubiquitousLanguages = defineCollection({
247
- type: 'content',
310
+ loader: glob({
311
+ pattern: ['domains/*/ubiquitous-language.(md|mdx)'],
312
+ base: projectDirBase,
313
+ generateId: ({ data }) => {
314
+ // File has no id, so we need to generate one
315
+ return uuidv4();
316
+ },
317
+ }),
248
318
  schema: z.object({
249
319
  dictionary: z
250
320
  .array(
@@ -260,16 +330,8 @@ const ubiquitousLanguages = defineCollection({
260
330
  }),
261
331
  });
262
332
 
263
- const projectDirBase = (() => {
264
- if (process.platform === 'win32') {
265
- const projectDirPath = process.env.PROJECT_DIR!.replace(/\\/g, '/');
266
- return projectDirPath.startsWith('/') ? projectDirPath : `/${projectDirPath}`;
267
- }
268
- return process.env.PROJECT_DIR;
269
- })();
270
-
271
333
  const users = defineCollection({
272
- loader: glob({ pattern: 'users/*.md', base: projectDirBase, generateId: ({ data }) => data.id as string }),
334
+ loader: glob({ pattern: 'users/*.(md|mdx)', base: projectDirBase, generateId: ({ data }) => data.id as string }),
273
335
  schema: z.object({
274
336
  id: z.string(),
275
337
  name: z.string(),
@@ -285,12 +347,11 @@ const users = defineCollection({
285
347
  ownedCommands: z.array(reference('commands')).optional(),
286
348
  ownedQueries: z.array(reference('queries')).optional(),
287
349
  associatedTeams: z.array(reference('teams')).optional(),
288
- pathToFile: z.string().optional(),
289
350
  }),
290
351
  });
291
352
 
292
353
  const teams = defineCollection({
293
- loader: glob({ pattern: 'teams/*.md', base: projectDirBase, generateId: ({ data }) => data.id as string }),
354
+ loader: glob({ pattern: 'teams/*.(md|mdx)', base: projectDirBase, generateId: ({ data }) => data.id as string }),
294
355
  schema: z.object({
295
356
  id: z.string(),
296
357
  name: z.string(),
@@ -305,7 +366,6 @@ const teams = defineCollection({
305
366
  ownedDomains: z.array(reference('domains')).optional(),
306
367
  ownedServices: z.array(reference('services')).optional(),
307
368
  ownedEvents: z.array(reference('events')).optional(),
308
- pathToFile: z.string().optional(),
309
369
  }),
310
370
  });
311
371
 
@@ -1,10 +1,10 @@
1
1
  ---
2
2
  import path from 'path';
3
- import { readFileSync } from 'fs';
4
3
  import { createElement } from 'react';
5
4
  import { renderToString } from 'react-dom/server';
6
5
  import { Parser } from '@asyncapi/parser';
7
6
  import { AvroSchemaParser } from '@asyncapi/avro-schema-parser';
7
+ import fs from 'fs';
8
8
 
9
9
  import type { CollectionTypes, PageTypes } from '@types';
10
10
 
@@ -39,15 +39,20 @@ export async function getStaticPaths() {
39
39
  }
40
40
 
41
41
  // @ts-ignore
42
- const { catalog, data } = Astro.props;
42
+ const { catalog, data, filePath } = Astro.props;
43
43
  const fileName = data.specifications?.asyncapiPath || 'asyncapi.yaml';
44
- const pathToSpec = path.join(catalog.publicPath, fileName);
45
- const pathOnDisk = path.join(process.cwd(), 'public', pathToSpec);
46
- const fileContent = readFileSync(pathOnDisk, 'utf-8');
44
+ const directory = path.dirname(filePath || '');
45
+ const pathToSpec = path.join(directory, fileName);
46
+ const fileExists = fs.existsSync(pathToSpec);
47
+ let content = '';
48
+
49
+ if (fileExists) {
50
+ content = fs.readFileSync(pathToSpec, 'utf8');
51
+ }
47
52
 
48
53
  // AsyncAPI parser will parser schemas for users, they can turn this off.
49
54
  const parseSchemas = Config?.asyncAPI?.renderParsedSchemas ?? true;
50
- const parsed = await new Parser({ schemaParsers: [AvroSchemaParser()] }).parse(fileContent, { parseSchemas });
55
+ const parsed = await new Parser({ schemaParsers: [AvroSchemaParser()] }).parse(content, { parseSchemas });
51
56
  const stringified = parsed.document?.json();
52
57
  const config: ConfigInterface = { show: { sidebar: true, errors: true } };
53
58
 
@@ -5,6 +5,7 @@ import type { PageTypes } from '@types';
5
5
  import { getChangeLogs } from '@utils/collections/changelogs';
6
6
  import { RectangleGroupIcon, ServerIcon, BoltIcon, ChatBubbleLeftIcon, MagnifyingGlassIcon } from '@heroicons/react/24/outline';
7
7
  import { pageDataLoader } from '@utils/page-loaders/page-data-loader';
8
+ import { render, getEntry } from 'astro:content';
8
9
  import 'diff2html/bundles/css/diff2html.min.css';
9
10
 
10
11
  import { buildUrl } from '@utils/url-builder';
@@ -38,11 +39,14 @@ const props = Astro.props;
38
39
  let collectionItem = props;
39
40
  const logs = await getChangeLogs(props);
40
41
 
42
+ // console.log('logs', logs)
43
+
41
44
  const { data } = props;
42
45
  const latestVersion = data.latestVersion;
43
46
 
44
47
  const renderedLogs = await logs.map(async (log) => {
45
- const { Content } = await log.render();
48
+ const logEntry = await getEntry('changelogs', log.id);
49
+ const { Content } = await render(logEntry as any);
46
50
  return {
47
51
  Content,
48
52
  ...log,
@@ -51,6 +55,8 @@ const renderedLogs = await logs.map(async (log) => {
51
55
 
52
56
  const logsToRender = await Promise.all(renderedLogs);
53
57
 
58
+ // console.log('LOGS TO RENDER', logsToRender);
59
+
54
60
  const logListPromise = logsToRender.map(async (log, index) => {
55
61
  const currentLogVersion = log.data.version;
56
62
  const previousLogVersion = log.data.version ? getPreviousVersion(log.data.version, props.allVersionsForCollection) : '';
@@ -19,6 +19,7 @@ import { buildUrl } from '@utils/url-builder';
19
19
  import { getFlows } from '@utils/collections/flows';
20
20
  import { pageDataLoader } from '@utils/page-loaders/page-data-loader';
21
21
  import { ClientRouter } from 'astro:transitions';
22
+ import { render } from 'astro:content';
22
23
  import { ArrowsRightLeftIcon } from '@heroicons/react/20/solid';
23
24
 
24
25
  import config from '@config';
@@ -51,7 +52,8 @@ export async function getStaticPaths() {
51
52
 
52
53
  const props = Astro.props;
53
54
 
54
- const { Content } = await props.render();
55
+ const { Content } = await render(props);
56
+ // const { Content } = await props.render();
55
57
 
56
58
  // Capitalize the first letter of a string
57
59
  const pageTitle = `${props.collection} | ${props.data.name}`.replace(/^\w/, (c) => c.toUpperCase());
@@ -198,7 +200,7 @@ const badges = [getBadge(), ...contentBadges, ...getSpecificationBadges()];
198
200
  </div>
199
201
  <div>
200
202
  <!-- @ts-ignore -->
201
- <SchemaViewer id={props.data.id} catalog={props.catalog} />
203
+ <SchemaViewer id={props.data.id} catalog={props.catalog} filePath={props.filePath} />
202
204
  <NodeGraph
203
205
  id={props.data.id}
204
206
  collection={props.collection}
@@ -10,7 +10,7 @@ const OpenAPISpec = ({ spec }: { spec: string }) => {
10
10
  <ApiReferenceReact
11
11
  configuration={{
12
12
  spec: {
13
- url: spec,
13
+ content: spec,
14
14
  },
15
15
  theme: 'fastify',
16
16
  hideClientButton: true,