@eventcatalog/core 2.5.5 → 2.6.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.
@@ -392,6 +392,15 @@
392
392
  "contributions": [
393
393
  "code"
394
394
  ]
395
+ },
396
+ {
397
+ "login": "XaaXaaX",
398
+ "name": "omid eidivandi",
399
+ "avatar_url": "https://avatars.githubusercontent.com/u/13409925?v=4",
400
+ "profile": "https://github.com/XaaXaaX",
401
+ "contributions": [
402
+ "code"
403
+ ]
395
404
  }
396
405
  ],
397
406
  "contributorsPerLine": 7,
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @eventcatalog/core
2
2
 
3
+ ## 2.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 4aecf6a: fix(core): fixed broken images for specifications on the service page
8
+
9
+ ## 2.6.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 76bebd7: feat(core): added AsyncAPI pages and new specifications frontmatter api. Deprecated the AsyncAPI and OpenAPI MDX components
14
+
3
15
  ## 2.5.5
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -29,7 +29,7 @@
29
29
  <h4>Features: Documentation generator for Event Driven Architectures, Markdown driven, Document Domains/Services/Messages/Schemas and more, Content versioning, Assign Owners, Schemas, OpenAPI, MDX Components and more...</h4>
30
30
 
31
31
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
32
- [![All Contributors](https://img.shields.io/badge/all_contributors-41-orange.svg?style=flat-square)](#contributors-)
32
+ [![All Contributors](https://img.shields.io/badge/all_contributors-42-orange.svg?style=flat-square)](#contributors-)
33
33
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
34
34
 
35
35
  [Read the Docs](https://eventcatalog.dev/) | [Edit the Docs](https://github.com/event-catalog/docs) | [View Demo](https://demo.eventcatalog.dev/docs)
@@ -223,6 +223,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
223
223
  <td align="center" valign="top" width="14.28%"><a href="https://natee.biz"><img src="https://avatars.githubusercontent.com/u/4300215?v=4?s=100" width="100px;" alt="Nathan Birrell"/><br /><sub><b>Nathan Birrell</b></sub></a><br /><a href="https://github.com/event-catalog/eventcatalog/commits?author=nathanbirrell" title="Code">💻</a></td>
224
224
  <td align="center" valign="top" width="14.28%"><a href="https://www.jacktomlinson.co.uk/"><img src="https://avatars.githubusercontent.com/u/15871032?v=4?s=100" width="100px;" alt="Jack Tomlinson"/><br /><sub><b>Jack Tomlinson</b></sub></a><br /><a href="https://github.com/event-catalog/eventcatalog/commits?author=jacktomlinson" title="Code">💻</a></td>
225
225
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/carlosallexandre"><img src="https://avatars.githubusercontent.com/u/20143946?v=4?s=100" width="100px;" alt="Carlos Rodrigues"/><br /><sub><b>Carlos Rodrigues</b></sub></a><br /><a href="https://github.com/event-catalog/eventcatalog/commits?author=carlosallexandre" title="Code">💻</a></td>
226
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/XaaXaaX"><img src="https://avatars.githubusercontent.com/u/13409925?v=4?s=100" width="100px;" alt="omid eidivandi"/><br /><sub><b>omid eidivandi</b></sub></a><br /><a href="https://github.com/event-catalog/eventcatalog/commits?author=XaaXaaX" title="Code">💻</a></td>
226
227
  </tr>
227
228
  </tbody>
228
229
  </table>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eventcatalog/core",
3
3
  "type": "module",
4
- "version": "2.5.5",
4
+ "version": "2.6.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -35,6 +35,7 @@
35
35
  "@astrojs/mdx": "^3.1.3",
36
36
  "@astrojs/react": "^3.6.2",
37
37
  "@astrojs/tailwind": "^5.1.0",
38
+ "@asyncapi/react-component": "^2.2.2",
38
39
  "@changesets/cli": "^2.27.5",
39
40
  "@headlessui/react": "^2.0.3",
40
41
  "@heroicons/react": "^2.1.3",
@@ -0,0 +1,2 @@
1
+
2
+ <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 155.51 155.51"><defs><style>.cls-1{fill:url(#linear-gradient);}.cls-2{fill:url(#linear-gradient-2);}.cls-3{fill:url(#linear-gradient-3);}.cls-4{fill:url(#linear-gradient-4);}.cls-5{fill:#fff;}</style><linearGradient id="linear-gradient" x1="133.74" y1="21.76" x2="24.84" y2="130.67" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#2dccfd"/><stop offset="1" stop-color="#ad20e2"/></linearGradient><linearGradient id="linear-gradient-2" x1="6471.36" y1="6969.64" x2="6362.46" y2="7078.54" gradientTransform="translate(7103.38 -6337.62) rotate(90)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#a829e2"/><stop offset="0.05" stop-color="#a829e2" stop-opacity="0.84"/><stop offset="0.11" stop-color="#a829e2" stop-opacity="0.67"/><stop offset="0.18" stop-color="#a829e2" stop-opacity="0.51"/><stop offset="0.25" stop-color="#a829e2" stop-opacity="0.38"/><stop offset="0.33" stop-color="#a829e2" stop-opacity="0.28"/><stop offset="0.43" stop-color="#a829e2" stop-opacity="0.2"/><stop offset="0.54" stop-color="#a829e2" stop-opacity="0.14"/><stop offset="0.68" stop-color="#a829e2" stop-opacity="0.11"/><stop offset="1" stop-color="#a829e2" stop-opacity="0.1"/></linearGradient><linearGradient id="linear-gradient-3" x1="13419.24" y1="632.02" x2="13310.33" y2="740.92" gradientTransform="translate(13441 765.76) rotate(180)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#e50e99"/><stop offset="1" stop-color="#a829e2" stop-opacity="0.1"/></linearGradient><linearGradient id="linear-gradient-4" x1="138.74" y1="-7.39" x2="29.84" y2="101.52" gradientTransform="translate(-5 29.16)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#21d4fd"/><stop offset="0.03" stop-color="#27cdfc" stop-opacity="0.96"/><stop offset="0.23" stop-color="#4e9cf4" stop-opacity="0.7"/><stop offset="0.43" stop-color="#6e73ee" stop-opacity="0.49"/><stop offset="0.61" stop-color="#8753e9" stop-opacity="0.32"/><stop offset="0.77" stop-color="#993ce5" stop-opacity="0.2"/><stop offset="0.9" stop-color="#a42ee3" stop-opacity="0.13"/><stop offset="1" stop-color="#a829e2" stop-opacity="0.1"/></linearGradient></defs><rect class="cls-1" x="8.88" y="8.88" width="137.75" height="137.75" rx="32.58"/><rect class="cls-2" x="8.88" y="8.88" width="137.75" height="137.75" rx="32.58"/><rect class="cls-3" x="8.88" y="8.88" width="137.75" height="137.75" rx="32.58"/><rect class="cls-4" x="8.88" y="8.88" width="137.75" height="137.75" rx="32.58"/><g id="New_lines" data-name="New lines"><polygon class="cls-5" points="53.35 63.21 49.25 68.86 81.27 92.1 81.49 92.26 85.59 86.61 53.57 63.37 53.35 63.21"/><polygon class="cls-5" points="74.27 63.37 74.05 63.21 69.95 68.86 101.97 92.1 102.19 92.26 106.29 86.61 74.27 63.37"/><path class="cls-5" d="M77.78,34.29c-17.35,0-31.48,10.79-31.48,24.06v.27h7v-.27c0-9.42,11-17.08,24.5-17.08s24.51,7.66,24.51,17.08v.27h7v-.27C109.27,45.08,95.14,34.29,77.78,34.29Z"/><path class="cls-5" d="M102.23,97.16c0,9.42-11,17.08-24.51,17.08s-24.5-7.66-24.5-17.08v-.27h-7v.27c0,13.26,14.13,24,31.48,24s31.49-10.79,31.49-24v-.27h-7Z"/></g></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 256 256" 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> <path d="M127.059657,255.996921 C58.8506544,255.526472 -0.457073619,198.918442 0.00265506057,126.998303 C0.444649399,57.7958628 57.9516598,-0.468967577 129.11002,0.00284555012 C198.267128,0.462386081 256.613109,57.8667711 255.995136,128.194199 C256.568091,197.883453 197.934268,256.489189 127.059657,255.996921 Z M127.059657,255.996921 C58.8506544,255.526472 -0.457073619,198.918442 0.00265506057,126.998303 C0.444649399,57.7958628 57.9516598,-0.468967577 129.11002,0.00284555012 C198.267128,0.462386081 256.613109,57.8667711 255.995136,128.194199 C256.568091,197.883453 197.934268,256.489189 127.059657,255.996921 Z" fill="#FFFFFF"> </path> <path d="M127.184644,238.997327 C68.0323765,238.589271 16.6036091,189.498744 17.0023028,127.131428 C17.3860285,67.1185953 67.2554,16.5917106 128.963117,17.0024872 C188.934544,17.4010221 239.531905,67.1825241 238.995778,128.169251 C239.492444,188.602381 188.64743,239.424426 127.184644,238.997327 Z M127.184644,238.997327 C68.0323765,238.589271 16.6036091,189.498744 17.0023028,127.131428 C17.3860285,67.1185953 67.2554,16.5917106 128.963117,17.0024872 C188.934544,17.4010221 239.531905,67.1825241 238.995778,128.169251 C239.492444,188.602381 188.64743,239.424426 127.184644,238.997327 Z" fill="#49A32B"> </path> <path d="M169.327319,127.956161 C169.042723,133.246373 164.421106,137.639224 159.866213,136.872586 C159.844426,136.872586 159.821277,136.872586 159.798128,136.872586 C154.753021,136.879395 150.658383,132.794288 150.652936,127.749182 C150.824511,122.690458 155.019915,118.703395 160.08,118.789182 C165.125106,118.813692 169.59966,123.077182 169.327319,127.956161 Z M88.2011915,179.220161 C90.1034894,179.27599 92.0071489,179.235139 94.2008511,179.235139 L94.2008511,193.021012 C80.5661277,195.326373 69.3348085,191.455054 66.5787234,179.929607 C65.6350638,175.69199 65.0549787,171.380841 64.8425532,167.04382 C64.5497872,162.452161 65.0563404,157.808756 64.706383,153.225267 C63.7368511,140.613182 62.1028085,136.30748 50,135.711054 L50,120.014714 C50.8674043,119.81182 51.7470638,119.662033 52.6321702,119.562629 C59.2677447,119.23582 62.0646809,117.201437 63.5489362,110.665267 C64.2243404,106.992756 64.6246809,103.275309 64.7431489,99.5428839 C65.268766,92.3258627 65.0822128,84.991735 66.2845957,77.8918201 C68.0221277,67.6245861 74.3962553,62.6366712 84.9249362,62.0783733 C87.9206809,61.9176925 90.9259574,62.0538627 94.3206809,62.0538627 L94.3206809,76.1447563 C92.9235745,76.2441605 91.6435745,76.4470542 90.3717447,76.4089265 C81.7916596,76.146118 81.3477447,79.0683308 80.7213617,86.1709691 C80.3305532,90.6250967 80.8697872,95.1554797 80.5661277,99.6245861 C80.2488511,104.071905 79.6537872,108.496075 78.7850213,112.869863 C77.547234,119.208586 73.6500426,123.922799 68.2495319,127.92348 C78.7332766,134.745607 79.9261277,145.346458 80.6069787,156.110714 C80.9732766,161.895224 80.8057872,167.720586 81.3926809,173.476501 C81.8502128,177.944246 83.5877447,179.08399 88.2011915,179.220161 Z M97.0372766,118.789182 C97.0917447,118.789182 97.1448511,118.789182 97.1993191,118.789182 C102.211745,118.872246 106.209702,123.002288 106.126638,128.016075 C106.126638,128.180841 106.121191,128.344246 106.11166,128.50765 C105.829787,133.407054 101.630298,137.149012 96.7308936,136.867139 C96.5334468,136.871224 96.3373617,136.867139 96.1399149,136.857607 C91.1506383,136.609778 87.3065532,132.36399 87.554383,127.374714 C87.8022128,122.385437 92.048,118.541352 97.0372766,118.789182 Z M128.273362,118.789182 C133.755574,118.746969 137.396766,122.29965 137.425362,127.719224 C137.455319,133.284501 134.003404,136.845352 128.556596,136.868501 C123.017191,136.893012 119.370553,133.389352 119.340596,128.002458 C119.324255,127.727395 119.32017,127.452331 119.32834,127.177267 C119.482213,122.390884 123.486979,118.635309 128.273362,118.789182 Z M193.673191,111.92348 C195.131574,117.370288 197.970723,119.284841 203.704851,119.546288 C204.644426,119.589863 205.579915,119.749182 206.868085,119.892161 L206.868085,135.584416 C206.170894,135.813182 205.456,135.984756 204.730213,136.096416 C197.046128,136.574373 193.54383,139.726714 192.76766,147.431224 C192.272,152.349692 192.312851,157.322629 191.972426,162.258799 C191.829447,167.678373 191.336511,173.082969 190.49634,178.438544 C188.535489,188.142033 182.477277,192.982884 172.467404,193.573863 C169.245617,193.764501 166.000681,193.60382 162.526979,193.60382 L162.526979,179.578288 C164.396596,179.462544 166.046979,179.303224 167.701447,179.263735 C173.682043,179.120756 175.796766,177.192586 176.089532,171.252841 C176.413617,164.727565 176.555234,158.194118 176.846638,151.66748 C177.270128,142.233607 179.853277,133.806033 188.641702,127.922118 C183.612936,124.336756 179.575489,119.994288 178.529702,114.138969 C177.264681,107.041778 176.85617,99.7879903 176.175319,92.5913946 C175.838979,88.9937776 175.855319,85.3648414 175.504,81.7699478 C175.125447,77.8890967 172.459234,76.5464584 168.926979,76.4593095 C166.903489,76.4102882 164.87183,76.4497776 162.284596,76.4497776 L162.284596,62.7537776 C178.793872,60.0126712 190.198128,65.5057776 191.257532,81.3015222 C191.701447,87.9343733 191.636085,94.5985435 192.060936,101.231395 C192.247489,104.839905 192.786723,108.421182 193.673191,111.92348 Z" fill="#FFFFFF"> </path> </g> </g></svg>
@@ -0,0 +1,40 @@
1
+ ---
2
+ import type { CollectionTypes } from '@types';
3
+ import { buildUrl } from '@utils/url-builder';
4
+ import type { CollectionEntry } from 'astro:content';
5
+
6
+ interface Props {
7
+ collectionItem: CollectionEntry<CollectionTypes>;
8
+ }
9
+
10
+ const { collectionItem } = Astro.props;
11
+
12
+ const specVersions = collectionItem.data.specifications || {};
13
+ const numberOfSpecifications = Object.keys(specVersions).length;
14
+ ---
15
+
16
+ <div class="space-y-2 my-2 mb-8">
17
+ <span class="font-light text-black group-data-[hover]:text-black/80 capitalize">Specifications ({numberOfSpecifications})</span>
18
+ {
19
+ collectionItem.data.specifications?.openapiPath && (
20
+ <a
21
+ href={buildUrl(`/docs/${collectionItem.collection}/${collectionItem.data.id}/${collectionItem.data.version}/spec`)}
22
+ class="text-sm flex items-center space-x-1 hover:underline hover:text-purple-500"
23
+ >
24
+ <img src={buildUrl('/icons/openapi.svg')} class="h-4 w-4" />
25
+ <span>OpenAPI spec</span>
26
+ </a>
27
+ )
28
+ }
29
+ {
30
+ collectionItem.data.specifications?.asyncapiPath && (
31
+ <a
32
+ href={buildUrl(`/docs/${collectionItem.collection}/${collectionItem.data.id}/${collectionItem.data.version}/asyncapi`)}
33
+ class="text-sm flex items-center space-x-1 hover:underline hover:text-purple-500"
34
+ >
35
+ <img src={buildUrl('/icons/asyncapi.svg')} class="h-4 w-4" />
36
+ <span>AsyncAPI spec</span>
37
+ </a>
38
+ )
39
+ }
40
+ </div>
@@ -0,0 +1,16 @@
1
+ ---
2
+ import Admonition from '../Admonition';
3
+ ---
4
+
5
+ <div class="mb-4">
6
+ <Admonition type="warning">
7
+ <>
8
+ <span class="block font-bold">{`<AsyncAPI/>`} component now deprecated</span>
9
+ <span class="block"
10
+ >Use the new specifications frontmatter api. <a href="https://www.eventcatalog.dev/docs/api/service-api"
11
+ >Read more here.</a
12
+ ></span
13
+ >
14
+ </>
15
+ </Admonition>
16
+ </div>
@@ -0,0 +1,16 @@
1
+ ---
2
+ import Admonition from '../Admonition';
3
+ ---
4
+
5
+ <div class="mb-4">
6
+ <Admonition type="warning">
7
+ <>
8
+ <span class="block font-bold">{`<OpenAPI/>`} component now deprecated</span>
9
+ <span class="block"
10
+ >Use the new specifications frontmatter api. <a href="https://www.eventcatalog.dev/docs/api/service-api"
11
+ >Read more here.</a
12
+ ></span
13
+ >
14
+ </>
15
+ </Admonition>
16
+ </div>
@@ -5,7 +5,8 @@ import Accordion from '@components/MDX/Accordion/Accordion.astro';
5
5
  import AccordionGroup from '@components/MDX/Accordion/AccordionGroup.astro';
6
6
  import Flow from '@components/MDX/Flow/Flow.astro';
7
7
  import Admonition from '@components/MDX/Admonition';
8
- import OpenAPI from '@components/MDX/OpenAPI/OpenAPI';
8
+ import OpenAPI from '@components/MDX/OpenAPI/OpenAPI.astro';
9
+ import AsyncAPI from '@components/MDX/AsyncAPI/AsyncAPI.astro';
9
10
 
10
11
  // Portals: required for server/client components
11
12
  import NodeGraphPortal from '@components/MDX/NodeGraph/NodeGraphPortal';
@@ -16,11 +17,12 @@ const components = (props: any) => {
16
17
  Accordion,
17
18
  AccordionGroup,
18
19
  Flow,
20
+ OpenAPI,
21
+ AsyncAPI,
19
22
  Admonition: (mdxProp: any) => <Admonition {...mdxProp} {...props} />,
20
23
  File: (mdxProp: any) => File({ ...props, ...mdxProp }),
21
24
  NodeGraph: (mdxProp: any) => NodeGraphPortal({ ...props.data, ...mdxProp }),
22
25
  SchemaViewer: (mdxProp: any) => SchemaViewerPortal({ ...props.data, ...mdxProp }),
23
- OpenAPI: (mdxProp: any) => <OpenAPI {...mdxProp} {...props} />,
24
26
  Schema: (mdxProp: any) => Schema({ ...props, ...mdxProp }),
25
27
  };
26
28
  };
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  import OwnersList from '@components/Lists/OwnersList';
3
3
  import PillList from '@components/Lists/PillList';
4
+ import SpecificationsList from '@components/Lists/SpecificationsList.astro';
4
5
  import VersionList from '@components/Lists/VersionList.astro';
5
6
  import { buildUrl } from '@utils/url-builder';
6
7
  import { getEntry, type CollectionEntry } from 'astro:content';
@@ -72,6 +73,7 @@ const schemaURL = join(publicPath, schemaFilePath || '');
72
73
  />
73
74
 
74
75
  {service.data.versions && <VersionList versions={service.data.versions} collectionItem={service} />}
76
+ {service.data.specifications && <SpecificationsList collectionItem={service} />}
75
77
 
76
78
  <div class="space-y-2">
77
79
  {
@@ -107,12 +109,6 @@ const schemaURL = join(publicPath, schemaFilePath || '');
107
109
  class="block text-center rounded-md w-full bg-white px-3.5 py-2.5 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-100/60 hover:text-purple-500"
108
110
  >View in Visualiser</a
109
111
  >
110
- <a
111
- id="open-api-button"
112
- href={buildUrl(`/docs/${service.collection}/${service.data.id}/${service.data.version}/spec`)}
113
- class="hidden text-center rounded-md w-full bg-white px-3.5 py-2.5 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-100/60 hover:text-purple-500"
114
- >View API spec</a
115
- >
116
112
  <a
117
113
  href={buildUrl(`/docs/${service.collection}/${service.data.id}/${service.data.version}/changelog`)}
118
114
  class="block text-center rounded-md w-full bg-white px-3.5 py-2.5 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-100/60 hover:text-purple-500"
@@ -121,14 +117,3 @@ const schemaURL = join(publicPath, schemaFilePath || '');
121
117
  </div>
122
118
  </div>
123
119
  </aside>
124
-
125
- <script>
126
- // If openapi-component is in the dom then show the button, when dom has loaded
127
- document.addEventListener('DOMContentLoaded', () => {
128
- const openApiComponent = document.getElementById('openapi-component');
129
- const openApiButton = document.getElementById('open-api-button');
130
- if (openApiComponent && openApiButton) {
131
- openApiButton.style.display = 'block';
132
- }
133
- });
134
- </script>
@@ -49,6 +49,12 @@ const baseSchema = z.object({
49
49
  badges: z.array(badge).optional(),
50
50
  owners: z.array(ownerReference).optional(),
51
51
  schemaPath: z.string().optional(),
52
+ specifications: z
53
+ .object({
54
+ openapiPath: z.string().optional(),
55
+ asyncapiPath: z.string().optional(),
56
+ })
57
+ .optional(),
52
58
  hidden: z.boolean().optional(),
53
59
  // Used by eventcatalog
54
60
  versions: z.array(z.string()).optional(),
@@ -0,0 +1,83 @@
1
+ ---
2
+ import type { CollectionEntry } from 'astro:content';
3
+ import type { CollectionTypes } from '@types';
4
+ import path from 'path';
5
+ import { readFileSync } from 'fs';
6
+
7
+ import PlainPage from '@layouts/PlainPage.astro';
8
+
9
+ import { createElement } from 'react';
10
+ import { renderToString } from 'react-dom/server';
11
+
12
+ import { Parser } from '@asyncapi/parser';
13
+
14
+ import { getEvents } from '@utils/events';
15
+ import { getServices } from '@utils/services/services';
16
+ import { getCommands } from '@utils/commands';
17
+ import { getDomains } from '@utils/domains/domains';
18
+
19
+ import '@asyncapi/react-component/styles/default.min.css';
20
+ import js from '@asyncapi/react-component/browser/standalone/without-parser.js?url';
21
+ import { AsyncApiComponentWP, type ConfigInterface } from '@asyncapi/react-component';
22
+
23
+ export async function getStaticPaths() {
24
+ const events = await getEvents();
25
+ const commands = await getCommands();
26
+ const services = await getServices();
27
+ const domains = await getDomains();
28
+
29
+ const hasAsyncAPISpec = (item: CollectionEntry<CollectionTypes>) => item.data.specifications?.asyncapiPath !== undefined;
30
+
31
+ const buildPages = (collection: CollectionEntry<CollectionTypes>[]) => {
32
+ const filteredCollection = collection.filter(hasAsyncAPISpec);
33
+
34
+ return filteredCollection.map((item) => ({
35
+ params: {
36
+ type: item.collection,
37
+ id: item.data.id,
38
+ version: item.data.version,
39
+ },
40
+ props: {
41
+ type: item.collection,
42
+ ...item,
43
+ },
44
+ }));
45
+ };
46
+
47
+ return [...buildPages(domains), ...buildPages(events), ...buildPages(services), ...buildPages(commands)];
48
+ }
49
+
50
+ // @ts-ignore
51
+ const { catalog, data } = Astro.props;
52
+ const fileName = data.specifications?.asyncapiPath || 'asyncapi.yaml';
53
+ const pathToSpec = path.join(catalog.publicPath, fileName);
54
+ const pathOnDisk = path.join(process.cwd(), 'public', pathToSpec);
55
+ const fileContent = readFileSync(pathOnDisk, 'utf-8');
56
+
57
+ const parsed = await new Parser().parse(fileContent);
58
+ const stringified = parsed.document?.json();
59
+ const config: ConfigInterface = { show: { sidebar: true, errors: true } };
60
+
61
+ const component = createElement(AsyncApiComponentWP, { schema: { stringified }, config });
62
+ const renderedComponent = renderToString(component);
63
+ ---
64
+
65
+ <PlainPage title="AsyncApi Spec">
66
+ <div id="asyncapi" class="md:pr-14" set:html={renderedComponent} />
67
+ </PlainPage>
68
+
69
+ <script is:inline src={js}></script>
70
+ <script define:vars={{ schema: stringified, config }}>
71
+ const root = document.getElementById('asyncapi');
72
+ AsyncApiStandalone.hydrate({ schema, config }, root);
73
+ </script>
74
+
75
+ <style>
76
+ #asyncapi {
77
+ @media screen and (min-width: 1417px) {
78
+ .sidebar {
79
+ z-index: 1 !important;
80
+ }
81
+ }
82
+ }
83
+ </style>
@@ -81,7 +81,39 @@ const getBadge = () => {
81
81
  return { backgroundColor: 'teal', textColor: 'teal', content: '', icon: QueueListIcon, class: 'text-gray' };
82
82
  };
83
83
 
84
- const badges = [getBadge(), ...contentBadges];
84
+ const getSpecificationBadges = () => {
85
+ const badges = [];
86
+ const hasOpenAPISpec = !!props.data.specifications?.openapiPath;
87
+ const hasAsyncAPISpec = !!props.data.specifications?.asyncapiPath;
88
+
89
+ if (hasOpenAPISpec) {
90
+ badges.push({
91
+ backgroundColor: 'white',
92
+ textColor: 'gray',
93
+ content: 'OpenAPI Spec',
94
+ iconURL: buildUrl('/icons/openapi.svg'),
95
+ class: 'text-black hover:underline',
96
+ id: 'open-api-badge',
97
+ url: buildUrl(`/docs/${props.collection}/${props.data.id}/${props.data.version}/spec`),
98
+ });
99
+ }
100
+
101
+ if (hasAsyncAPISpec) {
102
+ badges.push({
103
+ backgroundColor: 'white',
104
+ textColor: 'gray',
105
+ content: 'AsyncAPI Spec',
106
+ iconURL: buildUrl('/icons/asyncapi.svg'),
107
+ class: 'text-black hover:underline',
108
+ id: 'asyncapi-badge',
109
+ url: buildUrl(`/docs/${props.collection}/${props.data.id}/${props.data.version}/asyncapi`),
110
+ });
111
+ }
112
+
113
+ return badges;
114
+ };
115
+
116
+ const badges = [getBadge(), ...contentBadges, ...getSpecificationBadges()];
85
117
  ---
86
118
 
87
119
  <DocsLayout title={pageTitle} description={props.data.summary}>
@@ -98,14 +130,20 @@ const badges = [getBadge(), ...contentBadges];
98
130
  {
99
131
  badges && (
100
132
  <div class="flex flex-wrap py-2 pt-4">
101
- {badges.map((badge: any) => (
102
- <span
103
- class={`text-sm font-light text-gray-500 px-2 py-1 rounded-md mr-2 bg-${badge.backgroundColor}-100 space-x-1 border border-${badge.backgroundColor}-200 text-${badge.textColor}-800 flex items-center ${badge.class ? badge.class : ''} `}
104
- >
105
- {badge.icon && <badge.icon className="w-4 h-4 inline-block mr-1 " />}
106
- <span>{badge.content}</span>
107
- </span>
108
- ))}
133
+ {badges.map((badge: any) => {
134
+ return (
135
+ <a href={badge.url || '#'}>
136
+ <span
137
+ id={badge.id || ''}
138
+ class={`text-sm font-light text-gray-500 px-2 py-1 rounded-md mr-2 bg-${badge.backgroundColor}-100 space-x-1 border border-${badge.backgroundColor}-200 text-${badge.textColor}-800 flex items-center ${badge.class ? badge.class : ''} `}
139
+ >
140
+ {badge.icon && <badge.icon className="w-4 h-4 inline-block mr-1 " />}
141
+ {badge.iconURL && <img src={badge.iconURL} class="w-5 h-5 inline-block " />}
142
+ <span>{badge.content}</span>
143
+ </span>
144
+ </a>
145
+ );
146
+ })}
109
147
  </div>
110
148
  )
111
149
  }
@@ -18,8 +18,12 @@ export async function getStaticPaths() {
18
18
  const services = await getServices();
19
19
  const domains = await getDomains();
20
20
 
21
+ const hasOpenAPISpec = (item: CollectionEntry<CollectionTypes>) => item.data.specifications?.openapiPath !== undefined;
22
+
21
23
  const buildPages = (collection: CollectionEntry<CollectionTypes>[]) => {
22
- return collection.map((item) => ({
24
+ const filteredCollection = collection.filter(hasOpenAPISpec);
25
+
26
+ return filteredCollection.map((item) => ({
23
27
  params: {
24
28
  type: item.collection,
25
29
  id: item.data.id,
@@ -37,7 +41,8 @@ export async function getStaticPaths() {
37
41
 
38
42
  // @ts-ignore
39
43
  const { data, catalog } = Astro.props;
40
- const pathToSpec = path.join(catalog.publicPath, 'openapi.yml');
44
+ const fileName = data.specifications?.openapiPath || 'openapi.yml';
45
+ const pathToSpec = path.join(catalog.publicPath, fileName);
41
46
  const pathOnDisk = path.join(process.cwd(), 'public', pathToSpec);
42
47
  const fileExists = fs.existsSync(pathOnDisk);
43
48
  ---
@@ -1,36 +0,0 @@
1
- import type { CollectionTypes } from '@types';
2
- import type { CollectionEntry } from 'astro:content';
3
- import * as path from 'path';
4
- import { existsSync } from 'node:fs';
5
- import { buildUrl } from '@utils/url-builder';
6
-
7
- const OpenAPI = (props: CollectionEntry<CollectionTypes>) => {
8
- // @ts-ignore
9
- const collectionPath = props?.catalog?.path;
10
- // @ts-ignore
11
- const publicPath = props?.catalog?.publicPath;
12
- const fileName = 'openapi.yml';
13
-
14
- const fileExists = existsSync(path.join(process.cwd(), 'public', publicPath, fileName));
15
-
16
- return (
17
- <div className="mb-4" id="openapi-component">
18
- <span className="text-3xl font-bold">OpenAPI</span>
19
- {!fileExists && (
20
- <div className="text-sm text-red-500">
21
- OpenAPI file not found. Put your OpenAPI file inside your {collectionPath} directory.
22
- </div>
23
- )}
24
- {fileExists && (
25
- <div>
26
- This {props.collection.slice(0, -1)} has an OpenAPI file{' '}
27
- <a className="text-purple-500" href={buildUrl(`/docs/${props.collection}/${props.data.id}/${props.data.version}/spec`)}>
28
- you can view here.
29
- </a>
30
- </div>
31
- )}
32
- </div>
33
- );
34
- };
35
-
36
- export default OpenAPI;