From b79f5abed379b23a0b1b1b5e811db1a4e89ae2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Thu, 29 Aug 2024 11:31:01 +0200 Subject: [PATCH] [Move `@kbn/config-schema` to server] `kbn-io-ts-utils` (#191692) --- .../src/props_to_schema/index.ts | 27 ------------------- packages/kbn-io-ts-utils/tsconfig.json | 1 - 2 files changed, 28 deletions(-) delete mode 100644 packages/kbn-io-ts-utils/src/props_to_schema/index.ts diff --git a/packages/kbn-io-ts-utils/src/props_to_schema/index.ts b/packages/kbn-io-ts-utils/src/props_to_schema/index.ts deleted file mode 100644 index 5915df1b0102e..0000000000000 --- a/packages/kbn-io-ts-utils/src/props_to_schema/index.ts +++ /dev/null @@ -1,27 +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 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ -import * as t from 'io-ts'; -import { PathReporter } from 'io-ts/lib/PathReporter'; -import { schema, Type } from '@kbn/config-schema'; -import { isLeft } from 'fp-ts/lib/Either'; - -export function propsToSchema>(type: T): Type> { - return schema.object( - {}, - { - unknowns: 'allow', - validate: (val) => { - const decoded = type.decode(val); - - if (isLeft(decoded)) { - return PathReporter.report(decoded).join('\n'); - } - }, - } - ); -} diff --git a/packages/kbn-io-ts-utils/tsconfig.json b/packages/kbn-io-ts-utils/tsconfig.json index 5145b1ee2a7f4..0ac791e1542ae 100644 --- a/packages/kbn-io-ts-utils/tsconfig.json +++ b/packages/kbn-io-ts-utils/tsconfig.json @@ -11,7 +11,6 @@ "**/*.ts" ], "kbn_references": [ - "@kbn/config-schema", "@kbn/core", "@kbn/datemath" ],