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

Explicit namespaces for esQuery and esKuery #57172

Merged

Conversation

lizozom
Copy link
Contributor

@lizozom lizozom commented Feb 9, 2020

Summary

Part of #56881

This PR applies the proposed resolution for #52374, trying to balance code readability, API discoverability, DX and documentation generation using ApiExtractor on the esQuery and esKuery namespaces of data plugin.

The solution involves:

  • Exporting types directly from index.ts, with a prefix (consistent with core)
  • Exporting utility functions and constants using a "namespace" (A simple object).

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

@lizozom lizozom added the release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. label Feb 9, 2020
@lizozom lizozom changed the title Explicit namespaces for esQuery and esQuery Explicit namespaces for esQuery and esKuery Feb 9, 2020
@lizozom
Copy link
Contributor Author

lizozom commented Feb 9, 2020

@elasticmachine merge upstream

@lizozom lizozom marked this pull request as ready for review February 9, 2020 20:34
@lizozom lizozom requested a review from a team February 9, 2020 20:34
@lizozom lizozom requested review from a team as code owners February 9, 2020 20:34
@lizozom lizozom added the review label Feb 9, 2020
Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

LGTM for platform changes

@lizozom lizozom added release_note:skip Skip the PR/issue when compiling release notes and removed release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. labels Feb 10, 2020
Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

code LGTM

@lizozom
Copy link
Contributor Author

lizozom commented Feb 10, 2020

@XavierM

SIEM is not marked as code owners (and I don;t know your GITHUB handle), so you didn't get an automatic notification, but I wanted to ket you know about some changes in this PR:

  • I removed the copy of x-pack/legacy/plugins/siem/common/typed_json.ts you had, as its now exported from kibana_utils
  • Some places in import from deep folders withing a folder (i.e. src/plugins/data/common/es_query) or from the common folder. Imports should be made from the top level of a plugin, and from public or server , so I fixed a couple of those as well.

Liza K added 2 commits February 10, 2020 17:03
Copy link
Member

@lukeelmers lukeelmers left a comment

Choose a reason for hiding this comment

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

This feels SO much cleaner than what we had before! Thanks for taking the time to do this @lizozom ... Code all LGTM

Comment on lines +20 to +27
export type JsonValue = null | boolean | number | string | JsonObject | JsonArray;

export interface JsonObject {
[key: string]: JsonValue;
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface JsonArray extends Array<JsonValue> {}
Copy link
Member

Choose a reason for hiding this comment

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

Would it make more sense to put this in packages/kbn-utility-types?

I could go either way, but this does feel like a pretty basic TS interface that I could see folks reaching for a lot, and kbn-utility-types seems designed to address this use case more than kibana_utils.

@@ -11,8 +11,7 @@ import { connect } from 'react-redux';
import { Dispatch } from 'redux';
import { ActionCreator } from 'typescript-fsa';

import { esFilters, esQuery } from '../../../../../../../../../src/plugins/data/common/es_query';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@XavierM FYI

@@ -6,15 +6,7 @@

import { FontawesomeIcon } from '../helpers/style_choices';
import { WorkspaceField, AdvancedSettings } from './app_state';

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface JsonArray extends Array<JsonValue> {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Graph changes LGTM, thanks for the improvement 👍

@lizozom lizozom merged commit eb54678 into elastic:master Feb 11, 2020
lizozom pushed a commit to lizozom/kibana that referenced this pull request Feb 11, 2020
* Explicit namespaces for esQuery and esQuery

* Remove unnecessary file from siem

* remove jsonvalue definition from siem

* server
  FieldFormatsRegistry,

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
lizozom pushed a commit that referenced this pull request Feb 11, 2020
* Explicit namespaces for esQuery and esQuery

* Remove unnecessary file from siem

* remove jsonvalue definition from siem

* server
  FieldFormatsRegistry,

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@alexwizp alexwizp mentioned this pull request Feb 12, 2020
7 tasks
@lizozom lizozom mentioned this pull request Feb 12, 2020
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants