66import _ from 'lodash' ;
77import expect from '@kbn/expect' ;
88import { firstNonNullValue } from '../../../../plugins/security_solution/common/endpoint/models/ecs_safety_helpers' ;
9- import {
10- NodeID ,
11- Schema ,
12- } from '../../../../plugins/security_solution/server/endpoint/routes/resolver/tree/utils' ;
9+ import { NodeID } from '../../../../plugins/security_solution/server/endpoint/routes/resolver/tree/utils' ;
1310import {
1411 SafeResolverChildNode ,
1512 SafeResolverLifecycleNode ,
1613 SafeResolverEvent ,
1714 ResolverNodeStats ,
1815 ResolverNode ,
16+ ResolverSchema ,
1917} from '../../../../plugins/security_solution/common/endpoint/types' ;
2018import {
2119 parentEntityIDSafeVersion ,
@@ -41,7 +39,7 @@ const createLevels = ({
4139 descendantsByParent : Map < NodeID , Map < NodeID , ResolverNode > > ;
4240 levels : Array < Map < NodeID , ResolverNode > > ;
4341 currentNodes : Map < NodeID , ResolverNode > | undefined ;
44- schema : Schema ;
42+ schema : ResolverSchema ;
4543} ) : Array < Map < NodeID , ResolverNode > > => {
4644 if ( ! currentNodes || currentNodes . size === 0 ) {
4745 return levels ;
@@ -98,15 +96,18 @@ export interface APIResponse {
9896 * @param node a resolver node
9997 * @param schema the schema that was used to retrieve this resolver node
10098 */
101- export const getID = ( node : ResolverNode | undefined , schema : Schema ) : NodeID => {
99+ export const getID = ( node : ResolverNode | undefined , schema : ResolverSchema ) : NodeID => {
102100 const id = firstNonNullValue ( node ?. data [ schema . id ] ) ;
103101 if ( ! id ) {
104102 throw new Error ( `Unable to find id ${ schema . id } in node: ${ JSON . stringify ( node ) } ` ) ;
105103 }
106104 return id ;
107105} ;
108106
109- const getParentInternal = ( node : ResolverNode | undefined , schema : Schema ) : NodeID | undefined => {
107+ const getParentInternal = (
108+ node : ResolverNode | undefined ,
109+ schema : ResolverSchema
110+ ) : NodeID | undefined => {
110111 if ( node ) {
111112 return firstNonNullValue ( node ?. data [ schema . parent ] ) ;
112113 }
@@ -119,7 +120,7 @@ const getParentInternal = (node: ResolverNode | undefined, schema: Schema): Node
119120 * @param node a resolver node
120121 * @param schema the schema that was used to retrieve this resolver node
121122 */
122- export const getParent = ( node : ResolverNode | undefined , schema : Schema ) : NodeID => {
123+ export const getParent = ( node : ResolverNode | undefined , schema : ResolverSchema ) : NodeID => {
123124 const parent = getParentInternal ( node , schema ) ;
124125 if ( ! parent ) {
125126 throw new Error ( `Unable to find parent ${ schema . parent } in node: ${ JSON . stringify ( node ) } ` ) ;
@@ -138,7 +139,7 @@ export const getParent = (node: ResolverNode | undefined, schema: Schema): NodeI
138139const createTreeFromResponse = (
139140 treeExpectations : TreeExpectation [ ] ,
140141 nodes : ResolverNode [ ] ,
141- schema : Schema
142+ schema : ResolverSchema
142143) => {
143144 const nodesByID = new Map < NodeID , ResolverNode > ( ) ;
144145 const nodesByParent = new Map < NodeID , Map < NodeID , ResolverNode > > ( ) ;
@@ -206,7 +207,7 @@ const verifyAncestry = ({
206207 genTree,
207208} : {
208209 responseTrees : APIResponse ;
209- schema : Schema ;
210+ schema : ResolverSchema ;
210211 genTree : Tree ;
211212} ) => {
212213 const allGenNodes = new Map < string , TreeNode > ( [
@@ -277,7 +278,7 @@ const verifyChildren = ({
277278 genTree,
278279} : {
279280 responseTrees : APIResponse ;
280- schema : Schema ;
281+ schema : ResolverSchema ;
281282 genTree : Tree ;
282283} ) => {
283284 const allGenNodes = new Map < string , TreeNode > ( [
@@ -358,7 +359,7 @@ export const verifyTree = ({
358359} : {
359360 expectations : TreeExpectation [ ] ;
360361 response : ResolverNode [ ] ;
361- schema : Schema ;
362+ schema : ResolverSchema ;
362363 genTree : Tree ;
363364 relatedEventsCategories ?: RelatedEventInfo [ ] ;
364365} ) => {
0 commit comments