@eventcatalog/core 2.33.1 → 2.33.2

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.
@@ -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.2";
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-ESJAFFBK.js";
4
+ import "../chunk-DDOQCYNI.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.2";
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-QXRF5XEW.js";
4
+ import "../chunk-ESJAFFBK.js";
5
+ import "../chunk-DDOQCYNI.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.2";
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-DDOQCYNI.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-ESJAFFBK.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.2";
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-DDOQCYNI.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.2";
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-QXRF5XEW.js";
10
+ import "./chunk-ESJAFFBK.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-DDOQCYNI.js";
18
18
  import {
19
19
  isBackstagePluginEnabled,
20
20
  isEventCatalogScaleEnabled,
@@ -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>
@@ -4,7 +4,7 @@ import Footer from '@layouts/Footer.astro';
4
4
 
5
5
  import components from '@components/MDX/components';
6
6
  import NodeGraph from '@components/MDX/NodeGraph/NodeGraph.astro';
7
- import SchemaViewer from '@components/MDX/SchemaViewer/SchemaViewer.astro';
7
+ import SchemaViewer from '@components/MDX/SchemaViewer/SchemaViewerRoot.astro';
8
8
 
9
9
  // SideBars
10
10
  import ServiceSideBar from '@components/SideBars/ServiceSideBar.astro';
@@ -202,7 +202,8 @@ const pagefindAttributes =
202
202
  </div>
203
203
  <div data-pagefind-ignore>
204
204
  <!-- @ts-ignore -->
205
- <SchemaViewer id={props.data.id} catalog={props.catalog} filePath={props.filePath} />
205
+ <!-- <SchemaViewer id={props.data.id} catalog={props.catalog} filePath={props.filePath} /> -->
206
+ <SchemaViewer id={props.data.id} filePath={props.filePath} />
206
207
  <NodeGraph
207
208
  id={props.data.id}
208
209
  collection={props.collection}
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "url": "https://github.com/event-catalog/eventcatalog.git"
7
7
  },
8
8
  "type": "module",
9
- "version": "2.33.1",
9
+ "version": "2.33.2",
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
@@ -42,7 +42,6 @@
42
42
  "@radix-ui/react-dialog": "^1.1.6",
43
43
  "@radix-ui/react-tooltip": "^1.1.8",
44
44
  "@scalar/api-reference-react": "^0.4.37",
45
- "@stoplight/json-schema-viewer": "^4.16.4",
46
45
  "@tailwindcss/typography": "^0.5.13",
47
46
  "@tanstack/react-table": "^8.17.3",
48
47
  "@xyflow/react": "^12.3.6",
@@ -69,7 +68,6 @@
69
68
  "lucide-react": "^0.453.0",
70
69
  "marked": "^15.0.6",
71
70
  "mermaid": "^11.4.1",
72
- "prismjs": "^1.29.0",
73
71
  "react": "^18.3.1",
74
72
  "react-dom": "^18.3.1",
75
73
  "rehype-slug": "^6.0.0",
@@ -1,62 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
-
3
- import 'prismjs';
4
- // @ts-ignore
5
- import { JsonSchemaViewer } from '@stoplight/json-schema-viewer';
6
- import './css/stoplight-mosaic-styles.css';
7
- import './css/stoplight-mosaic-theme-default.css';
8
-
9
- import { createPortal } from 'react-dom';
10
-
11
- type Props = {
12
- id: string;
13
- file: string;
14
- renderRootTreeLines?: boolean;
15
- hideExamples?: boolean;
16
- defaultExpandedDepth?: number;
17
- maxHeight?: string;
18
- schema: any;
19
- catalog: any;
20
- title?: string;
21
- };
22
-
23
- const SchemaViewer = ({
24
- id,
25
- maxHeight = '500',
26
- renderRootTreeLines = true,
27
- hideExamples = false,
28
- defaultExpandedDepth = 3,
29
- title,
30
- schema,
31
- }: Props) => {
32
- const [elem, setElem] = useState(null);
33
- useEffect(() => {
34
- // @ts-ignore
35
- setElem(document.getElementById(`${id}-SchemaViewer-portal`));
36
- }, []);
37
-
38
- if (!elem) return null;
39
-
40
- return (
41
- <div>
42
- {createPortal(
43
- <section className="not-prose space-y-2 ">
44
- {title && <h2 className="text-3xl font-bold">{title}</h2>}
45
- <div className="border border-gray-100 p-2 schemaViewer">
46
- <JsonSchemaViewer
47
- schema={schema}
48
- emptyText="No schema defined"
49
- maxHeight={parseInt(maxHeight, 10)}
50
- defaultExpandedDepth={defaultExpandedDepth}
51
- renderRootTreeLines={renderRootTreeLines}
52
- hideExamples={hideExamples}
53
- />
54
- </div>
55
- </section>,
56
- elem
57
- )}
58
- </div>
59
- );
60
- };
61
-
62
- export default SchemaViewer;