fix: 保持 Registry 客户端 Schema 信任摘要兼容 (#9)

This commit is contained in:
2026-09-22 00:56:56 +08:00
committed by GitHub
parent 7728203ed6
commit 33f3ae4a8a
13 changed files with 52 additions and 54 deletions

View File

@@ -0,0 +1,18 @@
/** Publication-only policy. Keep the byte-pinned authored client schema unchanged. */
const dynamicFields = new Set([
'stars', 'views', 'viewCount', 'visits', 'visitCount', 'downloads', 'downloadCount',
'rating', 'ratings', 'ratingCount', 'averageRating', 'popularity', 'usageCount',
'installCount', 'installedCount', 'activeUsers', 'installStatus', 'installedVersion',
'healthScore', 'resourceUsage', 'lastHealthCheck',
])
export function findStaticMetrics(value, prefix = '') {
if (!value || typeof value !== 'object' || Array.isArray(value)) return []
const findings = []
for (const [key, child] of Object.entries(value)) {
if (dynamicFields.has(key)) findings.push(prefix + key)
if (['metrics', 'statistics', 'stats', 'metadata'].includes(key)) {
findings.push(...findStaticMetrics(child, prefix + key + '.'))
}
}
return findings
}