mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[ML] Remove export wildcard syntax for file upload plugin. (#123205)
Remove export wildcard syntax for file upload plugin.
This commit is contained in:
parent
d49880b807
commit
d744500c24
25 changed files with 63 additions and 54 deletions
|
@ -21,6 +21,13 @@ export const FILE_SIZE_DISPLAY_FORMAT = '0,0.[0] b';
|
|||
// index as having been created by the File Data Visualizer.
|
||||
export const INDEX_META_DATA_CREATED_BY = 'file-data-visualizer';
|
||||
|
||||
export const FILE_FORMATS = {
|
||||
DELIMITED: 'delimited',
|
||||
NDJSON: 'ndjson',
|
||||
SEMI_STRUCTURED_TEXT: 'semi_structured_text',
|
||||
// XML: 'xml',
|
||||
};
|
||||
|
||||
export const JOB_FIELD_TYPES = {
|
||||
BOOLEAN: 'boolean',
|
||||
DATE: 'date',
|
||||
|
|
|
@ -9,7 +9,7 @@ import { i18n } from '@kbn/i18n';
|
|||
import { cloneDeep } from 'lodash';
|
||||
import uuid from 'uuid/v4';
|
||||
import { CombinedField } from './types';
|
||||
import {
|
||||
import type {
|
||||
FindFileStructureResponse,
|
||||
IngestPipeline,
|
||||
Mappings,
|
||||
|
|
|
@ -6,12 +6,8 @@
|
|||
*/
|
||||
|
||||
import { isEqual } from 'lodash';
|
||||
import {
|
||||
AnalysisResult,
|
||||
InputOverrides,
|
||||
MB,
|
||||
FILE_FORMATS,
|
||||
} from '../../../../../../file_upload/common';
|
||||
import type { AnalysisResult, InputOverrides } from '../../../../../../file_upload/common';
|
||||
import { MB, FILE_FORMATS } from '../../../../../common';
|
||||
|
||||
export const DEFAULT_LINES_TO_SAMPLE = 1000;
|
||||
const UPLOAD_SIZE_MB = 5;
|
||||
|
|
|
@ -9,7 +9,8 @@ import { FormattedMessage } from '@kbn/i18n-react';
|
|||
import React, { FC } from 'react';
|
||||
|
||||
import { EuiTitle, EuiSpacer, EuiDescriptionList } from '@elastic/eui';
|
||||
import { FindFileStructureResponse, FILE_FORMATS } from '../../../../../../file_upload/common';
|
||||
import type { FindFileStructureResponse } from '../../../../../../file_upload/common';
|
||||
import { FILE_FORMATS } from '../../../../../common';
|
||||
|
||||
export const AnalysisSummary: FC<{ results: FindFileStructureResponse }> = ({ results }) => {
|
||||
const items = createDisplayItems(results);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { FILE_FORMATS } from '../../../../../../../file_upload/common';
|
||||
import { FILE_FORMATS } from '../../../../../../common/';
|
||||
|
||||
import {
|
||||
TIMESTAMP_OPTIONS,
|
||||
|
|
|
@ -23,7 +23,7 @@ import {
|
|||
EuiTextArea,
|
||||
} from '@elastic/eui';
|
||||
|
||||
import { FILE_FORMATS } from '../../../../../../file_upload/common';
|
||||
import { FILE_FORMATS } from '../../../../../common';
|
||||
|
||||
import {
|
||||
getFormatOptions,
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest';
|
||||
import React from 'react';
|
||||
import { FILE_FORMATS } from '../../../../../../file_upload/common/constants';
|
||||
import { FILE_FORMATS } from '../../../../../common';
|
||||
|
||||
import { Overrides } from './overrides';
|
||||
|
||||
|
|
|
@ -6,11 +6,9 @@
|
|||
*/
|
||||
|
||||
export const UI_SETTING_MAX_FILE_SIZE = 'fileUpload:maxFileSize';
|
||||
|
||||
export const MB = Math.pow(2, 20);
|
||||
export const MAX_FILE_SIZE = '100MB';
|
||||
export const MAX_FILE_SIZE_BYTES = 104857600; // 100MB
|
||||
|
||||
export const ABSOLUTE_MAX_FILE_SIZE_BYTES = 1073741274; // 1GB
|
||||
export const FILE_SIZE_DISPLAY_FORMAT = '0,0.[0] b';
|
||||
|
||||
|
|
|
@ -5,8 +5,14 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
// TODO: https://github.com/elastic/kibana/issues/110898
|
||||
/* eslint-disable @kbn/eslint/no_export_all */
|
||||
|
||||
export * from './constants';
|
||||
export * from './types';
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type {
|
||||
AnalysisResult,
|
||||
FindFileStructureErrorResponse,
|
||||
FindFileStructureResponse,
|
||||
InputOverrides,
|
||||
IngestPipeline,
|
||||
Mappings,
|
||||
} from './types';
|
||||
|
|
|
@ -118,11 +118,11 @@ export interface ImportFailure {
|
|||
doc: ImportDoc;
|
||||
}
|
||||
|
||||
export interface Doc {
|
||||
export interface ImportDocMessage {
|
||||
message: string;
|
||||
}
|
||||
|
||||
export type ImportDoc = Doc | string | object;
|
||||
export type ImportDoc = ImportDocMessage | string | object;
|
||||
|
||||
export interface Settings {
|
||||
pipeline?: string;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { lazyLoadModules } from '../lazy_load_bundle';
|
||||
import type { IImporter, ImportFactoryOptions } from '../importer';
|
||||
import type { HasImportPermission, FindFileStructureResponse } from '../../common';
|
||||
import type { HasImportPermission, FindFileStructureResponse } from '../../common/types';
|
||||
import type { getMaxBytes, getMaxBytesFormatted } from '../importer/get_max_bytes';
|
||||
import { JsonUploadAndParseAsyncWrapper } from './json_upload_and_parse_async_wrapper';
|
||||
import { IndexNameFormAsyncWrapper } from './index_name_form_async_wrapper';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import React, { Component } from 'react';
|
||||
import { EuiFilePicker, EuiFormRow } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { MB } from '../../../common';
|
||||
import { MB } from '../../../common/constants';
|
||||
import { getMaxBytesFormatted } from '../../importer/get_max_bytes';
|
||||
import { validateFile } from '../../importer';
|
||||
import {
|
||||
|
|
|
@ -15,7 +15,7 @@ import { ES_FIELD_TYPES } from '../../../../../src/plugins/data/public';
|
|||
import type { FileUploadComponentProps, FileUploadGeoResults } from '../lazy_load_bundle';
|
||||
import { ImportResults } from '../importer';
|
||||
import { GeoJsonImporter } from '../importer/geojson_importer';
|
||||
import { Settings } from '../../common';
|
||||
import type { Settings } from '../../common/types';
|
||||
import { hasImportPermission } from '../api';
|
||||
|
||||
enum PHASE {
|
||||
|
|
|
@ -14,7 +14,8 @@ import { callImportRoute, Importer, IMPORT_RETRIES, MAX_CHUNK_CHAR_COUNT } from
|
|||
import { ES_FIELD_TYPES } from '../../../../../../src/plugins/data/public';
|
||||
// @ts-expect-error
|
||||
import { geoJsonCleanAndValidate } from './geojson_clean_and_validate';
|
||||
import { ImportDoc, ImportFailure, ImportResponse, MB } from '../../../common';
|
||||
import { MB } from '../../../common/constants';
|
||||
import type { ImportDoc, ImportFailure, ImportResponse } from '../../../common/types';
|
||||
|
||||
const BLOCK_SIZE_MB = 5 * MB;
|
||||
export const GEOJSON_FILE_TYPES = ['.json', '.geojson'];
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
|
||||
import numeral from '@elastic/numeral';
|
||||
import {
|
||||
MAX_FILE_SIZE,
|
||||
MAX_FILE_SIZE_BYTES,
|
||||
ABSOLUTE_MAX_FILE_SIZE_BYTES,
|
||||
FILE_SIZE_DISPLAY_FORMAT,
|
||||
MAX_FILE_SIZE,
|
||||
MAX_FILE_SIZE_BYTES,
|
||||
UI_SETTING_MAX_FILE_SIZE,
|
||||
} from '../../common';
|
||||
} from '../../common/constants';
|
||||
import { getUiSettings } from '../kibana_services';
|
||||
|
||||
export function getMaxBytes() {
|
||||
|
|
|
@ -9,15 +9,15 @@ import { chunk, intersection } from 'lodash';
|
|||
import moment from 'moment';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { getHttp } from '../kibana_services';
|
||||
import {
|
||||
import { MB } from '../../common/constants';
|
||||
import type {
|
||||
ImportDoc,
|
||||
ImportFailure,
|
||||
ImportResponse,
|
||||
Mappings,
|
||||
Settings,
|
||||
IngestPipeline,
|
||||
MB,
|
||||
} from '../../common';
|
||||
} from '../../common/types';
|
||||
import { CreateDocsResponse, IImporter, ImportResults } from './types';
|
||||
import { isPopulatedObject } from '../../common/utils';
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { Importer } from './importer';
|
||||
import { Doc } from '../../common';
|
||||
import { ImportDocMessage } from '../../common/types';
|
||||
import { CreateDocsResponse, ImportFactoryOptions } from './types';
|
||||
|
||||
export class MessageImporter extends Importer {
|
||||
|
@ -33,7 +33,7 @@ export class MessageImporter extends Importer {
|
|||
protected _createDocs(text: string, isLastPart: boolean): CreateDocsResponse {
|
||||
let remainder = 0;
|
||||
try {
|
||||
const docs: Doc[] = [];
|
||||
const docs: ImportDocMessage[] = [];
|
||||
|
||||
let message = '';
|
||||
let line = '';
|
||||
|
@ -82,7 +82,7 @@ export class MessageImporter extends Importer {
|
|||
}
|
||||
}
|
||||
|
||||
private _processLine(data: Doc[], message: string, line: string) {
|
||||
private _processLine(data: ImportDocMessage[], message: string, line: string) {
|
||||
if (this._excludeLinesRegex === null || line.match(this._excludeLinesRegex) === null) {
|
||||
if (this._multilineStartRegex === null || line.match(this._multilineStartRegex) !== null) {
|
||||
this._addMessage(data, message);
|
||||
|
@ -100,7 +100,7 @@ export class MessageImporter extends Importer {
|
|||
return message;
|
||||
}
|
||||
|
||||
private _addMessage(data: Doc[], message: string) {
|
||||
private _addMessage(data: ImportDocMessage[], message: string) {
|
||||
// if the message ended \r\n (Windows line endings)
|
||||
// then omit the \r as well as the \n for consistency
|
||||
message = message.replace(/\r$/, '');
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import {
|
||||
import type {
|
||||
ImportFailure,
|
||||
IngestPipeline,
|
||||
ImportDoc,
|
||||
ImportResponse,
|
||||
Mappings,
|
||||
Settings,
|
||||
} from '../../common';
|
||||
} from '../../common/types';
|
||||
|
||||
export interface ImportConfig {
|
||||
settings: Settings;
|
||||
|
|
|
@ -5,17 +5,12 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
// TODO: https://github.com/elastic/kibana/issues/110898
|
||||
/* eslint-disable @kbn/eslint/no_export_all */
|
||||
|
||||
import { FileUploadPlugin } from './plugin';
|
||||
|
||||
export function plugin() {
|
||||
return new FileUploadPlugin();
|
||||
}
|
||||
|
||||
export * from './importer/types';
|
||||
|
||||
export type { Props as IndexNameFormProps } from './components/geojson_upload_form/index_name_form';
|
||||
|
||||
export type { FileUploadPluginStart } from './plugin';
|
||||
|
|
|
@ -6,7 +6,12 @@
|
|||
*/
|
||||
|
||||
import { IScopedClusterClient } from 'kibana/server';
|
||||
import { AnalysisResult, FormattedOverrides, InputData, InputOverrides } from '../common';
|
||||
import type {
|
||||
AnalysisResult,
|
||||
FormattedOverrides,
|
||||
InputData,
|
||||
InputOverrides,
|
||||
} from '../common/types';
|
||||
|
||||
export async function analyzeFile(
|
||||
client: IScopedClusterClient,
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
Settings,
|
||||
Mappings,
|
||||
IngestPipelineWrapper,
|
||||
} from '../common';
|
||||
} from '../common/types';
|
||||
|
||||
export function importDataProvider({ asCurrentUser }: IScopedClusterClient) {
|
||||
async function importData(
|
||||
|
|
|
@ -10,7 +10,7 @@ import { CoreSetup, CoreStart, Logger, Plugin, PluginInitializerContext } from '
|
|||
import { schema } from '@kbn/config-schema';
|
||||
import { fileUploadRoutes } from './routes';
|
||||
import { initFileUploadTelemetry } from './telemetry';
|
||||
import { UI_SETTING_MAX_FILE_SIZE, MAX_FILE_SIZE } from '../common';
|
||||
import { MAX_FILE_SIZE, UI_SETTING_MAX_FILE_SIZE } from '../common/constants';
|
||||
import { setupCapabilities } from './capabilities';
|
||||
import { StartDeps, SetupDeps } from './types';
|
||||
|
||||
|
|
|
@ -8,13 +8,8 @@
|
|||
import { schema } from '@kbn/config-schema';
|
||||
import { IScopedClusterClient } from 'kibana/server';
|
||||
import { CoreSetup, Logger } from 'src/core/server';
|
||||
import {
|
||||
MAX_FILE_SIZE_BYTES,
|
||||
IngestPipelineWrapper,
|
||||
InputData,
|
||||
Mappings,
|
||||
Settings,
|
||||
} from '../common';
|
||||
import { MAX_FILE_SIZE_BYTES } from '../common/constants';
|
||||
import type { IngestPipelineWrapper, InputData, Mappings, Settings } from '../common/types';
|
||||
import { wrapError } from './error_wrapper';
|
||||
import { importDataProvider } from './import_data';
|
||||
import { getTimeFieldRange } from './get_time_field_range';
|
||||
|
|
|
@ -29,6 +29,11 @@ export const JOB_MAP_NODE_TYPES = {
|
|||
TRAINED_MODEL: 'trainedModel',
|
||||
} as const;
|
||||
|
||||
export const INDEX_CREATED_BY = {
|
||||
FILE_DATA_VISUALIZER: 'file-data-visualizer',
|
||||
DATA_FRAME_ANALYTICS: 'data-frame-analytics',
|
||||
} as const;
|
||||
|
||||
export const BUILT_IN_MODEL_TAG = 'prepackaged';
|
||||
|
||||
export type JobMapNodeTypes = typeof JOB_MAP_NODE_TYPES[keyof typeof JOB_MAP_NODE_TYPES];
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
import Boom from '@hapi/boom';
|
||||
import { IScopedClusterClient } from 'kibana/server';
|
||||
import {
|
||||
INDEX_CREATED_BY,
|
||||
JOB_MAP_NODE_TYPES,
|
||||
JobMapNodeTypes,
|
||||
} from '../../../common/constants/data_frame_analytics';
|
||||
|
@ -19,7 +20,6 @@ import {
|
|||
DataFrameAnalyticsStats,
|
||||
MapElements,
|
||||
} from '../../../common/types/data_frame_analytics';
|
||||
import { INDEX_META_DATA_CREATED_BY } from '../../../../file_upload/common';
|
||||
import { getAnalysisType } from '../../../common/util/analytics_utils';
|
||||
import {
|
||||
ExtendAnalyticsMapArgs,
|
||||
|
@ -458,14 +458,14 @@ export class AnalyticsManager {
|
|||
if (
|
||||
link.isWildcardIndexPattern === false &&
|
||||
(link.meta === undefined ||
|
||||
link.meta?.created_by.includes(INDEX_META_DATA_CREATED_BY))
|
||||
link.meta?.created_by.includes(INDEX_CREATED_BY.FILE_DATA_VISUALIZER))
|
||||
) {
|
||||
rootIndexPattern = nextLinkId;
|
||||
complete = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (link.meta?.created_by === 'data-frame-analytics') {
|
||||
if (link.meta?.created_by === INDEX_CREATED_BY.DATA_FRAME_ANALYTICS) {
|
||||
nextLinkId = link.meta.analytics;
|
||||
nextType = JOB_MAP_NODE_TYPES.ANALYTICS;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue