@eventcatalog/core 2.65.1 → 3.0.0-beta.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.
Files changed (131) hide show
  1. package/README.md +1 -1
  2. package/dist/analytics/analytics.cjs +1 -1
  3. package/dist/analytics/analytics.js +2 -2
  4. package/dist/analytics/log-build.cjs +1 -1
  5. package/dist/analytics/log-build.js +3 -3
  6. package/dist/{chunk-BTS6L3KY.js → chunk-FH5AN4Z6.js} +1 -1
  7. package/dist/{chunk-XB4SZX3I.js → chunk-KE2IUVK6.js} +1 -1
  8. package/dist/{chunk-2TTD2MLE.js → chunk-M6QG3NPM.js} +1 -1
  9. package/dist/constants.cjs +1 -1
  10. package/dist/constants.js +1 -1
  11. package/dist/eventcatalog.cjs +1 -21
  12. package/dist/eventcatalog.config.d.cts +9 -0
  13. package/dist/eventcatalog.config.d.ts +9 -0
  14. package/dist/eventcatalog.js +3 -20
  15. package/eventcatalog/src/components/CopyAsMarkdown.tsx +19 -1
  16. package/eventcatalog/src/components/FavoriteButton.tsx +54 -0
  17. package/eventcatalog/src/components/Grids/DomainGrid.tsx +386 -362
  18. package/eventcatalog/src/components/Grids/MessageGrid.tsx +166 -523
  19. package/eventcatalog/src/components/Header.astro +44 -25
  20. package/eventcatalog/src/components/Lists/VersionList.astro +2 -2
  21. package/eventcatalog/src/components/SchemaExplorer/SchemaDetailsPanel.tsx +8 -2
  22. package/eventcatalog/src/components/SchemaExplorer/SchemaExplorer.tsx +0 -10
  23. package/eventcatalog/src/components/SchemaExplorer/SchemaPageViewer.tsx +37 -0
  24. package/eventcatalog/src/components/Search/Search.astro +50 -30
  25. package/eventcatalog/src/components/Search/SearchModal.tsx +393 -702
  26. package/eventcatalog/src/components/SideNav/NestedSideBar/SearchBar.tsx +298 -0
  27. package/eventcatalog/src/components/SideNav/NestedSideBar/builders/container.ts +66 -0
  28. package/eventcatalog/src/components/SideNav/NestedSideBar/builders/domain.ts +101 -0
  29. package/eventcatalog/src/components/SideNav/NestedSideBar/builders/flow.ts +29 -0
  30. package/eventcatalog/src/components/SideNav/NestedSideBar/builders/message.ts +84 -0
  31. package/eventcatalog/src/components/SideNav/NestedSideBar/builders/service.ts +147 -0
  32. package/eventcatalog/src/components/SideNav/NestedSideBar/builders/shared.ts +146 -0
  33. package/eventcatalog/src/components/SideNav/NestedSideBar/index.tsx +1087 -0
  34. package/eventcatalog/src/components/SideNav/NestedSideBar/sidebar-builder.ts +365 -0
  35. package/eventcatalog/src/components/SideNav/NestedSideBar/storage.ts +90 -0
  36. package/eventcatalog/src/components/SideNav/SideNav.astro +18 -28
  37. package/eventcatalog/src/content.config.ts +2 -0
  38. package/eventcatalog/src/enterprise/custom-documentation/pages/docs/custom/index.astro +1 -1
  39. package/eventcatalog/src/enterprise/eventcatalog-chat/pages/chat/index.astro +4 -4
  40. package/eventcatalog/src/layouts/DirectoryLayout.astro +3 -3
  41. package/eventcatalog/src/layouts/DiscoverLayout.astro +4 -4
  42. package/eventcatalog/src/layouts/VerticalSideBarLayout.astro +79 -173
  43. package/eventcatalog/src/layouts/VisualiserLayout.astro +3 -3
  44. package/eventcatalog/src/pages/_index.astro +530 -110
  45. package/eventcatalog/src/pages/architecture/[type]/[id]/[version]/_index.data.ts +64 -0
  46. package/eventcatalog/src/pages/architecture/[type]/[id]/[version]/index.astro +29 -0
  47. package/eventcatalog/src/pages/chat/feature.astro +1 -1
  48. package/eventcatalog/src/pages/directory/[type]/_index.data.ts +4 -4
  49. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/_index.data.ts +1 -4
  50. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/changelog/_index.data.ts +3 -3
  51. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/changelog/index.astro +1 -5
  52. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/index.astro +354 -186
  53. package/eventcatalog/src/pages/docs/[type]/[id]/[version].md.ts +1 -1
  54. package/eventcatalog/src/pages/docs/[type]/[id]/index.astro +4 -4
  55. package/eventcatalog/src/pages/docs/[type]/[id]/language/_index.data.ts +1 -4
  56. package/eventcatalog/src/pages/docs/[type]/[id]/language/index.astro +3 -27
  57. package/eventcatalog/src/pages/docs/custom/feature.astro +1 -1
  58. package/eventcatalog/src/pages/docs/custom/index.astro +1 -1
  59. package/eventcatalog/src/pages/docs/teams/[id]/_index.data.ts +2 -2
  60. package/eventcatalog/src/pages/docs/users/[id]/_index.data.ts +2 -2
  61. package/eventcatalog/src/pages/nav-index.json.ts +30 -0
  62. package/eventcatalog/src/pages/plans/index.astro +1 -1
  63. package/eventcatalog/src/pages/schemas/[type]/[id]/[version]/_index.data.ts +77 -0
  64. package/eventcatalog/src/pages/schemas/[type]/[id]/[version]/index.astro +90 -0
  65. package/eventcatalog/src/pages/schemas/{index.astro → explorer/index.astro} +4 -4
  66. package/eventcatalog/src/pages/studio.astro +4 -4
  67. package/eventcatalog/src/pages/unauthorized/index.astro +1 -1
  68. package/eventcatalog/src/pages/visualiser/[type]/[id]/index.astro +2 -2
  69. package/eventcatalog/src/stores/favorites-store.ts +83 -0
  70. package/eventcatalog/src/stores/sidebar-store.ts +8 -0
  71. package/eventcatalog/src/utils/collections/changelogs.ts +7 -4
  72. package/eventcatalog/src/utils/{channels.ts → collections/channels.ts} +81 -31
  73. package/eventcatalog/src/utils/collections/commands.ts +134 -0
  74. package/eventcatalog/src/utils/collections/containers.ts +44 -33
  75. package/eventcatalog/src/utils/collections/domains.ts +205 -63
  76. package/eventcatalog/src/utils/{entities.ts → collections/entities.ts} +44 -24
  77. package/eventcatalog/src/utils/collections/events.ts +136 -0
  78. package/eventcatalog/src/utils/collections/flows.ts +59 -25
  79. package/eventcatalog/src/utils/{messages.ts → collections/messages.ts} +13 -4
  80. package/eventcatalog/src/utils/{queries.ts → collections/queries.ts} +49 -28
  81. package/eventcatalog/src/utils/collections/services.ts +100 -68
  82. package/eventcatalog/src/utils/collections/teams.ts +94 -0
  83. package/eventcatalog/src/utils/collections/types.ts +6 -0
  84. package/eventcatalog/src/utils/collections/users.ts +122 -0
  85. package/eventcatalog/src/utils/collections/util.ts +57 -1
  86. package/eventcatalog/src/utils/feature.ts +4 -2
  87. package/eventcatalog/src/utils/{collections/file-diffs.ts → file-diffs.ts} +1 -1
  88. package/eventcatalog/src/utils/node-graphs/container-node-graph.ts +2 -0
  89. package/eventcatalog/src/utils/node-graphs/domain-entity-map.ts +16 -6
  90. package/eventcatalog/src/utils/node-graphs/domains-canvas.ts +14 -10
  91. package/eventcatalog/src/utils/node-graphs/domains-node-graph.ts +36 -64
  92. package/eventcatalog/src/utils/node-graphs/flows-node-graph.ts +23 -19
  93. package/eventcatalog/src/utils/node-graphs/message-node-graph.ts +36 -49
  94. package/eventcatalog/src/utils/node-graphs/services-node-graph.ts +22 -18
  95. package/eventcatalog/src/utils/page-loaders/page-data-loader.ts +4 -4
  96. package/eventcatalog/tailwind.config.mjs +14 -0
  97. package/eventcatalog/tsconfig.json +4 -2
  98. package/package.json +7 -4
  99. package/eventcatalog/public/logo_old.png +0 -0
  100. package/eventcatalog/src/components/DiscoverInsight.astro +0 -61
  101. package/eventcatalog/src/components/Grids/ServiceGrid.tsx +0 -540
  102. package/eventcatalog/src/components/Lists/CustomSideBarSectionList.astro +0 -55
  103. package/eventcatalog/src/components/Lists/ProtocolList.tsx +0 -74
  104. package/eventcatalog/src/components/Lists/RepositoryList.astro +0 -37
  105. package/eventcatalog/src/components/Lists/SpecificationsList.astro +0 -67
  106. package/eventcatalog/src/components/SideBars/ChannelSideBar.astro +0 -204
  107. package/eventcatalog/src/components/SideBars/ContainerSideBar.astro +0 -183
  108. package/eventcatalog/src/components/SideBars/DomainSideBar.astro +0 -277
  109. package/eventcatalog/src/components/SideBars/EntitySideBar.astro +0 -139
  110. package/eventcatalog/src/components/SideBars/FlowSideBar.astro +0 -132
  111. package/eventcatalog/src/components/SideBars/MessageSideBar.astro +0 -251
  112. package/eventcatalog/src/components/SideBars/ServiceSideBar.astro +0 -298
  113. package/eventcatalog/src/components/SideNav/ListViewSideBar/components/CollapsibleGroup.tsx +0 -46
  114. package/eventcatalog/src/components/SideNav/ListViewSideBar/components/MessageList.tsx +0 -78
  115. package/eventcatalog/src/components/SideNav/ListViewSideBar/components/SpecificationList.tsx +0 -83
  116. package/eventcatalog/src/components/SideNav/ListViewSideBar/index.tsx +0 -1250
  117. package/eventcatalog/src/components/SideNav/ListViewSideBar/types.ts +0 -91
  118. package/eventcatalog/src/components/SideNav/ListViewSideBar/utils.ts +0 -201
  119. package/eventcatalog/src/components/SideNav/TreeView/getTreeView.ts +0 -190
  120. package/eventcatalog/src/components/SideNav/TreeView/index.tsx +0 -94
  121. package/eventcatalog/src/components/TreeView/index.tsx +0 -328
  122. package/eventcatalog/src/components/TreeView/styles.module.css +0 -264
  123. package/eventcatalog/src/components/TreeView/useSlots.ts +0 -95
  124. package/eventcatalog/src/pages/architecture/[type]/index.astro +0 -14
  125. package/eventcatalog/src/pages/architecture/architecture.astro +0 -110
  126. package/eventcatalog/src/pages/architecture/docs/[type]/index.astro +0 -14
  127. package/eventcatalog/src/utils/commands.ts +0 -112
  128. package/eventcatalog/src/utils/events.ts +0 -108
  129. package/eventcatalog/src/utils/generators/index.ts +0 -10
  130. package/eventcatalog/src/utils/teams.ts +0 -72
  131. package/eventcatalog/src/utils/users.ts +0 -72
@@ -1,110 +0,0 @@
1
- ---
2
- import { getDomains, getMessagesForDomain } from '@utils/collections/domains';
3
- import { getServices } from '@utils/collections/services';
4
- import { getContainers } from '@utils/collections/containers';
5
- import { getMessages } from '@utils/messages';
6
- import type { ExtendedDomain } from '@components/Grids/DomainGrid';
7
- import VerticalSideBarLayout from '@layouts/VerticalSideBarLayout.astro';
8
- import DomainGrid from '@components/Grids/DomainGrid';
9
- import ServiceGrid from '@components/Grids/ServiceGrid';
10
- import MessageGrid from '@components/Grids/MessageGrid';
11
- import { removeContentFromCollection } from '@utils/collections/util';
12
-
13
- import type { CollectionEntry } from 'astro:content';
14
- import type { CollectionMessageTypes } from '@types';
15
-
16
- import { isVisualiserEnabled } from '@utils/feature';
17
-
18
- import { ClientRouter, fade } from 'astro:transitions';
19
- // Define valid types and their corresponding data fetchers
20
- const VALID_TYPES = ['domains', 'services', 'messages'] as const;
21
- type ValidType = (typeof VALID_TYPES)[number];
22
-
23
- interface Service extends CollectionEntry<'services'> {
24
- sends: CollectionEntry<'events' | 'commands' | 'queries'>[];
25
- receives: CollectionEntry<'events' | 'commands' | 'queries'>[];
26
- }
27
-
28
- const { type, embeded = false } = Astro.props as { type: ValidType; embeded: boolean };
29
-
30
- // Get data based on type
31
- let items: Service[] | CollectionEntry<'commands'>[] | CollectionEntry<CollectionMessageTypes>[] = [];
32
- let domains: ExtendedDomain[] = [];
33
- let containers: CollectionEntry<'containers'>[] = [];
34
-
35
- const getDomainsForArchitecturePages = async () => {
36
- const domains = await getDomains({ getAllVersions: false });
37
-
38
- // Get messages for each domain
39
- return Promise.all(
40
- domains.map(async (domain) => {
41
- const messages = await getMessagesForDomain(domain);
42
- // @ts-ignore we have to remove markdown information, as it's all send to the astro components. This reduced the page size.
43
- return {
44
- ...domain,
45
- sends: messages.sends.map((s) => ({ ...s, body: undefined, catalog: undefined })),
46
- receives: messages.receives.map((r) => ({ ...r, body: undefined, catalog: undefined })),
47
- catalog: undefined,
48
- body: undefined,
49
- } as ExtendedDomain;
50
- })
51
- );
52
- };
53
-
54
- if (type === 'domains' || type === 'services') {
55
- domains = await getDomainsForArchitecturePages();
56
- }
57
-
58
- if (type === 'services') {
59
- const services = await getServices({ getAllVersions: false });
60
- let filteredServices = services.map((s) => {
61
- // @ts-ignore we have to remove markdown information, as it's all send to the astro components. This reduced the page size.
62
- return {
63
- ...s,
64
- sends: (s.data.sends || []).map((s) => ({ ...s, body: undefined, catalog: undefined })),
65
- receives: (s.data.receives || []).map((r) => ({ ...r, body: undefined, catalog: undefined })),
66
- catalog: undefined,
67
- body: undefined,
68
- } as Service;
69
- }) as unknown as Service[];
70
- items = filteredServices;
71
- } else if (type === 'messages') {
72
- const { events, commands, queries } = await getMessages({ getAllVersions: false, hydrateServices: false });
73
- const messages = [...events, ...commands, ...queries];
74
- items = removeContentFromCollection(messages) as unknown as CollectionEntry<CollectionMessageTypes>[];
75
- containers = await getContainers({ getAllVersions: false });
76
- }
77
- ---
78
-
79
- <VerticalSideBarLayout title={'EventCatalog'}>
80
- <div class="bg-white min-h-screen">
81
- <div class="max-w-[90em] mx-auto">
82
- <div class="px-6 py-6" transition:animate={fade({ duration: '0.4s' })}>
83
- {type === 'domains' && <DomainGrid domains={domains} embeded={embeded} client:load />}
84
- {
85
- type === 'services' && (
86
- <ServiceGrid
87
- domains={domains}
88
- services={items as unknown as Service[]}
89
- embeded={embeded}
90
- isVisualiserEnabled={isVisualiserEnabled()}
91
- client:load
92
- />
93
- )
94
- }
95
- {
96
- type === 'messages' && (
97
- <MessageGrid
98
- messages={items as CollectionEntry<CollectionMessageTypes>[]}
99
- embeded={embeded}
100
- containers={containers}
101
- isVisualiserEnabled={isVisualiserEnabled()}
102
- client:load
103
- />
104
- )
105
- }
106
- </div>
107
- </div>
108
- <ClientRouter />
109
- </div>
110
- </VerticalSideBarLayout>
@@ -1,14 +0,0 @@
1
- ---
2
- import Architecture from '../../architecture.astro';
3
-
4
- export async function getStaticPaths() {
5
- const VALID_TYPES = ['domains', 'services', 'messages'] as const;
6
- return VALID_TYPES.map((type) => ({
7
- params: { type },
8
- }));
9
- }
10
-
11
- const { type } = Astro.params;
12
- ---
13
-
14
- <Architecture type={type} embeded={true} />
@@ -1,112 +0,0 @@
1
- import { getCollection } from 'astro:content';
2
- import type { CollectionEntry } from 'astro:content';
3
- import path from 'path';
4
- import { getVersionForCollectionItem, satisfies } from './collections/util';
5
- import utils from '@eventcatalog/sdk';
6
-
7
- const PROJECT_DIR = process.env.PROJECT_DIR || process.cwd();
8
-
9
- type Command = CollectionEntry<'commands'> & {
10
- catalog: {
11
- path: string;
12
- filePath: string;
13
- type: string;
14
- };
15
- };
16
-
17
- interface Props {
18
- getAllVersions?: boolean;
19
- hydrateServices?: boolean;
20
- }
21
-
22
- // cache for build time
23
- let cachedCommands: Record<string, Command[]> = {
24
- allVersions: [],
25
- currentVersions: [],
26
- };
27
-
28
- export const getCommands = async ({ getAllVersions = true, hydrateServices = true }: Props = {}): Promise<Command[]> => {
29
- const cacheKey = getAllVersions ? 'allVersions' : 'currentVersions';
30
-
31
- if (cachedCommands[cacheKey].length > 0 && hydrateServices) {
32
- return cachedCommands[cacheKey];
33
- }
34
-
35
- const commands = await getCollection('commands', (command) => {
36
- return (getAllVersions || !command.filePath?.includes('versioned')) && command.data.hidden !== true;
37
- });
38
-
39
- const services = await getCollection('services');
40
- const allChannels = await getCollection('channels');
41
-
42
- // @ts-ignore
43
- cachedCommands[cacheKey] = await Promise.all(
44
- commands.map(async (command) => {
45
- const { latestVersion, versions } = getVersionForCollectionItem(command, commands);
46
-
47
- const producers = services
48
- .filter((service) => {
49
- return service.data.sends?.some((item) => {
50
- if (item.id != command.data.id) return false;
51
- if (item.version == 'latest' || item.version == undefined) return command.data.version == latestVersion;
52
- return satisfies(command.data.version, item.version);
53
- });
54
- })
55
- .map((service) => {
56
- if (!hydrateServices) return { id: service.data.id, version: service.data.version };
57
- return service;
58
- });
59
-
60
- const consumers = services
61
- .filter((service) => {
62
- return service.data.receives?.some((item) => {
63
- if (item.id != command.data.id) return false;
64
- if (item.version == 'latest' || item.version == undefined) return command.data.version == latestVersion;
65
- return satisfies(command.data.version, item.version);
66
- });
67
- })
68
- .map((service) => {
69
- if (!hydrateServices) return { id: service.data.id, version: service.data.version };
70
- return service;
71
- });
72
-
73
- const messageChannels = command.data.channels || [];
74
- const channelsForCommand = allChannels.filter((c) => messageChannels.some((channel) => c.data.id === channel.id));
75
-
76
- const { getResourceFolderName } = utils(process.env.PROJECT_DIR ?? '');
77
- const folderName = await getResourceFolderName(
78
- process.env.PROJECT_DIR ?? '',
79
- command.data.id,
80
- command.data.version.toString()
81
- );
82
- const commandFolderName = folderName ?? command.id.replace(`-${command.data.version}`, '');
83
-
84
- return {
85
- ...command,
86
- data: {
87
- ...command.data,
88
- messageChannels: channelsForCommand,
89
- producers,
90
- consumers,
91
- versions,
92
- latestVersion,
93
- },
94
- catalog: {
95
- path: path.join(command.collection, command.id.replace('/index.mdx', '')),
96
- absoluteFilePath: path.join(PROJECT_DIR, command.collection, command.id.replace('/index.mdx', '/index.md')),
97
- astroContentFilePath: path.join(process.cwd(), 'src', 'content', command.collection, command.id),
98
- filePath: path.join(process.cwd(), 'src', 'catalog-files', command.collection, command.id.replace('/index.mdx', '')),
99
- publicPath: path.join('/generated', command.collection, commandFolderName),
100
- type: 'command',
101
- },
102
- };
103
- })
104
- );
105
-
106
- // order them by the name of the command
107
- cachedCommands[cacheKey].sort((a, b) => {
108
- return (a.data.name || a.data.id).localeCompare(b.data.name || b.data.id);
109
- });
110
-
111
- return cachedCommands[cacheKey];
112
- };
@@ -1,108 +0,0 @@
1
- import { getCollection } from 'astro:content';
2
- import type { CollectionEntry } from 'astro:content';
3
- import path from 'path';
4
- import { getVersionForCollectionItem, satisfies } from './collections/util';
5
- import utils from '@eventcatalog/sdk';
6
-
7
- const PROJECT_DIR = process.env.PROJECT_DIR || process.cwd();
8
-
9
- type Event = CollectionEntry<'events'> & {
10
- catalog: {
11
- path: string;
12
- filePath: string;
13
- type: string;
14
- };
15
- };
16
-
17
- interface Props {
18
- getAllVersions?: boolean;
19
- hydrateServices?: boolean;
20
- }
21
-
22
- // cache for build time
23
- let cachedEvents: Record<string, Event[]> = {
24
- allVersions: [],
25
- currentVersions: [],
26
- };
27
-
28
- export const getEvents = async ({ getAllVersions = true, hydrateServices = true }: Props = {}): Promise<Event[]> => {
29
- const cacheKey = getAllVersions ? 'allVersions' : 'currentVersions';
30
-
31
- if (cachedEvents[cacheKey].length > 0 && hydrateServices) {
32
- return cachedEvents[cacheKey];
33
- }
34
-
35
- const events = await getCollection('events', (event) => {
36
- return (getAllVersions || !event.filePath?.includes('versioned')) && event.data.hidden !== true;
37
- });
38
-
39
- const services = await getCollection('services');
40
- const allChannels = await getCollection('channels');
41
-
42
- // @ts-ignore
43
- cachedEvents[cacheKey] = await Promise.all(
44
- events.map(async (event) => {
45
- const { latestVersion, versions } = getVersionForCollectionItem(event, events);
46
-
47
- const producers = services
48
- .filter((service) =>
49
- service.data.sends?.some((item) => {
50
- if (item.id != event.data.id) return false;
51
- if (item.version == 'latest' || item.version == undefined) return event.data.version == latestVersion;
52
- return satisfies(event.data.version, item.version);
53
- })
54
- )
55
- .map((service) => {
56
- if (!hydrateServices) return { id: service.data.id, version: service.data.version };
57
- return service;
58
- });
59
-
60
- const consumers = services
61
- .filter((service) =>
62
- service.data.receives?.some((item) => {
63
- if (item.id != event.data.id) return false;
64
- if (item.version == 'latest' || item.version == undefined) return event.data.version == latestVersion;
65
- return satisfies(event.data.version, item.version);
66
- })
67
- )
68
- .map((service) => {
69
- if (!hydrateServices) return { id: service.data.id, version: service.data.version };
70
- return service;
71
- });
72
-
73
- const messageChannels = event.data.channels || [];
74
- const channelsForEvent = allChannels.filter((c) => messageChannels.some((channel) => c.data.id === channel.id));
75
-
76
- const { getResourceFolderName } = utils(process.env.PROJECT_DIR ?? '');
77
- const folderName = await getResourceFolderName(process.env.PROJECT_DIR ?? '', event.data.id, event.data.version.toString());
78
- const eventFolderName = folderName ?? event.id.replace(`-${event.data.version}`, '');
79
-
80
- return {
81
- ...event,
82
- data: {
83
- ...event.data,
84
- messageChannels: channelsForEvent,
85
- producers,
86
- consumers,
87
- versions,
88
- latestVersion,
89
- },
90
- catalog: {
91
- path: path.join(event.collection, event.id.replace('/index.mdx', '')),
92
- absoluteFilePath: path.join(PROJECT_DIR, event.collection, event.id.replace('/index.mdx', '/index.md')),
93
- astroContentFilePath: path.join(process.cwd(), 'src', 'content', event.collection, event.id),
94
- filePath: path.join(process.cwd(), 'src', 'catalog-files', event.collection, event.id.replace('/index.mdx', '')),
95
- publicPath: path.join('/generated', event.collection, eventFolderName),
96
- type: 'event',
97
- },
98
- };
99
- })
100
- );
101
-
102
- // order them by the name of the event
103
- cachedEvents[cacheKey].sort((a, b) => {
104
- return (a.data.name || a.data.id).localeCompare(b.data.name || b.data.id);
105
- });
106
-
107
- return cachedEvents[cacheKey];
108
- };
@@ -1,10 +0,0 @@
1
- // Should really only be used on the server side
2
- // If users are using path or fs in the eventcatalog.config.js file, it will break the build (for now)
3
-
4
- import config from '@config';
5
-
6
- export const getConfigurationForGivenGenerator = (generator: string) => {
7
- const generators = config.generators ?? [];
8
- const generatorConfig = generators.find((g: any) => g[0] === generator);
9
- return generatorConfig?.[1];
10
- };
@@ -1,72 +0,0 @@
1
- import { getCollection } from 'astro:content';
2
- import type { CollectionEntry } from 'astro:content';
3
- import path from 'path';
4
-
5
- export type Team = CollectionEntry<'teams'>;
6
-
7
- // Cache for build time
8
- let cachedTeams: Team[] = [];
9
-
10
- export const getTeams = async (): Promise<Team[]> => {
11
- if (cachedTeams.length > 0) {
12
- return cachedTeams;
13
- }
14
-
15
- // Get services that are not versioned
16
- const teams = await getCollection('teams', (team) => {
17
- return team.data.hidden !== true;
18
- });
19
- // What do they own?
20
- const domains = await getCollection('domains');
21
- // What do they own?
22
- const services = await getCollection('services');
23
- // What do they own?
24
- const events = await getCollection('events');
25
- const commands = await getCollection('commands');
26
- const queries = await getCollection('queries');
27
- cachedTeams = teams.map((team) => {
28
- const ownedDomains = domains.filter((domain) => {
29
- return domain.data.owners?.find((owner) => owner.id === team.data.id);
30
- });
31
-
32
- const ownedServices = services.filter((service) => {
33
- return service.data.owners?.find((owner) => owner.id === team.data.id);
34
- });
35
-
36
- const ownedEvents = events.filter((event) => {
37
- return event.data.owners?.find((owner) => owner.id === team.data.id);
38
- });
39
-
40
- const ownedCommands = commands.filter((command) => {
41
- return command.data.owners?.find((owner) => owner.id === team.data.id);
42
- });
43
-
44
- const ownedQueries = queries.filter((query) => {
45
- return query.data.owners?.find((owner) => owner.id === team.data.id);
46
- });
47
-
48
- return {
49
- ...team,
50
- data: {
51
- ...team.data,
52
- ownedDomains,
53
- ownedServices,
54
- ownedCommands,
55
- ownedQueries,
56
- ownedEvents,
57
- },
58
- catalog: {
59
- path: path.join(team.collection, team.id.replace('/index.mdx', '')),
60
- filePath: path.join(process.cwd(), 'src', 'catalog-files', team.collection, team.id.replace('/index.mdx', '')),
61
- type: 'team',
62
- },
63
- };
64
- });
65
-
66
- // order them by the name of the team
67
- cachedTeams.sort((a, b) => {
68
- return (a.data.name || a.data.id).localeCompare(b.data.name || b.data.id);
69
- });
70
-
71
- return cachedTeams;
72
- };
@@ -1,72 +0,0 @@
1
- import type { CollectionTypes } from '@types';
2
- import { getCollection } from 'astro:content';
3
- import type { CollectionEntry } from 'astro:content';
4
- import path from 'path';
5
-
6
- export type User = CollectionEntry<'users'>;
7
-
8
- export const getUsers = async (): Promise<User[]> => {
9
- // Get services that are not versioned
10
- const users = await getCollection('users', (user) => {
11
- return user.data.hidden !== true;
12
- });
13
-
14
- // What do they own?
15
- const domains = await getCollection('domains');
16
- const services = await getCollection('services');
17
- const events = await getCollection('events');
18
- const commands = await getCollection('commands');
19
- const queries = await getCollection('queries');
20
-
21
- const teams = await getCollection('teams', (team) => {
22
- return team.data.hidden !== true;
23
- });
24
-
25
- const mappedUsers = users.map((user) => {
26
- const associatedTeams = teams.filter((team) => {
27
- return team.data.members?.some((member) => member.id === user.data.id);
28
- });
29
-
30
- const ownedDomains = domains.filter((domain) => {
31
- return domain.data.owners?.find((owner) => owner.id === user.data.id);
32
- });
33
-
34
- const isOwnedByUserOrAssociatedTeam = (item: CollectionEntry<CollectionTypes>) => {
35
- const associatedTeamsId: string[] = associatedTeams.map((team) => team.data.id);
36
- return item.data.owners?.some((owner) => owner.id === user.data.id || associatedTeamsId.includes(owner.id));
37
- };
38
-
39
- const ownedServices = services.filter(isOwnedByUserOrAssociatedTeam);
40
-
41
- const ownedEvents = events.filter(isOwnedByUserOrAssociatedTeam);
42
-
43
- const ownedCommands = commands.filter(isOwnedByUserOrAssociatedTeam);
44
-
45
- const ownedQueries = queries.filter(isOwnedByUserOrAssociatedTeam);
46
-
47
- return {
48
- ...user,
49
- data: {
50
- ...user.data,
51
- ownedDomains,
52
- ownedServices,
53
- ownedEvents,
54
- ownedCommands,
55
- ownedQueries,
56
- associatedTeams,
57
- },
58
- catalog: {
59
- path: path.join(user.collection, user.id.replace('/index.mdx', '')),
60
- filePath: path.join(process.cwd(), 'src', 'catalog-files', user.collection, user.id.replace('/index.mdx', '')),
61
- type: 'user',
62
- },
63
- };
64
- });
65
-
66
- // order them by the name of the user
67
- mappedUsers.sort((a, b) => {
68
- return (a.data.name || a.data.id).localeCompare(b.data.name || b.data.id);
69
- });
70
-
71
- return mappedUsers;
72
- };