@servicetitan/data-query 31.1.0 → 31.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/accessor.js +7 -7
  2. package/dist/accessor.js.map +1 -1
  3. package/dist/array.operators.js +22 -23
  4. package/dist/array.operators.js.map +1 -1
  5. package/dist/common.interfaces.js +4 -1
  6. package/dist/common.interfaces.js.map +1 -1
  7. package/dist/data-result.interface.js +4 -1
  8. package/dist/data-result.interface.js.map +1 -1
  9. package/dist/data-source/async-data-source.js +28 -36
  10. package/dist/data-source/async-data-source.js.map +1 -1
  11. package/dist/data-source/data-source.js +2 -1
  12. package/dist/data-source/data-source.js.map +1 -1
  13. package/dist/data-source/in-memory-data-source.js +47 -50
  14. package/dist/data-source/in-memory-data-source.js.map +1 -1
  15. package/dist/data-source/index.js +2 -0
  16. package/dist/data-source/index.js.map +1 -1
  17. package/dist/filter-serialization.common.js +33 -43
  18. package/dist/filter-serialization.common.js.map +1 -1
  19. package/dist/filtering/filter-descriptor.interface.js +2 -2
  20. package/dist/filtering/filter-descriptor.interface.js.map +1 -1
  21. package/dist/filtering/filter-expression.factory.js +7 -8
  22. package/dist/filtering/filter-expression.factory.js.map +1 -1
  23. package/dist/filtering/filter-no-eval.js +42 -50
  24. package/dist/filtering/filter-no-eval.js.map +1 -1
  25. package/dist/filtering/filter.operators.js +42 -40
  26. package/dist/filtering/filter.operators.js.map +1 -1
  27. package/dist/funcs.js +5 -8
  28. package/dist/funcs.js.map +1 -1
  29. package/dist/grouping/aggregate.operators.js +4 -4
  30. package/dist/grouping/aggregate.operators.js.map +1 -1
  31. package/dist/grouping/group-descriptor.interface.js +4 -2
  32. package/dist/grouping/group-descriptor.interface.js.map +1 -1
  33. package/dist/grouping/group.operators.js +13 -12
  34. package/dist/grouping/group.operators.js.map +1 -1
  35. package/dist/index.js +13 -6
  36. package/dist/index.js.map +1 -1
  37. package/dist/mvc/deserialization.js +30 -31
  38. package/dist/mvc/deserialization.js.map +1 -1
  39. package/dist/mvc/operators.js +66 -48
  40. package/dist/mvc/operators.js.map +1 -1
  41. package/dist/odata-filtering.operators.js +68 -38
  42. package/dist/odata-filtering.operators.js.map +1 -1
  43. package/dist/odata.operators.js +12 -17
  44. package/dist/odata.operators.js.map +1 -1
  45. package/dist/sort-descriptor.js +4 -1
  46. package/dist/sort-descriptor.js.map +1 -1
  47. package/dist/sorting/sort-array.operator.js +10 -13
  48. package/dist/sorting/sort-array.operator.js.map +1 -1
  49. package/dist/sorting/sort.js +9 -10
  50. package/dist/sorting/sort.js.map +1 -1
  51. package/dist/state.js +4 -1
  52. package/dist/state.js.map +1 -1
  53. package/dist/transducers.js +93 -102
  54. package/dist/transducers.js.map +1 -1
  55. package/dist/utils.js +11 -20
  56. package/dist/utils.js.map +1 -1
  57. package/package.json +3 -3
@@ -8,63 +8,53 @@ import { isString, isDate } from './utils';
8
8
  * //ignoreCase=true -> tolower(${field})`
9
9
  * //ignoreCase=false -> ${field}`
10
10
  * ```
11
- */
12
- export const wrapIf = predicate => (str, ...args) => predicate() ? `${str[0]}${args[0]}${str[1]}` : args[0];
11
+ */ export const wrapIf = (predicate)=>(str, ...args)=>predicate() ? `${str[0]}${args[0]}${str[1]}` : args[0];
13
12
  /**
14
13
  * @hidden
15
- */
16
- export const toUTC = (date) => new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
14
+ */ export const toUTC = (date)=>new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
17
15
  /**
18
16
  * @hidden
19
- */
20
- export const quote = ({ field, value, ignoreCase, operator }) => ({
21
- value: `'${value.replace(/'/g, "''")}'`,
22
- field,
23
- ignoreCase,
24
- operator
25
- });
17
+ */ export const quote = ({ field, value, ignoreCase, operator })=>({
18
+ value: `'${value.replace(/'/g, "''")}'`,
19
+ field,
20
+ ignoreCase,
21
+ operator
22
+ });
26
23
  /**
27
24
  * @hidden
28
- */
29
- export const encodeValue = ({ field, value, ignoreCase, operator }) => ({
30
- value: `${encodeURIComponent(value)}`,
31
- field,
32
- ignoreCase,
33
- operator
34
- });
25
+ */ export const encodeValue = ({ field, value, ignoreCase, operator })=>({
26
+ value: `${encodeURIComponent(value)}`,
27
+ field,
28
+ ignoreCase,
29
+ operator
30
+ });
35
31
  /**
36
32
  * @hidden
37
- */
38
- export const toLower = ({ field, value, ignoreCase, operator }) => ({
39
- field: wrapIf(() => ignoreCase) `tolower(${field})`,
40
- value,
41
- ignoreCase,
42
- operator
43
- });
33
+ */ export const toLower = ({ field, value, ignoreCase, operator })=>({
34
+ field: wrapIf(()=>ignoreCase)`tolower(${field})`,
35
+ value,
36
+ ignoreCase,
37
+ operator
38
+ });
44
39
  /**
45
40
  * @hidden
46
- */
47
- export const normalizeField = ({ field, value, ignoreCase, operator }) => ({
48
- value,
49
- field: field.replace(/\./g, "/"),
50
- ignoreCase,
51
- operator
52
- });
41
+ */ export const normalizeField = ({ field, value, ignoreCase, operator })=>({
42
+ value,
43
+ field: field.replace(/\./g, "/"),
44
+ ignoreCase,
45
+ operator
46
+ });
53
47
  /**
54
48
  * @hidden
55
- */
56
- export const isStringValue = x => isString(x.value);
49
+ */ export const isStringValue = (x)=>isString(x.value);
57
50
  /**
58
51
  * @hidden
59
- */
60
- export const isDateValue = x => isDate(x.value);
52
+ */ export const isDateValue = (x)=>isDate(x.value);
61
53
  /**
62
54
  * @hidden
63
- */
64
- export const serializeFilters = (map, join) => (filter) => {
65
- const brackets = wrapIf(() => filter.filters.length > 1);
66
- return brackets `(${filter.filters
67
- .map(map)
68
- .join(join(filter))})`;
69
- };
55
+ */ export const serializeFilters = (map, join)=>(filter)=>{
56
+ const brackets = wrapIf(()=>filter.filters.length > 1);
57
+ return brackets`(${filter.filters.map(map).join(join(filter))})`;
58
+ };
59
+
70
60
  //# sourceMappingURL=filter-serialization.common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter-serialization.common.js","sourceRoot":"","sources":["../src/filter-serialization.common.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAO3C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAE5G;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAU,EAAE,EAAE,CAChC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CACb,IAAI,CAAC,WAAW,EAAE,EAClB,IAAI,CAAC,QAAQ,EAAE,EACf,IAAI,CAAC,OAAO,EAAE,EACd,IAAI,CAAC,QAAQ,EAAE,EACf,IAAI,CAAC,UAAU,EAAE,EACjB,IAAI,CAAC,UAAU,EAAE,EACjB,IAAI,CAAC,eAAe,EAAE,CACzB,CAAC,CAAC;AAEP;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAmB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;IAC9E,KAAK,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG;IACvC,KAAK;IACL,UAAU;IACV,QAAQ;CACX,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAmB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;IACpF,KAAK,EAAE,GAAG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version":3,"sources":["../src/filter-serialization.common.ts"],"sourcesContent":["import { FilterDescriptor, CompositeFilterDescriptor } from './filtering/filter-descriptor.interface';\nimport { isString, isDate } from './utils';\n\n/**\n * @hidden\n */\nexport type Transformation = (x: FilterDescriptor) => FilterDescriptor;\n\n/**\n * @hidden\n * Creates a single arity function which wraps the value based on the provided predicate.\n * @example\n * ```\n * wrapIf(() => ignoreCase) `tolower(${field})`\n * //ignoreCase=true -> tolower(${field})`\n * //ignoreCase=false -> ${field}`\n * ```\n */\nexport const wrapIf = predicate => (str, ...args) => predicate() ? `${str[0]}${args[0]}${str[1]}` : args[0];\n\n/**\n * @hidden\n */\nexport const toUTC = (date: Date) =>\n new Date(Date.UTC(\n date.getFullYear(),\n date.getMonth(),\n date.getDate(),\n date.getHours(),\n date.getMinutes(),\n date.getSeconds(),\n date.getMilliseconds()\n ));\n\n/**\n * @hidden\n */\nexport const quote: Transformation = ({ field, value, ignoreCase, operator }) => ({\n value: `'${value.replace(/'/g, \"''\")}'`,\n field,\n ignoreCase,\n operator\n});\n\n/**\n * @hidden\n */\nexport const encodeValue: Transformation = ({ field, value, ignoreCase, operator }) => ({\n value: `${encodeURIComponent(value)}`,\n field,\n ignoreCase,\n operator\n});\n\n/**\n * @hidden\n */\nexport const toLower: Transformation = ({ field, value, ignoreCase, operator }) => ({\n field: wrapIf(() => ignoreCase)`tolower(${field})`,\n value,\n ignoreCase,\n operator\n});\n\n/**\n * @hidden\n */\nexport const normalizeField: Transformation = ({ field, value, ignoreCase, operator }) => ({\n value,\n field: (<string>field).replace(/\\./g, \"/\"),\n ignoreCase,\n operator\n});\n\n/**\n * @hidden\n */\nexport const isStringValue = x => isString(x.value);\n/**\n * @hidden\n */\nexport const isDateValue = x => isDate(x.value);\n\n/**\n * @hidden\n */\nexport const serializeFilters = (map, join) => (filter: CompositeFilterDescriptor): string => {\n const brackets = wrapIf(() => filter.filters.length > 1);\n return brackets`(${\n filter.filters\n .map(map)\n .join(join(filter))\n })`;\n};\n"],"names":["isString","isDate","wrapIf","predicate","str","args","toUTC","date","Date","UTC","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","getMilliseconds","quote","field","value","ignoreCase","operator","replace","encodeValue","encodeURIComponent","toLower","normalizeField","isStringValue","x","isDateValue","serializeFilters","map","join","filter","brackets","filters","length"],"mappings":"AACA,SAASA,QAAQ,EAAEC,MAAM,QAAQ,UAAU;AAO3C;;;;;;;;;CASC,GACD,OAAO,MAAMC,SAASC,CAAAA,YAAa,CAACC,KAAK,GAAGC,OAASF,cAAc,GAAGC,GAAG,CAAC,EAAE,GAAGC,IAAI,CAAC,EAAE,GAAGD,GAAG,CAAC,EAAE,EAAE,GAAGC,IAAI,CAAC,EAAE,CAAC;AAE5G;;CAEC,GACD,OAAO,MAAMC,QAAQ,CAACC,OAClB,IAAIC,KAAKA,KAAKC,GAAG,CACbF,KAAKG,WAAW,IAChBH,KAAKI,QAAQ,IACbJ,KAAKK,OAAO,IACZL,KAAKM,QAAQ,IACbN,KAAKO,UAAU,IACfP,KAAKQ,UAAU,IACfR,KAAKS,eAAe,KACrB;AAEP;;CAEC,GACD,OAAO,MAAMC,QAAwB,CAAC,EAAEC,KAAK,EAAEC,KAAK,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAM,CAAA;QAC9EF,OAAO,CAAC,CAAC,EAAEA,MAAMG,OAAO,CAAC,MAAM,MAAM,CAAC,CAAC;QACvCJ;QACAE;QACAC;IACJ,CAAA,EAAG;AAEH;;CAEC,GACD,OAAO,MAAME,cAA8B,CAAC,EAAEL,KAAK,EAAEC,KAAK,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAM,CAAA;QACpFF,OAAO,GAAGK,mBAAmBL,QAAQ;QACrCD;QACAE;QACAC;IACJ,CAAA,EAAG;AAEH;;CAEC,GACD,OAAO,MAAMI,UAA0B,CAAC,EAAEP,KAAK,EAAEC,KAAK,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAM,CAAA;QAChFH,OAAOhB,OAAO,IAAMkB,WAAW,CAAC,QAAQ,EAAEF,MAAM,CAAC,CAAC;QAClDC;QACAC;QACAC;IACJ,CAAA,EAAG;AAEH;;CAEC,GACD,OAAO,MAAMK,iBAAiC,CAAC,EAAER,KAAK,EAAEC,KAAK,EAAEC,UAAU,EAAEC,QAAQ,EAAE,GAAM,CAAA;QACvFF;QACAD,OAAO,AAASA,MAAOI,OAAO,CAAC,OAAO;QACtCF;QACAC;IACJ,CAAA,EAAG;AAEH;;CAEC,GACD,OAAO,MAAMM,gBAAgBC,CAAAA,IAAK5B,SAAS4B,EAAET,KAAK,EAAE;AACpD;;CAEC,GACD,OAAO,MAAMU,cAAcD,CAAAA,IAAK3B,OAAO2B,EAAET,KAAK,EAAE;AAEhD;;CAEC,GACD,OAAO,MAAMW,mBAAmB,CAACC,KAAKC,OAAS,CAACC;QAC5C,MAAMC,WAAWhC,OAAO,IAAM+B,OAAOE,OAAO,CAACC,MAAM,GAAG;QACtD,OAAOF,QAAQ,CAAC,CAAC,EACbD,OAAOE,OAAO,CACTJ,GAAG,CAACA,KACJC,IAAI,CAACA,KAAKC,SACd,CAAC,CAAC;IACX,EAAE"}
@@ -3,8 +3,8 @@ import { isPresent } from '../utils';
3
3
  /**
4
4
  * @hidden
5
5
  * Type guard for `CompositeFilterDescriptor`.
6
- */
7
- export const isCompositeFilterDescriptor = (source) => {
6
+ */ export const isCompositeFilterDescriptor = (source)=>{
8
7
  return isPresent(source.filters);
9
8
  };
9
+
10
10
  //# sourceMappingURL=filter-descriptor.interface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter-descriptor.interface.js","sourceRoot":"","sources":["../../src/filtering/filter-descriptor.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AA+DrC,gCAAgC;AAEhC;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,MAAoD,EAAuC,EAAE;IACrI,OAAO,SAAS,CAA6B,MAAO,CAAC,OAAO,CAAC,CAAC;AAClE,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/filtering/filter-descriptor.interface.ts"],"sourcesContent":["import { isPresent } from '../utils';\n\n// tslint:disable:max-line-length\n/**\n * A basic filter expression. Usually is a part of [`CompositeFilterDescriptor`]({% slug api_kendo-data-query_compositefilterdescriptor %}).\n *\n * For more information on filtering the provided data array, refer to the [`filterBy`]({% slug api_kendo-data-query_filterby %}) method.\n * For examples on using the `FilterDescriptor`, refer to the [documentation on filtering the Grid]({% slug filtering_grid %}).\n */\nexport interface FilterDescriptor {\n /**\n * The data item field to which the filter operator is applied.\n */\n field?: string | Function;\n /**\n * The filter operator (comparison).\n *\n * The supported operators are:\n * * `\"eq\"` (equal to)\n * * `\"neq\"` (not equal to)\n * * `\"isnull\"` (is equal to null)\n * * `\"isnotnull\"` (is not equal to null)\n * * `\"lt\"` (less than)\n * * `\"lte\"` (less than or equal to)\n * * `\"gt\"` (greater than)\n * * `\"gte\"` (greater than or equal to)\n *\n * The following operators are supported for string fields only:\n * * `\"startswith\"`\n * * `\"endswith\"`\n * * `\"contains\"`\n * * `\"doesnotcontain\"`\n * * `\"isempty\"`\n * * `\"isnotempty\"`\n */\n operator: string | Function;\n /**\n * The value to which the field is compared. Has to be of the same type as the field.\n */\n value?: any;\n /**\n * Determines if the string comparison is case-insensitive.\n */\n ignoreCase?: boolean;\n}\n\n/**\n * A complex filter expression. For more information, refer to the [`filterBy`]({% slug api_kendo-data-query_filterby %}) method.\n */\nexport interface CompositeFilterDescriptor {\n /**\n * The logical operation to use when the `filter.filters` option is set.\n *\n * The supported values are:\n * * `\"and\"`\n * * `\"or\"`\n */\n logic: 'or' | 'and';\n /**\n * The nested filter expressions&mdash;either [`FilterDescriptor`]({% slug api_kendo-data-query_filterdescriptor %}), or [`CompositeFilterDescriptor`]({% slug api_kendo-data-query_compositefilterdescriptor %}). Supports the same options as `filter`. You can nest filters indefinitely.\n */\n filters: Array<FilterDescriptor | CompositeFilterDescriptor>;\n}\n// tslint:enable:max-line-length\n\n/**\n * @hidden\n * Type guard for `CompositeFilterDescriptor`.\n */\nexport const isCompositeFilterDescriptor = (source: CompositeFilterDescriptor | FilterDescriptor): source is CompositeFilterDescriptor => {\n return isPresent((<CompositeFilterDescriptor>source).filters);\n};\n"],"names":["isPresent","isCompositeFilterDescriptor","source","filters"],"mappings":"AAAA,SAASA,SAAS,QAAQ,WAAW;AA+DrC,gCAAgC;AAEhC;;;CAGC,GACD,OAAO,MAAMC,8BAA8B,CAACC;IACxC,OAAOF,UAAU,AAA4BE,OAAQC,OAAO;AAChE,EAAE"}
@@ -18,11 +18,10 @@ import { transformCompositeFilter } from "./filter-no-eval";
18
18
  * const result = data.filter(predicate);
19
19
  *
20
20
  * ```
21
- */
22
- // tslint:enable:max-line-length
23
- export const compileFilter = (descriptor, preprocessors = {}) => {
21
+ */ // tslint:enable:max-line-length
22
+ export const compileFilter = (descriptor, preprocessors = {})=>{
24
23
  if (!descriptor || descriptor.filters.length === 0) {
25
- return () => true;
24
+ return ()=>true;
26
25
  }
27
26
  return transformCompositeFilter(descriptor, preprocessors);
28
27
  };
@@ -55,12 +54,12 @@ export const compileFilter = (descriptor, preprocessors = {}) => {
55
54
  * // output:
56
55
  * // [{ "name": "Pork", "category": "Food", "subcategory": "Meat" }]
57
56
  * ```
58
- */
59
- // tslint:enable:max-line-length
60
- export const filterBy = (data, descriptor, preprocessors = {}) => {
61
- if (!isPresent(descriptor) || (isCompositeFilterDescriptor(descriptor) && descriptor.filters.length === 0)) {
57
+ */ // tslint:enable:max-line-length
58
+ export const filterBy = (data, descriptor, preprocessors = {})=>{
59
+ if (!isPresent(descriptor) || isCompositeFilterDescriptor(descriptor) && descriptor.filters.length === 0) {
62
60
  return data;
63
61
  }
64
62
  return data.filter(compileFilter(normalizeFilters(descriptor), preprocessors));
65
63
  };
64
+
66
65
  //# sourceMappingURL=filter-expression.factory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter-expression.factory.js","sourceRoot":"","sources":["../../src/filtering/filter-expression.factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAA+C,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AACzH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,iCAAiC;AACjC;;;;;;;;;;;;;;;GAeG;AACH,gCAAgC;AAChC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAI,UAAqC,EAAE,gBAAkC,EAAE,EAAa,EAAE;IACvH,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjD,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC;IACtB,CAAC;IACD,OAAO,wBAAwB,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AAC/D,CAAC,CAAC;AAEF,iCAAiC;AACjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,gCAAgC;AAChC,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAI,IAAS,EAAE,UAAwD,EAAE,gBAAkC,EAAE,EAAO,EAAE;IAC1I,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,2BAA2B,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;QACzG,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;AACnF,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/filtering/filter-expression.factory.ts"],"sourcesContent":["import { isPresent } from '../utils';\nimport { CompositeFilterDescriptor, FilterDescriptor, isCompositeFilterDescriptor } from './filter-descriptor.interface';\nimport { normalizeFilters } from './filter.operators';\nimport { Predicate, Preprocessors } from '../common.interfaces';\nimport { transformCompositeFilter } from \"./filter-no-eval\";\n\n// tslint:disable:max-line-length\n/**\n * Creates a [`Predicate`]({% slug api_kendo-data-query_predicate %}) function for the specified [`CompositeFilterDescriptor`]({% slug api_kendo-data-query_compositefilterdescriptor %}).\n *\n * @param {CompositeFilterDescriptor} descriptor - The descriptor for which the predicate is created.\n * @returns {Predicate} - The created function instance.\n *\n * @example\n * ```ts-no-run\n * import { compileFilter } from '@progress/kendo-data-query';\n *\n * const data = [{ name: \"Pork\" }, { name: \"Pepper\" }, { name: \"Beef\" } ];\n * const predicate = compileFilter({ logic: \"and\", filters: [{ field: \"name\", operator: \"startswith\", value: \"P\" }] });\n * const result = data.filter(predicate);\n *\n * ```\n */\n// tslint:enable:max-line-length\nexport const compileFilter = <T>(descriptor: CompositeFilterDescriptor, preprocessors: Preprocessors<T> = {}): Predicate => {\n if (!descriptor || descriptor.filters.length === 0) {\n return () => true;\n }\n return transformCompositeFilter(descriptor, preprocessors);\n};\n\n// tslint:disable:max-line-length\n/**\n * Filters the provided array according to the specified [`CompositeFilterDescriptor`]({% slug api_kendo-data-query_compositefilterdescriptor %}).\n *\n * @param {T[]} data - The data that will be filtered.\n * @param {(CompositeFilterDescriptor | FilterDescriptor)} descriptor - The filter criteria that will be applied.\n * @returns {T[]} - The filtered data.\n *\n * @example\n * ```ts-no-run\n * import { filterBy } from '@progress/kendo-data-query';\n *\n * const data = [\n * { name: \"Pork\", category: \"Food\", subcategory: \"Meat\" },\n * { name: \"Pepper\", category: \"Food\", subcategory: \"Vegetables\" },\n * { name: \"Beef\", category: \"Food\", subcategory: \"Meat\" }\n * ];\n *\n * const result = filterBy(data, {\n * logic: 'and',\n * filters: [\n * { field: \"name\", operator: \"startswith\", value: \"p\", ignoreCase: true },\n * { field: \"subcategory\", operator: \"eq\", value: \"Meat\" },\n * ]\n * });\n *\n * // output:\n * // [{ \"name\": \"Pork\", \"category\": \"Food\", \"subcategory\": \"Meat\" }]\n * ```\n */\n// tslint:enable:max-line-length\nexport const filterBy = <T>(data: T[], descriptor: CompositeFilterDescriptor | FilterDescriptor, preprocessors: Preprocessors<T> = {}): T[] => {\n if (!isPresent(descriptor) || (isCompositeFilterDescriptor(descriptor) && descriptor.filters.length === 0)) {\n return data;\n }\n\n return data.filter(compileFilter(normalizeFilters(descriptor), preprocessors));\n};\n"],"names":["isPresent","isCompositeFilterDescriptor","normalizeFilters","transformCompositeFilter","compileFilter","descriptor","preprocessors","filters","length","filterBy","data","filter"],"mappings":"AAAA,SAASA,SAAS,QAAQ,WAAW;AACrC,SAAsDC,2BAA2B,QAAQ,gCAAgC;AACzH,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD,SAASC,wBAAwB,QAAQ,mBAAmB;AAE5D,iCAAiC;AACjC;;;;;;;;;;;;;;;CAeC,GACD,gCAAgC;AAChC,OAAO,MAAMC,gBAAgB,CAAIC,YAAuCC,gBAAkC,CAAC,CAAC;IACxG,IAAI,CAACD,cAAcA,WAAWE,OAAO,CAACC,MAAM,KAAK,GAAG;QAChD,OAAO,IAAM;IACjB;IACA,OAAOL,yBAAyBE,YAAYC;AAChD,EAAE;AAEF,iCAAiC;AACjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BC,GACD,gCAAgC;AAChC,OAAO,MAAMG,WAAW,CAAIC,MAAWL,YAA0DC,gBAAkC,CAAC,CAAC;IACjI,IAAI,CAACN,UAAUK,eAAgBJ,4BAA4BI,eAAeA,WAAWE,OAAO,CAACC,MAAM,KAAK,GAAI;QACxG,OAAOE;IACX;IAEA,OAAOA,KAAKC,MAAM,CAACP,cAAcF,iBAAiBG,aAAaC;AACnE,EAAE"}
@@ -3,56 +3,53 @@ import { getter } from "../accessor";
3
3
  import { isFunction, isPresent, isDate, isString, isBlank, isNumeric, isArray } from "../utils";
4
4
  const logic = {
5
5
  "or": {
6
- concat: (acc, fn) => a => acc(a) || fn(a),
7
- identity: () => false
6
+ concat: (acc, fn)=>(a)=>acc(a) || fn(a),
7
+ identity: ()=>false
8
8
  },
9
9
  "and": {
10
- concat: (acc, fn) => a => acc(a) && fn(a),
11
- identity: () => true
10
+ concat: (acc, fn)=>(a)=>acc(a) && fn(a),
11
+ identity: ()=>true
12
12
  }
13
13
  };
14
14
  const operatorsMap = {
15
- contains: (a, b) => (a || "").indexOf(b) >= 0,
16
- doesnotcontain: (a, b) => (a || "").indexOf(b) === -1,
17
- doesnotendwith: (a, b) => (a || "").indexOf(b, (a || "").length - (b || "").length) < 0,
18
- doesnotstartwith: (a, b) => (a || "").lastIndexOf(b, 0) === -1,
19
- endswith: (a, b) => (a || "").indexOf(b, (a || "").length - (b || "").length) >= 0,
20
- eq: (a, b) => a === b,
21
- gt: (a, b) => a > b,
22
- gte: (a, b) => a >= b,
23
- isempty: (a) => isBlank(a) || a === '',
24
- isnotempty: (a) => isPresent(a) && a !== '',
25
- isnotnull: (a) => isPresent(a),
26
- isnull: (a) => isBlank(a),
27
- lt: (a, b) => a < b,
28
- lte: (a, b) => a <= b,
29
- neq: (a, b) => a != b, // tslint:disable-line:triple-equals
30
- startswith: (a, b) => (a || "").lastIndexOf(b, 0) === 0,
31
- in: (a, b) => b.includes(a),
32
- notin: (a, b) => !b.includes(a),
33
- isinteger: (a) => isNumeric(a) && Math.round(a) === a,
34
- isfractional: (a) => isNumeric(a) && Math.round(a) !== a
15
+ contains: (a, b)=>(a || "").indexOf(b) >= 0,
16
+ doesnotcontain: (a, b)=>(a || "").indexOf(b) === -1,
17
+ doesnotendwith: (a, b)=>(a || "").indexOf(b, (a || "").length - (b || "").length) < 0,
18
+ doesnotstartwith: (a, b)=>(a || "").lastIndexOf(b, 0) === -1,
19
+ endswith: (a, b)=>(a || "").indexOf(b, (a || "").length - (b || "").length) >= 0,
20
+ eq: (a, b)=>a === b,
21
+ gt: (a, b)=>a > b,
22
+ gte: (a, b)=>a >= b,
23
+ isempty: (a)=>isBlank(a) || a === '',
24
+ isnotempty: (a)=>isPresent(a) && a !== '',
25
+ isnotnull: (a)=>isPresent(a),
26
+ isnull: (a)=>isBlank(a),
27
+ lt: (a, b)=>a < b,
28
+ lte: (a, b)=>a <= b,
29
+ neq: (a, b)=>a != b,
30
+ startswith: (a, b)=>(a || "").lastIndexOf(b, 0) === 0,
31
+ in: (a, b)=>b.includes(a),
32
+ notin: (a, b)=>!b.includes(a),
33
+ isinteger: (a)=>isNumeric(a) && Math.round(a) === a,
34
+ isfractional: (a)=>isNumeric(a) && Math.round(a) !== a
35
35
  };
36
36
  const dateRegExp = /^\/Date\((.*?)\)\/$/;
37
- const convertValue = (value, ignoreCase) => {
37
+ const convertValue = (value, ignoreCase)=>{
38
38
  if (value != null && isString(value)) {
39
39
  const date = dateRegExp.exec(value);
40
40
  if (date) {
41
41
  return new Date(+date[1]).getTime();
42
- }
43
- else if (ignoreCase) {
42
+ } else if (ignoreCase) {
44
43
  return value.toLowerCase();
45
44
  }
46
- }
47
- else if (value != null && isDate(value)) {
45
+ } else if (value != null && isDate(value)) {
48
46
  return value.getTime();
49
- }
50
- else if (value != null && isArray(value)) {
51
- return value.map(v => isString(v) ? v.toLowerCase() : v);
47
+ } else if (value != null && isArray(value)) {
48
+ return value.map((v)=>isString(v) ? v.toLowerCase() : v);
52
49
  }
53
50
  return value;
54
51
  };
55
- const typedGetter = (prop, value, ignoreCase) => {
52
+ const typedGetter = (prop, value, ignoreCase)=>{
56
53
  if (!isPresent(value)) {
57
54
  return prop;
58
55
  }
@@ -61,53 +58,48 @@ const typedGetter = (prop, value, ignoreCase) => {
61
58
  const date = dateRegExp.exec(value);
62
59
  if (date) {
63
60
  value = new Date(+date[1]);
64
- }
65
- else {
66
- acc = a => {
61
+ } else {
62
+ acc = (a)=>{
67
63
  const x = prop(a);
68
64
  if (typeof x === 'string' && ignoreCase) {
69
65
  return x.toLowerCase();
70
- }
71
- else {
66
+ } else {
72
67
  return isNumeric(x) ? x + "" : x;
73
68
  }
74
69
  };
75
70
  }
76
71
  }
77
72
  if (isDate(value)) {
78
- return a => {
73
+ return (a)=>{
79
74
  const x = acc(a);
80
75
  return isDate(x) ? x.getTime() : x;
81
76
  };
82
77
  }
83
78
  if (isArray(value) && ignoreCase) {
84
- acc = a => {
79
+ acc = (a)=>{
85
80
  const x = prop(a);
86
81
  return isString(x) ? x.toLowerCase() : x;
87
82
  };
88
83
  }
89
84
  return acc;
90
85
  };
91
- const transformFilter = ({ field, ignoreCase, value, operator }, preprocessors = {}) => {
92
- field = !isPresent(field) ? a => a : field;
86
+ const transformFilter = ({ field, ignoreCase, value, operator }, preprocessors = {})=>{
87
+ field = !isPresent(field) ? (a)=>a : field;
93
88
  ignoreCase = isPresent(ignoreCase) ? ignoreCase : true;
94
- const itemProp = typedGetter(isFunction(field) ? field : a => {
89
+ const itemProp = typedGetter(isFunction(field) ? field : (a)=>{
95
90
  const value = getter(field, true)(a);
96
91
  const preprocessor = preprocessors[field];
97
92
  return preprocessor ? preprocessor(value) : value;
98
93
  }, value, ignoreCase);
99
94
  value = convertValue(value, ignoreCase);
100
95
  const op = isFunction(operator) ? operator : operatorsMap[operator];
101
- return a => op(itemProp(a), value, ignoreCase);
96
+ return (a)=>op(itemProp(a), value, ignoreCase);
102
97
  };
103
98
  /**
104
99
  * @hidden
105
- */
106
- export const transformCompositeFilter = (filter, preprocessors = {}) => {
100
+ */ export const transformCompositeFilter = (filter, preprocessors = {})=>{
107
101
  const combiner = logic[filter.logic];
108
- return filter.filters
109
- .filter(isPresent)
110
- .map(x => isCompositeFilterDescriptor(x) ? transformCompositeFilter(x, preprocessors) : transformFilter(x, preprocessors))
111
- .reduce(combiner.concat, combiner.identity);
102
+ return filter.filters.filter(isPresent).map((x)=>isCompositeFilterDescriptor(x) ? transformCompositeFilter(x, preprocessors) : transformFilter(x, preprocessors)).reduce(combiner.concat, combiner.identity);
112
103
  };
104
+
113
105
  //# sourceMappingURL=filter-no-eval.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter-no-eval.js","sourceRoot":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CAAC;IAExC,MAAM,EAAE,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAS,QAAQ,CAAC,CAAC;IAE5E,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAI,MAAiC,EAAE,gBAAkC,EAAE,EAAa,EAAE;IAC9H,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrC,OAAO,MAAM,CAAC,OAAO;SAChB,MAAM,CAAC,SAAS,CAAC;SACjB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;SACzH,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACpD,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/filtering/filter-no-eval.ts"],"sourcesContent":["import { CompositeFilterDescriptor, FilterDescriptor, isCompositeFilterDescriptor } from \"./filter-descriptor.interface\";\nimport { Predicate, Preprocessors } from \"../common.interfaces\";\nimport { getter } from \"../accessor\";\nimport { isFunction, isPresent, isDate, isString, isBlank, isNumeric, isArray } from \"../utils\";\n\nconst logic = {\n \"or\": {\n concat: (acc, fn) => a => acc(a) || fn(a),\n identity: () => false\n },\n \"and\": {\n concat: (acc, fn) => a => acc(a) && fn(a),\n identity: () => true\n }\n};\n\nconst operatorsMap = {\n contains: (a, b) => (a || \"\").indexOf(b) >= 0,\n doesnotcontain: (a, b) => (a || \"\").indexOf(b) === -1,\n doesnotendwith: (a, b) => (a || \"\").indexOf(b, (a || \"\").length - (b || \"\").length) < 0,\n doesnotstartwith: (a: string, b: string): boolean => (a || \"\").lastIndexOf(b, 0) === -1,\n endswith: (a: string, b: string): boolean => (a || \"\").indexOf(b, (a || \"\").length - (b || \"\").length) >= 0,\n eq: (a, b) => a === b,\n gt: <T>(a: T, b: T): boolean => a > b,\n gte: <T>(a: T, b: T): boolean => a >= b,\n isempty: (a: any) => isBlank(a) || a === '',\n isnotempty: (a: any) => isPresent(a) && a !== '',\n isnotnull: (a: any) => isPresent(a),\n isnull: (a: any) => isBlank(a),\n lt: <T>(a: T, b: T): boolean => a < b,\n lte: <T>(a: T, b: T): boolean => a <= b,\n neq: <T>(a: T, b: T): boolean => a != b, // tslint:disable-line:triple-equals\n startswith: (a: string, b: string): boolean => (a || \"\").lastIndexOf(b, 0) === 0,\n in: <T>(a: T, b: T[]): boolean => b.includes(a),\n notin: <T>(a: T, b: T[]): boolean => !b.includes(a),\n isinteger: (a: any) => isNumeric(a) && Math.round(a) === a,\n isfractional: (a: any) => isNumeric(a) && Math.round(a) !== a\n};\n\nconst dateRegExp = /^\\/Date\\((.*?)\\)\\/$/;\n\nconst convertValue = (value, ignoreCase) => {\n if (value != null && isString(value)) {\n const date = dateRegExp.exec(value);\n if (date) {\n return new Date(+date[1]).getTime();\n } else if (ignoreCase) {\n return value.toLowerCase();\n }\n } else if (value != null && isDate(value)) {\n return value.getTime();\n } else if (value != null && isArray(value)) {\n return value.map(v => isString(v) ? v.toLowerCase() : v);\n }\n return value;\n};\n\n\nconst typedGetter = (prop, value, ignoreCase) => {\n if (!isPresent(value)) {\n return prop;\n }\n\n let acc = prop;\n\n if (isString(value)) {\n const date = dateRegExp.exec(value);\n if (date) {\n value = new Date(+date[1]);\n } else {\n acc = a => {\n const x = prop(a);\n if (typeof x === 'string' && ignoreCase) {\n return x.toLowerCase();\n } else {\n return isNumeric(x) ? x + \"\" : x;\n }\n };\n }\n }\n\n if (isDate(value)) {\n return a => {\n const x = acc(a);\n return isDate(x) ? x.getTime() : x;\n };\n }\n\n if(isArray(value) && ignoreCase){\n acc = a => {\n const x = prop(a);\n return isString(x) ? x.toLowerCase() : x;\n };\n }\n\n return acc;\n};\n\nconst transformFilter = <T>({ field, ignoreCase, value, operator }: FilterDescriptor, preprocessors: Preprocessors<T> = {}): Predicate => {\n field = !isPresent(field) ? a => a : field;\n\n ignoreCase = isPresent(ignoreCase) ? ignoreCase : true;\n\n const itemProp = typedGetter(\n isFunction(field) ? field : a => {\n const value = getter(<string>field, true)(a);\n const preprocessor = preprocessors[<string>field];\n return preprocessor ? preprocessor(value) : value;\n },\n value,\n ignoreCase\n );\n\n value = convertValue(value, ignoreCase);\n\n const op = isFunction(operator) ? operator : operatorsMap[<string>operator];\n\n return a => op(itemProp(a), value, ignoreCase);\n};\n\n/**\n * @hidden\n */\nexport const transformCompositeFilter = <T>(filter: CompositeFilterDescriptor, preprocessors: Preprocessors<T> = {}): Predicate => {\n const combiner = logic[filter.logic];\n return filter.filters\n .filter(isPresent)\n .map(x => isCompositeFilterDescriptor(x) ? transformCompositeFilter(x, preprocessors) : transformFilter(x, preprocessors))\n .reduce(combiner.concat, combiner.identity);\n};\n"],"names":["isCompositeFilterDescriptor","getter","isFunction","isPresent","isDate","isString","isBlank","isNumeric","isArray","logic","concat","acc","fn","a","identity","operatorsMap","contains","b","indexOf","doesnotcontain","doesnotendwith","length","doesnotstartwith","lastIndexOf","endswith","eq","gt","gte","isempty","isnotempty","isnotnull","isnull","lt","lte","neq","startswith","in","includes","notin","isinteger","Math","round","isfractional","dateRegExp","convertValue","value","ignoreCase","date","exec","Date","getTime","toLowerCase","map","v","typedGetter","prop","x","transformFilter","field","operator","preprocessors","itemProp","preprocessor","op","transformCompositeFilter","filter","combiner","filters","reduce"],"mappings":"AAAA,SAAsDA,2BAA2B,QAAQ,gCAAgC;AAEzH,SAASC,MAAM,QAAQ,cAAc;AACrC,SAASC,UAAU,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ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C,CAAC,CAAC;IAC/G,MAAMM,WAAWzD,KAAK,CAACwD,OAAOxD,KAAK,CAAC;IACpC,OAAOwD,OAAOE,OAAO,CAChBF,MAAM,CAAC9D,WACPiD,GAAG,CAACI,CAAAA,IAAKxD,4BAA4BwD,KAAKQ,yBAAyBR,GAAGI,iBAAiBH,gBAAgBD,GAAGI,gBAC1GQ,MAAM,CAACF,SAASxD,MAAM,EAAEwD,SAASpD,QAAQ;AAClD,EAAE"}
@@ -1,41 +1,41 @@
1
1
  import { isPresent, isString, isArray } from '../utils';
2
2
  import { isCompositeFilterDescriptor } from './filter-descriptor.interface';
3
- const operatorMap = (key) => ({
4
- "!=": "neq",
5
- "<": "lt",
6
- "<=": "lte",
7
- "==": "eq",
8
- ">": "gt",
9
- ">=": "gte",
10
- equal: "eq",
11
- equals: "eq",
12
- equalto: "eq",
13
- ge: "gte",
14
- greater: "gt",
15
- greaterthan: "gt",
16
- greaterthanequal: "gte",
17
- isempty: "isempty",
18
- isequalto: "eq",
19
- isgreaterthan: "gt",
20
- isgreaterthanorequalto: "gte",
21
- islessthan: "lt",
22
- islessthanorequalto: "lte",
23
- isnotempty: "isnotempty",
24
- isnotequalto: "neq",
25
- isnull: "isnull",
26
- le: "lte",
27
- less: "lt",
28
- lessthan: "lt",
29
- lessthanequal: "lte",
30
- ne: "neq",
31
- notequal: "neq",
32
- notequals: "neq",
33
- notequalto: "neq",
34
- notsubstringof: "doesnotcontain"
35
- }[key.toLowerCase()] || key);
36
- const normalizeOperator = (descriptor) => {
3
+ const operatorMap = (key)=>({
4
+ "!=": "neq",
5
+ "<": "lt",
6
+ "<=": "lte",
7
+ "==": "eq",
8
+ ">": "gt",
9
+ ">=": "gte",
10
+ equal: "eq",
11
+ equals: "eq",
12
+ equalto: "eq",
13
+ ge: "gte",
14
+ greater: "gt",
15
+ greaterthan: "gt",
16
+ greaterthanequal: "gte",
17
+ isempty: "isempty",
18
+ isequalto: "eq",
19
+ isgreaterthan: "gt",
20
+ isgreaterthanorequalto: "gte",
21
+ islessthan: "lt",
22
+ islessthanorequalto: "lte",
23
+ isnotempty: "isnotempty",
24
+ isnotequalto: "neq",
25
+ isnull: "isnull",
26
+ le: "lte",
27
+ less: "lt",
28
+ lessthan: "lt",
29
+ lessthanequal: "lte",
30
+ ne: "neq",
31
+ notequal: "neq",
32
+ notequals: "neq",
33
+ notequalto: "neq",
34
+ notsubstringof: "doesnotcontain"
35
+ })[key.toLowerCase()] || key;
36
+ const normalizeOperator = (descriptor)=>{
37
37
  if (descriptor.filters) {
38
- descriptor.filters = descriptor.filters.map(filter => {
38
+ descriptor.filters = descriptor.filters.map((filter)=>{
39
39
  const result = Object.assign({}, filter);
40
40
  if (!isCompositeFilterDescriptor(filter) && isString(filter.operator)) {
41
41
  result.operator = operatorMap(filter.operator);
@@ -47,10 +47,12 @@ const normalizeOperator = (descriptor) => {
47
47
  });
48
48
  }
49
49
  };
50
- const normalizeDescriptor = (descriptor) => {
50
+ const normalizeDescriptor = (descriptor)=>{
51
51
  if (!isCompositeFilterDescriptor(descriptor)) {
52
52
  return {
53
- filters: isArray(descriptor) ? descriptor : [descriptor],
53
+ filters: isArray(descriptor) ? descriptor : [
54
+ descriptor
55
+ ],
54
56
  logic: "and"
55
57
  };
56
58
  }
@@ -62,13 +64,13 @@ const normalizeDescriptor = (descriptor) => {
62
64
  *
63
65
  * @param {CompositeFilterDescriptor | FilterDescriptor} descriptor - The descriptor that will be normalized.
64
66
  * @returns {CompositeFilterDescriptor} - The normalized descriptor.
65
- */
66
- // tslint:enable:max-line-length
67
- export const normalizeFilters = (descriptor) => {
67
+ */ // tslint:enable:max-line-length
68
+ export const normalizeFilters = (descriptor)=>{
68
69
  if (isPresent(descriptor)) {
69
70
  descriptor = normalizeDescriptor(descriptor);
70
71
  normalizeOperator(descriptor);
71
72
  }
72
73
  return descriptor;
73
74
  };
75
+
74
76
  //# sourceMappingURL=filter.operators.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"filter.operators.js","sourceRoot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,MAAM,GAAQ,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;YAC9C,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACpE,MAAM,CAAC,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACnD,CAAC;YACD,IAAI,2BAA2B,CAAC,MAAM,CAAC,EAAE,CAAC;gBACtC,iBAAiB,CAAC,MAAM,CAAC,CAAC;YAC9B,CAAC;YAED,OAAO,MAAM,CAAC;QAClB,CAAC,CAAC,CAAC;IACP,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,UAAU,EAA6B,EAAE;IAClE,IAAI,CAAC,2BAA2B,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3C,OAAO;YACH,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;YACxD,KAAK,EAAE,KAAK;SACf,CAAC;IACN,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;AACzC,CAAC,CAAC;AAEF,iCAAiC;AACjC;;;;;GAKG;AACH,gCAAgC;AAChC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,UAAwD,EAA6B,EAAE;IACpH,IAAI,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;QACxB,UAAU,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAC7C,iBAAiB,CAA4B,UAAU,CAAC,CAAC;IAC7D,CAAC;IACD,OAAkC,UAAU,CAAC;AACjD,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/filtering/filter.operators.ts"],"sourcesContent":["import { isPresent, isString, isArray } from '../utils';\nimport { CompositeFilterDescriptor, FilterDescriptor, isCompositeFilterDescriptor } from './filter-descriptor.interface';\n\nconst operatorMap = (key) => ({\n \"!=\": \"neq\",\n \"<\": \"lt\",\n \"<=\": \"lte\",\n \"==\": \"eq\",\n \">\": \"gt\",\n \">=\": \"gte\",\n equal: \"eq\",\n equals: \"eq\",\n equalto: \"eq\",\n ge: \"gte\",\n greater: \"gt\",\n greaterthan: \"gt\",\n greaterthanequal: \"gte\",\n isempty: \"isempty\",\n isequalto: \"eq\",\n isgreaterthan: \"gt\",\n isgreaterthanorequalto: \"gte\",\n islessthan: \"lt\",\n islessthanorequalto: \"lte\",\n isnotempty: \"isnotempty\",\n isnotequalto: \"neq\",\n isnull: \"isnull\",\n le: \"lte\",\n less: \"lt\",\n lessthan: \"lt\",\n lessthanequal: \"lte\",\n ne: \"neq\",\n notequal: \"neq\",\n notequals: \"neq\",\n notequalto: \"neq\",\n notsubstringof: \"doesnotcontain\"\n}[key.toLowerCase()] || key);\n\nconst normalizeOperator = (descriptor: CompositeFilterDescriptor) => {\n if (descriptor.filters) {\n descriptor.filters = descriptor.filters.map(filter => {\n const result: any = Object.assign({}, filter);\n if (!isCompositeFilterDescriptor(filter) && isString(filter.operator)) {\n result.operator = operatorMap(filter.operator);\n }\n if (isCompositeFilterDescriptor(filter)) {\n normalizeOperator(result);\n }\n\n return result;\n });\n }\n};\n\nconst normalizeDescriptor = (descriptor): CompositeFilterDescriptor => {\n if (!isCompositeFilterDescriptor(descriptor)) {\n return {\n filters: isArray(descriptor) ? descriptor : [descriptor],\n logic: \"and\"\n };\n }\n return Object.assign({}, descriptor);\n};\n\n// tslint:disable:max-line-length\n/**\n * Converts a [`FilterDescriptor`]({% slug api_kendo-data-query_filterdescriptor %}) into a [`CompositeFilterDescriptor`]({% slug api_kendo-data-query_compositefilterdescriptor %}). If a `CompositeFilterDescriptor` is passed, no modifications will be made.\n *\n * @param {CompositeFilterDescriptor | FilterDescriptor} descriptor - The descriptor that will be normalized.\n * @returns {CompositeFilterDescriptor} - The normalized descriptor.\n */\n// tslint:enable:max-line-length\nexport const normalizeFilters = (descriptor: CompositeFilterDescriptor | FilterDescriptor): CompositeFilterDescriptor => {\n if (isPresent(descriptor)) {\n descriptor = normalizeDescriptor(descriptor);\n normalizeOperator(<CompositeFilterDescriptor>descriptor);\n }\n return <CompositeFilterDescriptor>descriptor;\n};\n"],"names":["isPresent","isString","isArray","isCompositeFilterDescriptor","operatorMap","key","equal","equals","equalto","ge","greater","greaterthan","greaterthanequal","isempty","isequalto","isgreaterthan","isgreaterthanorequalto","islessthan","islessthanorequalto","isnotempty","isnotequalto","isnull","le","less","lessthan","lessthanequal","ne","notequal","notequals","notequalto","notsubstringof","toLowerCase","normalizeOperator","descriptor","filters","map","filter","result","Object","assign","operator","normalizeDescriptor","logic","normalizeFilters"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,EAAEC,OAAO,QAAQ,WAAW;AACxD,SAAsDC,2BAA2B,QAAQ,gCAAgC;AAEzH,MAAMC,cAAc,CAACC,MAAS,CAAA;QAC1B,MAAM;QACN,KAAK;QACL,MAAM;QACN,MAAM;QACN,KAAK;QACL,MAAM;QACNC,OAAO;QACPC,QAAQ;QACRC,SAAS;QACTC,IAAI;QACJC,SAAS;QACTC,aAAa;QACbC,kBAAkB;QAClBC,SAAS;QACTC,WAAW;QACXC,eAAe;QACfC,wBAAwB;QACxBC,YAAY;QACZC,qBAAqB;QACrBC,YAAY;QACZC,cAAc;QACdC,QAAQ;QACRC,IAAI;QACJC,MAAM;QACNC,UAAU;QACVC,eAAe;QACfC,IAAI;QACJC,UAAU;QACVC,WAAW;QACXC,YAAY;QACZC,gBAAgB;IACpB,CAAA,CAAC,CAACzB,IAAI0B,WAAW,GAAG,IAAI1B;AAExB,MAAM2B,oBAAoB,CAACC;IACvB,IAAIA,WAAWC,OAAO,EAAE;QACpBD,WAAWC,OAAO,GAAGD,WAAWC,OAAO,CAACC,GAAG,CAACC,CAAAA;YACxC,MAAMC,SAAcC,OAAOC,MAAM,CAAC,CAAC,GAAGH;YACtC,IAAI,CAACjC,4BAA4BiC,WAAWnC,SAASmC,OAAOI,QAAQ,GAAG;gBACnEH,OAAOG,QAAQ,GAAGpC,YAAYgC,OAAOI,QAAQ;YACjD;YACA,IAAIrC,4BAA4BiC,SAAS;gBACrCJ,kBAAkBK;YACtB;YAEA,OAAOA;QACX;IACJ;AACJ;AAEA,MAAMI,sBAAsB,CAACR;IACzB,IAAI,CAAC9B,4BAA4B8B,aAAa;QAC1C,OAAO;YACHC,SAAShC,QAAQ+B,cAAcA,aAAa;gBAACA;aAAW;YACxDS,OAAO;QACX;IACJ;IACA,OAAOJ,OAAOC,MAAM,CAAC,CAAC,GAAGN;AAC7B;AAEA,iCAAiC;AACjC;;;;;CAKC,GACD,gCAAgC;AAChC,OAAO,MAAMU,mBAAmB,CAACV;IAC7B,IAAIjC,UAAUiC,aAAa;QACvBA,aAAaQ,oBAAoBR;QACjCD,kBAA6CC;IACjD;IACA,OAAkCA;AACtC,EAAE"}
package/dist/funcs.js CHANGED
@@ -1,18 +1,15 @@
1
1
  /**
2
2
  * @hidden
3
- */
4
- export const ifElse = (predicate, right, left) => value => predicate(value) ? right(value) : left(value);
3
+ */ export const ifElse = (predicate, right, left)=>(value)=>predicate(value) ? right(value) : left(value);
5
4
  /**
6
5
  * @hidden
7
6
  * Performs the right-to-left function composition. Functions should have a unary.
8
- */
9
- export const compose = (...args) => (data) => args.reduceRight((acc, curr) => curr(acc), data);
7
+ */ export const compose = (...args)=>(data)=>args.reduceRight((acc, curr)=>curr(acc), data);
10
8
  /**
11
9
  * @hidden
12
- */
13
- export const constant = x => () => x;
10
+ */ export const constant = (x)=>()=>x;
14
11
  /**
15
12
  * @hidden
16
- */
17
- export const identity = x => x;
13
+ */ export const identity = (x)=>x;
14
+
18
15
  //# sourceMappingURL=funcs.js.map
package/dist/funcs.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"funcs.js","sourceRoot":"","sources":["../src/funcs.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAEzG;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;AAE/F;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../src/funcs.ts"],"sourcesContent":["/**\n * @hidden\n */\nexport const ifElse = (predicate, right, left) => value => predicate(value) ? right(value) : left(value);\n\n/**\n * @hidden\n * Performs the right-to-left function composition. Functions should have a unary.\n */\nexport const compose = (...args) => (data) => args.reduceRight((acc, curr) => curr(acc), data);\n\n/**\n * @hidden\n */\nexport const constant = x => () => x;\n\n/**\n * @hidden\n */\nexport const identity = x => x;\n"],"names":["ifElse","predicate","right","left","value","compose","args","data","reduceRight","acc","curr","constant","x","identity"],"mappings":"AAAA;;CAEC,GACD,OAAO,MAAMA,SAAS,CAACC,WAAWC,OAAOC,OAASC,CAAAA,QAASH,UAAUG,SAASF,MAAME,SAASD,KAAKC,OAAO;AAEzG;;;CAGC,GACD,OAAO,MAAMC,UAAU,CAAC,GAAGC,OAAS,CAACC,OAASD,KAAKE,WAAW,CAAC,CAACC,KAAKC,OAASA,KAAKD,MAAMF,MAAM;AAE/F;;CAEC,GACD,OAAO,MAAMI,WAAWC,CAAAA,IAAK,IAAMA,EAAE;AAErC;;CAEC,GACD,OAAO,MAAMC,WAAWD,CAAAA,IAAKA,EAAE"}