mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Import zod from @kbn/zod and add an eslint rule (#190581)
Closes #187638 ## Summary In this [PR](https://github.com/elastic/kibana/pull/186190), we introduced @kbn/zod package and an OAS convertor to automatically generate Open API Specifications for the routes that use zod for their validation. In this PR, we add an eslint rule to enforce importing from @kbn/zod instead of zod directly. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
d9da7f6f16
commit
51736afd24
336 changed files with 367 additions and 336 deletions
|
@ -115,6 +115,12 @@ module.exports = {
|
|||
disallowedMessage: `import from @kbn/i18n-react instead`,
|
||||
exclude: [/packages[\/\\]kbn-i18n-react[\/\\]/],
|
||||
},
|
||||
{
|
||||
from: 'zod',
|
||||
to: '@kbn/zod',
|
||||
disallowedMessage: `import from @kbn/zod instead`,
|
||||
exclude: [/packages[\/\\]kbn-zod[\/\\]/],
|
||||
},
|
||||
{
|
||||
from: 'styled-components',
|
||||
to: false,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: not applicable
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
export type PlatformErrorResponse = z.infer<typeof PlatformErrorResponse>;
|
||||
export const PlatformErrorResponse = z.object({
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: not applicable
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
/**
|
||||
* A string that is not empty and does not contain only whitespace
|
||||
|
|
|
@ -6,5 +6,7 @@
|
|||
"exclude": ["target/**/*"],
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"include": ["**/*.ts"],
|
||||
"kbn_references": []
|
||||
"kbn_references": [
|
||||
"@kbn/zod",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ By default it uses the `zod_operation_schema` template which produces runtime ty
|
|||
Example of generated code:
|
||||
|
||||
```ts
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
/*
|
||||
* NOTICE: Do not edit this file manually.
|
||||
|
|
|
@ -210,7 +210,7 @@ components:
|
|||
Running OpenAPI Generator on that file will produce the following `.gen.ts` file
|
||||
|
||||
```ts
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
export type EntityId = z.infer<typeof EntityId>;
|
||||
export const EntityId = z.string();
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
|
||||
{{> disclaimer}}
|
||||
|
||||
import type { ZodTypeDef } from 'zod';
|
||||
import { z } from 'zod';
|
||||
import type { ZodTypeDef } from '@kbn/zod';
|
||||
import { z } from '@kbn/zod';
|
||||
import { requiredOptional, isValidDateMath, ArrayFromString, BooleanFromString } from '@kbn/zod-helpers';
|
||||
|
||||
{{#each imports}}
|
||||
import {
|
||||
{{#each this}}{{.}},{{/each}}
|
||||
import {
|
||||
{{#each this}}{{.}},{{/each}}
|
||||
} from "{{@key}}"
|
||||
{{/each}}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
|
||||
export const sharedOas = {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { EndpointList } from '../model/endpoint_list_common.gen';
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ExceptionListItemHumanId,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ExceptionListItemId,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { NonEmptyString } from '@kbn/openapi-common/schemas/primitives.gen';
|
||||
import { EndpointListItem } from '../model/endpoint_list_common.gen';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: not applicable
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ExceptionList,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ExceptionListItemId,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ExceptionListItemId,
|
||||
|
|
|
@ -6,5 +6,9 @@
|
|||
"exclude": ["target/**/*"],
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"include": ["**/*.ts"],
|
||||
"kbn_references": ["@kbn/securitysolution-exceptions-common", "@kbn/openapi-common"]
|
||||
"kbn_references": [
|
||||
"@kbn/securitysolution-exceptions-common",
|
||||
"@kbn/openapi-common",
|
||||
"@kbn/zod",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import { errors } from '@elastic/elasticsearch';
|
||||
import Boom from '@hapi/boom';
|
||||
import { stringifyZodError } from '@kbn/zod-helpers';
|
||||
import { ZodError } from 'zod';
|
||||
import { ZodError } from '@kbn/zod';
|
||||
import { BadRequestError } from '../bad_request_error';
|
||||
|
||||
export interface OutputError {
|
||||
|
|
|
@ -15,5 +15,6 @@
|
|||
],
|
||||
"kbn_references": [
|
||||
"@kbn/zod-helpers",
|
||||
"@kbn/zod",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ExceptionListHumanId,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { NonEmptyString } from '@kbn/openapi-common/schemas/primitives.gen';
|
||||
import {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { UUID, NonEmptyString } from '@kbn/openapi-common/schemas/primitives.gen';
|
||||
import {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ExceptionListName,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ExceptionListId,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ExceptionListItemId,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ExceptionListHumanId,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ExceptionListId,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
import { ArrayFromString } from '@kbn/zod-helpers';
|
||||
|
||||
import { NonEmptyString } from '@kbn/openapi-common/schemas/primitives.gen';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
import { ArrayFromString } from '@kbn/zod-helpers';
|
||||
|
||||
import { ExceptionNamespaceType, ExceptionList } from '../model/exception_list_common.gen';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
import { BooleanFromString } from '@kbn/zod-helpers';
|
||||
|
||||
import {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: not applicable
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { NonEmptyString } from '@kbn/openapi-common/schemas/primitives.gen';
|
||||
import { ExceptionListItemEntryArray } from './exception_list_item_entry.gen';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: not applicable
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { NonEmptyString } from '@kbn/openapi-common/schemas/primitives.gen';
|
||||
import { ListId, ListType } from '@kbn/securitysolution-lists-common/api/model/list_common.gen';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ExceptionListId,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ExceptionListItemId,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ExceptionListId,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ExceptionListId,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { NonEmptyString } from '@kbn/openapi-common/schemas/primitives.gen';
|
||||
import {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
"kbn_references": [
|
||||
"@kbn/openapi-common",
|
||||
"@kbn/zod-helpers",
|
||||
"@kbn/securitysolution-lists-common"
|
||||
"@kbn/securitysolution-lists-common",
|
||||
"@kbn/zod"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ListId,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
export type CreateListIndexResponse = z.infer<typeof CreateListIndexResponse>;
|
||||
export const CreateListIndexResponse = z.object({
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { ListItemId, ListId, ListItemValue, ListItemMetadata } from '../model/list_common.gen';
|
||||
import { ListItem } from '../model/list_schemas.gen';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
import { BooleanFromString } from '@kbn/zod-helpers';
|
||||
|
||||
import { ListId } from '../model/list_common.gen';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
export type DeleteListIndexResponse = z.infer<typeof DeleteListIndexResponse>;
|
||||
export const DeleteListIndexResponse = z.object({
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { ListId } from '../model/list_common.gen';
|
||||
import { ListItem } from '../model/list_schemas.gen';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { ListId } from '../model/list_common.gen';
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { NonEmptyString } from '@kbn/openapi-common/schemas/primitives.gen';
|
||||
import { ListId } from '../model/list_common.gen';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { NonEmptyString } from '@kbn/openapi-common/schemas/primitives.gen';
|
||||
import { List } from '../model/list_schemas.gen';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { ListId, ListType } from '../model/list_common.gen';
|
||||
import { List } from '../model/list_schemas.gen';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: not applicable
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { NonEmptyString } from '@kbn/openapi-common/schemas/primitives.gen';
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: not applicable
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ListId,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { ListId, ListName, ListDescription, ListMetadata } from '../model/list_common.gen';
|
||||
import { List } from '../model/list_schemas.gen';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { ListItemId, ListItemValue, ListItemMetadata } from '../model/list_common.gen';
|
||||
import { ListItem } from '../model/list_schemas.gen';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { ListId } from '../model/list_common.gen';
|
||||
import { List } from '../model/list_schemas.gen';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
export type ReadListIndexResponse = z.infer<typeof ReadListIndexResponse>;
|
||||
export const ReadListIndexResponse = z.object({
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { ListId } from '../model/list_common.gen';
|
||||
import { ListItem } from '../model/list_schemas.gen';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
export type ListPrivileges = z.infer<typeof ListPrivileges>;
|
||||
export const ListPrivileges = z.object({
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { ListId, ListName, ListDescription, ListMetadata } from '../model/list_common.gen';
|
||||
import { List } from '../model/list_schemas.gen';
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { ListItemId, ListItemValue, ListItemMetadata } from '../model/list_common.gen';
|
||||
import { ListItem } from '../model/list_schemas.gen';
|
||||
|
|
|
@ -6,5 +6,9 @@
|
|||
"exclude": ["target/**/*"],
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"include": ["**/*.ts"],
|
||||
"kbn_references": ["@kbn/zod-helpers", "@kbn/openapi-common"]
|
||||
"kbn_references": [
|
||||
"@kbn/zod-helpers",
|
||||
"@kbn/openapi-common",
|
||||
"@kbn/zod",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import { ArrayFromString } from './array_from_string';
|
||||
import * as z from 'zod';
|
||||
import * as z from '@kbn/zod';
|
||||
|
||||
describe('ArrayFromString', () => {
|
||||
const itemsSchema = z.string();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import * as z from 'zod';
|
||||
import * as z from '@kbn/zod';
|
||||
|
||||
/**
|
||||
* This is a helper schema to convert comma separated strings to arrays. Useful
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
import * as z from 'zod';
|
||||
import * as z from '@kbn/zod';
|
||||
|
||||
/**
|
||||
* This is a helper schema to convert a boolean string ("true" or "false") to a
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import type { TypeOf, ZodType } from 'zod';
|
||||
import type { TypeOf, ZodType } from '@kbn/zod';
|
||||
import type { RouteValidationFunction, RouteValidationResultFactory } from '@kbn/core/server';
|
||||
import { stringifyZodError } from './stringify_zod_error';
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import type { SafeParseError, SafeParseReturnType } from 'zod';
|
||||
import type { SafeParseError, SafeParseReturnType } from '@kbn/zod';
|
||||
|
||||
export function expectParseError<Input, Output>(
|
||||
result: SafeParseReturnType<Input, Output>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import type { SafeParseReturnType, SafeParseSuccess } from 'zod';
|
||||
import type { SafeParseReturnType, SafeParseSuccess } from '@kbn/zod';
|
||||
import { stringifyZodError } from './stringify_zod_error';
|
||||
|
||||
export function expectParseSuccess<Input, Output>(
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import * as z from 'zod';
|
||||
import * as z from '@kbn/zod';
|
||||
import dateMath from '@kbn/datemath';
|
||||
|
||||
function validateDateMath(time: string): boolean {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import * as z from 'zod';
|
||||
import * as z from '@kbn/zod';
|
||||
|
||||
/**
|
||||
* Safely parse a payload against a schema, returning the output or undefined.
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { ZodError, ZodIssue } from 'zod';
|
||||
import { ZodError, ZodIssue } from '@kbn/zod';
|
||||
|
||||
const MAX_ERRORS = 5;
|
||||
|
||||
|
|
|
@ -6,5 +6,9 @@
|
|||
"exclude": ["target/**/*"],
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"include": ["**/*.ts"],
|
||||
"kbn_references": ["@kbn/datemath", "@kbn/core"]
|
||||
"kbn_references": [
|
||||
"@kbn/datemath",
|
||||
"@kbn/core",
|
||||
"@kbn/zod",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 1
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { NonEmptyString } from '../common_attributes.gen';
|
||||
import { Replacements } from '../conversations/common_attributes.gen';
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { NonEmptyString } from '../common_attributes.gen';
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
import { ArrayFromString } from '@kbn/zod-helpers';
|
||||
|
||||
import { SortOrder } from '../common_attributes.gen';
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 1
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { NonEmptyString } from '../common_attributes.gen';
|
||||
import { AttackDiscoveryResponse } from './common_attributes.gen';
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: not applicable
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { NonEmptyString, User } from '../common_attributes.gen';
|
||||
import { Replacements, ApiConfig } from '../conversations/common_attributes.gen';
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 1
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { NonEmptyString } from '../common_attributes.gen';
|
||||
import { AttackDiscoveryResponse, AttackDiscoveryStat } from './common_attributes.gen';
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 1
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { AnonymizationFieldResponse } from '../anonymization_fields/bulk_crud_anonymization_fields_route.gen';
|
||||
import { ApiConfig, Replacements } from '../conversations/common_attributes.gen';
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 1
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
export type GetCapabilitiesResponse = z.infer<typeof GetCapabilitiesResponse>;
|
||||
export const GetCapabilitiesResponse = z.object({
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
export type RootContext = z.infer<typeof RootContext>;
|
||||
export const RootContext = z.literal('security');
|
||||
|
|
|
@ -14,7 +14,7 @@ import type {
|
|||
RouteValidationResultFactory,
|
||||
RouteValidationError,
|
||||
} from '@kbn/core/server';
|
||||
import type { TypeOf, ZodType } from 'zod';
|
||||
import type { TypeOf, ZodType } from '@kbn/zod';
|
||||
import { stringifyZodError } from '@kbn/zod-helpers';
|
||||
|
||||
type RequestValidationResult<T> =
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: not applicable
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
/**
|
||||
* A string that is not empty and does not contain only whitespace
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 1
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { NonEmptyString } from '../common_attributes.gen';
|
||||
import { ConversationMessageCreateProps, ConversationResponse } from './common_attributes.gen';
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 1
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ConversationCreateProps,
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: not applicable
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { NonEmptyString, User } from '../common_attributes.gen';
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
ConversationCreateProps,
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
import { ArrayFromString } from '@kbn/zod-helpers';
|
||||
|
||||
import { SortOrder } from '../common_attributes.gen';
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 1
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
export type GetEvaluateResponse = z.infer<typeof GetEvaluateResponse>;
|
||||
export const GetEvaluateResponse = z.object({
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 1
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { Replacements } from '../conversations/common_attributes.gen';
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 1
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
KnowledgeBaseEntryCreateProps,
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: not applicable
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { NonEmptyString, User } from '../common_attributes.gen';
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 1
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
/**
|
||||
* AI assistant KnowledgeBase.
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 1
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import {
|
||||
KnowledgeBaseEntryCreateProps,
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 1
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
import { ArrayFromString } from '@kbn/zod-helpers';
|
||||
|
||||
import { SortOrder } from '../common_attributes.gen';
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
import { NonEmptyString, User } from '../common_attributes.gen';
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* version: 2023-10-31
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
import { ArrayFromString } from '@kbn/zod-helpers';
|
||||
|
||||
import { SortOrder } from '../common_attributes.gen';
|
||||
|
|
|
@ -20,5 +20,6 @@
|
|||
"@kbn/securitysolution-io-ts-utils",
|
||||
"@kbn/core",
|
||||
"@kbn/logging",
|
||||
"@kbn/zod",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
export const createEntityDefinitionQuerySchema = z.object({
|
||||
installOnly: z.optional(z.coerce.boolean()).default(false),
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
export const deleteEntityDefinitionParamsSchema = z.object({
|
||||
id: z.string(),
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
export const getEntityDefinitionQuerySchema = z.object({
|
||||
page: z.optional(z.coerce.number()),
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
|
||||
export const resetEntityDefinitionParamsSchema = z.object({
|
||||
id: z.string(),
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
import moment from 'moment';
|
||||
|
||||
export const arrayOfStringsSchema = z.array(z.string());
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
import { z } from '@kbn/zod';
|
||||
import { arrayOfStringsSchema } from './common';
|
||||
|
||||
export const entityBaseSchema = z.object({
|
||||
|
|
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