1.0.4 • Published 2 years ago

@looker/filter-expressions v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@looker/filter-expressions

This TypeScript package provides the necessary functions for transforming Looker filter expressions into data structures and localized text summaries – and vice versa.

getExpressionType

Returns a valid filter expression type when given the type and field properties of an IDashboardFilter object as defined in @looker/sdk.

getExpressionType({ field: { is_numeric: true }, type: 'field_filter' });
// 'number'

parseFilterExpression

Returns an Abstract Syntax Tree (AST) that logically represents the filter expression string passed in, as well as the filter expression type (and optional user attributes).

parseFilterExpression('number', '[0,20],>30');
// {
//   type: ',',
//   left: {
//     type: 'between',
//     bounds: '[]',
//     low: 0,
//     high: 20,
//     is: true,
//   },
//   right: {
//     is: true,
//     type: '>',
//     value: [30],
//   },
// }

summary

The summary function returns a localized, human-readable summary of a filter expression, given the expression's type, the expression itself, and the user attributes and field, if applicable.

summary('number', '[0,20],>30');
// 'is in range [0, 20] or is > 30'

typeToGrammar

Returns an object with utility functions and values pertaining to a given expression type:

  • toString: a function that converts an AST into an expression of the given type
  • subTypes: an array containing the sub-types of the expression type, for example ">", "<", "=", "between", etc, for a number expression type

getFilterTokenItem

Converts an AST to a single item for use in a token (i.e. not advanced) filter.

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

3 years ago

0.8.21

3 years ago

0.8.20

3 years ago

0.8.19

3 years ago

0.8.16

3 years ago

0.8.15

3 years ago

0.8.18

3 years ago

0.8.17

3 years ago

0.8.14

3 years ago

0.8.13

4 years ago

0.8.12

4 years ago

0.8.9

4 years ago

0.8.11

4 years ago

0.8.10

4 years ago

0.8.8

4 years ago

0.8.5

4 years ago

0.8.7

4 years ago

0.8.6

4 years ago

0.8.4

4 years ago

0.8.3

4 years ago

0.8.2

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.8.0-alpha.1

4 years ago

0.8.0-alpha.0

4 years ago

0.7.0

4 years ago

0.7.0-alpha.0

4 years ago

0.6.0

4 years ago

0.6.0-alpha.1

4 years ago

0.6.0-alpha.0

4 years ago