@@ -18,6 +18,30 @@ interface SuggestedIndex {
18
18
weight ?: number ;
19
19
}
20
20
21
+ interface SuggestedIndexesResponse {
22
+ content : {
23
+ suggestedIndexes ?: SuggestedIndex [ ] ;
24
+ } ;
25
+ }
26
+
27
+ interface DropIndexesResponse {
28
+ content : {
29
+ hiddenIndexes ?: DropIndexSuggestion [ ] ;
30
+ redundantIndexes ?: DropIndexSuggestion [ ] ;
31
+ unusedIndexes ?: DropIndexSuggestion [ ] ;
32
+ } ;
33
+ }
34
+
35
+ interface SchemaAdviceResponse {
36
+ content : {
37
+ recommendations ?: SchemaRecommendation [ ] ;
38
+ } ;
39
+ }
40
+
41
+ interface SlowQueriesResponse {
42
+ slowQueries ?: SlowQueryLog [ ] ;
43
+ }
44
+
21
45
interface DropIndexSuggestion {
22
46
accessCount ?: number ;
23
47
index ?: Array < { [ key : string ] : 1 | - 1 } > ;
@@ -105,7 +129,9 @@ export async function getSuggestedIndexes(
105
129
} ,
106
130
} ,
107
131
} ) ;
108
- return { suggestedIndexes : response ?. content ?. suggestedIndexes ?? [ ] } ;
132
+ return {
133
+ suggestedIndexes : ( response as SuggestedIndexesResponse ) . content . suggestedIndexes ?? [ ] ,
134
+ } ;
109
135
} catch ( err ) {
110
136
apiClient . logger . debug ( {
111
137
id : LogId . atlasPaSuggestedIndexesFailure ,
@@ -135,9 +161,9 @@ export async function getDropIndexSuggestions(
135
161
} ,
136
162
} ) ;
137
163
return {
138
- hiddenIndexes : response ? .content ? .hiddenIndexes ?? [ ] ,
139
- redundantIndexes : response ? .content ? .redundantIndexes ?? [ ] ,
140
- unusedIndexes : response ? .content ? .unusedIndexes ?? [ ] ,
164
+ hiddenIndexes : ( response as DropIndexesResponse ) . content . hiddenIndexes ?? [ ] ,
165
+ redundantIndexes : ( response as DropIndexesResponse ) . content . redundantIndexes ?? [ ] ,
166
+ unusedIndexes : ( response as DropIndexesResponse ) . content . unusedIndexes ?? [ ] ,
141
167
} ;
142
168
} catch ( err ) {
143
169
apiClient . logger . debug ( {
@@ -163,7 +189,7 @@ export async function getSchemaAdvice(
163
189
} ,
164
190
} ,
165
191
} ) ;
166
- return { recommendations : response ? .content ? .recommendations ?? [ ] } ;
192
+ return { recommendations : ( response as SchemaAdviceResponse ) . content . recommendations ?? [ ] } ;
167
193
} catch ( err ) {
168
194
apiClient . logger . debug ( {
169
195
id : LogId . atlasPaSchemaAdviceFailure ,
@@ -202,7 +228,7 @@ export async function getSlowQueries(
202
228
} ,
203
229
} ) ;
204
230
205
- return { slowQueryLogs : response ? .slowQueries ?? [ ] } ;
231
+ return { slowQueryLogs : ( response as SlowQueriesResponse ) . slowQueries ?? [ ] } ;
206
232
} catch ( err ) {
207
233
apiClient . logger . debug ( {
208
234
id : LogId . atlasPaSlowQueryLogsFailure ,
0 commit comments