MCPcopy Index your code
hub / github.com/simstudioai/sim / resolveLatest

Function resolveLatest

apps/sim/blocks/registry.ts:41–58  ·  view source on GitHub ↗

* Resolve the canonical (highest-version) block for a base type. Handles * versioned variants like `confluence_v2`: callers pass `confluence` and * receive the latest implementation. Returns the registry key alongside the * config so callers that need the canonical type identifier avoid re-derivi

(baseType: string)

Source from the content-addressed store, hash-verified

39 * it.
40 */
41function resolveLatest(baseType: string): { type: string; config: BlockConfig } | undefined {
42 const normalized = normalizeType(baseType)
43 const versionPattern = new RegExp(`^${normalized}_v(\\d+)$`)
44 let latestKey: string | undefined
45 let latestVersion = -1
46 for (const key of Object.keys(BLOCK_REGISTRY)) {
47 const match = key.match(versionPattern)
48 if (!match) continue
49 const version = Number.parseInt(match[1]!, 10)
50 if (version > latestVersion) {
51 latestVersion = version
52 latestKey = key
53 }
54 }
55 if (latestKey) return { type: latestKey, config: BLOCK_REGISTRY[latestKey]! }
56 const config = BLOCK_REGISTRY[normalized]
57 return config ? { type: normalized, config } : undefined
58}
59
60/**
61 * Resolve the canonical (highest-version) block for a base type. Handles

Callers 1

getLatestBlockFunction · 0.85

Calls 1

normalizeTypeFunction · 0.85

Tested by

no test coverage detected