# 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`, `NOT` and 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

```bash
npm install @open-kappa/colors
// Or
bun install @open-kappa/colors
```

## Architecture

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

```typescript
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](https://open-kappa.gitlab.io/nodejs/omni-query-filter)
* **Source Code:** [GitLab](https://gitlab.com/open-kappa/nodejs/omni-query-filter)
* **Open-Kappa Projects:** [Index](https://open-kappa.gitlab.io)
