@eventcatalog/core 2.2.5 → 2.2.7
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/.github/workflows/verify-build.yml +4 -5
- package/.prettierrc +17 -9
- package/CHANGELOG.md +13 -0
- package/package.json +6 -5
- package/scripts/build-ci.js +1 -1
- package/scripts/catalog-to-astro-content-directory.js +9 -7
- package/scripts/watcher.js +4 -0
- package/src/components/DocsNavigation.astro +34 -25
- package/src/components/Header.astro +14 -11
- package/src/components/Lists/VersionList.astro +29 -17
- package/src/components/MDX/Accordion/Accordion.astro +5 -6
- package/src/components/MDX/Accordion/AccordionGroup.astro +1 -0
- package/src/components/MDX/NodeGraph/NodeGraph.astro +13 -8
- package/src/components/MDX/SchemaViewer/SchemaViewer.astro +45 -50
- package/src/components/Search.astro +16 -5
- package/src/components/Seo.astro +48 -54
- package/src/components/SideBars/DomainSideBar.astro +24 -6
- package/src/components/SideBars/MessageSideBar.astro +41 -10
- package/src/components/SideBars/ServiceSideBar.astro +54 -13
- package/src/layouts/CustomDocsPageLayout.astro +70 -23
- package/src/layouts/DiscoverLayout.astro +3 -1
- package/src/layouts/DocsLayout.astro +4 -4
- package/src/layouts/Footer.astro +19 -6
- package/src/pages/discover/[type]/index.astro +26 -21
- package/src/pages/docs/[type]/[id]/[version]/changelog/index.astro +68 -59
- package/src/pages/docs/[type]/[id]/[version]/index.astro +38 -20
- package/src/pages/docs/index.astro +13 -16
- package/src/pages/docs/teams/[id]/index.astro +24 -7
- package/src/pages/docs/users/[id]/index.astro +23 -6
- package/src/pages/visualiser/[type]/[id]/[version]/index.astro +12 -1
|
@@ -11,7 +11,10 @@ jobs:
|
|
|
11
11
|
build:
|
|
12
12
|
name: Verify Build
|
|
13
13
|
timeout-minutes: 30
|
|
14
|
-
|
|
14
|
+
strategy:
|
|
15
|
+
matrix:
|
|
16
|
+
os: [ubuntu-latest, windows-latest]
|
|
17
|
+
runs-on: ${{ matrix.os }}
|
|
15
18
|
steps:
|
|
16
19
|
- uses: actions/checkout@v4
|
|
17
20
|
- uses: actions/setup-node@v4
|
|
@@ -19,9 +22,5 @@ jobs:
|
|
|
19
22
|
node-version: '20.x'
|
|
20
23
|
- name: Installation
|
|
21
24
|
run: npm i
|
|
22
|
-
- name: Log
|
|
23
|
-
run: ls
|
|
24
|
-
- name: Log2
|
|
25
|
-
run: pwd
|
|
26
25
|
- name: Build
|
|
27
26
|
run: npm run verify-build:catalog
|
package/.prettierrc
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
"semi": true,
|
|
3
|
+
"singleQuote": true,
|
|
4
|
+
"printWidth": 130,
|
|
5
|
+
"tabWidth": 2,
|
|
6
|
+
"useTabs": false,
|
|
7
|
+
"trailingComma": "es5",
|
|
8
|
+
"bracketSpacing": true,
|
|
9
|
+
"plugins": ["prettier-plugin-astro"],
|
|
10
|
+
"overrides": [
|
|
11
|
+
{
|
|
12
|
+
"files": "*.astro",
|
|
13
|
+
"options": {
|
|
14
|
+
"parser": "astro"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @eventcatalog/core
|
|
2
2
|
|
|
3
|
+
## 2.2.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d7148fa: chore(core): fixed long labels on the documentation sidebar
|
|
8
|
+
|
|
9
|
+
## 2.2.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 50a43e0: core(fix): removed forward slash before # to prevent double trailing slash
|
|
14
|
+
- 8104078: chore(core): added windows tests and fixed watcher to work with changelogs files on windows
|
|
15
|
+
|
|
3
16
|
## 2.2.5
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eventcatalog/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.7",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"test": "jest --config=$(pwd)/../../jest.config.js",
|
|
17
17
|
"start": "astro dev",
|
|
18
18
|
"build": "npm run scripts:hydrate-content && astro check --minimumSeverity error && astro build",
|
|
19
|
-
"build:cd": "node scripts/build-ci.js
|
|
19
|
+
"build:cd": "node scripts/build-ci.js",
|
|
20
20
|
"preview": "astro preview",
|
|
21
21
|
"astro": "astro",
|
|
22
22
|
"scripts:hydrate-content": "node scripts/catalog-to-astro-content-directory.js",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"changeset": "changeset",
|
|
26
26
|
"generate": "node scripts/generate.js",
|
|
27
27
|
"release": "changeset publish",
|
|
28
|
-
"format": "prettier --config .prettierrc --write \"**/*.{js,jsx,ts,tsx,json}\"",
|
|
29
|
-
"format:diff": "prettier --config .prettierrc --list-different \"**/*.{js,jsx,ts,tsx,json}\""
|
|
28
|
+
"format": "prettier --config .prettierrc --write \"**/*.{js,jsx,ts,tsx,json,astro}\"",
|
|
29
|
+
"format:diff": "prettier --config .prettierrc --list-different \"**/*.{js,jsx,ts,tsx,json,astro}\""
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@astrojs/check": "^0.7.0",
|
|
@@ -70,7 +70,8 @@
|
|
|
70
70
|
"concurrently": "^8.2.2",
|
|
71
71
|
"cross-env": "^7.0.3",
|
|
72
72
|
"jest": "^29.7.0",
|
|
73
|
-
"prettier": "^3.3.
|
|
73
|
+
"prettier": "^3.3.3",
|
|
74
|
+
"prettier-plugin-astro": "^0.14.1",
|
|
74
75
|
"rimraf": "^5.0.7",
|
|
75
76
|
"tsup": "^8.1.0"
|
|
76
77
|
}
|
package/scripts/build-ci.js
CHANGED
|
@@ -16,7 +16,7 @@ fs.copyFileSync(join(projectDIR, 'eventcatalog.config.js'), join(catalogDir, 'ev
|
|
|
16
16
|
|
|
17
17
|
fs.copyFileSync(join(projectDIR, 'eventcatalog.styles.css'), join(catalogDir, 'eventcatalog.styles.css'));
|
|
18
18
|
|
|
19
|
-
execSync(`cross-env NODE_ENV=CI PROJECT_DIR=${projectDIR} CATALOG_DIR=${catalogDir} npm run
|
|
19
|
+
execSync(`cross-env NODE_ENV=CI PROJECT_DIR=${projectDIR} CATALOG_DIR=${catalogDir} npm run build`, {
|
|
20
20
|
cwd: catalogDir,
|
|
21
21
|
stdio: 'inherit',
|
|
22
22
|
});
|
|
@@ -40,17 +40,19 @@ const copyFiles = async ({ source, target, catalogFilesDir, pathToMarkdownFiles,
|
|
|
40
40
|
|
|
41
41
|
// Copy markdown files into the astro content (collection) folder
|
|
42
42
|
for (const file of markdownFiles) {
|
|
43
|
-
|
|
43
|
+
let fileTarget = target;
|
|
44
|
+
|
|
45
|
+
// If they are change logs they need to go into their own content folder
|
|
46
|
+
if (file.includes('changelog.md')) {
|
|
47
|
+
fileTarget = path.join(target, 'changelogs');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const targetPath = getTargetPath(source, fileTarget, type, file);
|
|
44
51
|
|
|
45
52
|
//ensure the directory exists
|
|
46
53
|
ensureDirSync(path.dirname(targetPath));
|
|
47
54
|
|
|
48
|
-
|
|
49
|
-
const target = targetPath.replace('/content', '/content/changelogs');
|
|
50
|
-
fs.cpSync(file, target.replace('changelog.md', 'changelog.mdx'));
|
|
51
|
-
} else {
|
|
52
|
-
fs.cpSync(file, targetPath.replace('index.md', 'index.mdx').replace('changelog.md', 'changelog.mdx'));
|
|
53
|
-
}
|
|
55
|
+
fs.cpSync(file, targetPath.replace('index.md', 'index.mdx').replace('changelog.md', 'changelog.mdx'));
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
// Copy all other files (non markdown) files into catalog-files directory (non collection)
|
package/scripts/watcher.js
CHANGED
|
@@ -35,6 +35,10 @@ for (let item of [...verifiedWatchList]) {
|
|
|
35
35
|
// Check if changlogs, they need to go into their own content folder
|
|
36
36
|
if (file.includes('changelog.md')) {
|
|
37
37
|
newPath = newPath.replace('src/content', 'src/content/changelogs');
|
|
38
|
+
|
|
39
|
+
if (os.platform() == 'win32') {
|
|
40
|
+
newPath = newPath.replace('src\\content', 'src\\content\\changelogs');
|
|
41
|
+
}
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
// If config files have changes
|
|
@@ -21,13 +21,20 @@ const messages = [...events, ...commands];
|
|
|
21
21
|
const allData = [...domains, ...services, ...messages, ...teams, ...users];
|
|
22
22
|
|
|
23
23
|
const eventCatalogConfig = config as CatalogConfig;
|
|
24
|
-
const {
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const {
|
|
25
|
+
services: servicesConfig,
|
|
26
|
+
domains: domainsConfig,
|
|
27
|
+
messages: messagesConfig,
|
|
28
|
+
teams: teamsConfig,
|
|
29
|
+
users: usersConfig,
|
|
30
|
+
showPageHeadings = true,
|
|
31
|
+
} = eventCatalogConfig?.docs?.sidebar || {};
|
|
32
|
+
|
|
33
|
+
const getConfigValue = (obj: any, key: string, defaultValue: any) => {
|
|
27
34
|
return obj?.[key] ?? defaultValue;
|
|
28
|
-
}
|
|
35
|
+
};
|
|
29
36
|
|
|
30
|
-
const visibleCollections: {[key:string]: boolean} = {
|
|
37
|
+
const visibleCollections: { [key: string]: boolean } = {
|
|
31
38
|
events: getConfigValue(messagesConfig, 'visible', true),
|
|
32
39
|
commands: getConfigValue(messagesConfig, 'visible', true),
|
|
33
40
|
domains: getConfigValue(domainsConfig, 'visible', true),
|
|
@@ -38,20 +45,17 @@ const visibleCollections: {[key:string]: boolean} = {
|
|
|
38
45
|
|
|
39
46
|
const fetchHeadings = allData.map(async (item) => {
|
|
40
47
|
const renderHeadings = showPageHeadings;
|
|
41
|
-
const headings = renderHeadings ? await item.render() : { headings: []};
|
|
48
|
+
const headings = renderHeadings ? await item.render() : { headings: [] };
|
|
42
49
|
return {
|
|
43
50
|
...item,
|
|
44
51
|
headings: headings.headings,
|
|
45
52
|
};
|
|
46
53
|
});
|
|
47
54
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const withHeadings = await Promise.all(fetchHeadings);
|
|
55
|
+
const withHeadings = await Promise.all(fetchHeadings);
|
|
51
56
|
|
|
52
57
|
const sideNav = withHeadings.reduce((acc, item) => {
|
|
53
|
-
|
|
54
|
-
const title = (item.collection === 'events' || item.collection === 'commands') ? 'Messages' : item.collection;
|
|
58
|
+
const title = item.collection === 'events' || item.collection === 'commands' ? 'Messages' : item.collection;
|
|
55
59
|
|
|
56
60
|
const group = acc[title] || [];
|
|
57
61
|
|
|
@@ -61,7 +65,10 @@ const sideNav = withHeadings.reduce((acc, item) => {
|
|
|
61
65
|
items: item.collection === 'users' ? [] : item.headings,
|
|
62
66
|
visible: visibleCollections[item.collection],
|
|
63
67
|
// @ts-ignore
|
|
64
|
-
href: item.data.version
|
|
68
|
+
href: item.data.version
|
|
69
|
+
? // @ts-ignore
|
|
70
|
+
buildUrl(`/docs/${item.collection}/${item.data.id}/${item.data.version}`)
|
|
71
|
+
: buildUrl(`/docs/${item.collection}/${item.data.id}`),
|
|
65
72
|
};
|
|
66
73
|
|
|
67
74
|
group.push(navigationItem);
|
|
@@ -73,29 +80,35 @@ const sideNav = withHeadings.reduce((acc, item) => {
|
|
|
73
80
|
}, {} as any);
|
|
74
81
|
|
|
75
82
|
const currentPath = Astro.url.pathname;
|
|
76
|
-
|
|
77
83
|
---
|
|
78
84
|
|
|
79
|
-
<div class="font-light w-full xl:pr-10 pb-20
|
|
85
|
+
<div class="font-light w-full xl:pr-10 pb-20">
|
|
80
86
|
{
|
|
81
87
|
Object.keys(sideNav).map((key) => {
|
|
82
88
|
const collection = sideNav[key];
|
|
83
|
-
if(collection[0] && collection[0].visible === false) return null;
|
|
89
|
+
if (collection[0] && collection[0].visible === false) return null;
|
|
84
90
|
return (
|
|
85
91
|
<ul class=" w-full space-y-2 pb-8">
|
|
86
92
|
<li class="font-semibold capitalize ">{key}</li>
|
|
87
93
|
{collection.map((item: any) => {
|
|
88
94
|
return (
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
<li class="px-2 w-full text-md xl:text-lg border-l border-gray-200 space-y-2 scroll-m-20" id={item.href}>
|
|
96
|
+
<a
|
|
97
|
+
class={`flex justify-between items-center w-full px-2 rounded-md font-normal ${currentPath.includes(item.href) ? 'bg-purple-200 text-purple-800 ' : 'font-thin'}`}
|
|
98
|
+
href={`${item.href}`}
|
|
99
|
+
>
|
|
100
|
+
<span class="block truncate !whitespace-normal">{item.label}</span>
|
|
101
|
+
{item.version && (
|
|
102
|
+
<span class="block text-sm bg-purple-100 p-0.5 px-1 text-gray-600 rounded-md font-light">
|
|
103
|
+
v{item.version}
|
|
104
|
+
</span>
|
|
105
|
+
)}
|
|
93
106
|
</a>
|
|
94
107
|
<ul class="hidden xl:block px-4 text-gray-500 text-md space-y-2 ">
|
|
95
108
|
{item.items.map((heading: any) => {
|
|
96
109
|
return (
|
|
97
110
|
<li class="text-xs">
|
|
98
|
-
<a href={`${item.href}
|
|
111
|
+
<a href={`${item.href}#${heading.slug}`}>{heading.text}</a>
|
|
99
112
|
</li>
|
|
100
113
|
);
|
|
101
114
|
})}
|
|
@@ -121,10 +134,6 @@ const currentPath = Astro.url.pathname;
|
|
|
121
134
|
block: 'start',
|
|
122
135
|
inline: 'start',
|
|
123
136
|
});
|
|
124
|
-
|
|
125
|
-
// currentElement.scrollIntoView({
|
|
126
|
-
// behavior: 'auto'
|
|
127
|
-
// });
|
|
128
137
|
}
|
|
129
138
|
});
|
|
130
|
-
</script>
|
|
139
|
+
</script>
|
|
@@ -17,16 +17,16 @@ const navItems = [
|
|
|
17
17
|
{
|
|
18
18
|
label: 'Discover',
|
|
19
19
|
href: buildUrl('/discover/events'),
|
|
20
|
-
}
|
|
20
|
+
},
|
|
21
21
|
];
|
|
22
22
|
|
|
23
23
|
const logo = {
|
|
24
24
|
src: ('/' + (catalog?.logo?.src || 'logo.png')).replace(/^\/+/, '/'), // replace the leading slashes with a single one
|
|
25
25
|
alt: catalog?.logo?.alt || 'Event Catalog',
|
|
26
|
-
text: catalog?.logo?.text ||
|
|
27
|
-
}
|
|
28
|
-
|
|
26
|
+
text: catalog?.logo?.text || 'EventCatalog',
|
|
27
|
+
};
|
|
29
28
|
---
|
|
29
|
+
|
|
30
30
|
<nav class="md:fixed top-0 w-full z-20 bg-white border-b border-gray-200 py-4 font-bold text-xl max-w-[70em]">
|
|
31
31
|
<div class="flex justify-between items-center">
|
|
32
32
|
<div class="w-1/3 flex space-x-2 items-center">
|
|
@@ -57,14 +57,17 @@ const logo = {
|
|
|
57
57
|
</div> -->
|
|
58
58
|
<div class="w-1/3 justify-end text-md">
|
|
59
59
|
<ul class="text-right flex justify-end space-x-8">
|
|
60
|
-
{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
{
|
|
61
|
+
navItems.map((item) => {
|
|
62
|
+
const isActive = currentPath.includes(item.href);
|
|
63
|
+
return (
|
|
64
|
+
<li class={`font-light ${isActive ? 'border-b-2 border-purple-500' : ''}`}>
|
|
65
|
+
<a href={item.href}>{item.label}</a>
|
|
66
|
+
</li>
|
|
67
|
+
);
|
|
68
|
+
})
|
|
69
|
+
}
|
|
66
70
|
</ul>
|
|
67
71
|
</div>
|
|
68
72
|
</div>
|
|
69
73
|
</nav>
|
|
70
|
-
|
|
@@ -4,34 +4,46 @@ import { buildUrl } from '@utils/url-builder';
|
|
|
4
4
|
import type { CollectionEntry } from 'astro:content';
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
|
-
versions: string[]
|
|
8
|
-
collectionItem: CollectionEntry<CollectionTypes
|
|
7
|
+
versions: string[];
|
|
8
|
+
collectionItem: CollectionEntry<CollectionTypes>;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
const { versions, collectionItem } = Astro.props;
|
|
12
12
|
const currentPath = Astro.url.pathname;
|
|
13
|
-
|
|
14
13
|
---
|
|
15
14
|
|
|
16
15
|
<div class="space-y-2 my-2 mb-8">
|
|
17
|
-
<span class="font-light text-black group-data-[hover]:text-black/80 capitalize"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
<span class="font-light text-black group-data-[hover]:text-black/80 capitalize"
|
|
17
|
+
>Versions ({collectionItem.data.versions?.length})</span
|
|
18
|
+
>
|
|
19
|
+
<select id="version" class="block bg-gray-50 rounded-md border border-gray-200 px-1 py-0.5 text-xs">
|
|
20
|
+
{
|
|
21
|
+
versions.map((version) => {
|
|
22
|
+
const isCurrent = currentPath.includes(version);
|
|
23
|
+
return (
|
|
24
|
+
<option
|
|
25
|
+
selected={isCurrent}
|
|
26
|
+
value={buildUrl(`/docs/${collectionItem.collection}/${collectionItem.data.id}/${version}`)}
|
|
27
|
+
class={`inline-flex items-center rounded-md px-2 py-1 text-xs text-indigo-700 ring-1 ring-inset ring-indigo-700/10 hover:bg-purple-100 hover:underline ${isCurrent ? 'bg-purple-100 text-purple-500 underline ' : 'bg-white'}`}
|
|
28
|
+
>
|
|
29
|
+
<span>
|
|
30
|
+
v{version}
|
|
31
|
+
{version === collectionItem.data.latestVersion && <span>(latest)</span>}
|
|
32
|
+
</span>
|
|
33
|
+
</option>
|
|
34
|
+
);
|
|
35
|
+
})
|
|
36
|
+
}
|
|
28
37
|
</select>
|
|
29
|
-
<a
|
|
38
|
+
<a
|
|
39
|
+
href={buildUrl(`/docs/${collectionItem.collection}/${collectionItem.data.id}/${collectionItem.data.latestVersion}/changelog`)}
|
|
40
|
+
class="text-[10px] text-gray-500">View changelogs</a
|
|
41
|
+
>
|
|
30
42
|
</div>
|
|
31
43
|
|
|
32
44
|
<script>
|
|
33
45
|
document.getElementById('version')?.addEventListener('change', (e: any) => {
|
|
34
|
-
if (!e.target) return
|
|
46
|
+
if (!e.target) return;
|
|
35
47
|
window.location.href = e.target.value;
|
|
36
|
-
})
|
|
48
|
+
});
|
|
37
49
|
</script>
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
---
|
|
2
|
-
import AccordionClient from './Accordion'
|
|
3
|
-
const {...props } = Astro.props;
|
|
2
|
+
import AccordionClient from './Accordion';
|
|
3
|
+
const { ...props } = Astro.props;
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
<AccordionClient {...props} client:load>
|
|
7
|
-
|
|
8
|
-
</AccordionClient>
|
|
9
|
-
|
|
6
|
+
<AccordionClient {...props} client:load>
|
|
7
|
+
<slot />
|
|
8
|
+
</AccordionClient>
|
|
@@ -5,7 +5,6 @@ import { getNodesAndEdges as getNodesAndEdgesForEvent } from '@utils/events/node
|
|
|
5
5
|
import { getNodesAndEdges as getNodesAndEdgesForCommand } from '@utils/commands/node-graph';
|
|
6
6
|
import { getNodesAndEdges as getNodesAndEdgesForDomain } from '@utils/domains/node-graph';
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
interface Props {
|
|
10
9
|
id: string;
|
|
11
10
|
collection: string;
|
|
@@ -19,7 +18,7 @@ interface Props {
|
|
|
19
18
|
};
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
const { id, collection, title, mode = 'simple', linkTo='docs', version, href } = Astro.props;
|
|
21
|
+
const { id, collection, title, mode = 'simple', linkTo = 'docs', version, href } = Astro.props;
|
|
23
22
|
let nodes = [],
|
|
24
23
|
edges = [];
|
|
25
24
|
|
|
@@ -56,7 +55,7 @@ if (collection === 'commands') {
|
|
|
56
55
|
edges = eventEdges;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
if(collection === 'domains'){
|
|
58
|
+
if (collection === 'domains') {
|
|
60
59
|
const { nodes: eventNodes, edges: eventEdges } = await getNodesAndEdgesForDomain({
|
|
61
60
|
id: id,
|
|
62
61
|
version,
|
|
@@ -66,17 +65,23 @@ if(collection === 'domains'){
|
|
|
66
65
|
nodes = eventNodes;
|
|
67
66
|
edges = eventEdges;
|
|
68
67
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
68
|
---
|
|
73
69
|
|
|
74
70
|
<div>
|
|
75
|
-
<NodeGraphNew
|
|
71
|
+
<NodeGraphNew
|
|
72
|
+
id={id}
|
|
73
|
+
nodes={nodes}
|
|
74
|
+
edges={edges}
|
|
75
|
+
title={title}
|
|
76
|
+
hrefLabel={href.label}
|
|
77
|
+
href={href.url}
|
|
78
|
+
linkTo={linkTo}
|
|
79
|
+
client:load
|
|
80
|
+
/>
|
|
76
81
|
</div>
|
|
77
82
|
|
|
78
83
|
<style is:global>
|
|
79
84
|
.react-flow__attribution {
|
|
80
85
|
display: none;
|
|
81
86
|
}
|
|
82
|
-
</style>
|
|
87
|
+
</style>
|
|
@@ -3,19 +3,19 @@ const { catalog, id } = Astro.props;
|
|
|
3
3
|
import fs from 'node:fs/promises';
|
|
4
4
|
import { existsSync } from 'fs';
|
|
5
5
|
import path from 'path';
|
|
6
|
-
import SchemaViewerClient from './SchemaViewer'
|
|
6
|
+
import SchemaViewerClient from './SchemaViewer';
|
|
7
7
|
import Admonition from '../Admonition';
|
|
8
8
|
let schemas = [];
|
|
9
9
|
|
|
10
10
|
function findSchemaViewers(document: string) {
|
|
11
11
|
// Define regex pattern to match <SchemaViewer ... />
|
|
12
12
|
const pattern = /<SchemaViewer\s+([^>]*)\/>/g;
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
// Find all matches of the pattern
|
|
15
15
|
const matches = [...document.matchAll(pattern)];
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
// Extract the properties of each SchemaViewer
|
|
18
|
-
const schemaViewers = matches.map(match => {
|
|
18
|
+
const schemaViewers = matches.map((match) => {
|
|
19
19
|
const propsString = match[1];
|
|
20
20
|
const props = {};
|
|
21
21
|
|
|
@@ -36,59 +36,54 @@ function findSchemaViewers(document: string) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
try {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// Loop around all the possible SchemaViewers in the file.
|
|
43
|
-
const getAllComponents = schemaViewers.map(async (schemaViewerProps: any) => {
|
|
39
|
+
const file = await fs.readFile(catalog.absoluteFilePath, 'utf-8');
|
|
40
|
+
const schemaViewers = findSchemaViewers(file);
|
|
44
41
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
// Loop around all the possible SchemaViewers in the file.
|
|
43
|
+
const getAllComponents = schemaViewers.map(async (schemaViewerProps: any) => {
|
|
44
|
+
const schemaPath = path.join(catalog.filePath, schemaViewerProps.file);
|
|
45
|
+
const exists = existsSync(schemaPath);
|
|
46
|
+
let schema;
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
if (exists) {
|
|
49
|
+
// Load the schema for the component
|
|
50
|
+
schema = await fs.readFile(schemaPath, 'utf-8');
|
|
51
|
+
schema = JSON.parse(schema);
|
|
52
|
+
}
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
schemas = await Promise.all(getAllComponents);
|
|
54
|
+
return {
|
|
55
|
+
id: schemaViewerProps.id || id,
|
|
56
|
+
exists,
|
|
57
|
+
schema,
|
|
58
|
+
schemaPath,
|
|
59
|
+
...schemaViewerProps,
|
|
60
|
+
};
|
|
61
|
+
});
|
|
65
62
|
|
|
63
|
+
schemas = await Promise.all(getAllComponents);
|
|
66
64
|
} catch (error) {
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
console.log('Failed to process schemas');
|
|
66
|
+
console.log(error);
|
|
69
67
|
}
|
|
70
|
-
|
|
71
68
|
---
|
|
72
|
-
<section class="space-y-4">
|
|
73
|
-
{schemas.length > 0 &&
|
|
74
|
-
schemas.map((schema) => (
|
|
75
|
-
<div>
|
|
76
|
-
|
|
77
|
-
{schema.exists &&
|
|
78
|
-
<SchemaViewerClient {...schema} client:load />
|
|
79
|
-
}
|
|
80
69
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
</>
|
|
88
|
-
</Admonition>
|
|
89
|
-
)}
|
|
70
|
+
<section class="space-y-4">
|
|
71
|
+
{
|
|
72
|
+
schemas.length > 0 &&
|
|
73
|
+
schemas.map((schema) => (
|
|
74
|
+
<div>
|
|
75
|
+
{schema.exists && <SchemaViewerClient {...schema} client:load />}
|
|
90
76
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
77
|
+
{/* User has tried to load the schema, but it was not found on file system */}
|
|
78
|
+
{!schema.exists && (
|
|
79
|
+
<Admonition type="warning">
|
|
80
|
+
<>
|
|
81
|
+
<span class="block font-bold">{`<SchemaViewer/>`} failed to load</span>
|
|
82
|
+
<span class="block">Tried to load schema from {schema.schemaPath}, but no schema can be found</span>
|
|
83
|
+
</>
|
|
84
|
+
</Admonition>
|
|
85
|
+
)}
|
|
86
|
+
</div>
|
|
87
|
+
))
|
|
88
|
+
}
|
|
94
89
|
</section>
|
|
@@ -21,10 +21,21 @@ import PageFindSearch from 'astro-pagefind/components/Search';
|
|
|
21
21
|
<div id="search-dialog" class="hidden relative z-10" role="dialog" aria-modal="true">
|
|
22
22
|
<div class="fixed inset-0 bg-gray-500 bg-opacity-25 transition-opacity search-background backdrop-blur-sm bg-black/10"></div>
|
|
23
23
|
<div id="search-background" class="fixed inset-0 z-10 w-screen overflow-y-auto p-4 sm:p-6 md:p-20">
|
|
24
|
-
<div
|
|
24
|
+
<div
|
|
25
|
+
id="command-pal"
|
|
26
|
+
class="mx-auto max-w-xl divide-y divide-gray-100 overflow-hidden rounded-xl bg-white shadow-2xl ring-1 ring-black ring-opacity-5 transition-all"
|
|
27
|
+
>
|
|
25
28
|
<div class="relative">
|
|
26
|
-
<svg
|
|
27
|
-
|
|
29
|
+
<svg
|
|
30
|
+
class="pointer-events-none absolute left-4 top-3.5 h-5 w-5 text-gray-400"
|
|
31
|
+
viewBox="0 0 20 20"
|
|
32
|
+
fill="currentColor"
|
|
33
|
+
aria-hidden="true"
|
|
34
|
+
>
|
|
35
|
+
<path
|
|
36
|
+
fill-rule="evenodd"
|
|
37
|
+
d="M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z"
|
|
38
|
+
clip-rule="evenodd"></path>
|
|
28
39
|
</svg>
|
|
29
40
|
<PageFindSearch id="search" className="pagefind-ui" uiOptions={{ showImages: false }} />
|
|
30
41
|
</div>
|
|
@@ -42,8 +53,8 @@ import PageFindSearch from 'astro-pagefind/components/Search';
|
|
|
42
53
|
event.preventDefault();
|
|
43
54
|
dummyInput?.click();
|
|
44
55
|
}
|
|
45
|
-
if(event.key === 'Escape') {
|
|
46
|
-
if(dialog){
|
|
56
|
+
if (event.key === 'Escape') {
|
|
57
|
+
if (dialog) {
|
|
47
58
|
dialog.style.display = 'none';
|
|
48
59
|
}
|
|
49
60
|
}
|