@eventcatalog/core 2.42.9 → 2.43.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.
- 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.js +2 -2
- package/dist/{chunk-4A2C2PVU.js → chunk-4DXH4NAT.js} +1 -1
- package/dist/{chunk-OQA3PAMR.js → chunk-IZ7E57FH.js} +1 -1
- package/dist/{chunk-HDG7YSFG.js → chunk-LUUBKWYP.js} +8 -0
- package/dist/{chunk-ISA6KNLN.js → chunk-MXNHNGRS.js} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/eventcatalog.auth.cjs +18 -0
- package/dist/eventcatalog.auth.d.cts +18 -0
- package/dist/eventcatalog.auth.d.ts +18 -0
- package/dist/eventcatalog.auth.js +0 -0
- package/dist/eventcatalog.cjs +50 -23
- package/dist/eventcatalog.js +29 -8
- package/dist/features.cjs +9 -0
- package/dist/features.d.cts +2 -1
- package/dist/features.d.ts +2 -1
- package/dist/features.js +3 -1
- package/dist/watcher.js +1 -1
- package/eventcatalog/astro.config.mjs +7 -3
- package/eventcatalog/auth.config.ts +142 -0
- package/eventcatalog/src/components/Header.astro +125 -25
- package/eventcatalog/src/middleware.ts +62 -0
- package/eventcatalog/src/pages/auth/error.astro +55 -0
- package/eventcatalog/src/pages/auth/login.astro +231 -0
- package/eventcatalog/src/pages/directory/[type]/_index.data.ts +63 -0
- package/eventcatalog/src/pages/directory/[type]/index.astro +6 -23
- package/eventcatalog/src/pages/discover/[type]/_index.data.ts +62 -0
- package/eventcatalog/src/pages/discover/[type]/index.astro +7 -24
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/_index.data.ts +62 -0
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/asyncapi/[filename].astro +5 -37
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/asyncapi/_[filename].data.ts +98 -0
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/changelog/_index.data.ts +68 -0
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/changelog/index.astro +5 -25
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/index.astro +6 -25
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/spec/[filename].astro +6 -35
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/spec/_[filename].data.ts +99 -0
- package/eventcatalog/src/pages/docs/[type]/[id]/index.astro +1 -0
- package/eventcatalog/src/pages/docs/[type]/[id]/language/_index.data.ts +40 -0
- package/eventcatalog/src/pages/docs/[type]/[id]/{language.astro → language/index.astro} +6 -20
- package/eventcatalog/src/pages/docs/custom/[...path]/_index.data.ts +49 -0
- package/eventcatalog/src/pages/docs/custom/[...path]/index.astro +5 -11
- package/eventcatalog/src/pages/docs/teams/[id]/_index.data.ts +46 -0
- package/eventcatalog/src/pages/docs/teams/[id]/index.astro +6 -10
- package/eventcatalog/src/pages/docs/users/[id]/_index.data.ts +46 -0
- package/eventcatalog/src/pages/docs/users/[id]/index.astro +5 -9
- package/eventcatalog/src/pages/visualiser/[type]/[id]/[version]/_index.data.ts +99 -0
- package/eventcatalog/src/pages/visualiser/[type]/[id]/[version]/index.astro +5 -29
- package/eventcatalog/src/utils/feature.ts +10 -0
- package/eventcatalog/src/utils/node-graphs/domains-node-graph.ts +12 -1
- package/eventcatalog/src/utils/node-graphs/services-node-graph.ts +11 -1
- package/eventcatalog/src/utils/page-loaders/hybrid-page.ts +68 -0
- package/eventcatalog/tsconfig.json +2 -1
- package/package.json +3 -1
- package/dist/{chunk-SLEMYHTU.js → chunk-SFA7F3CQ.js} +3 -3
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// pages/docs/[type]/[id]/[version]/spec/[filename]/index.page.ts
|
|
2
|
+
import { isSSR } from '@utils/feature';
|
|
3
|
+
import { HybridPage } from '@utils/page-loaders/hybrid-page';
|
|
4
|
+
import type { CollectionEntry } from 'astro:content';
|
|
5
|
+
import type { CollectionTypes, PageTypes } from '@types';
|
|
6
|
+
|
|
7
|
+
export class Page extends HybridPage {
|
|
8
|
+
static get prerender(): boolean {
|
|
9
|
+
return !isSSR();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static async getStaticPaths(): Promise<Array<{ params: any; props: any }>> {
|
|
13
|
+
if (isSSR()) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const { pageDataLoader } = await import('@utils/page-loaders/page-data-loader');
|
|
18
|
+
const { getSpecificationsForService } = await import('@utils/collections/services');
|
|
19
|
+
|
|
20
|
+
const itemTypes: PageTypes[] = ['events', 'commands', 'queries', 'services', 'domains'];
|
|
21
|
+
const allItems = await Promise.all(itemTypes.map((type) => pageDataLoader[type]()));
|
|
22
|
+
|
|
23
|
+
const hasSpecifications = (item: CollectionEntry<CollectionTypes>) => {
|
|
24
|
+
const specifications = getSpecificationsForService(item);
|
|
25
|
+
// Ensure there is at least one 'openapi' specification
|
|
26
|
+
return specifications && specifications.some((spec) => spec.type === 'openapi');
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const filteredItems = allItems.map((items) => items.filter(hasSpecifications));
|
|
30
|
+
|
|
31
|
+
return filteredItems.flatMap((items, index) =>
|
|
32
|
+
items.flatMap((item) => {
|
|
33
|
+
// Filter for openapi specifications only
|
|
34
|
+
const openApiSpecifications = getSpecificationsForService(item).filter((spec) => spec.type === 'openapi');
|
|
35
|
+
|
|
36
|
+
return openApiSpecifications.map((spec) => ({
|
|
37
|
+
params: {
|
|
38
|
+
type: itemTypes[index],
|
|
39
|
+
id: item.data.id,
|
|
40
|
+
version: item.data.version,
|
|
41
|
+
filename: spec.filenameWithoutExtension || spec.type,
|
|
42
|
+
},
|
|
43
|
+
props: {
|
|
44
|
+
type: itemTypes[index],
|
|
45
|
+
filenameWithoutExtension: spec.filenameWithoutExtension || spec.type,
|
|
46
|
+
filename: spec.filename || spec.type,
|
|
47
|
+
...item,
|
|
48
|
+
},
|
|
49
|
+
}));
|
|
50
|
+
})
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
protected static async fetchData(params: any) {
|
|
55
|
+
const { type, id, version, filename } = params;
|
|
56
|
+
|
|
57
|
+
if (!type || !id || !version || !filename) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const { pageDataLoader } = await import('@utils/page-loaders/page-data-loader');
|
|
62
|
+
const { getSpecificationsForService } = await import('@utils/collections/services');
|
|
63
|
+
|
|
64
|
+
// Get all items of the specified type
|
|
65
|
+
const items = await pageDataLoader[type as PageTypes]();
|
|
66
|
+
|
|
67
|
+
// Find the specific item by id and version
|
|
68
|
+
const item = items.find((i) => i.data.id === id && i.data.version === version);
|
|
69
|
+
|
|
70
|
+
if (!item) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Check if this item has OpenAPI specifications
|
|
75
|
+
const specifications = getSpecificationsForService(item);
|
|
76
|
+
const openApiSpecifications = specifications.filter((spec) => spec.type === 'openapi');
|
|
77
|
+
|
|
78
|
+
// Find the specific specification
|
|
79
|
+
const spec = openApiSpecifications.find((s) => (s.filenameWithoutExtension || s.type) === filename);
|
|
80
|
+
|
|
81
|
+
if (!spec) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
type,
|
|
87
|
+
filenameWithoutExtension: spec.filenameWithoutExtension || spec.type,
|
|
88
|
+
filename: spec.filename || spec.type,
|
|
89
|
+
...item,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
protected static createNotFoundResponse(): Response {
|
|
94
|
+
return new Response(null, {
|
|
95
|
+
status: 404,
|
|
96
|
+
statusText: 'OpenAPI specification not found',
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { isSSR } from '@utils/feature';
|
|
2
|
+
import { HybridPage } from '@utils/page-loaders/hybrid-page';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Domain page class with static methods
|
|
6
|
+
*/
|
|
7
|
+
export class Page extends HybridPage {
|
|
8
|
+
static async getStaticPaths() {
|
|
9
|
+
if (isSSR()) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { getDomains } = await import('@utils/collections/domains');
|
|
14
|
+
const domains = await getDomains({ getAllVersions: false });
|
|
15
|
+
|
|
16
|
+
return domains.map((item) => ({
|
|
17
|
+
params: {
|
|
18
|
+
type: item.collection,
|
|
19
|
+
id: item.data.id,
|
|
20
|
+
},
|
|
21
|
+
props: {
|
|
22
|
+
type: item.collection,
|
|
23
|
+
...item,
|
|
24
|
+
},
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
protected static async fetchData(params: any) {
|
|
29
|
+
const { getDomains } = await import('@utils/collections/domains');
|
|
30
|
+
const domains = await getDomains({ getAllVersions: false });
|
|
31
|
+
return domains.find((d) => d.data.id === params.id && d.collection === params.type) || null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
protected static createNotFoundResponse(): Response {
|
|
35
|
+
return new Response(null, {
|
|
36
|
+
status: 404,
|
|
37
|
+
statusText: 'Domain not found',
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -1,35 +1,21 @@
|
|
|
1
1
|
---
|
|
2
2
|
import Footer from '@layouts/Footer.astro';
|
|
3
3
|
import VerticalSideBarLayout from '@layouts/VerticalSideBarLayout.astro';
|
|
4
|
-
import {
|
|
4
|
+
import { getUbiquitousLanguage } from '@utils/collections/domains';
|
|
5
5
|
import { buildUrl } from '@utils/url-builder';
|
|
6
|
-
import type { CollectionEntry } from 'astro:content';
|
|
7
6
|
import { ClientRouter } from 'astro:transitions';
|
|
8
7
|
import * as LucideIcons from 'lucide-react';
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
const domains = await getDomains({ getAllVersions: false });
|
|
9
|
+
import { Page } from './_index.data';
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
params: {
|
|
16
|
-
type: item.collection,
|
|
17
|
-
id: item.data.id,
|
|
18
|
-
},
|
|
19
|
-
props: {
|
|
20
|
-
type: item.collection,
|
|
21
|
-
...item,
|
|
22
|
-
},
|
|
23
|
-
}));
|
|
24
|
-
};
|
|
11
|
+
export const prerender = Page.prerender;
|
|
12
|
+
export const getStaticPaths = Page.getStaticPaths;
|
|
25
13
|
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
// Get data
|
|
15
|
+
const props = await Page.getData(Astro);
|
|
28
16
|
|
|
29
|
-
const props = Astro.props;
|
|
30
17
|
const pageTitle = `${props.collection} | ${props.data.name}`.replace(/^\w/, (c) => c.toUpperCase());
|
|
31
18
|
const ubiquitousLanguages = await getUbiquitousLanguage(props);
|
|
32
|
-
|
|
33
19
|
const ubiquitousLanguage = ubiquitousLanguages[0];
|
|
34
20
|
---
|
|
35
21
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// pages/docs/custom/[...path]/index.page.ts
|
|
2
|
+
import { isSSR } from '@utils/feature';
|
|
3
|
+
import { HybridPage } from '@utils/page-loaders/hybrid-page';
|
|
4
|
+
|
|
5
|
+
export class Page extends HybridPage {
|
|
6
|
+
static get prerender(): boolean {
|
|
7
|
+
return !isSSR();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static async getStaticPaths(): Promise<Array<{ params: any; props: any }>> {
|
|
11
|
+
if (isSSR()) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { getCollection } = await import('astro:content');
|
|
16
|
+
const docs = await getCollection('customPages');
|
|
17
|
+
|
|
18
|
+
const paths = docs.map((doc) => ({
|
|
19
|
+
params: { path: doc.id.replace('docs/', '') },
|
|
20
|
+
props: doc,
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
return paths;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
protected static async fetchData(params: any) {
|
|
27
|
+
const { path } = params;
|
|
28
|
+
|
|
29
|
+
if (!path) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const { getCollection } = await import('astro:content');
|
|
34
|
+
const docs = await getCollection('customPages');
|
|
35
|
+
|
|
36
|
+
// Find the specific doc by reconstructing the id
|
|
37
|
+
const docId = `docs/${Array.isArray(path) ? path.join('/') : path}`;
|
|
38
|
+
const doc = docs.find((d) => d.id === docId);
|
|
39
|
+
|
|
40
|
+
return doc || null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
protected static createNotFoundResponse(): Response {
|
|
44
|
+
return new Response(null, {
|
|
45
|
+
status: 404,
|
|
46
|
+
statusText: 'Custom documentation page not found',
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
import CustomDocumentationPage from '@enterprise/custom-documentation/pages/docs/custom/index.astro';
|
|
3
|
-
import { getCollection } from 'astro:content';
|
|
4
3
|
import { buildUrl } from '@utils/url-builder';
|
|
5
|
-
import type { GetStaticPaths } from 'astro';
|
|
6
4
|
import { isCustomDocsEnabled } from '@utils/feature';
|
|
5
|
+
import { Page } from './_index.data';
|
|
7
6
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
const paths = docs.map((doc) => ({
|
|
11
|
-
params: { path: doc.id.replace('docs/', '') },
|
|
12
|
-
props: doc,
|
|
13
|
-
}));
|
|
14
|
-
return paths;
|
|
15
|
-
}) satisfies GetStaticPaths;
|
|
7
|
+
export const prerender = Page.prerender;
|
|
8
|
+
export const getStaticPaths = Page.getStaticPaths;
|
|
16
9
|
|
|
17
|
-
|
|
10
|
+
// Get data
|
|
11
|
+
const props = await Page.getData(Astro);
|
|
18
12
|
|
|
19
13
|
if (!isCustomDocsEnabled()) {
|
|
20
14
|
return Astro.redirect(buildUrl('/docs/custom/feature'));
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// pages/teams/[id]/index.page.ts
|
|
2
|
+
import { isSSR } from '@utils/feature';
|
|
3
|
+
import { HybridPage } from '@utils/page-loaders/hybrid-page';
|
|
4
|
+
|
|
5
|
+
export class Page extends HybridPage {
|
|
6
|
+
static get prerender(): boolean {
|
|
7
|
+
return !isSSR();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static async getStaticPaths(): Promise<Array<{ params: any; props: any }>> {
|
|
11
|
+
if (isSSR()) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { getTeams } = await import('@utils/teams');
|
|
16
|
+
const teams = await getTeams();
|
|
17
|
+
|
|
18
|
+
return teams.map((team) => ({
|
|
19
|
+
params: { id: team.data.id },
|
|
20
|
+
props: team,
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
protected static async fetchData(params: any) {
|
|
25
|
+
const { id } = params;
|
|
26
|
+
|
|
27
|
+
if (!id) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const { getTeams } = await import('@utils/teams');
|
|
32
|
+
const teams = await getTeams();
|
|
33
|
+
|
|
34
|
+
// Find the specific team by id
|
|
35
|
+
const team = teams.find((t) => t.data.id === id);
|
|
36
|
+
|
|
37
|
+
return team || null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
protected static createNotFoundResponse(): Response {
|
|
41
|
+
return new Response(null, {
|
|
42
|
+
status: 404,
|
|
43
|
+
statusText: 'Team not found',
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import components from '@components/MDX/components';
|
|
3
3
|
|
|
4
4
|
// SideBars
|
|
5
|
-
import { getTeams } from '@utils/teams';
|
|
6
5
|
import { getEntry, render } from 'astro:content';
|
|
7
6
|
import type { CollectionEntry } from 'astro:content';
|
|
8
7
|
import OwnersList from '@components/Lists/OwnersList';
|
|
@@ -10,21 +9,18 @@ import PillListFlat from '@components/Lists/PillListFlat';
|
|
|
10
9
|
import EnvelopeIcon from '@heroicons/react/16/solid/EnvelopeIcon';
|
|
11
10
|
import { buildUrl } from '@utils/url-builder';
|
|
12
11
|
import VerticalSideBarLayout from '@layouts/VerticalSideBarLayout.astro';
|
|
12
|
+
import { Page } from './_index.data';
|
|
13
13
|
|
|
14
|
-
export
|
|
15
|
-
|
|
14
|
+
export const prerender = Page.prerender;
|
|
15
|
+
export const getStaticPaths = Page.getStaticPaths;
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
props: team,
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
17
|
+
// Get data
|
|
18
|
+
const props = await Page.getData(Astro);
|
|
22
19
|
|
|
23
|
-
const props = Astro.props;
|
|
24
20
|
const { Content } = await render(props);
|
|
25
21
|
|
|
26
22
|
const membersRaw = props.data.members || [];
|
|
27
|
-
const members = (await Promise.all(membersRaw.map((m) => getEntry(m)))).filter(Boolean);
|
|
23
|
+
const members = (await Promise.all(membersRaw.map((m: CollectionEntry<'teams'>) => getEntry(m)))).filter(Boolean);
|
|
28
24
|
|
|
29
25
|
const domains = props.data.ownedDomains as CollectionEntry<'domains'>[];
|
|
30
26
|
const services = props.data.ownedServices as CollectionEntry<'services'>[];
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// pages/teams/[id]/index.page.ts
|
|
2
|
+
import { isSSR } from '@utils/feature';
|
|
3
|
+
import { HybridPage } from '@utils/page-loaders/hybrid-page';
|
|
4
|
+
|
|
5
|
+
export class Page extends HybridPage {
|
|
6
|
+
static get prerender(): boolean {
|
|
7
|
+
return !isSSR();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
static async getStaticPaths(): Promise<Array<{ params: any; props: any }>> {
|
|
11
|
+
if (isSSR()) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { getUsers } = await import('@utils/users');
|
|
16
|
+
const users = await getUsers();
|
|
17
|
+
|
|
18
|
+
return users.map((user) => ({
|
|
19
|
+
params: { id: user.data.id },
|
|
20
|
+
props: user,
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
protected static async fetchData(params: any) {
|
|
25
|
+
const { id } = params;
|
|
26
|
+
|
|
27
|
+
if (!id) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const { getUsers } = await import('@utils/users');
|
|
32
|
+
const users = await getUsers();
|
|
33
|
+
|
|
34
|
+
// Find the specific team by id
|
|
35
|
+
const user = users.find((u) => u.data.id === id);
|
|
36
|
+
|
|
37
|
+
return user || null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
protected static createNotFoundResponse(): Response {
|
|
41
|
+
return new Response(null, {
|
|
42
|
+
status: 404,
|
|
43
|
+
statusText: 'User not found',
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -6,21 +6,17 @@ import { render } from 'astro:content';
|
|
|
6
6
|
import type { CollectionEntry } from 'astro:content';
|
|
7
7
|
import OwnersList from '@components/Lists/OwnersList';
|
|
8
8
|
import PillListFlat from '@components/Lists/PillListFlat';
|
|
9
|
-
import { getUsers } from '@utils/users';
|
|
10
9
|
import EnvelopeIcon from '@heroicons/react/16/solid/EnvelopeIcon';
|
|
11
10
|
import { buildUrl } from '@utils/url-builder';
|
|
12
11
|
import VerticalSideBarLayout from '@layouts/VerticalSideBarLayout.astro';
|
|
12
|
+
import { Page } from './_index.data';
|
|
13
13
|
|
|
14
|
-
export
|
|
15
|
-
|
|
14
|
+
export const prerender = Page.prerender;
|
|
15
|
+
export const getStaticPaths = Page.getStaticPaths;
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
props: user,
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
17
|
+
// Get data
|
|
18
|
+
const props = await Page.getData(Astro);
|
|
22
19
|
|
|
23
|
-
const props = Astro.props;
|
|
24
20
|
const { Content } = await render(props);
|
|
25
21
|
|
|
26
22
|
const domains = props.data.ownedDomains as CollectionEntry<'domains'>[];
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// pages/visualiser/[type]/[id]/[version]/index.page.ts
|
|
2
|
+
import { HybridPage } from '@utils/page-loaders/hybrid-page';
|
|
3
|
+
import { isAuthEnabled } from '@utils/feature';
|
|
4
|
+
import type { PageTypes } from '@types';
|
|
5
|
+
import { pageDataLoader } from '@utils/page-loaders/page-data-loader';
|
|
6
|
+
|
|
7
|
+
type PageTypesWithFlows = PageTypes | 'flows';
|
|
8
|
+
|
|
9
|
+
export class Page extends HybridPage {
|
|
10
|
+
static async getStaticPaths(): Promise<Array<{ params: any; props: any }>> {
|
|
11
|
+
if (isAuthEnabled()) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { getFlows } = await import('@utils/collections/flows');
|
|
16
|
+
|
|
17
|
+
const loaders = {
|
|
18
|
+
...pageDataLoader,
|
|
19
|
+
flows: getFlows,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const itemTypes: PageTypesWithFlows[] = ['events', 'commands', 'queries', 'services', 'domains', 'flows'];
|
|
23
|
+
const allItems = await Promise.all(itemTypes.map((type) => loaders[type]()));
|
|
24
|
+
|
|
25
|
+
return allItems.flatMap((items, index) =>
|
|
26
|
+
items
|
|
27
|
+
.filter((item) => item.data.visualiser !== false)
|
|
28
|
+
.map((item) => ({
|
|
29
|
+
params: {
|
|
30
|
+
type: itemTypes[index],
|
|
31
|
+
id: item.data.id,
|
|
32
|
+
version: item.data.version,
|
|
33
|
+
},
|
|
34
|
+
props: {
|
|
35
|
+
type: itemTypes[index],
|
|
36
|
+
...item,
|
|
37
|
+
},
|
|
38
|
+
}))
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
protected static async fetchData(params: any) {
|
|
43
|
+
const { type, id, version } = params;
|
|
44
|
+
|
|
45
|
+
if (!type || !id || !version) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const { getFlows } = await import('@utils/collections/flows');
|
|
50
|
+
|
|
51
|
+
const loaders = {
|
|
52
|
+
...pageDataLoader,
|
|
53
|
+
flows: getFlows,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Get all items of the specified type
|
|
57
|
+
const items = await loaders[type as PageTypesWithFlows]();
|
|
58
|
+
|
|
59
|
+
// Find the specific item by id and version
|
|
60
|
+
const item = items.find((i) => i.data.id === id && i.data.version === version && i.data.visualiser !== false);
|
|
61
|
+
|
|
62
|
+
if (!item) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
type,
|
|
68
|
+
...item,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
protected static createNotFoundResponse(): Response {
|
|
73
|
+
return new Response(null, {
|
|
74
|
+
status: 404,
|
|
75
|
+
statusText: 'Visualiser page not found',
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static get clientAuthScript(): string {
|
|
80
|
+
if (!isAuthEnabled()) {
|
|
81
|
+
return '';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return `
|
|
85
|
+
if (typeof window !== 'undefined' && !import.meta.env.SSR) {
|
|
86
|
+
fetch('/api/auth/session')
|
|
87
|
+
.then(res => res.json())
|
|
88
|
+
.then(session => {
|
|
89
|
+
if (!session?.user) {
|
|
90
|
+
window.location.href = '/auth/login?callbackUrl=' + encodeURIComponent(window.location.pathname);
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
.catch(() => {
|
|
94
|
+
window.location.href = '/auth/login?callbackUrl=' + encodeURIComponent(window.location.pathname);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
`;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -2,40 +2,16 @@
|
|
|
2
2
|
import NodeGraph from '@components/MDX/NodeGraph/NodeGraph.astro';
|
|
3
3
|
import VisualiserLayout from '@layouts/VisualiserLayout.astro';
|
|
4
4
|
import type { PageTypes } from '@types';
|
|
5
|
-
import { getFlows } from '@utils/collections/flows';
|
|
6
5
|
import { buildUrl } from '@utils/url-builder';
|
|
7
|
-
|
|
8
|
-
import { pageDataLoader } from '@utils/page-loaders/page-data-loader';
|
|
9
6
|
import { ClientRouter } from 'astro:transitions';
|
|
10
|
-
type PageTypesWithFlows = PageTypes | 'flows';
|
|
11
|
-
|
|
12
|
-
export async function getStaticPaths() {
|
|
13
|
-
const loaders = {
|
|
14
|
-
...pageDataLoader,
|
|
15
|
-
flows: getFlows,
|
|
16
|
-
};
|
|
17
7
|
|
|
18
|
-
|
|
19
|
-
const allItems = await Promise.all(itemTypes.map((type) => loaders[type]()));
|
|
8
|
+
import { Page } from './_index.data';
|
|
20
9
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.filter((item) => item.data.visualiser !== false)
|
|
24
|
-
.map((item) => ({
|
|
25
|
-
params: {
|
|
26
|
-
type: itemTypes[index],
|
|
27
|
-
id: item.data.id,
|
|
28
|
-
version: item.data.version,
|
|
29
|
-
},
|
|
30
|
-
props: {
|
|
31
|
-
type: itemTypes[index],
|
|
32
|
-
...item,
|
|
33
|
-
},
|
|
34
|
-
}))
|
|
35
|
-
);
|
|
36
|
-
}
|
|
10
|
+
export const prerender = Page.prerender;
|
|
11
|
+
export const getStaticPaths = Page.getStaticPaths;
|
|
37
12
|
|
|
38
|
-
|
|
13
|
+
// Get data
|
|
14
|
+
const props = await Page.getData(Astro);
|
|
39
15
|
|
|
40
16
|
const {
|
|
41
17
|
data: { id },
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import config from '@config';
|
|
15
|
+
import fs from 'fs';
|
|
16
|
+
import { join } from 'path';
|
|
15
17
|
|
|
16
18
|
// These functions check for valid, legally obtained access to premium features
|
|
17
19
|
export const isEventCatalogStarterEnabled = () => process.env.EVENTCATALOG_STARTER === 'true';
|
|
@@ -42,3 +44,11 @@ export const isEventCatalogUpgradeEnabled = () => !isEventCatalogStarterEnabled(
|
|
|
42
44
|
export const isCustomLandingPageEnabled = () => isEventCatalogStarterEnabled() || isEventCatalogScaleEnabled();
|
|
43
45
|
|
|
44
46
|
export const isMarkdownDownloadEnabled = () => config?.llmsTxt?.enabled ?? false;
|
|
47
|
+
|
|
48
|
+
export const isAuthEnabled = () => {
|
|
49
|
+
const directory = process.env.PROJECT_DIR || process.cwd();
|
|
50
|
+
const hasAuthConfig = fs.existsSync(join(directory, 'eventcatalog.auth.js'));
|
|
51
|
+
return (hasAuthConfig && isSSR() && isEventCatalogScaleEnabled()) || false;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const isSSR = () => config?.output === 'server';
|
|
@@ -17,6 +17,7 @@ type DagreGraph = any;
|
|
|
17
17
|
|
|
18
18
|
interface Props {
|
|
19
19
|
defaultFlow?: DagreGraph;
|
|
20
|
+
channelRenderMode?: 'single' | 'flat';
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export const getNodesAndEdgesForDomainContextMap = async ({ defaultFlow = null }: Props) => {
|
|
@@ -214,9 +215,17 @@ interface NodesAndEdgesProps {
|
|
|
214
215
|
defaultFlow?: DagreGraph;
|
|
215
216
|
mode: 'simple' | 'full';
|
|
216
217
|
group?: boolean;
|
|
218
|
+
channelRenderMode?: 'single' | 'flat';
|
|
217
219
|
}
|
|
218
220
|
|
|
219
|
-
export const getNodesAndEdges = async ({
|
|
221
|
+
export const getNodesAndEdges = async ({
|
|
222
|
+
id,
|
|
223
|
+
version,
|
|
224
|
+
defaultFlow,
|
|
225
|
+
mode = 'simple',
|
|
226
|
+
group = false,
|
|
227
|
+
channelRenderMode = 'flat',
|
|
228
|
+
}: NodesAndEdgesProps) => {
|
|
220
229
|
const flow = defaultFlow || createDagreGraph({ ranksep: 360, nodesep: 50, edgesep: 50 });
|
|
221
230
|
let nodes = new Map(),
|
|
222
231
|
edges = new Map();
|
|
@@ -257,6 +266,7 @@ export const getNodesAndEdges = async ({ id, version, defaultFlow, mode = 'simpl
|
|
|
257
266
|
defaultFlow: flow,
|
|
258
267
|
mode,
|
|
259
268
|
renderAllEdges: true,
|
|
269
|
+
channelRenderMode,
|
|
260
270
|
});
|
|
261
271
|
serviceNodes.forEach((n) => {
|
|
262
272
|
/**
|
|
@@ -280,6 +290,7 @@ export const getNodesAndEdges = async ({ id, version, defaultFlow, mode = 'simpl
|
|
|
280
290
|
defaultFlow: flow,
|
|
281
291
|
mode,
|
|
282
292
|
group: true,
|
|
293
|
+
channelRenderMode,
|
|
283
294
|
});
|
|
284
295
|
subDomainNodes.forEach((n) => {
|
|
285
296
|
nodes.set(n.id, nodes.has(n.id) ? merge(nodes.get(n.id), n) : n);
|
|
@@ -20,6 +20,7 @@ interface Props {
|
|
|
20
20
|
defaultFlow?: DagreGraph;
|
|
21
21
|
mode?: 'simple' | 'full';
|
|
22
22
|
renderAllEdges?: boolean;
|
|
23
|
+
channelRenderMode?: 'single' | 'flat';
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
const getSendsMessageByMessageType = (messageType: string) => {
|
|
@@ -47,7 +48,14 @@ const getReceivesMessageByMessageType = (messageType: string) => {
|
|
|
47
48
|
}
|
|
48
49
|
};
|
|
49
50
|
|
|
50
|
-
export const getNodesAndEdges = async ({
|
|
51
|
+
export const getNodesAndEdges = async ({
|
|
52
|
+
id,
|
|
53
|
+
defaultFlow,
|
|
54
|
+
version,
|
|
55
|
+
mode = 'simple',
|
|
56
|
+
renderAllEdges = false,
|
|
57
|
+
channelRenderMode = 'flat',
|
|
58
|
+
}: Props) => {
|
|
51
59
|
const flow = defaultFlow || createDagreGraph({ ranksep: 300, nodesep: 50 });
|
|
52
60
|
const nodes = [] as any,
|
|
53
61
|
edges = [] as any;
|
|
@@ -111,6 +119,7 @@ export const getNodesAndEdges = async ({ id, defaultFlow, version, mode = 'simpl
|
|
|
111
119
|
target: service,
|
|
112
120
|
mode,
|
|
113
121
|
currentNodes: nodes,
|
|
122
|
+
channelRenderMode,
|
|
114
123
|
});
|
|
115
124
|
|
|
116
125
|
nodes.push(...channelNodes);
|
|
@@ -158,6 +167,7 @@ export const getNodesAndEdges = async ({ id, defaultFlow, version, mode = 'simpl
|
|
|
158
167
|
sourceToChannelLabel: `${getSendsMessageByMessageType(send?.collection)}`,
|
|
159
168
|
channelToTargetLabel: getSendsMessageByMessageType(send?.collection),
|
|
160
169
|
currentNodes: nodes,
|
|
170
|
+
channelRenderMode,
|
|
161
171
|
});
|
|
162
172
|
nodes.push(...channelNodes);
|
|
163
173
|
edges.push(...channelEdges);
|