"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.notifyWhenSchema = exports.createParamsSchema = exports.createBodySchema = exports.actionSchema = exports.actionFrequencySchema = exports.actionAlertsFilterSchema = void 0; var _configSchema = require("@kbn/config-schema"); var _response = require("../../../response"); var _validation = require("../../../validation"); /* * 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 notifyWhenSchema = _configSchema.schema.oneOf([_configSchema.schema.literal(_response.ruleNotifyWhenV1.CHANGE), _configSchema.schema.literal(_response.ruleNotifyWhenV1.ACTIVE), _configSchema.schema.literal(_response.ruleNotifyWhenV1.THROTTLE)], { validate: _validation.validateNotifyWhenV1 }); exports.notifyWhenSchema = notifyWhenSchema; const actionFrequencySchema = _configSchema.schema.object({ summary: _configSchema.schema.boolean(), notify_when: notifyWhenSchema, throttle: _configSchema.schema.nullable(_configSchema.schema.string({ validate: _validation.validateDurationV1 })) }); exports.actionFrequencySchema = actionFrequencySchema; const actionAlertsFilterSchema = _configSchema.schema.object({ query: _configSchema.schema.maybe(_configSchema.schema.object({ kql: _configSchema.schema.string(), filters: _configSchema.schema.arrayOf(_configSchema.schema.object({ query: _configSchema.schema.maybe(_configSchema.schema.recordOf(_configSchema.schema.string(), _configSchema.schema.any())), meta: _configSchema.schema.recordOf(_configSchema.schema.string(), _configSchema.schema.any()), state$: _configSchema.schema.maybe(_configSchema.schema.object({ store: _configSchema.schema.string() })) })), dsl: _configSchema.schema.maybe(_configSchema.schema.string()) })), timeframe: _configSchema.schema.maybe(_configSchema.schema.object({ days: _configSchema.schema.arrayOf(_configSchema.schema.oneOf([_configSchema.schema.literal(1), _configSchema.schema.literal(2), _configSchema.schema.literal(3), _configSchema.schema.literal(4), _configSchema.schema.literal(5), _configSchema.schema.literal(6), _configSchema.schema.literal(7)])), hours: _configSchema.schema.object({ start: _configSchema.schema.string({ validate: _validation.validateHoursV1 }), end: _configSchema.schema.string({ validate: _validation.validateHoursV1 }) }), timezone: _configSchema.schema.string({ validate: _validation.validateTimezoneV1 }) })) }); exports.actionAlertsFilterSchema = actionAlertsFilterSchema; const actionSchema = _configSchema.schema.object({ uuid: _configSchema.schema.maybe(_configSchema.schema.string()), group: _configSchema.schema.string(), id: _configSchema.schema.string(), actionTypeId: _configSchema.schema.maybe(_configSchema.schema.string()), params: _configSchema.schema.recordOf(_configSchema.schema.string(), _configSchema.schema.maybe(_configSchema.schema.any()), { defaultValue: {} }), frequency: _configSchema.schema.maybe(actionFrequencySchema), alerts_filter: _configSchema.schema.maybe(actionAlertsFilterSchema) }); exports.actionSchema = actionSchema; const createBodySchema = _configSchema.schema.object({ name: _configSchema.schema.string(), rule_type_id: _configSchema.schema.string(), enabled: _configSchema.schema.boolean({ defaultValue: true }), consumer: _configSchema.schema.string(), tags: _configSchema.schema.arrayOf(_configSchema.schema.string(), { defaultValue: [] }), throttle: _configSchema.schema.maybe(_configSchema.schema.nullable(_configSchema.schema.string({ validate: _validation.validateDurationV1 }))), params: _configSchema.schema.recordOf(_configSchema.schema.string(), _configSchema.schema.maybe(_configSchema.schema.any()), { defaultValue: {} }), schedule: _configSchema.schema.object({ interval: _configSchema.schema.string({ validate: _validation.validateDurationV1 }) }), actions: _configSchema.schema.arrayOf(actionSchema, { defaultValue: [] }), notify_when: _configSchema.schema.maybe(_configSchema.schema.nullable(notifyWhenSchema)) }); exports.createBodySchema = createBodySchema; const createParamsSchema = _configSchema.schema.object({ id: _configSchema.schema.maybe(_configSchema.schema.string()) }); exports.createParamsSchema = createParamsSchema;