Skip to content

Commit

Permalink
[ResponseOps][Rules] Move the params of tracking containment rule typ…
Browse files Browse the repository at this point in the history
…e to @kbn/response-ops-rule-params package (elastic#210955)

Connected with elastic#195188

## Summary

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

---------

Co-authored-by: kibanamachine <[email protected]>
  • Loading branch information
georgianaonoleata1904 and kibanamachine authored Feb 14, 2025
1 parent 0d4be1d commit d1d1b6b
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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>;
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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[];
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion x-pack/platform/plugins/shared/stack_alerts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/**/*",
Expand Down

0 comments on commit d1d1b6b

Please sign in to comment.