[ResponseOps][Rules] Move the params of tracking containment rule type to @kbn/response-ops-rule-params package (#210955)

Connected with https://github.com/elastic/kibana/issues/195188

## Summary

- Moved the params of tracking containment rule type to
`@kbn/response-ops-rule-params/geo_containment` package

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Georgiana-Andreea Onoleață 2025-02-14 12:29:18 +02:00 committed by GitHub
parent 0d4be1db49
commit d1d1b6b063
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 56 additions and 19 deletions

View file

@ -0,0 +1,14 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export { trackingContainmentRuleParamsSchema } from './latest';
export { trackingContainmentRuleParamsSchema as trackingContainmentRuleParamsSchemaV1 } from './latest';
export type { TrackingContainmentRuleParams } from './latest';
export type { TrackingContainmentRuleParams as TrackingContainmentRuleParamsV1 } from './latest';

View file

@ -0,0 +1,10 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
export * from './v1';

View file

@ -0,0 +1,27 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { schema, TypeOf } from '@kbn/config-schema';
export const trackingContainmentRuleParamsSchema = schema.object({
index: schema.string({ minLength: 1 }),
indexId: schema.string({ minLength: 1 }),
geoField: schema.string({ minLength: 1 }),
entity: schema.string({ minLength: 1 }),
dateField: schema.string({ minLength: 1 }),
boundaryType: schema.string({ minLength: 1 }),
boundaryIndexTitle: schema.string({ minLength: 1 }),
boundaryIndexId: schema.string({ minLength: 1 }),
boundaryGeoField: schema.string({ minLength: 1 }),
boundaryNameField: schema.maybe(schema.string({ minLength: 1 })),
indexQuery: schema.maybe(schema.any({})),
boundaryIndexQuery: schema.maybe(schema.any({})),
});
export type TrackingContainmentRuleParams = TypeOf<typeof trackingContainmentRuleParamsSchema>;

View file

@ -6,10 +6,10 @@
*/
import { i18n } from '@kbn/i18n';
import { schema } from '@kbn/config-schema';
import { SavedObjectReference, DEFAULT_APP_CATEGORIES } from '@kbn/core/server';
import { RuleParamsAndRefs } from '@kbn/alerting-plugin/server';
import { STACK_ALERTS_FEATURE_ID } from '@kbn/rule-data-utils';
import { trackingContainmentRuleParamsSchema } from '@kbn/response-ops-rule-params/geo_containment';
import type {
GeoContainmentRuleType,
GeoContainmentExtractedRuleParams,
@ -90,21 +90,6 @@ const actionVariables = {
],
};
export const ParamsSchema = schema.object({
index: schema.string({ minLength: 1 }),
indexId: schema.string({ minLength: 1 }),
geoField: schema.string({ minLength: 1 }),
entity: schema.string({ minLength: 1 }),
dateField: schema.string({ minLength: 1 }),
boundaryType: schema.string({ minLength: 1 }),
boundaryIndexTitle: schema.string({ minLength: 1 }),
boundaryIndexId: schema.string({ minLength: 1 }),
boundaryGeoField: schema.string({ minLength: 1 }),
boundaryNameField: schema.maybe(schema.string({ minLength: 1 })),
indexQuery: schema.maybe(schema.any({})),
boundaryIndexQuery: schema.maybe(schema.any({})),
});
export function extractEntityAndBoundaryReferences(params: GeoContainmentRuleParams): {
params: GeoContainmentExtractedRuleParams;
references: SavedObjectReference[];
@ -183,12 +168,12 @@ export function getRuleType(): GeoContainmentRuleType {
category: DEFAULT_APP_CATEGORIES.management.id,
producer: STACK_ALERTS_FEATURE_ID,
validate: {
params: ParamsSchema,
params: trackingContainmentRuleParamsSchema,
},
schemas: {
params: {
type: 'config-schema',
schema: ParamsSchema,
schema: trackingContainmentRuleParamsSchema,
},
},
actionVariables,

View file

@ -55,7 +55,8 @@
"@kbn/task-manager-plugin",
"@kbn/core-logging-server-mocks",
"@kbn/core-saved-objects-server",
"@kbn/alerting-rule-utils"
"@kbn/alerting-rule-utils",
"@kbn/response-ops-rule-params"
],
"exclude": [
"target/**/*",