"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.createRuleDataSchema = void 0;
var _configSchema = require("@kbn/config-schema");
var _validation = require("../../../validation");
var _schemas = require("../../../schemas");
/*
 * 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 createRuleDataSchema = _configSchema.schema.object({
  name: _configSchema.schema.string(),
  alertTypeId: _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.validateDuration
  }))),
  params: _configSchema.schema.recordOf(_configSchema.schema.string(), _configSchema.schema.maybe(_configSchema.schema.any()), {
    defaultValue: {}
  }),
  schedule: _configSchema.schema.object({
    interval: _configSchema.schema.string({
      validate: _validation.validateDuration
    })
  }),
  actions: _configSchema.schema.arrayOf(_configSchema.schema.object({
    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(_configSchema.schema.object({
      summary: _configSchema.schema.boolean(),
      notifyWhen: _schemas.notifyWhenSchema,
      throttle: _configSchema.schema.nullable(_configSchema.schema.string({
        validate: _validation.validateDuration
      }))
    })),
    uuid: _configSchema.schema.maybe(_configSchema.schema.string()),
    alertsFilter: _configSchema.schema.maybe(_schemas.actionAlertsFilterSchema)
  }), {
    defaultValue: []
  }),
  notifyWhen: _configSchema.schema.maybe(_configSchema.schema.nullable(_schemas.notifyWhenSchema))
});
exports.createRuleDataSchema = createRuleDataSchema;