Skip to content

Explicit namespaces for esQuery and esKuery#57172

Merged
lizozom merged 8 commits intoelastic:masterfrom
lizozom:newplatform/data/kuery-query-namespace
Feb 11, 2020
Merged

Explicit namespaces for esQuery and esKuery#57172
lizozom merged 8 commits intoelastic:masterfrom
lizozom:newplatform/data/kuery-query-namespace

Conversation

@lizozom
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 requested a review from ppisljar February 10, 2020 09:21
@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
Copy Markdown
Contributor

@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
Copy Markdown
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
  FieldFormatsRegistry,
Copy link
Copy Markdown
Contributor

@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
Copy Markdown
Contributor

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.

import { Dispatch } from 'redux';
import { ActionCreator } from 'typescript-fsa';

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

Choose a reason for hiding this comment

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

@XavierM FYI

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

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface JsonArray extends Array<JsonValue> {}
Copy link
Copy Markdown
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
Copy Markdown
Contributor

💚 Build Succeeded

History

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

Copy link
Copy Markdown
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.

8 participants