mirror of
https://git.openapi.site/https://github.com/desirecore/registry.git
synced 2026-10-21 02:13:28 +08:00
fix: 保持 Registry 客户端 Schema 信任摘要兼容 (#9)
This commit is contained in:
18
scripts/catalog/static-metadata.mjs
Normal file
18
scripts/catalog/static-metadata.mjs
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user