-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow savedObjects types registration from NP #57430
Merged
pgayvallet
merged 20 commits into
elastic:master
from
pgayvallet:kbn-503xx-expose-register-type-so-api
Feb 26, 2020
Merged
Changes from 16 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
af5ac5e
expose `registerType` API
pgayvallet 97f8c1e
expose `getTypeRegistry` API
pgayvallet cbf73b3
change SavedObjectMigrationFn signature to add context
pgayvallet b5ad014
fix exported types
pgayvallet 3b8cd43
update generated doc
pgayvallet 9e7aa96
update migration documentation
pgayvallet af8c10d
Merge remote-tracking branch 'upstream/master' into kbn-503xx-expose-…
pgayvallet d3937c7
fix legacy service test
pgayvallet 76f0dd4
Merge remote-tracking branch 'upstream/master' into kbn-503xx-expose-…
pgayvallet 1989e89
Merge remote-tracking branch 'upstream/master' into kbn-503xx-expose-…
pgayvallet d2f1016
fix typings
pgayvallet 6857054
update service setup description
pgayvallet 9422f06
Merge remote-tracking branch 'upstream/master' into kbn-503xx-expose-…
pgayvallet e408a9c
add saved_objects server folder convention
pgayvallet c3efbb1
fix unit test
pgayvallet 15e7646
Merge remote-tracking branch 'upstream/master' into kbn-503xx-expose-…
pgayvallet 9c93b40
Merge remote-tracking branch 'upstream/master' into kbn-503xx-expose-…
pgayvallet 6c8a015
documentation NITs
pgayvallet 18f5c05
add typeRegistry to SavedObjectClientWrapperOptions
pgayvallet 7d1475f
Merge remote-tracking branch 'upstream/master' into kbn-503xx-expose-…
pgayvallet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
docs/development/core/server/kibana-plugin-server.isavedobjecttyperegistry.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) > [ISavedObjectTypeRegistry](./kibana-plugin-server.isavedobjecttyperegistry.md) | ||
|
||
## ISavedObjectTypeRegistry type | ||
|
||
See [SavedObjectTypeRegistry](./kibana-plugin-server.savedobjecttyperegistry.md) for documentation. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export declare type ISavedObjectTypeRegistry = Pick<SavedObjectTypeRegistry, 'getType' | 'getAllTypes' | 'getIndex' | 'isNamespaceAgnostic' | 'isHidden'>; | ||
``` |
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
...development/core/server/kibana-plugin-server.savedobjectmigrationcontext.log.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) > [SavedObjectMigrationContext](./kibana-plugin-server.savedobjectmigrationcontext.md) > [log](./kibana-plugin-server.savedobjectmigrationcontext.log.md) | ||
|
||
## SavedObjectMigrationContext.log property | ||
|
||
logger instance to be used by the migration handler | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
log: SavedObjectsMigrationLogger; | ||
``` |
20 changes: 20 additions & 0 deletions
20
docs/development/core/server/kibana-plugin-server.savedobjectmigrationcontext.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,20 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectMigrationContext](./kibana-plugin-server.savedobjectmigrationcontext.md) | ||
|
||
## SavedObjectMigrationContext interface | ||
|
||
Migration context provided when invoking a [migration handler](./kibana-plugin-server.savedobjectmigrationfn.md) | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export interface SavedObjectMigrationContext | ||
``` | ||
|
||
## Properties | ||
|
||
| Property | Type | Description | | ||
| --- | --- | --- | | ||
| [log](./kibana-plugin-server.savedobjectmigrationcontext.log.md) | <code>SavedObjectsMigrationLogger</code> | logger instance to be used by the migration handler | | ||
|
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 | ||||
---|---|---|---|---|---|---|
|
@@ -4,10 +4,26 @@ | |||||
|
||||||
## SavedObjectMigrationFn type | ||||||
|
||||||
A migration function defined for a [saved objects type](./kibana-plugin-server.savedobjectstype.md) used to migrate it's | ||||||
A migration function defined for a [saved objects type](./kibana-plugin-server.savedobjectstype.md) used to migrate it's to a given version | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
|
||||||
|
||||||
<b>Signature:</b> | ||||||
|
||||||
```typescript | ||||||
export declare type SavedObjectMigrationFn = (doc: SavedObjectUnsanitizedDoc, log: SavedObjectsMigrationLogger) => SavedObjectUnsanitizedDoc; | ||||||
export declare type SavedObjectMigrationFn = (doc: SavedObjectUnsanitizedDoc, context: SavedObjectMigrationContext) => SavedObjectUnsanitizedDoc; | ||||||
``` | ||||||
|
||||||
## Example | ||||||
|
||||||
|
||||||
```typescript | ||||||
const migrateProperty: SavedObjectMigrationFn = (doc, { log }) => { | ||||||
try { | ||||||
doc.attributes.someProp = migrateProperty(doc.attributes.someProp); | ||||||
} catch(e) { | ||||||
log.warn('Error migrating `someProp`'); | ||||||
} | ||||||
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
60 changes: 60 additions & 0 deletions
60
...pment/core/server/kibana-plugin-server.savedobjectsservicesetup.registertype.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,60 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) > [registerType](./kibana-plugin-server.savedobjectsservicesetup.registertype.md) | ||
|
||
## SavedObjectsServiceSetup.registerType property | ||
|
||
Register a [savedObjects type](./kibana-plugin-server.savedobjectstype.md) definition. | ||
|
||
See the [mappings format](./kibana-plugin-server.savedobjectstypemappingdefinition.md) and [migration format](./kibana-plugin-server.savedobjectmigrationmap.md) for more details about these. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
registerType: (type: SavedObjectsType) => void; | ||
``` | ||
|
||
## Remarks | ||
|
||
The type definition is an aggregation of the legacy savedObjects `schema`<!-- -->, `mappings` and `migration` concepts. This API is the single entry point to register saved object types in the new platform. | ||
|
||
## Example | ||
|
||
|
||
```ts | ||
// src/plugins/my_plugin/server/saved_objects/types.ts | ||
import { SavedObjectsType } from 'src/core/server'; | ||
import * as migrations from './migrations'; | ||
|
||
export const myType: SavedObjectsType = { | ||
name: 'MyType', | ||
hidden: false, | ||
namespaceAgnostic: true, | ||
mappings: { | ||
properties: { | ||
textField: { | ||
type: 'text', | ||
}, | ||
boolField: { | ||
type: 'boolean', | ||
}, | ||
}, | ||
}, | ||
migrations: { | ||
'2.0.0': migrations.migrateToV2, | ||
'2.1.0': migrations.migrateToV2_1 | ||
}, | ||
}; | ||
|
||
// src/plugins/my_plugin/server/plugin.ts | ||
import { SavedObjectsClient, CoreSetup } from 'src/core/server'; | ||
import { myType } from './saved_objects'; | ||
|
||
export class Plugin() { | ||
setup: (core: CoreSetup) => { | ||
core.savedObjects.registerType(myType); | ||
} | ||
} | ||
|
||
``` | ||
|
13 changes: 13 additions & 0 deletions
13
...nt/core/server/kibana-plugin-server.savedobjectsservicestart.gettyperegistry.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) > [SavedObjectsServiceStart](./kibana-plugin-server.savedobjectsservicestart.md) > [getTypeRegistry](./kibana-plugin-server.savedobjectsservicestart.gettyperegistry.md) | ||
|
||
## SavedObjectsServiceStart.getTypeRegistry property | ||
|
||
Returns the [registry](./kibana-plugin-server.isavedobjecttyperegistry.md) containing all registered [savedObject types](./kibana-plugin-server.savedobjectstype.md) | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
getTypeRegistry: () => ISavedObjectTypeRegistry; | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.