@eventcatalog/core 2.65.0 → 3.0.0-beta.0

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 (130) hide show
  1. package/README.md +1 -26
  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-NK6OYMRD.js → chunk-JB4YT5JY.js} +1 -1
  7. package/dist/{chunk-BMDTX5IN.js → chunk-TQ4HZREX.js} +1 -1
  8. package/dist/{chunk-IJRFYF4B.js → chunk-X4W4YC3U.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 +10 -0
  13. package/dist/eventcatalog.config.d.ts +10 -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 -518
  19. package/eventcatalog/src/components/Header.astro +48 -23
  20. package/eventcatalog/src/components/Lists/VersionList.astro +2 -2
  21. package/eventcatalog/src/components/MDX/Design/Design.astro +4 -1
  22. package/eventcatalog/src/components/MDX/Flow/Flow.astro +2 -1
  23. package/eventcatalog/src/components/MDX/NodeGraph/NodeGraph.astro +3 -3
  24. package/eventcatalog/src/components/SchemaExplorer/SchemaDetailsPanel.tsx +8 -2
  25. package/eventcatalog/src/components/SchemaExplorer/SchemaPageViewer.tsx +37 -0
  26. package/eventcatalog/src/components/Search/Search.astro +48 -28
  27. package/eventcatalog/src/components/Search/SearchModal.tsx +393 -702
  28. package/eventcatalog/src/components/SideNav/NestedSideBar/SearchBar.tsx +298 -0
  29. package/eventcatalog/src/components/SideNav/NestedSideBar/builders/container.ts +66 -0
  30. package/eventcatalog/src/components/SideNav/NestedSideBar/builders/domain.ts +101 -0
  31. package/eventcatalog/src/components/SideNav/NestedSideBar/builders/flow.ts +29 -0
  32. package/eventcatalog/src/components/SideNav/NestedSideBar/builders/message.ts +84 -0
  33. package/eventcatalog/src/components/SideNav/NestedSideBar/builders/service.ts +147 -0
  34. package/eventcatalog/src/components/SideNav/NestedSideBar/builders/shared.ts +146 -0
  35. package/eventcatalog/src/components/SideNav/NestedSideBar/index.tsx +1073 -0
  36. package/eventcatalog/src/components/SideNav/NestedSideBar/sidebar-builder.ts +365 -0
  37. package/eventcatalog/src/components/SideNav/NestedSideBar/storage.ts +90 -0
  38. package/eventcatalog/src/components/SideNav/SideNav.astro +18 -28
  39. package/eventcatalog/src/content.config.ts +2 -0
  40. package/eventcatalog/src/enterprise/custom-documentation/pages/docs/custom/index.astro +10 -4
  41. package/eventcatalog/src/enterprise/eventcatalog-chat/pages/chat/index.astro +3 -3
  42. package/eventcatalog/src/layouts/DirectoryLayout.astro +2 -2
  43. package/eventcatalog/src/layouts/DiscoverLayout.astro +3 -3
  44. package/eventcatalog/src/layouts/VerticalSideBarLayout.astro +85 -63
  45. package/eventcatalog/src/layouts/VisualiserLayout.astro +3 -3
  46. package/eventcatalog/src/pages/_index.astro +530 -110
  47. package/eventcatalog/src/pages/architecture/[type]/[id]/[version]/_index.data.ts +64 -0
  48. package/eventcatalog/src/pages/architecture/[type]/[id]/[version]/index.astro +29 -0
  49. package/eventcatalog/src/pages/directory/[type]/_index.data.ts +4 -4
  50. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/_index.data.ts +1 -4
  51. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/changelog/_index.data.ts +3 -3
  52. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/changelog/index.astro +1 -5
  53. package/eventcatalog/src/pages/docs/[type]/[id]/[version]/index.astro +362 -190
  54. package/eventcatalog/src/pages/docs/[type]/[id]/[version].md.ts +1 -1
  55. package/eventcatalog/src/pages/docs/[type]/[id]/index.astro +4 -4
  56. package/eventcatalog/src/pages/docs/[type]/[id]/language/_index.data.ts +1 -4
  57. package/eventcatalog/src/pages/docs/[type]/[id]/language/index.astro +3 -27
  58. package/eventcatalog/src/pages/docs/teams/[id]/_index.data.ts +2 -2
  59. package/eventcatalog/src/pages/docs/users/[id]/_index.data.ts +2 -2
  60. package/eventcatalog/src/pages/index.astro +14 -5
  61. package/eventcatalog/src/pages/nav-index.json.ts +30 -0
  62. package/eventcatalog/src/pages/schemas/[type]/[id]/[version]/_index.data.ts +77 -0
  63. package/eventcatalog/src/pages/schemas/[type]/[id]/[version]/index.astro +90 -0
  64. package/eventcatalog/src/pages/schemas/{index.astro → explorer/index.astro} +3 -3
  65. package/eventcatalog/src/pages/studio.astro +3 -3
  66. package/eventcatalog/src/pages/visualiser/[type]/[id]/[version]/_index.data.ts +4 -3
  67. package/eventcatalog/src/pages/visualiser/[type]/[id]/index.astro +2 -2
  68. package/eventcatalog/src/pages/visualiser/domains/[id]/[version]/entity-map/_index.data.ts +4 -3
  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 +204 -62
  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/users.ts +122 -0
  84. package/eventcatalog/src/utils/collections/util.ts +57 -1
  85. package/eventcatalog/src/utils/feature.ts +3 -1
  86. package/eventcatalog/src/utils/{collections/file-diffs.ts → file-diffs.ts} +1 -1
  87. package/eventcatalog/src/utils/node-graphs/container-node-graph.ts +2 -0
  88. package/eventcatalog/src/utils/node-graphs/domain-entity-map.ts +16 -6
  89. package/eventcatalog/src/utils/node-graphs/domains-canvas.ts +14 -10
  90. package/eventcatalog/src/utils/node-graphs/domains-node-graph.ts +36 -64
  91. package/eventcatalog/src/utils/node-graphs/flows-node-graph.ts +23 -19
  92. package/eventcatalog/src/utils/node-graphs/message-node-graph.ts +36 -49
  93. package/eventcatalog/src/utils/node-graphs/services-node-graph.ts +22 -18
  94. package/eventcatalog/src/utils/page-loaders/page-data-loader.ts +4 -4
  95. package/eventcatalog/tailwind.config.mjs +14 -0
  96. package/eventcatalog/tsconfig.json +2 -1
  97. package/package.json +7 -4
  98. package/eventcatalog/public/logo_old.png +0 -0
  99. package/eventcatalog/src/components/DiscoverInsight.astro +0 -61
  100. package/eventcatalog/src/components/Grids/ServiceGrid.tsx +0 -534
  101. package/eventcatalog/src/components/Lists/CustomSideBarSectionList.astro +0 -55
  102. package/eventcatalog/src/components/Lists/ProtocolList.tsx +0 -74
  103. package/eventcatalog/src/components/Lists/RepositoryList.astro +0 -37
  104. package/eventcatalog/src/components/Lists/SpecificationsList.astro +0 -67
  105. package/eventcatalog/src/components/SideBars/ChannelSideBar.astro +0 -204
  106. package/eventcatalog/src/components/SideBars/ContainerSideBar.astro +0 -180
  107. package/eventcatalog/src/components/SideBars/DomainSideBar.astro +0 -273
  108. package/eventcatalog/src/components/SideBars/EntitySideBar.astro +0 -139
  109. package/eventcatalog/src/components/SideBars/FlowSideBar.astro +0 -128
  110. package/eventcatalog/src/components/SideBars/MessageSideBar.astro +0 -248
  111. package/eventcatalog/src/components/SideBars/ServiceSideBar.astro +0 -294
  112. package/eventcatalog/src/components/SideNav/ListViewSideBar/components/CollapsibleGroup.tsx +0 -46
  113. package/eventcatalog/src/components/SideNav/ListViewSideBar/components/MessageList.tsx +0 -78
  114. package/eventcatalog/src/components/SideNav/ListViewSideBar/components/SpecificationList.tsx +0 -83
  115. package/eventcatalog/src/components/SideNav/ListViewSideBar/index.tsx +0 -1250
  116. package/eventcatalog/src/components/SideNav/ListViewSideBar/types.ts +0 -91
  117. package/eventcatalog/src/components/SideNav/ListViewSideBar/utils.ts +0 -201
  118. package/eventcatalog/src/components/SideNav/TreeView/getTreeView.ts +0 -190
  119. package/eventcatalog/src/components/SideNav/TreeView/index.tsx +0 -94
  120. package/eventcatalog/src/components/TreeView/index.tsx +0 -328
  121. package/eventcatalog/src/components/TreeView/styles.module.css +0 -264
  122. package/eventcatalog/src/components/TreeView/useSlots.ts +0 -95
  123. package/eventcatalog/src/pages/architecture/[type]/index.astro +0 -14
  124. package/eventcatalog/src/pages/architecture/architecture.astro +0 -101
  125. package/eventcatalog/src/pages/architecture/docs/[type]/index.astro +0 -14
  126. package/eventcatalog/src/utils/commands.ts +0 -112
  127. package/eventcatalog/src/utils/events.ts +0 -108
  128. package/eventcatalog/src/utils/generators/index.ts +0 -10
  129. package/eventcatalog/src/utils/teams.ts +0 -72
  130. package/eventcatalog/src/utils/users.ts +0 -72
@@ -1,101 +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 { ClientRouter, fade } from 'astro:transitions';
17
- // Define valid types and their corresponding data fetchers
18
- const VALID_TYPES = ['domains', 'services', 'messages'] as const;
19
- type ValidType = (typeof VALID_TYPES)[number];
20
-
21
- interface Service extends CollectionEntry<'services'> {
22
- sends: CollectionEntry<'events' | 'commands' | 'queries'>[];
23
- receives: CollectionEntry<'events' | 'commands' | 'queries'>[];
24
- }
25
-
26
- const { type, embeded = false } = Astro.props as { type: ValidType; embeded: boolean };
27
-
28
- // Get data based on type
29
- let items: Service[] | CollectionEntry<'commands'>[] | CollectionEntry<CollectionMessageTypes>[] = [];
30
- let domains: ExtendedDomain[] = [];
31
- let containers: CollectionEntry<'containers'>[] = [];
32
-
33
- const getDomainsForArchitecturePages = async () => {
34
- const domains = await getDomains({ getAllVersions: false });
35
-
36
- // Get messages for each domain
37
- return Promise.all(
38
- domains.map(async (domain) => {
39
- const messages = await getMessagesForDomain(domain);
40
- // @ts-ignore we have to remove markdown information, as it's all send to the astro components. This reduced the page size.
41
- return {
42
- ...domain,
43
- sends: messages.sends.map((s) => ({ ...s, body: undefined, catalog: undefined })),
44
- receives: messages.receives.map((r) => ({ ...r, body: undefined, catalog: undefined })),
45
- catalog: undefined,
46
- body: undefined,
47
- } as ExtendedDomain;
48
- })
49
- );
50
- };
51
-
52
- if (type === 'domains' || type === 'services') {
53
- domains = await getDomainsForArchitecturePages();
54
- }
55
-
56
- if (type === 'services') {
57
- const services = await getServices({ getAllVersions: false });
58
- let filteredServices = services.map((s) => {
59
- // @ts-ignore we have to remove markdown information, as it's all send to the astro components. This reduced the page size.
60
- return {
61
- ...s,
62
- sends: (s.data.sends || []).map((s) => ({ ...s, body: undefined, catalog: undefined })),
63
- receives: (s.data.receives || []).map((r) => ({ ...r, body: undefined, catalog: undefined })),
64
- catalog: undefined,
65
- body: undefined,
66
- } as Service;
67
- }) as unknown as Service[];
68
- items = filteredServices;
69
- } else if (type === 'messages') {
70
- const { events, commands, queries } = await getMessages({ getAllVersions: false, hydrateServices: false });
71
- const messages = [...events, ...commands, ...queries];
72
- items = removeContentFromCollection(messages) as unknown as CollectionEntry<CollectionMessageTypes>[];
73
- containers = await getContainers({ getAllVersions: false });
74
- }
75
- ---
76
-
77
- <VerticalSideBarLayout title={'EventCatalog'}>
78
- <div class="bg-white min-h-screen">
79
- <div class="max-w-[90em] mx-auto">
80
- <div class="px-6 py-6" transition:animate={fade({ duration: '0.4s' })}>
81
- {type === 'domains' && <DomainGrid domains={domains} embeded={embeded} client:load />}
82
- {
83
- type === 'services' && (
84
- <ServiceGrid domains={domains} services={items as unknown as Service[]} embeded={embeded} client:load />
85
- )
86
- }
87
- {
88
- type === 'messages' && (
89
- <MessageGrid
90
- messages={items as CollectionEntry<CollectionMessageTypes>[]}
91
- embeded={embeded}
92
- containers={containers}
93
- client:load
94
- />
95
- )
96
- }
97
- </div>
98
- </div>
99
- <ClientRouter />
100
- </div>
101
- </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
- };