Skip to content

Commit 0b06dc4

Browse files
ericyangpanclaude
andcommitted
refactor(utils): improve type handling and null filtering in utilities
- Moved ComponentResourceUrls and ComponentCommunityUrls types to product-utils.ts - Fixed provider githubUrl handling (providers don't have githubUrl in schema) - Removed unused installCommand from extension IDE compatibility - Improved transform functions to explicitly filter null values instead of using || undefined 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 24c6ad2 commit 0b06dc4

File tree

2 files changed

+43
-20
lines changed

2 files changed

+43
-20
lines changed

src/lib/landscape-data.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export interface ExtensionIDECompatibility {
7676
ideName: string
7777
marketplaceUrl?: string | null
7878
installUri?: string | null
79-
installCommand?: string | null
8079
}>
8180
}
8281

@@ -206,7 +205,7 @@ function providerToProduct(provider: ManifestProvider): LandscapeProduct {
206205
description: provider.description,
207206
websiteUrl: provider.websiteUrl,
208207
docsUrl: provider.docsUrl || undefined,
209-
githubUrl: provider.githubUrl,
208+
githubUrl: null, // Providers don't have githubUrl in schema
210209
githubStars: null, // Providers don't have GitHub stars tracking
211210
path: `/model-providers/${provider.id}`,
212211
}
@@ -382,7 +381,6 @@ export function buildExtensionIDECompatibility(): ExtensionIDECompatibility[] {
382381
ideName: ide.name,
383382
marketplaceUrl: supported.marketplaceUrl,
384383
installUri: supported.installUri,
385-
installCommand: supported.installCommand,
386384
}
387385
})
388386
.filter((item): item is NonNullable<typeof item> => item !== null)

src/lib/product-utils.ts

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,39 @@
44
*/
55

66
import type {
7-
ComponentCommunityUrls,
8-
ComponentResourceUrls,
97
ManifestCLI,
108
ManifestCommunityUrls,
119
ManifestExtension,
1210
ManifestIDE,
1311
ManifestResourceUrls,
1412
} from '@/types/manifests'
1513

14+
/**
15+
* Component-compatible resource URLs (all optional, null values filtered out)
16+
* Used for passing to React components that expect optional string props
17+
*/
18+
export interface ComponentResourceUrls {
19+
download?: string
20+
changelog?: string
21+
pricing?: string
22+
mcp?: string
23+
issue?: string
24+
}
25+
26+
/**
27+
* Component-compatible community URLs (all optional, null values filtered out)
28+
* Used for passing to React components that expect optional string props
29+
*/
30+
export interface ComponentCommunityUrls {
31+
linkedin?: string
32+
twitter?: string
33+
github?: string
34+
youtube?: string
35+
discord?: string
36+
reddit?: string
37+
blog?: string
38+
}
39+
1640
/**
1741
* Platform information type
1842
*/
@@ -64,13 +88,13 @@ export function transformResourceUrls(
6488
return {}
6589
}
6690

67-
return {
68-
download: resourceUrls.download || undefined,
69-
changelog: resourceUrls.changelog || undefined,
70-
pricing: resourceUrls.pricing || undefined,
71-
mcp: resourceUrls.mcp || undefined,
72-
issue: resourceUrls.issue || undefined,
73-
}
91+
const result: ComponentResourceUrls = {}
92+
if (resourceUrls.download) result.download = resourceUrls.download
93+
if (resourceUrls.changelog) result.changelog = resourceUrls.changelog
94+
if (resourceUrls.pricing) result.pricing = resourceUrls.pricing
95+
if (resourceUrls.mcp) result.mcp = resourceUrls.mcp
96+
if (resourceUrls.issue) result.issue = resourceUrls.issue
97+
return result
7498
}
7599

76100
/**
@@ -84,12 +108,13 @@ export function transformCommunityUrls(
84108
return {}
85109
}
86110

87-
return {
88-
linkedin: communityUrls.linkedin || undefined,
89-
twitter: communityUrls.twitter || undefined,
90-
github: communityUrls.github || undefined,
91-
youtube: communityUrls.youtube || undefined,
92-
discord: communityUrls.discord || undefined,
93-
reddit: communityUrls.reddit || undefined,
94-
}
111+
const result: ComponentCommunityUrls = {}
112+
if (communityUrls.linkedin) result.linkedin = communityUrls.linkedin
113+
if (communityUrls.twitter) result.twitter = communityUrls.twitter
114+
if (communityUrls.github) result.github = communityUrls.github
115+
if (communityUrls.youtube) result.youtube = communityUrls.youtube
116+
if (communityUrls.discord) result.discord = communityUrls.discord
117+
if (communityUrls.reddit) result.reddit = communityUrls.reddit
118+
if (communityUrls.blog) result.blog = communityUrls.blog
119+
return result
95120
}

0 commit comments

Comments
 (0)