( config: ManagedKimiConfigShape, entries: Record<string, CustomRegistryProviderEntry>, source: CustomRegistrySource, )
| 384 | * registry". |
| 385 | */ |
| 386 | export function applyCustomRegistryEntries( |
| 387 | config: ManagedKimiConfigShape, |
| 388 | entries: Record<string, CustomRegistryProviderEntry>, |
| 389 | source: CustomRegistrySource, |
| 390 | ): void { |
| 391 | const surviving = new Set(Object.values(entries).map((entry) => entry.id)); |
| 392 | for (const [providerId, provider] of Object.entries(config.providers)) { |
| 393 | if (surviving.has(providerId)) continue; |
| 394 | if (!isRecord(provider)) continue; |
| 395 | const existingSource = provider['source']; |
| 396 | if ( |
| 397 | isRecord(existingSource) && |
| 398 | existingSource['kind'] === 'apiJson' && |
| 399 | existingSource['url'] === source.url |
| 400 | ) { |
| 401 | removeCustomRegistryProvider(config, providerId); |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | for (const entry of Object.values(entries)) { |
| 406 | if (entry.id in config.providers) { |
| 407 | removeCustomRegistryProvider(config, entry.id); |
| 408 | } |
| 409 | applyCustomRegistryProvider(config, entry, source); |
| 410 | } |
| 411 | } |
no test coverage detected