UNPKG

dsl-builder

Version:

OpenSearch Query Builder - Extract from OpenSearch Dashboards

31 lines (30 loc) 1.32 kB
"use strict"; /* * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. * * Any modifications Copyright OpenSearch Contributors. See * GitHub history for details. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.getTitle = void 0; const utils_1 = require("../utils"); async function getTitle(client, indexPatternId, dataSourceIdToTitle) { const savedObject = (await client.get('index-pattern', indexPatternId)); if (savedObject.error) { throw new Error(`Unable to get index-pattern title: ${savedObject.error.message}`); } const dataSourceReference = (0, utils_1.getDataSourceReference)(savedObject.references); if (dataSourceReference) { const dataSourceId = dataSourceReference.id; if (dataSourceIdToTitle.has(dataSourceId)) { return (0, utils_1.concatDataSourceWithIndexPattern)(dataSourceIdToTitle.get(dataSourceId), savedObject.attributes.title); } } const getDataSource = async (id) => await client.get('data-source', id); return (0, utils_1.getIndexPatternTitle)(savedObject.attributes.title, savedObject.references, getDataSource); } exports.getTitle = getTitle;