@servicetitan/data-query 31.2.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
@@ -1,5 +1,5 @@
1
1
  import { exec, map, aggregatesCombinator, expandAggregates } from '../transducers';
2
- const identity = map(x => x);
2
+ const identity = map((x)=>x);
3
3
  // tslint:disable:max-line-length
4
4
  /**
5
5
  * Applies the specified [`AggregateDescriptors`]({% slug api_kendo-data-query_aggregatedescriptor %}) to the data. Returns an [`AggregateResult`]({% slug api_kendo-data-query_aggregateresult %}) instance.
@@ -28,9 +28,8 @@ const identity = map(x => x);
28
28
  * @param {any} transformers - For internal use.
29
29
  * @returns {AggregateResult} - The aggregated result.
30
30
  * For more information, refer to the [`aggregateresult`]({% slug api_kendo-data-query_aggregateresult %}) configuration.
31
- */
32
- // tslint:enable:max-line-length
33
- export const aggregateBy = (data, descriptors = [], preprocessors = {}, transformers = identity) => {
31
+ */ // tslint:enable:max-line-length
32
+ export const aggregateBy = (data, descriptors = [], preprocessors = {}, transformers = identity)=>{
34
33
  const initialValue = {};
35
34
  if (!descriptors.length) {
36
35
  return initialValue;
@@ -38,4 +37,5 @@ export const aggregateBy = (data, descriptors = [], preprocessors = {}, transfor
38
37
  const result = exec(transformers(aggregatesCombinator(descriptors, preprocessors)), initialValue, data);
39
38
  return expandAggregates(result);
40
39
  };
40
+
41
41
  //# sourceMappingURL=aggregate.operators.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"aggregate.operators.js","sourceRoot":"","sources":["../../src/grouping/aggregate.operators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,oBAAoB,EAAE,gBAAgB,EAAmB,MAAM,gBAAgB,CAAC;AAqBpG,MAAM,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAE7B,iCAAiC;AACjC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,gCAAgC;AAChC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAI,IAAS,EAAE,cAAqC,EAAE,EAAE,gBAAkC,EAAE,EAAE,eAAoD,QAAQ,EAAmB,EAAE;IACtM,MAAM,YAAY,GAAG,EAAE,CAAC;IAExB,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;QACtB,OAAO,YAAY,CAAC;IACxB,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,oBAAoB,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;IACxG,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;AACpC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/grouping/aggregate.operators.ts"],"sourcesContent":["import { exec, map, aggregatesCombinator, expandAggregates, AggregateResult } from '../transducers';\nimport { Combinator, Transformer, Preprocessors } from '../common.interfaces';\n\n/**\n * The aggregate operation.\n *\n * For more information, refer to the [`aggregateBy`]({% slug api_kendo-data-query_aggregateby %}) method.\n */\nexport interface AggregateDescriptor {\n\n /**\n * The name of the record field on which the function will be executed.\n */\n field: string;\n\n /**\n * The aggregate function that will be calculated.\n */\n aggregate: 'count' | 'sum' | 'average' | 'min' | 'max' | 'count_distinct';\n}\n\nconst identity = map(x => x);\n\n// tslint:disable:max-line-length\n/**\n * Applies the specified [`AggregateDescriptors`]({% slug api_kendo-data-query_aggregatedescriptor %}) to the data. Returns an [`AggregateResult`]({% slug api_kendo-data-query_aggregateresult %}) instance.\n *\n * @example\n * ```ts-no-run\n * const data = [\n * { unitPrice: 23, unitsInStock: 21 },\n * { unitPrice: 10, unitsInStock: 12 },\n * { unitPrice: 20, unitsInStock: 33 }\n * ];\n *\n * const result = aggregateBy(data, [\n * { aggregate: \"sum\", field: \"unitPrice\" },\n * { aggregate: \"sum\", field: \"unitsInStock\" }\n * ]);\n *\n * //output:\n * // {\n * // \"unitPrice\": { \"sum\": 53 },\n * // \"unitsInStock\": { \"sum\": 66 }\n * // }\n * ```\n * @param {T[]} data - The data on which the calculation will be executed.\n * @param {AggregateDescriptor[]} descriptors - The aggregate operations that will be executed.\n * @param {any} transformers - For internal use.\n * @returns {AggregateResult} - The aggregated result.\n * For more information, refer to the [`aggregateresult`]({% slug api_kendo-data-query_aggregateresult %}) configuration.\n */\n// tslint:enable:max-line-length\nexport const aggregateBy = <T>(data: T[], descriptors: AggregateDescriptor[] = [], preprocessors: Preprocessors<T> = {}, transformers: (reduce: Combinator) => Transformer = identity): AggregateResult => {\n const initialValue = {};\n\n if (!descriptors.length) {\n return initialValue;\n }\n\n const result = exec(transformers(aggregatesCombinator(descriptors, preprocessors)), initialValue, data);\n return expandAggregates(result);\n};\n"],"names":["exec","map","aggregatesCombinator","expandAggregates","identity","x","aggregateBy","data","descriptors","preprocessors","transformers","initialValue","length","result"],"mappings":"AAAA,SAASA,IAAI,EAAEC,GAAG,EAAEC,oBAAoB,EAAEC,gBAAgB,QAAyB,iBAAiB;AAqBpG,MAAMC,WAAWH,IAAII,CAAAA,IAAKA;AAE1B,iCAAiC;AACjC;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BC,GACD,gCAAgC;AAChC,OAAO,MAAMC,cAAc,CAAIC,MAAWC,cAAqC,EAAE,EAAEC,gBAAkC,CAAC,CAAC,EAAEC,eAAoDN,QAAQ;IACjL,MAAMO,eAAe,CAAC;IAEtB,IAAI,CAACH,YAAYI,MAAM,EAAE;QACrB,OAAOD;IACX;IAEA,MAAME,SAASb,KAAKU,aAAaR,qBAAqBM,aAAaC,iBAAiBE,cAAcJ;IAClG,OAAOJ,iBAAiBU;AAC5B,EAAE"}
@@ -1,3 +1,5 @@
1
- export {};
2
- // tslint:enable:max-line-length
1
+ /**
2
+ * The result of the group operation.
3
+ */ export { }; // tslint:enable:max-line-length
4
+
3
5
  //# sourceMappingURL=group-descriptor.interface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"group-descriptor.interface.js","sourceRoot":"","sources":["../../src/grouping/group-descriptor.interface.ts"],"names":[],"mappings":";AA2CA,gCAAgC"}
1
+ {"version":3,"sources":["../../src/grouping/group-descriptor.interface.ts"],"sourcesContent":["import { AggregateDescriptor } from './aggregate.operators';\nimport { AggregateResult } from '../transducers';\n\n// tslint:disable:max-line-length\n/**\n * The group descriptor used by the `groupBy` method.\n */\nexport interface GroupDescriptor {\n /**\n * The data item field by which the data will be grouped.\n */\n field: string;\n /**\n * The sort order of the group.\n */\n dir?: 'asc' | 'desc';\n /**\n * The aggregates which are calculated during grouping.\n */\n aggregates?: Array<AggregateDescriptor>;\n}\n\n/**\n * The result of the group operation.\n */\nexport interface GroupResult<T = Object> {\n /**\n * Contains either the subgroups, or the data items.\n */\n items: T[] | GroupResult<T>[];\n /**\n * The aggregated values for the group. An [`AggregateResult`]({% slug api_kendo-data-query_aggregateresult %}) instance.\n */\n aggregates: AggregateResult;\n /**\n * The field by which the data items are grouped.\n */\n field: string;\n /**\n * The group key.\n */\n value: any;\n}\n// tslint:enable:max-line-length\n"],"names":[],"mappings":"AAsBA;;CAEC,GACD,WAiBC,CACD,gCAAgC"}
@@ -4,12 +4,15 @@ import { aggregateBy } from './aggregate.operators';
4
4
  import { filterBy } from '../filtering/filter-expression.factory';
5
5
  /**
6
6
  * @hidden
7
- */
8
- export const normalizeGroups = (descriptors) => {
9
- descriptors = isArray(descriptors) ? descriptors : [descriptors];
10
- return descriptors.map(x => Object.assign({ dir: "asc" }, x));
7
+ */ export const normalizeGroups = (descriptors)=>{
8
+ descriptors = isArray(descriptors) ? descriptors : [
9
+ descriptors
10
+ ];
11
+ return descriptors.map((x)=>Object.assign({
12
+ dir: "asc"
13
+ }, x));
11
14
  };
12
- const identity = map(x => x);
15
+ const identity = map((x)=>x);
13
16
  /**
14
17
  * Groups the provided data according to the specified descriptors.
15
18
  *
@@ -32,8 +35,7 @@ const identity = map(x => x);
32
35
  *
33
36
  * const result = groupBy(data, [{ field: "subcategory" }]);
34
37
  * ```
35
- */
36
- export const groupBy = (data, descriptors = [], preprocessors = {}, transformers = identity, originalData = data) => {
38
+ */ export const groupBy = (data, descriptors = [], preprocessors = {}, transformers = identity, originalData = data)=>{
37
39
  descriptors = normalizeGroups(descriptors);
38
40
  if (!descriptors.length) {
39
41
  return data;
@@ -42,8 +44,8 @@ export const groupBy = (data, descriptors = [], preprocessors = {}, transformers
42
44
  const initialValue = {};
43
45
  const view = exec(transformers(groupCombinator(descriptor.field, preprocessors)), initialValue, data);
44
46
  const result = [];
45
- Object.keys(view).forEach(field => {
46
- Object.keys(view[field]).forEach(value => {
47
+ Object.keys(view).forEach((field)=>{
48
+ Object.keys(view[field]).forEach((value)=>{
47
49
  const group = view[field][value];
48
50
  let aggregateResult = {};
49
51
  let filteredData = originalData;
@@ -59,13 +61,12 @@ export const groupBy = (data, descriptors = [], preprocessors = {}, transformers
59
61
  result[group.__position] = {
60
62
  aggregates: aggregateResult,
61
63
  field: field,
62
- items: descriptors.length > 1 ?
63
- groupBy(group.items, descriptors.slice(1), preprocessors, identity, filteredData)
64
- : group.items,
64
+ items: descriptors.length > 1 ? groupBy(group.items, descriptors.slice(1), preprocessors, identity, filteredData) : group.items,
65
65
  value: group.value
66
66
  };
67
67
  });
68
68
  });
69
69
  return result;
70
70
  };
71
+
71
72
  //# sourceMappingURL=group.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B,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/grouping/group.operators.ts"],"sourcesContent":["import { GroupDescriptor, GroupResult } from './group-descriptor.interface';\nimport { exec, map, groupCombinator } from '../transducers';\nimport { isArray, isPresent } from '../utils';\nimport { aggregateBy } from './aggregate.operators';\nimport { filterBy } from '../filtering/filter-expression.factory';\nimport { Reducer, Preprocessors } from '../common.interfaces';\n\n/**\n * @hidden\n */\nexport const normalizeGroups = (descriptors) => {\n descriptors = isArray(descriptors) ? descriptors : [descriptors];\n return descriptors.map(x => Object.assign({ dir: \"asc\" }, x));\n};\n\nconst identity: Reducer = map(x => x);\n\n/**\n * Groups the provided data according to the specified descriptors.\n *\n * @param {Array} data - The data that will be grouped.\n * @param {GroupDescriptor[]} descriptors - The descriptors.\n * @param {any} transformers - For internal use.\n * @param {Array} originalData - For internal use.\n * @returns {(Array<GroupResult<T>> | T[])} - The grouped data.\n *\n * @example\n * ```ts-no-run\n *\n * import { groupBy } 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 = groupBy(data, [{ field: \"subcategory\" }]);\n * ```\n */\nexport const groupBy = <T>(\n data: T[],\n descriptors: GroupDescriptor[] = [],\n preprocessors: Preprocessors<T> = {},\n transformers = identity,\n originalData: T[] = data\n): Array<GroupResult> | T[] => {\n\n descriptors = normalizeGroups(descriptors);\n\n if (!descriptors.length) {\n return data;\n }\n\n const descriptor = descriptors[0];\n const initialValue = {};\n\n const view = exec(transformers(groupCombinator(descriptor.field, preprocessors)), initialValue, data);\n\n const result = [];\n\n Object.keys(view).forEach(field => {\n Object.keys(view[field]).forEach(value => {\n const group = view[field][value];\n\n let aggregateResult = {};\n let filteredData = originalData;\n\n if (isPresent(descriptor.aggregates)) {\n\n filteredData = filterBy(originalData, {\n field: descriptor.field,\n ignoreCase: false,\n operator: 'eq',\n value: group.value\n }, preprocessors);\n\n aggregateResult = aggregateBy(filteredData, descriptor.aggregates, preprocessors);\n }\n\n result[group.__position] = {\n aggregates: aggregateResult,\n field: field,\n items: descriptors.length > 1 ?\n groupBy(group.items, descriptors.slice(1), preprocessors, identity, filteredData)\n : group.items,\n value: group.value\n };\n });\n });\n return result;\n};\n"],"names":["exec","map","groupCombinator","isArray","isPresent","aggregateBy","filterBy","normalizeGroups","descriptors","x","Object","assign","dir","identity","groupBy","data","preprocessors","transformers","originalData","length","descriptor","initialValue","view","field","result","keys","forEach","value","group","aggregateResult","filteredData","aggregates","ignoreCase","operator","__position","items","slice"],"mappings":"AACA,SAASA,IAAI,EAAEC,GAAG,EAAEC,eAAe,QAAQ,iBAAiB;AAC5D,SAASC,OAAO,EAAEC,SAAS,QAAQ,WAAW;AAC9C,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,QAAQ,QAAQ,yCAAyC;AAGlE;;CAEC,GACD,OAAO,MAAMC,kBAAkB,CAACC;IAC5BA,cAAcL,QAAQK,eAAeA,cAAc;QAACA;KAAY;IAChE,OAAOA,YAAYP,GAAG,CAACQ,CAAAA,IAAKC,OAAOC,MAAM,CAAC;YAAEC,KAAK;QAAM,GAAGH;AAC9D,EAAE;AAEF,MAAMI,WAAoBZ,IAAIQ,CAAAA,IAAKA;AAEnC;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,OAAO,MAAMK,UAAU,CACnBC,MACAP,cAAiC,EAAE,EACnCQ,gBAAkC,CAAC,CAAC,EACpCC,eAAeJ,QAAQ,EACvBK,eAAoBH,IAAI;IAGxBP,cAAcD,gBAAgBC;IAE9B,IAAI,CAACA,YAAYW,MAAM,EAAE;QACrB,OAAOJ;IACX;IAEA,MAAMK,aAAaZ,WAAW,CAAC,EAAE;IACjC,MAAMa,eAAe,CAAC;IAEtB,MAAMC,OAAOtB,KAAKiB,aAAaf,gBAAgBkB,WAAWG,KAAK,EAAEP,iBAAiBK,cAAcN;IAEhG,MAAMS,SAAS,EAAE;IAEjBd,OAAOe,IAAI,CAACH,MAAMI,OAAO,CAACH,CAAAA;QACtBb,OAAOe,IAAI,CAACH,IAAI,CAACC,MAAM,EAAEG,OAAO,CAACC,CAAAA;YAC7B,MAAMC,QAAQN,IAAI,CAACC,MAAM,CAACI,MAAM;YAEhC,IAAIE,kBAAkB,CAAC;YACvB,IAAIC,eAAeZ;YAEnB,IAAId,UAAUgB,WAAWW,UAAU,GAAG;gBAElCD,eAAexB,SAASY,cAAc;oBAClCK,OAAOH,WAAWG,KAAK;oBACvBS,YAAY;oBACZC,UAAU;oBACVN,OAAOC,MAAMD,KAAK;gBACtB,GAAGX;gBAEHa,kBAAkBxB,YAAYyB,cAAcV,WAAWW,UAAU,EAAEf;YACvE;YAEAQ,MAAM,CAACI,MAAMM,UAAU,CAAC,GAAG;gBACvBH,YAAYF;gBACZN,OAAOA;gBACPY,OAAO3B,YAAYW,MAAM,GAAG,IACxBL,QAAQc,MAAMO,KAAK,EAAE3B,YAAY4B,KAAK,CAAC,IAAIpB,eAAeH,UAAUiB,gBAClEF,MAAMO,KAAK;gBACjBR,OAAOC,MAAMD,KAAK;YACtB;QACJ;IACJ;IACA,OAAOH;AACX,EAAE"}
package/dist/index.js CHANGED
@@ -1,14 +1,21 @@
1
- export { isCompositeFilterDescriptor } from './filtering/filter-descriptor.interface';
1
+ export { SortDescriptor } from './sort-descriptor';
2
+ export { GroupDescriptor, GroupResult } from './grouping/group-descriptor.interface';
3
+ export { FilterDescriptor, CompositeFilterDescriptor, isCompositeFilterDescriptor } from './filtering/filter-descriptor.interface';
2
4
  export { toODataString } from './odata.operators';
3
- export { toDataSourceRequestString, toDataSourceRequest } from './mvc/operators';
4
- export { translateDataSourceResultGroups, translateAggregateResults } from './mvc/deserialization';
5
+ export { toDataSourceRequestString, DataSourceRequestState, toDataSourceRequest } from './mvc/operators';
6
+ export { translateDataSourceResultGroups, ServerGroupResult, translateAggregateResults } from './mvc/deserialization';
7
+ export { State } from './state';
5
8
  export { orderBy, process, distinct } from './array.operators';
6
9
  export { getter } from './accessor';
7
10
  export { filterBy, compileFilter } from './filtering/filter-expression.factory';
8
11
  export { groupBy } from './grouping/group.operators';
9
- export { composeSortDescriptors } from './sorting/sort-array.operator';
12
+ export { Comparer, composeSortDescriptors } from './sorting/sort-array.operator';
10
13
  export { normalizeFilters } from './filtering/filter.operators';
11
14
  export { normalizeGroups } from './grouping/group.operators';
12
- export { aggregateBy } from './grouping/aggregate.operators';
13
- export { InMemoryDataSource, AsyncDataSource } from './data-source';
15
+ export { DataResult } from './data-result.interface';
16
+ export { aggregateBy, AggregateDescriptor } from './grouping/aggregate.operators';
17
+ export { AggregateResult } from './transducers';
18
+ export { Preprocessors } from './common.interfaces';
19
+ export { IdType, DataSource, InMemoryDataSource, AsyncDataSource } from './data-source';
20
+
14
21
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAA+C,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACnI,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAA0B,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACzG,OAAO,EAAE,+BAA+B,EAAqB,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAEtH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAY,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,WAAW,EAAuB,MAAM,gCAAgC,CAAC;AAGlF,OAAO,EAAsB,kBAAkB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { SortDescriptor } from './sort-descriptor';\nexport { GroupDescriptor, GroupResult } from './grouping/group-descriptor.interface';\nexport { FilterDescriptor, CompositeFilterDescriptor, isCompositeFilterDescriptor } from './filtering/filter-descriptor.interface';\nexport { toODataString } from './odata.operators';\nexport { toDataSourceRequestString, DataSourceRequestState, toDataSourceRequest } from './mvc/operators';\nexport { translateDataSourceResultGroups, ServerGroupResult, translateAggregateResults } from './mvc/deserialization';\nexport { State } from './state';\nexport { orderBy, process, distinct } from './array.operators';\nexport { getter } from './accessor';\nexport { filterBy, compileFilter } from './filtering/filter-expression.factory';\nexport { groupBy } from './grouping/group.operators';\nexport { Comparer, composeSortDescriptors } from './sorting/sort-array.operator';\nexport { normalizeFilters } from './filtering/filter.operators';\nexport { normalizeGroups } from './grouping/group.operators';\nexport { DataResult } from './data-result.interface';\nexport { aggregateBy, AggregateDescriptor } from './grouping/aggregate.operators';\nexport { AggregateResult } from './transducers';\nexport { Preprocessors } from './common.interfaces';\nexport { IdType, DataSource, InMemoryDataSource, AsyncDataSource } from './data-source'\n"],"names":["SortDescriptor","GroupDescriptor","GroupResult","FilterDescriptor","CompositeFilterDescriptor","isCompositeFilterDescriptor","toODataString","toDataSourceRequestString","DataSourceRequestState","toDataSourceRequest","translateDataSourceResultGroups","ServerGroupResult","translateAggregateResults","State","orderBy","process","distinct","getter","filterBy","compileFilter","groupBy","Comparer","composeSortDescriptors","normalizeFilters","normalizeGroups","DataResult","aggregateBy","AggregateDescriptor","AggregateResult","Preprocessors","IdType","DataSource","InMemoryDataSource","AsyncDataSource"],"mappings":"AAAA,SAASA,cAAc,QAAQ,oBAAoB;AACnD,SAASC,eAAe,EAAEC,WAAW,QAAQ,wCAAwC;AACrF,SAASC,gBAAgB,EAAEC,yBAAyB,EAAEC,2BAA2B,QAAQ,0CAA0C;AACnI,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,yBAAyB,EAAEC,sBAAsB,EAAEC,mBAAmB,QAAQ,kBAAkB;AACzG,SAASC,+BAA+B,EAAEC,iBAAiB,EAAEC,yBAAyB,QAAQ,wBAAwB;AACtH,SAASC,KAAK,QAAQ,UAAU;AAChC,SAASC,OAAO,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AAC/D,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,QAAQ,EAAEC,aAAa,QAAQ,wCAAwC;AAChF,SAASC,OAAO,QAAQ,6BAA6B;AACrD,SAASC,QAAQ,EAAEC,sBAAsB,QAAQ,gCAAgC;AACjF,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SAASC,eAAe,QAAQ,6BAA6B;AAC7D,SAASC,UAAU,QAAQ,0BAA0B;AACrD,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,iCAAiC;AAClF,SAASC,eAAe,QAAQ,gBAAgB;AAChD,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAASC,MAAM,EAAEC,UAAU,EAAEC,kBAAkB,EAAEC,eAAe,QAAQ,gBAAe"}
@@ -1,50 +1,49 @@
1
1
  import { isPresent } from '../utils';
2
2
  import { compose } from '../funcs';
3
3
  // tslint:enable:max-line-length
4
- const set = (field, target, value) => {
4
+ const set = (field, target, value)=>{
5
5
  target[field] = value;
6
6
  return target;
7
7
  };
8
- const toCamelCase = str => str.replace(/(^[A-Z])/g, (_, g1) => g1.toLowerCase());
9
- const prop = (fieldName) => (obj) => {
10
- const value = obj[fieldName];
11
- if (isPresent(value)) {
12
- return value;
13
- }
14
- return obj[toCamelCase(fieldName)];
15
- };
8
+ const toCamelCase = (str)=>str.replace(/(^[A-Z])/g, (_, g1)=>g1.toLowerCase());
9
+ const prop = (fieldName)=>(obj)=>{
10
+ const value = obj[fieldName];
11
+ if (isPresent(value)) {
12
+ return value;
13
+ }
14
+ return obj[toCamelCase(fieldName)];
15
+ };
16
16
  const member = prop("Member");
17
17
  const aggregateMethodName = prop("AggregateMethodName");
18
18
  const value = prop("Value");
19
- const convert = mapper => values => Object.keys(values).reduce(mapper.bind(null, values), {});
20
- const translateAggregate = convert((source, acc, field) => set(field.toLowerCase(), acc, source[field]));
21
- const translateAggregates = convert((source, acc, field) => set(field, acc, translateAggregate(source[field])));
22
- const valueOrDefault = (value, defaultValue) => isPresent(value) ? value : defaultValue;
23
- const normalizeGroup = group => ({
24
- aggregates: group.Aggregates || group.aggregates,
25
- field: group.Member || group.member || group.field,
26
- hasSubgroups: group.HasSubgroups || group.hasSubgroups || false,
27
- items: group.Items || group.items,
28
- value: valueOrDefault(group.Key, valueOrDefault(group.key, group.value))
29
- });
30
- const translateGroup = compose(({ field, hasSubgroups, value, aggregates, items }) => ({
31
- aggregates: translateAggregates(aggregates),
32
- field,
33
- items: hasSubgroups ? items.map(translateGroup) : items,
34
- value
35
- }), normalizeGroup);
19
+ const convert = (mapper)=>(values)=>Object.keys(values).reduce(mapper.bind(null, values), {});
20
+ const translateAggregate = convert((source, acc, field)=>set(field.toLowerCase(), acc, source[field]));
21
+ const translateAggregates = convert((source, acc, field)=>set(field, acc, translateAggregate(source[field])));
22
+ const valueOrDefault = (value, defaultValue)=>isPresent(value) ? value : defaultValue;
23
+ const normalizeGroup = (group)=>({
24
+ aggregates: group.Aggregates || group.aggregates,
25
+ field: group.Member || group.member || group.field,
26
+ hasSubgroups: group.HasSubgroups || group.hasSubgroups || false,
27
+ items: group.Items || group.items,
28
+ value: valueOrDefault(group.Key, valueOrDefault(group.key, group.value))
29
+ });
30
+ const translateGroup = compose(({ field, hasSubgroups, value, aggregates, items })=>({
31
+ aggregates: translateAggregates(aggregates),
32
+ field,
33
+ items: hasSubgroups ? items.map(translateGroup) : items,
34
+ value
35
+ }), normalizeGroup);
36
36
  // tslint:disable:max-line-length
37
37
  /**
38
38
  * Converts the grouped result, which is returned into the `Data` field of the UI for ASP.NET MVC `ToDataSourceResult` method, to a comparable format.
39
39
  * @param data - The value of the `Data` field of the response.
40
40
  * @returns {GroupResult[]} - The converted result.
41
- */
42
- export const translateDataSourceResultGroups = (data) => data.map(translateGroup);
41
+ */ export const translateDataSourceResultGroups = (data)=>data.map(translateGroup);
43
42
  /**
44
43
  * Converts the `AggregateResults` field content, which is returned by the UI for ASP.NET MVC `ToDataSourceResult` method, to a comparable format.
45
44
  * @param data - The value of the `AggregateResults` field of the response.
46
45
  * @returns {AggregateResult} - The converted result.
47
- */
48
- // tslint:enable:max-line-length
49
- export const translateAggregateResults = (data) => ((data || []).reduce((acc, x) => set(member(x), acc, set(aggregateMethodName(x).toLowerCase(), acc[member(x)] || {}, value(x))), {}));
46
+ */ // tslint:enable:max-line-length
47
+ export const translateAggregateResults = (data)=>(data || []).reduce((acc, x)=>set(member(x), acc, set(aggregateMethodName(x).toLowerCase(), acc[member(x)] || {}, value(x))), {});
48
+
50
49
  //# sourceMappingURL=deserialization.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"deserialization.js","sourceRoot":"","sources":["../../src/mvc/deserialization.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AA6BnC,gCAAgC;AAEhC,MAAM,GAAG,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;IACjC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;IACtB,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;AA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AC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CACtI,CAAC"}
1
+ {"version":3,"sources":["../../src/mvc/deserialization.ts"],"sourcesContent":["import { GroupResult } from '../grouping/group-descriptor.interface';\nimport { isPresent } from '../utils';\nimport { compose } from '../funcs';\nimport { AggregateResult } from '../transducers';\n\n// tslint:disable:max-line-length\n/**\n * Represents the grouped result returned by the UI for ASP.NET MVC `ToDataSourceResult` method.\n */\nexport type ServerGroupResult = {\n /**\n * Contains either the subgroups or the data items.\n */\n Items: Object[];\n /**\n * The aggregated values for the group. An [`AggregateResult`]({% slug api_kendo-data-query_aggregateresult %}) instance.\n */\n Aggregates: any;\n /**\n * The field by which the data items are grouped.\n */\n Member: string;\n /**\n * The group key.\n */\n Key: any;\n /**\n * Determines if `Items` contains subgroups.\n */\n HasSubgroups: boolean\n};\n// tslint:enable:max-line-length\n\nconst set = (field, target, value) => {\n target[field] = value;\n return target;\n};\n\nconst toCamelCase = str => str.replace(/(^[A-Z])/g, (_, g1) => g1.toLowerCase());\n\nconst prop = (fieldName: string) => (obj: any) => {\n const value = obj[fieldName];\n if (isPresent(value)) {\n return value;\n }\n return obj[toCamelCase(fieldName)];\n};\n\nconst member = prop(\"Member\");\nconst aggregateMethodName = prop(\"AggregateMethodName\");\nconst value = prop(\"Value\");\n\nconst convert = mapper => values => Object.keys(values).reduce(mapper.bind(null, values), {});\nconst translateAggregate = convert((source, acc, field) => set(field.toLowerCase(), acc, source[field]));\nconst translateAggregates = convert((source, acc, field) => set(field, acc, translateAggregate(source[field])));\nconst valueOrDefault = (value, defaultValue) => isPresent(value) ? value : defaultValue;\n\nconst normalizeGroup = group => ({\n aggregates: group.Aggregates || group.aggregates,\n field: group.Member || group.member || group.field,\n hasSubgroups: group.HasSubgroups || group.hasSubgroups || false,\n items: group.Items || group.items,\n value: valueOrDefault(group.Key, valueOrDefault(group.key, group.value))\n});\n\nconst translateGroup = compose(\n ({ field, hasSubgroups, value, aggregates, items }) => ({\n aggregates: translateAggregates(aggregates),\n field,\n items: hasSubgroups ? items.map(translateGroup) : items,\n value\n }),\n normalizeGroup\n);\n\n// tslint:disable:max-line-length\n/**\n * Converts the grouped result, which is returned into the `Data` field of the UI for ASP.NET MVC `ToDataSourceResult` method, to a comparable format.\n * @param data - The value of the `Data` field of the response.\n * @returns {GroupResult[]} - The converted result.\n */\nexport const translateDataSourceResultGroups = (data: any[]): GroupResult[] => data.map(translateGroup);\n\n/**\n * Converts the `AggregateResults` field content, which is returned by the UI for ASP.NET MVC `ToDataSourceResult` method, to a comparable format.\n * @param data - The value of the `AggregateResults` field of the response.\n * @returns {AggregateResult} - The converted result.\n */\n// tslint:enable:max-line-length\nexport const translateAggregateResults = (data: any[]): AggregateResult => (\n (data || []).reduce((acc, x) => set(member(x), acc, set(aggregateMethodName(x).toLowerCase(), acc[member(x)] || {}, value(x))), {})\n);\n"],"names":["isPresent","compose","set","field","target","value","toCamelCase","str","replace","_","g1","toLowerCase","prop","fieldName","obj","member","aggregateMethodName","convert","mapper","values","Object","keys","reduce","bind","translateAggregate","source","acc","translateAggregates","valueOrDefault","defaultValue","normalizeGroup","group","aggregates","Aggregates","Member","hasSubgroups","HasSubgroups","items","Items","Key","key","translateGroup","map","translateDataSourceResultGroups","data","translateAggregateResults","x"],"mappings":"AACA,SAASA,SAAS,QAAQ,WAAW;AACrC,SAASC,OAAO,QAAQ,WAAW;AA6BnC,gCAAgC;AAEhC,MAAMC,MAAM,CAACC,OAAOC,QAAQC;IACxBD,MAAM,CAACD,MAAM,GAAGE;IAChB,OAAOD;AACX;AAEA,MAAME,cAAcC,CAAAA,MAAOA,IAAIC,OAAO,CAAC,aAAa,CAACC,GAAGC,KAAOA,GAAGC,WAAW;AAE7E,MAAMC,OAAO,CAACC,YAAsB,CAACC;QACjC,MAAMT,QAAQS,GAAG,CAACD,UAAU;QAC5B,IAAIb,UAAUK,QAAQ;Y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kC,CAACC,OAA+BA,KAAKF,GAAG,CAACD,gBAAgB;AAExG;;;;CAIC,GACD,gCAAgC;AAChC,OAAO,MAAMI,4BAA4B,CAACD,OACtC,AAACA,CAAAA,QAAQ,EAAE,AAAD,EAAGtB,MAAM,CAAC,CAACI,KAAKoB,IAAM5C,IAAIa,OAAO+B,IAAIpB,KAAKxB,IAAIc,oBAAoB8B,GAAGnC,WAAW,IAAIe,GAAG,CAACX,OAAO+B,GAAG,IAAI,CAAC,GAAGzC,MAAMyC,MAAM,CAAC,GACnI"}
@@ -3,22 +3,42 @@ import { isPresent, isNotNullOrEmptyString, isArray } from '../utils';
3
3
  import { getter } from '../accessor';
4
4
  import { compose, ifElse, identity } from '../funcs';
5
5
  import { isStringValue, isDateValue, quote, serializeFilters, toUTC, encodeValue } from '../filter-serialization.common';
6
- const toQueryString = values => values.reduce((acc, [key, value]) => [...acc, `${key}=${value}`], []);
7
- const toObject = values => values.reduce((acc, [key, value]) => ({ ...acc, ...{ [key]: value } }), {});
8
- const pairwise = key => value => [key, value];
9
- const empty = () => null;
10
- const isNotEmptyArray = value => isPresent(value) && isArray(value) && value.length > 0;
11
- const has = accessor => value => isPresent(accessor(value));
12
- const isNotEmpty = accessor => value => isNotEmptyArray(accessor(value));
13
- const runOrEmpty = (predicate, fn) => ifElse(predicate, fn, empty);
14
- const calcPage = ({ skip, take }) => Math.floor((skip || 0) / take) + 1;
15
- const formatDescriptors = (accessor, formatter) => state => (accessor(state).map(formatter).join("~"));
16
- const removeAfter = (what) => (str) => str.slice(0, str.indexOf(what));
17
- const replace = (patterns) => compose(...patterns.map(([left, right]) => (s) => s.replace(new RegExp(left, "g"), right)));
18
- const sanitizeDateLiterals = replace([["\"", ""], [":", "-"]]);
6
+ const toQueryString = (values)=>values.reduce((acc, [key, value])=>[
7
+ ...acc,
8
+ `${key}=${value}`
9
+ ], []);
10
+ const toObject = (values)=>values.reduce((acc, [key, value])=>({
11
+ ...acc,
12
+ ...{
13
+ [key]: value
14
+ }
15
+ }), {});
16
+ const pairwise = (key)=>(value)=>[
17
+ key,
18
+ value
19
+ ];
20
+ const empty = ()=>null;
21
+ const isNotEmptyArray = (value)=>isPresent(value) && isArray(value) && value.length > 0;
22
+ const has = (accessor)=>(value)=>isPresent(accessor(value));
23
+ const isNotEmpty = (accessor)=>(value)=>isNotEmptyArray(accessor(value));
24
+ const runOrEmpty = (predicate, fn)=>ifElse(predicate, fn, empty);
25
+ const calcPage = ({ skip, take })=>Math.floor((skip || 0) / take) + 1;
26
+ const formatDescriptors = (accessor, formatter)=>(state)=>accessor(state).map(formatter).join("~");
27
+ const removeAfter = (what)=>(str)=>str.slice(0, str.indexOf(what));
28
+ const replace = (patterns)=>compose(...patterns.map(([left, right])=>(s)=>s.replace(new RegExp(left, "g"), right)));
29
+ const sanitizeDateLiterals = replace([
30
+ [
31
+ "\"",
32
+ ""
33
+ ],
34
+ [
35
+ ":",
36
+ "-"
37
+ ]
38
+ ]);
19
39
  const removeAfterDot = removeAfter(".");
20
- const directionFormatter = ({ field, dir = "asc" }) => `${field}-${dir}`;
21
- const aggregateFormatter = ({ field, aggregate }) => `${field}-${aggregate}`;
40
+ const directionFormatter = ({ field, dir = "asc" })=>`${field}-${dir}`;
41
+ const aggregateFormatter = ({ field, aggregate })=>`${field}-${aggregate}`;
22
42
  const take = getter("take");
23
43
  const aggregates = getter("aggregates");
24
44
  const skip = getter("skip");
@@ -27,17 +47,17 @@ const sort = getter("sort", true);
27
47
  const formatSort = formatDescriptors(sort, directionFormatter);
28
48
  const formatGroup = formatDescriptors(group, directionFormatter);
29
49
  const formatAggregates = formatDescriptors(aggregates, aggregateFormatter);
30
- const prefixDateValue = value => `datetime'${value}'`;
50
+ const prefixDateValue = (value)=>`datetime'${value}'`;
31
51
  const formatDateValue = compose(prefixDateValue, removeAfterDot, sanitizeDateLiterals, JSON.stringify, toUTC);
32
- const formatDate = ({ field, value, ignoreCase, operator }) => ({
33
- value: formatDateValue(value),
34
- field,
35
- ignoreCase,
36
- operator
37
- });
38
- const normalizeSort = (state) => Object.assign({}, state, {
39
- sort: (sort(state) || []).filter(({ dir }) => isNotNullOrEmptyString(dir))
40
- });
52
+ const formatDate = ({ field, value, ignoreCase, operator })=>({
53
+ value: formatDateValue(value),
54
+ field,
55
+ ignoreCase,
56
+ operator
57
+ });
58
+ const normalizeSort = (state)=>Object.assign({}, state, {
59
+ sort: (sort(state) || []).filter(({ dir })=>isNotNullOrEmptyString(dir))
60
+ });
41
61
  const transformSkip = compose(pairwise('page'), calcPage);
42
62
  const transformTake = compose(pairwise('pageSize'), take);
43
63
  const transformGroup = compose(pairwise('group'), formatGroup);
@@ -48,29 +68,32 @@ const serializePageSize = runOrEmpty(has(take), transformTake);
48
68
  const serializeGroup = runOrEmpty(isNotEmpty(group), transformGroup);
49
69
  const serializeAggregates = runOrEmpty(has(aggregates), transformAggregates);
50
70
  const serializeSort = compose(runOrEmpty(isNotEmpty(sort), transformSort), normalizeSort);
51
- const hasField = ({ field }) => isNotNullOrEmptyString(field);
52
- const filterFormatter = ({ field, operator, value }) => `${field}~${operator}~${value}`;
71
+ const hasField = ({ field })=>isNotNullOrEmptyString(field);
72
+ const filterFormatter = ({ field, operator, value })=>`${field}~${operator}~${value}`;
53
73
  const dateFormatter = ifElse(isDateValue, compose(filterFormatter, formatDate), filterFormatter);
54
- const typedFormatter = encode => runOrEmpty(hasField, ifElse(isStringValue, compose(filterFormatter, quote, encode ? encodeValue : identity), dateFormatter));
55
- const join = ({ logic }) => `~${logic}~`;
56
- const serialize = encode => serializeFilters(filter => ifElse(isCompositeFilterDescriptor, serialize(encode), typedFormatter(encode))(filter), join);
57
- const serializeFilter = ({ filter }, encode) => {
74
+ const typedFormatter = (encode)=>runOrEmpty(hasField, ifElse(isStringValue, compose(filterFormatter, quote, encode ? encodeValue : identity), dateFormatter));
75
+ const join = ({ logic })=>`~${logic}~`;
76
+ const serialize = (encode)=>serializeFilters((filter)=>ifElse(isCompositeFilterDescriptor, serialize(encode), typedFormatter(encode))(filter), join);
77
+ const serializeFilter = ({ filter }, encode)=>{
58
78
  if (filter && filter.filters) {
59
79
  const filters = serialize(encode)(filter);
60
80
  if (filters.length) {
61
- return ['filter', filters];
81
+ return [
82
+ 'filter',
83
+ filters
84
+ ];
62
85
  }
63
86
  }
64
87
  return null;
65
88
  };
66
- const rules = (state, encode = true) => key => ({
67
- "aggregates": serializeAggregates(state),
68
- "filter": serializeFilter(state, encode),
69
- "group": serializeGroup(state),
70
- "skip": serializePage(state),
71
- "sort": serializeSort(state),
72
- "take": serializePageSize(state)
73
- }[key]);
89
+ const rules = (state, encode = true)=>(key)=>({
90
+ "aggregates": serializeAggregates(state),
91
+ "filter": serializeFilter(state, encode),
92
+ "group": serializeGroup(state),
93
+ "skip": serializePage(state),
94
+ "sort": serializeSort(state),
95
+ "take": serializePageSize(state)
96
+ })[key];
74
97
  /**
75
98
  * Converts a [`DataSourceRequestState`]({% slug api_kendo-data-query_datasourcerequeststate %}) into a string
76
99
  * that is comparable with the `DataSourceRequest` format in UI for ASP.NET MVC.
@@ -175,18 +198,13 @@ const rules = (state, encode = true) => key => ({
175
198
  * }
176
199
  * ```
177
200
  * {% endplatform_content %}
178
- */
179
- export const toDataSourceRequestString = (state) => (toQueryString(Object.keys(state)
180
- .map(rules(state))
181
- .filter(isPresent)).join('&'));
201
+ */ export const toDataSourceRequestString = (state)=>toQueryString(Object.keys(state).map(rules(state)).filter(isPresent)).join('&');
182
202
  /**
183
203
  * Converts a [`DataSourceRequestState`]({% slug api_kendo-data-query_datasourcerequeststate %}) into an object
184
204
  * that is compatible with the `DataSourceRequest` format in UI for ASP.NET MVC.
185
205
  *
186
206
  * @param {DataRequestState} state - The state that will be serialized.
187
207
  * @returns {any} - The serialized state.
188
- */
189
- export const toDataSourceRequest = (state) => (toObject(Object.keys(state)
190
- .map(rules(state, false))
191
- .filter(isPresent)));
208
+ */ export const toDataSourceRequest = (state)=>toObject(Object.keys(state).map(rules(state, false)).filter(isPresent));
209
+
192
210
  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D,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC5C,YAAY,EAAE,mBAAmB,CAAC,KAAK,CAAC;IACxC,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC;IACxC,OAAO,EAAE,cAAc,CAAC,KAAK,CAAC;IAC9B,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC;IAC5B,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC;IAC5B,MAAM,EAAE,iBAAiB,CAAC,KAAK,CAAC;CACnC,CAAC,GAAG,CAAC,CAAC,CAAC;AAkBR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,KAA6B,EAAU,EAAE,CAAC,CAChF,aAAa,CACT,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;KACb,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACjB,MAAM,CAAC,SAAS,CAAC,CACzB,CAAC,IAAI,CAAC,GAAG,CAAC,CACd,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAA6B,EAAO,EAAE,CAAC,CACvE,QAAQ,CACJ,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;KACb,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;KACxB,MAAM,CAAC,SAAS,CAAC,CACzB,CACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/mvc/operators.ts"],"sourcesContent":["import { State } from '../state';\nimport { FilterDescriptor, isCompositeFilterDescriptor } from '../filtering/filter-descriptor.interface';\nimport { AggregateDescriptor } from '../grouping/aggregate.operators';\nimport { isPresent, isNotNullOrEmptyString, isArray, Pair } from '../utils';\nimport { getter } from '../accessor';\nimport { compose, ifElse, identity } from '../funcs';\nimport { isStringValue, isDateValue, quote, serializeFilters, Transformation, toUTC, encodeValue } from '../filter-serialization.common';\n\nconst toQueryString = values => values.reduce((acc, [key, value]) => [...acc, `${key}=${value}`], []);\nconst toObject = values => values.reduce((acc, [key, value]) => ({ ...acc, ...{ [key]: value } }), {});\nconst pairwise = key => value => [key, value];\nconst empty = () => null;\nconst isNotEmptyArray = value => isPresent(value) && isArray(value) && value.length > 0;\nconst has = accessor => value => isPresent(accessor(value));\nconst isNotEmpty = accessor => value => isNotEmptyArray(accessor(value));\nconst runOrEmpty = (predicate, fn) => ifElse(predicate, fn, empty);\n\nconst calcPage = ({ skip, take }: State) => Math.floor((skip || 0) / take) + 1;\nconst formatDescriptors = (accessor, formatter) => state => (\n accessor(state).map(formatter).join(\"~\")\n);\n\nconst removeAfter = (what: string) => (str: string) => str.slice(0, str.indexOf(what));\nconst replace = (patterns: Pair<string, string>[]) =>\n compose(...patterns.map(([left, right]) => (s: string) => s.replace(new RegExp(left, \"g\"), right)));\n\nconst sanitizeDateLiterals = replace([[\"\\\"\", \"\"], [\":\", \"-\"]]);\nconst removeAfterDot = removeAfter(\".\");\n\nconst directionFormatter = ({ field, dir = \"asc\" }) => `${field}-${dir}`;\nconst aggregateFormatter = ({ field, aggregate }) => `${field}-${aggregate}`;\n\nconst take = getter(\"take\");\nconst aggregates = getter(\"aggregates\");\nconst skip = getter(\"skip\");\nconst group = getter(\"group\");\nconst sort = getter(\"sort\", true);\n\nconst formatSort = formatDescriptors(sort, directionFormatter);\nconst formatGroup = formatDescriptors(group, directionFormatter);\nconst formatAggregates = formatDescriptors(aggregates, aggregateFormatter);\n\nconst prefixDateValue = value => `datetime'${value}'`;\n\nconst formatDateValue = compose(\n prefixDateValue,\n removeAfterDot,\n sanitizeDateLiterals,\n JSON.stringify,\n toUTC\n);\n\nconst formatDate: Transformation = ({ field, value, ignoreCase, operator }) => ({\n value: formatDateValue(value),\n field,\n ignoreCase,\n operator\n});\n\nconst normalizeSort = (state: State) => Object.assign({}, state, {\n sort: (sort(state) || []).filter(({ dir }) => isNotNullOrEmptyString(dir))\n});\n\nconst transformSkip = compose(pairwise('page'), calcPage);\nconst transformTake = compose(pairwise('pageSize'), take);\nconst transformGroup = compose(pairwise('group'), formatGroup);\nconst transformSort = compose(pairwise('sort'), formatSort);\nconst transformAggregates = compose(pairwise('aggregate'), formatAggregates);\n\nconst serializePage = runOrEmpty(has(skip), transformSkip);\nconst serializePageSize = runOrEmpty(has(take), transformTake);\nconst serializeGroup = runOrEmpty(isNotEmpty(group), transformGroup);\nconst serializeAggregates = runOrEmpty(has(aggregates), transformAggregates);\nconst serializeSort = compose(runOrEmpty(isNotEmpty(sort), transformSort), normalizeSort);\n\nconst hasField = ({ field }) => isNotNullOrEmptyString(field);\nconst filterFormatter = ({ field, operator, value }: FilterDescriptor) => `${field}~${operator}~${value}`;\nconst dateFormatter = ifElse(isDateValue, compose(filterFormatter, formatDate), filterFormatter);\nconst typedFormatter = encode => runOrEmpty(\n hasField,\n ifElse(\n isStringValue,\n compose(filterFormatter, quote, encode ? encodeValue : identity),\n dateFormatter\n )\n);\n\nconst join = ({ logic }) => `~${logic}~`;\nconst serialize = encode => serializeFilters(\n filter => ifElse(isCompositeFilterDescriptor, serialize(encode), typedFormatter(encode))(filter),\n join\n);\n\nconst serializeFilter = ({ filter }: State, encode: boolean) => {\n if (filter && filter.filters) {\n const filters = serialize(encode)(filter);\n if (filters.length) {\n return ['filter', filters];\n }\n }\n return null;\n};\n\nconst rules = (state, encode = true) => key => ({\n \"aggregates\": serializeAggregates(state),\n \"filter\": serializeFilter(state, encode),\n \"group\": serializeGroup(state),\n \"skip\": serializePage(state),\n \"sort\": serializeSort(state),\n \"take\": serializePageSize(state)\n}[key]);\n\n/**\n * Represents the operation descriptors that will be sent\n * ([see example]({% slug api_kendo-data-query_todatasourcerequeststring %})).\n *\n * Extends [`State`]({% slug api_kendo-data-query_state %}) by adding the `aggregates` descriptors&mdash;\n * an array of [`AggregateDescriptor`]({% slug api_kendo-data-query_aggregatedescriptor %}).\n */\nexport type DataSourceRequestState = State & {\n\n /**\n * The descriptors used for aggregation.\n * @type {Array<AggregateDescriptor>}\n */\n aggregates?: Array<AggregateDescriptor>;\n};\n\n/**\n * Converts a [`DataSourceRequestState`]({% slug api_kendo-data-query_datasourcerequeststate %}) into a string\n * that is comparable with the `DataSourceRequest` format in UI for ASP.NET MVC.\n *\n * @param {DataRequestState} state - The state that will be serialized.\n * @returns {string} - The serialized state.\n *\n * @example\n * {% platform_content angular %}\n * ```ts-no-run\n * import {\n * toDataSourceRequestString,\n * translateDataSourceResultGroups,\n * translateAggregateResults\n * } from '@progress/kendo-data-query';\n *\n * export class Service {\n * private BASE_URL: string = '...';\n *\n * constructor(private http: Http) { }\n *\n * // Omitted for brevity...\n *\n * private fetch(state: DataSourceRequestState): Observable<DataResult> {\n * const queryStr = `${toDataSourceRequestString(state)}`; //serialize the state\n * const hasGroups = state.group && state.group.length;\n *\n * return this.http\n * .get(`${this.BASE_URL}?${queryStr}`) //send the state to the server\n * .map(response => response.json())\n * .map(({Data, Total, AggregateResults}) => // process the response\n * (<GridDataResult>{\n * //if there are groups convert them to compatible format\n * data: hasGroups ? translateDataSourceResultGroups(Data) : Data,\n * total: Total,\n * // convert the aggregates if such exists\n * aggregateResult: translateAggregateResults(AggregateResults)\n * })\n * );\n * }\n * }\n * ```\n * {% endplatform_content %}\n *\n * {% platform_content react %}\n * ```jsx-no-run\n * import { Component } from 'react';\n * import { toDataSourceRequestString, translateDataSourceResultGroups } from '@progress/kendo-data-query';\n *\n * export function withState(WrappedGrid) {\n * return class StatefullGrid extends Component {\n * constructor(props) {\n * super(props);\n * this.state = { dataState: { skip: 0, take: 20 } };\n * }\n *\n * render() {\n * return (\n * <WrappedGrid\n * filterable={true}\n * sortable={true}\n * pageable={{ pageSizes: true }}\n * {...this.props}\n * total={this.state.total}\n * data={this.state.data}\n * skip={this.state.dataState.skip}\n * pageSize={this.state.dataState.take}\n * filter={this.state.dataState.filter}\n * sort={this.state.dataState.sort}\n * dataStateChange={this.dataStateChange}\n * />\n * );\n * }\n *\n * componentDidMount() {\n * this.fetchData(this.state.dataState);\n * }\n *\n * dataStateChange = (changeEvent) => {\n * this.setState({ dataState: changeEvent.data });\n * this.fetchData(changeEvent.data);\n * }\n *\n * fetchData(dataState) {\n * const queryStr = `${toDataSourceRequestString(dataState)}`; // Serialize the state\n * const hasGroups = dataState.group && dataState.group.length;\n *\n * const base_url = 'api/Products';\n * const init = { method: 'GET', accept: 'application/json', headers: {} };\n *\n * fetch(`${base_url}?${queryStr}`, init)\n * .then(response => response.json())\n * .then(({ data, total }) => {\n * this.setState({\n * data: hasGroups ? translateDataSourceResultGroups(data) : data,\n * total,\n * dataState\n * });\n * });\n * }\n * }\n * }\n * ```\n * {% endplatform_content %}\n */\nexport const toDataSourceRequestString = (state: DataSourceRequestState): string => (\n toQueryString(\n Object.keys(state)\n .map(rules(state))\n .filter(isPresent)\n ).join('&')\n);\n\n/**\n * Converts a [`DataSourceRequestState`]({% slug api_kendo-data-query_datasourcerequeststate %}) into an object\n * that is compatible with the `DataSourceRequest` format in UI for ASP.NET MVC.\n *\n * @param {DataRequestState} state - The state that will be serialized.\n * @returns {any} - The serialized state.\n */\nexport const toDataSourceRequest = (state: DataSourceRequestState): any => (\n toObject(\n Object.keys(state)\n .map(rules(state, false))\n .filter(isPresent)\n )\n);\n"],"names":["isCompositeFilterDescriptor","isPresent","isNotNullOrEmptyString","isArray","getter","compose","ifElse","identity","isStringValue","isDateValue","quote","serializeFilters","toUTC","encodeValue","toQueryString","values","reduce","acc","key","value","toObject","pairwise","empty","isNotEmptyArray","length","has","accessor","isNotEmpty","runOrEmpty","predicate","fn","calcPage","skip","take","Math","floor","formatDescriptors","formatter","state","map","join","removeAfter","what","str","slice","indexOf","replace","patterns","left","right","s","RegExp","sanitizeDateLiterals","removeAfterDot","directionFormatter","field","dir","aggregateFormatter","aggregate","aggregates","group","sort","formatSort","formatGroup","formatAggregates","prefixDateValue","formatDateValue","JSON","stringify","formatDate","ignoreCase","operator","normalizeSort","Object","assign","filter","transformSkip","transformTake","transformGroup","transformSort","transformAggregates","serializePage","serializePageSize","serializeGroup","serializeAggregates","serializeSort","hasField","filterFormatter","dateFormatter","typedFormatter","encode","logic","serialize","serializeFilter","filters","rules","toDataSourceRequestString","keys","toDataSourceRequest"],"mappings":"AACA,SAA2BA,2BAA2B,QAAQ,2CAA2C;AAEzG,SAASC,SAAS,EAAEC,sBAAsB,EAAEC,OAAO,QAAc,WAAW;AAC5E,SAASC,MAAM,QAAQ,cAAc;AACrC,SAASC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,WAAW;AACrD,SAASC,aAAa,EAAEC,WAAW,EAAEC,KAAK,EAAEC,gBAAgB,EAAkBC,KAAK,EAAEC,WAAW,QAAQ,iCAAiC;AAEzI,MAAMC,gBAAgBC,CAAAA,SAAUA,OAAOC,MAAM,CAAC,CAACC,KAAK,CAACC,KAAKC,MAAM,GAAK;eAAIF;YAAK,GAAGC,IAAI,CAAC,EAAEC,OAAO;SAAC,EAAE,EAAE;AACpG,MAAMC,WAAWL,CAAAA,SAAUA,OAAOC,MAAM,CAAC,CAACC,KAAK,CAACC,KAAKC,MAAM,GAAM,CAAA;YAAE,GAAGF,GAAG;YAAE,GAAG;gBAAE,CAACC,IAAI,EAAEC;YAAM,CAAC;QAAC,CAAA,GAAI,CAAC;AACpG,MAAME,WAAWH,CAAAA,MAAOC,CAAAA,QAAS;YAACD;YAAKC;SAAM;AAC7C,MAAMG,QAAQ,IAAM;AACpB,MAAMC,kBAAkBJ,CAAAA,QAASlB,UAAUkB,UAAUhB,QAAQgB,UAAUA,MAAMK,MAAM,GAAG;AACtF,MAAMC,MAAMC,CAAAA,WAAYP,CAAAA,QAASlB,UAAUyB,SAASP;AACpD,MAAMQ,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