-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of interest: why are we ignoring those two files for linting? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're generated by PEG
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great overall, just had a couple minor questions. Tested some queries and filters in the UI and everything seemed to work still.
src/utils/es_query/from_kuery.js
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation_links module could also probably be moved to utils?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That module relies on ui/metadata which I'm not sure could be moved to utils...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
src/utils/es_query/from_kuery.js
Outdated
catch (parseError) { | ||
if (parseError instanceof NoLeadingWildcardsError) { | ||
throw parseError; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was this condition doing and why was it removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just delete this module now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
buildESQuery
module (includingfilters
andkuery
) 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: