@deephaven/jsapi-utils
Advanced tools
Comparing version 0.15.7-beta.0 to 0.15.7-beta.3
@@ -132,2 +132,8 @@ import { TypeValue as FilterTypeValue, OperatorValue as FilterOperatorValue } from '@deephaven/filters'; | ||
static makeQuickDateFilterWithOperation(column: Column, text: string, operation: string | undefined, timeZone: string): FilterCondition; | ||
/** | ||
* Adds quotes to a value if they're not already added | ||
* @param value Value to add quotes around | ||
*/ | ||
static quoteValue(value: string): string; | ||
static isRangeOperation(operation: string): boolean; | ||
static makeQuickCharFilter(column: Column, text: string): FilterCondition | null; | ||
@@ -181,3 +187,4 @@ /** | ||
static makeNumberValue(text: string): number | null; | ||
static makeAdvancedValueFilter(column: Column, operation: FilterTypeValue, value: string, timeZone: string): FilterCondition; | ||
static getFilterOperatorString(operation: FilterTypeValue): string; | ||
static makeAdvancedValueFilter(column: Column, operation: FilterTypeValue, value: string, timeZone: string): FilterCondition | null; | ||
/** | ||
@@ -184,0 +191,0 @@ * Create a filter using the selected items |
@@ -56,12 +56,5 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
return [FilterType.isTrue, FilterType.isFalse, FilterType.isNull]; | ||
} // TODO (DH-11799): In Bard (and beyond), we should use the same types as numbers | ||
// It should just work after the merge for DH-11040: https://gitlab.eng.illumon.com/illumon/iris/merge_requests/5801 | ||
// In Powell though, just support equals/not equals | ||
if (TableUtils.isCharType(columnType)) { | ||
return [FilterType.eq, FilterType.notEq]; | ||
} | ||
if (TableUtils.isNumberType(columnType) || TableUtils.isDateType(columnType)) { | ||
if (TableUtils.isCharType(columnType) || TableUtils.isNumberType(columnType) || TableUtils.isDateType(columnType)) { | ||
return [FilterType.eq, FilterType.notEq, FilterType.greaterThan, FilterType.greaterThanOrEqualTo, FilterType.lessThan, FilterType.lessThanOrEqualTo]; | ||
@@ -791,3 +784,31 @@ } | ||
} | ||
/** | ||
* Adds quotes to a value if they're not already added | ||
* @param value Value to add quotes around | ||
*/ | ||
static quoteValue(value) { | ||
if (value.length >= 2 && (value.charAt(0) === '"' && value.charAt(value.length - 1) === '"' || value.charAt(0) === "'" && value.charAt(value.length - 1) === "'")) { | ||
return value; | ||
} | ||
return "\"".concat(value, "\""); | ||
} | ||
static isRangeOperation(operation) { | ||
switch (operation) { | ||
case '<': | ||
case '<=': | ||
case '=<': | ||
case '>': | ||
case '>=': | ||
case '=>': | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
static makeQuickCharFilter(column, text) { | ||
@@ -799,3 +820,3 @@ if (text == null) { | ||
var cleanText = "".concat(text).trim(); | ||
var regex = /^(!=|=|!)?(null|.)?(.*)/; | ||
var regex = /^(>=|<=|=>|=<|>|<|!=|=|!)?(null|"."|'.'|.)?(.*)/; | ||
var result = regex.exec(cleanText); | ||
@@ -838,5 +859,7 @@ var operation = null; | ||
} | ||
} | ||
} // We need to put quotes around range operations or else the API fails | ||
return TableUtils.makeRangeFilterWithOperation(filter, operation, dh.FilterValue.ofString(value)); | ||
var filterValue = dh.FilterValue.ofString(TableUtils.isRangeOperation(operation) ? TableUtils.quoteValue(value) : value); | ||
return TableUtils.makeRangeFilterWithOperation(filter, operation, filterValue); | ||
} | ||
@@ -1142,2 +1165,33 @@ /** | ||
static getFilterOperatorString(operation) { | ||
switch (operation) { | ||
case FilterType.eq: | ||
return '='; | ||
case FilterType.notEq: | ||
return '!='; | ||
case FilterType.greaterThan: | ||
return '>'; | ||
case FilterType.greaterThanOrEqualTo: | ||
return '>='; | ||
case FilterType.lessThan: | ||
return '<'; | ||
case FilterType.lessThanOrEqualTo: | ||
return '<='; | ||
case FilterType.contains: | ||
return '~'; | ||
case FilterType.notContains: | ||
return '!~'; | ||
default: | ||
throw new Error("Unexpected filter type ".concat(operation)); | ||
} | ||
} | ||
static makeAdvancedValueFilter(column, operation, value, timeZone) { | ||
@@ -1148,2 +1202,6 @@ if (TableUtils.isDateType(column.type)) { | ||
if (TableUtils.isNumberType(column.type) || TableUtils.isCharType(column.type)) { | ||
return TableUtils.makeQuickFilter(column, "".concat(TableUtils.getFilterOperatorString(operation)).concat(value)); | ||
} | ||
var filterValue = TableUtils.makeFilterValue(column.type, value); | ||
@@ -1150,0 +1208,0 @@ var filter = column.filter(); |
{ | ||
"name": "@deephaven/jsapi-utils", | ||
"version": "0.15.7-beta.0+c54e11a", | ||
"version": "0.15.7-beta.3+3214155", | ||
"description": "Deephaven JSAPI Utils", | ||
@@ -30,9 +30,9 @@ "author": "Deephaven Data Labs LLC", | ||
"dependencies": { | ||
"@deephaven/filters": "^0.15.7-beta.0+c54e11a", | ||
"@deephaven/jsapi-shim": "^0.15.7-beta.0+c54e11a", | ||
"@deephaven/log": "^0.15.7-beta.0+c54e11a", | ||
"@deephaven/utils": "^0.15.7-beta.0+c54e11a" | ||
"@deephaven/filters": "^0.15.7-beta.3+3214155", | ||
"@deephaven/jsapi-shim": "^0.15.7-beta.3+3214155", | ||
"@deephaven/log": "^0.15.7-beta.3+3214155", | ||
"@deephaven/utils": "^0.15.7-beta.3+3214155" | ||
}, | ||
"devDependencies": { | ||
"@deephaven/tsconfig": "^0.15.7-beta.0+c54e11a" | ||
"@deephaven/tsconfig": "^0.15.7-beta.3+3214155" | ||
}, | ||
@@ -45,3 +45,3 @@ "files": [ | ||
}, | ||
"gitHead": "c54e11a1fe772b855b6bac2a1534857c8cedc8f8" | ||
"gitHead": "32141554dfc8a60ff2629fd7aa4e65d79dd35c07" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
280303
2525