Skip to content

Commit

Permalink
chore(core): update to astro 5 (#1027)
Browse files Browse the repository at this point in the history
* chore(core): update to astro 5

* Create wise-forks-invent.md

* chore(core): update to astro 5
  • Loading branch information
boyney123 authored Dec 15, 2024
1 parent 5beb19a commit 8746d32
Show file tree
Hide file tree
Showing 23 changed files with 5,887 additions and 6,023 deletions.
5 changes: 5 additions & 0 deletions .changeset/wise-forks-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@eventcatalog/core": minor
---

chore(core): update to astro 5
14 changes: 7 additions & 7 deletions eventcatalog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"start": "astro dev"
},
"dependencies": {
"@astrojs/markdown-remark": "^5.3.0",
"@astrojs/mdx": "^3.1.8",
"@astrojs/react": "^3.6.2",
"@astrojs/tailwind": "^5.1.2",
"@astrojs/markdown-remark": "^6.0.1",
"@astrojs/mdx": "^4.0.2",
"@astrojs/react": "^4.1.0",
"@astrojs/tailwind": "^5.1.3",
"@asyncapi/avro-schema-parser": "^3.0.24",
"@asyncapi/parser": "^3.4.0",
"@asyncapi/react-component": "^2.4.3",
Expand All @@ -31,9 +31,9 @@
"@tailwindcss/typography": "^0.5.13",
"@tanstack/react-table": "^8.17.3",
"@xyflow/react": "^12.3.6",
"astro": "^4.16.5",
"astro-expressive-code": "^0.36.1",
"astro-pagefind": "^1.6.0",
"astro": "^5.0.5",
"astro-expressive-code": "^0.38.3",
"astro-pagefind": "^1.7.0",
"astro-seo": "^0.8.4",
"dagre": "^0.8.5",
"diff": "^7.0.0",
Expand Down
5 changes: 3 additions & 2 deletions eventcatalog/src/components/SideBars/ChannelSideBar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const { channel } = Astro.props;
const ownersRaw = channel.data?.owners || [];
const owners = await Promise.all(ownersRaw.map((o) => getEntry(o)));
const filteredOwners = owners.filter((o) => o !== undefined);
const channelParameters: Record<string, { enum?: string[]; description?: string }> = channel.data.parameters || {};
const parameters = Object.keys(channelParameters).map((key) => ({
Expand All @@ -37,7 +38,7 @@ const protocolList = protocols.map((p) => ({
icon: p,
}));
const ownersList = owners.map((o) => ({
const ownersList = filteredOwners.map((o) => ({
label: o.data.name,
type: o.collection,
badge: o.collection === 'users' ? o.data.role : 'Team',
Expand Down Expand Up @@ -86,7 +87,7 @@ const messageList = (channel.data.messages ?? []).map((p) => ({
}

<OwnersList
title={`Channel owners (${ownersList.length})`}
title={`Channel owners (${filteredOwners.length})`}
owners={ownersList}
emptyMessage={`This channel does not have any documented owners.`}
client:load
Expand Down
3 changes: 2 additions & 1 deletion eventcatalog/src/components/SideBars/DomainSideBar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const ubiquitousLanguageDictionary = hasUbiquitousLanguage ? ubiquitousLanguage[
const ownersRaw = domain.data?.owners || [];
const owners = await Promise.all(ownersRaw.map((o) => getEntry(o)));
const filteredOwners = owners.filter((o) => o !== undefined);
const serviceList = services.map((p) => ({
label: p.data.name,
Expand All @@ -37,7 +38,7 @@ const ubiquitousLanguageList = ubiquitousLanguageDictionary?.map((l) => ({
href: buildUrl(`/docs/${domain.collection}/${domain.data.id}/language?id=${l.id}`),
}));
const ownersList = owners.map((o) => ({
const ownersList = filteredOwners.map((o) => ({
label: o.data.name,
type: o.collection,
badge: o.collection === 'users' ? o.data.role : 'Team',
Expand Down
3 changes: 2 additions & 1 deletion eventcatalog/src/components/SideBars/MessageSideBar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const channels = (message.data.messageChannels as CollectionEntry<'channels'>[])
const ownersRaw = message.data?.owners || [];
const owners = await Promise.all(ownersRaw.map((o) => getEntry(o)));
const filteredOwners = owners.filter((o) => o !== undefined);
const producerList = producers.map((p) => ({
label: `${p.data.name}`,
Expand All @@ -35,7 +36,7 @@ const consumerList = consumers.map((p) => ({
href: buildUrl(`/docs/services/${p.data.id}/${p.data.version}`),
}));
const ownersList = owners.map((o) => ({
const ownersList = filteredOwners.map((o) => ({
label: o.data.name,
type: o.collection,
badge: o.collection === 'users' ? o.data.role : 'Team',
Expand Down
3 changes: 2 additions & 1 deletion eventcatalog/src/components/SideBars/ServiceSideBar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const receives = (service.data.receives as CollectionEntry<'events'>[]) || [];
const ownersRaw = service.data?.owners || [];
const owners = await Promise.all(ownersRaw.map((o) => getEntry(o)));
const filteredOwners = owners.filter((o) => o !== undefined);
const sendsList = sends.map((p) => ({
label: p.data.name,
Expand All @@ -39,7 +40,7 @@ const receivesList = receives.map((p) => ({
href: buildUrl(`/docs/${p.collection}/${p.data.id}/${p.data.version}`),
}));
const ownersList = owners.map((o) => ({
const ownersList = filteredOwners.map((o) => ({
label: o.data.name,
type: o.collection,
badge: o.collection === 'users' ? o.data.role : 'Team',
Expand Down
4 changes: 2 additions & 2 deletions eventcatalog/src/pages/docs/teams/[id]/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ const ownedDomainsList = domains.map((p) => ({
}));
const ownedServicesList = services.map((p) => ({
label: `${p.data.name} (service)`,
label: `${p.data.name}`,
href: buildUrl(`/docs/${p.collection}/${p.data.id}/${p.data.version}`),
collection: p.collection,
tag: `v${p.data.version}`,
}));
const ownedEventsList = [...events, ...commands].map((p) => ({
label: `${p.data.name} (${p.collection.slice(0, -1)})`,
label: `${p.data.name}`,
href: buildUrl(`/docs/${p.collection}/${p.data.id}/${p.data.version}`),
color: p.collection === 'events' ? 'orange' : 'blue',
collection: p.collection,
Expand Down
2 changes: 1 addition & 1 deletion eventcatalog/src/pages/docs/users/[id]/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const ownedDomainsList = domains.map((p) => ({
}));
const ownedServicesList = services.map((p) => ({
label: `${p.data.name} (service)`,
label: `${p.data.name}`,
href: buildUrl(`/docs/${p.collection}/${p.data.id}/${p.data.version}`),
collection: p.collection,
tag: `v${p.data.version}`,
Expand Down
2 changes: 1 addition & 1 deletion eventcatalog/src/utils/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface Props {

export const getChannels = async ({ getAllVersions = true }: Props = {}): Promise<Channel[]> => {
const channels = await getCollection('channels', (query) => {
return (getAllVersions || !query.slug.includes('versioned')) && query.data.hidden !== true;
return (getAllVersions || !query.data?.pathToFile?.includes('versioned')) && query.data.hidden !== true;
});

const { commands, events, queries } = await getMessages();
Expand Down
2 changes: 1 addition & 1 deletion eventcatalog/src/utils/collections/changelogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const getChangeLogs = async (item: CollectionEntry<CollectionTypes>): Pro

// Get all logs for collection type and filter by given collection
const logs = await getCollection('changelogs', (log) => {
return log.id.includes(`${collection}/`) && log.slug.includes(slug);
return log.id.includes(`${collection}/`) && log.id.includes(slug);
});

const hydratedLogs = logs.map((log) => {
Expand Down
2 changes: 1 addition & 1 deletion eventcatalog/src/utils/collections/domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface Props {
export const getDomains = async ({ getAllVersions = true }: Props = {}): Promise<Domain[]> => {
// Get all the domains that are not versioned
const domains = await getCollection('domains', (domain) => {
return (getAllVersions || !domain.slug.includes('versioned')) && domain.data.hidden !== true;
return (getAllVersions || !domain.data?.pathToFile?.includes('versioned')) && domain.data.hidden !== true;
});

// Get all the services that are not versioned
Expand Down
2 changes: 1 addition & 1 deletion eventcatalog/src/utils/collections/flows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface Props {
export const getFlows = async ({ getAllVersions = true }: Props = {}): Promise<Flow[]> => {
// Get flows that are not versioned
const flows = await getCollection('flows', (flow) => {
return (getAllVersions || !flow.slug.includes('versioned')) && flow.data.hidden !== true;
return (getAllVersions || !flow.data.pathToFile?.includes('versioned')) && flow.data.hidden !== true;
});

const events = await getCollection('events');
Expand Down
2 changes: 1 addition & 1 deletion eventcatalog/src/utils/collections/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface Props {
export const getServices = async ({ getAllVersions = true }: Props = {}): Promise<Service[]> => {
// Get services that are not versioned
const services = await getCollection('services', (service) => {
return (getAllVersions || !service.slug.includes('versioned')) && service.data.hidden !== true;
return (getAllVersions || !service.data?.pathToFile?.includes('versioned')) && service.data.hidden !== true;
});
const events = await getCollection('events');
const commands = await getCollection('commands');
Expand Down
2 changes: 1 addition & 1 deletion eventcatalog/src/utils/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface Props {

export const getCommands = async ({ getAllVersions = true }: Props = {}): Promise<Command[]> => {
const commands = await getCollection('commands', (command) => {
return (getAllVersions || !command.slug.includes('versioned')) && command.data.hidden !== true;
return (getAllVersions || !command.data?.pathToFile?.includes('versioned')) && command.data.hidden !== true;
});

const services = await getCollection('services');
Expand Down
2 changes: 1 addition & 1 deletion eventcatalog/src/utils/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface Props {

export const getEvents = async ({ getAllVersions = true }: Props = {}): Promise<Event[]> => {
const events = await getCollection('events', (event) => {
return (getAllVersions || !event.slug.includes('versioned')) && event.data.hidden !== true;
return (getAllVersions || !event.data?.pathToFile?.includes('versioned')) && event.data.hidden !== true;
});

const services = await getCollection('services');
Expand Down
31 changes: 22 additions & 9 deletions eventcatalog/src/utils/node-graphs/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
import { getCollection, type CollectionEntry } from 'astro:content';
// Can't use the CollectionEntry type from astro:content because a client component is using this util
// import { type CollectionEntry } from 'astro:content';
import { MarkerType, Position, type Edge, type Node } from '@xyflow/react';
import dagre from 'dagre';
import { getItemsFromCollectionByIdAndSemverOrLatest } from '@utils/collections/util';
import type { CollectionMessageTypes, CollectionTypes } from '@types';
interface BaseCollectionData {
id: string;
version: string;
}

export const generateIdForNode = (node: CollectionEntry<CollectionTypes>) => {
interface CollectionItem {
collection: string;
data: BaseCollectionData;
}

interface MessageCollectionItem extends CollectionItem {
collection: 'commands' | 'events' | 'queries';
}

export const generateIdForNode = (node: CollectionItem) => {
return `${node.data.id}-${node.data.version}`;
};
export const generateIdForNodes = (nodes: any) => {
return nodes.map((node: any) => `${node.data.id}-${node.data.version}`).join('-');
};
export const generatedIdForEdge = (source: CollectionEntry<CollectionTypes>, target: CollectionEntry<CollectionTypes>) => {
export const generatedIdForEdge = (source: CollectionItem, target: CollectionItem) => {
return `${source.data.id}-${source.data.version}-${target.data.id}-${target.data.version}`;
};

export const getEdgeLabelForServiceAsTarget = (data: CollectionEntry<CollectionMessageTypes>) => {
export const getEdgeLabelForServiceAsTarget = (data: MessageCollectionItem) => {
const type = data.collection;
switch (type) {
case 'commands':
Expand All @@ -27,7 +40,7 @@ export const getEdgeLabelForServiceAsTarget = (data: CollectionEntry<CollectionM
return 'sends to';
}
};
export const getEdgeLabelForMessageAsSource = (data: CollectionEntry<CollectionMessageTypes>) => {
export const getEdgeLabelForMessageAsSource = (data: MessageCollectionItem) => {
const type = data.collection;
switch (type) {
case 'commands':
Expand Down Expand Up @@ -90,10 +103,10 @@ export const getChannelNodesAndEdges = ({
mode = 'full',
currentNodes = [],
}: {
channels: CollectionEntry<'channels'>[];
channels: CollectionItem[];
channelsToRender: { id: string; version: string }[];
source: CollectionEntry<CollectionTypes>;
target: CollectionEntry<CollectionTypes>;
source: CollectionItem;
target: CollectionItem;
channelToTargetLabel?: string;
sourceToChannelLabel?: string;
mode?: 'simple' | 'full';
Expand Down
2 changes: 1 addition & 1 deletion eventcatalog/src/utils/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface Props {

export const getQueries = async ({ getAllVersions = true }: Props = {}): Promise<Query[]> => {
const queries = await getCollection('queries', (query) => {
return (getAllVersions || !query.slug.includes('versioned')) && query.data.hidden !== true;
return (getAllVersions || !query.data?.pathToFile?.includes('versioned')) && query.data.hidden !== true;
});

const services = await getCollection('services');
Expand Down
8 changes: 4 additions & 4 deletions eventcatalog/src/utils/teams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ export const getTeams = async (): Promise<Team[]> => {

return teams.map((team) => {
const ownedDomains = domains.filter((domain) => {
return domain.data.owners?.find((owner) => owner.slug === team.data.id);
return domain.data.owners?.find((owner) => owner.id === team.data.id);
});

const ownedServices = services.filter((service) => {
return service.data.owners?.find((owner) => owner.slug === team.data.id);
return service.data.owners?.find((owner) => owner.id === team.data.id);
});

const ownedEvents = events.filter((event) => {
return event.data.owners?.find((owner) => owner.slug === team.data.id);
return event.data.owners?.find((owner) => owner.id === team.data.id);
});

const ownedCommands = commands.filter((command) => {
return command.data.owners?.find((owner) => owner.slug === team.data.id);
return command.data.owners?.find((owner) => owner.id === team.data.id);
});

return {
Expand Down
12 changes: 6 additions & 6 deletions eventcatalog/src/utils/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@ export const getUsers = async (): Promise<User[]> => {

return users.map((user) => {
const associatedTeams = teams.filter((team) => {
return team.data.members?.some((member) => member.slug === user.data.id);
return team.data.members?.some((member) => member.id === user.data.id);
});

const ownedDomains = domains.filter((domain) => {
return domain.data.owners?.find((owner) => owner.slug === user.data.id);
return domain.data.owners?.find((owner) => owner.id === user.data.id);
});

const isOwnedByUserOrAssociatedTeam = () => {
const associatedTeamsSlug: string[] = associatedTeams.map((team) => team.slug);
const associatedTeamsSlug: string[] = associatedTeams.map((team) => team.id);

return ({ data }: { data: { owners?: Array<{ slug: string }> } }) => {
return data.owners?.some((owner) => owner.slug === user.data.id || associatedTeamsSlug.includes(owner.slug));
};
};

const ownedServices = services.filter(isOwnedByUserOrAssociatedTeam());
const ownedServices = services.filter(() => isOwnedByUserOrAssociatedTeam());

const ownedEvents = events.filter(isOwnedByUserOrAssociatedTeam());
const ownedEvents = events.filter(() => isOwnedByUserOrAssociatedTeam());

const ownedCommands = commands.filter(isOwnedByUserOrAssociatedTeam());
const ownedCommands = commands.filter(() => isOwnedByUserOrAssociatedTeam());

return {
...user,
Expand Down
Loading

0 comments on commit 8746d32

Please sign in to comment.