@eventcatalog/core 2.29.4 → 2.30.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.
- package/dist/analytics/analytics.cjs +1 -1
- package/dist/analytics/analytics.js +2 -2
- package/dist/analytics/log-build.cjs +1 -1
- package/dist/analytics/log-build.js +3 -3
- package/dist/catalog-to-astro-content-directory.cjs +24 -64
- package/dist/catalog-to-astro-content-directory.d.cts +2 -1
- package/dist/catalog-to-astro-content-directory.d.ts +2 -1
- package/dist/catalog-to-astro-content-directory.js +6 -4
- package/dist/chunk-7SI5EVOX.js +59 -0
- package/dist/{chunk-6DVICCCE.js → chunk-AGI6ZQUB.js} +1 -1
- package/dist/{chunk-FIY5JLSQ.js → chunk-HAYFEAB4.js} +3 -18
- package/dist/{chunk-7PSA2C5C.js → chunk-NSBAGG3S.js} +1 -1
- package/dist/{chunk-DH6NCUJX.js → chunk-RC4ARAOT.js} +1 -1
- package/dist/{chunk-WUCY3QHK.js → chunk-UKJ7F5WR.js} +4 -12
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/eventcatalog.cjs +59 -88
- package/dist/eventcatalog.config.d.cts +3 -7
- package/dist/eventcatalog.config.d.ts +3 -7
- package/dist/eventcatalog.js +43 -24
- package/dist/map-catalog-to-astro.cjs +3 -18
- package/dist/map-catalog-to-astro.js +1 -1
- package/dist/watcher.cjs +6 -30
- package/dist/watcher.js +2 -2
- package/eventcatalog/astro.config.mjs +5 -0
- package/eventcatalog/src/components/MDX/Schema.astro +6 -4
- package/eventcatalog/src/components/MDX/SchemaViewer/SchemaViewer.astro +3 -3
- package/eventcatalog/src/components/SideBars/MessageSideBar.astro +1 -0
- package/eventcatalog/src/components/SideNav/TreeView/getTreeView.ts +2 -2
- package/eventcatalog/src/content.config.ts +94 -34
- package/eventcatalog/src/layouts/VerticalSideBarLayout.astro +7 -1
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/asyncapi/index.astro +11 -6
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/changelog/index.astro +7 -1
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/index.astro +4 -2
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/spec/_OpenAPI.tsx +1 -1
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/spec/index.astro +12 -5
- package/eventcatalog/src/pages/docs/[type]/[id]/[version].md.ts +2 -2
- package/eventcatalog/src/pages/docs/[type]/[id]/[version].mdx.ts +55 -0
- package/eventcatalog/src/pages/docs/llm/llms-full.txt.ts +2 -2
- package/eventcatalog/src/pages/docs/llm/llms.txt.ts +2 -2
- package/eventcatalog/src/pages/docs/teams/[id].md.ts +2 -2
- package/eventcatalog/src/pages/docs/users/[id].md.ts +2 -2
- package/eventcatalog/src/pages/rss/[resource]/rss.xml.js +2 -2
- package/eventcatalog/src/utils/channels.ts +2 -2
- package/eventcatalog/src/utils/collections/changelogs.ts +6 -2
- package/eventcatalog/src/utils/collections/domains.ts +5 -3
- package/eventcatalog/src/utils/collections/file-diffs.ts +1 -1
- package/eventcatalog/src/utils/collections/flows.ts +2 -2
- package/eventcatalog/src/utils/collections/services.ts +8 -6
- package/eventcatalog/src/utils/commands.ts +2 -2
- package/eventcatalog/src/utils/events.ts +2 -2
- package/eventcatalog/src/utils/queries.ts +2 -2
- package/package.json +6 -5
- package/dist/chunk-R2NILSWL.js +0 -82
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
type SideBarConfig = {
|
|
2
|
+
id: string;
|
|
2
3
|
visible: boolean;
|
|
3
4
|
};
|
|
4
5
|
type ResourceDependency = {
|
|
@@ -31,15 +32,10 @@ interface Config {
|
|
|
31
32
|
renderParsedSchemas?: boolean;
|
|
32
33
|
};
|
|
33
34
|
mdxOptimize?: boolean;
|
|
35
|
+
sidebar?: SideBarConfig[];
|
|
34
36
|
docs: {
|
|
35
37
|
sidebar: {
|
|
36
38
|
type?: 'TREE_VIEW' | 'LIST_VIEW';
|
|
37
|
-
showPageHeadings: true;
|
|
38
|
-
services?: SideBarConfig;
|
|
39
|
-
messages?: SideBarConfig;
|
|
40
|
-
domains?: SideBarConfig;
|
|
41
|
-
teams?: SideBarConfig;
|
|
42
|
-
users?: SideBarConfig;
|
|
43
39
|
};
|
|
44
40
|
};
|
|
45
41
|
dependencies?: {
|
|
@@ -59,4 +55,4 @@ interface Config {
|
|
|
59
55
|
};
|
|
60
56
|
}
|
|
61
57
|
|
|
62
|
-
export type { Config };
|
|
58
|
+
export type { Config, SideBarConfig };
|
package/dist/eventcatalog.js
CHANGED
|
@@ -3,17 +3,18 @@ import {
|
|
|
3
3
|
} from "./chunk-BLDONK5J.js";
|
|
4
4
|
import {
|
|
5
5
|
watch
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-UKJ7F5WR.js";
|
|
7
7
|
import {
|
|
8
8
|
log_build_default
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-AGI6ZQUB.js";
|
|
10
|
+
import "./chunk-RC4ARAOT.js";
|
|
11
11
|
import {
|
|
12
|
-
catalogToAstro
|
|
13
|
-
|
|
12
|
+
catalogToAstro,
|
|
13
|
+
checkAndConvertMdToMdx
|
|
14
|
+
} from "./chunk-7SI5EVOX.js";
|
|
14
15
|
import {
|
|
15
16
|
VERSION
|
|
16
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-NSBAGG3S.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-
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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")
|
|
88
|
+
return [import_node_path.default.join("public", "generated")];
|
|
104
89
|
}
|
|
105
|
-
return [import_node_path.default.join("public", "generated")
|
|
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")];
|
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")
|
|
92
|
+
return [import_node_path.default.join("public", "generated")];
|
|
108
93
|
}
|
|
109
|
-
return [import_node_path.default.join("public", "generated")
|
|
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
|
@@ -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,22 +9,24 @@ interface Props {
|
|
|
9
9
|
filePath: string;
|
|
10
10
|
};
|
|
11
11
|
title?: string;
|
|
12
|
+
filePath: string;
|
|
13
|
+
lang?: string;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
const { file = 'schema.json', catalog, title } = Astro.props;
|
|
16
|
+
const { file = 'schema.json', catalog, title, filePath, lang = 'json' } = Astro.props;
|
|
15
17
|
|
|
16
18
|
let code: string | null = null;
|
|
17
19
|
|
|
18
|
-
const exists = fs.existsSync(path.join(
|
|
20
|
+
const exists = fs.existsSync(path.join(path.dirname(filePath), file));
|
|
19
21
|
if (exists) {
|
|
20
|
-
code = fs.readFileSync(path.join(
|
|
22
|
+
code = fs.readFileSync(path.join(path.dirname(filePath), file), 'utf-8');
|
|
21
23
|
}
|
|
22
24
|
---
|
|
23
25
|
|
|
24
26
|
{
|
|
25
27
|
code ? (
|
|
26
28
|
<div class="not-prose max-w-4xl overflow-x-auto">
|
|
27
|
-
<Code code={code} title={title || file} lang=
|
|
29
|
+
<Code code={code} title={title || file} lang={lang} />
|
|
28
30
|
</div>
|
|
29
31
|
) : (
|
|
30
32
|
<div class="italic">Tried to load schema from {path.join(catalog.filePath, file)}, but no schema can be found</div>
|
|
@@ -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(
|
|
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(
|
|
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;
|
|
@@ -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, '/*.
|
|
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.
|
|
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 {
|
|
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
|
|
14
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -9,6 +9,8 @@ import { BookOpenText, Workflow, TableProperties, House, BookUser, MessageSquare
|
|
|
9
9
|
import Header from '../components/Header.astro';
|
|
10
10
|
import SEO from '../components/Seo.astro';
|
|
11
11
|
import SideNav from '../components/SideNav/SideNav.astro';
|
|
12
|
+
import config from '@config';
|
|
13
|
+
|
|
12
14
|
import '@fontsource/inter';
|
|
13
15
|
import '@fontsource/inter/400.css'; // Specify weight
|
|
14
16
|
import '@fontsource/inter/700.css'; // Specify weight
|
|
@@ -54,6 +56,7 @@ const getDefaultUrl = (route: string, defaultValue: string) => {
|
|
|
54
56
|
return buildUrl(defaultValue);
|
|
55
57
|
};
|
|
56
58
|
|
|
59
|
+
const userSideBarConfiguration = config.sidebar || [];
|
|
57
60
|
const navigationItems = [
|
|
58
61
|
{
|
|
59
62
|
id: '/',
|
|
@@ -111,7 +114,10 @@ const navigationItems = [
|
|
|
111
114
|
href: buildUrl('/chat'),
|
|
112
115
|
current: currentPath.includes('/chat'),
|
|
113
116
|
},
|
|
114
|
-
]
|
|
117
|
+
].filter((item) => {
|
|
118
|
+
const userSideBarOption = userSideBarConfiguration.find((config: { id: string; visible: boolean }) => config.id === item.id);
|
|
119
|
+
return userSideBarOption ? userSideBarOption.visible : true;
|
|
120
|
+
});
|
|
115
121
|
|
|
116
122
|
const currentNavigationItem = navigationItems.find((item) => item.current);
|
|
117
123
|
const { title, description } = Astro.props;
|
|
@@ -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
|
|
45
|
-
const
|
|
46
|
-
const
|
|
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(
|
|
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
|
|