@eventcatalog/core 2.57.2 → 2.58.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/{chunk-IZVKIJ4Q.js → chunk-F3YDLMMR.js} +1 -1
- package/dist/{chunk-C2EHTPRH.js → chunk-N7MEYFUO.js} +1 -1
- package/dist/{chunk-A7SEN2P6.js → chunk-X4GKQ2ZE.js} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/eventcatalog.cjs +1 -1
- package/dist/eventcatalog.js +3 -3
- package/eventcatalog/public/icons/graphql.svg +1 -0
- package/eventcatalog/src/components/Lists/SpecificationsList.astro +15 -0
- package/eventcatalog/src/components/MDX/Attachments.astro +1 -1
- package/eventcatalog/src/components/SideNav/ListViewSideBar/components/SpecificationList.tsx +20 -0
- package/eventcatalog/src/content.config.ts +2 -1
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/graphql/[filename].astro +177 -0
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/graphql/_[filename].data.ts +98 -0
- package/eventcatalog/src/pages/docs/[type]/[id]/[version]/index.astro +17 -0
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
log_build_default
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-X4GKQ2ZE.js";
|
|
4
|
+
import "../chunk-F3YDLMMR.js";
|
|
5
|
+
import "../chunk-N7MEYFUO.js";
|
|
6
6
|
import "../chunk-UPONRQSN.js";
|
|
7
7
|
export {
|
|
8
8
|
log_build_default as default
|
package/dist/constants.cjs
CHANGED
package/dist/constants.js
CHANGED
package/dist/eventcatalog.cjs
CHANGED
package/dist/eventcatalog.js
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
} from "./chunk-PLNJC7NZ.js";
|
|
7
7
|
import {
|
|
8
8
|
log_build_default
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-X4GKQ2ZE.js";
|
|
10
|
+
import "./chunk-F3YDLMMR.js";
|
|
11
11
|
import {
|
|
12
12
|
catalogToAstro,
|
|
13
13
|
checkAndConvertMdToMdx
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import "./chunk-55D645EH.js";
|
|
16
16
|
import {
|
|
17
17
|
VERSION
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-N7MEYFUO.js";
|
|
19
19
|
import {
|
|
20
20
|
getProjectOutDir,
|
|
21
21
|
isAuthEnabled,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg viewBox="-16 0 288 288" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid" fill="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <g fill-rule="evenodd"> <path d="M152.575995,32.9634453 L211.722058,67.1124427 C213.387503,65.348329 215.332859,63.7907081 217.539734,62.5088708 C229.806457,55.4573413 245.452038,59.6441869 252.577021,71.9109101 C259.62855,84.1776333 255.441705,99.8232143 243.174982,106.948197 C240.984974,108.207124 238.684929,109.10784 236.343812,109.66832 L236.343812,177.99302 C238.659582,178.554683 240.934429,179.449686 243.101528,180.695443 C255.441705,187.820426 259.62855,203.466007 252.503568,215.73273 C245.452038,227.999453 229.733004,232.186299 217.46628,225.13477 C215.024105,223.730884 212.902189,221.983449 211.125456,219.988103 L152.340162,253.928803 C153.180519,256.46808 153.635248,259.18431 153.635248,262.008393 C153.635248,276.111452 142.176512,287.64364 128,287.64364 C113.823488,287.64364 102.364752,276.184905 102.364752,262.008393 C102.364752,259.488481 102.726802,257.054441 103.40181,254.755362 L44.2714887,220.615454 C42.6238257,222.34493 40.705394,223.873378 38.5337196,225.13477 C26.193543,232.186299 10.547962,227.999453 3.49643248,215.73273 C-3.55509701,203.466007 0.631748621,187.820426 12.8984718,180.695443 C15.0673397,179.448669 17.3418356,178.553222 19.6561876,177.991646 L19.6561876,109.66832 C17.3150714,109.10784 15.0150257,108.207124 12.8250184,106.948197 C0.558295189,99.8966677 -3.62855044,84.1776333 3.42297904,71.9109101 C10.4745085,59.6441869 26.193543,55.4573413 38.4602662,62.5088708 C40.6551374,63.7837361 42.5913269,65.3313931 44.2507413,67.0836756 L103.41276,32.9254664 C102.730718,30.6154532 102.364752,28.1687503 102.364752,25.6352478 C102.364752,11.4587354 113.823488,0 128,0 C142.176512,0 153.635248,11.4587354 153.635248,25.6352478 C153.635248,28.1826393 153.265258,30.6422768 152.575995,32.9634453 Z M146.413638,43.4848713 L205.700555,77.715193 C203.867899,84.1516888 204.540515,91.2885638 208.137694,97.5461579 C211.746601,103.824151 217.625783,107.985785 224.150543,109.607654 L224.150543,178.017842 C223.818032,178.099463 223.48718,178.187674 223.158201,178.282419 L145.72529,44.1686182 C145.959017,43.9450469 146.18851,43.7170876 146.413638,43.4848713 Z M110.29093,44.1841203 L32.8593279,178.295656 C32.524559,178.19844 32.1878611,178.108015 31.8494573,178.024438 L31.8494573,109.607654 C38.3742168,107.985785 44.2533992,103.824151 47.8623055,97.5461579 C51.466599,91.276189 52.1347497,84.1234583 50.2885426,77.6770157 L109.558747,43.4563434 C109.797913,43.7038019 110.042027,43.9464469 110.29093,44.1841203 Z M135.162749,50.259763 L212.576817,184.340928 C210.844241,185.99279 209.317376,187.91755 208.064241,190.097482 C206.818484,192.264581 205.923481,194.539429 205.361818,196.855198 L50.6395564,196.855198 C50.0779798,194.540846 49.1825333,192.26635 47.9357589,190.097482 C46.6776713,187.931497 45.1539248,186.017428 43.4300297,184.372667 L120.858821,50.2659993 C123.124941,50.9200822 125.520915,51.2704957 128,51.2704957 C130.486952,51.2704957 132.890265,50.9178547 135.162749,50.259763 Z M146.958084,244.737995 L205.860107,210.729899 C205.683398,210.174924 205.525483,209.614096 205.38664,209.048468 L50.6067643,209.048468 C50.5246888,209.380792 50.4360084,209.711472 50.3407792,210.040295 L109.531782,244.215239 C114.192298,239.378545 120.739739,236.373145 128,236.373145 C135.518379,236.373145 142.272352,239.596041 146.958084,244.737995 Z" fill="#E535AB"> </path> </g> </g></svg>
|
|
@@ -17,6 +17,7 @@ const specs = getSpecificationsForService(collectionItem as Service);
|
|
|
17
17
|
|
|
18
18
|
const openAPISpecifications = specs.filter((spec) => spec.type === 'openapi');
|
|
19
19
|
const asyncAPISpecifications = specs.filter((spec) => spec.type === 'asyncapi');
|
|
20
|
+
const graphQLSpecifications = specs.filter((spec) => spec.type === 'graphql');
|
|
20
21
|
---
|
|
21
22
|
|
|
22
23
|
<div class="space-y-2 mb-8">
|
|
@@ -49,4 +50,18 @@ const asyncAPISpecifications = specs.filter((spec) => spec.type === 'asyncapi');
|
|
|
49
50
|
</a>
|
|
50
51
|
))
|
|
51
52
|
}
|
|
53
|
+
{
|
|
54
|
+
graphQLSpecifications.length > 0 &&
|
|
55
|
+
graphQLSpecifications.map((spec) => (
|
|
56
|
+
<a
|
|
57
|
+
href={buildUrl(
|
|
58
|
+
`/docs/${collectionItem.collection}/${collectionItem.data.id}/${collectionItem.data.version}/graphql/${spec.filenameWithoutExtension}`
|
|
59
|
+
)}
|
|
60
|
+
class="px-1 text-sm font-light flex items-center space-x-1 hover:underline rounded-md hover:bg-gradient-to-l hover:from-purple-500 hover:to-purple-700 hover:text-white"
|
|
61
|
+
>
|
|
62
|
+
<img src={buildUrl('/icons/graphql.svg', true)} class="h-4 w-4" />
|
|
63
|
+
<span>{spec.name}</span>
|
|
64
|
+
</a>
|
|
65
|
+
))
|
|
66
|
+
}
|
|
52
67
|
</div>
|
|
@@ -91,7 +91,7 @@ const sortedGroups = Object.entries(groupedAttachments).sort(([a], [b]) => {
|
|
|
91
91
|
) : (
|
|
92
92
|
<div class="space-y-6">
|
|
93
93
|
{sortedGroups.map(([groupType, groupAttachments], index) => (
|
|
94
|
-
<div
|
|
94
|
+
<div>
|
|
95
95
|
<h4 class="text-sm font-medium text-gray-900 mb-3 uppercase tracking-wider">
|
|
96
96
|
{groupType} ({groupAttachments.length})
|
|
97
97
|
</h4>
|
package/eventcatalog/src/components/SideNav/ListViewSideBar/components/SpecificationList.tsx
CHANGED
|
@@ -17,6 +17,7 @@ interface SpecificationListProps {
|
|
|
17
17
|
const SpecificationList: React.FC<SpecificationListProps> = ({ specifications, id, version }) => {
|
|
18
18
|
const asyncAPISpecifications = specifications.filter((spec) => spec.type === 'asyncapi');
|
|
19
19
|
const openAPISpecifications = specifications.filter((spec) => spec.type === 'openapi');
|
|
20
|
+
const graphQLSpecifications = specifications.filter((spec) => spec.type === 'graphql');
|
|
20
21
|
|
|
21
22
|
return (
|
|
22
23
|
<ul className="space-y-0.5 border-l border-gray-200/80 ml-[9px] pl-4">
|
|
@@ -56,6 +57,25 @@ const SpecificationList: React.FC<SpecificationListProps> = ({ specifications, i
|
|
|
56
57
|
</span>
|
|
57
58
|
</a>
|
|
58
59
|
))}
|
|
60
|
+
{graphQLSpecifications &&
|
|
61
|
+
graphQLSpecifications.length > 0 &&
|
|
62
|
+
graphQLSpecifications.map((spec) => (
|
|
63
|
+
<a
|
|
64
|
+
key={`${spec.name}-openapi`}
|
|
65
|
+
href={buildUrl(`/docs/services/${id}/${version}/graphql/${spec.filenameWithoutExtension}`)}
|
|
66
|
+
data-active={window.location.href.includes(`docs/services/${id}/${version}/graphql/${spec.filenameWithoutExtension}`)}
|
|
67
|
+
className={`items-center px-2 py-1.5 text-xs text-gray-600 hover:bg-purple-100 rounded-md flex justify-between ${
|
|
68
|
+
window.location.href.includes(`docs/services/${id}/${version}/graphql/${spec.filenameWithoutExtension}`)
|
|
69
|
+
? 'bg-purple-100'
|
|
70
|
+
: 'hover:bg-purple-100'
|
|
71
|
+
}`}
|
|
72
|
+
>
|
|
73
|
+
<span className="truncate flex items-center gap-1">{spec.name}</span>
|
|
74
|
+
<span className="text-green-600 ml-2 text-[10px] uppercase font-medium bg-gray-50 px-4 py-0.5 rounded">
|
|
75
|
+
<img src={buildUrl('/icons/graphql.svg', true)} className="w-4 h-4" alt="GraphQL" />
|
|
76
|
+
</span>
|
|
77
|
+
</a>
|
|
78
|
+
))}
|
|
59
79
|
</ul>
|
|
60
80
|
);
|
|
61
81
|
};
|
|
@@ -103,10 +103,11 @@ const baseSchema = z.object({
|
|
|
103
103
|
z.object({
|
|
104
104
|
openapiPath: z.string().optional(),
|
|
105
105
|
asyncapiPath: z.string().optional(),
|
|
106
|
+
graphqlPath: z.string().optional(),
|
|
106
107
|
}),
|
|
107
108
|
z.array(
|
|
108
109
|
z.object({
|
|
109
|
-
type: z.enum(['openapi', 'asyncapi']),
|
|
110
|
+
type: z.enum(['openapi', 'asyncapi', 'graphql']),
|
|
110
111
|
path: z.string(),
|
|
111
112
|
name: z.string().optional(),
|
|
112
113
|
})
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { Code } from 'astro-expressive-code/components';
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
|
|
5
|
+
import VerticalSideBarLayout from '@layouts/VerticalSideBarLayout.astro';
|
|
6
|
+
import Footer from '@layouts/Footer.astro';
|
|
7
|
+
import { Page } from './_[filename].data';
|
|
8
|
+
import { getAbsoluteFilePathForAstroFile } from '@utils/files';
|
|
9
|
+
import { buildUrl, buildEditUrlForResource } from '@utils/url-builder';
|
|
10
|
+
import Admonition from '@components/MDX/Admonition';
|
|
11
|
+
|
|
12
|
+
import { ServerIcon } from '@heroicons/react/24/outline';
|
|
13
|
+
|
|
14
|
+
export const prerender = Page.prerender;
|
|
15
|
+
export const getStaticPaths = Page.getStaticPaths;
|
|
16
|
+
|
|
17
|
+
// Get data
|
|
18
|
+
const { collection, data, filePath, filename } = await Page.getData(Astro);
|
|
19
|
+
|
|
20
|
+
const fileName = filename || 'schema.graphql';
|
|
21
|
+
const pathToSpec = getAbsoluteFilePathForAstroFile(filePath, fileName);
|
|
22
|
+
const fileExists = fs.existsSync(pathToSpec);
|
|
23
|
+
let content = '';
|
|
24
|
+
|
|
25
|
+
if (fileExists) {
|
|
26
|
+
content = fs.readFileSync(pathToSpec, 'utf8');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Create comprehensive page title
|
|
30
|
+
const pageTitle = `${collection} | ${data.name} | GraphQL Schema`.replace(/^\w/, (c) => c.toUpperCase());
|
|
31
|
+
|
|
32
|
+
const getServiceBadge = () => {
|
|
33
|
+
return [{ backgroundColor: 'pink', textColor: 'pink', content: 'Service', icon: ServerIcon, class: 'text-pink-400' }];
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const getGraphQLBadge = () => {
|
|
37
|
+
return [
|
|
38
|
+
{
|
|
39
|
+
backgroundColor: 'white',
|
|
40
|
+
textColor: 'gray',
|
|
41
|
+
content: 'GraphQL Schema',
|
|
42
|
+
iconURL: buildUrl('/icons/graphql.svg', true),
|
|
43
|
+
class: 'text-black',
|
|
44
|
+
id: 'graphql-schema-badge',
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const badges = [...getServiceBadge(), ...getGraphQLBadge()];
|
|
50
|
+
|
|
51
|
+
// Index only the latest version
|
|
52
|
+
const pagefindAttributes =
|
|
53
|
+
data.version === data.latestVersion
|
|
54
|
+
? {
|
|
55
|
+
'data-pagefind-body': '',
|
|
56
|
+
'data-pagefind-meta': `title:${pageTitle}`,
|
|
57
|
+
}
|
|
58
|
+
: {};
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
<VerticalSideBarLayout title={pageTitle} description={`GraphQL schema for ${data.name}`}>
|
|
62
|
+
<main class="flex sm:px-8 docs-layout h-full" {...pagefindAttributes}>
|
|
63
|
+
<div class="flex docs-layout w-full">
|
|
64
|
+
<div class="w-full lg:mr-2 pr-8 overflow-y-auto py-8">
|
|
65
|
+
<div class="border-b border-gray-200 md:pb-4">
|
|
66
|
+
<div>
|
|
67
|
+
<div class="flex justify-between items-start">
|
|
68
|
+
<div class="flex-1">
|
|
69
|
+
<h1 class="text-2xl md:text-4xl font-bold text-black mb-2">
|
|
70
|
+
{data.name}
|
|
71
|
+
<span class="text-gray-900">(v{data.version})</span>
|
|
72
|
+
</h1>
|
|
73
|
+
<h2 class="text-lg text-gray-600 font-medium mb-1">GraphQL Schema</h2>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
{
|
|
78
|
+
badges && (
|
|
79
|
+
<div class="flex flex-wrap gap-3 py-4">
|
|
80
|
+
{badges.map((badge: any) => (
|
|
81
|
+
<span
|
|
82
|
+
id={badge.id || ''}
|
|
83
|
+
class={`
|
|
84
|
+
inline-flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium
|
|
85
|
+
bg-${badge.backgroundColor || 'white'}-50 border border-${badge.backgroundColor || 'gray'}-200
|
|
86
|
+
text-${badge.textColor || 'gray'}-700 shadow-sm
|
|
87
|
+
transition-all duration-200 ease-out
|
|
88
|
+
${badge.class ? badge.class : ''}
|
|
89
|
+
`}
|
|
90
|
+
>
|
|
91
|
+
{badge.icon && <badge.icon className={`w-4 h-4 flex-shrink-0 text-${badge.textColor || 'gray'}-600`} />}
|
|
92
|
+
{badge.iconURL && <img src={badge.iconURL} class="w-4 h-4 flex-shrink-0 opacity-80" alt="" />}
|
|
93
|
+
<span>{badge.content}</span>
|
|
94
|
+
</span>
|
|
95
|
+
))}
|
|
96
|
+
</div>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
<div data-pagefind-ignore>
|
|
103
|
+
{
|
|
104
|
+
data.version !== data.latestVersion && (
|
|
105
|
+
<div class="rounded-md bg-gradient-to-r from-purple-50 to-purple-100 p-4 not-prose my-4">
|
|
106
|
+
<div class="flex">
|
|
107
|
+
<div class="flex-shrink-0">
|
|
108
|
+
<svg class="h-5 w-5 text-purple-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
|
109
|
+
<path
|
|
110
|
+
fill-rule="evenodd"
|
|
111
|
+
d="M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z"
|
|
112
|
+
clip-rule="evenodd"
|
|
113
|
+
/>
|
|
114
|
+
</svg>
|
|
115
|
+
</div>
|
|
116
|
+
<div class="ml-3">
|
|
117
|
+
<h3 class="text-sm font-medium text-purple-800">New version found</h3>
|
|
118
|
+
<div class="mt-2 text-sm text-purple-700">
|
|
119
|
+
<p>
|
|
120
|
+
You are looking at a previous version of the service <strong>{data.name}</strong>.{' '}
|
|
121
|
+
<a
|
|
122
|
+
class="underline hover:text-primary block pt-2"
|
|
123
|
+
href={buildUrl(`/docs/${collection}/${data.id}/${data.latestVersion}/graphql/${filename}`)}
|
|
124
|
+
>
|
|
125
|
+
The latest version of this GraphQL schema is
|
|
126
|
+
<span>v{data.latestVersion}</span> →
|
|
127
|
+
</a>
|
|
128
|
+
</p>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
</div>
|
|
136
|
+
|
|
137
|
+
{
|
|
138
|
+
!fileExists && (
|
|
139
|
+
<Admonition type="warning" title="Schema not found">
|
|
140
|
+
<p>The GraphQL schema file could not be found at the expected location.</p>
|
|
141
|
+
</Admonition>
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
{
|
|
146
|
+
fileExists && content && (
|
|
147
|
+
<div class="mt-6">
|
|
148
|
+
<div class="bg-gray-50 rounded-lg p-4 mb-4">
|
|
149
|
+
<div class="flex items-center gap-2 mb-2">
|
|
150
|
+
<img src={buildUrl('/icons/graphql.svg', true)} class="w-5 h-5" alt="GraphQL" />
|
|
151
|
+
<h3 class="text-lg font-semibold text-gray-800">GraphQL Schema</h3>
|
|
152
|
+
</div>
|
|
153
|
+
<p class="text-sm text-gray-600">
|
|
154
|
+
This schema defines the GraphQL API structure including types, queries, mutations, and subscriptions for{' '}
|
|
155
|
+
{data.name}.
|
|
156
|
+
</p>
|
|
157
|
+
</div>
|
|
158
|
+
|
|
159
|
+
<div class="not-prose overflow-x-auto">
|
|
160
|
+
<Code code={content} title={`${data.name} v${data.version} - Schema`} lang="graphql" />
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
<Footer />
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
</main>
|
|
170
|
+
|
|
171
|
+
<style is:global>
|
|
172
|
+
.docs-layout .prose {
|
|
173
|
+
max-width: none;
|
|
174
|
+
overflow: auto;
|
|
175
|
+
}
|
|
176
|
+
</style>
|
|
177
|
+
</VerticalSideBarLayout>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// pages/docs/[type]/[id]/[version]/asyncapi/[filename]/index.page.ts
|
|
2
|
+
import { isSSR, isAuthEnabled } 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 'asyncapi' specification
|
|
26
|
+
return specifications && specifications.some((spec) => spec.type === 'graphql');
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const filteredItems = allItems.map((items) => items.filter(hasSpecifications));
|
|
30
|
+
|
|
31
|
+
return filteredItems.flatMap((items, index) =>
|
|
32
|
+
items.flatMap((item) => {
|
|
33
|
+
const asyncApiSpecifications = getSpecificationsForService(item).filter((spec) => spec.type === 'graphql');
|
|
34
|
+
|
|
35
|
+
return asyncApiSpecifications.map((spec) => ({
|
|
36
|
+
params: {
|
|
37
|
+
type: itemTypes[index],
|
|
38
|
+
id: item.data.id,
|
|
39
|
+
version: item.data.version,
|
|
40
|
+
filename: spec.filenameWithoutExtension || spec.type,
|
|
41
|
+
},
|
|
42
|
+
props: {
|
|
43
|
+
type: itemTypes[index],
|
|
44
|
+
filenameWithoutExtension: spec.filenameWithoutExtension || spec.type,
|
|
45
|
+
filename: spec.filename || spec.type,
|
|
46
|
+
...item,
|
|
47
|
+
},
|
|
48
|
+
}));
|
|
49
|
+
})
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
protected static async fetchData(params: any) {
|
|
54
|
+
const { type, id, version, filename } = params;
|
|
55
|
+
|
|
56
|
+
if (!type || !id || !version || !filename) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const { pageDataLoader } = await import('@utils/page-loaders/page-data-loader');
|
|
61
|
+
const { getSpecificationsForService } = await import('@utils/collections/services');
|
|
62
|
+
|
|
63
|
+
// Get all items of the specified type
|
|
64
|
+
const items = await pageDataLoader[type as PageTypes]();
|
|
65
|
+
|
|
66
|
+
// Find the specific item by id and version
|
|
67
|
+
const item = items.find((i) => i.data.id === id && i.data.version === version);
|
|
68
|
+
|
|
69
|
+
if (!item) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Check if this item has AsyncAPI specifications
|
|
74
|
+
const specifications = getSpecificationsForService(item);
|
|
75
|
+
const asyncApiSpecifications = specifications.filter((spec) => spec.type === 'graphql');
|
|
76
|
+
|
|
77
|
+
// Find the specific specification
|
|
78
|
+
const spec = asyncApiSpecifications.find((s) => (s.filenameWithoutExtension || s.type) === filename);
|
|
79
|
+
|
|
80
|
+
if (!spec) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
type,
|
|
86
|
+
filenameWithoutExtension: spec.filenameWithoutExtension || spec.type,
|
|
87
|
+
filename: spec.filename || spec.type,
|
|
88
|
+
...item,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
protected static createNotFoundResponse(): Response {
|
|
93
|
+
return new Response(null, {
|
|
94
|
+
status: 404,
|
|
95
|
+
statusText: 'GraphQL specification not found',
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -125,6 +125,7 @@ const getSpecificationBadges = () => {
|
|
|
125
125
|
|
|
126
126
|
const asyncapiSpecs = specifications.filter((spec) => spec.type === 'asyncapi');
|
|
127
127
|
const openapiSpecs = specifications.filter((spec) => spec.type === 'openapi');
|
|
128
|
+
const graphQLSpecs = specifications.filter((spec) => spec.type === 'graphql');
|
|
128
129
|
|
|
129
130
|
if (openapiSpecs.length > 0) {
|
|
130
131
|
for (const spec of openapiSpecs) {
|
|
@@ -156,6 +157,22 @@ const getSpecificationBadges = () => {
|
|
|
156
157
|
}
|
|
157
158
|
}
|
|
158
159
|
|
|
160
|
+
if (graphQLSpecs.length > 0) {
|
|
161
|
+
for (const spec of graphQLSpecs) {
|
|
162
|
+
badges.push({
|
|
163
|
+
backgroundColor: 'white',
|
|
164
|
+
textColor: 'gray',
|
|
165
|
+
content: spec.name || 'GraphQL Spec',
|
|
166
|
+
iconURL: buildUrl('/icons/graphql.svg', true),
|
|
167
|
+
class: 'text-black hover:underline',
|
|
168
|
+
id: 'graphql-badge',
|
|
169
|
+
url: buildUrl(
|
|
170
|
+
`/docs/${props.collection}/${props.data.id}/${props.data.version}/graphql/${spec.filenameWithoutExtension}`
|
|
171
|
+
),
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
159
176
|
return badges;
|
|
160
177
|
};
|
|
161
178
|
|