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

Move application.applications$ to public contract #67463

Merged

Conversation

pgayvallet
Copy link
Contributor

Summary

Fix #67302

  • Expose the applications$ observable on the service's public start contract
  • Introduce and use new types instead of the raw App and LegacyApp to avoid leaking 'private' properties such as the mount function

Checklist

@pgayvallet pgayvallet added v7.9.0 v8.0.0 Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc labels May 27, 2020
@elasticmachine
Copy link
Contributor

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

@pgayvallet pgayvallet added release_note:skip Skip the PR/issue when compiling release notes Feature:New Platform labels May 27, 2020
Comment on lines 251 to 253
export type AppInfo = Omit<App, 'mount' | 'updater$'> & {
legacy: false;
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was not very inspired when choosing a name for these types. Any better suggestion is welcome

Copy link
Contributor

Choose a reason for hiding this comment

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

PublicAppInfo to indicate that's publicly available to other plugins?

Comment on lines 123 to 127
export function getAppInfo(app: App<unknown> | LegacyApp): AppInfo | LegacyAppInfo {
if (isLegacyApp(app)) {
const { updater$, ...infos } = app;
return {
...infos,
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 tried a generic approach to have proper return type depending on the input

function getAppInfo<T extends App<unknown> | LegacyApp>(
  app: T
): T extends App ? AppInfo : LegacyAppInfo {
  if (isLegacyApp(app)) {
    const { updater$, ...infos } = app;
    return {
      ...infos,
      legacy: true,
    };
  }
  const { updater$, mount, ...infos } = app;
  return {
    ...infos,
    legacy: false,
  };
}

However the isLegacyApp typeguard was not enough for TS, and the return type was not correctly inferred, resulting in type errors. As this is only used to populate a Map<string, AppInfo | LegacyAppInfo anyway, I think current signature is still fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's fine too. Also there are only two remaining legacy apps right now, so we're close to gutting this anyways 😄

@pgayvallet
Copy link
Contributor Author

retest

@pgayvallet pgayvallet marked this pull request as ready for review May 27, 2020 14:04
@pgayvallet pgayvallet requested a review from a team as a code owner May 27, 2020 14:04
subUrlBase?: string;
}

// Warning: (ae-incompatible-release-tags) The symbol "LegacyAppInfo" is marked as @public, but its signature references "LegacyApp" which is marked as @internal
Copy link
Contributor

Choose a reason for hiding this comment

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

might want to fix this? not sure if very important though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LegacyApp was flagged as internal, however LegacyAppInfo is based on it, and is public. What should I do, change LegacyApp visibility to public?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess so. It doesn't matter a whole lot since this is going away soon.

@pgayvallet
Copy link
Contributor Author

retest

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@pgayvallet pgayvallet merged commit a091124 into elastic:master Jun 2, 2020
pgayvallet added a commit to pgayvallet/kibana that referenced this pull request Jun 2, 2020
* expose applications$ on public contract

* review comments
pgayvallet added a commit that referenced this pull request Jun 2, 2020
* expose applications$ on public contract

* review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:New Platform release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.9.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose an API allowing plugins to access registered applications info
4 participants