* 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)
| 39 | * it. |
| 40 | */ |
| 41 | function 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 |
no test coverage detected