"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getRowsWithPins = exports.getAllFields = void 0; /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ const getAllFields = metadata => { var _metadata$info$host, _metadata$info$host2, _metadata$info$host3, _metadata$info$host4, _metadata$info$host5, _metadata$info$host6, _metadata$info$host7, _metadata$info$host7$, _metadata$info$host8, _metadata$info$host8$, _metadata$info$host9, _metadata$info$host9$, _metadata$info$host10, _metadata$info$host11, _metadata$info$host12, _metadata$info$host13, _metadata$info$host14, _metadata$info$host15, _metadata$info$cloud, _metadata$info$cloud$, _metadata$info$cloud2, _metadata$info$cloud3, _metadata$info$cloud4, _metadata$info$cloud5, _metadata$info$cloud6, _metadata$info$cloud7, _metadata$info$cloud8, _metadata$info$cloud9, _metadata$info$cloud10, _metadata$info$cloud11, _metadata$info$cloud12, _metadata$info$agent, _metadata$info$agent2, _metadata$info$agent3; if (!(metadata !== null && metadata !== void 0 && metadata.info)) return []; return prune([{ name: 'host.architecture', value: (_metadata$info$host = metadata.info.host) === null || _metadata$info$host === void 0 ? void 0 : _metadata$info$host.architecture }, { name: 'host.hostname', value: (_metadata$info$host2 = metadata.info.host) === null || _metadata$info$host2 === void 0 ? void 0 : _metadata$info$host2.name }, { name: 'host.id', value: (_metadata$info$host3 = metadata.info.host) === null || _metadata$info$host3 === void 0 ? void 0 : _metadata$info$host3.id }, { name: 'host.ip', value: (_metadata$info$host4 = metadata.info.host) === null || _metadata$info$host4 === void 0 ? void 0 : _metadata$info$host4.ip }, { name: 'host.mac', value: (_metadata$info$host5 = metadata.info.host) === null || _metadata$info$host5 === void 0 ? void 0 : _metadata$info$host5.mac }, { name: 'host.name', value: (_metadata$info$host6 = metadata.info.host) === null || _metadata$info$host6 === void 0 ? void 0 : _metadata$info$host6.name }, { name: 'host.os.build', value: (_metadata$info$host7 = metadata.info.host) === null || _metadata$info$host7 === void 0 ? void 0 : (_metadata$info$host7$ = _metadata$info$host7.os) === null || _metadata$info$host7$ === void 0 ? void 0 : _metadata$info$host7$.build }, { name: 'host.os.family', value: (_metadata$info$host8 = metadata.info.host) === null || _metadata$info$host8 === void 0 ? void 0 : (_metadata$info$host8$ = _metadata$info$host8.os) === null || _metadata$info$host8$ === void 0 ? void 0 : _metadata$info$host8$.family }, { name: 'host.os.name', value: (_metadata$info$host9 = metadata.info.host) === null || _metadata$info$host9 === void 0 ? void 0 : (_metadata$info$host9$ = _metadata$info$host9.os) === null || _metadata$info$host9$ === void 0 ? void 0 : _metadata$info$host9$.name }, { name: 'host.os.kernel', value: (_metadata$info$host10 = metadata.info.host) === null || _metadata$info$host10 === void 0 ? void 0 : (_metadata$info$host11 = _metadata$info$host10.os) === null || _metadata$info$host11 === void 0 ? void 0 : _metadata$info$host11.kernel }, { name: 'host.os.platform', value: (_metadata$info$host12 = metadata.info.host) === null || _metadata$info$host12 === void 0 ? void 0 : (_metadata$info$host13 = _metadata$info$host12.os) === null || _metadata$info$host13 === void 0 ? void 0 : _metadata$info$host13.platform }, { name: 'host.os.version', value: (_metadata$info$host14 = metadata.info.host) === null || _metadata$info$host14 === void 0 ? void 0 : (_metadata$info$host15 = _metadata$info$host14.os) === null || _metadata$info$host15 === void 0 ? void 0 : _metadata$info$host15.version }, { name: 'cloud.account.id', value: (_metadata$info$cloud = metadata.info.cloud) === null || _metadata$info$cloud === void 0 ? void 0 : (_metadata$info$cloud$ = _metadata$info$cloud.account) === null || _metadata$info$cloud$ === void 0 ? void 0 : _metadata$info$cloud$.id }, { name: 'cloud.account.name', value: (_metadata$info$cloud2 = metadata.info.cloud) === null || _metadata$info$cloud2 === void 0 ? void 0 : (_metadata$info$cloud3 = _metadata$info$cloud2.account) === null || _metadata$info$cloud3 === void 0 ? void 0 : _metadata$info$cloud3.name }, { name: 'cloud.availability_zone', value: (_metadata$info$cloud4 = metadata.info.cloud) === null || _metadata$info$cloud4 === void 0 ? void 0 : _metadata$info$cloud4.availability_zone }, { name: 'cloud.instance.id', value: (_metadata$info$cloud5 = metadata.info.cloud) === null || _metadata$info$cloud5 === void 0 ? void 0 : (_metadata$info$cloud6 = _metadata$info$cloud5.instance) === null || _metadata$info$cloud6 === void 0 ? void 0 : _metadata$info$cloud6.id }, { name: 'cloud.instance.name', value: (_metadata$info$cloud7 = metadata.info.cloud) === null || _metadata$info$cloud7 === void 0 ? void 0 : (_metadata$info$cloud8 = _metadata$info$cloud7.instance) === null || _metadata$info$cloud8 === void 0 ? void 0 : _metadata$info$cloud8.name }, { name: 'cloud.machine.type', value: (_metadata$info$cloud9 = metadata.info.cloud) === null || _metadata$info$cloud9 === void 0 ? void 0 : (_metadata$info$cloud10 = _metadata$info$cloud9.machine) === null || _metadata$info$cloud10 === void 0 ? void 0 : _metadata$info$cloud10.type }, { name: 'cloud.provider', value: (_metadata$info$cloud11 = metadata.info.cloud) === null || _metadata$info$cloud11 === void 0 ? void 0 : _metadata$info$cloud11.provider }, { name: 'cloud.region', value: (_metadata$info$cloud12 = metadata.info.cloud) === null || _metadata$info$cloud12 === void 0 ? void 0 : _metadata$info$cloud12.region }, { name: 'agent.id', value: (_metadata$info$agent = metadata.info.agent) === null || _metadata$info$agent === void 0 ? void 0 : _metadata$info$agent.id }, { name: 'agent.version', value: (_metadata$info$agent2 = metadata.info.agent) === null || _metadata$info$agent2 === void 0 ? void 0 : _metadata$info$agent2.version }, { name: 'agent.policy', value: (_metadata$info$agent3 = metadata.info.agent) === null || _metadata$info$agent3 === void 0 ? void 0 : _metadata$info$agent3.policy }]); }; exports.getAllFields = getAllFields; const prune = fields => fields.filter(f => !!f.value); const getRowsWithPins = (rows, pinnedItems) => { if (pinnedItems.length > 0) { const { pinned, other } = rows.reduce((acc, row) => { (pinnedItems.includes(row.name) ? acc.pinned : acc.other).push(row); return acc; }, { pinned: [], other: [] }); return [...pinned, ...other]; } }; exports.getRowsWithPins = getRowsWithPins;