Skip to content

Commit

Permalink
Use TS to discourage SO mappings with dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolf committed Jun 25, 2020
1 parent 8ed4f7f commit d5a0ee0
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion docs/development/core/server/kibana-plugin-core-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [SavedObjectsBulkUpdateResponse](./kibana-plugin-core-server.savedobjectsbulkupdateresponse.md) | |
| [SavedObjectsClientProviderOptions](./kibana-plugin-core-server.savedobjectsclientprovideroptions.md) | Options to control the creation of the Saved Objects Client. |
| [SavedObjectsClientWrapperOptions](./kibana-plugin-core-server.savedobjectsclientwrapperoptions.md) | Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance. |
| [SavedObjectsComplexFieldMapping](./kibana-plugin-core-server.savedobjectscomplexfieldmapping.md) | See [SavedObjectsFieldMapping](./kibana-plugin-core-server.savedobjectsfieldmapping.md) for documentation. |
| [SavedObjectsComplexFieldMapping](./kibana-plugin-core-server.savedobjectscomplexfieldmapping.md) | See [SavedObjectsFieldMapping](./kibana-plugin-core-server.savedobjectsfieldmapping.md) for documentation.<!-- -->Note: this type intentially doesn't include a type definition for defining the <code>dynamic</code> mapping parameter. Saved Object fields should always inherit the <code>dynamic: 'strict'</code> paramater. If you are unsure of the shape of your data use <code>type: 'object', enabled: false</code> instead. |
| [SavedObjectsCoreFieldMapping](./kibana-plugin-core-server.savedobjectscorefieldmapping.md) | See [SavedObjectsFieldMapping](./kibana-plugin-core-server.savedobjectsfieldmapping.md) for documentation. |
| [SavedObjectsCreateOptions](./kibana-plugin-core-server.savedobjectscreateoptions.md) | |
| [SavedObjectsDeleteByNamespaceOptions](./kibana-plugin-core-server.savedobjectsdeletebynamespaceoptions.md) | |
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

See [SavedObjectsFieldMapping](./kibana-plugin-core-server.savedobjectsfieldmapping.md) for documentation.

Note: this type intentially doesn't include a type definition for defining the `dynamic` mapping parameter. Saved Object fields should always inherit the `dynamic: 'strict'` paramater. If you are unsure of the shape of your data use `type: 'object', enabled: false` instead.

<b>Signature:</b>

```typescript
Expand All @@ -16,7 +18,6 @@ export interface SavedObjectsComplexFieldMapping

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

6 changes: 5 additions & 1 deletion src/core/server/saved_objects/mappings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,14 @@ export interface SavedObjectsCoreFieldMapping {
/**
* See {@link SavedObjectsFieldMapping} for documentation.
*
* Note: this type intentially doesn't include a type definition for defining
* the `dynamic` mapping parameter. Saved Object fields should always inherit
* the `dynamic: 'strict'` paramater. If you are unsure of the shape of your
* data use `type: 'object', enabled: false` instead.
*
* @public
*/
export interface SavedObjectsComplexFieldMapping {
dynamic?: string;
type?: string;
properties: SavedObjectsMappingProperties;
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ function defaultMapping(): IndexMapping {
dynamic: 'strict',
properties: {
migrationVersion: {
// Saved Objects can't redefine dynamic, but we cheat here to support migrations
// @ts-expect-error
dynamic: 'true',
type: 'object',
},
Expand Down
2 changes: 0 additions & 2 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1970,8 +1970,6 @@ export interface SavedObjectsClientWrapperOptions {

// @public
export interface SavedObjectsComplexFieldMapping {
// (undocumented)
dynamic?: string;
// (undocumented)
properties: SavedObjectsMappingProperties;
// (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ const savedObjectTypes: { [key: string]: SavedObjectsType } = {
internal: { type: 'boolean' },
removable: { type: 'boolean' },
es_index_patterns: {
dynamic: 'false',
enabled: false,
type: 'object',
},
installed: {
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/maps/server/saved_objects/maps_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export const mapsTelemetrySavedObjects: SavedObjectsType = {
avg: { type: 'long' },
},
},
layerTypesCount: { dynamic: 'true', properties: {} },
emsVectorLayersCount: { dynamic: 'true', properties: {} },
layerTypesCount: { type: 'object', enabled: false },
emsVectorLayersCount: { type: 'object', enabled: false },
},
},
},
Expand Down

0 comments on commit d5a0ee0

Please sign in to comment.