From d72de0ea163ae4c5b9d454d5c7f91a7e2e835ecb Mon Sep 17 00:00:00 2001 From: Joe Portner <5295965+jportner@users.noreply.github.com> Date: Thu, 16 Apr 2020 14:37:55 -0400 Subject: [PATCH] Refactor saved object types to use `namespaceType` (#63217) Remove `namespaceAgnostic` field that was deprecated in #54605, use `namespaceType` instead. --- ...ana-plugin-core-server.savedobjectstype.md | 1 - ...rver.savedobjectstype.namespaceagnostic.md | 18 -------------- ...e-server.savedobjectstype.namespacetype.md | 2 +- .../server/todo_saved_object.ts | 2 +- .../migrations/core/build_index_map.test.ts | 12 +++++----- .../migrations/core/document_migrator.test.ts | 2 +- .../migrations/kibana/kibana_migrator.mock.ts | 2 +- .../migrations/kibana/kibana_migrator.test.ts | 6 ++--- .../routes/integration_tests/test_utils.ts | 2 +- .../saved_objects_type_registry.test.ts | 24 ------------------- .../saved_objects_type_registry.ts | 9 +++---- .../lib/repository_create_repository.test.ts | 6 ++--- src/core/server/saved_objects/types.ts | 7 +----- src/core/server/saved_objects/utils.test.ts | 14 ----------- src/core/server/saved_objects/utils.ts | 4 ++-- src/core/server/server.api.md | 4 +--- .../ui_settings/saved_objects/ui_settings.ts | 2 +- .../server/saved_objects/index_patterns.ts | 2 +- .../data/server/saved_objects/query.ts | 2 +- .../data/server/saved_objects/search.ts | 2 +- .../server/services/management.test.ts | 2 +- .../application_usage/saved_objects_types.ts | 4 ++-- .../telemetry_ui_metric_collector.ts | 2 +- src/plugins/telemetry/server/plugin.ts | 2 +- .../validation_telemetry/saved_object_type.ts | 2 +- .../server/saved_objects/visualization.ts | 2 +- .../apis/saved_objects/migrations.js | 2 +- .../server/saved_objects/custom_element.ts | 2 +- .../canvas/server/saved_objects/workpad.ts | 2 +- .../case/server/saved_object_types/cases.ts | 2 +- .../server/saved_object_types/comments.ts | 2 +- .../server/saved_object_types/configure.ts | 2 +- .../server/saved_object_types/user_actions.ts | 2 +- .../file_upload/server/telemetry/mappings.ts | 2 +- x-pack/plugins/lens/server/saved_objects.ts | 4 ++-- .../ml/server/lib/telemetry/mappings.ts | 2 +- .../lib/copy_to_spaces/copy_to_spaces.test.ts | 8 +++---- .../resolve_copy_conflicts.test.ts | 8 +++---- x-pack/plugins/spaces/server/plugin.test.ts | 2 +- .../__fixtures__/create_mock_so_service.ts | 12 +++++----- .../saved_objects_service.test.ts | 2 +- .../saved_objects/saved_objects_service.ts | 2 +- .../spaces_saved_objects_client.test.ts | 6 ++--- .../uptime/server/lib/saved_objects.ts | 2 +- .../api_consumer_plugin/server/index.ts | 2 +- .../plugins/event_log/server/plugin.ts | 2 +- 46 files changed, 69 insertions(+), 136 deletions(-) delete mode 100644 docs/development/core/server/kibana-plugin-core-server.savedobjectstype.namespaceagnostic.md diff --git a/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.md b/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.md index d8202545f0eae..a8894286de910 100644 --- a/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.md +++ b/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.md @@ -25,6 +25,5 @@ This is only internal for now, and will only be public when we expose the regist | [mappings](./kibana-plugin-core-server.savedobjectstype.mappings.md) | SavedObjectsTypeMappingDefinition | The [mapping definition](./kibana-plugin-core-server.savedobjectstypemappingdefinition.md) for the type. | | [migrations](./kibana-plugin-core-server.savedobjectstype.migrations.md) | SavedObjectMigrationMap | An optional map of [migrations](./kibana-plugin-core-server.savedobjectmigrationfn.md) to be used to migrate the type. | | [name](./kibana-plugin-core-server.savedobjectstype.name.md) | string | The name of the type, which is also used as the internal id. | -| [namespaceAgnostic](./kibana-plugin-core-server.savedobjectstype.namespaceagnostic.md) | boolean | Is the type global (true), or not (false). | | [namespaceType](./kibana-plugin-core-server.savedobjectstype.namespacetype.md) | SavedObjectsNamespaceType | The [namespace type](./kibana-plugin-core-server.savedobjectsnamespacetype.md) for the type. | diff --git a/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.namespaceagnostic.md b/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.namespaceagnostic.md deleted file mode 100644 index e347421590482..0000000000000 --- a/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.namespaceagnostic.md +++ /dev/null @@ -1,18 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [SavedObjectsType](./kibana-plugin-core-server.savedobjectstype.md) > [namespaceAgnostic](./kibana-plugin-core-server.savedobjectstype.namespaceagnostic.md) - -## SavedObjectsType.namespaceAgnostic property - -> Warning: This API is now obsolete. -> -> Use `namespaceType` instead. -> - -Is the type global (true), or not (false). - -Signature: - -```typescript -namespaceAgnostic?: boolean; -``` diff --git a/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.namespacetype.md b/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.namespacetype.md index 69912f9144980..3a3b0f7f3a9a5 100644 --- a/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.namespacetype.md +++ b/docs/development/core/server/kibana-plugin-core-server.savedobjectstype.namespacetype.md @@ -9,5 +9,5 @@ The [namespace type](./kibana-plugin-core-server.savedobjectsnamespacetype.md) f Signature: ```typescript -namespaceType?: SavedObjectsNamespaceType; +namespaceType: SavedObjectsNamespaceType; ``` diff --git a/examples/embeddable_examples/server/todo_saved_object.ts b/examples/embeddable_examples/server/todo_saved_object.ts index 0f67c53cfa3e1..58da2014de498 100644 --- a/examples/embeddable_examples/server/todo_saved_object.ts +++ b/examples/embeddable_examples/server/todo_saved_object.ts @@ -22,7 +22,7 @@ import { SavedObjectsType } from 'kibana/server'; export const todoSavedObject: SavedObjectsType = { name: 'todo', hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { title: { diff --git a/src/core/server/saved_objects/migrations/core/build_index_map.test.ts b/src/core/server/saved_objects/migrations/core/build_index_map.test.ts index 44add4e977006..2c710d4eaa079 100644 --- a/src/core/server/saved_objects/migrations/core/build_index_map.test.ts +++ b/src/core/server/saved_objects/migrations/core/build_index_map.test.ts @@ -26,7 +26,7 @@ const createRegistry = (...types: Array>) => { types.forEach(type => registry.registerType({ name: 'unknown', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, migrations: {}, @@ -41,7 +41,7 @@ test('mappings without index pattern goes to default index', () => { kibanaIndexName: '.kibana', registry: createRegistry({ name: 'type1', - namespaceAgnostic: false, + namespaceType: 'single', }), indexMap: { type1: { @@ -73,7 +73,7 @@ test(`mappings with custom index pattern doesn't go to default index`, () => { kibanaIndexName: '.kibana', registry: createRegistry({ name: 'type1', - namespaceAgnostic: false, + namespaceType: 'single', indexPattern: '.other_kibana', }), indexMap: { @@ -106,7 +106,7 @@ test('creating a script gets added to the index pattern', () => { kibanaIndexName: '.kibana', registry: createRegistry({ name: 'type1', - namespaceAgnostic: false, + namespaceType: 'single', indexPattern: '.other_kibana', convertToAliasScript: `ctx._id = ctx._source.type + ':' + ctx._id`, }), @@ -141,12 +141,12 @@ test('throws when two scripts are defined for an index pattern', () => { const registry = createRegistry( { name: 'type1', - namespaceAgnostic: false, + namespaceType: 'single', convertToAliasScript: `ctx._id = ctx._source.type + ':' + ctx._id`, }, { name: 'type2', - namespaceAgnostic: false, + namespaceType: 'single', convertToAliasScript: `ctx._id = ctx._source.type + ':' + ctx._id`, } ); diff --git a/src/core/server/saved_objects/migrations/core/document_migrator.test.ts b/src/core/server/saved_objects/migrations/core/document_migrator.test.ts index ef3f546b5e574..64270c677ff20 100644 --- a/src/core/server/saved_objects/migrations/core/document_migrator.test.ts +++ b/src/core/server/saved_objects/migrations/core/document_migrator.test.ts @@ -32,7 +32,7 @@ const createRegistry = (...types: Array>) => { types.forEach(type => registry.registerType({ name: 'unknown', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, migrations: {}, diff --git a/src/core/server/saved_objects/migrations/kibana/kibana_migrator.mock.ts b/src/core/server/saved_objects/migrations/kibana/kibana_migrator.mock.ts index 257b32c1e4c23..3f5c0c3876615 100644 --- a/src/core/server/saved_objects/migrations/kibana/kibana_migrator.mock.ts +++ b/src/core/server/saved_objects/migrations/kibana/kibana_migrator.mock.ts @@ -27,7 +27,7 @@ const defaultSavedObjectTypes: SavedObjectsType[] = [ { name: 'testtype', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: { name: { type: 'keyword' }, diff --git a/src/core/server/saved_objects/migrations/kibana/kibana_migrator.test.ts b/src/core/server/saved_objects/migrations/kibana/kibana_migrator.test.ts index 336eeff99f47b..cda0e86f15bdf 100644 --- a/src/core/server/saved_objects/migrations/kibana/kibana_migrator.test.ts +++ b/src/core/server/saved_objects/migrations/kibana/kibana_migrator.test.ts @@ -28,8 +28,8 @@ const createRegistry = (types: Array>) => { types.forEach(type => registry.registerType({ name: 'unknown', - namespaceAgnostic: false, hidden: false, + namespaceType: 'single', mappings: { properties: {} }, migrations: {}, ...type, @@ -120,7 +120,7 @@ function mockOptions(): KibanaMigratorOptions { { name: 'testtype', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: { name: { type: 'keyword' }, @@ -131,7 +131,7 @@ function mockOptions(): KibanaMigratorOptions { { name: 'testtype2', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', indexPattern: 'other-index', mappings: { properties: { diff --git a/src/core/server/saved_objects/routes/integration_tests/test_utils.ts b/src/core/server/saved_objects/routes/integration_tests/test_utils.ts index 82a889f75d3c1..23e0285201dc7 100644 --- a/src/core/server/saved_objects/routes/integration_tests/test_utils.ts +++ b/src/core/server/saved_objects/routes/integration_tests/test_utils.ts @@ -49,7 +49,7 @@ export const createExportableType = (name: string): SavedObjectsType => { return { name, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: {}, }, diff --git a/src/core/server/saved_objects/saved_objects_type_registry.test.ts b/src/core/server/saved_objects/saved_objects_type_registry.test.ts index 84337474f3ee3..f82822f90f489 100644 --- a/src/core/server/saved_objects/saved_objects_type_registry.test.ts +++ b/src/core/server/saved_objects/saved_objects_type_registry.test.ts @@ -183,14 +183,6 @@ describe('SavedObjectTypeRegistry', () => { expectResult(false, { namespaceType: 'single' }); expectResult(false, { namespaceType: undefined }); }); - - // deprecated test cases - it(`returns true when namespaceAgnostic is true`, () => { - expectResult(true, { namespaceAgnostic: true, namespaceType: 'agnostic' }); - expectResult(true, { namespaceAgnostic: true, namespaceType: 'multiple' }); - expectResult(true, { namespaceAgnostic: true, namespaceType: 'single' }); - expectResult(true, { namespaceAgnostic: true, namespaceType: undefined }); - }); }); describe('#isSingleNamespace', () => { @@ -213,14 +205,6 @@ describe('SavedObjectTypeRegistry', () => { expectResult(false, { namespaceType: 'agnostic' }); expectResult(false, { namespaceType: 'multiple' }); }); - - // deprecated test cases - it(`returns false when namespaceAgnostic is true`, () => { - expectResult(false, { namespaceAgnostic: true, namespaceType: 'agnostic' }); - expectResult(false, { namespaceAgnostic: true, namespaceType: 'multiple' }); - expectResult(false, { namespaceAgnostic: true, namespaceType: 'single' }); - expectResult(false, { namespaceAgnostic: true, namespaceType: undefined }); - }); }); describe('#isMultiNamespace', () => { @@ -243,14 +227,6 @@ describe('SavedObjectTypeRegistry', () => { expectResult(false, { namespaceType: 'single' }); expectResult(false, { namespaceType: undefined }); }); - - // deprecated test cases - it(`returns false when namespaceAgnostic is true`, () => { - expectResult(false, { namespaceAgnostic: true, namespaceType: 'agnostic' }); - expectResult(false, { namespaceAgnostic: true, namespaceType: 'multiple' }); - expectResult(false, { namespaceAgnostic: true, namespaceType: 'single' }); - expectResult(false, { namespaceAgnostic: true, namespaceType: undefined }); - }); }); describe('#isHidden', () => { diff --git a/src/core/server/saved_objects/saved_objects_type_registry.ts b/src/core/server/saved_objects/saved_objects_type_registry.ts index be3fdb86a994c..740313a53d1e2 100644 --- a/src/core/server/saved_objects/saved_objects_type_registry.ts +++ b/src/core/server/saved_objects/saved_objects_type_registry.ts @@ -72,11 +72,7 @@ export class SavedObjectTypeRegistry { * resolves to `false` if the type is not registered */ public isNamespaceAgnostic(type: string) { - return ( - this.types.get(type)?.namespaceType === 'agnostic' || - this.types.get(type)?.namespaceAgnostic || - false - ); + return this.types.get(type)?.namespaceType === 'agnostic'; } /** @@ -84,6 +80,7 @@ export class SavedObjectTypeRegistry { * resolves to `true` if the type is not registered */ public isSingleNamespace(type: string) { + // in the case we somehow registered a type with an invalid `namespaceType`, treat it as single-namespace return !this.isNamespaceAgnostic(type) && !this.isMultiNamespace(type); } @@ -92,7 +89,7 @@ export class SavedObjectTypeRegistry { * resolves to `false` if the type is not registered */ public isMultiNamespace(type: string) { - return !this.isNamespaceAgnostic(type) && this.types.get(type)?.namespaceType === 'multiple'; + return this.types.get(type)?.namespaceType === 'multiple'; } /** diff --git a/src/core/server/saved_objects/service/lib/repository_create_repository.test.ts b/src/core/server/saved_objects/service/lib/repository_create_repository.test.ts index a6b580e9b3461..ea881805e1ae6 100644 --- a/src/core/server/saved_objects/service/lib/repository_create_repository.test.ts +++ b/src/core/server/saved_objects/service/lib/repository_create_repository.test.ts @@ -32,7 +32,7 @@ describe('SavedObjectsRepository#createRepository', () => { typeRegistry.registerType({ name: 'nsAgnosticType', hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { name: { type: 'keyword' }, @@ -44,7 +44,7 @@ describe('SavedObjectsRepository#createRepository', () => { typeRegistry.registerType({ name: 'nsType', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', indexPattern: 'beats', mappings: { properties: { @@ -56,7 +56,7 @@ describe('SavedObjectsRepository#createRepository', () => { typeRegistry.registerType({ name: 'hiddenType', hidden: true, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { name: { type: 'keyword' }, diff --git a/src/core/server/saved_objects/types.ts b/src/core/server/saved_objects/types.ts index 9efc82603b179..b50c6dc9a1abf 100644 --- a/src/core/server/saved_objects/types.ts +++ b/src/core/server/saved_objects/types.ts @@ -202,15 +202,10 @@ export interface SavedObjectsType { * See {@link SavedObjectsServiceStart.createInternalRepository | createInternalRepository}. */ hidden: boolean; - /** - * Is the type global (true), or not (false). - * @deprecated Use `namespaceType` instead. - */ - namespaceAgnostic?: boolean; /** * The {@link SavedObjectsNamespaceType | namespace type} for the type. */ - namespaceType?: SavedObjectsNamespaceType; + namespaceType: SavedObjectsNamespaceType; /** * If defined, the type instances will be stored in the given index instead of the default one. */ diff --git a/src/core/server/saved_objects/utils.test.ts b/src/core/server/saved_objects/utils.test.ts index 64bdf1771decc..033aeea7c018d 100644 --- a/src/core/server/saved_objects/utils.test.ts +++ b/src/core/server/saved_objects/utils.test.ts @@ -421,14 +421,6 @@ describe('convertTypesToLegacySchema', () => { namespaceType: 'multiple', mappings: { properties: {} }, }, - // deprecated test case - { - name: 'typeD', - hidden: false, - namespaceAgnostic: true, - namespaceType: 'multiple', // if namespaceAgnostic and namespaceType are both set, namespaceAgnostic takes precedence - mappings: { properties: {} }, - }, ]; expect(convertTypesToLegacySchema(types)).toEqual({ typeA: { @@ -448,12 +440,6 @@ describe('convertTypesToLegacySchema', () => { isNamespaceAgnostic: false, multiNamespace: true, }, - // deprecated test case - typeD: { - hidden: false, - isNamespaceAgnostic: true, - multiNamespace: false, - }, }); }); }); diff --git a/src/core/server/saved_objects/utils.ts b/src/core/server/saved_objects/utils.ts index 5348963812629..af7c08d1fbfcc 100644 --- a/src/core/server/saved_objects/utils.ts +++ b/src/core/server/saved_objects/utils.ts @@ -82,8 +82,8 @@ export const convertTypesToLegacySchema = ( return { ...schema, [type.name]: { - isNamespaceAgnostic: type.namespaceAgnostic || type.namespaceType === 'agnostic', - multiNamespace: !type.namespaceAgnostic && type.namespaceType === 'multiple', + isNamespaceAgnostic: type.namespaceType === 'agnostic', + multiNamespace: type.namespaceType === 'multiple', hidden: type.hidden, indexPattern: type.indexPattern, convertToAliasScript: type.convertToAliasScript, diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md index e2af94437c9f3..dd08df06c73d2 100644 --- a/src/core/server/server.api.md +++ b/src/core/server/server.api.md @@ -2263,9 +2263,7 @@ export interface SavedObjectsType { mappings: SavedObjectsTypeMappingDefinition; migrations?: SavedObjectMigrationMap; name: string; - // @deprecated - namespaceAgnostic?: boolean; - namespaceType?: SavedObjectsNamespaceType; + namespaceType: SavedObjectsNamespaceType; } // @public diff --git a/src/core/server/ui_settings/saved_objects/ui_settings.ts b/src/core/server/ui_settings/saved_objects/ui_settings.ts index 031315bec0dab..1bea65ddee924 100644 --- a/src/core/server/ui_settings/saved_objects/ui_settings.ts +++ b/src/core/server/ui_settings/saved_objects/ui_settings.ts @@ -22,7 +22,7 @@ import { SavedObjectsType } from '../../saved_objects'; export const uiSettingsType: SavedObjectsType = { name: 'config', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { // we don't want to allow `true` in the public `SavedObjectsTypeMappingDefinition` type, however // this is needed for the config that is kinda a special type. To avoid adding additional internal types diff --git a/src/plugins/data/server/saved_objects/index_patterns.ts b/src/plugins/data/server/saved_objects/index_patterns.ts index 9838071eee5a4..497dbb7d6f630 100644 --- a/src/plugins/data/server/saved_objects/index_patterns.ts +++ b/src/plugins/data/server/saved_objects/index_patterns.ts @@ -23,7 +23,7 @@ import { indexPatternSavedObjectTypeMigrations } from './index_pattern_migration export const indexPatternSavedObjectType: SavedObjectsType = { name: 'index-pattern', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', management: { icon: 'indexPatternApp', defaultSearchField: 'title', diff --git a/src/plugins/data/server/saved_objects/query.ts b/src/plugins/data/server/saved_objects/query.ts index ff0a6cfde8113..015cc7c6cb134 100644 --- a/src/plugins/data/server/saved_objects/query.ts +++ b/src/plugins/data/server/saved_objects/query.ts @@ -22,7 +22,7 @@ import { SavedObjectsType } from 'kibana/server'; export const querySavedObjectType: SavedObjectsType = { name: 'query', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', management: { icon: 'search', defaultSearchField: 'title', diff --git a/src/plugins/data/server/saved_objects/search.ts b/src/plugins/data/server/saved_objects/search.ts index 8b30ff7d08201..54de35a90ae02 100644 --- a/src/plugins/data/server/saved_objects/search.ts +++ b/src/plugins/data/server/saved_objects/search.ts @@ -23,7 +23,7 @@ import { searchSavedObjectTypeMigrations } from './search_migrations'; export const searchSavedObjectType: SavedObjectsType = { name: 'search', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', management: { icon: 'discoverApp', defaultSearchField: 'title', diff --git a/src/plugins/saved_objects_management/server/services/management.test.ts b/src/plugins/saved_objects_management/server/services/management.test.ts index 6b95048749fae..3625a3f913444 100644 --- a/src/plugins/saved_objects_management/server/services/management.test.ts +++ b/src/plugins/saved_objects_management/server/services/management.test.ts @@ -28,7 +28,7 @@ describe('SavedObjectsManagement', () => { registry.registerType({ name: 'unknown', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: {} }, migrations: {}, ...type, diff --git a/src/plugins/telemetry/server/collectors/application_usage/saved_objects_types.ts b/src/plugins/telemetry/server/collectors/application_usage/saved_objects_types.ts index 9f997ab7b5df3..a0de79da565e6 100644 --- a/src/plugins/telemetry/server/collectors/application_usage/saved_objects_types.ts +++ b/src/plugins/telemetry/server/collectors/application_usage/saved_objects_types.ts @@ -33,7 +33,7 @@ export function registerMappings(registerType: SavedObjectsServiceSetup['registe registerType({ name: 'application_usage_totals', hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { appId: { type: 'keyword' }, @@ -46,7 +46,7 @@ export function registerMappings(registerType: SavedObjectsServiceSetup['registe registerType({ name: 'application_usage_transactional', hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { timestamp: { type: 'date' }, diff --git a/src/plugins/telemetry/server/collectors/ui_metric/telemetry_ui_metric_collector.ts b/src/plugins/telemetry/server/collectors/ui_metric/telemetry_ui_metric_collector.ts index 3f6e1836cac7d..603742f612a6b 100644 --- a/src/plugins/telemetry/server/collectors/ui_metric/telemetry_ui_metric_collector.ts +++ b/src/plugins/telemetry/server/collectors/ui_metric/telemetry_ui_metric_collector.ts @@ -38,7 +38,7 @@ export function registerUiMetricUsageCollector( registerType({ name: 'ui-metric', hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { count: { diff --git a/src/plugins/telemetry/server/plugin.ts b/src/plugins/telemetry/server/plugin.ts index 1df6a665e4d76..d1530c272027a 100644 --- a/src/plugins/telemetry/server/plugin.ts +++ b/src/plugins/telemetry/server/plugin.ts @@ -125,7 +125,7 @@ export class TelemetryPlugin implements Plugin { registerType({ name: 'telemetry', hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { enabled: { diff --git a/src/plugins/vis_type_timeseries/server/validation_telemetry/saved_object_type.ts b/src/plugins/vis_type_timeseries/server/validation_telemetry/saved_object_type.ts index 77b49e824334f..f18fa1e4cc2fa 100644 --- a/src/plugins/vis_type_timeseries/server/validation_telemetry/saved_object_type.ts +++ b/src/plugins/vis_type_timeseries/server/validation_telemetry/saved_object_type.ts @@ -31,7 +31,7 @@ const resetCount: SavedObjectMigrationFn = doc => ({ export const tsvbTelemetrySavedObjectType: SavedObjectsType = { name: 'tsvb-validation-telemetry', hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { failedRequests: { diff --git a/src/plugins/visualizations/server/saved_objects/visualization.ts b/src/plugins/visualizations/server/saved_objects/visualization.ts index 9f4782f3ec730..cd2211c185530 100644 --- a/src/plugins/visualizations/server/saved_objects/visualization.ts +++ b/src/plugins/visualizations/server/saved_objects/visualization.ts @@ -23,7 +23,7 @@ import { visualizationSavedObjectTypeMigrations } from './visualization_migratio export const visualizationSavedObjectType: SavedObjectsType = { name: 'visualization', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', management: { icon: 'visualizeApp', defaultSearchField: 'title', diff --git a/test/api_integration/apis/saved_objects/migrations.js b/test/api_integration/apis/saved_objects/migrations.js index bd207ccb41b20..9d908b95ca575 100644 --- a/test/api_integration/apis/saved_objects/migrations.js +++ b/test/api_integration/apis/saved_objects/migrations.js @@ -383,7 +383,7 @@ function migrationsToTypes(migrations) { return Object.entries(migrations).map(([type, migrations]) => ({ name: type, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: {} }, migrations: { ...migrations }, })); diff --git a/x-pack/plugins/canvas/server/saved_objects/custom_element.ts b/x-pack/plugins/canvas/server/saved_objects/custom_element.ts index dadead0263be1..14223455cbc21 100644 --- a/x-pack/plugins/canvas/server/saved_objects/custom_element.ts +++ b/x-pack/plugins/canvas/server/saved_objects/custom_element.ts @@ -10,7 +10,7 @@ import { CUSTOM_ELEMENT_TYPE } from '../../../../legacy/plugins/canvas/common/li export const customElementType: SavedObjectsType = { name: CUSTOM_ELEMENT_TYPE, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { dynamic: false, properties: { diff --git a/x-pack/plugins/canvas/server/saved_objects/workpad.ts b/x-pack/plugins/canvas/server/saved_objects/workpad.ts index e83ba9720b43a..918f4bf991076 100644 --- a/x-pack/plugins/canvas/server/saved_objects/workpad.ts +++ b/x-pack/plugins/canvas/server/saved_objects/workpad.ts @@ -11,7 +11,7 @@ import { removeAttributesId } from './migrations/remove_attributes_id'; export const workpadType: SavedObjectsType = { name: CANVAS_TYPE, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { dynamic: false, properties: { diff --git a/x-pack/plugins/case/server/saved_object_types/cases.ts b/x-pack/plugins/case/server/saved_object_types/cases.ts index a4c5dab0feeb7..cc2b1e74b38c4 100644 --- a/x-pack/plugins/case/server/saved_object_types/cases.ts +++ b/x-pack/plugins/case/server/saved_object_types/cases.ts @@ -11,7 +11,7 @@ export const CASE_SAVED_OBJECT = 'cases'; export const caseSavedObjectType: SavedObjectsType = { name: CASE_SAVED_OBJECT, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: { closed_at: { diff --git a/x-pack/plugins/case/server/saved_object_types/comments.ts b/x-pack/plugins/case/server/saved_object_types/comments.ts index 73b1852bafe58..8b69f272d5b0d 100644 --- a/x-pack/plugins/case/server/saved_object_types/comments.ts +++ b/x-pack/plugins/case/server/saved_object_types/comments.ts @@ -11,7 +11,7 @@ export const CASE_COMMENT_SAVED_OBJECT = 'cases-comments'; export const caseCommentSavedObjectType: SavedObjectsType = { name: CASE_COMMENT_SAVED_OBJECT, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: { comment: { diff --git a/x-pack/plugins/case/server/saved_object_types/configure.ts b/x-pack/plugins/case/server/saved_object_types/configure.ts index d66c38b6ea8ff..d6bc3c9f2e227 100644 --- a/x-pack/plugins/case/server/saved_object_types/configure.ts +++ b/x-pack/plugins/case/server/saved_object_types/configure.ts @@ -11,7 +11,7 @@ export const CASE_CONFIGURE_SAVED_OBJECT = 'cases-configure'; export const caseConfigureSavedObjectType: SavedObjectsType = { name: CASE_CONFIGURE_SAVED_OBJECT, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: { created_at: { diff --git a/x-pack/plugins/case/server/saved_object_types/user_actions.ts b/x-pack/plugins/case/server/saved_object_types/user_actions.ts index b61bfafc3b33c..826c6907efea6 100644 --- a/x-pack/plugins/case/server/saved_object_types/user_actions.ts +++ b/x-pack/plugins/case/server/saved_object_types/user_actions.ts @@ -11,7 +11,7 @@ export const CASE_USER_ACTION_SAVED_OBJECT = 'cases-user-actions'; export const caseUserActionSavedObjectType: SavedObjectsType = { name: CASE_USER_ACTION_SAVED_OBJECT, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: { action_field: { diff --git a/x-pack/plugins/file_upload/server/telemetry/mappings.ts b/x-pack/plugins/file_upload/server/telemetry/mappings.ts index ca935fea3449a..97a5ed9eeef82 100644 --- a/x-pack/plugins/file_upload/server/telemetry/mappings.ts +++ b/x-pack/plugins/file_upload/server/telemetry/mappings.ts @@ -10,7 +10,7 @@ import { TELEMETRY_DOC_ID } from './telemetry'; export const fileUploadTelemetryMappingsType: SavedObjectsType = { name: TELEMETRY_DOC_ID, hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { filesUploadedTotalCount: { diff --git a/x-pack/plugins/lens/server/saved_objects.ts b/x-pack/plugins/lens/server/saved_objects.ts index b2eb325c09266..ac80eb098e780 100644 --- a/x-pack/plugins/lens/server/saved_objects.ts +++ b/x-pack/plugins/lens/server/saved_objects.ts @@ -12,7 +12,7 @@ export function setupSavedObjects(core: CoreSetup) { core.savedObjects.registerType({ name: 'lens', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', management: { icon: 'lensApp', defaultSearchField: 'title', @@ -46,7 +46,7 @@ export function setupSavedObjects(core: CoreSetup) { core.savedObjects.registerType({ name: 'lens-ui-telemetry', hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: { name: { diff --git a/x-pack/plugins/ml/server/lib/telemetry/mappings.ts b/x-pack/plugins/ml/server/lib/telemetry/mappings.ts index 87e2243328422..5aaf9f8c79dc0 100644 --- a/x-pack/plugins/ml/server/lib/telemetry/mappings.ts +++ b/x-pack/plugins/ml/server/lib/telemetry/mappings.ts @@ -10,7 +10,7 @@ import { TELEMETRY_DOC_ID } from './telemetry'; export const mlTelemetryMappingsType: SavedObjectsType = { name: TELEMETRY_DOC_ID, hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: { file_data_visualizer: { diff --git a/x-pack/plugins/spaces/server/lib/copy_to_spaces/copy_to_spaces.test.ts b/x-pack/plugins/spaces/server/lib/copy_to_spaces/copy_to_spaces.test.ts index 72faab0d2c892..d842f07cdb205 100644 --- a/x-pack/plugins/spaces/server/lib/copy_to_spaces/copy_to_spaces.test.ts +++ b/x-pack/plugins/spaces/server/lib/copy_to_spaces/copy_to_spaces.test.ts @@ -57,26 +57,26 @@ describe('copySavedObjectsToSpaces', () => { typeRegistry.getAllTypes.mockReturnValue([ { name: 'dashboard', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, }, { name: 'visualization', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, }, { name: 'globaltype', - namespaceAgnostic: true, + namespaceType: 'agnostic', hidden: false, mappings: { properties: {} }, }, ]); typeRegistry.isNamespaceAgnostic.mockImplementation((type: string) => - typeRegistry.getAllTypes().some(t => t.name === type && t.namespaceAgnostic) + typeRegistry.getAllTypes().some(t => t.name === type && t.namespaceType === 'agnostic') ); coreStart.savedObjects.getTypeRegistry.mockReturnValue(typeRegistry); diff --git a/x-pack/plugins/spaces/server/lib/copy_to_spaces/resolve_copy_conflicts.test.ts b/x-pack/plugins/spaces/server/lib/copy_to_spaces/resolve_copy_conflicts.test.ts index aa1d5e9a47832..0654712ecff0e 100644 --- a/x-pack/plugins/spaces/server/lib/copy_to_spaces/resolve_copy_conflicts.test.ts +++ b/x-pack/plugins/spaces/server/lib/copy_to_spaces/resolve_copy_conflicts.test.ts @@ -57,26 +57,26 @@ describe('resolveCopySavedObjectsToSpacesConflicts', () => { typeRegistry.getAllTypes.mockReturnValue([ { name: 'dashboard', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, }, { name: 'visualization', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, }, { name: 'globaltype', - namespaceAgnostic: true, + namespaceType: 'agnostic', hidden: false, mappings: { properties: {} }, }, ]); typeRegistry.isNamespaceAgnostic.mockImplementation((type: string) => - typeRegistry.getAllTypes().some(t => t.name === type && t.namespaceAgnostic) + typeRegistry.getAllTypes().some(t => t.name === type && t.namespaceType === 'agnostic') ); coreStart.savedObjects.getTypeRegistry.mockReturnValue(typeRegistry); diff --git a/x-pack/plugins/spaces/server/plugin.test.ts b/x-pack/plugins/spaces/server/plugin.test.ts index 0b9905d5e9c95..75ddee772b168 100644 --- a/x-pack/plugins/spaces/server/plugin.test.ts +++ b/x-pack/plugins/spaces/server/plugin.test.ts @@ -81,7 +81,7 @@ describe('Spaces Plugin', () => { expect(core.savedObjects.registerType).toHaveBeenCalledWith({ name: 'space', - namespaceAgnostic: true, + namespaceType: 'agnostic', hidden: true, mappings: expect.any(Object), migrations: expect.any(Object), diff --git a/x-pack/plugins/spaces/server/routes/api/__fixtures__/create_mock_so_service.ts b/x-pack/plugins/spaces/server/routes/api/__fixtures__/create_mock_so_service.ts index d8c318369834e..cbe832e485d66 100644 --- a/x-pack/plugins/spaces/server/routes/api/__fixtures__/create_mock_so_service.ts +++ b/x-pack/plugins/spaces/server/routes/api/__fixtures__/create_mock_so_service.ts @@ -46,37 +46,37 @@ export const createMockSavedObjectsService = (spaces: any[] = []) => { typeRegistry.getAllTypes.mockReturnValue([ { name: 'visualization', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, }, { name: 'dashboard', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, }, { name: 'index-pattern', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, }, { name: 'globalType', - namespaceAgnostic: true, + namespaceType: 'agnostic', hidden: false, mappings: { properties: {} }, }, { name: 'space', - namespaceAgnostic: true, + namespaceType: 'agnostic', hidden: true, mappings: { properties: {} }, }, ]); typeRegistry.isNamespaceAgnostic.mockImplementation((type: string) => - typeRegistry.getAllTypes().some(t => t.name === type && t.namespaceAgnostic) + typeRegistry.getAllTypes().some(t => t.name === type && t.namespaceType === 'agnostic') ); savedObjects.getTypeRegistry.mockReturnValue(typeRegistry); diff --git a/x-pack/plugins/spaces/server/saved_objects/saved_objects_service.test.ts b/x-pack/plugins/spaces/server/saved_objects/saved_objects_service.test.ts index 4a9756d9e03f8..31f2c98d74c96 100644 --- a/x-pack/plugins/spaces/server/saved_objects/saved_objects_service.test.ts +++ b/x-pack/plugins/spaces/server/saved_objects/saved_objects_service.test.ts @@ -58,7 +58,7 @@ describe('SpacesSavedObjectsService', () => { "6.6.0": [Function], }, "name": "space", - "namespaceAgnostic": true, + "namespaceType": "agnostic", }, ] `); diff --git a/x-pack/plugins/spaces/server/saved_objects/saved_objects_service.ts b/x-pack/plugins/spaces/server/saved_objects/saved_objects_service.ts index 40ea49573e3c1..58aa1fe08558a 100644 --- a/x-pack/plugins/spaces/server/saved_objects/saved_objects_service.ts +++ b/x-pack/plugins/spaces/server/saved_objects/saved_objects_service.ts @@ -20,7 +20,7 @@ export class SpacesSavedObjectsService { core.savedObjects.registerType({ name: 'space', hidden: true, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: SpacesSavedObjectMappings, migrations: { '6.6.0': migrateToKibana660, diff --git a/x-pack/plugins/spaces/server/saved_objects/spaces_saved_objects_client.test.ts b/x-pack/plugins/spaces/server/saved_objects/spaces_saved_objects_client.test.ts index f9961329c088b..569219a0b8990 100644 --- a/x-pack/plugins/spaces/server/saved_objects/spaces_saved_objects_client.test.ts +++ b/x-pack/plugins/spaces/server/saved_objects/spaces_saved_objects_client.test.ts @@ -13,21 +13,21 @@ import { SavedObjectTypeRegistry } from 'src/core/server'; const typeRegistry = new SavedObjectTypeRegistry(); typeRegistry.registerType({ name: 'foo', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, }); typeRegistry.registerType({ name: 'bar', - namespaceAgnostic: false, + namespaceType: 'single', hidden: false, mappings: { properties: {} }, }); typeRegistry.registerType({ name: 'space', - namespaceAgnostic: true, + namespaceType: 'agnostic', hidden: true, mappings: { properties: {} }, }); diff --git a/x-pack/plugins/uptime/server/lib/saved_objects.ts b/x-pack/plugins/uptime/server/lib/saved_objects.ts index 175634ef797cc..01004ad7c6424 100644 --- a/x-pack/plugins/uptime/server/lib/saved_objects.ts +++ b/x-pack/plugins/uptime/server/lib/saved_objects.ts @@ -26,7 +26,7 @@ export const settingsObjectId = 'uptime-dynamic-settings-singleton'; export const umDynamicSettings: SavedObjectsType = { name: settingsObjectType, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: { properties: { heartbeatIndices: { diff --git a/x-pack/test/encrypted_saved_objects_api_integration/fixtures/api_consumer_plugin/server/index.ts b/x-pack/test/encrypted_saved_objects_api_integration/fixtures/api_consumer_plugin/server/index.ts index 170b7e0c6d09d..1a01cf8929c05 100644 --- a/x-pack/test/encrypted_saved_objects_api_integration/fixtures/api_consumer_plugin/server/index.ts +++ b/x-pack/test/encrypted_saved_objects_api_integration/fixtures/api_consumer_plugin/server/index.ts @@ -29,7 +29,7 @@ export const plugin: PluginInitializer = core.savedObjects.registerType({ name: SAVED_OBJECT_WITH_SECRET_TYPE, hidden: false, - namespaceAgnostic: false, + namespaceType: 'single', mappings: deepFreeze({ properties: { publicProperty: { type: 'keyword' }, diff --git a/x-pack/test/plugin_api_integration/plugins/event_log/server/plugin.ts b/x-pack/test/plugin_api_integration/plugins/event_log/server/plugin.ts index eccbd4fb7f90b..1b6db3a9a31b4 100644 --- a/x-pack/test/plugin_api_integration/plugins/event_log/server/plugin.ts +++ b/x-pack/test/plugin_api_integration/plugins/event_log/server/plugin.ts @@ -50,7 +50,7 @@ export class EventLogFixturePlugin core.savedObjects.registerType({ name: 'event_log_test', hidden: false, - namespaceAgnostic: true, + namespaceType: 'agnostic', mappings: { properties: {}, },