-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathIntegrationGallery.tsx
More file actions
173 lines (160 loc) · 4.6 KB
/
Copy pathIntegrationGallery.tsx
File metadata and controls
173 lines (160 loc) · 4.6 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import fs from 'node:fs';
import path from 'node:path';
import { Card, Cards } from 'fumadocs-ui/components/card';
import {
IconApi,
IconBox,
IconBrain,
IconChartBar,
IconCloud,
IconCode,
IconCpu,
IconDatabase,
IconFileText,
IconGitBranch,
IconPuzzle,
IconRobot,
IconServer,
IconShield,
IconStack2,
} from '@tabler/icons-react';
type Integration = {
id: string;
name: string;
resource: string;
telemetry_types: string[];
description: string;
isOtel?: boolean;
links: { docs: string };
assets?: { logo?: string | null };
};
type ResourceDef = { id: string; label: string; order: number };
const resourceOrder: ResourceDef[] = [
{ id: 'opentelemetry', label: 'OpenTelemetry', order: 1 },
{ id: 'ebpf', label: 'eBPF', order: 2 },
{ id: 'llm-ai-agents', label: 'LLMs & AI Agents', order: 3 },
{ id: 'telemetry-agents', label: 'Telemetry Agents', order: 4 },
{ id: 'databases', label: 'Databases', order: 5 },
{ id: 'containers', label: 'Containers', order: 6 },
{ id: 'streaming', label: 'Streaming', order: 7 },
{ id: 'ci-cd', label: 'CI/CD', order: 8 },
{ id: 'cloud-providers', label: 'Cloud Providers', order: 9 },
{ id: 'security', label: 'Security', order: 10 },
{ id: 'programming-languages', label: 'Programming Languages', order: 11 },
];
const fallbackIconByResource: Record<string, React.ReactNode> = {
'opentelemetry': <IconStack2 />,
'ebpf': <IconCpu />,
'llm-ai-agents': <IconRobot />,
'telemetry-agents': <IconChartBar />,
'databases': <IconDatabase />,
'containers': <IconBox />,
'streaming': <IconGitBranch />,
'ci-cd': <IconCode />,
'cloud-providers': <IconCloud />,
'security': <IconShield />,
'programming-languages': <IconFileText />,
};
const manifestPath = path.join(
process.cwd(),
'vendor',
'datasources',
'dist',
'integrations.json',
);
function loadIntegrations(): Integration[] | null {
try {
const raw = fs.readFileSync(manifestPath, 'utf8');
const parsed = JSON.parse(raw);
if (Array.isArray(parsed)) return parsed as Integration[];
if (parsed && Array.isArray(parsed.integrations)) {
return parsed.integrations as Integration[];
}
return null;
} catch {
return null;
}
}
function toInternalHref(docsUrl: string): string {
return docsUrl.replace(/^https?:\/\/(www\.)?parseable\.com/, '');
}
function logoSrc(logoPath: string | null | undefined): string | null {
if (!logoPath) return null;
const base = path.basename(logoPath);
return `/integrations/logos/${base.toLowerCase()}`;
}
function LogoIcon({ integration }: { integration: Integration }) {
const src = logoSrc(integration.assets?.logo);
if (src) {
return (
<img
src={src}
alt=""
aria-hidden="true"
width={20}
height={20}
style={{ width: 20, height: 20, objectFit: 'contain' }}
/>
);
}
return (
<>{fallbackIconByResource[integration.resource] ?? <IconPuzzle />}</>
);
}
export function IntegrationGallery() {
const integrations = loadIntegrations();
if (!integrations) {
return (
<div
style={{
padding: '1rem',
border: '1px dashed var(--color-fd-border, #ccc)',
borderRadius: 8,
fontSize: '0.875rem',
color: 'var(--color-fd-muted-foreground, #666)',
}}
>
Integrations catalog not found at
{' '}<code>vendor/datasources/dist/integrations.json</code>.
{' '}Run{' '}
<code>git submodule update --init --recursive</code>
{' '}then{' '}
<code>pnpm sync-catalog</code>.
</div>
);
}
const grouped = new Map<string, Integration[]>();
for (const integration of integrations) {
const list = grouped.get(integration.resource) ?? [];
list.push(integration);
grouped.set(integration.resource, list);
}
for (const list of grouped.values()) {
list.sort((a, b) => a.name.localeCompare(b.name));
}
return (
<>
{resourceOrder.map((resource) => {
const items = grouped.get(resource.id);
if (!items || items.length === 0) return null;
return (
<section key={resource.id}>
<h2>{resource.label}</h2>
<Cards>
{items.map((integration) => (
<Card
key={integration.id}
title={integration.name}
href={toInternalHref(integration.links.docs)}
icon={<LogoIcon integration={integration} />}
>
{integration.description}
</Card>
))}
</Cards>
</section>
);
})}
</>
);
}