Skip to content

Commit

Permalink
fixing some types
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Apr 3, 2020
1 parent 3538c91 commit 09c4d8e
Showing 9 changed files with 32 additions and 17 deletions.
10 changes: 8 additions & 2 deletions x-pack/plugins/ml/common/types/file_datavisualizer.ts
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@ export interface FindFileStructureResponse {
explanation?: string[];
grok_pattern?: string;
multiline_start_pattern?: string;
exclude_lines_pattern?: string;
java_timestamp_formats?: string[];
joda_timestamp_formats?: string[];
timestamp_field?: string;
@@ -84,7 +85,12 @@ export interface Mappings {
[key: string]: any;
}

export interface IngestPipeline {
export interface IngestPipelineWrapper {
id: string;
pipeline: any;
pipeline: IngestPipeline;
}

export interface IngestPipeline {
description: string;
processors: any[];
}
Original file line number Diff line number Diff line change
@@ -12,6 +12,11 @@ import { EuiCallOut, EuiAccordion } from '@elastic/eui';

import { IMPORT_STATUS, Statuses } from '../import_progress';

interface ImportError {
msg: string;
more?: string;
}

interface Props {
errors: any[];
statuses: Statuses;
@@ -112,11 +117,6 @@ function ImportError(error: any, key: number) {
);
}

interface ImportError {
msg: string;
more?: string;
}

function toString(error: any): ImportError {
if (typeof error === 'string') {
return { msg: error };
Original file line number Diff line number Diff line change
@@ -111,7 +111,6 @@ export const AdvancedSettings: FC<Props> = ({
defaultMessage="Index pattern name"
/>
}
// disabled={createIndexPattern === false || initialized === true}
isInvalid={indexPatternNameError !== ''}
error={[indexPatternNameError]}
>
Original file line number Diff line number Diff line change
@@ -135,6 +135,7 @@ export class Importer {
retries--;
} catch (err) {
resp.success = false;
resp.error = err;
retries = 0;
}
}
@@ -188,7 +189,7 @@ function populateFailures(error: ImportResponse, failures: ImportFailure[], chun
// But it's not sending every single field that Filebeat would add, so the ingest pipeline
// cannot look for a event.timezone variable in each input record.
// Therefore we need to replace {{ event.timezone }} with the actual browser timezone
function updatePipelineTimezone(ingestPipeline: any) {
function updatePipelineTimezone(ingestPipeline: IngestPipeline) {
if (ingestPipeline !== undefined && ingestPipeline.processors && ingestPipeline.processors) {
const dateProcessor = ingestPipeline.processors.find(
(p: any) => p.date !== undefined && p.date.timezone === '{{ event.timezone }}'
Original file line number Diff line number Diff line change
@@ -7,8 +7,13 @@
import { MessageImporter } from './message_importer';
import { NdjsonImporter } from './ndjson_importer';
import { ImportConfig } from './importer';
import { FindFileStructureResponse } from '../../../../../../../common/types/file_datavisualizer';

export function importerFactory(format: string, results: any, settings: ImportConfig) {
export function importerFactory(
format: string,
results: FindFileStructureResponse,
settings: ImportConfig
) {
switch (format) {
// delimited and semi-structured text are both handled by splitting the
// file into messages, then sending these to ES for further processing
Original file line number Diff line number Diff line change
@@ -5,13 +5,16 @@
*/

import { Importer, ImportConfig } from './importer';
import { Doc } from '../../../../../../../common/types/file_datavisualizer';
import {
Doc,
FindFileStructureResponse,
} from '../../../../../../../common/types/file_datavisualizer';

export class MessageImporter extends Importer {
private _excludeLinesRegex: RegExp | null;
private _multilineStartRegex: RegExp | null;

constructor(results: any, settings: ImportConfig) {
constructor(results: FindFileStructureResponse, settings: ImportConfig) {
super(settings);

this._excludeLinesRegex =
Original file line number Diff line number Diff line change
@@ -5,9 +5,10 @@
*/

import { Importer, ImportConfig } from './importer';
import { FindFileStructureResponse } from '../../../../../../../common/types/file_datavisualizer';

export class NdjsonImporter extends Importer {
constructor(results: any, settings: ImportConfig) {
constructor(results: FindFileStructureResponse, settings: ImportConfig) {
super(settings);
}

Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ import {
ImportFailure,
Settings,
Mappings,
IngestPipeline,
IngestPipelineWrapper,
} from '../../../common/types/file_datavisualizer';
import { InputData } from './file_data_visualizer';

@@ -21,7 +21,7 @@ export function importDataProvider(callAsCurrentUser: APICaller) {
index: string,
settings: Settings,
mappings: Mappings,
ingestPipeline: IngestPipeline,
ingestPipeline: IngestPipelineWrapper,
data: InputData
): Promise<ImportResponse> {
let createdIndex;
4 changes: 2 additions & 2 deletions x-pack/plugins/ml/server/routes/file_data_visualizer.ts
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import { MAX_BYTES } from '../../common/constants/file_datavisualizer';
import {
InputOverrides,
Settings,
IngestPipeline,
IngestPipelineWrapper,
Mappings,
} from '../../common/types/file_datavisualizer';
import { wrapError } from '../client/error_wrapper';
@@ -34,7 +34,7 @@ function importData(
index: string,
settings: Settings,
mappings: Mappings,
ingestPipeline: IngestPipeline,
ingestPipeline: IngestPipelineWrapper,
data: InputData
) {
const { importData: importDataFunc } = importDataProvider(context.ml!.mlClient.callAsCurrentUser);

0 comments on commit 09c4d8e

Please sign in to comment.