diff --git a/packages/kbn-babel-preset/common_preset.js b/packages/kbn-babel-preset/common_preset.js index e67a2db5a380..0c2b37331f3a 100644 --- a/packages/kbn-babel-preset/common_preset.js +++ b/packages/kbn-babel-preset/common_preset.js @@ -18,10 +18,7 @@ */ module.exports = { - presets: [ - require.resolve('@babel/preset-typescript'), - require.resolve('@babel/preset-react') - ], + presets: [require.resolve('@babel/preset-typescript'), require.resolve('@babel/preset-react')], plugins: [ require.resolve('babel-plugin-add-module-exports'), @@ -37,15 +34,14 @@ module.exports = { { // Babel 7 don't support the namespace feature on typescript code. // With namespaces only used for type declarations, we can securely - // strip them off for babel on x-pack infra plugin + // strip them off for babel on x-pack infra/siem plugins // // See https://github.com/babel/babel/issues/8244#issuecomment-466548733 - test: /x-pack[\/\\]plugins[\/\\]infra[\/\\].*[\/\\]graphql/, - plugins: [ - [ - require.resolve('babel-plugin-typescript-strip-namespaces'), - ], - ] - } - ] + test: [ + /x-pack[\/\\]plugins[\/\\]infra[\/\\].*[\/\\]graphql/, + /x-pack[\/\\]plugins[\/\\]siem[\/\\].*[\/\\]graphql/, + ], + plugins: [[require.resolve('babel-plugin-typescript-strip-namespaces')]], + }, + ], }; diff --git a/packages/kbn-babel-preset/node_preset.js b/packages/kbn-babel-preset/node_preset.js index ac4dc17e6380..41298823ae9d 100644 --- a/packages/kbn-babel-preset/node_preset.js +++ b/packages/kbn-babel-preset/node_preset.js @@ -36,7 +36,7 @@ module.exports = () => { // for just the polyfills that the target versions don't already supply // on their own useBuiltIns: 'entry', - modules: 'cjs' + modules: 'cjs', }, ], require('./common_preset'), @@ -45,9 +45,9 @@ module.exports = () => { [ require.resolve('babel-plugin-transform-define'), { - 'global.__BUILT_WITH_BABEL__': 'true' - } - ] - ] + 'global.__BUILT_WITH_BABEL__': 'true', + }, + ], + ], }; }; diff --git a/packages/kbn-interpreter/.babelrc b/packages/kbn-interpreter/.babelrc index 875cbcde9d0e..95ebd3e4198f 100644 --- a/packages/kbn-interpreter/.babelrc +++ b/packages/kbn-interpreter/.babelrc @@ -1,8 +1,11 @@ { "presets": ["@kbn/babel-preset/webpack_preset"], "plugins": [ - ["@babel/plugin-transform-runtime", { - "regenerator": true - }] + [ + "@babel/plugin-transform-runtime", + { + "regenerator": true + } + ] ] } diff --git a/x-pack/plugins/siem/public/components/drag_and_drop/drag_drop_context_wrapper.tsx b/x-pack/plugins/siem/public/components/drag_and_drop/drag_drop_context_wrapper.tsx index cb051407ea63..a7918e3e5f6e 100644 --- a/x-pack/plugins/siem/public/components/drag_and_drop/drag_drop_context_wrapper.tsx +++ b/x-pack/plugins/siem/public/components/drag_and_drop/drag_drop_context_wrapper.tsx @@ -11,9 +11,7 @@ import { connect } from 'react-redux'; import { pure } from 'recompose'; import { Dispatch } from 'redux'; -import { IdToDataProvider } from '../../store/local/drag_and_drop/model'; -import { dataProvidersSelector } from '../../store/local/drag_and_drop/selectors'; -import { State } from '../../store/reducer'; +import { dragAndDropModel, dragAndDropSelectors, State } from '../../store'; import { addProviderToTimeline, @@ -22,13 +20,13 @@ import { } from './helpers'; interface Props { - dataProviders?: IdToDataProvider; + dataProviders?: dragAndDropModel.IdToDataProvider; dispatch: Dispatch; } interface OnDragEndHandlerParams { result: DropResult; - dataProviders: IdToDataProvider; + dataProviders: dragAndDropModel.IdToDataProvider; dispatch: Dispatch; } @@ -56,10 +54,13 @@ const DragDropContextWrapperComponent = pure(({ dataProviders, dispatch, )); -const emptyDataProviders: IdToDataProvider = {}; // stable reference +const emptyDataProviders: dragAndDropModel.IdToDataProvider = {}; // stable reference const mapStateToProps = (state: State) => { - const dataProviders = defaultTo(emptyDataProviders, dataProvidersSelector(state)); + const dataProviders = defaultTo( + emptyDataProviders, + dragAndDropSelectors.dataProvidersSelector(state) + ); return { dataProviders }; }; diff --git a/x-pack/plugins/siem/public/components/drag_and_drop/draggable_wrapper.tsx b/x-pack/plugins/siem/public/components/drag_and_drop/draggable_wrapper.tsx index 7bd14134bc18..5b305fe329c6 100644 --- a/x-pack/plugins/siem/public/components/drag_and_drop/draggable_wrapper.tsx +++ b/x-pack/plugins/siem/public/components/drag_and_drop/draggable_wrapper.tsx @@ -17,10 +17,13 @@ import { connect } from 'react-redux'; import styled from 'styled-components'; import { ActionCreator } from 'typescript-fsa'; -import { dragAndDropActions } from '../../store/local/drag_and_drop'; -import { IdToDataProvider } from '../../store/local/drag_and_drop/model'; -import { dataProvidersSelector } from '../../store/local/drag_and_drop/selectors'; -import { State } from '../../store/reducer'; +import { State } from '../../store'; +// This import needs to be directly link to drag_and_drop store or we will have a circular dependency +import { + dragAndDropActions, + dragAndDropModel, + dragAndDropSelectors, +} from '../../store/drag_and_drop'; import { DataProvider } from '../timeline/data_providers/data_provider'; import { TruncatableText } from '../truncatable_text'; @@ -47,7 +50,7 @@ interface OwnProps { } interface StateReduxProps { - dataProviders?: IdToDataProvider; + dataProviders?: dragAndDropModel.IdToDataProvider; } interface DispatchProps { @@ -123,10 +126,10 @@ class DraggableWrapperComponent extends React.PureComponent { } } -const emptyDataProviders: IdToDataProvider = {}; // stable reference +const emptyDataProviders: dragAndDropModel.IdToDataProvider = {}; // stable reference const mapStateToProps = (state: State) => - defaultTo(emptyDataProviders, dataProvidersSelector(state)); + defaultTo(emptyDataProviders, dragAndDropSelectors.dataProvidersSelector(state)); export const DraggableWrapper = connect( mapStateToProps, diff --git a/x-pack/plugins/siem/public/components/drag_and_drop/helpers.ts b/x-pack/plugins/siem/public/components/drag_and_drop/helpers.ts index 00f086c729df..492d70a39885 100644 --- a/x-pack/plugins/siem/public/components/drag_and_drop/helpers.ts +++ b/x-pack/plugins/siem/public/components/drag_and_drop/helpers.ts @@ -8,9 +8,7 @@ import { DropResult } from 'react-beautiful-dnd'; import { Dispatch } from 'redux'; import { ActionCreator } from 'typescript-fsa'; -import { timelineActions } from '../../store'; -import { dragAndDropActions } from '../../store/local/drag_and_drop'; -import { IdToDataProvider } from '../../store/local/drag_and_drop/model'; +import { dragAndDropActions, dragAndDropModel, timelineActions } from '../../store'; import { DataProvider } from '../timeline/data_providers/data_provider'; export const draggableIdPrefix = 'draggableId'; @@ -71,7 +69,7 @@ export const providerWasDroppedOnTimelineButton = (result: DropResult): boolean destinationIsTimelineButton(result); interface AddProviderToTimelineParams { - dataProviders: IdToDataProvider; + dataProviders: dragAndDropModel.IdToDataProvider; result: DropResult; dispatch: Dispatch; addProvider?: ActionCreator<{ diff --git a/x-pack/plugins/siem/public/components/error_toast/index.tsx b/x-pack/plugins/siem/public/components/error_toast/index.tsx index d1a53a906441..6bb03cfebc93 100644 --- a/x-pack/plugins/siem/public/components/error_toast/index.tsx +++ b/x-pack/plugins/siem/public/components/error_toast/index.tsx @@ -10,15 +10,14 @@ import { connect } from 'react-redux'; import { pure } from 'recompose'; import { ActionCreator } from 'typescript-fsa'; -import { appActions, appSelectors, State } from '../../store'; -import { Error } from '../../store/local/app/model'; +import { appActions, appModel, appSelectors, State } from '../../store'; interface OwnProps { toastLifeTimeMs?: number; } interface ReduxProps { - errors?: Error[]; + errors?: appModel.Error[]; } interface DispatchProps { @@ -45,7 +44,7 @@ export const globalListFromToasts = ( /> ) : null; -export const errorsToToasts = (errors: Error[]): Toast[] => +export const errorsToToasts = (errors: appModel.Error[]): Toast[] => errors.map(({ id, title, message }) => { const toast: Toast = { id, diff --git a/x-pack/plugins/siem/public/components/flyout/index.test.tsx b/x-pack/plugins/siem/public/components/flyout/index.test.tsx index 5d2a8891c320..bb587a824b6f 100644 --- a/x-pack/plugins/siem/public/components/flyout/index.test.tsx +++ b/x-pack/plugins/siem/public/components/flyout/index.test.tsx @@ -59,7 +59,7 @@ describe('Flyout', () => { }); test('it renders the title field when its state is set to flyout is true', () => { - const stateShowIsTrue = set('local.timeline.timelineById.test.show', true, state); + const stateShowIsTrue = set('timeline.timelineById.test.show', true, state); const storeShowIsTrue = createStore(stateShowIsTrue); const wrapper = mount( @@ -82,7 +82,7 @@ describe('Flyout', () => { }); test('it does NOT render the fly out button when its state is set to flyout is true', () => { - const stateShowIsTrue = set('local.timeline.timelineById.test.show', true, state); + const stateShowIsTrue = set('timeline.timelineById.test.show', true, state); const storeShowIsTrue = createStore(stateShowIsTrue); const wrapper = mount( @@ -100,7 +100,7 @@ describe('Flyout', () => { }); test('it renders the flyout body', () => { - const stateShowIsTrue = set('local.timeline.timelineById.test.show', true, state); + const stateShowIsTrue = set('timeline.timelineById.test.show', true, state); const storeShowIsTrue = createStore(stateShowIsTrue); const wrapper = mount( @@ -126,7 +126,7 @@ describe('Flyout', () => { test('it does render the data providers badge when the number is greater than 0', () => { const stateWithDataProviders = set( - 'local.timeline.timelineById.test.dataProviders', + 'timeline.timelineById.test.dataProviders', mockDataProviders, state ); @@ -148,7 +148,7 @@ describe('Flyout', () => { test('it renders the correct number of data providers badge when the number is greater than 0', () => { const stateWithDataProviders = set( - 'local.timeline.timelineById.test.dataProviders', + 'timeline.timelineById.test.dataProviders', mockDataProviders, state ); @@ -213,7 +213,7 @@ describe('Flyout', () => { }); test('should call the onClose when the close button is clicked', () => { - const stateShowIsTrue = set('local.timeline.timelineById.test.show', true, state); + const stateShowIsTrue = set('timeline.timelineById.test.show', true, state); const storeShowIsTrue = createStore(stateShowIsTrue); const showTimeline = (jest.fn() as unknown) as ActionCreator<{ id: string; show: boolean }>; diff --git a/x-pack/plugins/siem/public/components/markdown/index.tsx b/x-pack/plugins/siem/public/components/markdown/index.tsx index 24a6ee3767ce..71464bd93197 100644 --- a/x-pack/plugins/siem/public/components/markdown/index.tsx +++ b/x-pack/plugins/siem/public/components/markdown/index.tsx @@ -17,22 +17,22 @@ const TableHeader = styled.thead` const markdownRenderers = { root: ({ children }: { children: React.ReactNode[] }) => ( - {...children} + {children} ), table: ({ children }: { children: React.ReactNode[] }) => ( - {...children} + {children}
), tableHead: ({ children }: { children: React.ReactNode[] }) => ( - {...children} + {children} ), tableRow: ({ children }: { children: React.ReactNode[] }) => ( - {...children} + {children} ), tableCell: ({ children }: { children: React.ReactNode[] }) => ( - {...children} + {children} ), }; diff --git a/x-pack/plugins/siem/public/components/page/navigation/breadcrumbs.test.tsx b/x-pack/plugins/siem/public/components/page/navigation/breadcrumbs.test.tsx index ad6c9f6a0250..726162f52282 100644 --- a/x-pack/plugins/siem/public/components/page/navigation/breadcrumbs.test.tsx +++ b/x-pack/plugins/siem/public/components/page/navigation/breadcrumbs.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { MemoryRouter } from 'react-router-dom'; // @ts-ignore Prevent auto-format from deleting - needed for 'chrome/ui' imports in host_details/ip_details -jest.mock('ui/chrome', () => ({ +jest.doMock('ui/chrome', () => ({ getBasePath: () => '', })); diff --git a/x-pack/plugins/siem/public/components/page/network/ip_overview/field_renderers.test.tsx b/x-pack/plugins/siem/public/components/page/network/ip_overview/field_renderers.test.tsx index 5b4d35595d88..962754ec2920 100644 --- a/x-pack/plugins/siem/public/components/page/network/ip_overview/field_renderers.test.tsx +++ b/x-pack/plugins/siem/public/components/page/network/ip_overview/field_renderers.test.tsx @@ -21,7 +21,8 @@ import { whoisRenderer, } from './field_renderers'; import { mockData } from './mock'; -import AutonomousSystem = GetIpOverviewQuery.AutonomousSystem; + +type AutonomousSystem = GetIpOverviewQuery.AutonomousSystem; describe('Field Renderers', () => { describe('#locationRenderer', () => { diff --git a/x-pack/plugins/siem/public/components/page/network/ip_overview/index.test.tsx b/x-pack/plugins/siem/public/components/page/network/ip_overview/index.test.tsx index 581c3a7a7660..8fa683a87431 100644 --- a/x-pack/plugins/siem/public/components/page/network/ip_overview/index.test.tsx +++ b/x-pack/plugins/siem/public/components/page/network/ip_overview/index.test.tsx @@ -11,8 +11,7 @@ import { MockedProvider } from 'react-apollo/test-utils'; import { mountWithIntl } from 'test_utils/enzyme_helpers'; import { mockGlobalState, TestProviders } from '../../../../mock'; -import { createStore, State } from '../../../../store'; -import { networkModel } from '../../../../store/local/network'; +import { createStore, networkModel, State } from '../../../../store'; import { IpOverview, IpOverviewId } from './index'; import { mockData } from './mock'; diff --git a/x-pack/plugins/siem/public/components/page/network/network_dns_table/index.test.tsx b/x-pack/plugins/siem/public/components/page/network/network_dns_table/index.test.tsx index e2fa78e33292..4fbfdbebcb46 100644 --- a/x-pack/plugins/siem/public/components/page/network/network_dns_table/index.test.tsx +++ b/x-pack/plugins/siem/public/components/page/network/network_dns_table/index.test.tsx @@ -68,7 +68,7 @@ describe('NetworkTopNFlow Table Component', () => { ); - expect(store.getState().local.network.page.queries!.dns.dnsSortField).toEqual({ + expect(store.getState().network.page.queries!.dns.dnsSortField).toEqual({ direction: 'desc', field: 'queryCount', }); @@ -80,7 +80,7 @@ describe('NetworkTopNFlow Table Component', () => { wrapper.update(); - expect(store.getState().local.network.page.queries!.dns.dnsSortField).toEqual({ + expect(store.getState().network.page.queries!.dns.dnsSortField).toEqual({ direction: 'asc', field: 'dnsName', }); diff --git a/x-pack/plugins/siem/public/components/page/network/network_top_n_flow_table/index.test.tsx b/x-pack/plugins/siem/public/components/page/network/network_top_n_flow_table/index.test.tsx index 77a9b0dbd2ea..3e56ada23e0b 100644 --- a/x-pack/plugins/siem/public/components/page/network/network_top_n_flow_table/index.test.tsx +++ b/x-pack/plugins/siem/public/components/page/network/network_top_n_flow_table/index.test.tsx @@ -147,7 +147,7 @@ describe('NetworkTopNFlow Table Component', () => { ); - expect(store.getState().local.network.page.queries!.topNFlow.topNFlowSort).toEqual({ + expect(store.getState().network.page.queries!.topNFlow.topNFlowSort).toEqual({ direction: 'desc', field: 'bytes', }); @@ -159,7 +159,7 @@ describe('NetworkTopNFlow Table Component', () => { wrapper.update(); - expect(store.getState().local.network.page.queries!.topNFlow.topNFlowSort).toEqual({ + expect(store.getState().network.page.queries!.topNFlow.topNFlowSort).toEqual({ direction: 'asc', field: 'packets', }); diff --git a/x-pack/plugins/siem/public/components/range_date_picker/index.tsx b/x-pack/plugins/siem/public/components/range_date_picker/index.tsx index 395af9000a8b..296a1a6886d4 100644 --- a/x-pack/plugins/siem/public/components/range_date_picker/index.tsx +++ b/x-pack/plugins/siem/public/components/range_date_picker/index.tsx @@ -202,7 +202,7 @@ class RangeDatePickerComponents extends React.PureComponent< } const mapStateToProps = (state: State, { id }: OwnProps) => { - const myState = getOr({}, `local.inputs.${id}`, state); + const myState = getOr({}, `inputs.${id}`, state); return { from: get('timerange.from', myState), to: get('timerange.to', myState), diff --git a/x-pack/plugins/siem/public/components/timeline/body/renderers/zeek_signature.test.tsx b/x-pack/plugins/siem/public/components/timeline/body/renderers/zeek_signature.test.tsx index d8954afa186b..d37cae6d53a8 100644 --- a/x-pack/plugins/siem/public/components/timeline/body/renderers/zeek_signature.test.tsx +++ b/x-pack/plugins/siem/public/components/timeline/body/renderers/zeek_signature.test.tsx @@ -10,8 +10,7 @@ import * as React from 'react'; import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers'; import { Ecs } from '../../../../graphql/types'; -import { TestProviders } from '../../../../mock'; -import { mockTimelineData } from '../../../../mock'; +import { mockTimelineData, TestProviders } from '../../../../mock'; import { constructDroppedValue, diff --git a/x-pack/plugins/siem/public/components/timeline/search_or_filter/helpers.tsx b/x-pack/plugins/siem/public/components/timeline/search_or_filter/helpers.tsx index 43d23da391e7..39f8816ccb48 100644 --- a/x-pack/plugins/siem/public/components/timeline/search_or_filter/helpers.tsx +++ b/x-pack/plugins/siem/public/components/timeline/search_or_filter/helpers.tsx @@ -13,7 +13,7 @@ import { import * as React from 'react'; import styled from 'styled-components'; -import { KqlMode } from '../../../store/local/timeline/model'; +import { timelineModel } from '../../../store'; import { AndOrBadge } from '../../and_or_badge'; import * as i18n from './translations'; @@ -24,14 +24,14 @@ const AndOrContainer = styled.div` `; interface ModeProperties { - mode: KqlMode; + mode: timelineModel.KqlMode; description: string; kqlBarTooltip: string; placeholder: string; selectText: string; } -export const modes: { [key in KqlMode]: ModeProperties } = { +export const modes: { [key in timelineModel.KqlMode]: ModeProperties } = { filter: { mode: 'filter', description: i18n.FILTER_DESCRIPTION, @@ -89,5 +89,5 @@ export const options = [ }, ]; -export const getPlaceholderText = (kqlMode: KqlMode): string => +export const getPlaceholderText = (kqlMode: timelineModel.KqlMode): string => kqlMode === 'filter' ? i18n.FILTER_KQL_PLACEHOLDER : i18n.SEARCH_KQL_PLACEHOLDER; diff --git a/x-pack/plugins/siem/public/components/timeline/search_or_filter/index.tsx b/x-pack/plugins/siem/public/components/timeline/search_or_filter/index.tsx index 6e7d82adfd1b..3c251af211dc 100644 --- a/x-pack/plugins/siem/public/components/timeline/search_or_filter/index.tsx +++ b/x-pack/plugins/siem/public/components/timeline/search_or_filter/index.tsx @@ -17,8 +17,7 @@ import { timelineActions, timelineSelectors, } from '../../../store'; -import { KqlMode, TimelineModel } from '../../../store/local/timeline/model'; -import { State } from '../../../store/reducer'; +import { State, timelineModel } from '../../../store'; import { SearchOrFilter } from './search_or_filter'; @@ -30,7 +29,7 @@ interface OwnProps { interface StateReduxProps { filterQueryDraft: KueryFilterQuery; isFilterQueryDraftValid: boolean; - kqlMode?: KqlMode; + kqlMode?: timelineModel.KqlMode; } interface DispatchProps { @@ -40,7 +39,7 @@ interface DispatchProps { }>; updateKqlMode: ActionCreator<{ id: string; - kqlMode: KqlMode; + kqlMode: timelineModel.KqlMode; }>; setKqlFilterQueryDraft: ActionCreator<{ id: string; @@ -104,7 +103,7 @@ const makeMapStateToProps = () => { const getKqlFilterQueryDraft = timelineSelectors.getKqlFilterQueryDraftSelector(); const isFilterQueryDraftValid = timelineSelectors.isFilterQueryDraftValidSelector(); const mapStateToProps = (state: State, { timelineId }: OwnProps) => { - const timeline: TimelineModel | {} = getTimeline(state, timelineId); + const timeline: timelineModel.TimelineModel | {} = getTimeline(state, timelineId); return { kqlMode: getOr('filter', 'kqlMode', timeline), filterQueryDraft: getKqlFilterQueryDraft(state, timelineId), diff --git a/x-pack/plugins/siem/public/components/timeline/search_or_filter/search_or_filter.tsx b/x-pack/plugins/siem/public/components/timeline/search_or_filter/search_or_filter.tsx index 500c99b1fd3c..024758cbde0a 100644 --- a/x-pack/plugins/siem/public/components/timeline/search_or_filter/search_or_filter.tsx +++ b/x-pack/plugins/siem/public/components/timeline/search_or_filter/search_or_filter.tsx @@ -19,8 +19,7 @@ import styled, { injectGlobal } from 'styled-components'; import { StaticIndexPattern } from 'ui/index_patterns'; import { KueryAutocompletion } from '../../../containers/kuery_autocompletion'; -import { KueryFilterQuery } from '../../../store'; -import { KqlMode } from '../../../store/local/timeline/model'; +import { KueryFilterQuery, timelineModel } from '../../../store'; import { AutocompleteField } from '../../autocomplete_field'; import { getPlaceholderText, modes, options } from './helpers'; @@ -41,7 +40,7 @@ interface Props { filterQueryDraft: KueryFilterQuery; indexPattern: StaticIndexPattern; isFilterQueryDraftValid: boolean; - kqlMode: KqlMode; + kqlMode: timelineModel.KqlMode; timelineId: string; updateKqlMode: ( { @@ -49,7 +48,7 @@ interface Props { kqlMode, }: { id: string; - kqlMode: KqlMode; + kqlMode: timelineModel.KqlMode; } ) => void; setKqlFilterQueryDraft: (expression: string) => void; @@ -84,7 +83,9 @@ export const SearchOrFilter = pure( hasDividers={true} itemLayoutAlign="top" itemClassName={timelineSelectModeItemsClassName} - onChange={(mode: KqlMode) => updateKqlMode({ id: timelineId, kqlMode: mode })} + onChange={(mode: timelineModel.KqlMode) => + updateKqlMode({ id: timelineId, kqlMode: mode }) + } options={options} valueOfSelected={kqlMode} /> diff --git a/x-pack/plugins/siem/public/containers/errors/index.tsx b/x-pack/plugins/siem/public/containers/errors/index.tsx index 5af75bbed591..ae0a02928e7f 100644 --- a/x-pack/plugins/siem/public/containers/errors/index.tsx +++ b/x-pack/plugins/siem/public/containers/errors/index.tsx @@ -8,19 +8,25 @@ import { onError } from 'apollo-link-error'; import uuid from 'uuid'; import { store } from '../../store'; -import { addError } from '../../store/local/app/actions'; +import { appActions } from '../../store'; import * as i18n from './translations'; export const errorLink = onError(({ graphQLErrors, networkError }) => { if (graphQLErrors != null) { graphQLErrors.forEach(({ message }) => - store.dispatch(addError({ id: uuid.v4(), title: i18n.DATA_FETCH_FAILURE, message })) + store.dispatch( + appActions.addError({ id: uuid.v4(), title: i18n.DATA_FETCH_FAILURE, message }) + ) ); } if (networkError != null) { store.dispatch( - addError({ id: uuid.v4(), title: i18n.NETWORK_FAILURE, message: networkError.message }) + appActions.addError({ + id: uuid.v4(), + title: i18n.NETWORK_FAILURE, + message: networkError.message, + }) ); } }); diff --git a/x-pack/plugins/siem/public/containers/global_time/index.tsx b/x-pack/plugins/siem/public/containers/global_time/index.tsx index 4f747a9ad31e..359b04593506 100644 --- a/x-pack/plugins/siem/public/containers/global_time/index.tsx +++ b/x-pack/plugins/siem/public/containers/global_time/index.tsx @@ -9,13 +9,7 @@ import { connect } from 'react-redux'; import { pure } from 'recompose'; import { ActionCreator } from 'typescript-fsa'; -import { - globalPolicySelector, - globalTimeRangeSelector, - inputsActions, - inputsModel, - State, -} from '../../store'; +import { inputsActions, inputsModel, inputsSelectors, State } from '../../store'; interface GlobalTimeArgs { poll: number; @@ -52,8 +46,8 @@ const GlobalTimeComponent = pure(({ children, poll, from, to, s )); const mapStateToProps = (state: State) => { - const timerange: inputsModel.TimeRange = globalTimeRangeSelector(state); - const policy: inputsModel.Policy = globalPolicySelector(state); + const timerange: inputsModel.TimeRange = inputsSelectors.globalTimeRangeSelector(state); + const policy: inputsModel.Policy = inputsSelectors.globalPolicySelector(state); return { poll: policy.kind === 'interval' && timerange.kind === 'absolute' ? policy.duration : 0, from: timerange.from, diff --git a/x-pack/plugins/siem/public/containers/ip_overview/index.tsx b/x-pack/plugins/siem/public/containers/ip_overview/index.tsx index 003608794f20..d1f9a211ebae 100644 --- a/x-pack/plugins/siem/public/containers/ip_overview/index.tsx +++ b/x-pack/plugins/siem/public/containers/ip_overview/index.tsx @@ -10,7 +10,7 @@ import { Query } from 'react-apollo'; import { pure } from 'recompose'; import { GetIpOverviewQuery, IpOverviewData } from '../../graphql/types'; -import { networkModel } from '../../store/local'; +import { networkModel } from '../../store'; import { createFilter } from '../helpers'; import { QueryTemplateProps } from '../query_template'; diff --git a/x-pack/plugins/siem/public/mock/global_state.ts b/x-pack/plugins/siem/public/mock/global_state.ts index b6d8946a7e09..c9521534c3a8 100644 --- a/x-pack/plugins/siem/public/mock/global_state.ts +++ b/x-pack/plugins/siem/public/mock/global_state.ts @@ -18,97 +18,95 @@ import { State } from '../store'; import { defaultHeaders } from './header'; export const mockGlobalState: State = { - local: { - app: { - notesById: {}, - errors: [ - { id: 'error-id-1', title: 'title-1', message: 'error-message-1' }, - { id: 'error-id-2', title: 'title-2', message: 'error-message-2' }, - ], + app: { + notesById: {}, + errors: [ + { id: 'error-id-1', title: 'title-1', message: 'error-message-1' }, + { id: 'error-id-2', title: 'title-2', message: 'error-message-2' }, + ], + }, + hosts: { + page: { + queries: { + authentications: { limit: 10 }, + hosts: { limit: 10 }, + events: { limit: 10 }, + uncommonProcesses: { limit: 10 }, + }, + filterQuery: null, + filterQueryDraft: null, }, - hosts: { - page: { - queries: { - authentications: { limit: 10 }, - hosts: { limit: 10 }, - events: { limit: 10 }, - uncommonProcesses: { limit: 10 }, - }, - filterQuery: null, - filterQueryDraft: null, - }, - details: { - queries: { - authentications: { limit: 10 }, - hosts: { limit: 10 }, - events: { limit: 10 }, - uncommonProcesses: { limit: 10 }, - }, - filterQuery: null, - filterQueryDraft: null, + details: { + queries: { + authentications: { limit: 10 }, + hosts: { limit: 10 }, + events: { limit: 10 }, + uncommonProcesses: { limit: 10 }, }, + filterQuery: null, + filterQueryDraft: null, }, - network: { - page: { - queries: { - topNFlow: { - limit: 10, - topNFlowType: NetworkTopNFlowType.source, - topNFlowDirection: NetworkTopNFlowDirection.uniDirectional, - topNFlowSort: { field: NetworkTopNFlowFields.bytes, direction: Direction.desc }, - }, - dns: { - limit: 10, - dnsSortField: { field: NetworkDnsFields.queryCount, direction: Direction.desc }, - isPtrIncluded: false, - }, + }, + network: { + page: { + queries: { + topNFlow: { + limit: 10, + topNFlowType: NetworkTopNFlowType.source, + topNFlowDirection: NetworkTopNFlowDirection.uniDirectional, + topNFlowSort: { field: NetworkTopNFlowFields.bytes, direction: Direction.desc }, }, - filterQuery: null, - filterQueryDraft: null, - }, - details: { - filterQuery: null, - filterQueryDraft: null, - queries: { - ipOverview: { - flowType: IpOverviewType.source, - }, + dns: { + limit: 10, + dnsSortField: { field: NetworkDnsFields.queryCount, direction: Direction.desc }, + isPtrIncluded: false, }, }, + filterQuery: null, + filterQueryDraft: null, }, - inputs: { - global: { - timerange: { kind: 'absolute', from: 0, to: 1 }, - query: [], - policy: { kind: 'manual', duration: 5000 }, - }, - }, - dragAndDrop: { dataProviders: {} }, - timeline: { - timelineById: { - test: { - id: 'test', - columns: defaultHeaders, - itemsPerPage: 5, - dataProviders: [], - description: '', - eventIdToNoteIds: {}, - highlightedDropAndProviderId: '', - historyIds: [], - isFavorite: false, - isLive: false, - kqlMode: 'filter', - kqlQuery: { filterQuery: null, filterQueryDraft: null }, - title: '', - noteIds: [], - range: '1 Day', - show: false, - pinnedEventIds: {}, - itemsPerPageOptions: [5, 10, 20], - sort: { columnId: '@timestamp', sortDirection: Direction.desc }, - width: defaultWidth, + details: { + filterQuery: null, + filterQueryDraft: null, + queries: { + ipOverview: { + flowType: IpOverviewType.source, }, }, }, }, + inputs: { + global: { + timerange: { kind: 'absolute', from: 0, to: 1 }, + query: [], + policy: { kind: 'manual', duration: 5000 }, + }, + }, + dragAndDrop: { dataProviders: {} }, + timeline: { + timelineById: { + test: { + id: 'test', + columns: defaultHeaders, + itemsPerPage: 5, + dataProviders: [], + description: '', + eventIdToNoteIds: {}, + highlightedDropAndProviderId: '', + historyIds: [], + isFavorite: false, + isLive: false, + kqlMode: 'filter', + kqlQuery: { filterQuery: null, filterQueryDraft: null }, + title: '', + noteIds: [], + range: '1 Day', + show: false, + pinnedEventIds: {}, + itemsPerPageOptions: [5, 10, 20], + sort: { columnId: '@timestamp', sortDirection: Direction.desc }, + width: defaultWidth, + }, + }, + }, }; diff --git a/x-pack/plugins/siem/public/store/actions.ts b/x-pack/plugins/siem/public/store/actions.ts index ce87b945cf2b..12da695d2966 100644 --- a/x-pack/plugins/siem/public/store/actions.ts +++ b/x-pack/plugins/siem/public/store/actions.ts @@ -4,10 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -export { - dragAndDropActions, - hostsActions, - inputsActions, - networkActions, - timelineActions, -} from './local'; +export { appActions } from './app'; +export { dragAndDropActions } from './drag_and_drop'; +export { hostsActions } from './hosts'; +export { inputsActions } from './inputs'; +export { networkActions } from './network'; +export { timelineActions } from './timeline'; diff --git a/x-pack/plugins/siem/public/store/local/app/actions.ts b/x-pack/plugins/siem/public/store/app/actions.ts similarity index 93% rename from x-pack/plugins/siem/public/store/local/app/actions.ts rename to x-pack/plugins/siem/public/store/app/actions.ts index d16b0c715ec2..435a8cad16cc 100644 --- a/x-pack/plugins/siem/public/store/local/app/actions.ts +++ b/x-pack/plugins/siem/public/store/app/actions.ts @@ -6,7 +6,7 @@ import actionCreatorFactory from 'typescript-fsa'; -import { Note } from '../../../lib/note'; +import { Note } from '../../lib/note'; const actionCreator = actionCreatorFactory('x-pack/siem/local/app'); diff --git a/x-pack/plugins/siem/public/store/local/app/index.ts b/x-pack/plugins/siem/public/store/app/index.ts similarity index 80% rename from x-pack/plugins/siem/public/store/local/app/index.ts rename to x-pack/plugins/siem/public/store/app/index.ts index bd4ef82dbd4a..808d130fa789 100644 --- a/x-pack/plugins/siem/public/store/local/app/index.ts +++ b/x-pack/plugins/siem/public/store/app/index.ts @@ -5,8 +5,8 @@ */ import * as appActions from './actions'; +import * as appModel from './model'; import * as appSelectors from './selectors'; -export { appSelectors }; -export { appActions }; +export { appActions, appModel, appSelectors }; export * from './reducer'; diff --git a/x-pack/plugins/siem/public/store/local/app/model.ts b/x-pack/plugins/siem/public/store/app/model.ts similarity index 92% rename from x-pack/plugins/siem/public/store/local/app/model.ts rename to x-pack/plugins/siem/public/store/app/model.ts index 2f7b0692c0a1..d9483d80e3c2 100644 --- a/x-pack/plugins/siem/public/store/local/app/model.ts +++ b/x-pack/plugins/siem/public/store/app/model.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Note } from '../../../lib/note'; +import { Note } from '../../lib/note'; export type ErrorState = ErrorModel; diff --git a/x-pack/plugins/siem/public/store/local/app/reducer.ts b/x-pack/plugins/siem/public/store/app/reducer.ts similarity index 96% rename from x-pack/plugins/siem/public/store/local/app/reducer.ts rename to x-pack/plugins/siem/public/store/app/reducer.ts index 5a3ec7a6804c..955067019133 100644 --- a/x-pack/plugins/siem/public/store/local/app/reducer.ts +++ b/x-pack/plugins/siem/public/store/app/reducer.ts @@ -6,7 +6,7 @@ import { reducerWithInitialState } from 'typescript-fsa-reducers'; -import { Note } from '../../../lib/note'; +import { Note } from '../../lib/note'; import { addError, removeError, updateNote } from './actions'; import { AppModel, NotesById } from './model'; diff --git a/x-pack/plugins/siem/public/store/local/app/selectors.ts b/x-pack/plugins/siem/public/store/app/selectors.ts similarity index 80% rename from x-pack/plugins/siem/public/store/local/app/selectors.ts rename to x-pack/plugins/siem/public/store/app/selectors.ts index e243d5e645af..c1d9b7559fd8 100644 --- a/x-pack/plugins/siem/public/store/local/app/selectors.ts +++ b/x-pack/plugins/siem/public/store/app/selectors.ts @@ -8,14 +8,14 @@ import { keys } from 'lodash/fp'; import memoizeOne from 'memoize-one'; import { createSelector } from 'reselect'; -import { Note } from '../../../lib/note'; -import { State } from '../../reducer'; +import { Note } from '../../lib/note'; +import { State } from '../reducer'; import { ErrorModel, NotesById } from './model'; -const selectNotesById = (state: State): NotesById => state.local.app.notesById; +const selectNotesById = (state: State): NotesById => state.app.notesById; -const getErrors = (state: State): ErrorModel => state.local.app.errors; +const getErrors = (state: State): ErrorModel => state.app.errors; const getNotes = (notesById: NotesById, noteIds: string[]) => keys(notesById).reduce((acc: Note[], noteId: string) => { diff --git a/x-pack/plugins/siem/public/store/local/constants.ts b/x-pack/plugins/siem/public/store/constants.ts similarity index 100% rename from x-pack/plugins/siem/public/store/local/constants.ts rename to x-pack/plugins/siem/public/store/constants.ts diff --git a/x-pack/plugins/siem/public/store/local/drag_and_drop/actions.ts b/x-pack/plugins/siem/public/store/drag_and_drop/actions.ts similarity index 87% rename from x-pack/plugins/siem/public/store/local/drag_and_drop/actions.ts rename to x-pack/plugins/siem/public/store/drag_and_drop/actions.ts index c55522bdfe2d..5d3cdc5a126f 100644 --- a/x-pack/plugins/siem/public/store/local/drag_and_drop/actions.ts +++ b/x-pack/plugins/siem/public/store/drag_and_drop/actions.ts @@ -6,7 +6,7 @@ import actionCreatorFactory from 'typescript-fsa'; -import { DataProvider } from '../../../components/timeline/data_providers/data_provider'; +import { DataProvider } from '../../components/timeline/data_providers/data_provider'; const actionCreator = actionCreatorFactory('x-pack/siem/local/drag_and_drop'); diff --git a/x-pack/plugins/siem/public/store/local/drag_and_drop/index.ts b/x-pack/plugins/siem/public/store/drag_and_drop/index.ts similarity index 65% rename from x-pack/plugins/siem/public/store/local/drag_and_drop/index.ts rename to x-pack/plugins/siem/public/store/drag_and_drop/index.ts index 9d31258d4620..4c06e9c4477b 100644 --- a/x-pack/plugins/siem/public/store/local/drag_and_drop/index.ts +++ b/x-pack/plugins/siem/public/store/drag_and_drop/index.ts @@ -5,7 +5,8 @@ */ import * as dragAndDropActions from './actions'; +import * as dragAndDropModel from './model'; +import * as dragAndDropSelectors from './selectors'; -export * from './selectors'; -export { dragAndDropActions }; +export { dragAndDropActions, dragAndDropModel, dragAndDropSelectors }; export * from './reducer'; diff --git a/x-pack/plugins/siem/public/store/local/drag_and_drop/model.ts b/x-pack/plugins/siem/public/store/drag_and_drop/model.ts similarity index 81% rename from x-pack/plugins/siem/public/store/local/drag_and_drop/model.ts rename to x-pack/plugins/siem/public/store/drag_and_drop/model.ts index 9d60ab195c44..6b6491b32a1d 100644 --- a/x-pack/plugins/siem/public/store/local/drag_and_drop/model.ts +++ b/x-pack/plugins/siem/public/store/drag_and_drop/model.ts @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { DataProvider } from '../../../components/timeline/data_providers/data_provider'; +import { DataProvider } from '../../components/timeline/data_providers/data_provider'; export interface IdToDataProvider { [id: string]: DataProvider; diff --git a/x-pack/plugins/siem/public/store/local/drag_and_drop/reducer.test.ts b/x-pack/plugins/siem/public/store/drag_and_drop/reducer.test.ts similarity index 86% rename from x-pack/plugins/siem/public/store/local/drag_and_drop/reducer.test.ts rename to x-pack/plugins/siem/public/store/drag_and_drop/reducer.test.ts index 2938a70e9a20..e779b990b590 100644 --- a/x-pack/plugins/siem/public/store/local/drag_and_drop/reducer.test.ts +++ b/x-pack/plugins/siem/public/store/drag_and_drop/reducer.test.ts @@ -4,8 +4,8 @@ * you may not use this file except in compliance with the Elastic License. */ -import { DataProvider } from '../../../components/timeline/data_providers/data_provider'; -import { mockDataProviders } from '../../../components/timeline/data_providers/mock/mock_data_providers'; +import { DataProvider } from '../../components/timeline/data_providers/data_provider'; +import { mockDataProviders } from '../../components/timeline/data_providers/mock/mock_data_providers'; import { IdToDataProvider } from './model'; import { registerProviderHandler, unRegisterProviderHandler } from './reducer'; diff --git a/x-pack/plugins/siem/public/store/local/drag_and_drop/reducer.ts b/x-pack/plugins/siem/public/store/drag_and_drop/reducer.ts similarity index 94% rename from x-pack/plugins/siem/public/store/local/drag_and_drop/reducer.ts rename to x-pack/plugins/siem/public/store/drag_and_drop/reducer.ts index d059be63f956..d5d49f3a0a1b 100644 --- a/x-pack/plugins/siem/public/store/local/drag_and_drop/reducer.ts +++ b/x-pack/plugins/siem/public/store/drag_and_drop/reducer.ts @@ -7,7 +7,7 @@ import { omit } from 'lodash/fp'; import { reducerWithInitialState } from 'typescript-fsa-reducers'; -import { DataProvider } from '../../../components/timeline/data_providers/data_provider'; +import { DataProvider } from '../../components/timeline/data_providers/data_provider'; import { registerProvider, unRegisterProvider } from './actions'; import { DragAndDropModel, IdToDataProvider } from './model'; diff --git a/x-pack/plugins/siem/public/store/local/drag_and_drop/selectors.ts b/x-pack/plugins/siem/public/store/drag_and_drop/selectors.ts similarity index 75% rename from x-pack/plugins/siem/public/store/local/drag_and_drop/selectors.ts rename to x-pack/plugins/siem/public/store/drag_and_drop/selectors.ts index 0bcb64e7b1db..39621db36f77 100644 --- a/x-pack/plugins/siem/public/store/local/drag_and_drop/selectors.ts +++ b/x-pack/plugins/siem/public/store/drag_and_drop/selectors.ts @@ -6,12 +6,11 @@ import { createSelector } from 'reselect'; -import { State } from '../../reducer'; +import { State } from '../reducer'; import { IdToDataProvider } from './model'; -const selectDataProviders = (state: State): IdToDataProvider => - state.local.dragAndDrop.dataProviders; +const selectDataProviders = (state: State): IdToDataProvider => state.dragAndDrop.dataProviders; export const dataProvidersSelector = createSelector( selectDataProviders, diff --git a/x-pack/plugins/siem/public/store/epic.ts b/x-pack/plugins/siem/public/store/epic.ts index b5e48a4ec621..8b40af30b522 100644 --- a/x-pack/plugins/siem/public/store/epic.ts +++ b/x-pack/plugins/siem/public/store/epic.ts @@ -6,6 +6,6 @@ import { combineEpics } from 'redux-observable'; -import { createLocalEpic } from './local'; +import { createGlobalTimeEpic } from './inputs'; -export const createRootEpic = () => combineEpics(createLocalEpic()); +export const createRootEpic = () => combineEpics(createGlobalTimeEpic()); diff --git a/x-pack/plugins/siem/public/store/local/hosts/actions.ts b/x-pack/plugins/siem/public/store/hosts/actions.ts similarity index 100% rename from x-pack/plugins/siem/public/store/local/hosts/actions.ts rename to x-pack/plugins/siem/public/store/hosts/actions.ts diff --git a/x-pack/plugins/siem/public/store/local/hosts/index.ts b/x-pack/plugins/siem/public/store/hosts/index.ts similarity index 84% rename from x-pack/plugins/siem/public/store/local/hosts/index.ts rename to x-pack/plugins/siem/public/store/hosts/index.ts index e6579bf544b4..93bdde791a7a 100644 --- a/x-pack/plugins/siem/public/store/local/hosts/index.ts +++ b/x-pack/plugins/siem/public/store/hosts/index.ts @@ -8,7 +8,5 @@ import * as hostsActions from './actions'; import * as hostsModel from './model'; import * as hostsSelectors from './selectors'; -export { hostsActions }; -export { hostsModel }; -export { hostsSelectors }; +export { hostsActions, hostsModel, hostsSelectors }; export * from './reducer'; diff --git a/x-pack/plugins/siem/public/store/local/hosts/model.ts b/x-pack/plugins/siem/public/store/hosts/model.ts similarity index 100% rename from x-pack/plugins/siem/public/store/local/hosts/model.ts rename to x-pack/plugins/siem/public/store/hosts/model.ts diff --git a/x-pack/plugins/siem/public/store/local/hosts/reducer.ts b/x-pack/plugins/siem/public/store/hosts/reducer.ts similarity index 100% rename from x-pack/plugins/siem/public/store/local/hosts/reducer.ts rename to x-pack/plugins/siem/public/store/hosts/reducer.ts diff --git a/x-pack/plugins/siem/public/store/local/hosts/selectors.ts b/x-pack/plugins/siem/public/store/hosts/selectors.ts similarity index 91% rename from x-pack/plugins/siem/public/store/local/hosts/selectors.ts rename to x-pack/plugins/siem/public/store/hosts/selectors.ts index 148bf6c6b451..b1ac7e63d6bb 100644 --- a/x-pack/plugins/siem/public/store/local/hosts/selectors.ts +++ b/x-pack/plugins/siem/public/store/hosts/selectors.ts @@ -7,13 +7,13 @@ import { get } from 'lodash/fp'; import { createSelector } from 'reselect'; -import { isFromKueryExpressionValid } from '../../../lib/keury'; -import { State } from '../../reducer'; +import { isFromKueryExpressionValid } from '../../lib/keury'; +import { State } from '../reducer'; import { GenericHostsModel, HostsType } from './model'; const selectHosts = (state: State, hostsType: HostsType): GenericHostsModel => - get(hostsType, state.local.hosts); + get(hostsType, state.hosts); export const authenticationsSelector = () => createSelector( diff --git a/x-pack/plugins/siem/public/store/index.ts b/x-pack/plugins/siem/public/store/index.ts index 13f23f609567..ffbd383306bf 100644 --- a/x-pack/plugins/siem/public/store/index.ts +++ b/x-pack/plugins/siem/public/store/index.ts @@ -5,10 +5,10 @@ */ export * from './actions'; -export * from './reducer'; -export * from './selectors'; export * from './epic'; export * from './model'; +export * from './reducer'; +export * from './selectors'; import { createStore } from './store'; diff --git a/x-pack/plugins/siem/public/store/local/inputs/actions.ts b/x-pack/plugins/siem/public/store/inputs/actions.ts similarity index 100% rename from x-pack/plugins/siem/public/store/local/inputs/actions.ts rename to x-pack/plugins/siem/public/store/inputs/actions.ts diff --git a/x-pack/plugins/siem/public/store/local/inputs/epic.ts b/x-pack/plugins/siem/public/store/inputs/epic.ts similarity index 100% rename from x-pack/plugins/siem/public/store/local/inputs/epic.ts rename to x-pack/plugins/siem/public/store/inputs/epic.ts diff --git a/x-pack/plugins/siem/public/store/local/inputs/index.ts b/x-pack/plugins/siem/public/store/inputs/index.ts similarity index 78% rename from x-pack/plugins/siem/public/store/local/inputs/index.ts rename to x-pack/plugins/siem/public/store/inputs/index.ts index c0fa9e5c855f..75c00c52cf77 100644 --- a/x-pack/plugins/siem/public/store/local/inputs/index.ts +++ b/x-pack/plugins/siem/public/store/inputs/index.ts @@ -6,9 +6,8 @@ import * as inputsActions from './actions'; import * as inputsModel from './model'; +import * as inputsSelectors from './selectors'; -export { inputsActions }; export * from './reducer'; -export * from './selectors'; export * from './epic'; -export { inputsModel }; +export { inputsActions, inputsModel, inputsSelectors }; diff --git a/x-pack/plugins/siem/public/store/local/inputs/model.ts b/x-pack/plugins/siem/public/store/inputs/model.ts similarity index 100% rename from x-pack/plugins/siem/public/store/local/inputs/model.ts rename to x-pack/plugins/siem/public/store/inputs/model.ts diff --git a/x-pack/plugins/siem/public/store/local/inputs/reducer.ts b/x-pack/plugins/siem/public/store/inputs/reducer.ts similarity index 100% rename from x-pack/plugins/siem/public/store/local/inputs/reducer.ts rename to x-pack/plugins/siem/public/store/inputs/reducer.ts diff --git a/x-pack/plugins/siem/public/store/local/inputs/selectors.ts b/x-pack/plugins/siem/public/store/inputs/selectors.ts similarity index 80% rename from x-pack/plugins/siem/public/store/local/inputs/selectors.ts rename to x-pack/plugins/siem/public/store/inputs/selectors.ts index 13103e8776bd..757b8cf92c15 100644 --- a/x-pack/plugins/siem/public/store/local/inputs/selectors.ts +++ b/x-pack/plugins/siem/public/store/inputs/selectors.ts @@ -6,13 +6,13 @@ import { createSelector } from 'reselect'; -import { State } from '../../reducer'; +import { State } from '../reducer'; import { GlobalQuery, Policy, TimeRange } from './model'; -const selectGlobalTimeRange = (state: State): TimeRange => state.local.inputs.global.timerange; -const selectGlobalPolicy = (state: State): Policy => state.local.inputs.global.policy; -const selectGlobalQuery = (state: State): GlobalQuery[] => state.local.inputs.global.query; +const selectGlobalTimeRange = (state: State): TimeRange => state.inputs.global.timerange; +const selectGlobalPolicy = (state: State): Policy => state.inputs.global.policy; +const selectGlobalQuery = (state: State): GlobalQuery[] => state.inputs.global.query; export const globalTimeRangeSelector = createSelector( selectGlobalTimeRange, diff --git a/x-pack/plugins/siem/public/store/local/actions.ts b/x-pack/plugins/siem/public/store/local/actions.ts deleted file mode 100644 index 12da695d2966..000000000000 --- a/x-pack/plugins/siem/public/store/local/actions.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { appActions } from './app'; -export { dragAndDropActions } from './drag_and_drop'; -export { hostsActions } from './hosts'; -export { inputsActions } from './inputs'; -export { networkActions } from './network'; -export { timelineActions } from './timeline'; diff --git a/x-pack/plugins/siem/public/store/local/epic.ts b/x-pack/plugins/siem/public/store/local/epic.ts deleted file mode 100644 index 46250ea81620..000000000000 --- a/x-pack/plugins/siem/public/store/local/epic.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { combineEpics } from 'redux-observable'; - -import { createGlobalTimeEpic } from './inputs'; - -export const createLocalEpic = () => combineEpics(createGlobalTimeEpic()); diff --git a/x-pack/plugins/siem/public/store/local/index.ts b/x-pack/plugins/siem/public/store/local/index.ts deleted file mode 100644 index 32f2a20dd202..000000000000 --- a/x-pack/plugins/siem/public/store/local/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export * from './actions'; -export * from './epic'; -export * from './model'; -export * from './reducer'; -export * from './selectors'; diff --git a/x-pack/plugins/siem/public/store/local/model.ts b/x-pack/plugins/siem/public/store/local/model.ts deleted file mode 100644 index 179ce831a96a..000000000000 --- a/x-pack/plugins/siem/public/store/local/model.ts +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { inputsModel } from './inputs'; -export { hostsModel } from './hosts'; -export { networkModel } from './network'; -export { timelineModel } from './timeline'; - -export interface KueryFilterQuery { - kind: 'kuery'; - expression: string; -} - -export interface SerializedFilterQuery { - query: KueryFilterQuery; - serializedQuery: string; -} diff --git a/x-pack/plugins/siem/public/store/local/reducer.ts b/x-pack/plugins/siem/public/store/local/reducer.ts deleted file mode 100644 index eeba92604476..000000000000 --- a/x-pack/plugins/siem/public/store/local/reducer.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { combineReducers } from 'redux'; - -import { appReducer, AppState, initialAppState } from './app'; -import { dragAndDropReducer, DragAndDropState, initialDragAndDropState } from './drag_and_drop'; -import { hostsReducer, HostsState, initialHostsState } from './hosts'; -import { initialInputsState, inputsReducer, InputsState } from './inputs'; -import { initialNetworkState, networkReducer, NetworkState } from './network'; -import { initialTimelineState, timelineReducer, TimelineState } from './timeline'; - -export interface LocalState { - app: AppState; - dragAndDrop: DragAndDropState; - hosts: HostsState; - inputs: InputsState; - network: NetworkState; - timeline: TimelineState; -} - -export const initialLocalState: LocalState = { - app: initialAppState, - dragAndDrop: initialDragAndDropState, - hosts: initialHostsState, - inputs: initialInputsState, - network: initialNetworkState, - timeline: initialTimelineState, -}; - -export const localReducer = combineReducers({ - app: appReducer, - dragAndDrop: dragAndDropReducer, - hosts: hostsReducer, - inputs: inputsReducer, - network: networkReducer, - timeline: timelineReducer, -}); diff --git a/x-pack/plugins/siem/public/store/local/selectors.ts b/x-pack/plugins/siem/public/store/local/selectors.ts deleted file mode 100644 index 6daebd3a62a7..000000000000 --- a/x-pack/plugins/siem/public/store/local/selectors.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export { appSelectors } from './app'; -export * from './drag_and_drop'; -export { hostsSelectors } from './hosts'; -export * from './inputs'; -export { networkSelectors } from './network'; -export { timelineSelectors } from './timeline'; diff --git a/x-pack/plugins/siem/public/store/model.ts b/x-pack/plugins/siem/public/store/model.ts index 273d0d39a931..f88d62f73267 100644 --- a/x-pack/plugins/siem/public/store/model.ts +++ b/x-pack/plugins/siem/public/store/model.ts @@ -4,4 +4,19 @@ * you may not use this file except in compliance with the Elastic License. */ -export * from './local'; +export { appModel } from './app'; +export { inputsModel } from './inputs'; +export { hostsModel } from './hosts'; +export { dragAndDropModel } from './drag_and_drop'; +export { networkModel } from './network'; +export { timelineModel } from './timeline'; + +export interface KueryFilterQuery { + kind: 'kuery'; + expression: string; +} + +export interface SerializedFilterQuery { + query: KueryFilterQuery; + serializedQuery: string; +} diff --git a/x-pack/plugins/siem/public/store/local/network/actions.ts b/x-pack/plugins/siem/public/store/network/actions.ts similarity index 98% rename from x-pack/plugins/siem/public/store/local/network/actions.ts rename to x-pack/plugins/siem/public/store/network/actions.ts index a7de86531cb5..a6d7f5de4ee1 100644 --- a/x-pack/plugins/siem/public/store/local/network/actions.ts +++ b/x-pack/plugins/siem/public/store/network/actions.ts @@ -12,7 +12,7 @@ import { NetworkTopNFlowDirection, NetworkTopNFlowSortField, NetworkTopNFlowType, -} from '../../../graphql/types'; +} from '../../graphql/types'; import { KueryFilterQuery, SerializedFilterQuery } from '../model'; import { NetworkType } from './model'; diff --git a/x-pack/plugins/siem/public/store/local/network/helper.ts b/x-pack/plugins/siem/public/store/network/helper.ts similarity index 96% rename from x-pack/plugins/siem/public/store/local/network/helper.ts rename to x-pack/plugins/siem/public/store/network/helper.ts index d2b764993b3d..1c0ea01c5de1 100644 --- a/x-pack/plugins/siem/public/store/local/network/helper.ts +++ b/x-pack/plugins/siem/public/store/network/helper.ts @@ -10,7 +10,7 @@ import { NetworkTopNFlowFields, NetworkTopNFlowSortField, NetworkTopNFlowType, -} from '../../../graphql/types'; +} from '../../graphql/types'; export const helperUpdateTopNFlowDirection = ( topNFlowType: NetworkTopNFlowType, diff --git a/x-pack/plugins/siem/public/store/local/network/index.ts b/x-pack/plugins/siem/public/store/network/index.ts similarity index 83% rename from x-pack/plugins/siem/public/store/local/network/index.ts rename to x-pack/plugins/siem/public/store/network/index.ts index 12a6e75219f7..dcd32fe17ac9 100644 --- a/x-pack/plugins/siem/public/store/local/network/index.ts +++ b/x-pack/plugins/siem/public/store/network/index.ts @@ -8,7 +8,5 @@ import * as networkActions from './actions'; import * as networkModel from './model'; import * as networkSelectors from './selectors'; -export { networkActions }; -export { networkModel }; -export { networkSelectors }; +export { networkActions, networkModel, networkSelectors }; export * from './reducer'; diff --git a/x-pack/plugins/siem/public/store/local/network/model.ts b/x-pack/plugins/siem/public/store/network/model.ts similarity index 97% rename from x-pack/plugins/siem/public/store/local/network/model.ts rename to x-pack/plugins/siem/public/store/network/model.ts index 10ea650669ce..358516501c84 100644 --- a/x-pack/plugins/siem/public/store/local/network/model.ts +++ b/x-pack/plugins/siem/public/store/network/model.ts @@ -10,7 +10,7 @@ import { NetworkTopNFlowDirection, NetworkTopNFlowSortField, NetworkTopNFlowType, -} from '../../../graphql/types'; +} from '../../graphql/types'; import { KueryFilterQuery, SerializedFilterQuery } from '../model'; export enum NetworkType { diff --git a/x-pack/plugins/siem/public/store/local/network/reducer.ts b/x-pack/plugins/siem/public/store/network/reducer.ts similarity index 99% rename from x-pack/plugins/siem/public/store/local/network/reducer.ts rename to x-pack/plugins/siem/public/store/network/reducer.ts index 1194833d7e34..b4e2459eacb1 100644 --- a/x-pack/plugins/siem/public/store/local/network/reducer.ts +++ b/x-pack/plugins/siem/public/store/network/reducer.ts @@ -13,7 +13,7 @@ import { NetworkTopNFlowDirection, NetworkTopNFlowFields, NetworkTopNFlowType, -} from '../../../graphql/types'; +} from '../../graphql/types'; import { DEFAULT_TABLE_LIMIT } from '../constants'; import { diff --git a/x-pack/plugins/siem/public/store/local/network/selectors.ts b/x-pack/plugins/siem/public/store/network/selectors.ts similarity index 90% rename from x-pack/plugins/siem/public/store/local/network/selectors.ts rename to x-pack/plugins/siem/public/store/network/selectors.ts index cf1ae06f1315..42467b2da103 100644 --- a/x-pack/plugins/siem/public/store/local/network/selectors.ts +++ b/x-pack/plugins/siem/public/store/network/selectors.ts @@ -6,14 +6,14 @@ import { createSelector } from 'reselect'; -import { isFromKueryExpressionValid } from '../../../lib/keury'; -import { State } from '../../reducer'; +import { isFromKueryExpressionValid } from '../../lib/keury'; +import { State } from '../reducer'; import { NetworkDetailsModel, NetworkPageModel } from './model'; -const selectNetworkPage = (state: State): NetworkPageModel => state.local.network.page; +const selectNetworkPage = (state: State): NetworkPageModel => state.network.page; -const selectNetworkDetails = (state: State): NetworkDetailsModel => state.local.network.details; +const selectNetworkDetails = (state: State): NetworkDetailsModel => state.network.details; export const dnsSelector = () => createSelector( diff --git a/x-pack/plugins/siem/public/store/reducer.ts b/x-pack/plugins/siem/public/store/reducer.ts index 2536ddbee401..384d11d2777f 100644 --- a/x-pack/plugins/siem/public/store/reducer.ts +++ b/x-pack/plugins/siem/public/store/reducer.ts @@ -6,16 +6,36 @@ import { combineReducers } from 'redux'; -import { initialLocalState, localReducer, LocalState } from './local'; +import { appReducer, AppState, initialAppState } from './app'; +import { dragAndDropReducer, DragAndDropState, initialDragAndDropState } from './drag_and_drop'; +import { hostsReducer, HostsState, initialHostsState } from './hosts'; +import { initialInputsState, inputsReducer, InputsState } from './inputs'; +import { initialNetworkState, networkReducer, NetworkState } from './network'; +import { initialTimelineState, timelineReducer, TimelineState } from './timeline'; export interface State { - local: LocalState; + app: AppState; + dragAndDrop: DragAndDropState; + hosts: HostsState; + inputs: InputsState; + network: NetworkState; + timeline: TimelineState; } export const initialState: State = { - local: initialLocalState, + app: initialAppState, + dragAndDrop: initialDragAndDropState, + hosts: initialHostsState, + inputs: initialInputsState, + network: initialNetworkState, + timeline: initialTimelineState, }; export const reducer = combineReducers({ - local: localReducer, + app: appReducer, + dragAndDrop: dragAndDropReducer, + hosts: hostsReducer, + inputs: inputsReducer, + network: networkReducer, + timeline: timelineReducer, }); diff --git a/x-pack/plugins/siem/public/store/selectors.ts b/x-pack/plugins/siem/public/store/selectors.ts index d8a8c7e129d2..b188f95ad27c 100644 --- a/x-pack/plugins/siem/public/store/selectors.ts +++ b/x-pack/plugins/siem/public/store/selectors.ts @@ -4,12 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -export { - appSelectors, - dataProvidersSelector, - globalTimeRangeSelector, - globalPolicySelector, - hostsSelectors, - networkSelectors, - timelineSelectors, -} from './local'; +export { appSelectors } from './app'; +export { dragAndDropSelectors } from './drag_and_drop'; +export { hostsSelectors } from './hosts'; +export { inputsSelectors } from './inputs'; +export { networkSelectors } from './network'; +export { timelineSelectors } from './timeline'; diff --git a/x-pack/plugins/siem/public/store/store.ts b/x-pack/plugins/siem/public/store/store.ts index bbc7ee5e0554..5689edae05dc 100644 --- a/x-pack/plugins/siem/public/store/store.ts +++ b/x-pack/plugins/siem/public/store/store.ts @@ -14,14 +14,7 @@ import { } from 'redux'; import { createEpicMiddleware } from 'redux-observable'; -import { - createRootEpic, - globalPolicySelector, - globalTimeRangeSelector, - initialState, - reducer, - State, -} from '.'; +import { createRootEpic, initialState, inputsSelectors, reducer, State } from '.'; declare global { interface Window { @@ -33,8 +26,8 @@ export const createStore = (state = initialState): Store => { const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; const middlewareDependencies = { - selectGlobalPolicy: globalPolicySelector, - selectGlobalTimeRange: globalTimeRangeSelector, + selectGlobalPolicy: inputsSelectors.globalPolicySelector, + selectGlobalTimeRange: inputsSelectors.globalTimeRangeSelector, }; const epicMiddleware = createEpicMiddleware( diff --git a/x-pack/plugins/siem/public/store/local/timeline/actions.ts b/x-pack/plugins/siem/public/store/timeline/actions.ts similarity index 94% rename from x-pack/plugins/siem/public/store/local/timeline/actions.ts rename to x-pack/plugins/siem/public/store/timeline/actions.ts index fe004abf06ac..05c262bf6da6 100644 --- a/x-pack/plugins/siem/public/store/local/timeline/actions.ts +++ b/x-pack/plugins/siem/public/store/timeline/actions.ts @@ -6,9 +6,9 @@ import actionCreatorFactory from 'typescript-fsa'; -import { ColumnHeader } from '../../../components/timeline/body/column_headers/column_header'; -import { Sort } from '../../../components/timeline/body/sort'; -import { DataProvider } from '../../../components/timeline/data_providers/data_provider'; +import { ColumnHeader } from '../../components/timeline/body/column_headers/column_header'; +import { Sort } from '../../components/timeline/body/sort'; +import { DataProvider } from '../../components/timeline/data_providers/data_provider'; import { KueryFilterQuery, SerializedFilterQuery } from '../model'; import { KqlMode } from './model'; diff --git a/x-pack/plugins/siem/public/store/local/timeline/helpers.ts b/x-pack/plugins/siem/public/store/timeline/helpers.ts similarity index 98% rename from x-pack/plugins/siem/public/store/local/timeline/helpers.ts rename to x-pack/plugins/siem/public/store/timeline/helpers.ts index 2c7aef45580e..178d15537c9c 100644 --- a/x-pack/plugins/siem/public/store/local/timeline/helpers.ts +++ b/x-pack/plugins/siem/public/store/timeline/helpers.ts @@ -6,10 +6,10 @@ import { getOr, omit, uniq } from 'lodash/fp'; -import { ColumnHeader } from '../../../components/timeline/body/column_headers/column_header'; -import { getColumnWidthFromType } from '../../../components/timeline/body/helpers'; -import { Sort } from '../../../components/timeline/body/sort'; -import { DataProvider } from '../../../components/timeline/data_providers/data_provider'; +import { ColumnHeader } from '../../components/timeline/body/column_headers/column_header'; +import { getColumnWidthFromType } from '../../components/timeline/body/helpers'; +import { Sort } from '../../components/timeline/body/sort'; +import { DataProvider } from '../../components/timeline/data_providers/data_provider'; import { KueryFilterQuery, SerializedFilterQuery } from '../model'; import { TimelineById, TimelineState } from '.'; diff --git a/x-pack/plugins/siem/public/store/local/timeline/index.ts b/x-pack/plugins/siem/public/store/timeline/index.ts similarity index 82% rename from x-pack/plugins/siem/public/store/local/timeline/index.ts rename to x-pack/plugins/siem/public/store/timeline/index.ts index 57596a6d966c..d920dc0a1ab1 100644 --- a/x-pack/plugins/siem/public/store/local/timeline/index.ts +++ b/x-pack/plugins/siem/public/store/timeline/index.ts @@ -8,7 +8,5 @@ import * as timelineActions from './actions'; import * as timelineModel from './model'; import * as timelineSelectors from './selectors'; -export { timelineActions }; -export { timelineModel }; +export { timelineActions, timelineModel, timelineSelectors }; export * from './reducer'; -export { timelineSelectors }; diff --git a/x-pack/plugins/siem/public/store/local/timeline/model.ts b/x-pack/plugins/siem/public/store/timeline/model.ts similarity index 90% rename from x-pack/plugins/siem/public/store/local/timeline/model.ts rename to x-pack/plugins/siem/public/store/timeline/model.ts index 52d69589a1d0..166d813de154 100644 --- a/x-pack/plugins/siem/public/store/local/timeline/model.ts +++ b/x-pack/plugins/siem/public/store/timeline/model.ts @@ -4,11 +4,11 @@ * you may not use this file except in compliance with the Elastic License. */ -import { defaultWidth } from '../../../components/timeline/body'; -import { ColumnHeader } from '../../../components/timeline/body/column_headers/column_header'; -import { Sort } from '../../../components/timeline/body/sort'; -import { DataProvider } from '../../../components/timeline/data_providers/data_provider'; -import { Direction } from '../../../graphql/types'; +import { defaultWidth } from '../../components/timeline/body'; +import { ColumnHeader } from '../../components/timeline/body/column_headers/column_header'; +import { Sort } from '../../components/timeline/body/sort'; +import { DataProvider } from '../../components/timeline/data_providers/data_provider'; +import { Direction } from '../../graphql/types'; import { KueryFilterQuery, SerializedFilterQuery } from '../model'; export const DEFAULT_PAGE_COUNT = 2; // Eui Pager will not render unless this is a minimum of 2 pages diff --git a/x-pack/plugins/siem/public/store/local/timeline/reducer.test.ts b/x-pack/plugins/siem/public/store/timeline/reducer.test.ts similarity index 99% rename from x-pack/plugins/siem/public/store/local/timeline/reducer.test.ts rename to x-pack/plugins/siem/public/store/timeline/reducer.test.ts index f69596c6d516..7cb0479d671b 100644 --- a/x-pack/plugins/siem/public/store/local/timeline/reducer.test.ts +++ b/x-pack/plugins/siem/public/store/timeline/reducer.test.ts @@ -6,15 +6,15 @@ import { cloneDeep, set } from 'lodash/fp'; -import { defaultWidth } from '../../../components/timeline/body'; -import { ColumnHeader } from '../../../components/timeline/body/column_headers/column_header'; -import { defaultColumnHeaderType } from '../../../components/timeline/body/column_headers/default_headers'; +import { defaultWidth } from '../../components/timeline/body'; +import { ColumnHeader } from '../../components/timeline/body/column_headers/column_header'; +import { defaultColumnHeaderType } from '../../components/timeline/body/column_headers/default_headers'; import { DEFAULT_COLUMN_MIN_WIDTH, getColumnWidthFromType, -} from '../../../components/timeline/body/helpers'; -import { Direction } from '../../../graphql/types'; -import { defaultHeaders } from '../../../mock'; +} from '../../components/timeline/body/helpers'; +import { Direction } from '../../graphql/types'; +import { defaultHeaders } from '../../mock'; import { TimelineById } from '.'; import { diff --git a/x-pack/plugins/siem/public/store/local/timeline/reducer.ts b/x-pack/plugins/siem/public/store/timeline/reducer.ts similarity index 100% rename from x-pack/plugins/siem/public/store/local/timeline/reducer.ts rename to x-pack/plugins/siem/public/store/timeline/reducer.ts diff --git a/x-pack/plugins/siem/public/store/local/timeline/selectors.ts b/x-pack/plugins/siem/public/store/timeline/selectors.ts similarity index 88% rename from x-pack/plugins/siem/public/store/local/timeline/selectors.ts rename to x-pack/plugins/siem/public/store/timeline/selectors.ts index bac45af474bd..27eb0e3a4267 100644 --- a/x-pack/plugins/siem/public/store/local/timeline/selectors.ts +++ b/x-pack/plugins/siem/public/store/timeline/selectors.ts @@ -6,16 +6,16 @@ import { createSelector } from 'reselect'; -import { isFromKueryExpressionValid } from '../../../lib/keury'; -import { State } from '../../reducer'; +import { isFromKueryExpressionValid } from '../../lib/keury'; +import { State } from '../reducer'; import { timelineDefaults, TimelineModel } from './model'; import { TimelineById } from './reducer'; -const selectTimelineById = (state: State): TimelineById => state.local.timeline.timelineById; +const selectTimelineById = (state: State): TimelineById => state.timeline.timelineById; export const selectTimeline = (state: State, timelineId: string): TimelineModel => - state.local.timeline.timelineById[timelineId]; + state.timeline.timelineById[timelineId]; export const timelineByIdSelector = createSelector( selectTimelineById, diff --git a/x-pack/plugins/siem/scripts/generate_types_from_graphql.js b/x-pack/plugins/siem/scripts/generate_types_from_graphql.js index 8df9588e6b50..ff377f9d14ec 100644 --- a/x-pack/plugins/siem/scripts/generate_types_from_graphql.js +++ b/x-pack/plugins/siem/scripts/generate_types_from_graphql.js @@ -28,7 +28,6 @@ async function main() { config: SERVER_CONFIG_PATH, out: OUTPUT_INTROSPECTION_PATH, overwrite: true, - require: ['ts-node/register'], schema: SCHEMA_PATH, template: 'graphql-codegen-introspection-template', }, diff --git a/x-pack/plugins/siem/server/graphql/authentications/resolvers.test.ts b/x-pack/plugins/siem/server/graphql/authentications/resolvers.test.ts index 8f6440677996..7be1c6abfd4d 100644 --- a/x-pack/plugins/siem/server/graphql/authentications/resolvers.test.ts +++ b/x-pack/plugins/siem/server/graphql/authentications/resolvers.test.ts @@ -20,7 +20,7 @@ import { AuthenticationsResolversDeps, createAuthenticationsResolvers } from './ const mockGetFields = jest.fn(); mockGetFields.mockResolvedValue({ fieldNodes: [mockAuthenticationsFields] }); -jest.mock('../../utils/build_query/fields', () => ({ +jest.doMock('../../utils/build_query/fields', () => ({ getFields: mockGetFields, })); diff --git a/x-pack/plugins/siem/server/graphql/events/resolvers.test.ts b/x-pack/plugins/siem/server/graphql/events/resolvers.test.ts index fc0926aa6dfa..b0facb1eacf6 100644 --- a/x-pack/plugins/siem/server/graphql/events/resolvers.test.ts +++ b/x-pack/plugins/siem/server/graphql/events/resolvers.test.ts @@ -25,7 +25,7 @@ import { createEventsResolvers, EventsResolversDeps } from './resolvers'; const mockGetFields = jest.fn(); mockGetFields.mockResolvedValue({ fieldNodes: [mockEventsFields] }); -jest.mock('../../utils/build_query/fields', () => ({ +jest.doMock('../../utils/build_query/fields', () => ({ getFields: mockGetFields, })); diff --git a/x-pack/plugins/siem/server/graphql/hosts/resolvers.test.ts b/x-pack/plugins/siem/server/graphql/hosts/resolvers.test.ts index 06365895f972..de15b432deb0 100644 --- a/x-pack/plugins/siem/server/graphql/hosts/resolvers.test.ts +++ b/x-pack/plugins/siem/server/graphql/hosts/resolvers.test.ts @@ -21,7 +21,7 @@ import { createHostsResolvers, HostsResolversDeps } from './resolvers'; const mockGetFields = jest.fn(); mockGetFields.mockResolvedValue({ fieldNodes: [mockHostsFields] }); -jest.mock('../../utils/build_query/fields', () => ({ +jest.doMock('../../utils/build_query/fields', () => ({ getFields: mockGetFields, })); diff --git a/x-pack/plugins/siem/server/graphql/ip_overview/resolvers.test.ts b/x-pack/plugins/siem/server/graphql/ip_overview/resolvers.test.ts index f3885bc52734..5b8c1a4ce3f5 100644 --- a/x-pack/plugins/siem/server/graphql/ip_overview/resolvers.test.ts +++ b/x-pack/plugins/siem/server/graphql/ip_overview/resolvers.test.ts @@ -21,7 +21,7 @@ import { createIpOverviewResolvers, IpOverviewResolversDeps } from './resolvers' const mockGetFields = jest.fn(); mockGetFields.mockResolvedValue({ fieldNodes: [mockIpOverviewFields] }); -jest.mock('../../utils/build_query/fields', () => ({ +jest.doMock('../../utils/build_query/fields', () => ({ getFields: mockGetFields, })); diff --git a/x-pack/plugins/siem/server/graphql/kpi_network/resolvers.test.ts b/x-pack/plugins/siem/server/graphql/kpi_network/resolvers.test.ts index aaaf8582b9b5..549af3bf180f 100644 --- a/x-pack/plugins/siem/server/graphql/kpi_network/resolvers.test.ts +++ b/x-pack/plugins/siem/server/graphql/kpi_network/resolvers.test.ts @@ -20,7 +20,7 @@ import { createKpiNetworkResolvers, KpiNetworkResolversDeps } from './resolvers' const mockGetFields = jest.fn(); mockGetFields.mockResolvedValue({ fieldNodes: [mockKpiNetworkFields] }); -jest.mock('../../utils/build_query/fields', () => ({ +jest.doMock('../../utils/build_query/fields', () => ({ getFields: mockGetFields, })); diff --git a/x-pack/plugins/siem/server/graphql/network/resolvers.test.ts b/x-pack/plugins/siem/server/graphql/network/resolvers.test.ts index 63471e2a1109..77de4d544d81 100644 --- a/x-pack/plugins/siem/server/graphql/network/resolvers.test.ts +++ b/x-pack/plugins/siem/server/graphql/network/resolvers.test.ts @@ -78,7 +78,7 @@ describe('Test Source Resolvers', () => { const mockGetFields = jest.fn(); mockGetFields.mockResolvedValue({ fieldNodes: [mockNetworkTopNFlowFields] }); - jest.mock('../../utils/build_query/fields', () => ({ + jest.doMock('../../utils/build_query/fields', () => ({ getFields: mockGetFields, })); @@ -118,7 +118,7 @@ describe('Test Source Resolvers', () => { const mockGetFields = jest.fn(); mockGetFields.mockResolvedValue({ fieldNodes: [mockNetworkDnsFields] }); - jest.mock('../../utils/build_query/fields', () => ({ + jest.doMock('../../utils/build_query/fields', () => ({ getFields: mockGetFields, })); diff --git a/x-pack/plugins/siem/server/graphql/uncommon_processes/resolvers.test.ts b/x-pack/plugins/siem/server/graphql/uncommon_processes/resolvers.test.ts index 8c9b388e2f1c..f930fec58b9e 100644 --- a/x-pack/plugins/siem/server/graphql/uncommon_processes/resolvers.test.ts +++ b/x-pack/plugins/siem/server/graphql/uncommon_processes/resolvers.test.ts @@ -21,7 +21,7 @@ import { mockUncommonProcessesData, mockUncommonProcessesFields } from './uncomm const mockGetFields = jest.fn(); mockGetFields.mockResolvedValue({ fieldNodes: [mockUncommonProcessesFields] }); -jest.mock('../../utils/build_query/fields', () => ({ +jest.doMock('../../utils/build_query/fields', () => ({ getFields: mockGetFields, })); diff --git a/x-pack/plugins/siem/server/lib/events/elasticsearch_adapter.test.ts b/x-pack/plugins/siem/server/lib/events/elasticsearch_adapter.test.ts index 633f0a9b5cd8..12bf8b581f72 100644 --- a/x-pack/plugins/siem/server/lib/events/elasticsearch_adapter.test.ts +++ b/x-pack/plugins/siem/server/lib/events/elasticsearch_adapter.test.ts @@ -512,7 +512,7 @@ describe('events elasticsearch_adapter', () => { registerGraphQLEndpoint: jest.fn(), getIndexPatternsService: jest.fn(), }; - jest.mock('../framework', () => ({ + jest.doMock('../framework', () => ({ callWithRequest: mockCallWithRequest, })); diff --git a/x-pack/plugins/siem/server/lib/kpi_network/elastic_adapter.test.ts b/x-pack/plugins/siem/server/lib/kpi_network/elastic_adapter.test.ts index 4b275396c15a..c205186943ea 100644 --- a/x-pack/plugins/siem/server/lib/kpi_network/elastic_adapter.test.ts +++ b/x-pack/plugins/siem/server/lib/kpi_network/elastic_adapter.test.ts @@ -33,7 +33,7 @@ describe('Network Kpi elasticsearch_adapter', () => { describe('getKpiNetwork - call stack', () => { beforeAll(async () => { mockCallWithRequest.mockResolvedValue(mockResponse); - jest.mock('../framework', () => ({ + jest.doMock('../framework', () => ({ callWithRequest: mockCallWithRequest, })); mockBuildQuery = jest.spyOn(generalQueryDsl, 'buildGeneralQuery').mockReturnValue([]); @@ -83,7 +83,7 @@ describe('Network Kpi elasticsearch_adapter', () => { describe('Happy Path - get Data', () => { beforeAll(async () => { mockCallWithRequest.mockResolvedValue(mockResponse); - jest.mock('../framework', () => ({ + jest.doMock('../framework', () => ({ callWithRequest: mockCallWithRequest, })); EsKpiNetwork = new ElasticsearchKpiNetworkAdapter(mockFramework); @@ -102,7 +102,7 @@ describe('Network Kpi elasticsearch_adapter', () => { describe('Unhappy Path - No data', () => { beforeAll(async () => { mockCallWithRequest.mockResolvedValue(null); - jest.mock('../framework', () => ({ + jest.doMock('../framework', () => ({ callWithRequest: mockCallWithRequest, })); EsKpiNetwork = new ElasticsearchKpiNetworkAdapter(mockFramework); diff --git a/x-pack/plugins/siem/server/lib/network/elastic_adapter.test.ts b/x-pack/plugins/siem/server/lib/network/elastic_adapter.test.ts index da4e0903c70e..4a4d64ae08f6 100644 --- a/x-pack/plugins/siem/server/lib/network/elastic_adapter.test.ts +++ b/x-pack/plugins/siem/server/lib/network/elastic_adapter.test.ts @@ -23,7 +23,7 @@ describe('Network Top N flow elasticsearch_adapter with NetworkTopNFlowType=sour registerGraphQLEndpoint: jest.fn(), getIndexPatternsService: jest.fn(), }; - jest.mock('../framework', () => ({ + jest.doMock('../framework', () => ({ callWithRequest: mockCallWithRequest, })); @@ -50,7 +50,7 @@ describe('Network Top N flow elasticsearch_adapter with NetworkTopNFlowType=sour registerGraphQLEndpoint: jest.fn(), getIndexPatternsService: jest.fn(), }; - jest.mock('../framework', () => ({ + jest.doMock('../framework', () => ({ callWithRequest: mockCallWithRequest, })); @@ -84,7 +84,7 @@ describe('Network Top N flow elasticsearch_adapter with NetworkTopNFlowType=sour registerGraphQLEndpoint: jest.fn(), getIndexPatternsService: jest.fn(), }; - jest.mock('../framework', () => ({ + jest.doMock('../framework', () => ({ callWithRequest: mockCallWithRequest, })); diff --git a/x-pack/plugins/siem/server/lib/overview/elastic_adapter.test.ts b/x-pack/plugins/siem/server/lib/overview/elastic_adapter.test.ts index 5bb9e8f52ed6..5592e48d5c16 100644 --- a/x-pack/plugins/siem/server/lib/overview/elastic_adapter.test.ts +++ b/x-pack/plugins/siem/server/lib/overview/elastic_adapter.test.ts @@ -33,7 +33,7 @@ describe('Siem Overview elasticsearch_adapter', () => { registerGraphQLEndpoint: jest.fn(), getIndexPatternsService: jest.fn(), }; - jest.mock('../framework', () => ({ + jest.doMock('../framework', () => ({ callWithRequest: mockCallWithRequest, })); @@ -63,7 +63,7 @@ describe('Siem Overview elasticsearch_adapter', () => { registerGraphQLEndpoint: jest.fn(), getIndexPatternsService: jest.fn(), }; - jest.mock('../framework', () => ({ + jest.doMock('../framework', () => ({ callWithRequest: mockCallWithRequest, })); @@ -94,7 +94,7 @@ describe('Siem Overview elasticsearch_adapter', () => { registerGraphQLEndpoint: jest.fn(), getIndexPatternsService: jest.fn(), }; - jest.mock('../framework', () => ({ + jest.doMock('../framework', () => ({ callWithRequest: mockCallWithRequest, })); @@ -125,7 +125,7 @@ describe('Siem Overview elasticsearch_adapter', () => { registerGraphQLEndpoint: jest.fn(), getIndexPatternsService: jest.fn(), }; - jest.mock('../framework', () => ({ + jest.doMock('../framework', () => ({ callWithRequest: mockCallWithRequest, })); diff --git a/x-pack/plugins/siem/tsconfig.json b/x-pack/plugins/siem/tsconfig.json new file mode 100644 index 000000000000..01bddbfc4264 --- /dev/null +++ b/x-pack/plugins/siem/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "../../tsconfig.json", +} \ No newline at end of file