"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.registerResolveRoute = void 0; var _configSchema = require("@kbn/config-schema"); var _utils = require("./utils"); /* * 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 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ const registerResolveRoute = (router, { config, coreUsageData, logger }) => { const { allowHttpApiAccess } = config; router.get({ path: '/resolve/{type}/{id}', validate: { params: _configSchema.schema.object({ type: _configSchema.schema.string(), id: _configSchema.schema.string() }) } }, router.handleLegacyErrors(async (context, req, res) => { (0, _utils.logWarnOnExternalRequest)({ method: 'get', path: '/api/saved_objects/resolve/{type}/{id}', req, logger }); const { type, id } = req.params; const { savedObjects } = await context.core; const usageStatsClient = coreUsageData.getClient(); usageStatsClient.incrementSavedObjectsResolve({ request: req }).catch(() => {}); if (!allowHttpApiAccess) { (0, _utils.throwIfTypeNotVisibleByAPI)(type, savedObjects.typeRegistry); } const result = await savedObjects.client.resolve(type, id, { migrationVersionCompatibility: 'compatible' }); return res.ok({ body: result }); })); }; exports.registerResolveRoute = registerResolveRoute;