@eventcatalog/core 2.55.2 → 2.55.4
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-IDIX2ZKS.js → chunk-DJEUHHVO.js} +1 -1
- package/dist/{chunk-GVFJKTWB.js → chunk-HCICJ77X.js} +1 -1
- package/dist/{chunk-5LLK3UBP.js → chunk-RMB2KQZ5.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/Grids/DomainGrid.tsx +33 -4
- package/eventcatalog/src/components/Grids/ServiceGrid.tsx +54 -6
- package/eventcatalog/src/pages/architecture/architecture.astro +3 -6
- package/eventcatalog/src/utils/collections/util.ts +8 -0
- package/eventcatalog/src/utils/commands.ts +26 -14
- package/eventcatalog/src/utils/events.ts +28 -16
- package/eventcatalog/src/utils/messages.ts +5 -4
- package/eventcatalog/src/utils/queries.ts +28 -16
- 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-RMB2KQZ5.js";
|
|
4
|
+
import "../chunk-DJEUHHVO.js";
|
|
5
|
+
import "../chunk-HCICJ77X.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
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-RMB2KQZ5.js";
|
|
10
|
+
import "./chunk-DJEUHHVO.js";
|
|
11
11
|
import {
|
|
12
12
|
catalogToAstro,
|
|
13
13
|
checkAndConvertMdToMdx
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import "./chunk-55D645EH.js";
|
|
16
16
|
import {
|
|
17
17
|
VERSION
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-HCICJ77X.js";
|
|
19
19
|
import {
|
|
20
20
|
getProjectOutDir,
|
|
21
21
|
isAuthEnabled,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useState, useMemo } from 'react';
|
|
2
|
-
import { ServerIcon, EnvelopeIcon, RectangleGroupIcon } from '@heroicons/react/24/outline';
|
|
1
|
+
import { useState, useMemo, useEffect } from 'react';
|
|
2
|
+
import { ServerIcon, EnvelopeIcon, RectangleGroupIcon, Squares2X2Icon, QueueListIcon } from '@heroicons/react/24/outline';
|
|
3
3
|
import { buildUrlWithParams } from '@utils/url-builder';
|
|
4
4
|
import type { CollectionEntry } from 'astro:content';
|
|
5
5
|
import { type CollectionMessageTypes } from '@types';
|
|
@@ -21,6 +21,24 @@ interface DomainGridProps {
|
|
|
21
21
|
|
|
22
22
|
export default function DomainGrid({ domains, embeded }: DomainGridProps) {
|
|
23
23
|
const [searchQuery, setSearchQuery] = useState('');
|
|
24
|
+
const [isMultiColumn, setIsMultiColumn] = useState(false);
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (typeof window !== 'undefined') {
|
|
28
|
+
const saved = localStorage.getItem('EventCatalog:ArchitectureColumnLayout');
|
|
29
|
+
if (saved !== null) {
|
|
30
|
+
setIsMultiColumn(saved === 'multi');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}, []);
|
|
34
|
+
|
|
35
|
+
const toggleColumnLayout = () => {
|
|
36
|
+
const newValue = !isMultiColumn;
|
|
37
|
+
setIsMultiColumn(newValue);
|
|
38
|
+
if (typeof window !== 'undefined') {
|
|
39
|
+
localStorage.setItem('EventCatalog:ArchitectureColumnLayout', newValue ? 'multi' : 'single');
|
|
40
|
+
}
|
|
41
|
+
};
|
|
24
42
|
|
|
25
43
|
const filteredDomains = useMemo(() => {
|
|
26
44
|
let result = [...domains];
|
|
@@ -63,7 +81,7 @@ export default function DomainGrid({ domains, embeded }: DomainGridProps) {
|
|
|
63
81
|
<p className="mt-2 text-sm text-gray-500">Browse and manage domains in your event-driven architecture</p>
|
|
64
82
|
</div>
|
|
65
83
|
|
|
66
|
-
<div className="mt-6 md:mt-0 md:ml-4 flex-shrink-0">
|
|
84
|
+
<div className="mt-6 md:mt-0 md:ml-4 flex-shrink-0 flex items-center gap-3">
|
|
67
85
|
<SearchBar
|
|
68
86
|
searchQuery={searchQuery}
|
|
69
87
|
onSearchChange={setSearchQuery}
|
|
@@ -71,11 +89,22 @@ export default function DomainGrid({ domains, embeded }: DomainGridProps) {
|
|
|
71
89
|
totalResults={filteredDomains.length}
|
|
72
90
|
totalItems={domains.length}
|
|
73
91
|
/>
|
|
92
|
+
<button
|
|
93
|
+
onClick={toggleColumnLayout}
|
|
94
|
+
className="flex items-center justify-center p-2 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors duration-200"
|
|
95
|
+
title={isMultiColumn ? 'Switch to single column' : 'Switch to multi column'}
|
|
96
|
+
>
|
|
97
|
+
{isMultiColumn ? (
|
|
98
|
+
<QueueListIcon className="h-5 w-5 text-gray-600" />
|
|
99
|
+
) : (
|
|
100
|
+
<Squares2X2Icon className="h-5 w-5 text-gray-600" />
|
|
101
|
+
)}
|
|
102
|
+
</button>
|
|
74
103
|
</div>
|
|
75
104
|
</div>
|
|
76
105
|
</div>
|
|
77
106
|
|
|
78
|
-
<div className=
|
|
107
|
+
<div className={`grid gap-6 ${isMultiColumn ? 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-2 xl:grid-cols-2' : 'grid-cols-1'}`}>
|
|
79
108
|
{filteredDomains.map((domain) => (
|
|
80
109
|
<a
|
|
81
110
|
key={domain.data.id}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, useMemo, useEffect, memo } from 'react';
|
|
2
|
-
import { ServerIcon, ChevronRightIcon } from '@heroicons/react/24/outline';
|
|
2
|
+
import { ServerIcon, ChevronRightIcon, Squares2X2Icon, QueueListIcon } from '@heroicons/react/24/outline';
|
|
3
3
|
import { RectangleGroupIcon } from '@heroicons/react/24/outline';
|
|
4
4
|
import { buildUrl, buildUrlWithParams } from '@utils/url-builder';
|
|
5
5
|
import type { CollectionEntry } from 'astro:content';
|
|
@@ -117,7 +117,19 @@ const ServiceCard = memo(({ service, urlParams, selectedTypes }: { service: any;
|
|
|
117
117
|
|
|
118
118
|
// Domain Section component
|
|
119
119
|
const DomainSection = memo(
|
|
120
|
-
({
|
|
120
|
+
({
|
|
121
|
+
domain,
|
|
122
|
+
services,
|
|
123
|
+
urlParams,
|
|
124
|
+
selectedTypes,
|
|
125
|
+
isMultiColumn,
|
|
126
|
+
}: {
|
|
127
|
+
domain: any;
|
|
128
|
+
services: any[];
|
|
129
|
+
urlParams: any;
|
|
130
|
+
selectedTypes: string[];
|
|
131
|
+
isMultiColumn: boolean;
|
|
132
|
+
}) => {
|
|
121
133
|
const subdomains = domain.data.domains || [];
|
|
122
134
|
const allSubDomainServices = subdomains.map((subdomain: any) => subdomain.data.services || []).flat();
|
|
123
135
|
|
|
@@ -128,7 +140,9 @@ const DomainSection = memo(
|
|
|
128
140
|
return (
|
|
129
141
|
<div className="space-y-6">
|
|
130
142
|
{servicesWithoutSubdomains.length > 0 && (
|
|
131
|
-
<div
|
|
143
|
+
<div
|
|
144
|
+
className={`grid gap-6 ${isMultiColumn ? 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-2 xl:grid-cols-2' : 'grid-cols-1'}`}
|
|
145
|
+
>
|
|
132
146
|
{servicesWithoutSubdomains.map((service) => (
|
|
133
147
|
<ServiceCard key={service.data.id} service={service} urlParams={urlParams} selectedTypes={selectedTypes} />
|
|
134
148
|
))}
|
|
@@ -186,7 +200,9 @@ const DomainSection = memo(
|
|
|
186
200
|
</div>
|
|
187
201
|
)}
|
|
188
202
|
|
|
189
|
-
<div
|
|
203
|
+
<div
|
|
204
|
+
className={`grid gap-6 ${isMultiColumn ? 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-2 xl:grid-cols-2' : 'grid-cols-1'}`}
|
|
205
|
+
>
|
|
190
206
|
{subdomainServices.map((service) => (
|
|
191
207
|
<ServiceCard
|
|
192
208
|
key={service.data.id}
|
|
@@ -219,6 +235,7 @@ export default function ServiceGrid({ services, domains, embeded }: ServiceGridP
|
|
|
219
235
|
const [searchQuery, setSearchQuery] = useState('');
|
|
220
236
|
const [currentPage, setCurrentPage] = useState(1);
|
|
221
237
|
const [selectedTypes, setSelectedTypes] = useState<CollectionMessageTypes[]>([]);
|
|
238
|
+
const [isMultiColumn, setIsMultiColumn] = useState(false);
|
|
222
239
|
const ITEMS_PER_PAGE = 16;
|
|
223
240
|
const [urlParams, setUrlParams] = useState<{
|
|
224
241
|
serviceIds?: string[];
|
|
@@ -237,6 +254,23 @@ export default function ServiceGrid({ services, domains, embeded }: ServiceGridP
|
|
|
237
254
|
});
|
|
238
255
|
}, []);
|
|
239
256
|
|
|
257
|
+
useEffect(() => {
|
|
258
|
+
if (typeof window !== 'undefined') {
|
|
259
|
+
const saved = localStorage.getItem('EventCatalog:ServiceColumnLayout');
|
|
260
|
+
if (saved !== null) {
|
|
261
|
+
setIsMultiColumn(saved === 'multi');
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}, []);
|
|
265
|
+
|
|
266
|
+
const toggleColumnLayout = () => {
|
|
267
|
+
const newValue = !isMultiColumn;
|
|
268
|
+
setIsMultiColumn(newValue);
|
|
269
|
+
if (typeof window !== 'undefined') {
|
|
270
|
+
localStorage.setItem('EventCatalog:ServiceColumnLayout', newValue ? 'multi' : 'single');
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
|
|
240
274
|
const filteredAndSortedServices = useMemo(() => {
|
|
241
275
|
if (urlParams === null) return [];
|
|
242
276
|
|
|
@@ -325,7 +359,7 @@ export default function ServiceGrid({ services, domains, embeded }: ServiceGridP
|
|
|
325
359
|
</p>
|
|
326
360
|
</div>
|
|
327
361
|
|
|
328
|
-
<div className="mt-6 md:mt-0 md:ml-4 flex-shrink-0">
|
|
362
|
+
<div className="mt-6 md:mt-0 md:ml-4 flex-shrink-0 flex items-center gap-3">
|
|
329
363
|
<SearchBar
|
|
330
364
|
searchQuery={searchQuery}
|
|
331
365
|
onSearchChange={setSearchQuery}
|
|
@@ -333,6 +367,17 @@ export default function ServiceGrid({ services, domains, embeded }: ServiceGridP
|
|
|
333
367
|
totalResults={filteredAndSortedServices.length}
|
|
334
368
|
totalItems={services.length}
|
|
335
369
|
/>
|
|
370
|
+
<button
|
|
371
|
+
onClick={toggleColumnLayout}
|
|
372
|
+
className="flex items-center justify-center p-2 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors duration-200"
|
|
373
|
+
title={isMultiColumn ? 'Switch to single column' : 'Switch to multi column'}
|
|
374
|
+
>
|
|
375
|
+
{isMultiColumn ? (
|
|
376
|
+
<QueueListIcon className="h-5 w-5 text-gray-600" />
|
|
377
|
+
) : (
|
|
378
|
+
<Squares2X2Icon className="h-5 w-5 text-gray-600" />
|
|
379
|
+
)}
|
|
380
|
+
</button>
|
|
336
381
|
</div>
|
|
337
382
|
</div>
|
|
338
383
|
</div>
|
|
@@ -383,10 +428,13 @@ export default function ServiceGrid({ services, domains, embeded }: ServiceGridP
|
|
|
383
428
|
services={paginatedServices}
|
|
384
429
|
urlParams={urlParams}
|
|
385
430
|
selectedTypes={selectedTypes}
|
|
431
|
+
isMultiColumn={isMultiColumn}
|
|
386
432
|
/>
|
|
387
433
|
))
|
|
388
434
|
) : (
|
|
389
|
-
<div
|
|
435
|
+
<div
|
|
436
|
+
className={`grid gap-6 ${isMultiColumn ? 'grid-cols-1 sm:grid-cols-2 lg:grid-cols-2 xl:grid-cols-2' : 'grid-cols-1'}`}
|
|
437
|
+
>
|
|
390
438
|
{paginatedServices.map((service) => (
|
|
391
439
|
<ServiceCard key={service.data.id} service={service} urlParams={urlParams} selectedTypes={selectedTypes} />
|
|
392
440
|
))}
|
|
@@ -7,6 +7,7 @@ import VerticalSideBarLayout from '@layouts/VerticalSideBarLayout.astro';
|
|
|
7
7
|
import DomainGrid from '@components/Grids/DomainGrid';
|
|
8
8
|
import ServiceGrid from '@components/Grids/ServiceGrid';
|
|
9
9
|
import MessageGrid from '@components/Grids/MessageGrid';
|
|
10
|
+
import { removeContentFromCollection } from '@utils/collections/util';
|
|
10
11
|
|
|
11
12
|
import type { CollectionEntry } from 'astro:content';
|
|
12
13
|
import type { CollectionMessageTypes } from '@types';
|
|
@@ -64,13 +65,9 @@ if (type === 'services') {
|
|
|
64
65
|
}) as unknown as Service[];
|
|
65
66
|
items = filteredServices;
|
|
66
67
|
} else if (type === 'messages') {
|
|
67
|
-
const { events, commands, queries } = await getMessages({ getAllVersions: false });
|
|
68
|
+
const { events, commands, queries } = await getMessages({ getAllVersions: false, hydrateServices: false });
|
|
68
69
|
const messages = [...events, ...commands, ...queries];
|
|
69
|
-
items = messages
|
|
70
|
-
...m,
|
|
71
|
-
body: undefined,
|
|
72
|
-
catalog: undefined,
|
|
73
|
-
})) as unknown as CollectionEntry<CollectionMessageTypes>[];
|
|
70
|
+
items = removeContentFromCollection(messages) as unknown as CollectionEntry<CollectionMessageTypes>[];
|
|
74
71
|
}
|
|
75
72
|
---
|
|
76
73
|
|
|
@@ -148,3 +148,11 @@ export const getDeprecatedDetails = (item: CollectionEntry<CollectionTypes>) =>
|
|
|
148
148
|
|
|
149
149
|
return options;
|
|
150
150
|
};
|
|
151
|
+
|
|
152
|
+
export const removeContentFromCollection = (collection: CollectionEntry<CollectionTypes>[]) => {
|
|
153
|
+
return collection.map((item) => ({
|
|
154
|
+
...item,
|
|
155
|
+
body: undefined,
|
|
156
|
+
catalog: undefined,
|
|
157
|
+
}));
|
|
158
|
+
};
|
|
@@ -15,6 +15,7 @@ type Command = CollectionEntry<'commands'> & {
|
|
|
15
15
|
|
|
16
16
|
interface Props {
|
|
17
17
|
getAllVersions?: boolean;
|
|
18
|
+
hydrateServices?: boolean;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
// cache for build time
|
|
@@ -23,10 +24,10 @@ let cachedCommands: Record<string, Command[]> = {
|
|
|
23
24
|
currentVersions: [],
|
|
24
25
|
};
|
|
25
26
|
|
|
26
|
-
export const getCommands = async ({ getAllVersions = true }: Props = {}): Promise<Command[]> => {
|
|
27
|
+
export const getCommands = async ({ getAllVersions = true, hydrateServices = true }: Props = {}): Promise<Command[]> => {
|
|
27
28
|
const cacheKey = getAllVersions ? 'allVersions' : 'currentVersions';
|
|
28
29
|
|
|
29
|
-
if (cachedCommands[cacheKey].length > 0) {
|
|
30
|
+
if (cachedCommands[cacheKey].length > 0 && hydrateServices) {
|
|
30
31
|
return cachedCommands[cacheKey];
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -37,24 +38,35 @@ export const getCommands = async ({ getAllVersions = true }: Props = {}): Promis
|
|
|
37
38
|
const services = await getCollection('services');
|
|
38
39
|
const allChannels = await getCollection('channels');
|
|
39
40
|
|
|
41
|
+
// @ts-ignore
|
|
40
42
|
cachedCommands[cacheKey] = commands.map((command) => {
|
|
41
43
|
const { latestVersion, versions } = getVersionForCollectionItem(command, commands);
|
|
42
44
|
|
|
43
|
-
const producers = services
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
const producers = services
|
|
46
|
+
.filter((service) => {
|
|
47
|
+
return service.data.sends?.some((item) => {
|
|
48
|
+
if (item.id != command.data.id) return false;
|
|
49
|
+
if (item.version == 'latest' || item.version == undefined) return command.data.version == latestVersion;
|
|
50
|
+
return satisfies(command.data.version, item.version);
|
|
51
|
+
});
|
|
52
|
+
})
|
|
53
|
+
.map((service) => {
|
|
54
|
+
if (!hydrateServices) return { id: service.id, version: service.data.version };
|
|
55
|
+
return service;
|
|
48
56
|
});
|
|
49
|
-
});
|
|
50
57
|
|
|
51
|
-
const consumers = services
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
const consumers = services
|
|
59
|
+
.filter((service) => {
|
|
60
|
+
return service.data.receives?.some((item) => {
|
|
61
|
+
if (item.id != command.data.id) return false;
|
|
62
|
+
if (item.version == 'latest' || item.version == undefined) return command.data.version == latestVersion;
|
|
63
|
+
return satisfies(command.data.version, item.version);
|
|
64
|
+
});
|
|
65
|
+
})
|
|
66
|
+
.map((service) => {
|
|
67
|
+
if (!hydrateServices) return { id: service.id, version: service.data.version };
|
|
68
|
+
return service;
|
|
56
69
|
});
|
|
57
|
-
});
|
|
58
70
|
|
|
59
71
|
const messageChannels = command.data.channels || [];
|
|
60
72
|
const channelsForCommand = allChannels.filter((c) => messageChannels.some((channel) => c.data.id === channel.id));
|
|
@@ -15,6 +15,7 @@ type Event = CollectionEntry<'events'> & {
|
|
|
15
15
|
|
|
16
16
|
interface Props {
|
|
17
17
|
getAllVersions?: boolean;
|
|
18
|
+
hydrateServices?: boolean;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
// cache for build time
|
|
@@ -23,10 +24,10 @@ let cachedEvents: Record<string, Event[]> = {
|
|
|
23
24
|
currentVersions: [],
|
|
24
25
|
};
|
|
25
26
|
|
|
26
|
-
export const getEvents = async ({ getAllVersions = true }: Props = {}): Promise<Event[]> => {
|
|
27
|
+
export const getEvents = async ({ getAllVersions = true, hydrateServices = true }: Props = {}): Promise<Event[]> => {
|
|
27
28
|
const cacheKey = getAllVersions ? 'allVersions' : 'currentVersions';
|
|
28
29
|
|
|
29
|
-
if (cachedEvents[cacheKey].length > 0) {
|
|
30
|
+
if (cachedEvents[cacheKey].length > 0 && hydrateServices) {
|
|
30
31
|
return cachedEvents[cacheKey];
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -37,24 +38,35 @@ export const getEvents = async ({ getAllVersions = true }: Props = {}): Promise<
|
|
|
37
38
|
const services = await getCollection('services');
|
|
38
39
|
const allChannels = await getCollection('channels');
|
|
39
40
|
|
|
41
|
+
// @ts-ignore
|
|
40
42
|
cachedEvents[cacheKey] = events.map((event) => {
|
|
41
43
|
const { latestVersion, versions } = getVersionForCollectionItem(event, events);
|
|
42
44
|
|
|
43
|
-
const producers = services
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
const producers = services
|
|
46
|
+
.filter((service) =>
|
|
47
|
+
service.data.sends?.some((item) => {
|
|
48
|
+
if (item.id != event.data.id) return false;
|
|
49
|
+
if (item.version == 'latest' || item.version == undefined) return event.data.version == latestVersion;
|
|
50
|
+
return satisfies(event.data.version, item.version);
|
|
51
|
+
})
|
|
52
|
+
)
|
|
53
|
+
.map((service) => {
|
|
54
|
+
if (!hydrateServices) return { id: service.id, version: service.data.version };
|
|
55
|
+
return service;
|
|
56
|
+
});
|
|
50
57
|
|
|
51
|
-
const consumers = services
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
const consumers = services
|
|
59
|
+
.filter((service) =>
|
|
60
|
+
service.data.receives?.some((item) => {
|
|
61
|
+
if (item.id != event.data.id) return false;
|
|
62
|
+
if (item.version == 'latest' || item.version == undefined) return event.data.version == latestVersion;
|
|
63
|
+
return satisfies(event.data.version, item.version);
|
|
64
|
+
})
|
|
65
|
+
)
|
|
66
|
+
.map((service) => {
|
|
67
|
+
if (!hydrateServices) return { id: service.id, version: service.data.version };
|
|
68
|
+
return service;
|
|
69
|
+
});
|
|
58
70
|
|
|
59
71
|
const messageChannels = event.data.channels || [];
|
|
60
72
|
const channelsForEvent = allChannels.filter((c) => messageChannels.some((channel) => c.data.id === channel.id));
|
|
@@ -8,6 +8,7 @@ export { getEvents } from '@utils/events';
|
|
|
8
8
|
|
|
9
9
|
interface Props {
|
|
10
10
|
getAllVersions?: boolean;
|
|
11
|
+
hydrateServices?: boolean;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
type Messages = {
|
|
@@ -17,11 +18,11 @@ type Messages = {
|
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
// Main function that uses the imported functions
|
|
20
|
-
export const getMessages = async ({ getAllVersions = true }: Props = {}): Promise<Messages> => {
|
|
21
|
+
export const getMessages = async ({ getAllVersions = true, hydrateServices = true }: Props = {}): Promise<Messages> => {
|
|
21
22
|
const [commands, events, queries] = await Promise.all([
|
|
22
|
-
getCommands({ getAllVersions }),
|
|
23
|
-
getEvents({ getAllVersions }),
|
|
24
|
-
getQueries({ getAllVersions }),
|
|
23
|
+
getCommands({ getAllVersions, hydrateServices }),
|
|
24
|
+
getEvents({ getAllVersions, hydrateServices }),
|
|
25
|
+
getQueries({ getAllVersions, hydrateServices }),
|
|
25
26
|
]);
|
|
26
27
|
|
|
27
28
|
return {
|
|
@@ -15,6 +15,7 @@ type Query = CollectionEntry<'queries'> & {
|
|
|
15
15
|
|
|
16
16
|
interface Props {
|
|
17
17
|
getAllVersions?: boolean;
|
|
18
|
+
hydrateServices?: boolean;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
// Cache for build time
|
|
@@ -23,10 +24,10 @@ let cachedQueries: Record<string, Query[]> = {
|
|
|
23
24
|
currentVersions: [],
|
|
24
25
|
};
|
|
25
26
|
|
|
26
|
-
export const getQueries = async ({ getAllVersions = true }: Props = {}): Promise<Query[]> => {
|
|
27
|
+
export const getQueries = async ({ getAllVersions = true, hydrateServices = true }: Props = {}): Promise<Query[]> => {
|
|
27
28
|
const cacheKey = getAllVersions ? 'allVersions' : 'currentVersions';
|
|
28
29
|
|
|
29
|
-
if (cachedQueries[cacheKey].length > 0) {
|
|
30
|
+
if (cachedQueries[cacheKey].length > 0 && hydrateServices) {
|
|
30
31
|
return cachedQueries[cacheKey];
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -37,24 +38,35 @@ export const getQueries = async ({ getAllVersions = true }: Props = {}): Promise
|
|
|
37
38
|
const services = await getCollection('services');
|
|
38
39
|
const allChannels = await getCollection('channels');
|
|
39
40
|
|
|
41
|
+
// @ts-ignore
|
|
40
42
|
cachedQueries[cacheKey] = queries.map((query) => {
|
|
41
43
|
const { latestVersion, versions } = getVersionForCollectionItem(query, queries);
|
|
42
44
|
|
|
43
|
-
const producers = services
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
const producers = services
|
|
46
|
+
.filter((service) =>
|
|
47
|
+
service.data.sends?.some((item) => {
|
|
48
|
+
if (item.id != query.data.id) return false;
|
|
49
|
+
if (item.version == 'latest' || item.version == undefined) return query.data.version == latestVersion;
|
|
50
|
+
return satisfies(query.data.version, item.version);
|
|
51
|
+
})
|
|
52
|
+
)
|
|
53
|
+
.map((service) => {
|
|
54
|
+
if (!hydrateServices) return { id: service.id, version: service.data.version };
|
|
55
|
+
return service;
|
|
56
|
+
});
|
|
50
57
|
|
|
51
|
-
const consumers = services
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
const consumers = services
|
|
59
|
+
.filter((service) =>
|
|
60
|
+
service.data.receives?.some((item) => {
|
|
61
|
+
if (item.id != query.data.id) return false;
|
|
62
|
+
if (item.version == 'latest' || item.version == undefined) return query.data.version == latestVersion;
|
|
63
|
+
return satisfies(query.data.version, item.version);
|
|
64
|
+
})
|
|
65
|
+
)
|
|
66
|
+
.map((service) => {
|
|
67
|
+
if (!hydrateServices) return { id: service.id, version: service.data.version };
|
|
68
|
+
return service;
|
|
69
|
+
});
|
|
58
70
|
|
|
59
71
|
const messageChannels = query.data.channels || [];
|
|
60
72
|
const channelsForQuery = allChannels.filter((c) => messageChannels.some((channel) => c.data.id === channel.id));
|