mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Infra] Remove runtime_types in favor of kbn-io-ts-utils package (#188204)
## Summary Remove the [runtime_types.ts](https://github.com/elastic/kibana/pull/188204/files#diff-d3c545bedb04ac327dfbc652fdc230f98513d672d84b4c2b12101738d324b5ab) file in of favor utilizing the kbn-io-ts-utils package. `runtime_types.ts` content was copied to kbn-io-ts-utils package at some point but the file was never removed from infra plugin. Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
db001d9d4f
commit
e94ef3e222
102 changed files with 131 additions and 254 deletions
|
@ -1,69 +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
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { fold } from 'fp-ts/lib/Either';
|
||||
import { identity } from 'fp-ts/lib/function';
|
||||
import { pipe } from 'fp-ts/lib/pipeable';
|
||||
import { Context, Errors, IntersectionType, Type, UnionType, ValidationError } from 'io-ts';
|
||||
import type { RouteValidationFunction } from '@kbn/core/server';
|
||||
|
||||
type ErrorFactory = (message: string) => Error;
|
||||
|
||||
const getErrorPath = ([first, ...rest]: Context): string[] => {
|
||||
if (typeof first === 'undefined') {
|
||||
return [];
|
||||
} else if (first.type instanceof IntersectionType) {
|
||||
const [, ...next] = rest;
|
||||
return getErrorPath(next);
|
||||
} else if (first.type instanceof UnionType) {
|
||||
const [, ...next] = rest;
|
||||
return [first.key, ...getErrorPath(next)];
|
||||
}
|
||||
|
||||
return [first.key, ...getErrorPath(rest)];
|
||||
};
|
||||
|
||||
const getErrorType = ({ context }: ValidationError) =>
|
||||
context[context.length - 1]?.type?.name ?? 'unknown';
|
||||
|
||||
const formatError = (error: ValidationError) =>
|
||||
error.message ??
|
||||
`in ${getErrorPath(error.context).join('/')}: ${JSON.stringify(
|
||||
error.value
|
||||
)} does not match expected type ${getErrorType(error)}`;
|
||||
|
||||
export const formatErrors = (errors: ValidationError[]) =>
|
||||
`Failed to validate: \n${errors.map((error) => ` ${formatError(error)}`).join('\n')}`;
|
||||
|
||||
export const createPlainError = (message: string) => new Error(message);
|
||||
|
||||
export const throwErrors = (createError: ErrorFactory) => (errors: Errors) => {
|
||||
throw createError(formatErrors(errors));
|
||||
};
|
||||
|
||||
export const decodeOrThrow =
|
||||
<DecodedValue, EncodedValue, InputValue>(
|
||||
runtimeType: Type<DecodedValue, EncodedValue, InputValue>,
|
||||
createError: ErrorFactory = createPlainError
|
||||
) =>
|
||||
(inputValue: InputValue) =>
|
||||
pipe(runtimeType.decode(inputValue), fold(throwErrors(createError), identity));
|
||||
|
||||
type ValdidationResult<Value> = ReturnType<RouteValidationFunction<Value>>;
|
||||
|
||||
export const createValidationFunction =
|
||||
<DecodedValue, EncodedValue, InputValue>(
|
||||
runtimeType: Type<DecodedValue, EncodedValue, InputValue>
|
||||
): RouteValidationFunction<DecodedValue> =>
|
||||
(inputValue, { badRequest, ok }) =>
|
||||
pipe(
|
||||
runtimeType.decode(inputValue),
|
||||
fold<Errors, DecodedValue, ValdidationResult<DecodedValue>>(
|
||||
(errors: Errors) => badRequest(formatErrors(errors)),
|
||||
(result: DecodedValue) => ok(result)
|
||||
)
|
||||
);
|
|
@ -25,6 +25,7 @@ import type { Message } from '@kbn/observability-ai-assistant-plugin/public';
|
|||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { pick, orderBy } from 'lodash';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { Color, colorTransformer } from '../../../../../../common/color_palette';
|
||||
import { useKibanaContextForPlugin } from '../../../../../hooks/use_kibana';
|
||||
import {
|
||||
|
@ -33,7 +34,6 @@ import {
|
|||
PartialRuleParams,
|
||||
ruleParamsRT,
|
||||
} from '../../../../../../common/alerting/logs/log_threshold';
|
||||
import { decodeOrThrow } from '../../../../../../common/runtime_types';
|
||||
import { getESQueryForLogRateAnalysis } from '../log_rate_analysis_query';
|
||||
|
||||
export interface AlertDetailsLogRateAnalysisSectionProps {
|
||||
|
|
|
@ -23,6 +23,7 @@ import {
|
|||
import { EuiText } from '@elastic/eui';
|
||||
import { FormattedMessage } from '@kbn/i18n-react';
|
||||
import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { useTimelineChartTheme } from '../../../../hooks/use_timeline_chart_theme';
|
||||
import { ExecutionTimeRange } from '../../../../types';
|
||||
import {
|
||||
|
@ -49,7 +50,6 @@ import {
|
|||
getLogAlertsChartPreviewDataAlertParamsSubsetRT,
|
||||
} from '../../../../../common/http_api';
|
||||
import { useChartPreviewData } from './hooks/use_chart_preview_data';
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
import { useKibanaTimeZoneSetting } from '../../../../hooks/use_kibana_time_zone_setting';
|
||||
|
||||
const GROUP_LIMIT = 5;
|
||||
|
|
|
@ -15,6 +15,7 @@ import {
|
|||
} from '@kbn/triggers-actions-ui-plugin/public';
|
||||
import { LogViewProvider, useLogViewContext } from '@kbn/logs-shared-plugin/public';
|
||||
import { PersistedLogViewReference, ResolvedLogViewField } from '@kbn/logs-shared-plugin/common';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
Comparator,
|
||||
isOptimizableGroupedThreshold,
|
||||
|
@ -26,7 +27,6 @@ import {
|
|||
ThresholdType,
|
||||
timeUnitRT,
|
||||
} from '../../../../../common/alerting/logs/log_threshold/types';
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
import { ObjectEntries } from '../../../../../common/utility_types';
|
||||
import { useKibanaContextForPlugin } from '../../../../hooks/use_kibana';
|
||||
import { GroupByExpression } from '../../../common/group_by_expression/group_by_expression';
|
||||
|
|
|
@ -9,6 +9,7 @@ import { HttpHandler } from '@kbn/core/public';
|
|||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { isRatioRule } from '../../../../../../common/alerting/logs/log_threshold';
|
||||
import {
|
||||
GetLogAlertsChartPreviewDataAlertParamsSubset,
|
||||
|
@ -17,7 +18,6 @@ import {
|
|||
getLogAlertsChartPreviewDataSuccessResponsePayloadRT,
|
||||
LOG_ALERTS_CHART_PREVIEW_DATA_PATH,
|
||||
} from '../../../../../../common/http_api';
|
||||
import { decodeOrThrow } from '../../../../../../common/runtime_types';
|
||||
import { ExecutionTimeRange } from '../../../../../types';
|
||||
import { useTrackedPromise } from '../../../../../hooks/use_tracked_promise';
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import { identity } from 'fp-ts/lib/function';
|
|||
import { pipe } from 'fp-ts/lib/pipeable';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import { throwErrors, createPlainError } from '@kbn/io-ts-utils';
|
||||
import { useKibanaContextForPlugin } from '../../../hooks/use_kibana';
|
||||
import { useTrackedPromise } from '../../../hooks/use_tracked_promise';
|
||||
import type {
|
||||
|
@ -22,7 +23,6 @@ import {
|
|||
InfraCustomDashboardRT,
|
||||
InfraDeleteCustomDashboardsResponseBodyRT,
|
||||
} from '../../../../common/http_api/custom_dashboards_api';
|
||||
import { throwErrors, createPlainError } from '../../../../common/runtime_types';
|
||||
|
||||
type ActionType = 'create' | 'update' | 'delete';
|
||||
const errorMessages: Record<ActionType, string> = {
|
||||
|
|
|
@ -10,10 +10,10 @@ import { fold } from 'fp-ts/lib/Either';
|
|||
import { identity } from 'fp-ts/lib/function';
|
||||
import { pipe } from 'fp-ts/lib/pipeable';
|
||||
import type { InventoryItemType } from '@kbn/metrics-data-access-plugin/common';
|
||||
import { throwErrors, createPlainError } from '@kbn/io-ts-utils';
|
||||
import type { InfraSavedCustomDashboard } from '../../../../common/custom_dashboards';
|
||||
import { InfraGetCustomDashboardsResponseBodyRT } from '../../../../common/http_api/custom_dashboards_api';
|
||||
import { useHTTPRequest } from '../../../hooks/use_http_request';
|
||||
import { throwErrors, createPlainError } from '../../../../common/runtime_types';
|
||||
import { useRequestObservable } from './use_request_observable';
|
||||
|
||||
interface UseDashboardProps {
|
||||
|
|
|
@ -11,9 +11,9 @@ import { identity } from 'fp-ts/lib/function';
|
|||
import { pipe } from 'fp-ts/lib/pipeable';
|
||||
import type { InventoryItemType, InventoryMetric } from '@kbn/metrics-data-access-plugin/common';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { throwErrors, createPlainError } from '@kbn/io-ts-utils';
|
||||
import { useHTTPRequest } from '../../../hooks/use_http_request';
|
||||
import { type InfraMetadata, InfraMetadataRT } from '../../../../common/http_api/metadata_api';
|
||||
import { throwErrors, createPlainError } from '../../../../common/runtime_types';
|
||||
import { getFilteredMetrics } from '../../../pages/metrics/metric_detail/lib/get_filtered_metrics';
|
||||
|
||||
interface UseMetadataProps {
|
||||
|
|
|
@ -11,8 +11,8 @@ import { identity } from 'fp-ts/lib/function';
|
|||
import { pipe } from 'fp-ts/lib/pipeable';
|
||||
import { useEffect } from 'react';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { throwErrors, createPlainError } from '@kbn/io-ts-utils';
|
||||
import { ProcessListAPIResponse, ProcessListAPIResponseRT } from '../../../../common/http_api';
|
||||
import { throwErrors, createPlainError } from '../../../../common/runtime_types';
|
||||
import { useHTTPRequest } from '../../../hooks/use_http_request';
|
||||
import { useMetricsDataViewContext } from '../../../containers/metrics_source';
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@ import { identity } from 'fp-ts/lib/function';
|
|||
import { pipe } from 'fp-ts/lib/pipeable';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { throwErrors, createPlainError } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
ProcessListAPIChartResponse,
|
||||
ProcessListAPIChartResponseRT,
|
||||
} from '../../../../common/http_api';
|
||||
import { throwErrors, createPlainError } from '../../../../common/runtime_types';
|
||||
import { useHTTPRequest } from '../../../hooks/use_http_request';
|
||||
import { useProcessListContext } from './use_process_list';
|
||||
|
||||
|
|
|
@ -9,12 +9,12 @@ import { fold } from 'fp-ts/lib/Either';
|
|||
import { identity } from 'fp-ts/lib/function';
|
||||
import { pipe } from 'fp-ts/lib/pipeable';
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import { throwErrors, createPlainError } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
ServicesAPIResponse,
|
||||
ServicesAPIResponseRT,
|
||||
ServicesAPIRequest,
|
||||
} from '../../../../common/http_api/host_details';
|
||||
import { throwErrors, createPlainError } from '../../../../common/runtime_types';
|
||||
import { useHTTPRequest } from '../../../hooks/use_http_request';
|
||||
import { useRequestObservable } from './use_request_observable';
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import { HttpHandler } from '@kbn/core/public';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
CategorizerStatus,
|
||||
getLatestLogEntryCategoryDatasetsStatsRequestPayloadRT,
|
||||
|
@ -13,7 +14,6 @@ import {
|
|||
LogEntryCategoriesDatasetStats,
|
||||
LOG_ANALYSIS_GET_LATEST_LOG_ENTRY_CATEGORY_DATASETS_STATS_PATH,
|
||||
} from '../../../../../common/http_api';
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
|
||||
export type { LogEntryCategoriesDatasetStats };
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
import * as rt from 'io-ts';
|
||||
import type { HttpHandler } from '@kbn/core/public';
|
||||
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { IdFormat, JobType } from '../../../../../common/http_api/latest';
|
||||
import { getDatafeedId, getJobId } from '../../../../../common/log_analysis';
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
|
||||
interface DeleteJobsRequestArgs<T extends JobType> {
|
||||
spaceId: string;
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
import * as rt from 'io-ts';
|
||||
import type { HttpHandler } from '@kbn/core/public';
|
||||
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { IdFormat, JobType } from '../../../../../common/http_api/latest';
|
||||
import { getJobId, jobCustomSettingsRT } from '../../../../../common/log_analysis';
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
|
||||
interface RequestArgs<T extends JobType> {
|
||||
spaceId: string;
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
import * as rt from 'io-ts';
|
||||
import type { HttpHandler } from '@kbn/core/public';
|
||||
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { jobCustomSettingsRT } from '../../../../../common/log_analysis';
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
|
||||
export const callGetMlModuleAPI = async (moduleId: string, fetch: HttpHandler) => {
|
||||
const response = await fetch(`/internal/ml/modules/get_module/${moduleId}`, {
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
import * as rt from 'io-ts';
|
||||
import type { HttpHandler } from '@kbn/core/public';
|
||||
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { getJobIdPrefix, jobCustomSettingsRT } from '../../../../../common/log_analysis';
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
|
||||
interface RequestArgs {
|
||||
moduleId: string;
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import type { HttpHandler } from '@kbn/core/public';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
LOG_ANALYSIS_VALIDATE_DATASETS_PATH,
|
||||
validateLogEntryDatasetsRequestPayloadRT,
|
||||
validateLogEntryDatasetsResponsePayloadRT,
|
||||
} from '../../../../../common/http_api';
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
|
||||
interface RequestArgs {
|
||||
indices: string[];
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
import type { HttpHandler } from '@kbn/core/public';
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
LOG_ANALYSIS_VALIDATE_INDICES_PATH,
|
||||
ValidationIndicesFieldSpecification,
|
||||
|
@ -15,8 +16,6 @@ import {
|
|||
validationIndicesResponsePayloadRT,
|
||||
} from '../../../../../common/http_api';
|
||||
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
|
||||
interface RequestArgs {
|
||||
indices: string[];
|
||||
fields: ValidationIndicesFieldSpecification[];
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
|
||||
import createContainer from 'constate';
|
||||
import { useMemo, useState, useEffect } from 'react';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { useTrackedPromise } from '../../../hooks/use_tracked_promise';
|
||||
import {
|
||||
getMlCapabilitiesResponsePayloadRT,
|
||||
GetMlCapabilitiesResponsePayload,
|
||||
} from './api/ml_api_types';
|
||||
import { decodeOrThrow } from '../../../../common/runtime_types';
|
||||
import { useKibanaContextForPlugin } from '../../../hooks/use_kibana';
|
||||
|
||||
export const useLogAnalysisCapabilities = () => {
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
import * as rt from 'io-ts';
|
||||
import type { HttpHandler } from '@kbn/core/public';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { getDatafeedId, getJobId } from '../../../../common/infra_ml';
|
||||
import { decodeOrThrow } from '../../../../common/runtime_types';
|
||||
|
||||
interface DeleteJobsRequestArgs<JobType extends string> {
|
||||
spaceId: string;
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
import * as rt from 'io-ts';
|
||||
import type { HttpHandler } from '@kbn/core/public';
|
||||
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { getJobId, jobCustomSettingsRT } from '../../../../common/infra_ml';
|
||||
import { decodeOrThrow } from '../../../../common/runtime_types';
|
||||
|
||||
interface RequestArgs<JobType extends string> {
|
||||
spaceId: string;
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
import * as rt from 'io-ts';
|
||||
import type { HttpHandler } from '@kbn/core/public';
|
||||
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { jobCustomSettingsRT } from '../../../../common/infra_ml';
|
||||
import { decodeOrThrow } from '../../../../common/runtime_types';
|
||||
|
||||
export const callGetMlModuleAPI = async (moduleId: string, fetch: HttpHandler) => {
|
||||
const response = await fetch(`/internal/ml/modules/get_module/${moduleId}`, {
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
import * as rt from 'io-ts';
|
||||
import type { HttpHandler } from '@kbn/core/public';
|
||||
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { getJobIdPrefix, jobCustomSettingsRT } from '../../../../common/infra_ml';
|
||||
import { decodeOrThrow } from '../../../../common/runtime_types';
|
||||
|
||||
interface RequestArgs {
|
||||
moduleId: string;
|
||||
|
|
|
@ -10,12 +10,12 @@ import { useMemo, useState, useEffect } from 'react';
|
|||
import { fold } from 'fp-ts/lib/Either';
|
||||
import { pipe } from 'fp-ts/lib/pipeable';
|
||||
import { identity } from 'fp-ts/lib/function';
|
||||
import { throwErrors, createPlainError } from '@kbn/io-ts-utils';
|
||||
import { useTrackedPromise } from '../../hooks/use_tracked_promise';
|
||||
import {
|
||||
getMlCapabilitiesResponsePayloadRT,
|
||||
GetMlCapabilitiesResponsePayload,
|
||||
} from './api/ml_api_types';
|
||||
import { throwErrors, createPlainError } from '../../../common/runtime_types';
|
||||
import { useKibanaContextForPlugin } from '../../hooks/use_kibana';
|
||||
|
||||
export const useInfraMLCapabilities = () => {
|
||||
|
|
|
@ -12,8 +12,8 @@ import { HttpStart, NotificationsStart } from '@kbn/core/public';
|
|||
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import { API_BASE_PATH as LICENSE_MANAGEMENT_API_BASE_PATH } from '@kbn/license-management-plugin/common/constants';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { useTrackedPromise } from './use_tracked_promise';
|
||||
import { decodeOrThrow } from '../../common/runtime_types';
|
||||
|
||||
interface UseTrialStatusState {
|
||||
loadState: 'uninitialized' | 'pending' | 'resolved' | 'rejected';
|
||||
|
|
|
@ -10,8 +10,8 @@ import { IKbnUrlStateStorage, withNotifyOnErrors } from '@kbn/kibana-utils-plugi
|
|||
import * as Either from 'fp-ts/lib/Either';
|
||||
import { pipe } from 'fp-ts/lib/function';
|
||||
import { InvokeCreator } from 'xstate';
|
||||
import { createPlainError, formatErrors } from '@kbn/io-ts-utils';
|
||||
import { minimalTimeKeyRT, pickTimeKey } from '../../../../common/time';
|
||||
import { createPlainError, formatErrors } from '../../../../common/runtime_types';
|
||||
import type { LogStreamPositionContext, LogStreamPositionEvent } from './types';
|
||||
interface LogStreamPositionUrlStateDependencies {
|
||||
positionStateKey?: string;
|
||||
|
|
|
@ -18,13 +18,13 @@ import {
|
|||
DEFAULT_REFRESH_INTERVAL,
|
||||
} from '@kbn/logs-shared-plugin/common';
|
||||
import moment from 'moment';
|
||||
import { createPlainError, formatErrors } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
getTimeRangeEndFromTime,
|
||||
getTimeRangeStartFromTime,
|
||||
} from '../../../../common/url_state_storage_service';
|
||||
import { minimalTimeKeyRT } from '../../../../common/time';
|
||||
import { datemathStringRT } from '../../../utils/datemath';
|
||||
import { createPlainError, formatErrors } from '../../../../common/runtime_types';
|
||||
import type { LogStreamQueryContext, LogStreamQueryEvent, ParsedQuery } from './types';
|
||||
import { DEFAULT_FILTERS, DEFAULT_QUERY, DEFAULT_TIMERANGE } from './defaults';
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import type { HttpHandler } from '@kbn/core/public';
|
||||
import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { IdFormat } from '../../../../../common/http_api/latest';
|
||||
|
||||
import {
|
||||
|
@ -14,7 +15,6 @@ import {
|
|||
getLogEntryCategoryDatasetsSuccessReponsePayloadRT,
|
||||
LOG_ANALYSIS_GET_LOG_ENTRY_CATEGORY_DATASETS_PATH,
|
||||
} from '../../../../../common/http_api';
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
|
||||
interface RequestArgs {
|
||||
logViewReference: PersistedLogViewReference;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import type { HttpHandler } from '@kbn/core/public';
|
||||
import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { IdFormat } from '../../../../../common/http_api/latest';
|
||||
|
||||
import {
|
||||
|
@ -14,7 +15,6 @@ import {
|
|||
getLogEntryCategoryExamplesSuccessReponsePayloadRT,
|
||||
LOG_ANALYSIS_GET_LOG_ENTRY_CATEGORY_EXAMPLES_PATH,
|
||||
} from '../../../../../common/http_api';
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
|
||||
interface RequestArgs {
|
||||
logViewReference: PersistedLogViewReference;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import type { HttpHandler } from '@kbn/core/public';
|
||||
import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { IdFormat } from '../../../../../common/http_api/latest';
|
||||
|
||||
import {
|
||||
|
@ -15,7 +16,6 @@ import {
|
|||
LOG_ANALYSIS_GET_LOG_ENTRY_CATEGORIES_PATH,
|
||||
} from '../../../../../common/http_api';
|
||||
import { CategoriesSort } from '../../../../../common/log_analysis';
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
|
||||
interface RequestArgs {
|
||||
logViewReference: PersistedLogViewReference;
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
|
||||
import type { HttpHandler } from '@kbn/core/public';
|
||||
import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { IdFormatByJobType } from '../../../../../common/http_api/latest';
|
||||
import {
|
||||
getLogEntryAnomaliesRequestPayloadRT,
|
||||
getLogEntryAnomaliesSuccessReponsePayloadRT,
|
||||
LOG_ANALYSIS_GET_LOG_ENTRY_ANOMALIES_PATH,
|
||||
} from '../../../../../common/http_api';
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
import { AnomaliesSort, Pagination } from '../../../../../common/log_analysis';
|
||||
|
||||
interface RequestArgs {
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
import type { HttpHandler } from '@kbn/core/public';
|
||||
import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { IdFormatByJobType } from '../../../../../common/http_api/latest';
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
import {
|
||||
getLogEntryAnomaliesDatasetsRequestPayloadRT,
|
||||
getLogEntryAnomaliesDatasetsSuccessReponsePayloadRT,
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import type { HttpHandler } from '@kbn/core/public';
|
||||
import { PersistedLogViewReference } from '@kbn/logs-shared-plugin/common';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { IdFormat } from '../../../../../common/http_api/latest';
|
||||
|
||||
import {
|
||||
|
@ -14,7 +15,6 @@ import {
|
|||
getLogEntryExamplesSuccessResponsePayloadRT,
|
||||
LOG_ANALYSIS_GET_LOG_ENTRY_RATE_EXAMPLES_PATH,
|
||||
} from '../../../../../common/http_api';
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
|
||||
interface RequestArgs {
|
||||
logViewReference: PersistedLogViewReference;
|
||||
|
|
|
@ -11,13 +11,13 @@ import datemath from '@kbn/datemath';
|
|||
import moment from 'moment';
|
||||
import * as rt from 'io-ts';
|
||||
import type { TimeRange as KibanaTimeRange } from '@kbn/es-query';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { TimeRange } from '../../../../common/time/time_range';
|
||||
import { useUrlState } from '../../../hooks/use_url_state';
|
||||
import {
|
||||
useKibanaTimefilterTime,
|
||||
useSyncKibanaTimeFilterTime,
|
||||
} from '../../../hooks/use_kibana_timefilter_time';
|
||||
import { decodeOrThrow } from '../../../../common/runtime_types';
|
||||
|
||||
const autoRefreshRT = rt.type({
|
||||
interval: rt.number,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { HttpHandler } from '@kbn/core/public';
|
||||
import { decodeOrThrow } from '../../../../common/runtime_types';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
getLogAnalysisIdFormatsRequestPayloadRT,
|
||||
getLogAnalysisIdFormatsSuccessResponsePayloadRT,
|
||||
|
|
|
@ -12,10 +12,10 @@ import { useCallback, useEffect, useMemo } from 'react';
|
|||
import { catchError, map, Observable, of, startWith, tap } from 'rxjs';
|
||||
import createContainer from 'constate';
|
||||
import type { QueryDslQueryContainer, SearchResponse } from '@elastic/elasticsearch/lib/api/types';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { HOST_NAME_FIELD, TIMESTAMP_FIELD } from '../../../../../common/constants';
|
||||
import type { ITelemetryClient } from '../../../../services/telemetry';
|
||||
import { useKibanaContextForPlugin } from '../../../../hooks/use_kibana';
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
import { useDataSearch, useLatestPartialDataSearchResponse } from '../../../../utils/data_search';
|
||||
import { useMetricsDataViewContext } from '../../../../containers/metrics_source';
|
||||
import { useUnifiedSearchContext } from './use_unified_search';
|
||||
|
|
|
@ -10,7 +10,7 @@ import { identity } from 'fp-ts/lib/function';
|
|||
import { pipe } from 'fp-ts/lib/pipeable';
|
||||
import { useEffect } from 'react';
|
||||
import { InventoryItemType } from '@kbn/metrics-data-access-plugin/common';
|
||||
import { throwErrors, createPlainError } from '../../../../../common/runtime_types';
|
||||
import { throwErrors, createPlainError } from '@kbn/io-ts-utils';
|
||||
import { useHTTPRequest } from '../../../../hooks/use_http_request';
|
||||
import {
|
||||
InventoryMetaResponseRT,
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import { useState, useCallback, useEffect, useReducer, useRef } from 'react';
|
||||
import { HttpHandler } from '@kbn/core/public';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
INFA_ML_GET_METRICS_HOSTS_ANOMALIES_PATH,
|
||||
Metric,
|
||||
|
@ -18,7 +19,6 @@ import {
|
|||
getMetricsHostsAnomaliesSuccessReponsePayloadRT,
|
||||
} from '../../../../../common/http_api/infra_ml';
|
||||
import { useTrackedPromise } from '../../../../hooks/use_tracked_promise';
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
import { useKibanaContextForPlugin } from '../../../../hooks/use_kibana';
|
||||
|
||||
export type SortOptions = Sort;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import { useState, useCallback, useEffect, useReducer, useRef } from 'react';
|
||||
import { HttpHandler } from '@kbn/core/public';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
Sort,
|
||||
Pagination,
|
||||
|
@ -18,7 +19,6 @@ import {
|
|||
Metric,
|
||||
} from '../../../../../common/http_api/infra_ml';
|
||||
import { useTrackedPromise } from '../../../../hooks/use_tracked_promise';
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
import { useKibanaContextForPlugin } from '../../../../hooks/use_kibana';
|
||||
|
||||
export type SortOptions = Sort;
|
||||
|
|
|
@ -9,7 +9,7 @@ import { fold } from 'fp-ts/lib/Either';
|
|||
import { identity } from 'fp-ts/lib/function';
|
||||
import { pipe } from 'fp-ts/lib/pipeable';
|
||||
import { useEffect } from 'react';
|
||||
import { throwErrors, createPlainError } from '../../../../../common/runtime_types';
|
||||
import { throwErrors, createPlainError } from '@kbn/io-ts-utils';
|
||||
import { useHTTPRequest } from '../../../../hooks/use_http_request';
|
||||
import {
|
||||
InfraTimerangeInput,
|
||||
|
|
|
@ -9,7 +9,7 @@ import { fold } from 'fp-ts/lib/Either';
|
|||
import { identity } from 'fp-ts/lib/function';
|
||||
import { pipe } from 'fp-ts/lib/pipeable';
|
||||
import { InventoryMetric, InventoryItemType } from '@kbn/metrics-data-access-plugin/common';
|
||||
import { throwErrors, createPlainError } from '../../../../../common/runtime_types';
|
||||
import { throwErrors, createPlainError } from '@kbn/io-ts-utils';
|
||||
import { useHTTPRequest } from '../../../../hooks/use_http_request';
|
||||
import {
|
||||
NodeDetailsMetricDataResponseRT,
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import { useInfiniteQuery } from '@tanstack/react-query';
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { useMetricsDataViewContext } from '../../../../containers/metrics_source';
|
||||
import {
|
||||
MetricsExplorerResponse,
|
||||
|
@ -14,7 +15,6 @@ import {
|
|||
} from '../../../../../common/http_api/metrics_explorer';
|
||||
import { convertKueryToElasticSearchQuery } from '../../../../utils/kuery';
|
||||
import { MetricsExplorerOptions, MetricsExplorerTimestamp } from './use_metrics_explorer_options';
|
||||
import { decodeOrThrow } from '../../../../../common/runtime_types';
|
||||
|
||||
export function useMetricsExplorerData({
|
||||
options,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import { HttpStart } from '@kbn/core/public';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
CreateInventoryViewAttributesRequestPayload,
|
||||
createInventoryViewRequestPayloadRT,
|
||||
|
@ -23,7 +24,6 @@ import {
|
|||
FetchInventoryViewError,
|
||||
UpsertInventoryViewError,
|
||||
} from '../../../common/inventory_views';
|
||||
import { decodeOrThrow } from '../../../common/runtime_types';
|
||||
import { IInventoryViewsClient } from './types';
|
||||
|
||||
export class InventoryViewsClient implements IInventoryViewsClient {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import { HttpStart } from '@kbn/core/public';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
CreateMetricsExplorerViewResponsePayload,
|
||||
createMetricsExplorerViewRequestPayloadRT,
|
||||
|
@ -23,7 +24,6 @@ import {
|
|||
FetchMetricsExplorerViewError,
|
||||
UpsertMetricsExplorerViewError,
|
||||
} from '../../../common/metrics_explorer_views';
|
||||
import { decodeOrThrow } from '../../../common/runtime_types';
|
||||
import { IMetricsExplorerViewsClient } from './types';
|
||||
|
||||
export class MetricsExplorerViewsClient implements IMetricsExplorerViewsClient {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { ResolvedLogView } from '@kbn/logs-shared-plugin/common';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
ExecutionTimeRange,
|
||||
GroupedSearchQueryResponse,
|
||||
|
@ -20,7 +21,6 @@ import {
|
|||
Point,
|
||||
Series,
|
||||
} from '../../../../common/http_api';
|
||||
import { decodeOrThrow } from '../../../../common/runtime_types';
|
||||
import type { InfraPluginRequestHandlerContext } from '../../../types';
|
||||
import { KibanaFramework } from '../../adapters/framework/kibana_framework_adapter';
|
||||
import { buildFiltersFromCriteria } from '../../../../common/alerting/logs/log_threshold/query_helpers';
|
||||
|
|
|
@ -33,6 +33,7 @@ import {
|
|||
} from '@kbn/alerting-plugin/server/alerts_client/types';
|
||||
|
||||
import { ecsFieldMap } from '@kbn/rule-registry-plugin/common/assets/field_maps/ecs_field_map';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { getChartGroupNames } from '../../../../common/utils/get_chart_group_names';
|
||||
import {
|
||||
RuleParams,
|
||||
|
@ -55,7 +56,6 @@ import {
|
|||
ExecutionTimeRange,
|
||||
Criterion,
|
||||
} from '../../../../common/alerting/logs/log_threshold';
|
||||
import { decodeOrThrow } from '../../../../common/runtime_types';
|
||||
import { getLogsAppAlertUrl } from '../../../../common/formatters/alert_link';
|
||||
import { InfraBackendLibs } from '../../infra_types';
|
||||
import {
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
import type { SavedObjectReference } from '@kbn/core/server';
|
||||
import { logViewReferenceRT } from '@kbn/logs-shared-plugin/common';
|
||||
import { logViewSavedObjectName } from '@kbn/logs-shared-plugin/server';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { RuleParams, ruleParamsRT } from '../../../../common/alerting/logs/log_threshold';
|
||||
import { decodeOrThrow } from '../../../../common/runtime_types';
|
||||
|
||||
export const LOG_VIEW_REFERENCE_NAME = 'log-view-reference-0';
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import { i18n } from '@kbn/i18n';
|
|||
import { DEFAULT_APP_CATEGORIES } from '@kbn/core/server';
|
||||
import { GetViewInAppRelativeUrlFnOpts, PluginSetupContract } from '@kbn/alerting-plugin/server';
|
||||
import { observabilityPaths } from '@kbn/observability-plugin/common';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import type { InfraConfig } from '../../../../common/plugin_config_types';
|
||||
import { O11Y_AAD_FIELDS } from '../../../../common/constants';
|
||||
import { createLogThresholdExecutor, FIRED_ACTIONS } from './log_threshold_executor';
|
||||
|
@ -18,7 +19,6 @@ import {
|
|||
ruleParamsRT,
|
||||
} from '../../../../common/alerting/logs/log_threshold';
|
||||
import { InfraBackendLibs } from '../../infra_types';
|
||||
import { decodeOrThrow } from '../../../../common/runtime_types';
|
||||
import {
|
||||
alertDetailUrlActionVariableDescription,
|
||||
groupByKeysActionVariableDescription,
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import type { MlAnomalyDetectors, MlSystem } from '../../types';
|
||||
import { NoLogAnalysisMlJobError } from './errors';
|
||||
|
||||
|
@ -14,7 +15,6 @@ import {
|
|||
LogEntryDatasetBucket,
|
||||
logEntryDatasetsResponseRT,
|
||||
} from './queries/log_entry_data_sets';
|
||||
import { decodeOrThrow } from '../../../common/runtime_types';
|
||||
import { startTracingSpan, TracingSpan } from '../../../common/performance_tracing';
|
||||
|
||||
export interface MappedAnomalyHit {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import { ML_ANOMALY_THRESHOLD } from '@kbn/ml-anomaly-utils/anomaly_threshold';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { InfraRequestHandlerContext } from '../../types';
|
||||
import { TracingSpan, startTracingSpan } from '../../../common/performance_tracing';
|
||||
import { fetchMlJob, MappedAnomalyHit, InfluencerFilter } from './common';
|
||||
|
@ -13,7 +14,6 @@ import { getJobId, metricsHostsJobTypes } from '../../../common/infra_ml';
|
|||
import { Sort, Pagination } from '../../../common/http_api/infra_ml';
|
||||
import type { MlSystem, MlAnomalyDetectors } from '../../types';
|
||||
import { isMlPrivilegesError } from './errors';
|
||||
import { decodeOrThrow } from '../../../common/runtime_types';
|
||||
import {
|
||||
metricsHostsAnomaliesResponseRT,
|
||||
createMetricsHostsAnomaliesQuery,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import { ML_ANOMALY_THRESHOLD } from '@kbn/ml-anomaly-utils/anomaly_threshold';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { InfraRequestHandlerContext } from '../../types';
|
||||
import { TracingSpan, startTracingSpan } from '../../../common/performance_tracing';
|
||||
import { fetchMlJob, MappedAnomalyHit, InfluencerFilter } from './common';
|
||||
|
@ -13,7 +14,6 @@ import { getJobId, metricsK8SJobTypes } from '../../../common/infra_ml';
|
|||
import { Sort, Pagination } from '../../../common/http_api/infra_ml';
|
||||
import type { MlSystem, MlAnomalyDetectors } from '../../types';
|
||||
import { isMlPrivilegesError } from './errors';
|
||||
import { decodeOrThrow } from '../../../common/runtime_types';
|
||||
import {
|
||||
metricsK8sAnomaliesResponseRT,
|
||||
createMetricsK8sAnomaliesQuery,
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import type { MlAnomalyDetectors, MlSystem } from '../../types';
|
||||
import { NoLogAnalysisMlJobError } from './errors';
|
||||
|
||||
|
@ -14,7 +15,6 @@ import {
|
|||
LogEntryDatasetBucket,
|
||||
logEntryDatasetsResponseRT,
|
||||
} from './queries/log_entry_data_sets';
|
||||
import { decodeOrThrow } from '../../../common/runtime_types';
|
||||
import { startTracingSpan, TracingSpan } from '../../../common/performance_tracing';
|
||||
|
||||
export async function fetchMlJob(mlAnomalyDetectors: MlAnomalyDetectors, jobId: string) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { PersistedLogViewReference, ResolvedLogView } from '@kbn/logs-shared-plugin/common';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { IdFormat, IdFormatByJobType } from '../../../common/http_api/latest';
|
||||
import {
|
||||
AnomaliesSort,
|
||||
|
@ -21,7 +22,6 @@ import {
|
|||
Pagination,
|
||||
} from '../../../common/log_analysis';
|
||||
import { startTracingSpan, TracingSpan } from '../../../common/performance_tracing';
|
||||
import { decodeOrThrow } from '../../../common/runtime_types';
|
||||
import type {
|
||||
InfraPluginRequestHandlerContext,
|
||||
InfraRequestHandlerContext,
|
||||
|
|
|
@ -12,6 +12,7 @@ import {
|
|||
PersistedLogViewReference,
|
||||
ResolvedLogView,
|
||||
} from '@kbn/logs-shared-plugin/common';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { IdFormat } from '../../../common/http_api/latest';
|
||||
import {
|
||||
CategoriesSort,
|
||||
|
@ -21,7 +22,6 @@ import {
|
|||
logEntryCategoriesJobTypes,
|
||||
} from '../../../common/log_analysis';
|
||||
import { startTracingSpan } from '../../../common/performance_tracing';
|
||||
import { decodeOrThrow } from '../../../common/runtime_types';
|
||||
import type { MlAnomalyDetectors, MlSystem } from '../../types';
|
||||
import { fetchMlJob, getLogEntryDatasets } from './common';
|
||||
import { InsufficientLogAnalysisMlJobConfigurationError, UnknownCategoryError } from './errors';
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { startTracingSpan } from '../../../common/performance_tracing';
|
||||
import { decodeOrThrow } from '../../../common/runtime_types';
|
||||
import type { MlAnomalyDetectors, MlSystem } from '../../types';
|
||||
import { COMPOSITE_AGGREGATION_BATCH_SIZE } from './common';
|
||||
import {
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { IdFormat } from '../../../common/http_api/latest';
|
||||
import { decodeOrThrow } from '../../../common/runtime_types';
|
||||
import {
|
||||
logRateModelPlotResponseRT,
|
||||
createLogEntryRateQuery,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { decodeOrThrow } from '../../../common/runtime_types';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { TIMESTAMP_FIELD } from '../../../common/constants';
|
||||
import { MetricsAPIRequest, MetricsAPIResponse } from '../../../common/http_api';
|
||||
import {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import Boom from '@hapi/boom';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import { InfraBackendLibs } from '../../../lib/infra_types';
|
||||
import {
|
||||
INFA_ML_GET_METRICS_HOSTS_ANOMALIES_PATH,
|
||||
|
@ -15,7 +16,6 @@ import {
|
|||
Sort,
|
||||
Pagination,
|
||||
} from '../../../../common/http_api/infra_ml';
|
||||
import { createValidationFunction } from '../../../../common/runtime_types';
|
||||
import { assertHasInfraMlPlugins } from '../../../utils/request_context';
|
||||
|
||||
import { isMlPrivilegesError } from '../../../lib/infra_ml/errors';
|
||||
|
@ -27,7 +27,7 @@ export const initGetHostsAnomaliesRoute = ({ framework }: InfraBackendLibs) => {
|
|||
method: 'post',
|
||||
path: INFA_ML_GET_METRICS_HOSTS_ANOMALIES_PATH,
|
||||
validate: {
|
||||
body: createValidationFunction(getMetricsHostsAnomaliesRequestPayloadRT),
|
||||
body: createRouteValidationFunction(getMetricsHostsAnomaliesRequestPayloadRT),
|
||||
},
|
||||
},
|
||||
framework.router.handleLegacyErrors(async (requestContext, request, response) => {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import Boom from '@hapi/boom';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import { InfraBackendLibs } from '../../../lib/infra_types';
|
||||
import {
|
||||
INFA_ML_GET_METRICS_K8S_ANOMALIES_PATH,
|
||||
|
@ -15,7 +16,6 @@ import {
|
|||
Sort,
|
||||
Pagination,
|
||||
} from '../../../../common/http_api/infra_ml';
|
||||
import { createValidationFunction } from '../../../../common/runtime_types';
|
||||
import { assertHasInfraMlPlugins } from '../../../utils/request_context';
|
||||
import { getMetricK8sAnomalies } from '../../../lib/infra_ml';
|
||||
import { isMlPrivilegesError } from '../../../lib/infra_ml/errors';
|
||||
|
@ -26,7 +26,7 @@ export const initGetK8sAnomaliesRoute = ({ framework }: InfraBackendLibs) => {
|
|||
method: 'post',
|
||||
path: INFA_ML_GET_METRICS_K8S_ANOMALIES_PATH,
|
||||
validate: {
|
||||
body: createValidationFunction(getMetricsK8sAnomaliesRequestPayloadRT),
|
||||
body: createRouteValidationFunction(getMetricsK8sAnomaliesRequestPayloadRT),
|
||||
},
|
||||
},
|
||||
framework.router.handleLegacyErrors(async (requestContext, request, response) => {
|
||||
|
|
|
@ -10,8 +10,8 @@ import Boom from '@hapi/boom';
|
|||
import { pipe } from 'fp-ts/lib/pipeable';
|
||||
import { fold } from 'fp-ts/lib/Either';
|
||||
import { identity } from 'fp-ts/lib/function';
|
||||
import { throwErrors } from '@kbn/io-ts-utils';
|
||||
import { InfraBackendLibs } from '../../lib/infra_types';
|
||||
import { throwErrors } from '../../../common/runtime_types';
|
||||
|
||||
import {
|
||||
InventoryMetaRequestRT,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { isBoom } from '@hapi/boom';
|
||||
import { createValidationFunction } from '../../../common/runtime_types';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
createInventoryViewRequestPayloadRT,
|
||||
inventoryViewRequestQueryRT,
|
||||
|
@ -24,8 +24,8 @@ export const initCreateInventoryViewRoute = ({
|
|||
method: 'post',
|
||||
path: INVENTORY_VIEW_URL,
|
||||
validate: {
|
||||
body: createValidationFunction(createInventoryViewRequestPayloadRT),
|
||||
query: createValidationFunction(inventoryViewRequestQueryRT),
|
||||
body: createRouteValidationFunction(createInventoryViewRequestPayloadRT),
|
||||
query: createRouteValidationFunction(inventoryViewRequestQueryRT),
|
||||
},
|
||||
},
|
||||
async (_requestContext, request, response) => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { isBoom } from '@hapi/boom';
|
||||
import { createValidationFunction } from '../../../common/runtime_types';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
inventoryViewRequestParamsRT,
|
||||
INVENTORY_VIEW_URL_ENTITY,
|
||||
|
@ -22,7 +22,7 @@ export const initDeleteInventoryViewRoute = ({
|
|||
method: 'delete',
|
||||
path: INVENTORY_VIEW_URL_ENTITY,
|
||||
validate: {
|
||||
params: createValidationFunction(inventoryViewRequestParamsRT),
|
||||
params: createRouteValidationFunction(inventoryViewRequestParamsRT),
|
||||
},
|
||||
},
|
||||
async (_requestContext, request, response) => {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { createValidationFunction } from '../../../common/runtime_types';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
findInventoryViewResponsePayloadRT,
|
||||
inventoryViewRequestQueryRT,
|
||||
|
@ -22,7 +22,7 @@ export const initFindInventoryViewRoute = ({
|
|||
method: 'get',
|
||||
path: INVENTORY_VIEW_URL,
|
||||
validate: {
|
||||
query: createValidationFunction(inventoryViewRequestQueryRT),
|
||||
query: createRouteValidationFunction(inventoryViewRequestQueryRT),
|
||||
},
|
||||
},
|
||||
async (_requestContext, request, response) => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { isBoom } from '@hapi/boom';
|
||||
import { createValidationFunction } from '../../../common/runtime_types';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
inventoryViewResponsePayloadRT,
|
||||
inventoryViewRequestQueryRT,
|
||||
|
@ -24,8 +24,8 @@ export const initGetInventoryViewRoute = ({
|
|||
method: 'get',
|
||||
path: INVENTORY_VIEW_URL_ENTITY,
|
||||
validate: {
|
||||
params: createValidationFunction(getInventoryViewRequestParamsRT),
|
||||
query: createValidationFunction(inventoryViewRequestQueryRT),
|
||||
params: createRouteValidationFunction(getInventoryViewRequestParamsRT),
|
||||
query: createRouteValidationFunction(inventoryViewRequestQueryRT),
|
||||
},
|
||||
},
|
||||
async (_requestContext, request, response) => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { isBoom } from '@hapi/boom';
|
||||
import { createValidationFunction } from '../../../common/runtime_types';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
inventoryViewRequestParamsRT,
|
||||
inventoryViewRequestQueryRT,
|
||||
|
@ -25,9 +25,9 @@ export const initUpdateInventoryViewRoute = ({
|
|||
method: 'put',
|
||||
path: INVENTORY_VIEW_URL_ENTITY,
|
||||
validate: {
|
||||
params: createValidationFunction(inventoryViewRequestParamsRT),
|
||||
query: createValidationFunction(inventoryViewRequestQueryRT),
|
||||
body: createValidationFunction(updateInventoryViewRequestPayloadRT),
|
||||
params: createRouteValidationFunction(inventoryViewRequestParamsRT),
|
||||
query: createRouteValidationFunction(inventoryViewRequestQueryRT),
|
||||
body: createRouteValidationFunction(updateInventoryViewRequestPayloadRT),
|
||||
},
|
||||
},
|
||||
async (_requestContext, request, response) => {
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
*/
|
||||
|
||||
import Boom from '@hapi/boom';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import { logAlertsV1 } from '../../../common/http_api';
|
||||
import { InfraBackendLibs } from '../../lib/infra_types';
|
||||
|
||||
import { createValidationFunction } from '../../../common/runtime_types';
|
||||
import { getChartPreviewData } from '../../lib/alerting/log_threshold/log_threshold_chart_preview';
|
||||
|
||||
export const initGetLogAlertsChartPreviewDataRoute = ({
|
||||
|
@ -31,7 +31,7 @@ export const initGetLogAlertsChartPreviewDataRoute = ({
|
|||
version: '1',
|
||||
validate: {
|
||||
request: {
|
||||
body: createValidationFunction(
|
||||
body: createRouteValidationFunction(
|
||||
logAlertsV1.getLogAlertsChartPreviewDataRequestPayloadRT
|
||||
),
|
||||
},
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
*/
|
||||
|
||||
import Boom from '@hapi/boom';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import { logAnalysisResultsV1 } from '../../../../common/http_api';
|
||||
import { InfraBackendLibs } from '../../../lib/infra_types';
|
||||
|
||||
import { AnomaliesSort, Pagination } from '../../../../common/log_analysis';
|
||||
import { createValidationFunction } from '../../../../common/runtime_types';
|
||||
import { assertHasInfraMlPlugins } from '../../../utils/request_context';
|
||||
import { getLogEntryAnomalies } from '../../../lib/log_analysis';
|
||||
import { isMlPrivilegesError } from '../../../lib/log_analysis/errors';
|
||||
|
@ -30,7 +30,7 @@ export const initGetLogEntryAnomaliesRoute = ({ framework }: InfraBackendLibs) =
|
|||
version: '1',
|
||||
validate: {
|
||||
request: {
|
||||
body: createValidationFunction(
|
||||
body: createRouteValidationFunction(
|
||||
logAnalysisResultsV1.getLogEntryAnomaliesRequestPayloadRT
|
||||
),
|
||||
},
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
import Boom from '@hapi/boom';
|
||||
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import { logAnalysisResultsV1 } from '../../../../common/http_api';
|
||||
import { createValidationFunction } from '../../../../common/runtime_types';
|
||||
import type { InfraBackendLibs } from '../../../lib/infra_types';
|
||||
import { getLogEntryAnomaliesDatasets } from '../../../lib/log_analysis';
|
||||
import { assertHasInfraMlPlugins } from '../../../utils/request_context';
|
||||
|
@ -29,7 +29,7 @@ export const initGetLogEntryAnomaliesDatasetsRoute = ({ framework }: InfraBacken
|
|||
version: '1',
|
||||
validate: {
|
||||
request: {
|
||||
body: createValidationFunction(
|
||||
body: createRouteValidationFunction(
|
||||
logAnalysisResultsV1.getLogEntryAnomaliesDatasetsRequestPayloadRT
|
||||
),
|
||||
},
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
import Boom from '@hapi/boom';
|
||||
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import { logAnalysisResultsV1 } from '../../../../common/http_api';
|
||||
import { createValidationFunction } from '../../../../common/runtime_types';
|
||||
import type { InfraBackendLibs } from '../../../lib/infra_types';
|
||||
import { getTopLogEntryCategories } from '../../../lib/log_analysis';
|
||||
import { assertHasInfraMlPlugins } from '../../../utils/request_context';
|
||||
|
@ -29,7 +29,7 @@ export const initGetLogEntryCategoriesRoute = ({ framework }: InfraBackendLibs)
|
|||
version: '1',
|
||||
validate: {
|
||||
request: {
|
||||
body: createValidationFunction(
|
||||
body: createRouteValidationFunction(
|
||||
logAnalysisResultsV1.getLogEntryCategoriesRequestPayloadRT
|
||||
),
|
||||
},
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
import Boom from '@hapi/boom';
|
||||
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import { logAnalysisResultsV1 } from '../../../../common/http_api';
|
||||
import { createValidationFunction } from '../../../../common/runtime_types';
|
||||
import type { InfraBackendLibs } from '../../../lib/infra_types';
|
||||
import { getLogEntryCategoryDatasets } from '../../../lib/log_analysis';
|
||||
import { assertHasInfraMlPlugins } from '../../../utils/request_context';
|
||||
|
@ -29,7 +29,7 @@ export const initGetLogEntryCategoryDatasetsRoute = ({ framework }: InfraBackend
|
|||
version: '1',
|
||||
validate: {
|
||||
request: {
|
||||
body: createValidationFunction(
|
||||
body: createRouteValidationFunction(
|
||||
logAnalysisResultsV1.getLogEntryCategoryDatasetsRequestPayloadRT
|
||||
),
|
||||
},
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
*/
|
||||
|
||||
import Boom from '@hapi/boom';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import { logAnalysisResultsV1 } from '../../../../common/http_api';
|
||||
|
||||
import { createValidationFunction } from '../../../../common/runtime_types';
|
||||
import type { InfraBackendLibs } from '../../../lib/infra_types';
|
||||
import { getLatestLogEntriesCategoriesDatasetsStats } from '../../../lib/log_analysis';
|
||||
import { isMlPrivilegesError } from '../../../lib/log_analysis/errors';
|
||||
|
@ -29,7 +29,7 @@ export const initGetLogEntryCategoryDatasetsStatsRoute = ({ framework }: InfraBa
|
|||
version: '1',
|
||||
validate: {
|
||||
request: {
|
||||
body: createValidationFunction(
|
||||
body: createRouteValidationFunction(
|
||||
logAnalysisResultsV1.getLatestLogEntryCategoryDatasetsStatsRequestPayloadRT
|
||||
),
|
||||
},
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
*/
|
||||
|
||||
import Boom from '@hapi/boom';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import { logAnalysisResultsV1 } from '../../../../common/http_api';
|
||||
|
||||
import { createValidationFunction } from '../../../../common/runtime_types';
|
||||
import type { InfraBackendLibs } from '../../../lib/infra_types';
|
||||
import { getLogEntryCategoryExamples } from '../../../lib/log_analysis';
|
||||
import { isMlPrivilegesError } from '../../../lib/log_analysis/errors';
|
||||
|
@ -32,7 +32,7 @@ export const initGetLogEntryCategoryExamplesRoute = ({
|
|||
version: '1',
|
||||
validate: {
|
||||
request: {
|
||||
body: createValidationFunction(
|
||||
body: createRouteValidationFunction(
|
||||
logAnalysisResultsV1.getLogEntryCategoryExamplesRequestPayloadRT
|
||||
),
|
||||
},
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
*/
|
||||
|
||||
import Boom from '@hapi/boom';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import { logAnalysisResultsV1 } from '../../../../common/http_api';
|
||||
|
||||
import { createValidationFunction } from '../../../../common/runtime_types';
|
||||
import { InfraBackendLibs } from '../../../lib/infra_types';
|
||||
import { getLogEntryExamples } from '../../../lib/log_analysis';
|
||||
import { isMlPrivilegesError } from '../../../lib/log_analysis/errors';
|
||||
|
@ -32,7 +32,7 @@ export const initGetLogEntryExamplesRoute = ({
|
|||
version: '1',
|
||||
validate: {
|
||||
request: {
|
||||
body: createValidationFunction(
|
||||
body: createRouteValidationFunction(
|
||||
logAnalysisResultsV1.getLogEntryExamplesRequestPayloadRT
|
||||
),
|
||||
},
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
import Boom from '@hapi/boom';
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import { InfraBackendLibs } from '../../../lib/infra_types';
|
||||
|
||||
import { createValidationFunction } from '../../../../common/runtime_types';
|
||||
import { logAnalysisValidationV1 } from '../../../../common/http_api';
|
||||
|
||||
export const initValidateLogAnalysisDatasetsRoute = ({
|
||||
|
@ -31,7 +31,7 @@ export const initValidateLogAnalysisDatasetsRoute = ({
|
|||
version: '1',
|
||||
validate: {
|
||||
request: {
|
||||
body: createValidationFunction(
|
||||
body: createRouteValidationFunction(
|
||||
logAnalysisValidationV1.validateLogEntryDatasetsRequestPayloadRT
|
||||
),
|
||||
},
|
||||
|
|
|
@ -11,9 +11,9 @@ import { pipe } from 'fp-ts/lib/pipeable';
|
|||
import { fold } from 'fp-ts/lib/Either';
|
||||
import { identity } from 'fp-ts/lib/function';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { throwErrors } from '@kbn/io-ts-utils';
|
||||
import { InfraBackendLibs } from '../../../lib/infra_types';
|
||||
|
||||
import { throwErrors } from '../../../../common/runtime_types';
|
||||
import { logAnalysisValidationV1 } from '../../../../common/http_api';
|
||||
|
||||
const escapeHatch = schema.object({}, { unknowns: 'allow' });
|
||||
|
|
|
@ -11,6 +11,7 @@ import { get } from 'lodash';
|
|||
import { pipe } from 'fp-ts/lib/pipeable';
|
||||
import { fold } from 'fp-ts/lib/Either';
|
||||
import { identity } from 'fp-ts/lib/function';
|
||||
import { throwErrors } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
InfraMetadataFeature,
|
||||
InfraMetadataRequestRT,
|
||||
|
@ -21,7 +22,6 @@ import { getMetricMetadata } from './lib/get_metric_metadata';
|
|||
import { pickFeatureName } from './lib/pick_feature_name';
|
||||
import { getCloudMetricsMetadata } from './lib/get_cloud_metric_metadata';
|
||||
import { getNodeInfo } from './lib/get_node_info';
|
||||
import { throwErrors } from '../../../common/runtime_types';
|
||||
|
||||
const escapeHatch = schema.object({}, { unknowns: 'allow' });
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ import { pipe } from 'fp-ts/lib/pipeable';
|
|||
import { fold } from 'fp-ts/lib/Either';
|
||||
import { identity } from 'fp-ts/lib/function';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { throwErrors } from '@kbn/io-ts-utils';
|
||||
import { InfraBackendLibs } from '../../lib/infra_types';
|
||||
import { throwErrors } from '../../../common/runtime_types';
|
||||
import { createSearchClient } from '../../lib/create_search_client';
|
||||
import { query } from '../../lib/metrics';
|
||||
import { MetricsAPIRequestRT, MetricsAPIResponseRT } from '../../../common/http_api';
|
||||
|
|
|
@ -10,13 +10,13 @@ import { pipe } from 'fp-ts/lib/pipeable';
|
|||
import { fold } from 'fp-ts/lib/Either';
|
||||
import { identity } from 'fp-ts/lib/function';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { throwErrors } from '@kbn/io-ts-utils';
|
||||
import { InfraBackendLibs } from '../../lib/infra_types';
|
||||
import {
|
||||
metricsExplorerRequestBodyRT,
|
||||
metricsExplorerResponseRT,
|
||||
MetricsExplorerPageInfo,
|
||||
} from '../../../common/http_api';
|
||||
import { throwErrors } from '../../../common/runtime_types';
|
||||
import { convertRequestToMetricsAPIOptions } from './lib/convert_request_to_metrics_api_options';
|
||||
import { createSearchClient } from '../../lib/create_search_client';
|
||||
import { findIntervalForMetrics } from './lib/find_interval_for_metrics';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { isBoom } from '@hapi/boom';
|
||||
import { createValidationFunction } from '../../../common/runtime_types';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
createMetricsExplorerViewRequestPayloadRT,
|
||||
metricsExplorerViewRequestQueryRT,
|
||||
|
@ -31,8 +31,8 @@ export const initCreateMetricsExplorerViewRoute = ({
|
|||
method: 'post',
|
||||
path: METRICS_EXPLORER_VIEW_URL,
|
||||
validate: {
|
||||
body: createValidationFunction(createMetricsExplorerViewRequestPayloadRT),
|
||||
query: createValidationFunction(metricsExplorerViewRequestQueryRT),
|
||||
body: createRouteValidationFunction(createMetricsExplorerViewRequestPayloadRT),
|
||||
query: createRouteValidationFunction(metricsExplorerViewRequestQueryRT),
|
||||
},
|
||||
},
|
||||
async (_requestContext, request, response) => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { isBoom } from '@hapi/boom';
|
||||
import { createValidationFunction } from '../../../common/runtime_types';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
metricsExplorerViewRequestParamsRT,
|
||||
METRICS_EXPLORER_VIEW_URL_ENTITY,
|
||||
|
@ -29,7 +29,7 @@ export const initDeleteMetricsExplorerViewRoute = ({
|
|||
method: 'delete',
|
||||
path: METRICS_EXPLORER_VIEW_URL_ENTITY,
|
||||
validate: {
|
||||
params: createValidationFunction(metricsExplorerViewRequestParamsRT),
|
||||
params: createRouteValidationFunction(metricsExplorerViewRequestParamsRT),
|
||||
},
|
||||
},
|
||||
async (_requestContext, request, response) => {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { createValidationFunction } from '../../../common/runtime_types';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
findMetricsExplorerViewResponsePayloadRT,
|
||||
metricsExplorerViewRequestQueryRT,
|
||||
|
@ -29,7 +29,7 @@ export const initFindMetricsExplorerViewRoute = ({
|
|||
method: 'get',
|
||||
path: METRICS_EXPLORER_VIEW_URL,
|
||||
validate: {
|
||||
query: createValidationFunction(metricsExplorerViewRequestQueryRT),
|
||||
query: createRouteValidationFunction(metricsExplorerViewRequestQueryRT),
|
||||
},
|
||||
},
|
||||
async (_requestContext, request, response) => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { isBoom } from '@hapi/boom';
|
||||
import { createValidationFunction } from '../../../common/runtime_types';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
metricsExplorerViewResponsePayloadRT,
|
||||
metricsExplorerViewRequestQueryRT,
|
||||
|
@ -31,8 +31,8 @@ export const initGetMetricsExplorerViewRoute = ({
|
|||
method: 'get',
|
||||
path: METRICS_EXPLORER_VIEW_URL_ENTITY,
|
||||
validate: {
|
||||
params: createValidationFunction(getMetricsExplorerViewRequestParamsRT),
|
||||
query: createValidationFunction(metricsExplorerViewRequestQueryRT),
|
||||
params: createRouteValidationFunction(getMetricsExplorerViewRequestParamsRT),
|
||||
query: createRouteValidationFunction(metricsExplorerViewRequestQueryRT),
|
||||
},
|
||||
},
|
||||
async (_requestContext, request, response) => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { isBoom } from '@hapi/boom';
|
||||
import { createValidationFunction } from '../../../common/runtime_types';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
metricsExplorerViewRequestParamsRT,
|
||||
metricsExplorerViewRequestQueryRT,
|
||||
|
@ -32,9 +32,9 @@ export const initUpdateMetricsExplorerViewRoute = ({
|
|||
method: 'put',
|
||||
path: METRICS_EXPLORER_VIEW_URL_ENTITY,
|
||||
validate: {
|
||||
params: createValidationFunction(metricsExplorerViewRequestParamsRT),
|
||||
query: createValidationFunction(metricsExplorerViewRequestQueryRT),
|
||||
body: createValidationFunction(updateMetricsExplorerViewRequestPayloadRT),
|
||||
params: createRouteValidationFunction(metricsExplorerViewRequestParamsRT),
|
||||
query: createRouteValidationFunction(metricsExplorerViewRequestQueryRT),
|
||||
body: createRouteValidationFunction(updateMetricsExplorerViewRequestPayloadRT),
|
||||
},
|
||||
},
|
||||
async (_requestContext, request, response) => {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import Boom from '@hapi/boom';
|
||||
import { createValidationFunction } from '../../../common/runtime_types';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import { InfraBackendLibs } from '../../lib/infra_types';
|
||||
import { hasData } from '../../lib/sources/has_data';
|
||||
import { createSearchClient } from '../../lib/create_search_client';
|
||||
|
@ -124,7 +124,7 @@ export const initMetricsSourceConfigurationRoutes = (libs: InfraBackendLibs) =>
|
|||
params: schema.object({
|
||||
sourceId: schema.string(),
|
||||
}),
|
||||
body: createValidationFunction(partialMetricsSourceConfigurationReqPayloadRT),
|
||||
body: createRouteValidationFunction(partialMetricsSourceConfigurationReqPayloadRT),
|
||||
},
|
||||
},
|
||||
framework.router.handleLegacyErrors(async (requestContext, request, response) => {
|
||||
|
|
|
@ -10,6 +10,7 @@ import { schema } from '@kbn/config-schema';
|
|||
import { pipe } from 'fp-ts/lib/pipeable';
|
||||
import { fold } from 'fp-ts/lib/Either';
|
||||
import { identity } from 'fp-ts/lib/function';
|
||||
import { throwErrors } from '@kbn/io-ts-utils';
|
||||
import { InfraBackendLibs } from '../../lib/infra_types';
|
||||
import { UsageCollector } from '../../usage/usage_collector';
|
||||
import { InfraMetricsRequestOptions } from '../../lib/adapters/metrics';
|
||||
|
@ -18,7 +19,6 @@ import {
|
|||
NodeDetailsRequestRT,
|
||||
NodeDetailsMetricDataResponseRT,
|
||||
} from '../../../common/http_api/node_details_api';
|
||||
import { throwErrors } from '../../../common/runtime_types';
|
||||
|
||||
const escapeHatch = schema.object({}, { unknowns: 'allow' });
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
import { createValidationFunction } from '../../../common/runtime_types';
|
||||
import { createRouteValidationFunction } from '@kbn/io-ts-utils';
|
||||
import { TopNodesRequestRT } from '../../../common/http_api/overview_api';
|
||||
import { InfraBackendLibs } from '../../lib/infra_types';
|
||||
import { createSearchClient } from '../../lib/create_search_client';
|
||||
|
@ -18,7 +18,7 @@ export const initOverviewRoute = (libs: InfraBackendLibs) => {
|
|||
method: 'post',
|
||||
path: '/api/metrics/overview/top',
|
||||
validate: {
|
||||
body: createValidationFunction(TopNodesRequestRT),
|
||||
body: createRouteValidationFunction(TopNodesRequestRT),
|
||||
},
|
||||
},
|
||||
async (requestContext, request, response) => {
|
||||
|
|
|
@ -10,8 +10,8 @@ import { pipe } from 'fp-ts/lib/pipeable';
|
|||
import { fold } from 'fp-ts/lib/Either';
|
||||
import { identity } from 'fp-ts/lib/function';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { throwErrors } from '@kbn/io-ts-utils';
|
||||
import { InfraBackendLibs } from '../../lib/infra_types';
|
||||
import { throwErrors } from '../../../common/runtime_types';
|
||||
import { createSearchClient } from '../../lib/create_search_client';
|
||||
import { getProcessList } from '../../lib/host_details/process_list';
|
||||
import { getProcessListChart } from '../../lib/host_details/process_list_chart';
|
||||
|
|
|
@ -13,6 +13,7 @@ import {
|
|||
SavedObjectsUtils,
|
||||
} from '@kbn/core/server';
|
||||
import Boom from '@hapi/boom';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
inventoryViewAttributesRT,
|
||||
staticInventoryViewAttributes,
|
||||
|
@ -23,7 +24,6 @@ import type {
|
|||
InventoryViewRequestQuery,
|
||||
} from '../../../common/http_api/latest';
|
||||
import type { InventoryView, InventoryViewAttributes } from '../../../common/inventory_views';
|
||||
import { decodeOrThrow } from '../../../common/runtime_types';
|
||||
import type { IInfraSources } from '../../lib/sources';
|
||||
import { inventoryViewSavedObjectName } from '../../saved_objects/inventory_view';
|
||||
import { inventoryViewSavedObjectRT } from '../../saved_objects/inventory_view/types';
|
||||
|
|
|
@ -13,6 +13,7 @@ import {
|
|||
SavedObjectsUtils,
|
||||
} from '@kbn/core/server';
|
||||
import Boom from '@hapi/boom';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
metricsExplorerViewAttributesRT,
|
||||
staticMetricsExplorerViewAttributes,
|
||||
|
@ -29,7 +30,6 @@ import type {
|
|||
MetricsExplorerView,
|
||||
MetricsExplorerViewAttributes,
|
||||
} from '../../../common/metrics_explorer_views';
|
||||
import { decodeOrThrow } from '../../../common/runtime_types';
|
||||
import type { IInfraSources } from '../../lib/sources';
|
||||
import { metricsExplorerViewSavedObjectName } from '../../saved_objects/metrics_explorer_view';
|
||||
import { metricsExplorerViewSavedObjectRT } from '../../saved_objects/metrics_explorer_view/types';
|
||||
|
|
|
@ -1,53 +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
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { fold } from 'fp-ts/lib/Either';
|
||||
import { identity } from 'fp-ts/lib/function';
|
||||
import { pipe } from 'fp-ts/lib/pipeable';
|
||||
import { Context, Errors, IntersectionType, Type, UnionType, ValidationError } from 'io-ts';
|
||||
|
||||
type ErrorFactory = (message: string) => Error;
|
||||
|
||||
const getErrorPath = ([first, ...rest]: Context): string[] => {
|
||||
if (typeof first === 'undefined') {
|
||||
return [];
|
||||
} else if (first.type instanceof IntersectionType) {
|
||||
const [, ...next] = rest;
|
||||
return getErrorPath(next);
|
||||
} else if (first.type instanceof UnionType) {
|
||||
const [, ...next] = rest;
|
||||
return [first.key, ...getErrorPath(next)];
|
||||
}
|
||||
|
||||
return [first.key, ...getErrorPath(rest)];
|
||||
};
|
||||
|
||||
const getErrorType = ({ context }: ValidationError) =>
|
||||
context[context.length - 1]?.type?.name ?? 'unknown';
|
||||
|
||||
const formatError = (error: ValidationError) =>
|
||||
error.message ??
|
||||
`in ${getErrorPath(error.context).join('/')}: ${JSON.stringify(
|
||||
error.value
|
||||
)} does not match expected type ${getErrorType(error)}`;
|
||||
|
||||
export const formatErrors = (errors: ValidationError[]) =>
|
||||
`Failed to validate: \n${errors.map((error) => ` ${formatError(error)}`).join('\n')}`;
|
||||
|
||||
export const createPlainError = (message: string) => new Error(message);
|
||||
|
||||
export const throwErrors = (createError: ErrorFactory) => (errors: Errors) => {
|
||||
throw createError(formatErrors(errors));
|
||||
};
|
||||
|
||||
export const decodeOrThrow =
|
||||
<DecodedValue, EncodedValue, InputValue>(
|
||||
runtimeType: Type<DecodedValue, EncodedValue, InputValue>,
|
||||
createError: ErrorFactory = createPlainError
|
||||
) =>
|
||||
(inputValue: InputValue) =>
|
||||
pipe(runtimeType.decode(inputValue), fold(throwErrors(createError), identity));
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { decodeOrThrow } from '../../../common/runtime_types';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
const TIMESTAMP_FIELD = '@timestamp';
|
||||
import { MetricsAPIRequest, MetricsAPIResponse } from '../../../common/http_api/metrics_api';
|
||||
import {
|
||||
|
|
|
@ -10,12 +10,12 @@ import { pipe } from 'fp-ts/lib/pipeable';
|
|||
import { fold } from 'fp-ts/lib/Either';
|
||||
import { identity } from 'fp-ts/lib/function';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { throwErrors } from '@kbn/io-ts-utils';
|
||||
import {
|
||||
metricsExplorerRequestBodyRT,
|
||||
metricsExplorerResponseRT,
|
||||
MetricsExplorerPageInfo,
|
||||
} from '../../../common/http_api/metrics_explorer';
|
||||
import { throwErrors } from '../../../common/runtime_types';
|
||||
import { convertRequestToMetricsAPIOptions } from './lib/convert_request_to_metrics_api_options';
|
||||
import { createSearchClient } from '../../lib/create_search_client';
|
||||
import { findIntervalForMetrics } from './lib/find_interval_for_metrics';
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
validateLogEntryDatasetsRequestPayloadRT,
|
||||
validateLogEntryDatasetsResponsePayloadRT,
|
||||
} from '@kbn/infra-plugin/common/http_api';
|
||||
import { decodeOrThrow } from '@kbn/infra-plugin/common/runtime_types';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
|
||||
export default function ({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -11,7 +11,7 @@ import { pipe } from 'fp-ts/lib/pipeable';
|
|||
import { identity } from 'fp-ts/lib/function';
|
||||
import { fold } from 'fp-ts/lib/Either';
|
||||
|
||||
import { createPlainError, throwErrors } from '@kbn/infra-plugin/common/runtime_types';
|
||||
import { createPlainError, throwErrors } from '@kbn/io-ts-utils';
|
||||
|
||||
import {
|
||||
LOG_ENTRIES_HIGHLIGHTS_PATH,
|
||||
|
|
|
@ -13,7 +13,7 @@ import { pipe } from 'fp-ts/lib/pipeable';
|
|||
import { identity } from 'fp-ts/lib/function';
|
||||
import { fold } from 'fp-ts/lib/Either';
|
||||
|
||||
import { createPlainError, throwErrors } from '@kbn/infra-plugin/common/runtime_types';
|
||||
import { createPlainError, throwErrors } from '@kbn/io-ts-utils';
|
||||
|
||||
import {
|
||||
LOG_ENTRIES_SUMMARY_PATH,
|
||||
|
|
|
@ -9,7 +9,7 @@ import expect from '@kbn/expect';
|
|||
import { first } from 'lodash';
|
||||
import moment from 'moment';
|
||||
import { metricsExplorerResponseRT } from '@kbn/infra-plugin/common/http_api/metrics_explorer';
|
||||
import { decodeOrThrow } from '@kbn/infra-plugin/common/runtime_types';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { DATES } from './constants';
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
TopNodesRequestRT,
|
||||
TopNodesResponseRT,
|
||||
} from '@kbn/infra-plugin/common/http_api/overview_api';
|
||||
import { decodeOrThrow } from '@kbn/infra-plugin/common/runtime_types';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
import { DATES } from './constants';
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
ProcessListAPIRequestRT,
|
||||
ProcessListAPIResponseRT,
|
||||
} from '@kbn/infra-plugin/common/http_api/host_details/process_list';
|
||||
import { decodeOrThrow } from '@kbn/infra-plugin/common/runtime_types';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
|
||||
export default function ({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
ProcessListAPIChartRequestRT,
|
||||
ProcessListAPIChartResponseRT,
|
||||
} from '@kbn/infra-plugin/common/http_api/host_details/process_list';
|
||||
import { decodeOrThrow } from '@kbn/infra-plugin/common/runtime_types';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
|
||||
export default function ({ getService }: FtrProviderContext) {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import expect from '@kbn/expect';
|
||||
import { ServicesAPIResponseRT } from '@kbn/infra-plugin/common/http_api/host_details';
|
||||
import { ApmSynthtraceEsClient } from '@kbn/apm-synthtrace';
|
||||
import { decodeOrThrow } from '@kbn/infra-plugin/common/runtime_types';
|
||||
import { decodeOrThrow } from '@kbn/io-ts-utils';
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
import { generateServicesData, generateServicesLogsOnlyData } from './helpers';
|
||||
import { getApmSynthtraceEsClient } from '../../../common/utils/synthtrace/apm_es_client';
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue