Skip to content

Commit

Permalink
Fix IRuleStatusSOAttributes
Browse files Browse the repository at this point in the history
  • Loading branch information
banderror committed Dec 30, 2021
1 parent 5068c1d commit eb69bde
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ import {
DETECTION_ENGINE_RULES_BULK_ACTION,
INTERNAL_DETECTION_ENGINE_RULE_STATUS_URL,
} from '../../../../../common/constants';
import {
RuleAlertType,
IRuleSavedAttributesSavedObjectAttributes,
HapiReadableStream,
IRuleStatusSOAttributes,
} from '../../rules/types';
import { RuleAlertType, HapiReadableStream, IRuleStatusSOAttributes } from '../../rules/types';
import { requestMock } from './request';
import { QuerySignalsSchemaDecoded } from '../../../../../common/detection_engine/schemas/request/query_signals_index_schema';
import { SetSignalsStatusSchemaDecoded } from '../../../../../common/detection_engine/schemas/request/set_signal_status_schema';
Expand Down Expand Up @@ -469,7 +464,7 @@ export const getMockPrivilegesResult = () => ({
});

export const getEmptySavedObjectsResponse =
(): SavedObjectsFindResponse<IRuleSavedAttributesSavedObjectAttributes> => ({
(): SavedObjectsFindResponse<IRuleStatusSOAttributes> => ({
page: 1,
per_page: 1,
total: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { SavedObjectsFindResponse } from 'kibana/server';

import { rulesClientMock } from '../../../../../alerting/server/mocks';
import { IRuleSavedAttributesSavedObjectAttributes, IRuleStatusSOAttributes } from '../rules/types';
import { IRuleStatusSOAttributes } from '../rules/types';
import { BadRequestError } from '@kbn/securitysolution-es-utils';
import {
transformBulkError,
Expand Down Expand Up @@ -94,7 +94,7 @@ describe.each([
// Array accessors can result in undefined but
// this is not represented in typescript for some reason,
// https://github.com/Microsoft/TypeScript/issues/11122
const values: SavedObjectsFindResponse<IRuleSavedAttributesSavedObjectAttributes> = {
const values: SavedObjectsFindResponse<IRuleStatusSOAttributes> = {
page: 0,
per_page: 5,
total: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from 'kibana/server';
import { isString } from 'lodash/fp';
import { truncateMessage } from '../../rule_execution_log';
import { IRuleSavedAttributesSavedObjectAttributes } from '../types';
import { IRuleStatusSOAttributes } from '../types';
// eslint-disable-next-line no-restricted-imports
import { legacyGetRuleReference } from './legacy_utils';

Expand Down Expand Up @@ -45,8 +45,8 @@ export const truncateMessageFields: SavedObjectMigrationFn<Record<string, unknow
* @returns The document migrated with saved object references
*/
export const legacyMigrateRuleAlertIdSOReferences = (
doc: SavedObjectUnsanitizedDoc<IRuleSavedAttributesSavedObjectAttributes>
): SavedObjectSanitizedDoc<IRuleSavedAttributesSavedObjectAttributes> => {
doc: SavedObjectUnsanitizedDoc<IRuleStatusSOAttributes>
): SavedObjectSanitizedDoc<IRuleStatusSOAttributes> => {
const { alertId, ...otherAttributes } = doc.attributes;
const existingReferences = doc.references ?? [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ import { IRuleExecutionLogClient } from '../rule_execution_log/types';

export type RuleAlertType = SanitizedAlert<RuleParams>;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export interface IRuleStatusSOAttributes extends Record<string, any> {
export interface IRuleStatusSOAttributes extends SavedObjectAttributes {
statusDate: StatusDate;
lastFailureAt: LastFailureAt | null | undefined;
lastFailureMessage: LastFailureMessage | null | undefined;
Expand Down Expand Up @@ -142,10 +141,6 @@ export interface RuleStatusResponse {
};
}

export interface IRuleSavedAttributesSavedObjectAttributes
extends IRuleStatusSOAttributes,
SavedObjectAttributes {}

export interface IRuleStatusSavedObject {
type: string;
id: string;
Expand Down

0 comments on commit eb69bde

Please sign in to comment.