Skip to content

Commit 84b7fef

Browse files
committed
undid some of the type moves into common that werent needed, cleaning up PR a bit
1 parent 9a42861 commit 84b7fef

File tree

8 files changed

+64
-61
lines changed

8 files changed

+64
-61
lines changed

x-pack/plugins/security_solution/common/detection_engine/types.ts

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -53,57 +53,3 @@ export interface EqlSearchResponse<T> {
5353
events?: Array<BaseHit<T>>;
5454
};
5555
}
56-
57-
export interface ShardsResponse {
58-
total: number;
59-
successful: number;
60-
failed: number;
61-
skipped: number;
62-
failures?: ShardError[];
63-
}
64-
65-
export interface ShardError {
66-
shard: number;
67-
index: string;
68-
node: string;
69-
reason: {
70-
type: string;
71-
reason: string;
72-
index_uuid: string;
73-
index: string;
74-
caused_by: {
75-
type: string;
76-
reason: string;
77-
};
78-
};
79-
}
80-
81-
export interface SearchResponse<T> {
82-
took: number;
83-
timed_out: boolean;
84-
_scroll_id?: string;
85-
_shards: ShardsResponse;
86-
hits: {
87-
total: TotalValue | number;
88-
max_score: number;
89-
hits: Array<
90-
BaseHit<T> & {
91-
_type: string;
92-
_score: number;
93-
_version?: number;
94-
_explanation?: Explanation;
95-
fields?: string[];
96-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
97-
highlight?: any;
98-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
99-
inner_hits?: any;
100-
matched_queries?: string[];
101-
sort?: string[];
102-
}
103-
>;
104-
};
105-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
106-
aggregations?: any;
107-
}
108-
109-
export type SearchHit = SearchResponse<object>['hits']['hits'][0];

x-pack/plugins/security_solution/server/lib/detection_engine/routes/__mocks__/request_responses.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
DETECTION_ENGINE_PREPACKAGED_URL,
1818
DETECTION_ENGINE_EQL_VALIDATION_URL,
1919
} from '../../../../../common/constants';
20+
import { ShardsResponse } from '../../../types';
2021
import {
2122
RuleAlertType,
2223
IRuleSavedAttributesSavedObjectAttributes,
@@ -29,7 +30,7 @@ import { SetSignalsStatusSchemaDecoded } from '../../../../../common/detection_e
2930
import { getCreateRulesSchemaMock } from '../../../../../common/detection_engine/schemas/request/create_rules_schema.mock';
3031
import { getListArrayMock } from '../../../../../common/detection_engine/schemas/types/lists.mock';
3132
import { getEqlValidationSchemaMock } from '../../../../../common/detection_engine/schemas/request/eql_validation_schema.mock';
32-
import { EqlSearchResponse, ShardsResponse } from '../../../../../common/detection_engine/types';
33+
import { EqlSearchResponse } from '../../../../../common/detection_engine/types';
3334

3435
export const typicalSetStatusSignalByIdsPayload = (): SetSignalsStatusSchemaDecoded => ({
3536
signal_ids: ['somefakeid1', 'somefakeid2'],

x-pack/plugins/security_solution/server/lib/detection_engine/signals/single_search_after.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import {
1111
} from './__mocks__/es_results';
1212
import { singleSearchAfter } from './single_search_after';
1313
import { alertsMock, AlertServicesMock } from '../../../../../alerts/server/mocks';
14+
import { ShardError } from '../../types';
1415
import { buildRuleMessageFactory } from './rule_messages';
15-
import { ShardError } from '../../../../common/detection_engine/types';
1616

1717
const buildRuleMessage = buildRuleMessageFactory({
1818
id: 'fake id',

x-pack/plugins/security_solution/server/lib/detection_engine/signals/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import {
1414
AlertExecutorOptions,
1515
AlertServices,
1616
} from '../../../../../alerts/server';
17+
import { SearchResponse } from '../../types';
1718
import {
18-
SearchResponse,
1919
EqlSearchResponse,
2020
BaseHit,
2121
RuleAlertAction,

x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import {
4646
sampleDocSearchResultsNoSortIdNoHits,
4747
repeatedSearchResultsWithSortId,
4848
} from './__mocks__/es_results';
49-
import { ShardError } from '../../../../common/detection_engine/types';
49+
import { ShardError } from '../../types';
5050

5151
const buildRuleMessage = buildRuleMessageFactory({
5252
id: 'fake id',

x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import { BuildRuleMessage } from './rule_messages';
2626
import { parseScheduleDates } from '../../../../common/detection_engine/parse_schedule_dates';
2727
import { hasLargeValueList } from '../../../../common/detection_engine/utils';
2828
import { MAX_EXCEPTION_LIST_SIZE } from '../../../../../lists/common/constants';
29-
import { ShardError } from '../../../../common/detection_engine/types';
29+
import { ShardError } from '../../types';
30+
3031
interface SortExceptionsReturn {
3132
exceptionsWithValueLists: ExceptionListItemSchema[];
3233
exceptionsWithoutValueLists: ExceptionListItemSchema[];

x-pack/plugins/security_solution/server/lib/hosts/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import {
1717
DocValueFieldsInput,
1818
} from '../../graphql/types';
1919
import { FrameworkRequest, RequestOptionsPaginated } from '../framework';
20-
import { Hit, Hits } from '../types';
21-
import { SearchHit, TotalValue } from '../../../common/detection_engine/types';
20+
import { Hit, Hits, SearchHit } from '../types';
21+
import { TotalValue } from '../../../common/detection_engine/types';
2222

2323
export interface HostsAdapter {
2424
getHosts(req: FrameworkRequest, options: HostsRequestOptions): Promise<HostsData>;

x-pack/plugins/security_solution/server/lib/types.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { Sources } from './sources';
1616
import { Note } from './note/saved_object';
1717
import { PinnedEvent } from './pinned_event/saved_object';
1818
import { Timeline } from './timeline/saved_object';
19+
import { TotalValue, BaseHit, Explanation } from '../../common/detection_engine/types';
1920

2021
export * from './hosts';
2122

@@ -39,6 +40,60 @@ export interface SiemContext {
3940
user: AuthenticatedUser | null;
4041
}
4142

43+
export interface ShardsResponse {
44+
total: number;
45+
successful: number;
46+
failed: number;
47+
skipped: number;
48+
failures?: ShardError[];
49+
}
50+
51+
export interface ShardError {
52+
shard: number;
53+
index: string;
54+
node: string;
55+
reason: {
56+
type: string;
57+
reason: string;
58+
index_uuid: string;
59+
index: string;
60+
caused_by: {
61+
type: string;
62+
reason: string;
63+
};
64+
};
65+
}
66+
67+
export interface SearchResponse<T> {
68+
took: number;
69+
timed_out: boolean;
70+
_scroll_id?: string;
71+
_shards: ShardsResponse;
72+
hits: {
73+
total: TotalValue | number;
74+
max_score: number;
75+
hits: Array<
76+
BaseHit<T> & {
77+
_type: string;
78+
_score: number;
79+
_version?: number;
80+
_explanation?: Explanation;
81+
fields?: string[];
82+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
83+
highlight?: any;
84+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
85+
inner_hits?: any;
86+
matched_queries?: string[];
87+
sort?: string[];
88+
}
89+
>;
90+
};
91+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
92+
aggregations?: any;
93+
}
94+
95+
export type SearchHit = SearchResponse<object>['hits']['hits'][0];
96+
4297
export interface TermAggregation {
4398
[agg: string]: {
4499
buckets: Array<{

0 commit comments

Comments
 (0)