@open-kappa/omni-query-filter
v0.2.1
Published
This is a simple package of utils to parse and manage a `omnibox` search filter.
Maintainers
Readme
omni-query-filter
This is a simple package of utils to parse and manage a omnibox search filter.
A omnibox is the usual generic search field common in web applications as
Drive, but it is also the same concept of the search bar of a search engine.
This implementation has the following features:
- Typecript: written in Typescript, so types are a built-in feature.
- Operators: supports the following operators:
AND,OR,NOTand the parenthesis()for the priority. - Tags: supports tags for search specialization:
tag:value. Their semantics is up to the specific query builder. - Search customization options: quite complete set of options to change the search behavior, such as: case sensitivity, dictionary for translations, etc.
Installation
npm install @open-kappa/colors
// Or
bun install @open-kappa/colorsArchitecture
There are few classes:
- Parser: it perform the parsing of the omnibox string.
- Fields: the description of the searchable "fields". For example, they could be the columns of a database table.
- Builder: visit the AST returned by the parser to build the search criteria.
Builders must be implemented by extending the Builder class.
Example
const builder = new MyBuilder()
const filter = OmniQueryFilter.create(builder)
.fields
.string("name")
.string("surname")
.currency("income")
.enum("status", ["active", "inactive"])
const result = filter.parseAndBuild(omniString)License
@open-kappa/omni-query-filter is released under the liberal
MIT License. Please refer to the LICENSE.txt project file for further
details.
Links
- Project Homepage: GitLab Pages
- Source Code: GitLab
- Open-Kappa Projects: Index
