@eventcatalog/core 2.33.10 → 2.33.11
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-KWYNYLOK.js → chunk-2NTEYUNI.js} +1 -1
- package/dist/{chunk-L2RGENDX.js → chunk-FKC4UAA6.js} +1 -1
- package/dist/{chunk-N7V2JS3E.js → chunk-WHJEWUMZ.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/src/components/MDX/SchemaViewer/SchemaViewer.astro +119 -6
- 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-FKC4UAA6.js";
|
|
4
|
+
import "../chunk-WHJEWUMZ.js";
|
|
5
|
+
import "../chunk-2NTEYUNI.js";
|
|
6
6
|
import "../chunk-E7TXTI7G.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,15 +6,15 @@ import {
|
|
|
6
6
|
} from "./chunk-UKJ7F5WR.js";
|
|
7
7
|
import {
|
|
8
8
|
log_build_default
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-FKC4UAA6.js";
|
|
10
|
+
import "./chunk-WHJEWUMZ.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-
|
|
17
|
+
} from "./chunk-2NTEYUNI.js";
|
|
18
18
|
import {
|
|
19
19
|
isBackstagePluginEnabled,
|
|
20
20
|
isEventCatalogScaleEnabled,
|
|
@@ -12,7 +12,65 @@ interface Props {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const { id, file, title, maxHeight, schema } = Astro.props;
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
// Function to merge allOf schemas
|
|
17
|
+
function mergeAllOfSchemas(schema: any) {
|
|
18
|
+
if (!schema.allOf) return schema;
|
|
19
|
+
|
|
20
|
+
const mergedSchema: {
|
|
21
|
+
type: string;
|
|
22
|
+
properties: Record<string, any>;
|
|
23
|
+
required: string[];
|
|
24
|
+
description?: string;
|
|
25
|
+
} = {
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {},
|
|
28
|
+
required: [],
|
|
29
|
+
description: schema.description,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
schema.allOf.forEach((subSchema: any) => {
|
|
33
|
+
if (subSchema.properties) {
|
|
34
|
+
mergedSchema.properties = {
|
|
35
|
+
...mergedSchema.properties,
|
|
36
|
+
...subSchema.properties,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (subSchema.required) {
|
|
40
|
+
mergedSchema.required = [...mergedSchema.required, ...subSchema.required];
|
|
41
|
+
}
|
|
42
|
+
if (subSchema.description && !mergedSchema.description) {
|
|
43
|
+
mergedSchema.description = subSchema.description;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return mergedSchema;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function processSchema(schema: any) {
|
|
51
|
+
if (schema.allOf) {
|
|
52
|
+
return mergeAllOfSchemas(schema);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (schema.oneOf) {
|
|
56
|
+
// For oneOf, we'll keep the base properties and handle variants in the UI
|
|
57
|
+
return {
|
|
58
|
+
...schema,
|
|
59
|
+
variants: schema.oneOf.map((variant: any) => ({
|
|
60
|
+
title: variant.title || 'Unnamed Variant',
|
|
61
|
+
required: variant.required || [],
|
|
62
|
+
})),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return schema;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const processedSchema = processSchema(schema);
|
|
70
|
+
const { description, properties, required = [], variants } = processedSchema;
|
|
71
|
+
|
|
72
|
+
// Generate a unique ID for this instance
|
|
73
|
+
const instanceId = `${id}-${file}-${Math.random().toString(36).substring(2, 9)}`;
|
|
16
74
|
---
|
|
17
75
|
|
|
18
76
|
<div id={`${id}-${file}-SchemaViewer-client`} class="not-prose my-4">
|
|
@@ -24,19 +82,74 @@ const { description, properties, required = [] } = schema;
|
|
|
24
82
|
}}
|
|
25
83
|
>
|
|
26
84
|
{description && <p class="text-gray-600 text-xs mb-5">{description}</p>}
|
|
27
|
-
{/* Reduced size, adjusted margin */}
|
|
28
85
|
|
|
29
86
|
{
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<
|
|
33
|
-
|
|
87
|
+
variants && (
|
|
88
|
+
<div class="mb-4">
|
|
89
|
+
<div class="flex items-center space-x-2">
|
|
90
|
+
<span class="text-sm text-gray-600">(one of)</span>
|
|
91
|
+
<select
|
|
92
|
+
id={`${instanceId}-variant-selector`}
|
|
93
|
+
class="form-select text-sm border-gray-300 rounded-md shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"
|
|
94
|
+
>
|
|
95
|
+
{variants.map((variant: any, index: number) => (
|
|
96
|
+
<option value={index}>{variant.title}</option>
|
|
97
|
+
))}
|
|
98
|
+
</select>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
{
|
|
105
|
+
properties && (
|
|
106
|
+
<div id={`${instanceId}-properties`}>
|
|
107
|
+
{Object.entries(properties).map(([name, details]) => (
|
|
108
|
+
<SchemaProperty name={name} details={details} isRequired={variants ? false : required.includes(name)} level={0} />
|
|
109
|
+
))}
|
|
110
|
+
</div>
|
|
111
|
+
)
|
|
34
112
|
}
|
|
35
113
|
|
|
36
114
|
{!properties && <p class="text-gray-500 text-sm">Schema does not contain any properties.</p>}
|
|
37
115
|
</div>
|
|
38
116
|
</div>
|
|
39
117
|
|
|
118
|
+
<script define:vars={{ instanceId, variants }}>
|
|
119
|
+
if (variants) {
|
|
120
|
+
const selector = document.getElementById(`${instanceId}-variant-selector`);
|
|
121
|
+
const propertiesContainer = document.getElementById(`${instanceId}-properties`);
|
|
122
|
+
|
|
123
|
+
function updateRequiredFields() {
|
|
124
|
+
const selectedVariant = variants[selector.value];
|
|
125
|
+
const properties = propertiesContainer.querySelectorAll('.property-container');
|
|
126
|
+
|
|
127
|
+
properties.forEach((prop) => {
|
|
128
|
+
const nameEl = prop.querySelector('.font-semibold');
|
|
129
|
+
if (!nameEl) return;
|
|
130
|
+
|
|
131
|
+
const name = nameEl.textContent;
|
|
132
|
+
const requiredBadge = prop.querySelector('.text-red-600');
|
|
133
|
+
|
|
134
|
+
if (selectedVariant.required.includes(name)) {
|
|
135
|
+
if (!requiredBadge) {
|
|
136
|
+
const badge = document.createElement('span');
|
|
137
|
+
badge.className = 'text-red-600 text-xs ml-3 flex-shrink-0';
|
|
138
|
+
badge.textContent = 'required';
|
|
139
|
+
nameEl.parentElement.appendChild(badge);
|
|
140
|
+
}
|
|
141
|
+
} else {
|
|
142
|
+
requiredBadge?.remove();
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
selector.addEventListener('change', updateRequiredFields);
|
|
148
|
+
// Initialize with first variant
|
|
149
|
+
updateRequiredFields();
|
|
150
|
+
}
|
|
151
|
+
</script>
|
|
152
|
+
|
|
40
153
|
<style>
|
|
41
154
|
.schema-viewer code {
|
|
42
155
|
font-family: 'Courier New', Courier, monospace;
|