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

Conversation

pgayvallet
Copy link
Contributor

@pgayvallet pgayvallet commented Jan 24, 2020

Summary

Fix #50309

PR does the following:

  • add new registerMappings API to savedObjects setup contract
  • cleanup, rename, and document the savedObjects mappings types

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

Dev Docs

Added API to register savedObjects mapping from the new platform

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

export const mappings: SavedObjectsTypeMappingDefinitions = {
  'my-type': {
    properties: {
      afield: {
        type: "text"
      }
    }
  }
}
 // my-plugin/server/plugin.ts
 import { mappings } from './mappings';

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

@pgayvallet pgayvallet added Feature:New Platform release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.7.0 labels Jan 24, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

Comment on lines 105 to 110
version: kibanaVersion,
savedObjectSchemas: new SavedObjectsSchema(uiExports.savedObjectSchemas),
savedObjectMappings: uiExports.savedObjectMappings,
savedObjectMappings: convertLegacyMappings(uiExports.savedObjectMappings),
savedObjectMigrations: uiExports.savedObjectMigrations,
savedObjectValidations: uiExports.savedObjectValidations,
callCluster: (path, ...args) => _.get(client, path).call(client, ...args),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a missed blocker regarding saved object migration to new platform: ATM the es-archiver has no way to be informed about mappings defined from NP (and it will be the same when we migrate schemas, migrations and validations).However I don't want to handle it in this PR (and I don't have a solution ATM) Created #55860 to discuss the issue.

Comment on lines +26 to -24
pluginId: string;
type: string;
fields?: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using a string instead of the OpaquePluginId here because the only usage of this field is to add details about the plugin name when two plugins are registering the same type, and using the String(pluginOpaqueId) outputs Symbol(myId)...

Comment on lines +241 to +242

this.mappings = convertLegacyMappings(legacyMappings || []);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if it should never be undefined, there were some integration tests starting the kibana server where the mappings were undefined. As the uiExport gathering/reducing code is an unreadable thing, doing this || [] here was the pragmatic solution (and will be deleted post 8.0 anyway)

Comment on lines -40 to +39
properties: {
name: { type: 'keyword' },
},
type: 'nsAgnosticType',
definition: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internal structure changed, had to adapt the test data to the new structure

@pgayvallet pgayvallet marked this pull request as ready for review January 24, 2020 16:47
@pgayvallet pgayvallet requested a review from a team as a code owner January 24, 2020 16:47
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@pgayvallet
Copy link
Contributor Author

Closing, obsolete due to #55857

@pgayvallet pgayvallet closed this Jan 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:New Platform release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Platform] SavedObject Mappings
3 participants