@eventcatalog/core 3.6.2 → 3.7.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-KOD6UMZD.js → chunk-44EDP7IH.js} +1 -1
- package/dist/{chunk-S3764NRV.js → chunk-B6NBNZGS.js} +1 -1
- package/dist/{chunk-NI3M6IVT.js → chunk-BVJJ3COQ.js} +1 -1
- package/dist/{chunk-LFXU3MEP.js → chunk-MIHGWXCX.js} +1 -1
- package/dist/{chunk-BWIAPGUD.js → chunk-PV5ER42D.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 +5 -5
- package/dist/generate.cjs +1 -1
- package/dist/generate.js +3 -3
- package/dist/utils/cli-logger.cjs +1 -1
- package/dist/utils/cli-logger.js +2 -2
- package/eventcatalog/src/components/SchemaExplorer/JSONSchemaViewer.tsx +175 -45
- package/eventcatalog/src/content.config.ts +2 -0
- package/eventcatalog/src/pages/api/sidebar-data.json.ts +8 -3
- package/eventcatalog/src/stores/sidebar-store/builders/domain.ts +24 -0
- package/eventcatalog/src/utils/collections/domains.ts +52 -32
- package/package.json +4 -4
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
log_build_default
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-B6NBNZGS.js";
|
|
4
|
+
import "../chunk-BVJJ3COQ.js";
|
|
5
|
+
import "../chunk-MIHGWXCX.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
|
@@ -109,7 +109,7 @@ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
|
|
|
109
109
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
110
110
|
|
|
111
111
|
// package.json
|
|
112
|
-
var version = "3.
|
|
112
|
+
var version = "3.7.1";
|
|
113
113
|
|
|
114
114
|
// src/constants.ts
|
|
115
115
|
var VERSION = version;
|
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-B6NBNZGS.js";
|
|
10
|
+
import "./chunk-BVJJ3COQ.js";
|
|
11
11
|
import {
|
|
12
12
|
runMigrations
|
|
13
13
|
} from "./chunk-BH3JMNAV.js";
|
|
@@ -21,13 +21,13 @@ import {
|
|
|
21
21
|
} from "./chunk-5VBIXL6C.js";
|
|
22
22
|
import {
|
|
23
23
|
generate
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-44EDP7IH.js";
|
|
25
25
|
import {
|
|
26
26
|
logger
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-PV5ER42D.js";
|
|
28
28
|
import {
|
|
29
29
|
VERSION
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-MIHGWXCX.js";
|
|
31
31
|
import "./chunk-UPONRQSN.js";
|
|
32
32
|
|
|
33
33
|
// src/eventcatalog.ts
|
package/dist/generate.cjs
CHANGED
package/dist/generate.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
generate
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-44EDP7IH.js";
|
|
4
|
+
import "./chunk-PV5ER42D.js";
|
|
5
|
+
import "./chunk-MIHGWXCX.js";
|
|
6
6
|
import "./chunk-UPONRQSN.js";
|
|
7
7
|
export {
|
|
8
8
|
generate
|
package/dist/utils/cli-logger.js
CHANGED
|
@@ -157,32 +157,32 @@ function processSchema(schema: any, rootSchema?: any): any {
|
|
|
157
157
|
return mergeAllOfSchemas({ ...schema, processSchema: (s: any) => processSchema(s, root) });
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
if (schema.oneOf) {
|
|
161
|
-
const
|
|
160
|
+
if (schema.oneOf || schema.anyOf) {
|
|
161
|
+
const variantsArray = schema.oneOf || schema.anyOf;
|
|
162
|
+
const variantType = schema.oneOf ? 'oneOf' : 'anyOf';
|
|
163
|
+
|
|
164
|
+
const processedVariants = variantsArray.map((variant: any, index: number) => {
|
|
162
165
|
const processedVariant = processSchema(variant, root);
|
|
163
166
|
return {
|
|
164
|
-
title: processedVariant.title || variant.title ||
|
|
167
|
+
title: processedVariant.title || variant.title || processedVariant.$id || `Option ${index + 1}`,
|
|
168
|
+
description: processedVariant.description || variant.description,
|
|
165
169
|
required: processedVariant.required || variant.required || [],
|
|
166
170
|
properties: processedVariant.properties || {},
|
|
171
|
+
type: processedVariant.type || variant.type || 'object',
|
|
167
172
|
...processedVariant,
|
|
168
173
|
};
|
|
169
174
|
});
|
|
170
175
|
|
|
171
|
-
const allProperties: Record<string, any> = {};
|
|
172
|
-
processedVariants.forEach((variant: any) => {
|
|
173
|
-
if (variant.properties) {
|
|
174
|
-
Object.assign(allProperties, variant.properties);
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
|
|
178
176
|
return {
|
|
179
177
|
...schema,
|
|
180
178
|
type: schema.type || 'object',
|
|
181
|
-
properties:
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
179
|
+
properties: schema.properties
|
|
180
|
+
? Object.fromEntries(
|
|
181
|
+
Object.entries(schema.properties).map(([key, prop]: [string, any]) => [key, processSchema(prop, root)])
|
|
182
|
+
)
|
|
183
|
+
: {},
|
|
185
184
|
variants: processedVariants,
|
|
185
|
+
variantType,
|
|
186
186
|
};
|
|
187
187
|
}
|
|
188
188
|
|
|
@@ -203,9 +203,66 @@ function processSchema(schema: any, rootSchema?: any): any {
|
|
|
203
203
|
return schema;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
+
// NestedVariantSelector component for handling variants within array items
|
|
207
|
+
const NestedVariantSelector = ({
|
|
208
|
+
variants,
|
|
209
|
+
variantType,
|
|
210
|
+
level,
|
|
211
|
+
expand,
|
|
212
|
+
}: {
|
|
213
|
+
variants: any[];
|
|
214
|
+
variantType?: string;
|
|
215
|
+
level: number;
|
|
216
|
+
expand: boolean;
|
|
217
|
+
}) => {
|
|
218
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
219
|
+
const selectedVariant = variants[selectedIndex];
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<div className="mt-2">
|
|
223
|
+
<div className="p-2 bg-[rgb(var(--ec-accent-subtle,var(--ec-content-hover)))] border border-[rgb(var(--ec-page-border))] rounded-md">
|
|
224
|
+
<div className="flex flex-col sm:flex-row sm:items-center gap-2">
|
|
225
|
+
<span className="text-xs font-medium text-[rgb(var(--ec-page-text))]">
|
|
226
|
+
{variantType === 'anyOf' ? 'Any of' : 'One of'} {variants.length} options:
|
|
227
|
+
</span>
|
|
228
|
+
<select
|
|
229
|
+
value={selectedIndex}
|
|
230
|
+
onChange={(e) => setSelectedIndex(parseInt(e.target.value))}
|
|
231
|
+
className="form-select text-xs border-[rgb(var(--ec-input-border))] bg-[rgb(var(--ec-input-bg))] text-[rgb(var(--ec-input-text))] rounded-md shadow-sm focus:border-[rgb(var(--ec-accent))] focus:ring focus:ring-[rgb(var(--ec-accent)/0.2)] py-1"
|
|
232
|
+
>
|
|
233
|
+
{variants.map((variant: any, index: number) => (
|
|
234
|
+
<option key={index} value={index}>
|
|
235
|
+
{variant.title}
|
|
236
|
+
</option>
|
|
237
|
+
))}
|
|
238
|
+
</select>
|
|
239
|
+
</div>
|
|
240
|
+
{selectedVariant?.description && (
|
|
241
|
+
<p className="text-xs text-[rgb(var(--ec-page-text-muted))] mt-1">{selectedVariant.description}</p>
|
|
242
|
+
)}
|
|
243
|
+
</div>
|
|
244
|
+
{selectedVariant?.properties && (
|
|
245
|
+
<div className="mt-2">
|
|
246
|
+
{Object.entries(selectedVariant.properties).map(([propName, propDetails]: [string, any]) => (
|
|
247
|
+
<SchemaProperty
|
|
248
|
+
key={`${selectedIndex}-${propName}`}
|
|
249
|
+
name={propName}
|
|
250
|
+
details={propDetails}
|
|
251
|
+
isRequired={selectedVariant.required?.includes(propName) ?? false}
|
|
252
|
+
level={level}
|
|
253
|
+
expand={expand}
|
|
254
|
+
/>
|
|
255
|
+
))}
|
|
256
|
+
</div>
|
|
257
|
+
)}
|
|
258
|
+
</div>
|
|
259
|
+
);
|
|
260
|
+
};
|
|
261
|
+
|
|
206
262
|
// SchemaProperty component
|
|
207
263
|
const SchemaProperty = ({ name, details, isRequired, level, isListItem = false, expand }: SchemaPropertyProps) => {
|
|
208
264
|
const [isExpanded, setIsExpanded] = useState(expand);
|
|
265
|
+
const [selectedVariantIndex, setSelectedVariantIndex] = useState(0);
|
|
209
266
|
const contentId = useRef(`prop-${name}-${level}-${Math.random().toString(36).substring(2, 7)}`).current;
|
|
210
267
|
|
|
211
268
|
useEffect(() => {
|
|
@@ -219,8 +276,11 @@ const SchemaProperty = ({ name, details, isRequired, level, isListItem = false,
|
|
|
219
276
|
((details.items.type === 'object' && details.items.properties) ||
|
|
220
277
|
details.items.allOf ||
|
|
221
278
|
details.items.oneOf ||
|
|
279
|
+
details.items.anyOf ||
|
|
280
|
+
details.items.variants ||
|
|
222
281
|
details.items.$ref);
|
|
223
|
-
const
|
|
282
|
+
const hasVariants = details.variants && details.variants.length > 0;
|
|
283
|
+
const isCollapsible = hasNestedProperties || hasArrayItemProperties || hasVariants;
|
|
224
284
|
|
|
225
285
|
const indentationClass = `pl-${level * 3}`;
|
|
226
286
|
|
|
@@ -247,7 +307,7 @@ const SchemaProperty = ({ name, details, isRequired, level, isListItem = false,
|
|
|
247
307
|
<div>
|
|
248
308
|
<span className="font-semibold text-[rgb(var(--ec-page-text))] text-sm">{name}</span>
|
|
249
309
|
<span className="ml-1.5 text-[rgb(var(--ec-accent))] font-mono text-xs">
|
|
250
|
-
{details.type}
|
|
310
|
+
{hasVariants ? (details.variantType === 'anyOf' ? 'anyOf' : 'oneOf') : details.type}
|
|
251
311
|
{details.type === 'array' && details.items?.type ? `[${details.items.type}]` : ''}
|
|
252
312
|
{details.format ? `<${details.format}>` : ''}
|
|
253
313
|
{details._refPath && (
|
|
@@ -325,9 +385,53 @@ const SchemaProperty = ({ name, details, isRequired, level, isListItem = false,
|
|
|
325
385
|
)}
|
|
326
386
|
</div>
|
|
327
387
|
|
|
328
|
-
{(hasNestedProperties || hasArrayItems) && (
|
|
388
|
+
{(hasNestedProperties || hasArrayItems || hasVariants) && (
|
|
329
389
|
<div id={contentId} className={`nested-content mt-1 ${isCollapsible && !isExpanded ? 'hidden' : ''}`}>
|
|
390
|
+
{hasVariants && (
|
|
391
|
+
<div className="mt-2 mb-2 p-2 bg-[rgb(var(--ec-accent-subtle,var(--ec-content-hover)))] border border-[rgb(var(--ec-page-border))] rounded-md">
|
|
392
|
+
<div className="flex flex-col sm:flex-row sm:items-center gap-2">
|
|
393
|
+
<span className="text-xs font-medium text-[rgb(var(--ec-page-text))]">
|
|
394
|
+
{details.variantType === 'anyOf' ? 'Any of' : 'One of'} {details.variants.length} options:
|
|
395
|
+
</span>
|
|
396
|
+
<select
|
|
397
|
+
value={selectedVariantIndex}
|
|
398
|
+
onChange={(e) => setSelectedVariantIndex(parseInt(e.target.value))}
|
|
399
|
+
className="form-select text-xs border-[rgb(var(--ec-input-border))] bg-[rgb(var(--ec-input-bg))] text-[rgb(var(--ec-input-text))] rounded-md shadow-sm focus:border-[rgb(var(--ec-accent))] focus:ring focus:ring-[rgb(var(--ec-accent)/0.2)] py-1"
|
|
400
|
+
>
|
|
401
|
+
{details.variants.map((variant: any, index: number) => (
|
|
402
|
+
<option key={index} value={index}>
|
|
403
|
+
{variant.title}
|
|
404
|
+
</option>
|
|
405
|
+
))}
|
|
406
|
+
</select>
|
|
407
|
+
</div>
|
|
408
|
+
{details.variants[selectedVariantIndex]?.description && (
|
|
409
|
+
<p className="text-xs text-[rgb(var(--ec-page-text-muted))] mt-1">
|
|
410
|
+
{details.variants[selectedVariantIndex].description}
|
|
411
|
+
</p>
|
|
412
|
+
)}
|
|
413
|
+
</div>
|
|
414
|
+
)}
|
|
415
|
+
|
|
416
|
+
{hasVariants && details.variants[selectedVariantIndex]?.properties && (
|
|
417
|
+
<div className="mt-1">
|
|
418
|
+
{Object.entries(details.variants[selectedVariantIndex].properties).map(
|
|
419
|
+
([nestedName, nestedDetails]: [string, any]) => (
|
|
420
|
+
<SchemaProperty
|
|
421
|
+
key={`${selectedVariantIndex}-${nestedName}`}
|
|
422
|
+
name={nestedName}
|
|
423
|
+
details={nestedDetails}
|
|
424
|
+
isRequired={details.variants[selectedVariantIndex]?.required?.includes(nestedName) ?? false}
|
|
425
|
+
level={level + 1}
|
|
426
|
+
expand={expand}
|
|
427
|
+
/>
|
|
428
|
+
)
|
|
429
|
+
)}
|
|
430
|
+
</div>
|
|
431
|
+
)}
|
|
432
|
+
|
|
330
433
|
{hasNestedProperties &&
|
|
434
|
+
!hasVariants &&
|
|
331
435
|
details.properties &&
|
|
332
436
|
Object.entries(details.properties).map(([nestedName, nestedDetails]: [string, any]) => (
|
|
333
437
|
<SchemaProperty
|
|
@@ -355,11 +459,21 @@ const SchemaProperty = ({ name, details, isRequired, level, isListItem = false,
|
|
|
355
459
|
expand={expand}
|
|
356
460
|
/>
|
|
357
461
|
))}
|
|
358
|
-
{
|
|
359
|
-
<
|
|
360
|
-
|
|
361
|
-
|
|
462
|
+
{details.items.variants && details.items.variants.length > 0 && (
|
|
463
|
+
<NestedVariantSelector
|
|
464
|
+
variants={details.items.variants}
|
|
465
|
+
variantType={details.items.variantType}
|
|
466
|
+
level={level + 1}
|
|
467
|
+
expand={expand}
|
|
468
|
+
/>
|
|
362
469
|
)}
|
|
470
|
+
{(details.items.allOf || details.items.oneOf || details.items.anyOf || details.items.$ref) &&
|
|
471
|
+
!details.items.properties &&
|
|
472
|
+
!details.items.variants && (
|
|
473
|
+
<div className="text-xs text-[rgb(var(--ec-page-text-muted))] mt-1">
|
|
474
|
+
Complex array item schema detected. The properties should be processed by the parent SchemaViewer.
|
|
475
|
+
</div>
|
|
476
|
+
)}
|
|
363
477
|
</div>
|
|
364
478
|
)}
|
|
365
479
|
</div>
|
|
@@ -421,7 +535,7 @@ export default function JSONSchemaViewer({
|
|
|
421
535
|
return { displaySchema: display, isRootArray: isArray };
|
|
422
536
|
}, [processedSchema]);
|
|
423
537
|
|
|
424
|
-
const { description, properties, required = [], variants } = displaySchema;
|
|
538
|
+
const { description, properties, required = [], variants, variantType } = displaySchema;
|
|
425
539
|
const totalProperties = useMemo(() => countProperties(displaySchema), [displaySchema]);
|
|
426
540
|
|
|
427
541
|
// Search functionality
|
|
@@ -667,14 +781,16 @@ export default function JSONSchemaViewer({
|
|
|
667
781
|
)}
|
|
668
782
|
{description && <p className="text-[rgb(var(--ec-page-text-muted))] text-xs mb-5">{description}</p>}
|
|
669
783
|
|
|
670
|
-
{variants && (
|
|
671
|
-
<div className="mb-4">
|
|
672
|
-
<div className="flex items-center
|
|
673
|
-
<span className="text-sm text-[rgb(var(--ec-page-text
|
|
784
|
+
{variants && variants.length > 0 && (
|
|
785
|
+
<div className="mb-4 p-3 bg-[rgb(var(--ec-accent-subtle,var(--ec-content-hover)))] border border-[rgb(var(--ec-page-border))] rounded-md">
|
|
786
|
+
<div className="flex flex-col sm:flex-row sm:items-center gap-2">
|
|
787
|
+
<span className="text-sm font-medium text-[rgb(var(--ec-page-text))]">
|
|
788
|
+
{variantType === 'anyOf' ? 'Any of' : 'One of'} {variants.length} options:
|
|
789
|
+
</span>
|
|
674
790
|
<select
|
|
675
791
|
value={selectedVariantIndex}
|
|
676
792
|
onChange={(e) => setSelectedVariantIndex(parseInt(e.target.value))}
|
|
677
|
-
className="form-select text-sm border-[rgb(var(--ec-input-border))] bg-[rgb(var(--ec-input-bg))] text-[rgb(var(--ec-input-text))] rounded-md shadow-sm focus:border-[rgb(var(--ec-accent))] focus:ring focus:ring-[rgb(var(--ec-accent)/0.2)]"
|
|
793
|
+
className="form-select text-sm border-[rgb(var(--ec-input-border))] bg-[rgb(var(--ec-input-bg))] text-[rgb(var(--ec-input-text))] rounded-md shadow-sm focus:border-[rgb(var(--ec-accent))] focus:ring focus:ring-[rgb(var(--ec-accent)/0.2)] flex-1 sm:flex-initial"
|
|
678
794
|
>
|
|
679
795
|
{variants.map((variant: any, index: number) => (
|
|
680
796
|
<option key={index} value={index}>
|
|
@@ -683,27 +799,41 @@ export default function JSONSchemaViewer({
|
|
|
683
799
|
))}
|
|
684
800
|
</select>
|
|
685
801
|
</div>
|
|
802
|
+
{variants[selectedVariantIndex]?.description && (
|
|
803
|
+
<p className="text-xs text-[rgb(var(--ec-page-text-muted))] mt-2">{variants[selectedVariantIndex].description}</p>
|
|
804
|
+
)}
|
|
686
805
|
</div>
|
|
687
806
|
)}
|
|
688
807
|
|
|
689
|
-
{
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
808
|
+
{(() => {
|
|
809
|
+
// Determine which properties to display
|
|
810
|
+
const propsToDisplay =
|
|
811
|
+
variants && variants.length > 0 && variants[selectedVariantIndex]?.properties
|
|
812
|
+
? { ...properties, ...variants[selectedVariantIndex].properties }
|
|
813
|
+
: properties;
|
|
814
|
+
const requiredProps = variants && variants.length > 0 ? variants[selectedVariantIndex]?.required || [] : required;
|
|
815
|
+
|
|
816
|
+
if (propsToDisplay && Object.keys(propsToDisplay).length > 0) {
|
|
817
|
+
return (
|
|
818
|
+
<div ref={propertiesContainerRef}>
|
|
819
|
+
{Object.entries(propsToDisplay).map(([name, details]: [string, any]) => (
|
|
820
|
+
<SchemaProperty
|
|
821
|
+
key={`${selectedVariantIndex}-${name}`}
|
|
822
|
+
name={name}
|
|
823
|
+
details={details}
|
|
824
|
+
isRequired={requiredProps.includes(name)}
|
|
825
|
+
level={0}
|
|
826
|
+
expand={expandAll}
|
|
827
|
+
/>
|
|
828
|
+
))}
|
|
829
|
+
</div>
|
|
830
|
+
);
|
|
831
|
+
} else if (!isRootArray) {
|
|
832
|
+
return <p className="text-[rgb(var(--ec-page-text-muted))] text-sm">Schema does not contain any properties.</p>;
|
|
833
|
+
}
|
|
834
|
+
return null;
|
|
835
|
+
})()}
|
|
836
|
+
{!properties && !variants && isRootArray && (
|
|
707
837
|
<div className="text-center py-8">
|
|
708
838
|
<div className="text-[rgb(var(--ec-page-text-muted))] text-sm">
|
|
709
839
|
<p>
|
|
@@ -490,6 +490,8 @@ const domains = defineCollection({
|
|
|
490
490
|
domains: z.array(pointer).optional(),
|
|
491
491
|
entities: z.array(pointer).optional(),
|
|
492
492
|
flows: z.array(pointer).optional(),
|
|
493
|
+
sends: z.array(sendsPointer).optional(),
|
|
494
|
+
receives: z.array(receivesPointer).optional(),
|
|
493
495
|
detailsPanel: z
|
|
494
496
|
.object({
|
|
495
497
|
parentDomains: detailPanelPropertySchema.optional(),
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { APIRoute } from 'astro';
|
|
2
2
|
import { getNestedSideBarData } from '@stores/sidebar-store/state';
|
|
3
3
|
|
|
4
|
+
const isDev = import.meta.env.DEV;
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* API route that returns the sidebar navigation data as JSON.
|
|
6
8
|
* This is pre-rendered in static mode to avoid embedding the data in every HTML page.
|
|
@@ -12,11 +14,14 @@ export const GET: APIRoute = async () => {
|
|
|
12
14
|
return new Response(JSON.stringify(sidebarData), {
|
|
13
15
|
headers: {
|
|
14
16
|
'Content-Type': 'application/json',
|
|
15
|
-
//
|
|
16
|
-
'Cache-Control':
|
|
17
|
+
// In dev mode, disable caching to ensure fresh data. In production, cache for 1 hour.
|
|
18
|
+
'Cache-Control': isDev
|
|
19
|
+
? 'no-cache, no-store, must-revalidate'
|
|
20
|
+
: 'public, max-age=3600, s-maxage=3600, stale-while-revalidate=86400',
|
|
17
21
|
},
|
|
18
22
|
});
|
|
19
23
|
};
|
|
20
24
|
|
|
21
25
|
// Pre-render this route in static mode so it becomes a static JSON file
|
|
22
|
-
|
|
26
|
+
// In dev mode, don't pre-render to allow dynamic updates
|
|
27
|
+
export const prerender = !isDev;
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
buildDiagramNavItems,
|
|
12
12
|
} from './shared';
|
|
13
13
|
import { isVisualiserEnabled } from '@utils/feature';
|
|
14
|
+
import { pluralizeMessageType } from '@utils/collections/messages';
|
|
14
15
|
|
|
15
16
|
export const buildDomainNode = (domain: CollectionEntry<'domains'>, owners: any[], context: ResourceGroupContext): NavNode => {
|
|
16
17
|
const servicesInDomain = domain.data.services || [];
|
|
@@ -37,6 +38,11 @@ export const buildDomainNode = (domain: CollectionEntry<'domains'>, owners: any[
|
|
|
37
38
|
|
|
38
39
|
const renderRepository = domain.data.repository && shouldRenderSideBarSection(domain, 'repository');
|
|
39
40
|
|
|
41
|
+
// Domain-level messages (sends/receives)
|
|
42
|
+
const sendsMessages = domain.data.sends || [];
|
|
43
|
+
const receivesMessages = domain.data.receives || [];
|
|
44
|
+
const renderMessages = shouldRenderSideBarSection(domain, 'messages');
|
|
45
|
+
|
|
40
46
|
// Diagrams
|
|
41
47
|
const domainDiagrams = domain.data.diagrams || [];
|
|
42
48
|
const diagramNavItems = buildDiagramNavItems(domainDiagrams, context.diagrams);
|
|
@@ -111,6 +117,24 @@ export const buildDomainNode = (domain: CollectionEntry<'domains'>, owners: any[
|
|
|
111
117
|
icon: 'Server',
|
|
112
118
|
pages: servicesInDomain.map((service) => `service:${(service as any).data.id}:${(service as any).data.version}`),
|
|
113
119
|
},
|
|
120
|
+
sendsMessages.length > 0 &&
|
|
121
|
+
renderMessages && {
|
|
122
|
+
type: 'group',
|
|
123
|
+
title: 'Domain Events',
|
|
124
|
+
icon: 'Mail',
|
|
125
|
+
pages: sendsMessages.map(
|
|
126
|
+
(message) => `${pluralizeMessageType(message as any)}:${(message as any).data.id}:${(message as any).data.version}`
|
|
127
|
+
),
|
|
128
|
+
},
|
|
129
|
+
receivesMessages.length > 0 &&
|
|
130
|
+
renderMessages && {
|
|
131
|
+
type: 'group',
|
|
132
|
+
title: 'External Events',
|
|
133
|
+
icon: 'Mail',
|
|
134
|
+
pages: receivesMessages.map(
|
|
135
|
+
(receive) => `${pluralizeMessageType(receive as any)}:${(receive as any).data.id}:${(receive as any).data.version}`
|
|
136
|
+
),
|
|
137
|
+
},
|
|
114
138
|
renderOwners && buildOwnersSection(owners),
|
|
115
139
|
renderRepository && buildRepositorySection(domain.data.repository as { url: string; language: string }),
|
|
116
140
|
hasAttachments && buildAttachmentsSection(domain.data.attachments as any[]),
|
|
@@ -79,35 +79,21 @@ export const getDomains = async ({
|
|
|
79
79
|
return memoryCache[cacheKey];
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
// 1. Fetch collections
|
|
83
|
-
const
|
|
82
|
+
// 1. Fetch collections (always fetch messages to hydrate domain-level sends/receives)
|
|
83
|
+
const [allDomains, allServices, allEntities, allFlows, allEvents, allCommands, allQueries, allContainers] = await Promise.all([
|
|
84
84
|
getCollection('domains'),
|
|
85
85
|
getCollection('services'),
|
|
86
86
|
getCollection('entities'),
|
|
87
87
|
getCollection('flows'),
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
getCollection('commands'),
|
|
94
|
-
getCollection('queries'),
|
|
95
|
-
getCollection('containers')
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const results = await Promise.all(collectionsToFetch);
|
|
100
|
-
const [allDomains, allServices, allEntities, allFlows] = results;
|
|
101
|
-
|
|
102
|
-
let messageMap = new Map();
|
|
103
|
-
let containerMap = new Map();
|
|
88
|
+
getCollection('events'),
|
|
89
|
+
getCollection('commands'),
|
|
90
|
+
getCollection('queries'),
|
|
91
|
+
getCollection('containers'),
|
|
92
|
+
]);
|
|
104
93
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
messageMap = createVersionedMap(allMessages);
|
|
109
|
-
containerMap = createVersionedMap(allContainers);
|
|
110
|
-
}
|
|
94
|
+
const allMessages = [...allEvents, ...allCommands, ...allQueries];
|
|
95
|
+
const messageMap = createVersionedMap(allMessages);
|
|
96
|
+
const containerMap = createVersionedMap(allContainers);
|
|
111
97
|
|
|
112
98
|
// 2. Build optimized maps
|
|
113
99
|
const domainMap = createVersionedMap(allDomains);
|
|
@@ -192,6 +178,15 @@ export const getDomains = async ({
|
|
|
192
178
|
? [...(hydratedMainServices as any), ...(hydratedSubdomainServices as any)]
|
|
193
179
|
: (hydratedMainServices as any);
|
|
194
180
|
|
|
181
|
+
// Hydrate domain-level sends and receives
|
|
182
|
+
const domainSends = (domain.data.sends || [])
|
|
183
|
+
.map((m: { id: string; version: string | undefined }) => findInMap(messageMap, m.id, m.version))
|
|
184
|
+
.filter((e): e is CollectionEntry<CollectionMessageTypes> => !!e);
|
|
185
|
+
|
|
186
|
+
const domainReceives = (domain.data.receives || [])
|
|
187
|
+
.map((m: { id: string; version: string | undefined }) => findInMap(messageMap, m.id, m.version))
|
|
188
|
+
.filter((e): e is CollectionEntry<CollectionMessageTypes> => !!e);
|
|
189
|
+
|
|
195
190
|
// Calculate folder paths
|
|
196
191
|
const folderName = await getResourceFolderName(
|
|
197
192
|
process.env.PROJECT_DIR ?? '',
|
|
@@ -208,6 +203,8 @@ export const getDomains = async ({
|
|
|
208
203
|
domains: subDomains as any,
|
|
209
204
|
entities: entities as any,
|
|
210
205
|
flows: flows as any,
|
|
206
|
+
sends: domainSends as any,
|
|
207
|
+
receives: domainReceives as any,
|
|
211
208
|
latestVersion,
|
|
212
209
|
versions,
|
|
213
210
|
},
|
|
@@ -249,20 +246,43 @@ export const getMessagesForDomain = async (
|
|
|
249
246
|
const allMessages = [...events, ...commands, ...queries];
|
|
250
247
|
const messageMap = createVersionedMap(allMessages);
|
|
251
248
|
|
|
252
|
-
|
|
253
|
-
const
|
|
249
|
+
// Get service-level sends/receives
|
|
250
|
+
const serviceSends = services.flatMap((service) => service.data.sends || []);
|
|
251
|
+
const serviceReceives = services.flatMap((service) => service.data.receives || []);
|
|
252
|
+
|
|
253
|
+
// Get domain-level sends/receives (already hydrated if domain came from getDomains)
|
|
254
|
+
const domainSends = domain.data.sends || [];
|
|
255
|
+
const domainReceives = domain.data.receives || [];
|
|
254
256
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
+
// Combine and deduplicate - domain-level messages take priority
|
|
258
|
+
const allSends = [...domainSends, ...serviceSends];
|
|
259
|
+
const allReceives = [...domainReceives, ...serviceReceives];
|
|
260
|
+
|
|
261
|
+
const sendsMessages = allSends
|
|
262
|
+
.map((send: any) => {
|
|
263
|
+
// If already hydrated (has data property), return as-is
|
|
264
|
+
if (send.data) return send;
|
|
265
|
+
// Otherwise, resolve from map
|
|
266
|
+
return findInMap(messageMap, send.id, send.version);
|
|
267
|
+
})
|
|
257
268
|
.filter((msg): msg is CollectionEntry<CollectionMessageTypes> => !!msg);
|
|
258
269
|
|
|
259
|
-
const receivesMessages =
|
|
260
|
-
.map((receive) =>
|
|
270
|
+
const receivesMessages = allReceives
|
|
271
|
+
.map((receive: any) => {
|
|
272
|
+
// If already hydrated (has data property), return as-is
|
|
273
|
+
if (receive.data) return receive;
|
|
274
|
+
// Otherwise, resolve from map
|
|
275
|
+
return findInMap(messageMap, receive.id, receive.version);
|
|
276
|
+
})
|
|
261
277
|
.filter((msg): msg is CollectionEntry<CollectionMessageTypes> => !!msg);
|
|
262
278
|
|
|
279
|
+
// Deduplicate by id and version
|
|
280
|
+
const uniqueSends = Array.from(new Map(sendsMessages.map((msg) => [`${msg.data.id}-${msg.data.version}`, msg])).values());
|
|
281
|
+
const uniqueReceives = Array.from(new Map(receivesMessages.map((msg) => [`${msg.data.id}-${msg.data.version}`, msg])).values());
|
|
282
|
+
|
|
263
283
|
return {
|
|
264
|
-
sends:
|
|
265
|
-
receives:
|
|
284
|
+
sends: uniqueSends,
|
|
285
|
+
receives: uniqueReceives,
|
|
266
286
|
};
|
|
267
287
|
};
|
|
268
288
|
|
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": "3.
|
|
9
|
+
"version": "3.7.1",
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"@ai-sdk/react": "^3.0.17",
|
|
24
24
|
"@astrojs/markdown-remark": "^6.3.10",
|
|
25
25
|
"@astrojs/mdx": "^4.3.13",
|
|
26
|
-
"@astrojs/node": "^9.5.
|
|
26
|
+
"@astrojs/node": "^9.5.2",
|
|
27
27
|
"@astrojs/react": "^4.4.2",
|
|
28
|
-
"@astrojs/rss": "^4.0.
|
|
28
|
+
"@astrojs/rss": "^4.0.15",
|
|
29
29
|
"@astrojs/tailwind": "^6.0.2",
|
|
30
30
|
"@asyncapi/avro-schema-parser": "3.0.24",
|
|
31
31
|
"@asyncapi/parser": "3.4.0",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@tanstack/react-table": "^8.17.3",
|
|
56
56
|
"@xyflow/react": "^12.3.6",
|
|
57
57
|
"ai": "^6.0.17",
|
|
58
|
-
"astro": "^5.16.
|
|
58
|
+
"astro": "^5.16.10",
|
|
59
59
|
"astro-compress": "^2.3.8",
|
|
60
60
|
"astro-expressive-code": "^0.41.3",
|
|
61
61
|
"astro-seo": "^0.8.4",
|