@@ -19,6 +19,11 @@ export const securitySolutionIndexFieldsProvider = (): ISearchStrategy<
19
19
IndexFieldsStrategyRequest ,
20
20
IndexFieldsStrategyResponse
21
21
> => {
22
+ // require the fields once we actually need them, rather than ahead of time, and pass
23
+ // them to createFieldItem to reduce the amount of work done as much as possible
24
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
25
+ const beatFields : BeatFields = require ( '../../utils/beat_schema/fields' ) . fieldsBeat ;
26
+
22
27
return {
23
28
search : async ( context , request ) => {
24
29
const { elasticsearch } = context . core ;
@@ -40,6 +45,7 @@ export const securitySolutionIndexFieldsProvider = (): ISearchStrategy<
40
45
41
46
if ( ! request . onlyCheckIfIndicesExist ) {
42
47
indexFields = await formatIndexFields (
48
+ beatFields ,
43
49
responsesIndexFields . filter ( ( rif ) => rif !== false ) as FieldDescriptor [ ] [ ] ,
44
50
dedupeIndices
45
51
) ;
@@ -151,16 +157,12 @@ export const createFieldItem = (
151
157
* @param indexesAlias The index aliases such as filebeat-*
152
158
*/
153
159
export const formatFirstFields = async (
160
+ beatFields : BeatFields ,
154
161
responsesIndexFields : FieldDescriptor [ ] [ ] ,
155
162
indexesAlias : string [ ]
156
163
) : Promise < IndexField [ ] > => {
157
164
return new Promise ( ( resolve ) => {
158
165
setTimeout ( ( ) => {
159
- // require the fields once we actually need them, rather than ahead of time, and pass
160
- // them to createFieldItem to reduce the amount of work done as much as possible
161
- // eslint-disable-next-line @typescript-eslint/no-var-requires
162
- const beatFields : BeatFields = require ( '../../utils/beat_schema/fields' ) . fieldsBeat ;
163
-
164
166
resolve (
165
167
responsesIndexFields . reduce (
166
168
( accumulator : IndexField [ ] , indexFields : FieldDescriptor [ ] , indexesAliasIdx : number ) => {
@@ -229,10 +231,11 @@ export const formatSecondFields = async (fields: IndexField[]): Promise<IndexFie
229
231
* @param indexesAlias The index alias
230
232
*/
231
233
export const formatIndexFields = async (
234
+ beatFields : BeatFields ,
232
235
responsesIndexFields : FieldDescriptor [ ] [ ] ,
233
236
indexesAlias : string [ ]
234
237
) : Promise < IndexField [ ] > => {
235
- const fields = await formatFirstFields ( responsesIndexFields , indexesAlias ) ;
238
+ const fields = await formatFirstFields ( beatFields , responsesIndexFields , indexesAlias ) ;
236
239
const secondFields = await formatSecondFields ( fields ) ;
237
240
return secondFields ;
238
241
} ;
0 commit comments