@eventcatalog/core 2.33.9 → 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.
@@ -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.9";
40
+ var version = "2.33.11";
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-LHX6OHFE.js";
4
- import "../chunk-OKSJ75RQ.js";
3
+ } from "../chunk-WHJEWUMZ.js";
4
+ import "../chunk-2NTEYUNI.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.9";
109
+ var version = "2.33.11";
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-LVSH6F2F.js";
4
- import "../chunk-LHX6OHFE.js";
5
- import "../chunk-OKSJ75RQ.js";
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
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "2.33.9";
2
+ var version = "2.33.11";
3
3
 
4
4
  // src/constants.ts
5
5
  var VERSION = version;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  raiseEvent
3
- } from "./chunk-LHX6OHFE.js";
3
+ } from "./chunk-WHJEWUMZ.js";
4
4
  import {
5
5
  getEventCatalogConfigFile,
6
6
  verifyRequiredFieldsAreInCatalogConfigFile
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-OKSJ75RQ.js";
3
+ } from "./chunk-2NTEYUNI.js";
4
4
 
5
5
  // src/analytics/analytics.js
6
6
  import axios from "axios";
@@ -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.9";
28
+ var version = "2.33.11";
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-OKSJ75RQ.js";
3
+ } from "./chunk-2NTEYUNI.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.9";
160
+ var version = "2.33.11";
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-LVSH6F2F.js";
10
- import "./chunk-LHX6OHFE.js";
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-OKSJ75RQ.js";
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
- const { description, properties, required = [] } = schema;
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
- properties &&
31
- Object.entries(properties).map(([name, details]) => (
32
- <SchemaProperty name={name} details={details} isRequired={required.includes(name)} level={0} />
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;
@@ -116,10 +116,13 @@ const baseSchema = z.object({
116
116
  })
117
117
  .optional(),
118
118
  deprecated: z
119
- .object({
120
- message: z.string().optional(),
121
- date: z.date().optional(),
122
- })
119
+ .union([
120
+ z.object({
121
+ message: z.string().optional(),
122
+ date: z.date().optional(),
123
+ }),
124
+ z.boolean().optional(),
125
+ ])
123
126
  .optional(),
124
127
  // Used by eventcatalog
125
128
  versions: z.array(z.string()).optional(),
@@ -6,7 +6,6 @@ import { marked } from 'marked';
6
6
  import components from '@components/MDX/components';
7
7
  import NodeGraph from '@components/MDX/NodeGraph/NodeGraph.astro';
8
8
  import SchemaViewer from '@components/MDX/SchemaViewer/SchemaViewerRoot.astro';
9
-
10
9
  import Admonition from '@components/MDX/Admonition';
11
10
 
12
11
  // SideBars
@@ -17,16 +16,20 @@ import ChannelSideBar from '@components/SideBars/ChannelSideBar.astro';
17
16
  import FlowSideBar from '@components/SideBars/FlowSideBar.astro';
18
17
 
19
18
  import { QueueListIcon, RectangleGroupIcon, ServerIcon, BoltIcon, ChatBubbleLeftIcon } from '@heroicons/react/24/outline';
19
+ import { ArrowsRightLeftIcon } from '@heroicons/react/20/solid';
20
+
20
21
  import type { PageTypes } from '@types';
22
+ import type { CollectionTypes } from '@types';
21
23
 
22
- import { buildUrl } from '@utils/url-builder';
23
- import { pageDataLoader } from '@utils/page-loaders/page-data-loader';
24
24
  import { ClientRouter } from 'astro:transitions';
25
25
  import { render } from 'astro:content';
26
- import { ArrowsRightLeftIcon } from '@heroicons/react/20/solid';
26
+ import type { CollectionEntry } from 'astro:content';
27
27
 
28
- import config from '@config';
29
28
  import { getIcon } from '@utils/badges';
29
+ import { getDeprecatedDetails } from '@utils/collections/util';
30
+ import { pageDataLoader } from '@utils/page-loaders/page-data-loader';
31
+ import { buildUrl } from '@utils/url-builder';
32
+ import config from '@config';
30
33
 
31
34
  export async function getStaticPaths() {
32
35
  const itemTypes: PageTypes[] = ['events', 'commands', 'queries', 'services', 'domains', 'flows', 'channels'];
@@ -136,11 +139,13 @@ const pagefindAttributes =
136
139
  }
137
140
  : {};
138
141
 
139
- const isMarkedAsDeprecated = props.data.deprecated;
140
- const hasDeprecated = props.data.deprecated?.date && new Date(props.data.deprecated?.date) < new Date();
141
- const formattedDate = props.data.deprecated?.date
142
- ? new Date(props.data.deprecated?.date).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })
143
- : '';
142
+ const {
143
+ hasDeprecated,
144
+ message: deprecatedMessage,
145
+ isMarkedAsDeprecated,
146
+ deprecatedDate: formattedDate,
147
+ } = getDeprecatedDetails(props as unknown as CollectionEntry<CollectionTypes>);
148
+
144
149
  let friendlyCollectionName = props.collection.slice(0, props.collection.length - 1);
145
150
  friendlyCollectionName = friendlyCollectionName === 'querie' ? 'query' : friendlyCollectionName;
146
151
  ---
@@ -149,7 +154,7 @@ friendlyCollectionName = friendlyCollectionName === 'querie' ? 'query' : friendl
149
154
  <main class="flex sm:px-8 docs-layout h-full" {...pagefindAttributes}>
150
155
  <div class="flex docs-layout w-full">
151
156
  <div class="w-full lg:mr-2 pr-8 overflow-y-auto py-8">
152
- <div class="border-b border-gray-200 flex justify-between items-start md:pb-2">
157
+ <div class="border-b border-gray-200 md:pb-2">
153
158
  <div>
154
159
  <h2
155
160
  id="doc-page-header"
@@ -160,16 +165,19 @@ friendlyCollectionName = friendlyCollectionName === 'querie' ? 'query' : friendl
160
165
  </h2>
161
166
  {
162
167
  isMarkedAsDeprecated && hasDeprecated && (
163
- <Admonition type="alert" title={`This ${friendlyCollectionName} was deprecated on ${formattedDate}`}>
168
+ <Admonition
169
+ className="w-full"
170
+ type="alert"
171
+ title={formattedDate ? `This ${friendlyCollectionName} was deprecated on ${formattedDate}` : `Deprecated`}
172
+ >
164
173
  <div>
165
- {!props.data.deprecated?.message && (
174
+ {!deprecatedMessage && (
166
175
  <p>
167
- The {friendlyCollectionName} has been deprecated ({props.data.deprecated?.date}).
176
+ The {friendlyCollectionName} has been marked as deprecated
177
+ {formattedDate && ` on ${formattedDate}`}.
168
178
  </p>
169
179
  )}
170
- {props.data.deprecated?.message && (
171
- <div class="prose prose-sm max-w-none" set:html={marked.parse(props.data.deprecated?.message)} />
172
- )}
180
+ {deprecatedMessage && <div class="prose prose-sm max-w-none" set:html={marked.parse(deprecatedMessage)} />}
173
181
  </div>
174
182
  </Admonition>
175
183
  )
@@ -178,14 +186,12 @@ friendlyCollectionName = friendlyCollectionName === 'querie' ? 'query' : friendl
178
186
  isMarkedAsDeprecated && !hasDeprecated && (
179
187
  <Admonition type="warning" title={`This ${friendlyCollectionName} will be deprecated on ${formattedDate}`}>
180
188
  <div>
181
- {!props.data.deprecated?.message && (
189
+ {!deprecatedMessage && (
182
190
  <p>
183
191
  The {friendlyCollectionName} will be deprecated on {formattedDate}.
184
192
  </p>
185
193
  )}
186
- {props.data.deprecated?.message && (
187
- <div class="prose prose-sm max-w-none" set:html={marked.parse(props.data.deprecated?.message)} />
188
- )}
194
+ {deprecatedMessage && <div class="prose prose-sm max-w-none" set:html={marked.parse(deprecatedMessage)} />}
189
195
  </div>
190
196
  </Admonition>
191
197
  )
@@ -109,3 +109,30 @@ export const resourceToCollectionMap = {
109
109
  user: 'users',
110
110
  team: 'teams',
111
111
  } as const;
112
+
113
+ export const getDeprecatedDetails = (item: CollectionEntry<CollectionTypes>) => {
114
+ let options = {
115
+ isMarkedAsDeprecated: false,
116
+ hasDeprecated: false,
117
+ message: '',
118
+ deprecatedDate: '',
119
+ };
120
+
121
+ if (!item.data?.deprecated) return options;
122
+
123
+ if (typeof item.data.deprecated === 'boolean') {
124
+ options.hasDeprecated = item.data.deprecated;
125
+ options.isMarkedAsDeprecated = item.data.deprecated;
126
+ }
127
+
128
+ if (typeof item.data.deprecated === 'object') {
129
+ options.isMarkedAsDeprecated = true;
130
+ options.hasDeprecated = item.data.deprecated.date ? new Date(item.data.deprecated.date) < new Date() : false;
131
+ options.message = item.data.deprecated.message ?? '';
132
+ options.deprecatedDate = item.data.deprecated.date
133
+ ? new Date(item.data.deprecated.date).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })
134
+ : '';
135
+ }
136
+
137
+ return options;
138
+ };
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.9",
9
+ "version": "2.33.11",
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },