( drivers?: ReadonlyArray<ConnectionStringDriver>, )
| 92 | } |
| 93 | |
| 94 | function buildProtocolRegistry( |
| 95 | drivers?: ReadonlyArray<ConnectionStringDriver>, |
| 96 | ): Map<string, ResolvedDriver> { |
| 97 | const registry = new Map<string, ResolvedDriver>(); |
| 98 | |
| 99 | for (const driver of resolveDrivers(drivers)) { |
| 100 | const local = isLocalDriver(driver.capabilities); |
| 101 | const canImport = |
| 102 | local || connectionStringImportEnabled(driver.capabilities); |
| 103 | |
| 104 | if (!canImport) continue; |
| 105 | |
| 106 | const idProtocol = normalizeProtocol(driver.id); |
| 107 | if (idProtocol) { |
| 108 | registry.set(idProtocol, { id: driver.id, local }); |
| 109 | } |
| 110 | |
| 111 | const exampleProtocol = getProtocolFromExample( |
| 112 | driver.capabilities?.connection_string_example ?? |
| 113 | driver.capabilities?.connectionStringExample, |
| 114 | ); |
| 115 | |
| 116 | if (exampleProtocol) { |
| 117 | registry.set(exampleProtocol, { id: driver.id, local }); |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | // Second pass: expand well-known aliases without overriding protocols |
| 122 | // explicitly registered by another driver. |
| 123 | for (const [protocol, resolved] of Array.from(registry.entries())) { |
| 124 | for (const alias of getProtocolAliases(protocol)) { |
| 125 | if (!registry.has(alias)) { |
| 126 | registry.set(alias, resolved); |
| 127 | } |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | return registry; |
| 132 | } |
| 133 | |
| 134 | export function getSupportedConnectionStringProtocols( |
| 135 | drivers?: ReadonlyArray<ConnectionStringDriver>, |
no test coverage detected