Skip to content
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

Add savedObjects mappings API to core #55825

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
234 changes: 234 additions & 0 deletions docs/development/core/server/kibana-plugin-server.md

Large diffs are not rendered by default.

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) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsComplexFieldMapping](./kibana-plugin-server.savedobjectscomplexfieldmapping.md) &gt; [dynamic](./kibana-plugin-server.savedobjectscomplexfieldmapping.dynamic.md)

## SavedObjectsComplexFieldMapping.dynamic property

<b>Signature:</b>

```typescript
dynamic?: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsComplexFieldMapping](./kibana-plugin-server.savedobjectscomplexfieldmapping.md)

## SavedObjectsComplexFieldMapping interface


<b>Signature:</b>

```typescript
export interface SavedObjectsComplexFieldMapping
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [dynamic](./kibana-plugin-server.savedobjectscomplexfieldmapping.dynamic.md) | <code>string</code> | |
| [properties](./kibana-plugin-server.savedobjectscomplexfieldmapping.properties.md) | <code>SavedObjectsMappingProperties</code> | |
| [type](./kibana-plugin-server.savedobjectscomplexfieldmapping.type.md) | <code>string</code> | |

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) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsComplexFieldMapping](./kibana-plugin-server.savedobjectscomplexfieldmapping.md) &gt; [properties](./kibana-plugin-server.savedobjectscomplexfieldmapping.properties.md)

## SavedObjectsComplexFieldMapping.properties property

<b>Signature:</b>

```typescript
properties: SavedObjectsMappingProperties;
```
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) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsComplexFieldMapping](./kibana-plugin-server.savedobjectscomplexfieldmapping.md) &gt; [type](./kibana-plugin-server.savedobjectscomplexfieldmapping.type.md)

## SavedObjectsComplexFieldMapping.type property

<b>Signature:</b>

```typescript
type?: string;
```
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) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsCoreFieldMapping](./kibana-plugin-server.savedobjectscorefieldmapping.md) &gt; [enabled](./kibana-plugin-server.savedobjectscorefieldmapping.enabled.md)

## SavedObjectsCoreFieldMapping.enabled property

<b>Signature:</b>

```typescript
enabled?: boolean;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsCoreFieldMapping](./kibana-plugin-server.savedobjectscorefieldmapping.md) &gt; [fields](./kibana-plugin-server.savedobjectscorefieldmapping.fields.md)

## SavedObjectsCoreFieldMapping.fields property

<b>Signature:</b>

```typescript
fields?: {
[subfield: string]: {
type: string;
};
};
```
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) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsCoreFieldMapping](./kibana-plugin-server.savedobjectscorefieldmapping.md) &gt; [index](./kibana-plugin-server.savedobjectscorefieldmapping.index.md)

## SavedObjectsCoreFieldMapping.index property

<b>Signature:</b>

```typescript
index?: boolean;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsCoreFieldMapping](./kibana-plugin-server.savedobjectscorefieldmapping.md)

## SavedObjectsCoreFieldMapping interface


<b>Signature:</b>

```typescript
export interface SavedObjectsCoreFieldMapping
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [enabled](./kibana-plugin-server.savedobjectscorefieldmapping.enabled.md) | <code>boolean</code> | |
| [fields](./kibana-plugin-server.savedobjectscorefieldmapping.fields.md) | <code>{</code><br/><code> [subfield: string]: {</code><br/><code> type: string;</code><br/><code> };</code><br/><code> }</code> | |
| [index](./kibana-plugin-server.savedobjectscorefieldmapping.index.md) | <code>boolean</code> | |
| [type](./kibana-plugin-server.savedobjectscorefieldmapping.type.md) | <code>string</code> | |

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) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsCoreFieldMapping](./kibana-plugin-server.savedobjectscorefieldmapping.md) &gt; [type](./kibana-plugin-server.savedobjectscorefieldmapping.type.md)

## SavedObjectsCoreFieldMapping.type property

<b>Signature:</b>

```typescript
type: string;
```
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) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsFieldMapping](./kibana-plugin-server.savedobjectsfieldmapping.md)

## SavedObjectsFieldMapping type

Describe a [saved object type mapping](./kibana-plugin-server.savedobjectstypemappingdefinition.md) field.

<b>Signature:</b>

```typescript
export declare type SavedObjectsFieldMapping = SavedObjectsCoreFieldMapping | SavedObjectsComplexFieldMapping;
```
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) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsMappingProperties](./kibana-plugin-server.savedobjectsmappingproperties.md)

## SavedObjectsMappingProperties interface

Describe the fields of a [saved object type](./kibana-plugin-server.savedobjectstypemappingdefinition.md)<!-- -->.

<b>Signature:</b>

```typescript
export interface SavedObjectsMappingProperties
```
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,25 @@ When plugins access the Saved Objects client, a new client is created using the

## Example


```ts
import { SavedObjectsClient, CoreSetup } from 'src/core/server';

export class Plugin() { setup: (core: CoreSetup) =<!-- -->&gt; { core.savedObjects.setClientFactory((<!-- -->{ request: KibanaRequest }<!-- -->) =<!-- -->&gt; { return new SavedObjectsClient(core.savedObjects.scopedRepository(request)); }<!-- -->) } }
export class Plugin() {
setup: (core: CoreSetup) => {
core.savedObjects.setClientFactory(({ request: KibanaRequest }) => {
return new SavedObjectsClient(core.savedObjects.scopedRepository(request));
})
}
}

```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [addClientWrapper](./kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md) | <code>(priority: number, id: string, factory: SavedObjectsClientWrapperFactory) =&gt; void</code> | Add a [client wrapper factory](./kibana-plugin-server.savedobjectsclientwrapperfactory.md) with the given priority. |
| [registerMappings](./kibana-plugin-server.savedobjectsservicesetup.registermappings.md) | <code>(mappings: SavedObjectsTypeMappingDefinitions) =&gt; void</code> | Register [saved object type mappings](./kibana-plugin-server.savedobjectstypemappingdefinitions.md) |
| [setClientFactoryProvider](./kibana-plugin-server.savedobjectsservicesetup.setclientfactoryprovider.md) | <code>(clientFactoryProvider: SavedObjectsClientFactoryProvider) =&gt; void</code> | Set the default [factory provider](./kibana-plugin-server.savedobjectsclientfactoryprovider.md) for creating Saved Objects clients. Only one provider can be set, subsequent calls to this method will fail. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) &gt; [registerMappings](./kibana-plugin-server.savedobjectsservicesetup.registermappings.md)

## SavedObjectsServiceSetup.registerMappings property

Register [saved object type mappings](./kibana-plugin-server.savedobjectstypemappingdefinitions.md)

<b>Signature:</b>

```typescript
registerMappings: (mappings: SavedObjectsTypeMappingDefinitions) => void;
```

## Remarks

It's possible to directly use an imported json mappings file to call this API. However, as typescript ensure type validation of the mappings, it's strongly encouraged to use a typescript definition instead.

## Example


```ts
// my-plugin/server/mappings.ts
import { SavedObjectsTypeMappingDefinitions } from 'src/core/server';

export const mappings: SavedObjectsTypeMappingDefinitions = {
'my-type': {
properties: {
afield: {
type: "text"
}
}
}
}

```

```ts
// my-plugin/server/plugin.ts
import { mappings } from './mappings';

export class MyPlugin implements Plugin {
setup({ savedObjects }) {
savedObjects.registerMappings(mappings);
}
}

```

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsTypeMappingDefinition](./kibana-plugin-server.savedobjectstypemappingdefinition.md)

## SavedObjectsTypeMappingDefinition interface

Describe a saved object type mapping.

<b>Signature:</b>

```typescript
export interface SavedObjectsTypeMappingDefinition
```

## Example


```ts
const typeDefinition: SavedObjectsTypeMappingDefinition = {
properties: {
enabled: {
type: "boolean"
},
sendUsageFrom: {
ignore_above: 256,
type: "keyword"
},
lastReported: {
type: "date"
},
lastVersionChecked: {
ignore_above: 256,
type: "keyword"
},
}
}

```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [properties](./kibana-plugin-server.savedobjectstypemappingdefinition.properties.md) | <code>SavedObjectsMappingProperties</code> | |

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) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsTypeMappingDefinition](./kibana-plugin-server.savedobjectstypemappingdefinition.md) &gt; [properties](./kibana-plugin-server.savedobjectstypemappingdefinition.properties.md)

## SavedObjectsTypeMappingDefinition.properties property

<b>Signature:</b>

```typescript
properties: SavedObjectsMappingProperties;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsTypeMappingDefinitions](./kibana-plugin-server.savedobjectstypemappingdefinitions.md)

## SavedObjectsTypeMappingDefinitions interface

A map of [saved object type mappings](./kibana-plugin-server.savedobjectstypemappingdefinition.md)

<b>Signature:</b>

```typescript
export interface SavedObjectsTypeMappingDefinitions
```

## Example


```ts
const mappings: SavedObjectsTypeMappingDefinitions = {
someType: {
properties: {
enabled: {
type: "boolean"
},
field: {
type: "keyword"
},
},
},
anotherType: {
properties: {
enabled: {
type: "boolean"
},
lastReported: {
type: "date"
},
},
},

}

```
This is the format for a `mappings.json` savedObject mapping file.

Loading