-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Cases] User actions enhancements (#120342)
Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
47abd52
commit 61dd51a
Showing
105 changed files
with
6,463 additions
and
4,554 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
x-pack/plugins/cases/common/api/cases/user_actions/comment.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import * as rt from 'io-ts'; | ||
import { CommentRequestRt } from '../comment'; | ||
import { ActionTypes, UserActionWithAttributes } from './common'; | ||
|
||
export const CommentUserActionPayloadRt = rt.type({ comment: CommentRequestRt }); | ||
|
||
export const CommentUserActionRt = rt.type({ | ||
type: rt.literal(ActionTypes.comment), | ||
payload: CommentUserActionPayloadRt, | ||
}); | ||
|
||
export type CommentUserAction = UserActionWithAttributes<rt.TypeOf<typeof CommentUserActionRt>>; |
55 changes: 55 additions & 0 deletions
55
x-pack/plugins/cases/common/api/cases/user_actions/common.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import * as rt from 'io-ts'; | ||
import { UserRT } from '../../user'; | ||
|
||
export const ActionTypes = { | ||
comment: 'comment', | ||
connector: 'connector', | ||
description: 'description', | ||
pushed: 'pushed', | ||
tags: 'tags', | ||
title: 'title', | ||
status: 'status', | ||
settings: 'settings', | ||
create_case: 'create_case', | ||
delete_case: 'delete_case', | ||
} as const; | ||
|
||
export const Actions = { | ||
add: 'add', | ||
create: 'create', | ||
delete: 'delete', | ||
update: 'update', | ||
push_to_service: 'push_to_service', | ||
} as const; | ||
|
||
/* To the next developer, if you add/removed fields here | ||
* make sure to check this file (x-pack/plugins/cases/server/services/user_actions/helpers.ts) too | ||
*/ | ||
export const ActionTypesRt = rt.keyof(ActionTypes); | ||
export const ActionsRt = rt.keyof(Actions); | ||
|
||
export const UserActionCommonAttributesRt = rt.type({ | ||
created_at: rt.string, | ||
created_by: UserRT, | ||
owner: rt.string, | ||
action: ActionsRt, | ||
}); | ||
|
||
export const CaseUserActionSavedObjectIdsRt = rt.intersection([ | ||
rt.type({ | ||
action_id: rt.string, | ||
case_id: rt.string, | ||
comment_id: rt.union([rt.string, rt.null]), | ||
}), | ||
rt.partial({ sub_case_id: rt.string }), | ||
]); | ||
|
||
export type UserActionWithAttributes<T> = T & rt.TypeOf<typeof UserActionCommonAttributesRt>; | ||
export type UserActionWithResponse<T> = T & rt.TypeOf<typeof CaseUserActionSavedObjectIdsRt>; |
33 changes: 33 additions & 0 deletions
33
x-pack/plugins/cases/common/api/cases/user_actions/connector.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import * as rt from 'io-ts'; | ||
import { CaseUserActionConnectorRt, CaseConnectorRt } from '../../connectors'; | ||
import { ActionTypes, UserActionWithAttributes } from './common'; | ||
|
||
export const ConnectorUserActionPayloadWithoutConnectorIdRt = rt.type({ | ||
connector: CaseUserActionConnectorRt, | ||
}); | ||
|
||
export const ConnectorUserActionPayloadRt = rt.type({ | ||
connector: CaseConnectorRt, | ||
}); | ||
|
||
export const ConnectorUserActionWithoutConnectorIdRt = rt.type({ | ||
type: rt.literal(ActionTypes.connector), | ||
payload: ConnectorUserActionPayloadWithoutConnectorIdRt, | ||
}); | ||
|
||
export const ConnectorUserActionRt = rt.type({ | ||
type: rt.literal(ActionTypes.connector), | ||
payload: ConnectorUserActionPayloadRt, | ||
}); | ||
|
||
export type ConnectorUserAction = UserActionWithAttributes<rt.TypeOf<typeof ConnectorUserActionRt>>; | ||
export type ConnectorUserActionWithoutConnectorId = UserActionWithAttributes< | ||
rt.TypeOf<typeof ConnectorUserActionWithoutConnectorIdRt> | ||
>; |
54 changes: 54 additions & 0 deletions
54
x-pack/plugins/cases/common/api/cases/user_actions/create_case.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import * as rt from 'io-ts'; | ||
import { ActionTypes, UserActionWithAttributes } from './common'; | ||
import { | ||
ConnectorUserActionPayloadRt, | ||
ConnectorUserActionPayloadWithoutConnectorIdRt, | ||
} from './connector'; | ||
import { DescriptionUserActionPayloadRt } from './description'; | ||
import { SettingsUserActionPayloadRt } from './settings'; | ||
import { TagsUserActionPayloadRt } from './tags'; | ||
import { TitleUserActionPayloadRt } from './title'; | ||
|
||
export const CommonFieldsRt = rt.type({ | ||
type: rt.literal(ActionTypes.create_case), | ||
}); | ||
|
||
const CommonPayloadAttributesRt = rt.type({ | ||
description: DescriptionUserActionPayloadRt.props.description, | ||
status: rt.string, | ||
tags: TagsUserActionPayloadRt.props.tags, | ||
title: TitleUserActionPayloadRt.props.title, | ||
settings: SettingsUserActionPayloadRt.props.settings, | ||
owner: rt.string, | ||
}); | ||
|
||
export const CreateCaseUserActionRt = rt.intersection([ | ||
CommonFieldsRt, | ||
rt.type({ | ||
payload: rt.intersection([ConnectorUserActionPayloadRt, CommonPayloadAttributesRt]), | ||
}), | ||
]); | ||
|
||
export const CreateCaseUserActionWithoutConnectorIdRt = rt.intersection([ | ||
CommonFieldsRt, | ||
rt.type({ | ||
payload: rt.intersection([ | ||
ConnectorUserActionPayloadWithoutConnectorIdRt, | ||
CommonPayloadAttributesRt, | ||
]), | ||
}), | ||
]); | ||
|
||
export type CreateCaseUserAction = UserActionWithAttributes< | ||
rt.TypeOf<typeof CreateCaseUserActionRt> | ||
>; | ||
export type CreateCaseUserActionWithoutConnectorId = UserActionWithAttributes< | ||
rt.TypeOf<typeof CreateCaseUserActionWithoutConnectorIdRt> | ||
>; |
18 changes: 18 additions & 0 deletions
18
x-pack/plugins/cases/common/api/cases/user_actions/delete_case.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import * as rt from 'io-ts'; | ||
import { ActionTypes, UserActionWithAttributes } from './common'; | ||
|
||
export const DeleteCaseUserActionRt = rt.type({ | ||
type: rt.literal(ActionTypes.delete_case), | ||
payload: rt.type({}), | ||
}); | ||
|
||
export type DeleteCaseUserAction = UserActionWithAttributes< | ||
rt.TypeOf<typeof DeleteCaseUserActionRt> | ||
>; |
20 changes: 20 additions & 0 deletions
20
x-pack/plugins/cases/common/api/cases/user_actions/description.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import * as rt from 'io-ts'; | ||
import { ActionTypes, UserActionWithAttributes } from './common'; | ||
|
||
export const DescriptionUserActionPayloadRt = rt.type({ description: rt.string }); | ||
|
||
export const DescriptionUserActionRt = rt.type({ | ||
type: rt.literal(ActionTypes.description), | ||
payload: DescriptionUserActionPayloadRt, | ||
}); | ||
|
||
export type DescriptionUserAction = UserActionWithAttributes< | ||
rt.TypeOf<typeof DescriptionUserActionRt> | ||
>; |
91 changes: 91 additions & 0 deletions
91
x-pack/plugins/cases/common/api/cases/user_actions/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import * as rt from 'io-ts'; | ||
|
||
import { | ||
ActionsRt, | ||
UserActionCommonAttributesRt, | ||
CaseUserActionSavedObjectIdsRt, | ||
ActionTypesRt, | ||
} from './common'; | ||
import { CreateCaseUserActionRt } from './create_case'; | ||
import { DescriptionUserActionRt } from './description'; | ||
import { CommentUserActionRt } from './comment'; | ||
import { ConnectorUserActionRt } from './connector'; | ||
import { PushedUserActionRt } from './pushed'; | ||
import { TagsUserActionRt } from './tags'; | ||
import { TitleUserActionRt } from './title'; | ||
import { SettingsUserActionRt } from './settings'; | ||
import { StatusUserActionRt } from './status'; | ||
import { DeleteCaseUserActionRt } from './delete_case'; | ||
|
||
export * from './common'; | ||
export * from './comment'; | ||
export * from './connector'; | ||
export * from './create_case'; | ||
export * from './delete_case'; | ||
export * from './description'; | ||
export * from './pushed'; | ||
export * from './settings'; | ||
export * from './status'; | ||
export * from './tags'; | ||
export * from './title'; | ||
|
||
const CommonUserActionsRt = rt.union([ | ||
DescriptionUserActionRt, | ||
CommentUserActionRt, | ||
TagsUserActionRt, | ||
TitleUserActionRt, | ||
SettingsUserActionRt, | ||
StatusUserActionRt, | ||
]); | ||
|
||
export const UserActionsRt = rt.union([ | ||
CommonUserActionsRt, | ||
CreateCaseUserActionRt, | ||
ConnectorUserActionRt, | ||
PushedUserActionRt, | ||
DeleteCaseUserActionRt, | ||
]); | ||
|
||
export const UserActionsWithoutConnectorIdRt = rt.union([ | ||
CommonUserActionsRt, | ||
CreateCaseUserActionRt, | ||
ConnectorUserActionRt, | ||
PushedUserActionRt, | ||
DeleteCaseUserActionRt, | ||
]); | ||
|
||
const CaseUserActionBasicRt = rt.intersection([UserActionsRt, UserActionCommonAttributesRt]); | ||
const CaseUserActionBasicWithoutConnectorIdRt = rt.intersection([ | ||
UserActionsWithoutConnectorIdRt, | ||
UserActionCommonAttributesRt, | ||
]); | ||
|
||
const CaseUserActionResponseRt = rt.intersection([ | ||
CaseUserActionBasicRt, | ||
CaseUserActionSavedObjectIdsRt, | ||
]); | ||
|
||
export const CaseUserActionAttributesRt = CaseUserActionBasicRt; | ||
export const CaseUserActionsResponseRt = rt.array(CaseUserActionResponseRt); | ||
|
||
export type CaseUserActionAttributes = rt.TypeOf<typeof CaseUserActionAttributesRt>; | ||
export type CaseUserActionAttributesWithoutConnectorId = rt.TypeOf< | ||
typeof CaseUserActionAttributesRt | ||
>; | ||
export type CaseUserActionsResponse = rt.TypeOf<typeof CaseUserActionsResponseRt>; | ||
export type CaseUserActionResponse = rt.TypeOf<typeof CaseUserActionResponseRt>; | ||
|
||
export type UserAction = rt.TypeOf<typeof ActionsRt>; | ||
export type UserActionTypes = rt.TypeOf<typeof ActionTypesRt>; | ||
|
||
export type CaseUserAction = rt.TypeOf<typeof CaseUserActionBasicRt>; | ||
export type CaseUserActionWithoutConnectorId = rt.TypeOf< | ||
typeof CaseUserActionBasicWithoutConnectorIdRt | ||
>; |
Oops, something went wrong.