From b50a3e0e7fd0a133927eef18e15b7a3070cdbf80 Mon Sep 17 00:00:00 2001 From: Christos Nasikas Date: Thu, 29 Jun 2023 11:44:22 +0300 Subject: [PATCH] Fix types from other plugins --- .../logic/export/get_export_all.test.ts | 2 ++ .../logic/export/get_export_by_object_ids.test.ts | 2 ++ .../import_rule_action_connectors.test.ts | 2 ++ .../rule_management/utils/utils.test.ts | 11 +++++++++++ .../connector_types/es_index/es_index_params.test.tsx | 2 ++ .../public/connector_types/gen_ai/params.test.tsx | 1 + .../public/connector_types/jira/jira_params.test.tsx | 1 + .../connector_types/lib/servicenow/helpers.test.ts | 1 + .../lib/servicenow/servicenow_connectors.tsx | 1 + .../lib/servicenow/use_choices.test.tsx | 1 + .../lib/servicenow/use_get_choices.test.tsx | 1 + .../public/connector_types/opsgenie/params.test.tsx | 1 + .../resilient/resilient_params.test.tsx | 1 + .../servicenow_itom/servicenow_itom_params.test.tsx | 1 + .../servicenow_itsm/servicenow_itsm_params.test.tsx | 1 + .../servicenow_sir/servicenow_sir_params.test.tsx | 1 + .../connector_types/swimlane/swimlane_params.test.tsx | 1 + .../public/apps/synthetics/state/settings/api.ts | 2 ++ .../lib/action_connector_api/connectors.ts | 3 ++- .../application/lib/action_connector_api/create.ts | 2 +- .../application/lib/action_connector_api/update.ts | 2 +- .../action_connector_form/action_type_form.test.tsx | 6 +++--- .../connectors_selection.test.tsx | 2 +- .../edit_connector_flyout/index.tsx | 2 +- x-pack/plugins/triggers_actions_ui/public/types.ts | 8 ++++++++ .../uptime/public/legacy_uptime/state/api/alerts.ts | 2 ++ 26 files changed, 52 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/export/get_export_all.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/export/get_export_all.test.ts index c86387f26f50a..55f797e73ebc3 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/export/get_export_all.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/export/get_export_all.test.ts @@ -39,6 +39,7 @@ const connectors = [ config: {}, isPreconfigured: false, isDeprecated: false, + isSystemAction: false, referencedByCount: 1, }, { @@ -47,6 +48,7 @@ const connectors = [ name: 'Email (preconfigured)', config: {}, isPreconfigured: true, + isSystemAction: false, isDeprecated: false, referencedByCount: 1, }, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/export/get_export_by_object_ids.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/export/get_export_by_object_ids.test.ts index 35151f1b4b1d6..79aa4bfd3d88e 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/export/get_export_by_object_ids.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/export/get_export_by_object_ids.test.ts @@ -38,6 +38,7 @@ const connectors = [ config: {}, isPreconfigured: false, isDeprecated: false, + isSystemAction: false, referencedByCount: 1, }, { @@ -47,6 +48,7 @@ const connectors = [ config: {}, isPreconfigured: true, isDeprecated: false, + isSystemAction: false, referencedByCount: 1, }, ]; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/import/action_connectors/import_rule_action_connectors.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/import/action_connectors/import_rule_action_connectors.test.ts index 54574c85f7036..19b4597f408df 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/import/action_connectors/import_rule_action_connectors.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/logic/import/action_connectors/import_rule_action_connectors.test.ts @@ -317,6 +317,7 @@ describe('importRuleActionConnectors', () => { id: 'cabc78e0-9031-11ed-b076-53cc4d57aaf1', referencedByCount: 1, isDeprecated: false, + isSystemAction: false, }, ]); const actionsImporter2 = core.savedObjects.getImporter; @@ -358,6 +359,7 @@ describe('importRuleActionConnectors', () => { id: 'cabc78e0-9031-11ed-b076-53cc4d57aaf1', referencedByCount: 1, isDeprecated: false, + isSystemAction: false, }, ]); diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/utils/utils.test.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/utils/utils.test.ts index 8e82965f2b5f9..89699de1316ad 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/utils/utils.test.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/utils/utils.test.ts @@ -874,6 +874,7 @@ describe('utils', () => { name: 'name', isPreconfigured: false, isDeprecated: false, + isSystemAction: false, }, ]); const [errors, output] = await getInvalidConnectors(rules, clients.actionsClient); @@ -918,6 +919,7 @@ describe('utils', () => { name: 'name', isPreconfigured: false, isDeprecated: false, + isSystemAction: false, }, { id: '789', @@ -926,6 +928,7 @@ describe('utils', () => { name: 'name', isPreconfigured: false, isDeprecated: false, + isSystemAction: false, }, ]); const [errors, output] = await getInvalidConnectors(rules, clients.actionsClient); @@ -976,6 +979,7 @@ describe('utils', () => { name: 'name', isPreconfigured: false, isDeprecated: false, + isSystemAction: false, }, { id: '789', @@ -984,6 +988,7 @@ describe('utils', () => { name: 'name', isPreconfigured: false, isDeprecated: false, + isSystemAction: false, }, ]); const [errors, output] = await getInvalidConnectors(rules, clients.actionsClient); @@ -1041,6 +1046,7 @@ describe('utils', () => { name: 'name', isPreconfigured: false, isDeprecated: false, + isSystemAction: false, }, { id: '789', @@ -1049,6 +1055,7 @@ describe('utils', () => { name: 'name', isPreconfigured: false, isDeprecated: false, + isSystemAction: false, }, ]); const [errors, output] = await getInvalidConnectors(rules, clients.actionsClient); @@ -1108,6 +1115,7 @@ describe('utils', () => { name: 'name', isPreconfigured: false, isDeprecated: false, + isSystemAction: false, }, { id: '789', @@ -1116,6 +1124,7 @@ describe('utils', () => { name: 'name', isPreconfigured: false, isDeprecated: false, + isSystemAction: false, }, ]); const [errors, output] = await getInvalidConnectors(rules, clients.actionsClient); @@ -1216,6 +1225,7 @@ describe('utils', () => { name: 'name', isPreconfigured: false, isDeprecated: false, + isSystemAction: false, }, { id: '789', @@ -1224,6 +1234,7 @@ describe('utils', () => { name: 'name', isPreconfigured: false, isDeprecated: false, + isSystemAction: false, }, ]); const [errors, output] = await getInvalidConnectors(rules, clients.actionsClient); diff --git a/x-pack/plugins/stack_connectors/public/connector_types/es_index/es_index_params.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/es_index/es_index_params.test.tsx index 44a6133cbefda..6118efcfdb12c 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/es_index/es_index_params.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/es_index/es_index_params.test.tsx @@ -33,6 +33,7 @@ const actionConnector = { }, id: 'es index connector', isPreconfigured: false, + isSystemAction: false as const, isDeprecated: false, name: 'test name', secrets: {}, @@ -45,6 +46,7 @@ const preconfiguredActionConnector = { }, id: AlertHistoryEsIndexConnectorId, isPreconfigured: true, + isSystemAction: false as const, isDeprecated: false, name: 'Alert history Elasticsearch index', secrets: {}, diff --git a/x-pack/plugins/stack_connectors/public/connector_types/gen_ai/params.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/gen_ai/params.test.tsx index f37ab8b39d573..ef418bd16965d 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/gen_ai/params.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/gen_ai/params.test.tsx @@ -65,6 +65,7 @@ describe('Gen AI Params Fields renders', () => { id: 'test', actionTypeId: '.gen-ai', isPreconfigured: false, + isSystemAction: false as const, isDeprecated: false, name: 'My GenAI Connector', config: { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/jira/jira_params.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/jira/jira_params.test.tsx index 3865da8ead3a7..6deb820876b96 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/jira/jira_params.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/jira/jira_params.test.tsx @@ -50,6 +50,7 @@ const connector: ActionConnector = { name: 'Test', isPreconfigured: false, isDeprecated: false, + isSystemAction: false as const, }; const editAction = jest.fn(); const defaultProps = { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/helpers.test.ts b/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/helpers.test.ts index 7700014e58021..17996ccf7fe65 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/helpers.test.ts +++ b/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/helpers.test.ts @@ -23,6 +23,7 @@ const deprecatedConnector: ActionConnector = { name: 'Test', isPreconfigured: false, isDeprecated: true, + isSystemAction: false as const, }; const validConnector = { diff --git a/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/servicenow_connectors.tsx b/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/servicenow_connectors.tsx index f667847f6dd29..c08e97902746a 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/servicenow_connectors.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/servicenow_connectors.tsx @@ -131,6 +131,7 @@ const ServiceNowConnectorFields: React.FC = ({ ...connectorToUpdate, isDeprecated, isPreconfigured: false, + isSystemAction: false, actionTypeId, }); diff --git a/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/use_choices.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/use_choices.test.tsx index d3584cc38a202..721897ece7266 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/use_choices.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/use_choices.test.tsx @@ -27,6 +27,7 @@ const actionConnector = { actionTypeId: '.servicenow', name: 'ServiceNow ITSM', isPreconfigured: false, + isSystemAction: false as const, isDeprecated: false, config: { apiUrl: 'https://dev94428.service-now.com/', diff --git a/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/use_get_choices.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/use_get_choices.test.tsx index b4d204c117b50..38ea6d55b4e17 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/use_get_choices.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/lib/servicenow/use_get_choices.test.tsx @@ -28,6 +28,7 @@ const actionConnector = { actionTypeId: '.servicenow', name: 'ServiceNow ITSM', isPreconfigured: false, + isSystemAction: false as const, isDeprecated: false, config: { apiUrl: 'https://dev94428.service-now.com/', diff --git a/x-pack/plugins/stack_connectors/public/connector_types/opsgenie/params.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/opsgenie/params.test.tsx index 7a65a8b5fd790..562fd66d031dd 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/opsgenie/params.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/opsgenie/params.test.tsx @@ -45,6 +45,7 @@ describe('OpsgenieParamFields', () => { actionTypeId: '.test', name: 'Test', isPreconfigured: false, + isSystemAction: false as const, isDeprecated: false, }; diff --git a/x-pack/plugins/stack_connectors/public/connector_types/resilient/resilient_params.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/resilient/resilient_params.test.tsx index c6417660720f7..178cb86389d18 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/resilient/resilient_params.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/resilient/resilient_params.test.tsx @@ -39,6 +39,7 @@ const connector = { actionTypeId: '.test', name: 'Test', isPreconfigured: false, + isSystemAction: false as const, isDeprecated: false, }; diff --git a/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itom/servicenow_itom_params.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itom/servicenow_itom_params.test.tsx index 5ac0c36b0c7fc..cc67186790be7 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itom/servicenow_itom_params.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itom/servicenow_itom_params.test.tsx @@ -41,6 +41,7 @@ const connector: ActionConnector = { actionTypeId: '.test', name: 'Test', isPreconfigured: false, + isSystemAction: false as const, isDeprecated: false, }; diff --git a/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itsm/servicenow_itsm_params.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itsm/servicenow_itsm_params.test.tsx index 344cd73208fb6..5925724b7b8a9 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itsm/servicenow_itsm_params.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/servicenow_itsm/servicenow_itsm_params.test.tsx @@ -46,6 +46,7 @@ const connector: ActionConnector = { actionTypeId: '.test', name: 'Test', isPreconfigured: false, + isSystemAction: false as const, isDeprecated: false, }; diff --git a/x-pack/plugins/stack_connectors/public/connector_types/servicenow_sir/servicenow_sir_params.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/servicenow_sir/servicenow_sir_params.test.tsx index a368c1564725d..8a62b6f09a758 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/servicenow_sir/servicenow_sir_params.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/servicenow_sir/servicenow_sir_params.test.tsx @@ -48,6 +48,7 @@ const connector: ActionConnector = { actionTypeId: '.test', name: 'Test', isPreconfigured: false, + isSystemAction: false as const, isDeprecated: false, }; diff --git a/x-pack/plugins/stack_connectors/public/connector_types/swimlane/swimlane_params.test.tsx b/x-pack/plugins/stack_connectors/public/connector_types/swimlane/swimlane_params.test.tsx index 302e5c80af15c..a8575912ddc38 100644 --- a/x-pack/plugins/stack_connectors/public/connector_types/swimlane/swimlane_params.test.tsx +++ b/x-pack/plugins/stack_connectors/public/connector_types/swimlane/swimlane_params.test.tsx @@ -36,6 +36,7 @@ describe('SwimlaneParamsFields renders', () => { actionTypeId: '.test', name: 'Test', isPreconfigured: false, + isSystemAction: false as const, isDeprecated: false, }; diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/state/settings/api.ts b/x-pack/plugins/synthetics/public/apps/synthetics/state/settings/api.ts index 02efa016475c2..b7ae7884b178a 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/state/settings/api.ts +++ b/x-pack/plugins/synthetics/public/apps/synthetics/state/settings/api.ts @@ -61,6 +61,7 @@ export const fetchConnectors = async (): Promise => { is_preconfigured: isPreconfigured, is_deprecated: isDeprecated, is_missing_secrets: isMissingSecrets, + is_system_action: isSystemAction, ...res }) => ({ ...res, @@ -69,6 +70,7 @@ export const fetchConnectors = async (): Promise => { isDeprecated, isPreconfigured, isMissingSecrets, + isSystemAction, }) ); }; diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connectors.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connectors.ts index 60f1e25295686..6938654b294ac 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connectors.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/connectors.ts @@ -41,5 +41,6 @@ export async function loadAllActions({ http }: { http: HttpSetup }): Promise[0]>( `${BASE_ACTION_API_PATH}/connectors` ); - return rewriteResponseRes(res); + + return rewriteResponseRes(res) as ActionConnector[]; } diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/create.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/create.ts index 1256497a5d448..32efba66d56be 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/create.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/create.ts @@ -49,5 +49,5 @@ export async function createActionConnector({ `${BASE_ACTION_API_PATH}/connector`, { body: JSON.stringify(rewriteBodyRequest(connector)) } ); - return rewriteBodyRes(res); + return rewriteBodyRes(res) as ActionConnector; } diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/update.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/update.ts index 7b65b53443198..c35378ebad17e 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/update.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/action_connector_api/update.ts @@ -51,5 +51,5 @@ export async function updateActionConnector({ } ); - return rewriteBodyRes(res); + return rewriteBodyRes(res) as ActionConnector; } diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.test.tsx index 807e5454f094f..46dafc3c4fc03 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/action_type_form.test.tsx @@ -556,7 +556,7 @@ function getActionTypeForm({ id: 'test', isPreconfigured: false, isDeprecated: false, - isSystemAction: false, + isSystemAction: false as const, name: 'test name', secrets: {}, }; @@ -580,7 +580,7 @@ function getActionTypeForm({ id: 'test', isPreconfigured: false, isDeprecated: false, - isSystemAction: false, + isSystemAction: false as const, name: 'test name', secrets: {}, }, @@ -590,7 +590,7 @@ function getActionTypeForm({ actionTypeId: '.server-log', isPreconfigured: false, isDeprecated: false, - isSystemAction: false, + isSystemAction: false as const, config: {}, secrets: {}, }, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connectors_selection.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connectors_selection.test.tsx index 230f81e153162..64a19d253740c 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connectors_selection.test.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/connectors_selection.test.tsx @@ -69,7 +69,7 @@ describe('connectors_selection', () => { id: 'testId', isPreconfigured: false, isDeprecated: false, - isSystemAction: false, + isSystemAction: false as const, name: 'test pagerduty', secrets: {}, }, diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/edit_connector_flyout/index.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/edit_connector_flyout/index.tsx index e00349cecd62b..343e0b01c4782 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/edit_connector_flyout/index.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/action_connector_form/edit_connector_flyout/index.tsx @@ -260,7 +260,7 @@ const EditConnectorFlyoutComponent: React.FC = ({ /> {selectedTab === EditConnectorTabs.Configuration ? ( - !connector.isPreconfigured ? ( + !connector.isPreconfigured && !connector.isSystemAction ? ( <> {isEdit && ( <> diff --git a/x-pack/plugins/triggers_actions_ui/public/types.ts b/x-pack/plugins/triggers_actions_ui/public/types.ts index 3e4006e64ca7f..607ceef218508 100644 --- a/x-pack/plugins/triggers_actions_ui/public/types.ts +++ b/x-pack/plugins/triggers_actions_ui/public/types.ts @@ -287,6 +287,7 @@ export type PreConfiguredActionConnector = Omit< 'config' | 'secrets' > & { isPreconfigured: true; + isSystemAction: false; }; export type UserConfiguredActionConnector = ActionConnectorProps< @@ -294,10 +295,17 @@ export type UserConfiguredActionConnector = ActionConnectorProp Secrets > & { isPreconfigured: false; + isSystemAction: false; +}; + +export type SystemAction = Omit, 'config' | 'secrets'> & { + isSystemAction: true; + isPreconfigured: false; }; export type ActionConnector, Secrets = Record> = | PreConfiguredActionConnector + | SystemAction | UserConfiguredActionConnector; export type ActionConnectorWithoutId< diff --git a/x-pack/plugins/uptime/public/legacy_uptime/state/api/alerts.ts b/x-pack/plugins/uptime/public/legacy_uptime/state/api/alerts.ts index 9355cea954f98..8c623e914516b 100644 --- a/x-pack/plugins/uptime/public/legacy_uptime/state/api/alerts.ts +++ b/x-pack/plugins/uptime/public/legacy_uptime/state/api/alerts.ts @@ -38,6 +38,7 @@ export const fetchConnectors = async (): Promise => { is_preconfigured: isPreconfigured, is_deprecated: isDeprecated, is_missing_secrets: isMissingSecrets, + is_system_action: isSystemAction, ...res }) => ({ ...res, @@ -46,6 +47,7 @@ export const fetchConnectors = async (): Promise => { isDeprecated, isPreconfigured, isMissingSecrets, + isSystemAction, }) ); };