@servicetitan/data-query 19.4.0 → 20.0.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.
- package/dist/accessor.js +4 -8
- package/dist/accessor.js.map +1 -1
- package/dist/array.operators.js +33 -41
- package/dist/array.operators.js.map +1 -1
- package/dist/common.interfaces.js +1 -2
- package/dist/data-result.interface.js +1 -2
- package/dist/data-source/async-data-source.js +9 -16
- package/dist/data-source/async-data-source.js.map +1 -1
- package/dist/data-source/data-source.js +1 -2
- package/dist/data-source/in-memory-data-source.js +15 -22
- package/dist/data-source/in-memory-data-source.js.map +1 -1
- package/dist/data-source/index.js +2 -7
- package/dist/data-source/index.js.map +1 -1
- package/dist/filter-serialization.common.js +12 -24
- package/dist/filter-serialization.common.js.map +1 -1
- package/dist/filtering/filter-descriptor.interface.js +3 -7
- package/dist/filtering/filter-descriptor.interface.js.map +1 -1
- package/dist/filtering/filter-expression.factory.js +9 -14
- package/dist/filtering/filter-expression.factory.js.map +1 -1
- package/dist/filtering/filter-no-eval.js +28 -32
- package/dist/filtering/filter-no-eval.js.map +1 -1
- package/dist/filtering/filter.operators.js +8 -12
- package/dist/filtering/filter.operators.js.map +1 -1
- package/dist/funcs.js +4 -11
- package/dist/funcs.js.map +1 -1
- package/dist/grouping/aggregate.operators.js +5 -9
- package/dist/grouping/aggregate.operators.js.map +1 -1
- package/dist/grouping/group-descriptor.interface.js +1 -2
- package/dist/grouping/group-descriptor.interface.js.map +1 -1
- package/dist/grouping/group.operators.js +14 -19
- package/dist/grouping/group.operators.js.map +1 -1
- package/dist/index.js +13 -35
- package/dist/index.js.map +1 -1
- package/dist/mvc/deserialization.js +7 -12
- package/dist/mvc/deserialization.js.map +1 -1
- package/dist/mvc/operators.js +30 -35
- package/dist/mvc/operators.js.map +1 -1
- package/dist/odata-filtering.operators.js +15 -19
- package/dist/odata-filtering.operators.js.map +1 -1
- package/dist/odata.operators.js +9 -13
- package/dist/odata.operators.js.map +1 -1
- package/dist/sort-descriptor.js +1 -2
- package/dist/sorting/sort-array.operator.js +7 -11
- package/dist/sorting/sort-array.operator.js.map +1 -1
- package/dist/sorting/sort.js +3 -7
- package/dist/sorting/sort.js.map +1 -1
- package/dist/state.js +1 -2
- package/dist/transducers.js +27 -41
- package/dist/transducers.js.map +1 -1
- package/dist/utils.js +10 -23
- package/dist/utils.js.map +1 -1
- package/package.json +5 -4
package/dist/accessor.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getter = void 0;
|
|
4
|
-
const utils_1 = require("./utils");
|
|
1
|
+
import { isPresent } from './utils';
|
|
5
2
|
const getterCache = {};
|
|
6
3
|
const FIELD_REGEX = /\[(?:(\d+)|['"](.*?)['"])\]|((?:(?!\[.*?\]|\.).)+)/g;
|
|
7
4
|
// tslint:disable-next-line:no-string-literal
|
|
@@ -9,21 +6,21 @@ getterCache['undefined'] = obj => obj;
|
|
|
9
6
|
/**
|
|
10
7
|
* @hidden
|
|
11
8
|
*/
|
|
12
|
-
const getter = (field, safe) => {
|
|
9
|
+
export const getter = (field, safe) => {
|
|
13
10
|
const key = field + safe;
|
|
14
11
|
if (getterCache[key]) {
|
|
15
12
|
return getterCache[key];
|
|
16
13
|
}
|
|
17
14
|
const fields = [];
|
|
18
15
|
field.replace(FIELD_REGEX, (_, index, indexAccessor, field) => {
|
|
19
|
-
fields.push(
|
|
16
|
+
fields.push(isPresent(index) ? index : (indexAccessor || field));
|
|
20
17
|
return undefined;
|
|
21
18
|
});
|
|
22
19
|
getterCache[key] = obj => {
|
|
23
20
|
let result = obj;
|
|
24
21
|
for (let idx = 0; idx < fields.length; idx++) {
|
|
25
22
|
result = result[fields[idx]];
|
|
26
|
-
if (!
|
|
23
|
+
if (!isPresent(result) && safe) {
|
|
27
24
|
return result;
|
|
28
25
|
}
|
|
29
26
|
}
|
|
@@ -31,5 +28,4 @@ const getter = (field, safe) => {
|
|
|
31
28
|
};
|
|
32
29
|
return getterCache[key];
|
|
33
30
|
};
|
|
34
|
-
exports.getter = getter;
|
|
35
31
|
//# sourceMappingURL=accessor.js.map
|
package/dist/accessor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessor.js","sourceRoot":"","sources":["../src/accessor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"accessor.js","sourceRoot":"","sources":["../src/accessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,MAAM,WAAW,GAAgC,EAAE,CAAC;AAEpD,MAAM,WAAW,GAAG,qDAAqD,CAAC;AAE1E,6CAA6C;AAC7C,WAAW,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,IAAc,EAAE,EAAE;IACpD,MAAM,GAAG,GAAG,KAAK,GAAG,IAAI,CAAC;IAEzB,IAAI,WAAW,CAAC,GAAG,CAAC,EAAE;QAClB,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;KAC3B;IAED,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,EAAE;QAC1D,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,IAAI,KAAK,CAAC,CAAC,CAAC;QACjE,OAAO,SAAS,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,WAAW,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,EAAE;QACrB,IAAI,MAAM,GAAG,GAAG,CAAC;QACjB,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;YAC1C,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;YAC7B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE;gBAC5B,OAAO,MAAM,CAAC;aACjB;SACJ;QAED,OAAO,MAAM,CAAC;IAClB,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC,CAAC"}
|
package/dist/array.operators.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const accessor_1 = require("./accessor");
|
|
11
|
-
const funcs_1 = require("./funcs");
|
|
12
|
-
const sort_1 = require("./sorting/sort");
|
|
1
|
+
import { isPresent, isString } from './utils';
|
|
2
|
+
import { composeSortDescriptors } from './sorting/sort-array.operator';
|
|
3
|
+
import { groupBy, normalizeGroups } from './grouping/group.operators';
|
|
4
|
+
import { normalizeFilters } from './filtering/filter.operators';
|
|
5
|
+
import { compileFilter } from './filtering/filter-expression.factory';
|
|
6
|
+
import { exec, skip, take, filter, concat } from './transducers';
|
|
7
|
+
import { getter } from './accessor';
|
|
8
|
+
import { compose } from './funcs';
|
|
9
|
+
import { sort } from './sorting/sort';
|
|
13
10
|
/**
|
|
14
11
|
* Orders the specified array according to the provided sort descriptors.
|
|
15
12
|
*
|
|
@@ -30,19 +27,18 @@ const sort_1 = require("./sorting/sort");
|
|
|
30
27
|
* const result = orderBy(data, [{ field: "name", dir: "asc" }]);
|
|
31
28
|
* ```
|
|
32
29
|
*/
|
|
33
|
-
const orderBy = (data, descriptors, preprocessors = {}) => {
|
|
34
|
-
if (descriptors.some(x =>
|
|
30
|
+
export const orderBy = (data, descriptors, preprocessors = {}) => {
|
|
31
|
+
if (descriptors.some(x => isPresent(x.dir))) {
|
|
35
32
|
data = data.slice(0);
|
|
36
|
-
const comparer =
|
|
37
|
-
|
|
33
|
+
const comparer = composeSortDescriptors(descriptors, preprocessors);
|
|
34
|
+
sort(data, 0, data.length, comparer);
|
|
38
35
|
}
|
|
39
36
|
return data;
|
|
40
37
|
};
|
|
41
|
-
exports.orderBy = orderBy;
|
|
42
38
|
const defaultComparer = (a, b) => a === b;
|
|
43
39
|
const normalizeComparer = (comparer) => {
|
|
44
|
-
if (
|
|
45
|
-
const accessor =
|
|
40
|
+
if (isString(comparer)) {
|
|
41
|
+
const accessor = getter(comparer);
|
|
46
42
|
comparer = (a, b) => accessor(a) === accessor(b);
|
|
47
43
|
}
|
|
48
44
|
return comparer;
|
|
@@ -74,12 +70,11 @@ const _distinct = (data, comparer) => data.filter((x, idx, xs) => xs.findIndex(c
|
|
|
74
70
|
* // ];
|
|
75
71
|
* ```
|
|
76
72
|
*/
|
|
77
|
-
const distinct = (data, comparer = defaultComparer) => _distinct(data, normalizeComparer(comparer));
|
|
78
|
-
exports.distinct = distinct;
|
|
73
|
+
export const distinct = (data, comparer = defaultComparer) => _distinct(data, normalizeComparer(comparer));
|
|
79
74
|
/**
|
|
80
75
|
* @hidden
|
|
81
76
|
*/
|
|
82
|
-
const count = (data, predicate) => {
|
|
77
|
+
export const count = (data, predicate) => {
|
|
83
78
|
let counter = 0;
|
|
84
79
|
for (let idx = 0, length = data.length; idx < length; idx++) {
|
|
85
80
|
if (predicate(data[idx])) {
|
|
@@ -88,17 +83,15 @@ const count = (data, predicate) => {
|
|
|
88
83
|
}
|
|
89
84
|
return counter;
|
|
90
85
|
};
|
|
91
|
-
exports.count = count;
|
|
92
86
|
/**
|
|
93
87
|
* @hidden
|
|
94
88
|
*/
|
|
95
|
-
const limit = (data, predicate) => {
|
|
89
|
+
export const limit = (data, predicate) => {
|
|
96
90
|
if (predicate) {
|
|
97
91
|
return data.filter(predicate);
|
|
98
92
|
}
|
|
99
93
|
return data;
|
|
100
94
|
};
|
|
101
|
-
exports.limit = limit;
|
|
102
95
|
/**
|
|
103
96
|
* Applies the specified operation descriptors to the data.
|
|
104
97
|
*
|
|
@@ -131,14 +124,14 @@ exports.limit = limit;
|
|
|
131
124
|
*
|
|
132
125
|
* ```
|
|
133
126
|
*/
|
|
134
|
-
const process = (data, state, preprocessors = {}) => {
|
|
127
|
+
export const process = (data, state, preprocessors = {}) => {
|
|
135
128
|
const { skip: skipCount, take: takeCount, filter: filterDescriptor, sort, group } = state;
|
|
136
|
-
const sortDescriptors = [...
|
|
129
|
+
const sortDescriptors = [...normalizeGroups(group || []), ...sort || []];
|
|
137
130
|
if (sortDescriptors.length) {
|
|
138
|
-
data =
|
|
131
|
+
data = orderBy(data, sortDescriptors, preprocessors);
|
|
139
132
|
}
|
|
140
|
-
const hasFilters =
|
|
141
|
-
const hasGroups =
|
|
133
|
+
const hasFilters = isPresent(filterDescriptor) && filter.length;
|
|
134
|
+
const hasGroups = isPresent(group) && group.length;
|
|
142
135
|
if (!hasFilters && !hasGroups) {
|
|
143
136
|
return {
|
|
144
137
|
data: takeCount ? data.slice(skipCount, skipCount + takeCount) : data,
|
|
@@ -149,28 +142,27 @@ const process = (data, state, preprocessors = {}) => {
|
|
|
149
142
|
const transformers = [];
|
|
150
143
|
let predicate;
|
|
151
144
|
if (hasFilters) {
|
|
152
|
-
predicate =
|
|
153
|
-
total =
|
|
154
|
-
transformers.push(
|
|
145
|
+
predicate = compileFilter(normalizeFilters(filterDescriptor), preprocessors);
|
|
146
|
+
total = count(data, predicate);
|
|
147
|
+
transformers.push(filter(predicate));
|
|
155
148
|
}
|
|
156
149
|
else {
|
|
157
150
|
total = data.length;
|
|
158
151
|
}
|
|
159
|
-
if (
|
|
160
|
-
transformers.push(
|
|
161
|
-
transformers.push(
|
|
152
|
+
if (isPresent(skipCount) && isPresent(takeCount)) {
|
|
153
|
+
transformers.push(skip(skipCount));
|
|
154
|
+
transformers.push(take(takeCount));
|
|
162
155
|
}
|
|
163
156
|
if (transformers.length) {
|
|
164
|
-
const transform =
|
|
157
|
+
const transform = compose(...transformers);
|
|
165
158
|
const result = hasGroups ?
|
|
166
|
-
|
|
167
|
-
|
|
159
|
+
groupBy(data, group, preprocessors, transform, limit(data, predicate)) :
|
|
160
|
+
exec(transform(concat), [], data);
|
|
168
161
|
return { data: result, total: total };
|
|
169
162
|
}
|
|
170
163
|
return {
|
|
171
|
-
data: hasGroups ?
|
|
164
|
+
data: hasGroups ? groupBy(data, group, preprocessors) : data,
|
|
172
165
|
total: total
|
|
173
166
|
};
|
|
174
167
|
};
|
|
175
|
-
exports.process = process;
|
|
176
168
|
//# sourceMappingURL=array.operators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.operators.js","sourceRoot":"","sources":["../src/array.operators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"array.operators.js","sourceRoot":"","sources":["../src/array.operators.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAEtE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAI,IAAS,EAAE,WAA6B,EAAE,gBAAkC,EAAE,EAAO,EAAE;I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EAAE,KAAK,EAAE,CAAC;KACzC;IAED,OAAO;QACH,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI;QAC5D,KAAK,EAAE,KAAK;KACf,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,15 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
exports.AsyncDataSource = void 0;
|
|
16
|
-
const axios_1 = __importDefault(require("axios"));
|
|
17
|
-
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
18
|
-
const mobx_1 = require("mobx");
|
|
19
|
-
class AsyncDataSource {
|
|
10
|
+
import axios from 'axios';
|
|
11
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
12
|
+
import { toJS, comparer } from 'mobx';
|
|
13
|
+
export class AsyncDataSource {
|
|
20
14
|
constructor(operations, idSelector, withCache) {
|
|
21
15
|
Object.defineProperty(this, "idSelector", {
|
|
22
16
|
enumerable: true,
|
|
@@ -57,14 +51,14 @@ class AsyncDataSource {
|
|
|
57
51
|
if (this.cancelation) {
|
|
58
52
|
this.cancelation.cancel();
|
|
59
53
|
}
|
|
60
|
-
if (this.withCache && this.cached &&
|
|
61
|
-
return (
|
|
54
|
+
if (this.withCache && this.cached && comparer.structural(this.cached.state, state)) {
|
|
55
|
+
return cloneDeep(this.cached.result);
|
|
62
56
|
}
|
|
63
|
-
this.cancelation =
|
|
64
|
-
const result =
|
|
57
|
+
this.cancelation = axios.CancelToken.source();
|
|
58
|
+
const result = toJS(yield this.operations.get(state, this.cancelation.token));
|
|
65
59
|
this.cancelation = undefined;
|
|
66
60
|
this.cached = { state, result };
|
|
67
|
-
return (
|
|
61
|
+
return cloneDeep(result);
|
|
68
62
|
});
|
|
69
63
|
}
|
|
70
64
|
addData(row, index) {
|
|
@@ -97,5 +91,4 @@ class AsyncDataSource {
|
|
|
97
91
|
});
|
|
98
92
|
}
|
|
99
93
|
}
|
|
100
|
-
exports.AsyncDataSource = AsyncDataSource;
|
|
101
94
|
//# sourceMappingURL=async-data-source.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-data-source.js","sourceRoot":"","sources":["../../src/data-source/async-data-source.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"async-data-source.js","sourceRoot":"","sources":["../../src/data-source/async-data-source.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAE9D,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAStC,MAAM,OAAO,eAAe;IAaxB,YAAY,UAA8B,EAAE,UAA4B,EAAE,SAAmB;QAZ7F;;;;;WAA6B;QAE7B;;;;;WAAuC;QAEvC;;;;;WAA4B;QAC5B;;;;;WAGE;QAEF;;;;;WAAwC;QAGpC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAEK,OAAO,CAAC,KAAY;;YACtB,IAAI,IAAI,CAAC,WAAW,EAAE;gBAClB,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;aAC7B;YAED,IAAI,IAAI,CAAC,SAAS,IAAI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,CAAC;aACrD;YAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAEhD,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;YAExB,OAAO,MAAM,CAAC;QAClB,CAAC;KAAA;CACJ"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,16 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const filter_expression_factory_1 = require("../filtering/filter-expression.factory");
|
|
17
|
-
const array_operators_1 = require("../array.operators");
|
|
18
|
-
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
19
|
-
const mobx_1 = require("mobx");
|
|
20
|
-
class InMemoryDataSource {
|
|
10
|
+
import { filterBy } from '../filtering/filter-expression.factory';
|
|
11
|
+
import { process } from '../array.operators';
|
|
12
|
+
import cloneDeep from 'lodash/cloneDeep';
|
|
13
|
+
import { toJS, comparer } from 'mobx';
|
|
14
|
+
export class InMemoryDataSource {
|
|
21
15
|
constructor(data, idSelector, preprocessors = {}) {
|
|
22
16
|
Object.defineProperty(this, "idSelector", {
|
|
23
17
|
enumerable: true,
|
|
@@ -43,35 +37,35 @@ class InMemoryDataSource {
|
|
|
43
37
|
writable: true,
|
|
44
38
|
value: void 0
|
|
45
39
|
});
|
|
46
|
-
this.data = (
|
|
40
|
+
this.data = cloneDeep(toJS(data));
|
|
47
41
|
this.idSelector = idSelector;
|
|
48
42
|
this.preprocessors = preprocessors;
|
|
49
43
|
}
|
|
50
44
|
getData(state) {
|
|
51
45
|
const { skip, take, sort, filter, group } = state;
|
|
52
|
-
const sortedAndFiltered = this.cached &&
|
|
46
|
+
const sortedAndFiltered = this.cached && comparer.structural(this.cached.state, { sort, filter })
|
|
53
47
|
? this.cached.result
|
|
54
|
-
:
|
|
48
|
+
: process(this.data, { sort, filter }, this.preprocessors);
|
|
55
49
|
this.cached = {
|
|
56
50
|
state: { sort, filter },
|
|
57
51
|
result: sortedAndFiltered,
|
|
58
52
|
};
|
|
59
|
-
const { data } =
|
|
53
|
+
const { data } = process(sortedAndFiltered.data, { skip, take, group }, this.preprocessors);
|
|
60
54
|
const { total } = sortedAndFiltered;
|
|
61
55
|
return Promise.resolve({
|
|
62
56
|
total,
|
|
63
|
-
data: (
|
|
57
|
+
data: cloneDeep(data),
|
|
64
58
|
});
|
|
65
59
|
}
|
|
66
60
|
addData(row, index) {
|
|
67
61
|
if (index !== undefined) {
|
|
68
|
-
this.data.splice(index, 0, (
|
|
62
|
+
this.data.splice(index, 0, cloneDeep(row));
|
|
69
63
|
}
|
|
70
64
|
else {
|
|
71
|
-
this.data.push((
|
|
65
|
+
this.data.push(cloneDeep(row));
|
|
72
66
|
}
|
|
73
67
|
this.cached = undefined;
|
|
74
|
-
return Promise.resolve((
|
|
68
|
+
return Promise.resolve(cloneDeep(row));
|
|
75
69
|
}
|
|
76
70
|
updateData(id, changes) {
|
|
77
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -102,10 +96,9 @@ class InMemoryDataSource {
|
|
|
102
96
|
}
|
|
103
97
|
getFilteredPersistentItems(filter) {
|
|
104
98
|
const set = new Set(this.data);
|
|
105
|
-
const inFilter =
|
|
99
|
+
const inFilter = filterBy(this.data, filter, this.preprocessors);
|
|
106
100
|
inFilter.forEach(dataItem => set.delete(dataItem));
|
|
107
|
-
return (
|
|
101
|
+
return cloneDeep(Array.from(set));
|
|
108
102
|
}
|
|
109
103
|
}
|
|
110
|
-
exports.InMemoryDataSource = InMemoryDataSource;
|
|
111
104
|
//# sourceMappingURL=in-memory-data-source.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-memory-data-source.js","sourceRoot":"","sources":["../../src/data-source/in-memory-data-source.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"in-memory-data-source.js","sourceRoot":"","sources":["../../src/data-source/in-memory-data-source.ts"],"names":[],"mappings":";;;;;;;;;AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAEtC,MAAM,OAAO,kBAAkB;IAW3B,YAAY,IAAS,EAAE,UAA4B,EAAE,gBAAkC,EAAE;QAVzF;;;;;WAA6B;QAE7B;;;;;WAAkB;QAClB;;;;;WAAwC;QAExC;;;;;WAGE;QAGE,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACvC,CAAC;IAED,OAAO,CAAC,KAAY;QAChB,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;QAElD,MAAM,iBAAiB,GACnB,IAAI,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;YACnE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;YACpB,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE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DataSource", { enumerable: true, get: function () { return in_memory_data_source_1.InMemoryDataSource; } });
|
|
6
|
-
var async_data_source_1 = require("./async-data-source");
|
|
7
|
-
Object.defineProperty(exports, "AsyncDataSource", { enumerable: true, get: function () { return async_data_source_1.AsyncDataSource; } });
|
|
1
|
+
export { InMemoryDataSource } from './in-memory-data-source';
|
|
2
|
+
export { AsyncDataSource } from './async-data-source';
|
|
8
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-source/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-source/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serializeFilters = exports.isDateValue = exports.isStringValue = exports.normalizeField = exports.toLower = exports.encodeValue = exports.quote = exports.toUTC = exports.wrapIf = void 0;
|
|
4
|
-
const utils_1 = require("./utils");
|
|
1
|
+
import { isString, isDate } from './utils';
|
|
5
2
|
/**
|
|
6
3
|
* @hidden
|
|
7
4
|
* Creates a single arity function which wraps the value based on the provided predicate.
|
|
@@ -12,71 +9,62 @@ const utils_1 = require("./utils");
|
|
|
12
9
|
* //ignoreCase=false -> ${field}`
|
|
13
10
|
* ```
|
|
14
11
|
*/
|
|
15
|
-
const wrapIf = predicate => (str, ...args) => predicate() ? `${str[0]}${args[0]}${str[1]}` : args[0];
|
|
16
|
-
exports.wrapIf = wrapIf;
|
|
12
|
+
export const wrapIf = predicate => (str, ...args) => predicate() ? `${str[0]}${args[0]}${str[1]}` : args[0];
|
|
17
13
|
/**
|
|
18
14
|
* @hidden
|
|
19
15
|
*/
|
|
20
|
-
const toUTC = (date) => new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
|
|
21
|
-
exports.toUTC = toUTC;
|
|
16
|
+
export const toUTC = (date) => new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
|
|
22
17
|
/**
|
|
23
18
|
* @hidden
|
|
24
19
|
*/
|
|
25
|
-
const quote = ({ field, value, ignoreCase, operator }) => ({
|
|
20
|
+
export const quote = ({ field, value, ignoreCase, operator }) => ({
|
|
26
21
|
value: `'${value.replace(/'/g, "''")}'`,
|
|
27
22
|
field,
|
|
28
23
|
ignoreCase,
|
|
29
24
|
operator
|
|
30
25
|
});
|
|
31
|
-
exports.quote = quote;
|
|
32
26
|
/**
|
|
33
27
|
* @hidden
|
|
34
28
|
*/
|
|
35
|
-
const encodeValue = ({ field, value, ignoreCase, operator }) => ({
|
|
29
|
+
export const encodeValue = ({ field, value, ignoreCase, operator }) => ({
|
|
36
30
|
value: `${encodeURIComponent(value)}`,
|
|
37
31
|
field,
|
|
38
32
|
ignoreCase,
|
|
39
33
|
operator
|
|
40
34
|
});
|
|
41
|
-
exports.encodeValue = encodeValue;
|
|
42
35
|
/**
|
|
43
36
|
* @hidden
|
|
44
37
|
*/
|
|
45
|
-
const toLower = ({ field, value, ignoreCase, operator }) => ({
|
|
46
|
-
field:
|
|
38
|
+
export const toLower = ({ field, value, ignoreCase, operator }) => ({
|
|
39
|
+
field: wrapIf(() => ignoreCase) `tolower(${field})`,
|
|
47
40
|
value,
|
|
48
41
|
ignoreCase,
|
|
49
42
|
operator
|
|
50
43
|
});
|
|
51
|
-
exports.toLower = toLower;
|
|
52
44
|
/**
|
|
53
45
|
* @hidden
|
|
54
46
|
*/
|
|
55
|
-
const normalizeField = ({ field, value, ignoreCase, operator }) => ({
|
|
47
|
+
export const normalizeField = ({ field, value, ignoreCase, operator }) => ({
|
|
56
48
|
value,
|
|
57
49
|
field: field.replace(/\./g, "/"),
|
|
58
50
|
ignoreCase,
|
|
59
51
|
operator
|
|
60
52
|
});
|
|
61
|
-
exports.normalizeField = normalizeField;
|
|
62
53
|
/**
|
|
63
54
|
* @hidden
|
|
64
55
|
*/
|
|
65
|
-
const isStringValue = x =>
|
|
66
|
-
exports.isStringValue = isStringValue;
|
|
56
|
+
export const isStringValue = x => isString(x.value);
|
|
67
57
|
/**
|
|
68
58
|
* @hidden
|
|
69
59
|
*/
|
|
70
|
-
const isDateValue = x =>
|
|
71
|
-
exports.isDateValue = isDateValue;
|
|
60
|
+
export const isDateValue = x => isDate(x.value);
|
|
72
61
|
/**
|
|
73
62
|
* @hidden
|
|
74
63
|
*/
|
|
75
|
-
const serializeFilters = (map, join) => (filter) => {
|
|
76
|
-
const brackets =
|
|
64
|
+
export const serializeFilters = (map, join) => (filter) => {
|
|
65
|
+
const brackets = wrapIf(() => filter.filters.length > 1);
|
|
77
66
|
return brackets `(${filter.filters
|
|
78
67
|
.map(map)
|
|
79
68
|
.join(join(filter))})`;
|
|
80
69
|
};
|
|
81
|
-
exports.serializeFilters = serializeFilters;
|
|
82
70
|
//# 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":"
|
|
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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AAC,MAAM,cAAc,GAAmB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;IACvF,KAAK;IACL,KAAK,EAAW,KAAM,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;IAC1C,UAAU;IACV,QAAQ;CACX,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AACpD;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,MAAiC,EAAU,EAAE;IACzF,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACzD,OAAO,QAAQ,CAAA,IACX,MAAM,CAAC,OAAO;SACT,GAAG,CAAC,GAAG,CAAC;SACR,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CACtB,GAAG,CAAC;AACZ,CAAC,CAAC"}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isCompositeFilterDescriptor = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
1
|
+
import { isPresent } from '../utils';
|
|
5
2
|
// tslint:enable:max-line-length
|
|
6
3
|
/**
|
|
7
4
|
* @hidden
|
|
8
5
|
* Type guard for `CompositeFilterDescriptor`.
|
|
9
6
|
*/
|
|
10
|
-
const isCompositeFilterDescriptor = (source) => {
|
|
11
|
-
return
|
|
7
|
+
export const isCompositeFilterDescriptor = (source) => {
|
|
8
|
+
return isPresent(source.filters);
|
|
12
9
|
};
|
|
13
|
-
exports.isCompositeFilterDescriptor = isCompositeFilterDescriptor;
|
|
14
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":"
|
|
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,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const filter_descriptor_interface_1 = require("./filter-descriptor.interface");
|
|
6
|
-
const filter_operators_1 = require("./filter.operators");
|
|
7
|
-
const filter_no_eval_1 = require("./filter-no-eval");
|
|
1
|
+
import { isPresent } from '../utils';
|
|
2
|
+
import { isCompositeFilterDescriptor } from './filter-descriptor.interface';
|
|
3
|
+
import { normalizeFilters } from './filter.operators';
|
|
4
|
+
import { transformCompositeFilter } from "./filter-no-eval";
|
|
8
5
|
// tslint:disable:max-line-length
|
|
9
6
|
/**
|
|
10
7
|
* Creates a [`Predicate`]({% slug api_kendo-data-query_predicate %}) function for the specified [`CompositeFilterDescriptor`]({% slug api_kendo-data-query_compositefilterdescriptor %}).
|
|
@@ -23,13 +20,12 @@ const filter_no_eval_1 = require("./filter-no-eval");
|
|
|
23
20
|
* ```
|
|
24
21
|
*/
|
|
25
22
|
// tslint:enable:max-line-length
|
|
26
|
-
const compileFilter = (descriptor, preprocessors = {}) => {
|
|
23
|
+
export const compileFilter = (descriptor, preprocessors = {}) => {
|
|
27
24
|
if (!descriptor || descriptor.filters.length === 0) {
|
|
28
25
|
return () => true;
|
|
29
26
|
}
|
|
30
|
-
return
|
|
27
|
+
return transformCompositeFilter(descriptor, preprocessors);
|
|
31
28
|
};
|
|
32
|
-
exports.compileFilter = compileFilter;
|
|
33
29
|
// tslint:disable:max-line-length
|
|
34
30
|
/**
|
|
35
31
|
* Filters the provided array according to the specified [`CompositeFilterDescriptor`]({% slug api_kendo-data-query_compositefilterdescriptor %}).
|
|
@@ -61,11 +57,10 @@ exports.compileFilter = compileFilter;
|
|
|
61
57
|
* ```
|
|
62
58
|
*/
|
|
63
59
|
// tslint:enable:max-line-length
|
|
64
|
-
const filterBy = (data, descriptor, preprocessors = {}) => {
|
|
65
|
-
if (!
|
|
60
|
+
export const filterBy = (data, descriptor, preprocessors = {}) => {
|
|
61
|
+
if (!isPresent(descriptor) || (isCompositeFilterDescriptor(descriptor) && descriptor.filters.length === 0)) {
|
|
66
62
|
return data;
|
|
67
63
|
}
|
|
68
|
-
return data.filter(
|
|
64
|
+
return data.filter(compileFilter(normalizeFilters(descriptor), preprocessors));
|
|
69
65
|
};
|
|
70
|
-
exports.filterBy = filterBy;
|
|
71
66
|
//# 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":"
|
|
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;QAChD,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC;KACrB;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;QACxG,OAAO,IAAI,CAAC;KACf;IAED,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;AACnF,CAAC,CAAC"}
|