How to extract a function from Kibana source code?

Dear all =)

I would like to be able to convert KQL to Lucene in my NodeJS application that uses the Kibana API to create rules.

In this I see fromExpression(expression) and toElasticsearchQuery(node, indexPattern) does exactly that =)

TypeScript is new to me, and also working with so large code bases as Kibana, so I am compeltely blank on where and how to extract the files I would need and how to compile them to ES6+ afterwards.

Is there a Kibana developer out there that can help me with this? =)

Sandra =)

Hi @Sandra_Schlichting

If you are new to Typescript I would recommend cloning a starter like this one to get you started.

Then you should be able to have the "kbn-es-query" folder in the "src" folder of your project. But this might be a license infringement so I would suggest that you write first an email to to verify that what you would like to do is OK under our license terms.

Thank you

1 Like

Dear SĂ©bastien

Thanks a lot for the kick start =)

Good point about the license. I'll have my boss contact before I proceed on this.

Sandra =)

Dear SĂ©bastien =)

I have now looked at the licenses, and there seams to be 3 depending on which files one would like to use. My boss proposes I get an exact list of the files I need before contacting .

So my current thinking is just to get it to compile, but I get the below errors. Can you figure out what I am doing wrong?

git clone
cd simple-typescript-starter/
npm install
cp -a ~/kibana/packages/kbn-es-query/ src/
npm install @types/lodash
npm install @kbn/utility-types
npm run build

gives me a long list of errors similar to

Cannot find module '@kbn/utility-types'

full output here

I imagine I somehow have to build @kbn/utility-types first?

Sandra =)

Hi @Sandra_Schlichting

Yes indeed you will need to bring over all the other package dependencies. And probably change the imports from absolute imports (e.g. import { <something> } from '@kbn/utility-types') to relative imports (import { <something> } from '../../@kbn-utility-types')

Another option is to compile the packages and place them in the node_modules folder. But that has its own part of difficulties.

Good luck!

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.