-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use NP saved objects service for type and wrapper registration
- Loading branch information
Showing
20 changed files
with
179 additions
and
166 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
13 changes: 13 additions & 0 deletions
13
docs/development/core/server/kibana-plugin-server.savedobjectunsanitizeddoc.md
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,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectUnsanitizedDoc](./kibana-plugin-server.savedobjectunsanitizeddoc.md) | ||
|
||
## SavedObjectUnsanitizedDoc type | ||
|
||
We want to have two types, one that guarantees a "references" attribute will exist and one that allows it to be null. Since we're not migrating all the saved objects to have a "references" array, we need to support the scenarios where it may be missing (ex migrations). | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export declare type SavedObjectUnsanitizedDoc = SavedObjectDoc & Partial<Referencable>; | ||
``` |
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 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 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.
12 changes: 0 additions & 12 deletions
12
x-pack/legacy/plugins/spaces/server/lib/migrations/migrate_6x.ts
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
x-pack/plugins/spaces/server/lib/migrations/migrate_6x.test.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
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 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,38 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export const SpacesSavedObjectMappings = Object.freeze({ | ||
properties: { | ||
name: { | ||
type: 'text', | ||
fields: { | ||
keyword: { | ||
type: 'keyword', | ||
ignore_above: 2048, | ||
}, | ||
}, | ||
}, | ||
description: { | ||
type: 'text', | ||
}, | ||
initials: { | ||
type: 'keyword', | ||
}, | ||
color: { | ||
type: 'keyword', | ||
}, | ||
disabledFeatures: { | ||
type: 'keyword', | ||
}, | ||
imageUrl: { | ||
type: 'text', | ||
index: false, | ||
}, | ||
_reserved: { | ||
type: 'boolean', | ||
}, | ||
}, | ||
}); |
File renamed without changes.
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
15 changes: 15 additions & 0 deletions
15
x-pack/plugins/spaces/server/saved_objects/migrations/migrate_6x.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,15 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { SavedObjectUnsanitizedDoc } from 'src/core/server'; | ||
|
||
export function migrateToKibana660(doc: SavedObjectUnsanitizedDoc) { | ||
const attributes = doc.attributes as Record<string, any>; | ||
if (!attributes.hasOwnProperty('disabledFeatures')) { | ||
attributes.disabledFeatures = []; | ||
} | ||
return doc; | ||
} |
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
36 changes: 36 additions & 0 deletions
36
x-pack/plugins/spaces/server/saved_objects/saved_objects_service.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,36 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { CoreSetup } from 'src/core/server'; | ||
import { SpacesSavedObjectMappings } from './mappings'; | ||
import { migrateToKibana660 } from './migrations'; | ||
import { spacesSavedObjectsClientWrapperFactory } from './saved_objects_client_wrapper_factory'; | ||
import { SpacesServiceSetup } from '../spaces_service'; | ||
|
||
interface SetupDeps { | ||
core: Pick<CoreSetup, 'savedObjects' | 'getStartServices'>; | ||
spacesService: SpacesServiceSetup; | ||
} | ||
|
||
export class SpacesSavedObjectsService { | ||
public setup({ core, spacesService }: SetupDeps) { | ||
core.savedObjects.registerType({ | ||
name: 'space', | ||
hidden: true, | ||
namespaceAgnostic: true, | ||
mappings: SpacesSavedObjectMappings, | ||
migrations: { | ||
'6.6.0': migrateToKibana660, | ||
}, | ||
}); | ||
|
||
core.savedObjects.addClientWrapper( | ||
Number.MIN_SAFE_INTEGER, | ||
'spaces', | ||
spacesSavedObjectsClientWrapperFactory(spacesService) | ||
); | ||
} | ||
} |
Oops, something went wrong.