(item: ClientApiResponse)
| 200 | let primaryKey = 0 |
| 201 | |
| 202 | const parse = (item: ClientApiResponse): Client | undefined => { |
| 203 | primaryKey++; |
| 204 | const clientId = item.clientId.toLowerCase() |
| 205 | if (!clientId) { |
| 206 | errorCallback('parse', 'empty client id', ''); |
| 207 | return undefined; |
| 208 | } |
| 209 | |
| 210 | const matches = clientId.match(/(?<name>\w+)\/(?<raw>.+)/); |
| 211 | if (matches?.groups) { |
| 212 | const raw = parseRaw(clientId, { primaryKey, errorCallback: (entity, data, pk) => { |
| 213 | errorCallback(entity, data, `${pk}: "${clientId}"`) |
| 214 | }, raw: clientId }); |
| 215 | if (!raw) { |
| 216 | return undefined; |
| 217 | } |
| 218 | |
| 219 | if (raw.runtime) { |
| 220 | const runtimeName = raw.runtime.name || 'Unknown' |
| 221 | topRuntimes.set(runtimeName, (topRuntimes.get(runtimeName) || 0) + item.count) |
| 222 | } |
| 223 | |
| 224 | if (raw.os) { |
| 225 | const osName = raw.os.vendor || 'Unknown' |
| 226 | topOs.set(osName, (topOs.get(osName) || 0) + item.count) |
| 227 | } |
| 228 | |
| 229 | return { |
| 230 | primaryKey, |
| 231 | name: matches.groups.name, |
| 232 | count: item.count, |
| 233 | ...raw, |
| 234 | }; |
| 235 | } |
| 236 | |
| 237 | errorCallback('parse', item.clientId, ''); |
| 238 | return undefined; |
| 239 | }; |
| 240 | |
| 241 | const matchesFilters = (client: Client, filters?: Filter[]): boolean => { |
| 242 | if (!filters || !filters.length) { |
no test coverage detected