@eventcatalog/core 2.33.1 → 2.33.3

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.
Files changed (30) hide show
  1. package/README.md +2 -1
  2. package/dist/analytics/analytics.cjs +1 -1
  3. package/dist/analytics/analytics.js +2 -2
  4. package/dist/analytics/log-build.cjs +1 -1
  5. package/dist/analytics/log-build.js +3 -3
  6. package/dist/{chunk-IVIWGH2J.js → chunk-557OECV4.js} +1 -1
  7. package/dist/{chunk-VDBGM3NV.js → chunk-5QUF2S7L.js} +1 -1
  8. package/dist/{chunk-R3X2SCY6.js → chunk-5TXSONUY.js} +1 -1
  9. package/dist/constants.cjs +1 -1
  10. package/dist/constants.js +1 -1
  11. package/dist/eventcatalog.cjs +1 -1
  12. package/dist/eventcatalog.js +3 -3
  13. package/eventcatalog/src/components/Lists/PillList.tsx +2 -2
  14. package/eventcatalog/src/components/Lists/PillListFlat.tsx +1 -1
  15. package/eventcatalog/src/components/Lists/ProtocolList.tsx +2 -2
  16. package/eventcatalog/src/components/MDX/ResourceLink/ResourceLink.astro +34 -7
  17. package/eventcatalog/src/components/MDX/SchemaViewer/SchemaProperty.astro +161 -0
  18. package/eventcatalog/src/components/MDX/SchemaViewer/SchemaViewer.astro +37 -70
  19. package/eventcatalog/src/components/MDX/SchemaViewer/SchemaViewerPortal.tsx +1 -1
  20. package/eventcatalog/src/components/MDX/SchemaViewer/SchemaViewerRoot.astro +98 -0
  21. package/eventcatalog/src/icons/protocols/grpc.svg +1 -0
  22. package/eventcatalog/src/icons/protocols/index.ts +2 -0
  23. package/eventcatalog/src/icons/protocols/zmq.svg +1 -0
  24. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/index.astro +11 -3
  25. package/eventcatalog/src/shared-collections.ts +1 -0
  26. package/eventcatalog/src/utils/badges.ts +5 -0
  27. package/package.json +4 -6
  28. package/eventcatalog/src/components/MDX/SchemaViewer/SchemaViewer.tsx +0 -62
  29. package/eventcatalog/src/components/MDX/SchemaViewer/css/stoplight-mosaic-styles.css +0 -29609
  30. package/eventcatalog/src/components/MDX/SchemaViewer/css/stoplight-mosaic-theme-default.css +0 -333
package/README.md CHANGED
@@ -34,7 +34,7 @@
34
34
  <h4>Features: Documentation for Event Driven Architectures, Integration with any broker, Generator from your OpenAPI and AsyncAPI documents, Docs and Code, Markdown driven, Document Domains/Services/Messages/Schemas and more, Content versioning, Assign Owners, Schemas, OpenAPI, MDX Components and more...</h4>
35
35
 
36
36
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
37
- [![All Contributors](https://img.shields.io/badge/all_contributors-52-orange.svg?style=flat-square)](#contributors-)
37
+ [![All Contributors](https://img.shields.io/badge/all_contributors-53-orange.svg?style=flat-square)](#contributors-)
38
38
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
39
39
 
40
40
  [Read the Docs](https://www.eventcatalog.dev/docs/development/getting-started/introduction) | [View Demo](https://demo.eventcatalog.dev)
@@ -263,6 +263,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
263
263
  <td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/ruudwelling/"><img src="https://avatars.githubusercontent.com/u/4014179?v=4?s=100" width="100px;" alt="Ruud Welling"/><br /><sub><b>Ruud Welling</b></sub></a><br /><a href="https://github.com/event-catalog/eventcatalog/commits?author=WellingR" title="Code">💻</a></td>
264
264
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/vienin"><img src="https://avatars.githubusercontent.com/u/2124283?v=4?s=100" width="100px;" alt="Kevin Pouget"/><br /><sub><b>Kevin Pouget</b></sub></a><br /><a href="https://github.com/event-catalog/eventcatalog/commits?author=vienin" title="Code">💻</a></td>
265
265
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/VitaliiBalash"><img src="https://avatars.githubusercontent.com/u/4520809?v=4?s=100" width="100px;" alt="Vitalii Balash"/><br /><sub><b>Vitalii Balash</b></sub></a><br /><a href="https://github.com/event-catalog/eventcatalog/commits?author=VitaliiBalash" title="Code">💻</a></td>
266
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/ababilone"><img src="https://avatars.githubusercontent.com/u/925013?v=4?s=100" width="100px;" alt="Arnaud Babilone"/><br /><sub><b>Arnaud Babilone</b></sub></a><br /><a href="https://github.com/event-catalog/eventcatalog/commits?author=ababilone" title="Code">💻</a></td>
266
267
  </tr>
267
268
  </tbody>
268
269
  </table>
@@ -37,7 +37,7 @@ var import_axios = __toESM(require("axios"), 1);
37
37
  var import_os = __toESM(require("os"), 1);
38
38
 
39
39
  // package.json
40
- var version = "2.33.1";
40
+ var version = "2.33.3";
41
41
 
42
42
  // src/constants.ts
43
43
  var VERSION = version;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  raiseEvent
3
- } from "../chunk-VDBGM3NV.js";
4
- import "../chunk-IVIWGH2J.js";
3
+ } from "../chunk-5QUF2S7L.js";
4
+ import "../chunk-557OECV4.js";
5
5
  export {
6
6
  raiseEvent
7
7
  };
@@ -106,7 +106,7 @@ var import_axios = __toESM(require("axios"), 1);
106
106
  var import_os = __toESM(require("os"), 1);
107
107
 
108
108
  // package.json
109
- var version = "2.33.1";
109
+ var version = "2.33.3";
110
110
 
111
111
  // src/constants.ts
112
112
  var VERSION = version;
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  log_build_default
3
- } from "../chunk-R3X2SCY6.js";
4
- import "../chunk-VDBGM3NV.js";
5
- import "../chunk-IVIWGH2J.js";
3
+ } from "../chunk-5TXSONUY.js";
4
+ import "../chunk-5QUF2S7L.js";
5
+ import "../chunk-557OECV4.js";
6
6
  import "../chunk-E7TXTI7G.js";
7
7
  export {
8
8
  log_build_default as default
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "2.33.1";
2
+ var version = "2.33.3";
3
3
 
4
4
  // src/constants.ts
5
5
  var VERSION = version;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-IVIWGH2J.js";
3
+ } from "./chunk-557OECV4.js";
4
4
 
5
5
  // src/analytics/analytics.js
6
6
  import axios from "axios";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  raiseEvent
3
- } from "./chunk-VDBGM3NV.js";
3
+ } from "./chunk-5QUF2S7L.js";
4
4
  import {
5
5
  getEventCatalogConfigFile,
6
6
  verifyRequiredFieldsAreInCatalogConfigFile
@@ -25,7 +25,7 @@ __export(constants_exports, {
25
25
  module.exports = __toCommonJS(constants_exports);
26
26
 
27
27
  // package.json
28
- var version = "2.33.1";
28
+ var version = "2.33.3";
29
29
 
30
30
  // src/constants.ts
31
31
  var VERSION = version;
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-IVIWGH2J.js";
3
+ } from "./chunk-557OECV4.js";
4
4
  export {
5
5
  VERSION
6
6
  };
@@ -157,7 +157,7 @@ var import_axios = __toESM(require("axios"), 1);
157
157
  var import_os = __toESM(require("os"), 1);
158
158
 
159
159
  // package.json
160
- var version = "2.33.1";
160
+ var version = "2.33.3";
161
161
 
162
162
  // src/constants.ts
163
163
  var VERSION = version;
@@ -6,15 +6,15 @@ import {
6
6
  } from "./chunk-UKJ7F5WR.js";
7
7
  import {
8
8
  log_build_default
9
- } from "./chunk-R3X2SCY6.js";
10
- import "./chunk-VDBGM3NV.js";
9
+ } from "./chunk-5TXSONUY.js";
10
+ import "./chunk-5QUF2S7L.js";
11
11
  import {
12
12
  catalogToAstro,
13
13
  checkAndConvertMdToMdx
14
14
  } from "./chunk-7SI5EVOX.js";
15
15
  import {
16
16
  VERSION
17
- } from "./chunk-IVIWGH2J.js";
17
+ } from "./chunk-557OECV4.js";
18
18
  import {
19
19
  isBackstagePluginEnabled,
20
20
  isEventCatalogScaleEnabled,
@@ -26,9 +26,9 @@ const PillList = ({ title, pills, emptyMessage, color = 'gray' }: Props) => {
26
26
  </DisclosureButton>
27
27
  <DisclosurePanel className="mt-2 text-sm/5 text-black/50">
28
28
  <ul role="list" className=" py-2 ">
29
- {pills.map((item) => {
29
+ {pills.map((item, index) => {
30
30
  return (
31
- <li className="py-1 " key={item.href}>
31
+ <li className="py-1 " key={`${item.href}-${index}`}>
32
32
  <a
33
33
  className={`flex items-start group border border-pink-200 hover:border-pink-400 rounded-md`}
34
34
  href={item.href}
@@ -46,7 +46,7 @@ const PillList = ({ title, pills, emptyMessage, color = 'gray', limit = 10, ...p
46
46
  >
47
47
  <a className={`leading-3`} href={href}>
48
48
  <span className="space-x-2 flex items-center">
49
- {Icon && <Icon className={`h-4 w-4`} />}
49
+ {Icon && <Icon className="h-4 w-4 shrink-0" />}
50
50
  <span className="font-light text-sm truncate">
51
51
  {item.label} {item.tag && <>({item.tag})</>}
52
52
  </span>
@@ -46,14 +46,14 @@ const ProtocolList = ({ title, pills, emptyMessage, color = 'gray', ...props }:
46
46
  </DisclosureButton>
47
47
  <DisclosurePanel className="mt-2 text-sm/5 text-black/50">
48
48
  <ul role="list" className="space-y-2">
49
- {pills.map((item) => {
49
+ {pills.map((item, index) => {
50
50
  const href = item.href ?? '#';
51
51
  const Icon = item.icon ? getIconForProtocol(item.icon) : null;
52
52
 
53
53
  return (
54
54
  <li
55
55
  className=" has-tooltip rounded-md text-gray-600 group px-1 w-full hover:bg-gradient-to-l hover:from-purple-500 hover:to-purple-700 hover:text-white hover:font-normal "
56
- key={item.href}
56
+ key={`${item.href}-${index}`}
57
57
  >
58
58
  <a className={`leading-3`} href={href}>
59
59
  <span className="space-x-2 flex items-center">
@@ -1,23 +1,50 @@
1
1
  ---
2
2
  import { buildUrl } from '@utils/url-builder';
3
- import { resourceToCollectionMap } from '@utils/collections/util';
3
+ import { getItemsFromCollectionByIdAndSemverOrLatest, resourceToCollectionMap } from '@utils/collections/util';
4
+ import { getCollection } from 'astro:content';
4
5
 
5
6
  const { id, version, type } = Astro.props;
6
7
  const collection = resourceToCollectionMap[type as keyof typeof resourceToCollectionMap];
8
+
9
+ let slotHTML = await Astro.slots.render('default');
10
+ let href = '#';
11
+ let linkHasError = false;
12
+
13
+ try {
14
+ if (collection === 'users' || collection === 'teams') {
15
+ const resources = await getCollection(collection, (resource) => resource.data.id === id);
16
+ const resource = resources[0];
17
+
18
+ slotHTML = slotHTML || resource.data.name;
19
+ href = buildUrl(`/docs/${collection}/${id}`);
20
+ } else {
21
+ const resourcesCollection = await getCollection(collection);
22
+
23
+ const resources = getItemsFromCollectionByIdAndSemverOrLatest(resourcesCollection, id, version);
24
+ const resource = resources[0];
25
+
26
+ slotHTML = slotHTML || resource.data.name;
27
+ href = buildUrl(`/docs/${collection}/${id}/${resource.data.version}`);
28
+ }
29
+ } catch (error) {
30
+ console.error(`Failed to fetch related resource: ${id} of type ${type}`, error);
31
+ linkHasError = true;
32
+ slotHTML = id;
33
+ }
7
34
  ---
8
35
 
9
36
  {
10
- version && (
11
- <a href={buildUrl(`/docs/${collection}/${id}/${version}`)} class="text-purple-500 hover:text-purple-700">
12
- <slot />
37
+ linkHasError && (
38
+ <a href={href} class="text-red-500 hover:text-red-700">
39
+ ⚠️ {slotHTML} (broken link)
13
40
  </a>
14
41
  )
15
42
  }
16
43
 
17
44
  {
18
- !version && (
19
- <a href={buildUrl(`/docs/${collection}/${id}`)} class="text-purple-500 hover:text-purple-700">
20
- <slot />
45
+ !linkHasError && (
46
+ <a href={href} class="text-purple-500 hover:text-purple-700">
47
+ {slotHTML}
21
48
  </a>
22
49
  )
23
50
  }
@@ -0,0 +1,161 @@
1
+ ---
2
+ import SchemaProp from './SchemaProperty.astro';
3
+
4
+ interface Props {
5
+ name: string;
6
+ details: any;
7
+ isRequired: boolean;
8
+ level: number;
9
+ isListItem?: boolean;
10
+ }
11
+
12
+ const { name, details, isRequired, level, isListItem = false } = Astro.props;
13
+
14
+ const hasNestedProperties = details.type === 'object' && details.properties && Object.keys(details.properties).length > 0;
15
+ const hasArrayItems = details.type === 'array' && details.items;
16
+ const isCollapsible = hasNestedProperties || (hasArrayItems && details.items.type === 'object' && details.items.properties);
17
+
18
+ // Using template literal for class calculation remains safe
19
+ const indentationClass = `pl-${level * 3}`;
20
+
21
+ const contentId = `prop-${name}-${level}-${Math.random().toString(36).substring(2, 7)}`;
22
+ ---
23
+
24
+ {/* Using simpler border class */}
25
+ <div class:list={['property-container mb-1.5 border-l border-gray-100 relative', indentationClass]}>
26
+ <div class="flex items-start space-x-1.5">
27
+ {
28
+ isCollapsible && (
29
+ <button
30
+ type="button"
31
+ aria-expanded="false"
32
+ aria-controls={contentId}
33
+ class="property-toggle text-gray-500 hover:text-gray-700 pt-0.5 focus:outline-none w-3 text-center flex-shrink-0"
34
+ >
35
+ <span class="icon-collapsed font-mono text-xs">&gt;</span>
36
+ <span class="icon-expanded font-mono text-xs hidden">v</span>
37
+ </button>
38
+ )
39
+ }
40
+ {!isCollapsible && <div class="w-3 h-4 flex-shrink-0" />}
41
+
42
+ <div class="flex-grow">
43
+ <div class="flex justify-between items-baseline">
44
+ <div>
45
+ <span class="font-semibold text-gray-800 text-sm">{name}</span>
46
+ <span class="ml-1.5 text-purple-600 font-mono text-xs">
47
+ {/* Expressions using ternary operators are generally safe */}
48
+ {details.type}
49
+ {details.type === 'array' && details.items?.type ? `[${details.items.type}]` : ''}
50
+ {details.format ? `<${details.format}>` : ''}
51
+ </span>
52
+ </div>
53
+ {isRequired && <span class="text-red-600 text-xs ml-3 flex-shrink-0">required</span>}
54
+ </div>
55
+
56
+ {details.description && <p class="text-gray-500 text-xs mt-0.5">{details.description}</p>}
57
+
58
+ {/* Reverted arbitrary text size to standard 'text-xs' */}
59
+ <div class="text-xs text-gray-500 mt-0.5 space-y-0">
60
+ {
61
+ details.pattern && (
62
+ <div>
63
+ Match pattern: <code class="bg-gray-100 px-1 rounded text-gray-800 font-thin py-0.5">{details.pattern}</code>
64
+ </div>
65
+ )
66
+ }
67
+ {
68
+ details.minimum !== undefined && (
69
+ <div>
70
+ Minimum: <code class="bg-gray-100 px-1 rounded text-gray-800 font-thin py-0.5">{details.minimum}</code>
71
+ </div>
72
+ )
73
+ }
74
+ {
75
+ details.maximum !== undefined && (
76
+ <div>
77
+ Maximum: <code class="bg-gray-100 px-1 rounded text-gray-800 font-thin py-0.5">{details.maximum}</code>
78
+ </div>
79
+ )
80
+ }
81
+ {
82
+ details.enum && (
83
+ <div>
84
+ <span class="text-xs inline-block">Allowed values:</span>
85
+
86
+ {/* Map function rendering standard elements */}
87
+ {details.enum.map((val: string) => (
88
+ <span class="text-xs">
89
+ <code class="bg-gray-100 px-1 rounded text-gray-800 font-thin py-0.5">{val}</code>
90
+ </span>
91
+ ))}
92
+ </div>
93
+ )
94
+ }
95
+ </div>
96
+
97
+ {
98
+ (hasNestedProperties || hasArrayItems) && (
99
+ // class:list with conditional object is standard and should be safe
100
+ <div id={contentId} class:list={['nested-content mt-1', { hidden: isCollapsible }]}>
101
+ {/* Recursive component calls */}
102
+ {hasNestedProperties &&
103
+ details.properties &&
104
+ Object.entries(details.properties).map(([nestedName, nestedDetails]) => (
105
+ <SchemaProp
106
+ name={nestedName}
107
+ details={nestedDetails}
108
+ isRequired={details.required?.includes(nestedName) ?? false}
109
+ level={level + 1}
110
+ />
111
+ ))}
112
+
113
+ {hasArrayItems && details.items.type === 'object' && details.items.properties && (
114
+ <div class="mt-1 border-l border-dashed border-gray-400 pl-3 ml-1.5">
115
+ <span class="text-xs italic text-gray-500 block mb-1">Item Details:</span>
116
+ {Object.entries(details.items.properties).map(([itemPropName, itemPropDetails]) => (
117
+ <SchemaProp
118
+ name={itemPropName}
119
+ details={itemPropDetails}
120
+ isRequired={details.items.required?.includes(itemPropName) ?? false}
121
+ level={level + 1}
122
+ isListItem={true}
123
+ />
124
+ ))}
125
+ </div>
126
+ )}
127
+ </div>
128
+ )
129
+ }
130
+ </div>
131
+ </div>
132
+ </div>
133
+
134
+ {/* Script tag content remains the same */}
135
+ <script is:inline>
136
+ function setupPropertyToggle() {
137
+ document.querySelectorAll('.property-toggle').forEach((button) => {
138
+ if (button.dataset.listenerAttached) return;
139
+ button.dataset.listenerAttached = 'true';
140
+
141
+ button.addEventListener('click', () => {
142
+ const contentId = button.getAttribute('aria-controls');
143
+ const content = document.getElementById(contentId);
144
+ const isExpanded = button.getAttribute('aria-expanded') === 'true';
145
+ const iconCollapsed = button.querySelector('.icon-collapsed');
146
+ const iconExpanded = button.querySelector('.icon-expanded');
147
+
148
+ if (content) {
149
+ button.setAttribute('aria-expanded', String(!isExpanded));
150
+ content.classList.toggle('hidden');
151
+ iconCollapsed?.classList.toggle('hidden', !isExpanded);
152
+ iconExpanded?.classList.toggle('hidden', isExpanded);
153
+ }
154
+ });
155
+ });
156
+ }
157
+
158
+ setupPropertyToggle();
159
+
160
+ document.addEventListener('astro:page-load', setupPropertyToggle);
161
+ </script>
@@ -1,77 +1,44 @@
1
1
  ---
2
- const { catalog, id, filePath } = Astro.props;
3
- import fs from 'node:fs/promises';
4
- import { existsSync } from 'fs';
5
- import yaml from 'js-yaml';
6
- import path from 'path';
7
- import SchemaViewerClient from './SchemaViewer';
8
- import Admonition from '../Admonition';
9
- import { getMDXComponentsByName } from '@utils/markdown';
10
-
11
- let schemas = [];
12
-
13
- try {
14
- const file = await fs.readFile(filePath, 'utf-8');
15
- const schemaViewers = getMDXComponentsByName(file, 'SchemaViewer');
2
+ // src/components/SchemaViewer.astro
3
+ import SchemaProperty from './SchemaProperty.astro';
4
+
5
+ interface Props {
6
+ schema: Record<string, any>;
7
+ schemaPath: string;
8
+ title: string;
9
+ maxHeight: string;
10
+ file: string;
11
+ id: string;
12
+ }
16
13
 
17
- // Loop around all the possible SchemaViewers in the file.
18
- const getAllComponents = schemaViewers.map(async (schemaViewerProps: any) => {
19
- const schemaPath = path.join(path.dirname(filePath), schemaViewerProps.file);
20
- const exists = existsSync(schemaPath);
21
- let schema;
22
- let render = true;
14
+ const { id, file, title, maxHeight, schema } = Astro.props;
15
+ const { description, properties, required = [] } = schema;
16
+ ---
23
17
 
24
- if (exists) {
25
- // Load the schema for the component
26
- schema = await fs.readFile(schemaPath, 'utf-8');
27
- if (schemaPath.endsWith('.yml') || schemaPath.endsWith('.yaml')) {
28
- schema = yaml.load(schema);
29
- } else {
30
- schema = JSON.parse(schema);
31
- // Lets JSON schema control if the component should be rendered or not
32
- if (schema['x-eventcatalog-render-schema-viewer'] !== undefined) {
33
- render = schema['x-eventcatalog-render-schema-viewer'];
34
- }
35
- }
18
+ <div id={`${id}-${file}-SchemaViewer-client`} class="not-prose my-4">
19
+ {title && <h2 class="text-3xl font-bold mb-2 !mt-0">{title}</h2>}
20
+ <div
21
+ class="schema-viewer p-4 bg-white overflow-y-auto rounded-lg border border-gray-100 shadow-sm font-sans"
22
+ style={{
23
+ maxHeight: maxHeight ? `${maxHeight}em` : `100em`,
24
+ }}
25
+ >
26
+ {description && <p class="text-gray-600 text-xs mb-5">{description}</p>}
27
+ {/* Reduced size, adjusted margin */}
28
+
29
+ {
30
+ properties &&
31
+ Object.entries(properties).map(([name, details]) => (
32
+ <SchemaProperty name={name} details={details} isRequired={required.includes(name)} level={0} />
33
+ ))
36
34
  }
37
35
 
38
- return {
39
- id: schemaViewerProps.id || id,
40
- exists,
41
- schema,
42
- schemaPath,
43
- ...schemaViewerProps,
44
- render,
45
- };
46
- });
47
-
48
- schemas = await Promise.all(getAllComponents);
49
- } catch (error) {
50
- console.log('Failed to process schemas');
51
- console.log(error);
52
- }
53
- ---
54
-
55
- <section class="space-y-4">
56
- {
57
- schemas.length > 0 &&
58
- schemas.map((schema) => {
59
- if (!schema.render) return null;
60
- return (
61
- <div>
62
- {schema.exists && <SchemaViewerClient {...schema} client:only="react" />}
36
+ {!properties && <p class="text-gray-500 text-sm">Schema does not contain any properties.</p>}
37
+ </div>
38
+ </div>
63
39
 
64
- {/* User has tried to load the schema, but it was not found on file system */}
65
- {!schema.exists && (
66
- <Admonition type="warning">
67
- <div>
68
- <span class="block font-bold">{`<SchemaViewer/>`} failed to load</span>
69
- <span class="block">Tried to load schema from {schema.schemaPath}, but no schema can be found</span>
70
- </div>
71
- </Admonition>
72
- )}
73
- </div>
74
- );
75
- })
40
+ <style>
41
+ .schema-viewer code {
42
+ font-family: 'Courier New', Courier, monospace;
76
43
  }
77
- </section>
44
+ </style>
@@ -1,5 +1,5 @@
1
1
  const SchemaViewerPortal = (props: any) => {
2
- return <div id={`${props.id}-SchemaViewer-portal`} />;
2
+ return <div id={`${props.id}-${props.file}-SchemaViewer-portal`} />;
3
3
  };
4
4
 
5
5
  export default SchemaViewerPortal;
@@ -0,0 +1,98 @@
1
+ ---
2
+ const { id, filePath } = Astro.props;
3
+ import fs from 'node:fs/promises';
4
+ import { existsSync } from 'fs';
5
+ import yaml from 'js-yaml';
6
+ import path from 'path';
7
+ import SchemaViewerClient from './SchemaViewer.astro';
8
+ import Admonition from '../Admonition';
9
+ import { getMDXComponentsByName } from '@utils/markdown';
10
+
11
+ let schemas = [];
12
+
13
+ try {
14
+ const file = await fs.readFile(filePath, 'utf-8');
15
+ const schemaViewers = getMDXComponentsByName(file, 'SchemaViewer');
16
+
17
+ // Loop around all the possible SchemaViewers in the file.
18
+ const getAllComponents = schemaViewers.map(async (schemaViewerProps: any) => {
19
+ const schemaPath = path.join(path.dirname(filePath), schemaViewerProps.file);
20
+ const exists = existsSync(schemaPath);
21
+ let schema;
22
+ let render = true;
23
+
24
+ if (exists) {
25
+ // Load the schema for the component
26
+ schema = await fs.readFile(schemaPath, 'utf-8');
27
+ if (schemaPath.endsWith('.yml') || schemaPath.endsWith('.yaml')) {
28
+ schema = yaml.load(schema);
29
+ } else {
30
+ schema = JSON.parse(schema);
31
+ // Lets JSON schema control if the component should be rendered or not
32
+ if (schema['x-eventcatalog-render-schema-viewer'] !== undefined) {
33
+ render = schema['x-eventcatalog-render-schema-viewer'];
34
+ }
35
+ }
36
+ }
37
+
38
+ return {
39
+ id: schemaViewerProps.id || id,
40
+ exists,
41
+ schema,
42
+ schemaPath,
43
+ ...schemaViewerProps,
44
+ render,
45
+ };
46
+ });
47
+
48
+ schemas = await Promise.all(getAllComponents);
49
+ } catch (error) {
50
+ console.log('Failed to process schemas');
51
+ console.log(error);
52
+ }
53
+ ---
54
+
55
+ <section class="space-y-4">
56
+ {
57
+ schemas.length > 0 &&
58
+ schemas.map((schema) => {
59
+ if (!schema.render) return null;
60
+ return (
61
+ <div>
62
+ {schema.exists && <SchemaViewerClient {...schema} />}
63
+
64
+ {/* User has tried to load the schema, but it was not found on file system */}
65
+ {!schema.exists && (
66
+ <Admonition type="warning">
67
+ <div>
68
+ <span class="block font-bold">{`<SchemaViewer/>`} failed to load</span>
69
+ <span class="block">Tried to load schema from {schema.schemaPath}, but no schema can be found</span>
70
+ </div>
71
+ </Admonition>
72
+ )}
73
+ </div>
74
+ );
75
+ })
76
+ }
77
+ </section>
78
+
79
+ <script is:inline define:vars={{ schemas }}>
80
+ // Can we move the SchemaViewerClient to another container? example container with the id "my-schema-viewer-container"
81
+ // and then we can move the SchemaViewerClient to that container?
82
+
83
+ function moveSchemaViewerToPortal(schema) {
84
+ const portalId = `${schema.id}-${schema.file}-SchemaViewer-portal`;
85
+ const schemaViewerContainer = document.getElementById(portalId);
86
+ console.log('schemaViewerContainer', schemaViewerContainer);
87
+ if (schemaViewerContainer) {
88
+ schemaViewerContainer.appendChild(document.getElementById(`${schema.id}-${schema.file}-SchemaViewer-client`));
89
+ }
90
+ }
91
+
92
+ console.log('schemas', schemas);
93
+
94
+ // on DOM ready, move the SchemaViewerClient to the portal
95
+ document.addEventListener('astro:page-load', () => {
96
+ schemas.forEach(moveSchemaViewerToPortal);
97
+ });
98
+ </script>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 96 96" id="Grpc--Streamline-Svg-Logos" ><desc>Grpc Streamline Icon: https://streamlinehq.com</desc><path fill="#244b5a" d="M11.4052 61.9509c.6979.9285 1.6048 1.6794 2.6473 2.1918 1.1274.5584 2.3714.8408 3.6294.8238 1.0172.0266 2.0297-.1461 2.9805-.5084.7605-.2988 1.4394-.7734 1.9811-1.385.5084-.5959.8795-1.2963 1.0871-2.0515.2264-.8163.3384-1.66.333-2.507v-2.9454h-.0699c-.6593 1.045-1.6103 1.8739-2.7355 2.3844-1.0728.4671-2.2311.7059-3.4012.7013-1.1465.0086-2.2838-.2057-3.3485-.6311-1.0082-.4003-1.9306-.9894-2.7177-1.7358-.781-.7499-1.4014-1.6507-1.8235-2.6478-.44911-1.0526-.67592-2.1866-.6662-3.331-.00969-1.1411.20483-2.2729.63137-3.3313.40313-1.0013.99203-1.9174 1.73553-2.6999.7434-.7761 1.6387-1.3909 2.63-1.806 1.0608-.441 2.2001-.6617 3.3488-.6486.5231.003 1.045.0499 1.5602.14.5666.099 1.1197.2638 1.6481.4911 1.2545.5437 2.3389 1.4161 3.1386 2.525h.0699v-2.7354h2.3146v16.2705c-.0079.956-.1197 1.9083-.3333 2.8402-.2234 1.0076-.6664 1.9534-1.2973 2.7701-.7179.901-1.6366 1.6216-2.6826 2.1043-1.1457.5608-2.6419.8411-4.4886.8411-1.5001.0256-2.9902-.2485-4.383-.8063-1.3326-.5708-2.5279-1.4196-3.50622-2.4894l1.71802-1.8237Zm.4207-11.7116c-.0058.8357.1552 1.6641.4735 2.4368.3035.7415.7435 1.4195 1.2971 1.9986.5504.5741 1.2049 1.0382 1.9287 1.3678.754.3426 1.5738.5162 2.402.5083 1.6401.0059 3.2206-.6149 4.4182-1.7355.5881-.555 1.0488-1.2311 1.3502-1.9816.3247-.825.4741-1.7086.4384-2.5944.0059-.831-.1366-1.6564-.4209-2.4373-.2701-.7422-.6876-1.4221-1.2274-1.9987-.5548-.5845-1.223-1.0498-1.9636-1.3675-.82-.3485-1.7039-.5218-2.5949-.5086-.8282-.0076-1.648.166-2.402.5086-.7236.3299-1.378.7939-1.9287 1.3675-.5535.5794-.9935 1.2573-1.2974 1.9987-.3181.7729-.479 1.6014-.4732 2.4373Zm23.9844 8.4156h-2.5245V33.8282H40.93c2.5247 0 4.5175.5493 5.9786 1.6481 1.4608 1.099 2.1914 2.7588 2.1917 4.9793.0445 1.6118-.5403 3.1776-1.6305 4.3656-1.0872 1.1807-2.6593 1.8645-4.7163 2.0512l7.1534 11.7825h-3.086l-6.8024-11.5367h-4.208l-.0002 11.5367Zm0-13.851h4.4886c.9644.0203 1.9268-.0978 2.8577-.3508.6809-.182 1.3186-.4978 1.8761-.929.4497-.3619.7997-.8326 1.0167-1.3675.2134-.5415.3205-1.119.3157-1.701.0026-.5702-.1046-1.1356-.3157-1.6654-.2196-.5384-.5688-1.0143-1.0167-1.3852-.5521-.4398-1.1917-.7566-1.8761-.9293-.933-.2402-1.8945-.3522-2.8577-.333h-4.4886v8.6612Zm18.4441-10.9757h7.2238c2.5245 0 4.5173.5494 5.9783 1.6483 1.4608 1.0991 2.1914 2.7589 2.1918 4.9794 0 2.2212-.7306 3.8867-2.1918 4.9967-1.461 1.1106-3.4538 1.6658-5.9783 1.6656h-4.6988v11.5367h-2.525V33.8282Zm2.5252 10.9759h4.0677c.9644.0203 1.9268-.0978 2.8577-.3507.6808-.1821 1.3186-.498 1.8761-.9291.4497-.3619.7996-.8326 1.0167-1.3675.2135-.5414.3206-1.1189.3157-1.7009.0027-.5703-.1045-1.1357-.3157-1.6654-.2196-.5385-.5688-1.0143-1.0167-1.3853-.5521-.4396-1.1917-.7565-1.8761-.9293-.933-.2401-1.8945-.3522-2.8577-.3329h-4.0679l.0002 8.6611ZM95 54.7276c-.4443.6582-.9682 1.2589-1.56 1.7884-.6406.5755-1.3539 1.0647-2.1216 1.4549-.8196.4185-1.6842.7421-2.5771.9646-.9579.2378-1.9415.3555-2.9284.3505-1.7604.0165-3.5065-.3172-5.1368-.9816-3.1091-1.2564-5.5719-3.7256-6.8204-6.8379-.6681-1.66-1.0017-3.4357-.9816-5.225-.02-1.7892.3136-3.5649.9816-5.2249 1.2484-3.1122 3.7113-5.5813 6.8204-6.8374 1.6302-.6646 3.3764-.9984 5.1368-.9819 1.5867.0085 3.1574.3178 4.6288.9115 1.5694.628 2.9388 1.6704 3.9622 3.0158l-2.2088 1.6481c-.2968-.442-.6506-.843-1.0523-1.1923-.464-.4109-.976-.764-1.5249-1.0518-.5864-.3089-1.2035-.5557-1.8412-.7364-.6383-.1847-1.2994-.2791-1.9638-.2806-1.4729-.0242-2.9332.2751-4.2779.8766-1.2199.5535-2.3122 1.3533-3.2083 2.3492-.8868.9987-1.5716 2.1599-2.0166 3.4192-.9349 2.6431-.9349 5.5268 0 8.1699.4449 1.2593 1.1297 2.4204 2.0166 3.4189.8958.9962 1.9882 1.7962 3.2083 2.3494 1.3446.602 2.8049.9014 4.2779.8769.6527.0003 1.3041-.0584 1.9462-.1753.6533-.1202 1.2893-.3204 1.8937-.5961.637-.2922 1.2277-.6763 1.7533-1.14.5904-.5274 1.1038-1.1352 1.5251-1.8054L95 54.7276Z"></path><path fill="url(#a)" d="m7.53809 41.9566-6.53851-6.49 6.49007-6.5386 6.53855 6.4901-6.49011 6.5385Z"></path><path fill="url(#b)" d="m25.3301 39.1863-3.8352-3.8067 3.8068-3.8352 3.8351 3.8068-3.8067 3.8351Z"></path><path fill="#244b5a" d="M7.77596 31.5034 3.8457 35.4631l3.95949 3.9303 3.34981-.0125-3.51277-3.4845 17.34547-.0643-1.5202 1.5305 1.6749-.0061 1.9653-1.9799-1.9799-1.965-1.6749.0061 1.5317 1.5195-17.34553.0643 3.48643-3.5105-3.34954.0124Z"></path><defs><linearGradient id="a" x1="-646.313" x2="656.545" y1="-607.051" y2="-611.894" gradientUnits="userSpaceOnUse"><stop stop-color="#72c9c9"></stop><stop offset="1" stop-color="#02b0ad"></stop></linearGradient><linearGradient id="b" x1="-358.188" x2="406.007" y1="-341.49" y2="-344.331" gradientUnits="userSpaceOnUse"><stop stop-color="#03b6b4"></stop><stop offset="1" stop-color="#74cbca"></stop></linearGradient></defs></svg>
@@ -14,3 +14,5 @@ export { default as EventBridge } from '@icons/protocols/eventbridge.svg?raw';
14
14
  export { default as Redis } from '@icons/protocols/redis.svg?raw';
15
15
  export { default as GooglePubSub } from '@icons/protocols/googlepubsub.svg?raw';
16
16
  export { default as Kinesis } from '@icons/protocols/kinesis.svg?raw';
17
+ export { default as GRPC } from '@icons/protocols/grpc.svg?raw';
18
+ export { default as ZMQ } from '@icons/protocols/zmq.svg?raw';
@@ -0,0 +1 @@
1
+ <svg version="1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 525 525"><path d="M245.85 3c-.07.15-3.07.45-6.6 0.75-7.27.6-7.35.6-24.38 3.15-1.2.22-2.78.52-3.38.68-.6.15-1.95.45-3 0.68-4.8 0.82-20.55 5.03-26.7 7.05-24.45 8.18-50.93 21.23-67.8 33.38-2.4 1.72-5.1 3.68-6 4.28-1 0.6-4.43 3.3-7.8 5.93-36.23 28.65-64.65 66.6-81.38 108.68-6.83 17.1-13.5 41.1-15.45 55.65-.22 1.88-.6 4.2-0.83 5.25-.38 2.1-.68 4.8-1.58 14.25-1.13 12.15-.6 44.18 0.9 53.33.15 0.98.45 3.45 0.75 5.55 0.68 5.7 1.2 8.7 1.88 12 0.38 1.65 0.83 3.98 1.05 5.25 0.68 3.68 0.98 4.95 2.7 11.63 1.58 6.38 5.48 19.28 6.68 22.13 0.38 0.83 1.88 4.88 3.45 9 3.68 9.75 13.65 30.08 18.83 38.33 2.25 3.53 4.05 6.75 4.05 7.13s-9.15 9.9-20.33 21.08l-20.25 20.4 39.23 39.23 39.3 39.3 20.25-20.25c11.18-11.18 20.78-20.33 21.3-20.33.53 0 2.7 1.13 4.8 2.55 2.1 1.35 6.53 3.98 9.83 5.7 3.3 1.8 6.38 3.45 6.75 3.75 0.68 0.45 14.1 6.68 20.25 9.38 15.9 6.98 45.53 15 64.13 17.33 1.05 0.15 3.08 0.38 4.5 0.6 14.03 2.18 49.05 2.1 63.75 0 20.18-2.93 35.18-6.45 51.75-12 43.58-14.78 84.08-41.63 112.73-74.93 2.48-2.93 4.73-5.4 5.03-5.63 0.23-0.23 2.63-3.23 5.33-6.75 31.2-40.5 49.65-87.45 54.45-138.38 1.13-11.63 0.45-52.2 0.9-54.38-.15-0.23-.45-2.25-0.68-4.5-.23-2.25-0.6-4.8-0.75-5.63-.15-0.83-0.83-4.58-1.58-8.25-5.33-28.8-16.8-58.73-32.33-84.83-2.25-3.75-4.05-7.05-4.05-7.43 0-0.3 8.33-8.93 18.6-19.13 10.2-10.2 19.28-19.43 20.18-20.4l1.65-1.8-39.23-39.23L445.73 0.6l-20.33 20.33C414.23 32.1 404.85 41.25 404.48 41.25s-3.15-1.58-6.23-3.53c-26.18-16.28-63.23-29.78-94.13-34.43-2.03-0.3-4.28-0.68-4.88-0.75-.6-.15-3.3-.45-6-0.68-2.7-0.3-5.78-0.68-6.75-0.9-2.03-0.38-40.2-1.05-40.65-0.68zm30.83 100.5c4.58 0.45 6.68 0.68 12.45 1.5 4.2 0.6 12.75 2.63 19.5 4.58 7.13 2.1 22.13 7.73 22.13 8.33 0 0.53-215.05 215.55-215.55 215.55-1.05 0-10.05-26.25-11.18-32.7-.23-1.2-0.9-5.03-1.58-8.55-2.55-14.1-2.93-38.55-0.83-49.65 0.23-0.9 0.83-4.58 1.5-8.18 0.6-3.53 2.25-10.35 3.75-15.15 10.35-34.35 28.2-60.15 58-83.93 4.88-3.83 17.4-11.4 25.8-15.6 8.85-4.35 27.23-11.18 33-11.7 1.8-0.3 7.43-1.43 8.1-1.58 0.23-0.08 2.1-0.38 4.13-0.75 2.1-0.3 4.43-0.68 5.25-0.83 0.83-0.15 4.58-0.53 8.25-0.75 3.75-0.3 6.83-0.53 6.9-0.68 0.38-0.23 15.38 0.23 20.4 0.68zm134.63 96.6c8.7 20.03 13.43 43.05 13.5 65.1 0 6.53-0.75 18.38-1.43 21.75-0.23 0.98-0.53 3.15-0.83 4.88-2.78 19.28-12.9 45.23-24.08 62.03-16.95 25.28-38 43.88-64.35 56.85-23.4 11.48-46.73 16.88-72.75 16.8-11.4-0.08-18.38-0.75-29.33-2.93-3.23-0.68-6.9-1.43-8.18-1.65-4.88-0.83-27.3-8.85-29.55-10.5-.3-0.23 214.58-215.4 215.18-215.4 0.23 0 1.05 1.43 1.8 3.15z"/></svg>