Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solutions] (Phase 2) Adds deprecation to all the io-ts types and copies of them #99260

Merged
merged 1 commit into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions x-pack/plugins/cases/common/api/runtime_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import { isObject } from 'lodash/fp';

type ErrorFactory = (message: string) => Error;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils/src/format_errors/index.ts
* Bug fix for the TODO is in the format_errors package
*/
export const formatErrors = (errors: rt.Errors): string[] => {
const err = errors.map((error) => {
if (error.message != null) {
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/lists/common/format_errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import * as t from 'io-ts';
import { isObject } from 'lodash/fp';

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils/src/format_errors/index.ts
*/
export const formatErrors = (errors: t.Errors): string[] => {
const err = errors.map((error) => {
if (error.message != null) {
Expand Down
168 changes: 168 additions & 0 deletions x-pack/plugins/lists/common/schemas/common/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,44 @@ import * as t from 'io-ts';
import { DefaultNamespace } from '../types/default_namespace';
import { DefaultArray, DefaultStringArray, NonEmptyString } from '../../shared_imports';

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const name = t.string;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type Name = t.TypeOf<typeof name>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const nameOrUndefined = t.union([name, t.undefined]);

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type NameOrUndefined = t.TypeOf<typeof nameOrUndefined>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const description = t.string;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type Description = t.TypeOf<typeof description>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const descriptionOrUndefined = t.union([description, t.undefined]);

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type DescriptionOrUndefined = t.TypeOf<typeof descriptionOrUndefined>;

export const list_id = NonEmptyString;
Expand All @@ -28,15 +58,47 @@ export const list_idOrUndefined = t.union([list_id, t.undefined]);
export type ListIdOrUndefined = t.TypeOf<typeof list_idOrUndefined>;

export const item = t.string;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const created_at = t.string; // TODO: Make this into an ISO Date string check

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const updated_at = t.string; // TODO: Make this into an ISO Date string check

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const updated_by = t.string;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const created_by = t.string;

export const file = t.object;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const id = NonEmptyString;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type Id = t.TypeOf<typeof id>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const idOrUndefined = t.union([id, t.undefined]);

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type IdOrUndefined = t.TypeOf<typeof idOrUndefined>;

export const binary = t.string;
Expand Down Expand Up @@ -93,6 +155,9 @@ export const valueOrUndefined = t.union([value, t.undefined]);
export const tie_breaker_id = t.string; // TODO: Use UUID for this instead of a string for validation
export const _index = t.string;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const type = t.keyof({
binary: null,
boolean: null,
Expand Down Expand Up @@ -122,9 +187,24 @@ export const type = t.keyof({
export const typeOrUndefined = t.union([type, t.undefined]);
export type Type = t.TypeOf<typeof type>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const meta = t.object;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type Meta = t.TypeOf<typeof meta>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const metaOrUndefined = t.union([meta, t.undefined]);

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type MetaOrUndefined = t.TypeOf<typeof metaOrUndefined>;

export const esDataTypeRange = t.exact(t.type({ gte: t.string, lte: t.string }));
Expand Down Expand Up @@ -207,28 +287,77 @@ export const esDataTypeUnion = t.union([

export type EsDataTypeUnion = t.TypeOf<typeof esDataTypeUnion>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const tags = DefaultStringArray;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type Tags = t.TypeOf<typeof tags>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const tagsOrUndefined = t.union([tags, t.undefined]);

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type TagsOrUndefined = t.TypeOf<typeof tagsOrUndefined>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const exceptionListType = t.keyof({
detection: null,
endpoint: null,
endpoint_events: null,
});

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const exceptionListTypeOrUndefined = t.union([exceptionListType, t.undefined]);

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type ExceptionListType = t.TypeOf<typeof exceptionListType>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type ExceptionListTypeOrUndefined = t.TypeOf<typeof exceptionListTypeOrUndefined>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export enum ExceptionListTypeEnum {
DETECTION = 'detection',
ENDPOINT = 'endpoint',
ENDPOINT_EVENTS = 'endpoint_events',
}

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const exceptionListItemType = t.keyof({ simple: null });

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const exceptionListItemTypeOrUndefined = t.union([exceptionListItemType, t.undefined]);

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type ExceptionListItemType = t.TypeOf<typeof exceptionListItemType>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type ExceptionListItemTypeOrUndefined = t.TypeOf<typeof exceptionListItemTypeOrUndefined>;

export const list_type = t.keyof({ item: null, list: null });
Expand Down Expand Up @@ -275,14 +404,32 @@ export type CursorOrUndefined = t.TypeOf<typeof cursorOrUndefined>;

export const namespace_type = DefaultNamespace;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const operatorIncluded = t.keyof({ included: null });

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const operator = t.keyof({ excluded: null, included: null });

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type Operator = t.TypeOf<typeof operator>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export enum OperatorEnum {
INCLUDED = 'included',
EXCLUDED = 'excluded',
}

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export enum OperatorTypeEnum {
NESTED = 'nested',
MATCH = 'match',
Expand Down Expand Up @@ -320,15 +467,36 @@ export type Immutable = t.TypeOf<typeof immutable>;
export const immutableOrUndefined = t.union([immutable, t.undefined]);
export type ImmutableOrUndefined = t.TypeOf<typeof immutableOrUndefined>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const osType = t.keyof({
linux: null,
macos: null,
windows: null,
});

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type OsType = t.TypeOf<typeof osType>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const osTypeArray = DefaultArray(osType);

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type OsTypeArray = t.TypeOf<typeof osTypeArray>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const osTypeArrayOrUndefined = t.union([osTypeArray, t.undefined]);

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type OsTypeArrayOrUndefined = t.OutputOf<typeof osTypeArray>;
22 changes: 22 additions & 0 deletions x-pack/plugins/lists/common/schemas/types/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import * as t from 'io-ts';
import { NonEmptyString } from '../../shared_imports';
import { created_at, created_by, id, updated_at, updated_by } from '../common/schemas';

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const comment = t.intersection([
t.exact(
t.type({
Expand All @@ -27,8 +30,27 @@ export const comment = t.intersection([
),
]);

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const commentsArray = t.array(comment);

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type CommentsArray = t.TypeOf<typeof commentsArray>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type Comment = t.TypeOf<typeof comment>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const commentsArrayOrUndefined = t.union([commentsArray, t.undefined]);

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type CommentsArrayOrUndefined = t.TypeOf<typeof commentsArrayOrUndefined>;
26 changes: 26 additions & 0 deletions x-pack/plugins/lists/common/schemas/types/create_comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,41 @@ import * as t from 'io-ts';

import { NonEmptyString } from '../../shared_imports';

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const createComment = t.exact(
t.type({
comment: NonEmptyString,
})
);

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type CreateComment = t.TypeOf<typeof createComment>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const createCommentsArray = t.array(createComment);

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type CreateCommentsArray = t.TypeOf<typeof createCommentsArray>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type CreateComments = t.TypeOf<typeof createComment>;

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const createCommentsArrayOrUndefined = t.union([createCommentsArray, t.undefined]);

/**
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export type CreateCommentsArrayOrUndefined = t.TypeOf<typeof createCommentsArrayOrUndefined>;
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { CommentsArray, comment } from './comment';
/**
* Types the DefaultCommentsArray as:
* - If null or undefined, then a default array of type entry will be set
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const DefaultCommentsArray = new t.Type<CommentsArray, CommentsArray, unknown>(
'DefaultCommentsArray',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { CreateCommentsArray, createComment } from './create_comment';
/**
* Types the DefaultCreateComments as:
* - If null or undefined, then a default array of type entry will be set
* @deprecated Use packages/kbn-securitysolution-io-ts-utils
*/
export const DefaultCreateCommentsArray = new t.Type<
CreateCommentsArray,
Expand Down
Loading