Move buildEsQuery to a package#23345
Conversation
💔 Build Failed |
.eslintignore
Outdated
| /src/ui/public/kuery/ast/kuery.js | ||
| /src/ui/public/kuery/ast/legacy_kuery.js | ||
| /src/utils/kuery/ast/kuery.js | ||
| /src/utils/kuery/ast/legacy_kuery.js |
There was a problem hiding this comment.
Out of interest: why are we ignoring those two files for linting? :)
💚 Build Succeeded |
Bargs
left a comment
There was a problem hiding this comment.
Looks great overall, just had a couple minor questions. Tested some queries and filters in the UI and everything seemed to work still.
| throw parseError; | ||
| } | ||
| throw new Error( | ||
| `It looks like you're using an outdated Kuery syntax. See what changed in the [docs](${queryDocs.kueryQuerySyntax})!` |
There was a problem hiding this comment.
Why did you remove the link to the docs? Without any direction I think it'll be impossible for a user to find the right information.
There was a problem hiding this comment.
I didn't want it to rely on something in public/ (which is where documentationLinks is). I guess I could just make the invoking function in public/ check for this type of error and add the links.
There was a problem hiding this comment.
The documentation_links module could also probably be moved to utils?
There was a problem hiding this comment.
That module relies on ui/metadata which I'm not sure could be moved to utils...
There was a problem hiding this comment.
It only uses the branch name though. I think the stuff in metadata ultimately comes from the server, so the branch name should be accessible somewhere.
| catch (parseError) { | ||
| if (parseError instanceof NoLeadingWildcardsError) { | ||
| throw parseError; | ||
| } |
There was a problem hiding this comment.
What was this condition doing and why was it removed?
There was a problem hiding this comment.
Because I got rid of the NoLeadingWildcardsError since it relied on KbnError in public. Instead, we just throw a regular error. This condition wasn't actually really necessary anyway since we end up throwing the error anyway below (unless it parses successfully in the old syntax). So in theory, the only thing that changes by removing this condition is when something would parse successfully in the old grammar but also has a leading wildcard, which I can't imagine of a scenario.
| decorateQuery, | ||
| buildQueryFromFilters, | ||
| luceneStringToDsl | ||
| } from '../../../../utils/es_query'; |
There was a problem hiding this comment.
Do we even need to export these from here now are can existing users of this module just import the functions from the new directory?
There was a problem hiding this comment.
We could, it just seemed like fewer changes to do it this way rather than go through each of the imports and change them. I'm open to changing this if you think it makes sense.
There was a problem hiding this comment.
Maybe I missed some, but it looked to me like the imports had already been changed. Intellij's refactoring tools should handle it. I'd just rip the band aid off cleanly so folks in the future aren't confused about where they should be importing from.
There was a problem hiding this comment.
Made the change. Wasn't even bad at all
| try { | ||
| flatData.body.query = buildESQuery(flatData.index, flatData.query, flatData.filters); | ||
| } catch (e) { | ||
| throw new KbnError(e.message, KbnError); |
There was a problem hiding this comment.
Ok now that I see this, I'm assuming that's why you removed the wildcard error type?
src/ui/public/kuery/index.js
Outdated
| export * from './ast'; | ||
| export * from './filter_migration'; | ||
| export * from './node_types'; | ||
| export * from '../../../utils/kuery'; |
There was a problem hiding this comment.
Can we just delete this module now?
There was a problem hiding this comment.
Same comment as above, we could, but we'd have to update all of the references, which is fine by me if you think it's best.
|
Responded to your feedback @Bargs. I also updated it so it retains the link to the docs in the outdated syntax error. |
💔 Build Failed |
💔 Build Failed |
lukeelmers
left a comment
There was a problem hiding this comment.
code makes sense & LGTM - just added one question
| if (e.message === 'OutdatedKuerySyntaxError') { | ||
| const message = `It looks like you're using an outdated Kuery syntax. | ||
| See what changed in the [docs](${documentationLinks.query.kueryQuerySyntax})!`; | ||
| throw new KbnError(message, KbnError); |
There was a problem hiding this comment.
Rather than adding the message / link back here, would it be better to add a class for this error type to errors.js? It seems that's a convention we've followed elsewhere, but not sure if it's something we are sticking with.
|
couldn't we move this to a package, so it could then be imported with |
|
@ppisljar Yeah, that makes a lot of sense. I'll see if I can get that working. |
💔 Build Failed |
💔 Build Failed |
This reverts commit 991d46f.
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💚 Build Succeeded |
💚 Build Succeeded |
|
@mattapperson @sqren @weltenwort Would you mind taking another quick look at this PR if we miss something for Infra/APM? We are trying to get this merged soon because we have some other PRs that depends on this. |
|
still looks good as far as the infra ui usage is concerned 👍 |
|
Everything looks good from APM POV 👍 |
|
@Bargs @lukasolson I've merged on master, but there is a conflict on backporting this PR because of this missing backported PR: #15640. |
|
@lukasolson when backporting this PR please remove the |
* fix: move buildEsQuery to utils * fix: tests that I broke * fix: add back link to the docs * fix: don't export from ui/ and link to utils * fix: move to a package * fix: move error to errors.js * fix: paths for peg task * fix: update reference to kuery * fix: build step for transpilation * fix: add typescript declaration file * fix: test * tmp: debug individual tests * debug: add debug stuff for reporting tests * try to debug test * Testing splitting reporting jobs in two * Testing splitting each job * Fix ci yaml * Skipping job to check failing test * debug - adding a catch to jobResponseHandler on report * Testing a different job and enabling verbose mode * Testing verbose on phantom_api skipping other CI tests * Fix script mode * fix: try running tests in chromium * fix: move out of devDependencies * fix: remove commented test * Revert "fix: try running tests in chromium" This reverts commit 991d46f. * Revert testing changes * Fixing build for phantomjs * Revert CI configuration to master. Remove verbose logging for tests
* Move buildEsQuery to a package (#23345) * fix: move buildEsQuery to utils * fix: tests that I broke * fix: add back link to the docs * fix: don't export from ui/ and link to utils * fix: move to a package * fix: move error to errors.js * fix: paths for peg task * fix: update reference to kuery * fix: build step for transpilation * fix: add typescript declaration file * fix: test * tmp: debug individual tests * debug: add debug stuff for reporting tests * try to debug test * Testing splitting reporting jobs in two * Testing splitting each job * Fix ci yaml * Skipping job to check failing test * debug - adding a catch to jobResponseHandler on report * Testing a different job and enabling verbose mode * Testing verbose on phantom_api skipping other CI tests * Fix script mode * fix: try running tests in chromium * fix: move out of devDependencies * fix: remove commented test * Revert "fix: try running tests in chromium" This reverts commit 991d46f. * Revert testing changes * Fixing build for phantomjs * Revert CI configuration to master. Remove verbose logging for tests * remove x-pack/yarn.lock, accidentally added back in #23345 * Fix import sorting
This PR moves the
buildESQuerymodule (includingfiltersandkuery) into a separate package so that it can be imported on both the client and server (in preparation to support Kuery in Timelion and TSVB)./cc @timroes @lukeelmers
To do: