()
| 18 | } |
| 19 | |
| 20 | export function getAvailableFields() { |
| 21 | const connection = state.connections[state.selectedConnectionId]; |
| 22 | if (!connection || !connection.messages) { |
| 23 | return []; |
| 24 | } |
| 25 | |
| 26 | const fieldsSet = new Set(); |
| 27 | |
| 28 | connection.messages.forEach(msg => { |
| 29 | try { |
| 30 | const parsed = JSON.parse(msg.data); |
| 31 | extractFields(parsed, '', fieldsSet); |
| 32 | } catch (e) { |
| 33 | // Not JSON, skip |
| 34 | } |
| 35 | }); |
| 36 | |
| 37 | return Array.from(fieldsSet).sort(); |
| 38 | } |
| 39 | |
| 40 | export function extractFields(obj, prefix = '', fields = new Set()) { |
| 41 | if (obj === null || obj === undefined) { |
no test coverage detected