forked from event-catalog/eventcatalog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteams.ts
53 lines (46 loc) · 1.63 KB
/
teams.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { getCollection } from 'astro:content';
import type { CollectionEntry } from 'astro:content';
import path from 'path';
export type Team = CollectionEntry<'teams'>;
export const getTeams = async (): Promise<Team[]> => {
// Get services that are not versioned
const teams = await getCollection('teams', (team) => {
return team.data.hidden !== true;
});
// What do they own?
const domains = await getCollection('domains');
// What do they own?
const services = await getCollection('services');
// What do they own?
const events = await getCollection('events');
const commands = await getCollection('commands');
return teams.map((team) => {
const ownedDomains = domains.filter((domain) => {
return domain.data.owners?.find((owner) => owner.slug === team.data.id);
});
const ownedServices = services.filter((service) => {
return service.data.owners?.find((owner) => owner.slug === team.data.id);
});
const ownedEvents = events.filter((event) => {
return event.data.owners?.find((owner) => owner.slug === team.data.id);
});
const ownedCommands = commands.filter((command) => {
return command.data.owners?.find((owner) => owner.slug === team.data.id);
});
return {
...team,
data: {
...team.data,
ownedDomains,
ownedServices,
ownedCommands,
ownedEvents,
},
catalog: {
path: path.join(team.collection, team.id.replace('/index.mdx', '')),
filePath: path.join(process.cwd(), 'src', 'catalog-files', team.collection, team.id.replace('/index.mdx', '')),
type: 'team',
},
};
});
};