(transport: {
connection?: ConnectionAdapter
fetcher?: ChatFetcher
})
| 75 | } |
| 76 | |
| 77 | function resolveTransport(transport: { |
| 78 | connection?: ConnectionAdapter |
| 79 | fetcher?: ChatFetcher |
| 80 | }): ConnectionAdapter { |
| 81 | const { connection, fetcher } = transport |
| 82 | if (connection && fetcher) { |
| 83 | throw new Error( |
| 84 | 'ChatClient: pass either `connection` or `fetcher`, not both.', |
| 85 | ) |
| 86 | } |
| 87 | if (connection) return connection |
| 88 | if (fetcher) return fetcherToConnectionAdapter(fetcher) |
| 89 | throw new Error('ChatClient: either `connection` or `fetcher` is required.') |
| 90 | } |
| 91 | |
| 92 | export class ChatClient< |
| 93 | TTools extends ReadonlyArray<AnyClientTool> = any, |
no test coverage detected