import type { Logger , SavedObject , SavedObjectsExportTransformContext , SavedObjectsServiceSetup , SavedObjectsTypeMappingDefinition , } from 'kibana/server' ; import mappings from './mappings.json' ; import { getMigrations } from './migrations' ; import { EncryptedSavedObjectsPluginSetup } from '../../../encrypted_saved_objects/server' ; import { transformRulesForExport } from './transform_rule_for_export' ; import { RawRule } from '../types' ; import { getImportWarnings } from './get_import_warnings' ; import { isRuleExportable } from './is_rule_exportable' ; import { RuleTypeRegistry } from '../rule_type_registry' ; export { partiallyUpdateAlert } from './partially_update_alert' ; export const AlertAttributesExcludedFromAAD = [ 'scheduledTaskId' , 'muteAll' , 'mutedInstanceIds' , 'updatedBy' , 'updatedAt' , 'executionStatus' , ] ; export type AlertAttributesExcludedFromAADType = 'scheduledTaskId' | 'muteAll' | 'mutedInstanceIds' | 'updatedBy' | 'updatedAt' | 'executionStatus' ; export function setupSavedObjects ( savedObjects , encryptedSavedObjects , ruleTypeRegistry , logger , isPreconfigured ) { savedObjects . registerType ( { name : 'alert' , hidden : true , namespaceType : 'multiple-isolated' , convertToMultiNamespaceTypeVersion : '8.0.0' , migrations : getMigrations ( encryptedSavedObjects , isPreconfigured ) , mappings : mappings . alert as SavedObjectsTypeMappingDefinition , management : { displayName : 'rule' , importableAndExportable : true , getTitle ( ruleSavedObject ) { return `Rule: [${ ruleSavedObject . attributes . name }]` ; } , onImport ( ruleSavedObjects ) { return { warnings : getImportWarnings ( ruleSavedObjects ) , } ; } , onExport < RawRule > ( context , objects ) { return transformRulesForExport ( objects ) ; } , isExportable < RawRule > ( ruleSavedObject ) { return isRuleExportable ( ruleSavedObject , ruleTypeRegistry , logger ) ; } , } , } ) ; savedObjects . registerType ( { name : 'api_key_pending_invalidation' , hidden : true , namespaceType : 'agnostic' , mappings : { properties : { apiKeyId : { type : 'keyword' , } , createdAt : { type : 'date' , } , } , } , } ) ; encryptedSavedObjects . registerType ( { type : 'alert' , attributesToEncrypt : new Set ( [ 'apiKey' ] ) , attributesToExcludeFromAAD : new Set ( AlertAttributesExcludedFromAAD ) , } ) ; encryptedSavedObjects . registerType ( { type : 'api_key_pending_invalidation' , attributesToEncrypt : new Set ( [ 'apiKeyId' ] ) , } ) ; }