"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.pipelineFormSchema = void 0; var _i18n = require("@kbn/i18n"); var _i18nReact = require("@kbn/i18n-react"); var _eui = require("@elastic/eui"); var _react = _interopRequireDefault(require("react")); var _utils = require("../../lib/utils"); var _shared_imports = require("../../../shared_imports"); /* * 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 { emptyField, isJsonField } = _shared_imports.fieldValidators; const { toInt } = _shared_imports.fieldFormatters; const pipelineFormSchema = { name: { type: _shared_imports.FIELD_TYPES.TEXT, label: _i18n.i18n.translate('xpack.ingestPipelines.form.nameFieldLabel', { defaultMessage: 'Name' }), validations: [{ validator: emptyField(_i18n.i18n.translate('xpack.ingestPipelines.form.pipelineNameRequiredError', { defaultMessage: 'Name is required.' })) }] }, description: { type: _shared_imports.FIELD_TYPES.TEXTAREA, label: _i18n.i18n.translate('xpack.ingestPipelines.form.descriptionFieldLabel', { defaultMessage: 'Description (optional)' }) }, version: { type: _shared_imports.FIELD_TYPES.NUMBER, label: _i18n.i18n.translate('xpack.ingestPipelines.form.versionFieldLabel', { defaultMessage: 'Version (optional)' }), formatters: [toInt] }, _meta: { label: _i18n.i18n.translate('xpack.ingestPipelines.form.metaFieldLabel', { defaultMessage: '_meta field data (optional)' }), helpText: /*#__PURE__*/_react.default.createElement(_i18nReact.FormattedMessage, { id: "xpack.ingestPipelines.form.metaHelpText", defaultMessage: "Use JSON format: {code}", values: { code: /*#__PURE__*/_react.default.createElement(_eui.EuiCode, null, JSON.stringify({ arbitrary_data: 'anything_goes' })) } }), serializer: value => { const result = (0, _utils.parseJson)(value, false); // If an empty object was passed, strip out this value entirely. if (!Object.keys(result).length) { return undefined; } return result; }, deserializer: value => (0, _utils.stringifyJson)(value, false), validations: [{ validator: isJsonField(_i18n.i18n.translate('xpack.ingestPipelines.form.validation.metaJsonError', { defaultMessage: 'The input is not valid.' }), { allowEmptyString: true }) }] } }; exports.pipelineFormSchema = pipelineFormSchema;