Skip to content

Commit

Permalink
Fix broken type exports. Introduce missing types.
Browse files Browse the repository at this point in the history
  • Loading branch information
justinkambic committed Feb 5, 2021
1 parent e513411 commit 51842a6
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 39 deletions.
40 changes: 25 additions & 15 deletions x-pack/plugins/uptime/common/constants/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,33 @@

import { ActionGroup } from '../../../alerts/common';

export type MonitorStatusActionGroup = ActionGroup<'xpack.uptime.alerts.actionGroups.monitorStatus'>;
export type TLSActionGroup = ActionGroup<'xpack.uptime.alerts.actionGroups.tls'>;
export type DurationAnomalyActionGroup = ActionGroup<'xpack.uptime.alerts.actionGroups.durationAnomaly'>;

export const MONITOR_STATUS: MonitorStatusActionGroup = {
id: 'xpack.uptime.alerts.actionGroups.monitorStatus',
name: 'Uptime Down Monitor',
};

export const TLS: TLSActionGroup = {
id: 'xpack.uptime.alerts.actionGroups.tls',
name: 'Uptime TLS Alert',
};

export const DURATION_ANOMALY: DurationAnomalyActionGroup = {
id: 'xpack.uptime.alerts.actionGroups.durationAnomaly',
name: 'Uptime Duration Anomaly',
};

export const ACTION_GROUP_DEFINITIONS: {
MONITOR_STATUS: ActionGroup<'xpack.uptime.alerts.actionGroups.monitorStatus'>;
TLS: ActionGroup<'xpack.uptime.alerts.actionGroups.tls'>;
DURATION_ANOMALY: ActionGroup<'xpack.uptime.alerts.actionGroups.durationAnomaly'>;
MONITOR_STATUS: MonitorStatusActionGroup;
TLS: TLSActionGroup;
DURATION_ANOMALY: DurationAnomalyActionGroup;
} = {
MONITOR_STATUS: {
id: 'xpack.uptime.alerts.actionGroups.monitorStatus',
name: 'Uptime Down Monitor',
},
TLS: {
id: 'xpack.uptime.alerts.actionGroups.tls',
name: 'Uptime TLS Alert',
},
DURATION_ANOMALY: {
id: 'xpack.uptime.alerts.actionGroups.durationAnomaly',
name: 'Uptime Duration Anomaly',
},
MONITOR_STATUS,
TLS,
DURATION_ANOMALY,
};

export const CLIENT_ALERT_TYPES = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
* 2.0.
*/

import { EuiPanel, EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui';
import { EuiPanel, EuiFlexGroup, EuiFlexItem, EuiText, EuiPanelProps } from '@elastic/eui';
import { rgba } from 'polished';
import { euiStyled } from '../../../../../../../../../src/plugins/kibana_react/common';
import { FunctionComponent } from 'react';
import { StyledComponent } from 'styled-components';
import { euiStyled, EuiTheme } from '../../../../../../../../../src/plugins/kibana_react/common';
import { FIXED_AXIS_HEIGHT } from './constants';

interface WaterfallChartOuterContainerProps {
Expand Down Expand Up @@ -40,7 +42,10 @@ export const WaterfallChartFixedTopContainer = euiStyled.div`
border-bottom: ${(props) => `1px solid ${props.theme.eui.euiColorLightShade}`};
`;

export const WaterfallChartFixedTopContainerSidebarCover = euiStyled(EuiPanel)`
export const WaterfallChartFixedTopContainerSidebarCover: StyledComponent<
FunctionComponent<EuiPanelProps>,
EuiTheme
> = euiStyled(EuiPanel)`
height: 100%;
border-radius: 0 !important;
border: none;
Expand All @@ -60,7 +65,10 @@ export const WaterfallChartSidebarContainer = euiStyled.div<WaterfallChartSideba
overflow-y: hidden;
`;

export const WaterfallChartSidebarContainerInnerPanel = euiStyled(EuiPanel)`
export const WaterfallChartSidebarContainerInnerPanel: StyledComponent<
FunctionComponent<EuiPanelProps>,
EuiTheme
> = euiStyled(EuiPanel)`
border: 0;
height: 100%;
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { IntegrationGroup } from './integration_group';
import { MonitorSummary } from '../../../../../../common/runtime_types';
import { toggleIntegrationsPopover, PopoverState } from '../../../../../state/actions';

interface ActionsPopoverProps {
export interface ActionsPopoverProps {
summary: MonitorSummary;
popoverState: PopoverState | null;
togglePopoverIsVisible: typeof toggleIntegrationsPopover;
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/uptime/public/state/alerts/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const deleteAnomalyAlertAction = createAsyncAction<{ alertId: string }, a
'DELETE ANOMALY ALERT'
);

interface AlertState {
export interface AlertState {
connectors: AsyncInitState<ActionConnector[]>;
newAlert: AsyncInitState<Alert<UptimeAlertTypeParams>>;
alerts: AsyncInitState<AlertsResult>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const getCertificatesAction = createAsyncAction<GetCertsParams, CertResul
'GET_CERTIFICATES'
);

interface CertificatesState {
export interface CertificatesState {
certs: AsyncInitState<CertResult>;
}

Expand Down
7 changes: 7 additions & 0 deletions x-pack/plugins/uptime/public/state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ import { rootReducer } from './reducers';

export type AppState = ReturnType<typeof rootReducer>;

type ComposeType = typeof compose;
declare global {
interface Window {
__REDUX_DEVTOOLS_EXTENSION_COMPOSE__: ComposeType;
}
}

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

const sagaMW = createSagaMiddleware();
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/uptime/public/state/reducers/journey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface JourneyState {
error?: Error;
}

interface JourneyKVP {
export interface JourneyKVP {
[checkGroup: string]: JourneyState;
}

Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/uptime/server/lib/alerts/duration_anomaly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import moment from 'moment';
import { schema } from '@kbn/config-schema';
import { ActionGroupIdsOf } from '../../../../alerts/common';
import { updateState } from './common';
import { ACTION_GROUP_DEFINITIONS } from '../../../common/constants/alerts';
import { DURATION_ANOMALY } from '../../../common/constants/alerts';
import { commonStateTranslations, durationAnomalyTranslations } from './translations';
import { AnomaliesTableRecord } from '../../../../ml/common/types/anomalies';
import { getSeverityType } from '../../../../ml/common/util/anomaly_utils';
Expand All @@ -21,7 +21,6 @@ import { getMLJobId } from '../../../common/lib';
import { getLatestMonitor } from '../requests/get_latest_monitor';
import { uptimeAlertWrapper } from './uptime_alert_wrapper';

const { DURATION_ANOMALY } = ACTION_GROUP_DEFINITIONS;
export type ActionGroupIds = ActionGroupIdsOf<typeof DURATION_ANOMALY>;

export const getAnomalySummary = (anomaly: AnomaliesTableRecord, monitorInfo: Ping) => {
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/uptime/server/lib/alerts/status_check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
Ping,
GetMonitorAvailabilityParams,
} from '../../../common/runtime_types';
import { ACTION_GROUP_DEFINITIONS } from '../../../common/constants/alerts';
import { MONITOR_STATUS } from '../../../common/constants/alerts';
import { updateState } from './common';
import { commonMonitorStateI18, commonStateTranslations, DOWN_LABEL } from './translations';
import { stringifyKueries, combineFiltersAndUserSearch } from '../../../common/lib';
Expand All @@ -29,7 +29,6 @@ import { MonitorStatusTranslations } from '../../../common/translations';
import { getUptimeIndexPattern, IndexPatternTitleAndFields } from '../requests/get_index_pattern';
import { UMServerLibs, UptimeESClient } from '../lib';

const { MONITOR_STATUS } = ACTION_GROUP_DEFINITIONS;
export type ActionGroupIds = ActionGroupIdsOf<typeof MONITOR_STATUS>;

const getMonIdByLoc = (monitorId: string, location: string) => {
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/uptime/server/lib/alerts/tls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ import moment from 'moment';
import { schema } from '@kbn/config-schema';
import { UptimeAlertTypeFactory } from './types';
import { updateState } from './common';
import { ACTION_GROUP_DEFINITIONS } from '../../../common/constants/alerts';
import { TLS } from '../../../common/constants/alerts';
import { DYNAMIC_SETTINGS_DEFAULTS } from '../../../common/constants';
import { Cert, CertResult } from '../../../common/runtime_types';
import { commonStateTranslations, tlsTranslations } from './translations';
import { DEFAULT_FROM, DEFAULT_TO } from '../../rest_api/certs/certs';
import { uptimeAlertWrapper } from './uptime_alert_wrapper';
import { ActionGroupIdsOf } from '../../../../alerts/common';

const { TLS } = ACTION_GROUP_DEFINITIONS;
export type ActionGroupIds = ActionGroupIdsOf<typeof TLS>;

const DEFAULT_SIZE = 20;
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/uptime/server/lib/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface UMServerLibs extends UMDomainLibs {
framework: UMBackendFrameworkAdapter;
}

interface CountResponse {
export interface CountResponse {
body: {
count: number;
_shards: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { UMElasticsearchQueryFn } from '../adapters/framework';
import { SyntheticsJourneyApiResponse } from '../../../common/runtime_types';

interface GetJourneyDetails {
export interface GetJourneyDetails {
checkGroup: string;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { UMElasticsearchQueryFn } from '../adapters/framework';
import { Ping } from '../../../common/runtime_types';

interface GetJourneyStepsParams {
export interface GetJourneyStepsParams {
checkGroups: string[];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { UMElasticsearchQueryFn } from '../adapters/framework';
import { Ping } from '../../../common/runtime_types/ping';

interface GetJourneyScreenshotParams {
export interface GetJourneyScreenshotParams {
checkGroup: string;
stepIndex: number;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { UMElasticsearchQueryFn } from '../adapters/framework';
import { Ping } from '../../../common/runtime_types';

interface GetJourneyStepsParams {
export interface GetJourneyStepsParams {
checkGroup: string;
syntheticEventTypes?: string | string[];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { UMElasticsearchQueryFn } from '../adapters/framework';
import { NetworkEvent } from '../../../common/runtime_types';

interface GetNetworkEventsParams {
export interface GetNetworkEventsParams {
checkGroup: string;
stepIndex: string;
}
Expand Down
15 changes: 11 additions & 4 deletions x-pack/plugins/uptime/server/lib/requests/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
* 2.0.
*/

// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { ElasticsearchClientMock } from 'src/core/server/elasticsearch/client/mocks';
import {
elasticsearchServiceMock,
savedObjectsClientMock,
} from '../../../../../../src/core/server/mocks';

// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { ElasticsearchClientMock } from '../../../../../../src/core/server/elasticsearch/client/mocks';
import { createUptimeESClient } from '../lib';
import { createUptimeESClient, UptimeESClient } from '../lib';

export interface MultiPageCriteria<K, T> {
after_key?: K;
Expand Down Expand Up @@ -60,7 +60,14 @@ export const setupMockEsCompositeQuery = <K, C, I>(
return esMock;
};

export const getUptimeESMockClient = (esClientMock?: ElasticsearchClientMock) => {
interface UptimeEsMockClient {
esClient: ElasticsearchClientMock;
uptimeEsClient: UptimeESClient;
}

export const getUptimeESMockClient = (
esClientMock?: ElasticsearchClientMock
): UptimeEsMockClient => {
const esClient = elasticsearchServiceMock.createElasticsearchClient();

const savedObjectsClient = savedObjectsClientMock.create();
Expand Down

0 comments on commit 51842a6

Please sign in to comment.