From 21f3b6713efa19d4f6c7e4ccb86a4d91222791d9 Mon Sep 17 00:00:00 2001 From: Christos Nasikas Date: Tue, 13 Oct 2020 16:12:03 +0300 Subject: [PATCH] [Security Solution][Case] Improve ServiceConnectorCaseParams type (#80109) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- x-pack/plugins/case/common/api/cases/case.ts | 9 +++++++-- x-pack/plugins/case/common/api/connectors/index.ts | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/case/common/api/cases/case.ts b/x-pack/plugins/case/common/api/cases/case.ts index ffeecf27743f5b..52e4a15a3f445f 100644 --- a/x-pack/plugins/case/common/api/cases/case.ts +++ b/x-pack/plugins/case/common/api/cases/case.ts @@ -10,7 +10,7 @@ import { NumberFromString } from '../saved_object'; import { UserRT } from '../user'; import { CommentResponseRt } from './comment'; import { CasesStatusResponseRt } from './status'; -import { CaseConnectorRt, ESCaseConnector } from '../connectors'; +import { CaseConnectorRt, ESCaseConnector, ConnectorPartialFieldsRt } from '../connectors'; // eslint-disable-next-line @kbn/eslint/no-restricted-paths export { ActionTypeExecutorResult } from '../../../../actions/server/types'; @@ -133,7 +133,7 @@ export const ServiceConnectorCommentParamsRt = rt.type({ updatedBy: rt.union([ServiceConnectorUserParams, rt.null]), }); -export const ServiceConnectorCaseParamsRt = rt.type({ +export const ServiceConnectorBasicCaseParamsRt = rt.type({ comments: rt.union([rt.array(ServiceConnectorCommentParamsRt), rt.null]), createdAt: rt.string, createdBy: ServiceConnectorUserParams, @@ -145,6 +145,11 @@ export const ServiceConnectorCaseParamsRt = rt.type({ updatedBy: rt.union([ServiceConnectorUserParams, rt.null]), }); +export const ServiceConnectorCaseParamsRt = rt.intersection([ + ServiceConnectorBasicCaseParamsRt, + ConnectorPartialFieldsRt, +]); + export const ServiceConnectorCaseResponseRt = rt.intersection([ rt.type({ title: rt.string, diff --git a/x-pack/plugins/case/common/api/connectors/index.ts b/x-pack/plugins/case/common/api/connectors/index.ts index 88d81eed2d87de..0019afe7c6b743 100644 --- a/x-pack/plugins/case/common/api/connectors/index.ts +++ b/x-pack/plugins/case/common/api/connectors/index.ts @@ -20,6 +20,12 @@ export const ConnectorFieldsRt = rt.union([ rt.null, ]); +export const ConnectorPartialFieldsRt = rt.partial({ + ...JiraFieldsRT.props, + ...ResilientFieldsRT.props, + ...ServiceNowFieldsRT.props, +}); + export enum ConnectorTypes { jira = '.jira', resilient = '.resilient',