forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow savedObjects types registration from NP (elastic#57430) (elasti…
…c#58602) * expose `registerType` API * expose `getTypeRegistry` API * change SavedObjectMigrationFn signature to add context * fix exported types * update generated doc * update migration documentation * fix legacy service test * fix typings * update service setup description * add saved_objects server folder convention * fix unit test * documentation NITs * add typeRegistry to SavedObjectClientWrapperOptions
- Loading branch information
1 parent
2ebec21
commit b4009fc
Showing
45 changed files
with
848 additions
and
80 deletions.
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
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
11 changes: 11 additions & 0 deletions
11
...re/server/kibana-plugin-server.savedobjectsclientwrapperoptions.typeregistry.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,11 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsClientWrapperOptions](./kibana-plugin-server.savedobjectsclientwrapperoptions.md) > [typeRegistry](./kibana-plugin-server.savedobjectsclientwrapperoptions.typeregistry.md) | ||
|
||
## SavedObjectsClientWrapperOptions.typeRegistry property | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
typeRegistry: ISavedObjectTypeRegistry; | ||
``` |
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/my_type.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); | ||
} | ||
} | ||
|
||
``` | ||
|
Oops, something went wrong.