"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getIndexPipelineParameters = void 0; var _fetch_connectors = require("../connectors/fetch_connectors"); var _get_default_pipeline = require("./get_default_pipeline"); /* * 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 getIndexPipelineParameters = async (indexName, client) => { // Get the default pipeline data and check for a custom pipeline in parallel // we want to throw the error if getDefaultPipeline() fails so we're not catching it on purpose const [defaultPipeline, connector, customPipelineResp] = await Promise.all([(0, _get_default_pipeline.getDefaultPipeline)(client), (0, _fetch_connectors.fetchConnectorByIndexName)(client, indexName), client.asCurrentUser.ingest.getPipeline({ id: `${indexName}` }).catch(() => null)]); if (connector && connector.pipeline) { return connector.pipeline; } let pipelineName = defaultPipeline.name; if (customPipelineResp && customPipelineResp[indexName]) { pipelineName = indexName; } return { ...defaultPipeline, name: pipelineName }; }; exports.getIndexPipelineParameters = getIndexPipelineParameters;