@eventcatalog/core 2.44.1 → 2.44.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.
- 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-ECUXDBJ7.js → chunk-CGPQJVQ3.js} +1 -1
- package/dist/{chunk-HGLZ22GT.js → chunk-EJOD6TNE.js} +1 -1
- package/dist/{chunk-AUGREOCT.js → chunk-SHFEPDUF.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/SchemaProperty.astro +44 -11
- package/eventcatalog/src/components/MDX/SchemaViewer/SchemaViewer.astro +126 -23
- package/eventcatalog/src/middleware-auth.ts +15 -7
- package/eventcatalog/src/middleware.ts +0 -1
- 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-CGPQJVQ3.js";
|
|
4
|
+
import "../chunk-SHFEPDUF.js";
|
|
5
|
+
import "../chunk-EJOD6TNE.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,8 +6,8 @@ import {
|
|
|
6
6
|
} from "./chunk-DCLTVJDP.js";
|
|
7
7
|
import {
|
|
8
8
|
log_build_default
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-CGPQJVQ3.js";
|
|
10
|
+
import "./chunk-SHFEPDUF.js";
|
|
11
11
|
import {
|
|
12
12
|
catalogToAstro,
|
|
13
13
|
checkAndConvertMdToMdx
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import "./chunk-EXAALOQA.js";
|
|
16
16
|
import {
|
|
17
17
|
VERSION
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-EJOD6TNE.js";
|
|
19
19
|
import {
|
|
20
20
|
isAuthEnabled,
|
|
21
21
|
isBackstagePluginEnabled,
|
|
@@ -13,7 +13,13 @@ const { name, details, isRequired, level, isListItem = false } = Astro.props;
|
|
|
13
13
|
|
|
14
14
|
const hasNestedProperties = details.type === 'object' && details.properties && Object.keys(details.properties).length > 0;
|
|
15
15
|
const hasArrayItems = details.type === 'array' && details.items;
|
|
16
|
-
const
|
|
16
|
+
const hasArrayItemProperties =
|
|
17
|
+
hasArrayItems &&
|
|
18
|
+
((details.items.type === 'object' && details.items.properties) ||
|
|
19
|
+
details.items.allOf ||
|
|
20
|
+
details.items.oneOf ||
|
|
21
|
+
details.items.$ref);
|
|
22
|
+
const isCollapsible = hasNestedProperties || hasArrayItemProperties;
|
|
17
23
|
|
|
18
24
|
// Using template literal for class calculation remains safe
|
|
19
25
|
const indentationClass = `pl-${level * 3}`;
|
|
@@ -48,12 +54,19 @@ const contentId = `prop-${name}-${level}-${Math.random().toString(36).substring(
|
|
|
48
54
|
{details.type}
|
|
49
55
|
{details.type === 'array' && details.items?.type ? `[${details.items.type}]` : ''}
|
|
50
56
|
{details.format ? `<${details.format}>` : ''}
|
|
57
|
+
{details._refPath && <span class="text-blue-600 ml-1">→ {details._refName || details._refPath}</span>}
|
|
58
|
+
{details._refNotFound && <span class="text-red-600 ml-1">❌ ref not found</span>}
|
|
51
59
|
</span>
|
|
52
60
|
</div>
|
|
53
61
|
{isRequired && <span class="text-red-600 text-xs ml-3 flex-shrink-0">required</span>}
|
|
54
62
|
</div>
|
|
55
63
|
|
|
56
64
|
{details.description && <p class="text-gray-500 text-xs mt-0.5">{details.description}</p>}
|
|
65
|
+
{
|
|
66
|
+
details.title && details.title !== details.description && (
|
|
67
|
+
<p class="text-gray-500 text-xs mt-0.5 italic">Title: {details.title}</p>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
57
70
|
|
|
58
71
|
{/* Reverted arbitrary text size to standard 'text-xs' */}
|
|
59
72
|
<div class="text-xs text-gray-500 mt-0.5 space-y-0">
|
|
@@ -78,6 +91,20 @@ const contentId = `prop-${name}-${level}-${Math.random().toString(36).substring(
|
|
|
78
91
|
</div>
|
|
79
92
|
)
|
|
80
93
|
}
|
|
94
|
+
{
|
|
95
|
+
details.minLength !== undefined && (
|
|
96
|
+
<div>
|
|
97
|
+
Min length: <code class="bg-gray-100 px-1 rounded text-gray-800 font-thin py-0.5">{details.minLength}</code>
|
|
98
|
+
</div>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
{
|
|
102
|
+
details.maxLength !== undefined && (
|
|
103
|
+
<div>
|
|
104
|
+
Max length: <code class="bg-gray-100 px-1 rounded text-gray-800 font-thin py-0.5">{details.maxLength}</code>
|
|
105
|
+
</div>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
81
108
|
{
|
|
82
109
|
details.enum && (
|
|
83
110
|
<div>
|
|
@@ -110,18 +137,24 @@ const contentId = `prop-${name}-${level}-${Math.random().toString(36).substring(
|
|
|
110
137
|
/>
|
|
111
138
|
))}
|
|
112
139
|
|
|
113
|
-
{
|
|
140
|
+
{hasArrayItemProperties && (
|
|
114
141
|
<div class="mt-1 border-l border-dashed border-gray-400 pl-3 ml-1.5">
|
|
115
142
|
<span class="text-xs italic text-gray-500 block mb-1">Item Details:</span>
|
|
116
|
-
{
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
143
|
+
{details.items.properties &&
|
|
144
|
+
Object.entries(details.items.properties).map(([itemPropName, itemPropDetails]) => (
|
|
145
|
+
<SchemaProp
|
|
146
|
+
name={itemPropName}
|
|
147
|
+
details={itemPropDetails}
|
|
148
|
+
isRequired={details.items.required?.includes(itemPropName) ?? false}
|
|
149
|
+
level={level + 1}
|
|
150
|
+
isListItem={true}
|
|
151
|
+
/>
|
|
152
|
+
))}
|
|
153
|
+
{(details.items.allOf || details.items.oneOf || details.items.$ref) && !details.items.properties && (
|
|
154
|
+
<div class="text-xs text-gray-500 mt-1">
|
|
155
|
+
Complex array item schema detected. The properties should be processed by the parent SchemaViewer.
|
|
156
|
+
</div>
|
|
157
|
+
)}
|
|
125
158
|
</div>
|
|
126
159
|
)}
|
|
127
160
|
</div>
|
|
@@ -14,7 +14,8 @@ interface Props {
|
|
|
14
14
|
const { id, file, title, maxHeight, schema } = Astro.props;
|
|
15
15
|
|
|
16
16
|
// Function to merge allOf schemas
|
|
17
|
-
function mergeAllOfSchemas(
|
|
17
|
+
function mergeAllOfSchemas(schemaWithProcessor: any): any {
|
|
18
|
+
const { processSchema: processor, ...schema } = schemaWithProcessor;
|
|
18
19
|
if (!schema.allOf) return schema;
|
|
19
20
|
|
|
20
21
|
const mergedSchema: {
|
|
@@ -22,63 +23,165 @@ function mergeAllOfSchemas(schema: any) {
|
|
|
22
23
|
properties: Record<string, any>;
|
|
23
24
|
required: string[];
|
|
24
25
|
description?: string;
|
|
26
|
+
[key: string]: any;
|
|
25
27
|
} = {
|
|
26
|
-
type: 'object',
|
|
28
|
+
type: schema.type || 'object',
|
|
27
29
|
properties: {},
|
|
28
30
|
required: [],
|
|
29
31
|
description: schema.description,
|
|
30
32
|
};
|
|
31
33
|
|
|
34
|
+
// Copy base schema properties first (excluding allOf)
|
|
35
|
+
Object.keys(schema).forEach((key) => {
|
|
36
|
+
if (key !== 'allOf' && key !== 'properties' && key !== 'required' && key !== 'description') {
|
|
37
|
+
mergedSchema[key] = schema[key];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Copy base properties if they exist
|
|
42
|
+
if (schema.properties) {
|
|
43
|
+
mergedSchema.properties = { ...schema.properties };
|
|
44
|
+
}
|
|
45
|
+
if (schema.required) {
|
|
46
|
+
mergedSchema.required = [...schema.required];
|
|
47
|
+
}
|
|
48
|
+
|
|
32
49
|
schema.allOf.forEach((subSchema: any) => {
|
|
33
|
-
|
|
50
|
+
// Recursively process each subSchema in case it has its own allOf, oneOf, or $ref
|
|
51
|
+
const processedSubSchema = processor ? processor(subSchema) : subSchema;
|
|
52
|
+
|
|
53
|
+
if (processedSubSchema.properties) {
|
|
34
54
|
mergedSchema.properties = {
|
|
35
55
|
...mergedSchema.properties,
|
|
36
|
-
...
|
|
56
|
+
...processedSubSchema.properties,
|
|
37
57
|
};
|
|
38
58
|
}
|
|
39
|
-
if (
|
|
40
|
-
mergedSchema.required = [...mergedSchema.required, ...
|
|
59
|
+
if (processedSubSchema.required) {
|
|
60
|
+
mergedSchema.required = [...new Set([...mergedSchema.required, ...processedSubSchema.required])];
|
|
41
61
|
}
|
|
42
|
-
if (
|
|
43
|
-
mergedSchema.description =
|
|
62
|
+
if (processedSubSchema.description && !mergedSchema.description) {
|
|
63
|
+
mergedSchema.description = processedSubSchema.description;
|
|
44
64
|
}
|
|
65
|
+
|
|
66
|
+
// Copy other properties from subSchema
|
|
67
|
+
Object.keys(processedSubSchema).forEach((key) => {
|
|
68
|
+
if (key !== 'properties' && key !== 'required' && key !== 'description' && key !== 'type') {
|
|
69
|
+
if (!mergedSchema[key]) {
|
|
70
|
+
mergedSchema[key] = processedSubSchema[key];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
45
74
|
});
|
|
46
75
|
|
|
47
76
|
return mergedSchema;
|
|
48
77
|
}
|
|
49
78
|
|
|
50
|
-
function processSchema(schema: any) {
|
|
79
|
+
function processSchema(schema: any, rootSchema?: any): any {
|
|
80
|
+
if (!schema) return schema;
|
|
81
|
+
|
|
82
|
+
// Set rootSchema for $ref resolution
|
|
83
|
+
const root = rootSchema || schema;
|
|
84
|
+
|
|
51
85
|
// Handle $ref
|
|
52
86
|
if (schema.$ref) {
|
|
53
|
-
// Only support local refs like "#/definitions/xyz"
|
|
54
87
|
const refPath = schema.$ref;
|
|
88
|
+
let resolvedSchema = null;
|
|
89
|
+
let defName = '';
|
|
90
|
+
|
|
91
|
+
// Try draft-7 style first: #/definitions/
|
|
55
92
|
if (refPath.startsWith('#/definitions/')) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
93
|
+
defName = refPath.replace('#/definitions/', '');
|
|
94
|
+
if (root.definitions && root.definitions[defName]) {
|
|
95
|
+
resolvedSchema = root.definitions[defName];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// Try 2020-12 style: #/$defs/
|
|
99
|
+
else if (refPath.startsWith('#/$defs/')) {
|
|
100
|
+
defName = refPath.replace('#/$defs/', '');
|
|
101
|
+
if (root.$defs && root.$defs[defName]) {
|
|
102
|
+
resolvedSchema = root.$defs[defName];
|
|
61
103
|
}
|
|
62
104
|
}
|
|
63
|
-
//
|
|
64
|
-
|
|
105
|
+
// Try other common patterns
|
|
106
|
+
else if (refPath.startsWith('#/components/schemas/')) {
|
|
107
|
+
defName = refPath.replace('#/components/schemas/', '');
|
|
108
|
+
if (root.components && root.components.schemas && root.components.schemas[defName]) {
|
|
109
|
+
resolvedSchema = root.components.schemas[defName];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (resolvedSchema) {
|
|
114
|
+
// Recursively process the referenced schema
|
|
115
|
+
const processedSchema = processSchema(resolvedSchema, root);
|
|
116
|
+
// Add reference info to the resolved schema
|
|
117
|
+
return {
|
|
118
|
+
...processedSchema,
|
|
119
|
+
_refPath: refPath,
|
|
120
|
+
_refName: defName,
|
|
121
|
+
_originalRef: schema.$ref,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// If not found, create a placeholder schema showing the reference
|
|
126
|
+
return {
|
|
127
|
+
type: 'string',
|
|
128
|
+
description: `Reference to ${refPath} (definition not found in root schema)`,
|
|
129
|
+
title: defName || refPath.split('/').pop(),
|
|
130
|
+
_refPath: refPath,
|
|
131
|
+
_refName: defName,
|
|
132
|
+
_refNotFound: true,
|
|
133
|
+
};
|
|
65
134
|
}
|
|
66
135
|
|
|
67
136
|
if (schema.allOf) {
|
|
68
|
-
return mergeAllOfSchemas(schema);
|
|
137
|
+
return mergeAllOfSchemas({ ...schema, processSchema: (s: any) => processSchema(s, root) });
|
|
69
138
|
}
|
|
70
139
|
|
|
71
140
|
if (schema.oneOf) {
|
|
72
|
-
//
|
|
141
|
+
// Process each oneOf variant and create a combined schema
|
|
142
|
+
const processedVariants = schema.oneOf.map((variant: any) => {
|
|
143
|
+
const processedVariant = processSchema(variant, root);
|
|
144
|
+
return {
|
|
145
|
+
title: processedVariant.title || variant.title || 'Unnamed Variant',
|
|
146
|
+
required: processedVariant.required || variant.required || [],
|
|
147
|
+
properties: processedVariant.properties || {},
|
|
148
|
+
...processedVariant,
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// Merge all properties from variants for display
|
|
153
|
+
const allProperties: Record<string, any> = {};
|
|
154
|
+
processedVariants.forEach((variant) => {
|
|
155
|
+
if (variant.properties) {
|
|
156
|
+
Object.assign(allProperties, variant.properties);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
73
160
|
return {
|
|
74
161
|
...schema,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
162
|
+
type: schema.type || 'object',
|
|
163
|
+
properties: {
|
|
164
|
+
...(schema.properties || {}),
|
|
165
|
+
...allProperties,
|
|
166
|
+
},
|
|
167
|
+
variants: processedVariants,
|
|
79
168
|
};
|
|
80
169
|
}
|
|
81
170
|
|
|
171
|
+
// Process nested schemas in properties
|
|
172
|
+
if (schema.properties) {
|
|
173
|
+
const processedProperties: Record<string, any> = {};
|
|
174
|
+
Object.entries(schema.properties).forEach(([key, prop]: [string, any]) => {
|
|
175
|
+
processedProperties[key] = processSchema(prop, root);
|
|
176
|
+
});
|
|
177
|
+
schema = { ...schema, properties: processedProperties };
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Process array items
|
|
181
|
+
if (schema.type === 'array' && schema.items) {
|
|
182
|
+
schema = { ...schema, items: processSchema(schema.items, root) };
|
|
183
|
+
}
|
|
184
|
+
|
|
82
185
|
return schema;
|
|
83
186
|
}
|
|
84
187
|
|
|
@@ -33,13 +33,21 @@ interface TypedLocals {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// Wildcard matching utilities
|
|
36
|
-
export function matchesPattern(pattern: string,
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
export function matchesPattern(pattern: string, path: string): boolean {
|
|
37
|
+
const escapeRegExp = (str: string) => str.replace(/[-/\\^$+?.()|[\]{}]/g, '\\$&');
|
|
38
|
+
|
|
39
|
+
// Convert the pattern to a regular expression
|
|
40
|
+
const regexStr = pattern
|
|
41
|
+
.split('/')
|
|
42
|
+
.map((part) => {
|
|
43
|
+
if (part === '**') return '.*';
|
|
44
|
+
if (part === '*') return '[^/]+';
|
|
45
|
+
return escapeRegExp(part);
|
|
46
|
+
})
|
|
47
|
+
.join('/');
|
|
48
|
+
|
|
49
|
+
const regex = new RegExp(`^${regexStr}$`);
|
|
50
|
+
return regex.test(path);
|
|
43
51
|
}
|
|
44
52
|
|
|
45
53
|
function calculateSpecificity(pattern: string): number {
|