Upgrade io-ts after fix was merged and update use of some types (#55013) (#55034)

* Upgrade io-ts after fix was merged and update use of some types

* Stricter checking against object keys
This commit is contained in:
Jean-Louis Leysens 2020-01-16 15:59:14 +01:00 committed by GitHub
parent 2df5eb1ed6
commit 81fcabfb3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 21 deletions

View file

@ -100,14 +100,10 @@ const fielddataFrequencyFilterParam = {
},
},
},
schema: t.intersection([
t.partial({
min: t.number,
max: t.number,
min_segment_size: t.number,
}),
t.brand(t.UnknownRecord, (v: any): v is any => !Array.isArray(v), 'Array'),
]),
schema: t.record(
t.union([t.literal('min'), t.literal('max'), t.literal('min_segment_size')]),
t.number
),
};
const analyzerValidations = [

View file

@ -3,14 +3,14 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { ValidationError, Validation } from 'io-ts';
import { ValidationError } from 'io-ts';
import { fold } from 'fp-ts/lib/Either';
import { Reporter } from 'io-ts/lib/Reporter';
export type ReporterResult = Array<{ path: string[]; message: string }>;
export const failure = (validation: any): ReporterResult => {
return validation.map((e: ValidationError) => {
const failure = (validation: ValidationError[]): ReporterResult => {
return validation.map(e => {
const path: string[] = [];
let validationName = '';
@ -37,6 +37,6 @@ export const failure = (validation: any): ReporterResult => {
const empty: never[] = [];
const success = () => empty;
export const ErrorReporter: Reporter<ReporterResult> = {
report: (validation: Validation<any>) => fold(failure, success)(validation as any),
export const errorReporter: Reporter<ReporterResult> = {
report: fold(failure, success),
};

View file

@ -8,7 +8,7 @@ import * as t from 'io-ts';
import { ordString } from 'fp-ts/lib/Ord';
import { toArray } from 'fp-ts/lib/Set';
import { isLeft, isRight } from 'fp-ts/lib/Either';
import { ErrorReporter } from './error_reporter';
import { errorReporter } from './error_reporter';
import { ALL_DATA_TYPES, PARAMETERS_DEFINITION } from '../constants';
import { FieldMeta } from '../types';
import { getFieldMeta } from '../lib';
@ -218,7 +218,7 @@ const mappingsConfigurationSchemaKeys = Object.keys(mappingsConfigurationSchema.
const validateMappingsConfiguration = (
mappingsConfiguration: any
): { value: any; errors: MappingsValidationError[] } => {
// Array to keep track of invalid configuration parameters.
// Set to keep track of invalid configuration parameters.
const configurationRemoved: Set<string> = new Set();
let copyOfMappingsConfig = { ...mappingsConfiguration };
@ -228,7 +228,7 @@ const validateMappingsConfiguration = (
/**
* To keep the logic simple we will strip out the parameters that contain errors
*/
const errors = ErrorReporter.report(result);
const errors = errorReporter.report(result);
errors.forEach(error => {
const configurationName = error.path[0];
configurationRemoved.add(configurationName);

View file

@ -251,7 +251,7 @@
"immer": "^1.5.0",
"inline-style": "^2.0.0",
"intl": "^1.2.5",
"io-ts": "^2.0.1",
"io-ts": "^2.0.5",
"isbinaryfile": "4.0.2",
"joi": "^13.5.2",
"jquery": "^3.4.1",

View file

@ -17530,10 +17530,10 @@ invert-kv@^2.0.0:
resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02"
integrity sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==
io-ts@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/io-ts/-/io-ts-2.0.1.tgz#1261c12f915c2f48d16393a36966636b48a45aa1"
integrity sha512-RezD+WcCfW4VkMkEcQWL/Nmy/nqsWTvTYg7oUmTGzglvSSV2P9h2z1PVeREPFf0GWNzruYleAt1XCMQZSg1xxQ==
io-ts@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/io-ts/-/io-ts-2.0.5.tgz#e6e3db9df8b047f9cbd6b69e7d2ad3e6437a0b13"
integrity sha512-pL7uUptryanI5Glv+GUv7xh+aLBjxGEDmLwmEYNSx0yOD3djK0Nw5Bt0N6BAkv9LadOUU7QKpRsLcqnTh3UlLA==
ip-regex@^2.1.0:
version "2.1.0"