angular-odata 0.140.0 → 0.140.1
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/fesm2022/angular-odata.mjs +46 -37
- package/fesm2022/angular-odata.mjs.map +1 -1
- package/index.d.ts +32 -38
- package/package.json +1 -1
|
@@ -497,21 +497,19 @@ const SUPPORTED_EXPAND_PROPERTIES = [
|
|
|
497
497
|
];
|
|
498
498
|
const FUNCTION_REGEX = /\((.*)\)/;
|
|
499
499
|
const INDEXOF_REGEX = /(?!indexof)\((\w+)\)/;
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
QueryCustomTypes[QueryCustomTypes["Binary"] = 3] = "Binary";
|
|
514
|
-
})(QueryCustomTypes || (QueryCustomTypes = {}));
|
|
500
|
+
const StandardAggregateMethods = {
|
|
501
|
+
sum: 'sum',
|
|
502
|
+
min: 'min',
|
|
503
|
+
max: 'max',
|
|
504
|
+
average: 'average',
|
|
505
|
+
countdistinct: 'countdistinct'
|
|
506
|
+
};
|
|
507
|
+
const QueryCustomTypes = {
|
|
508
|
+
Raw: 'Raw',
|
|
509
|
+
Alias: 'Alias',
|
|
510
|
+
Duration: 'Duration',
|
|
511
|
+
Binary: 'Binary'
|
|
512
|
+
};
|
|
515
513
|
//https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_QueryOptions
|
|
516
514
|
const raw = (value) => ({
|
|
517
515
|
type: QueryCustomTypes.Raw,
|
|
@@ -887,10 +885,8 @@ function buildFilter(filters = {}, { aliases, propPrefix, escape, }) {
|
|
|
887
885
|
}
|
|
888
886
|
}
|
|
889
887
|
function getStringCollectionClause(lambdaParameter, value, collectionOperator, propName) {
|
|
890
|
-
let clause = '';
|
|
891
888
|
const conditionOperator = collectionOperator == 'all' ? 'ne' : 'eq';
|
|
892
|
-
|
|
893
|
-
return clause;
|
|
889
|
+
return `${propName}/${collectionOperator}(${lambdaParameter}: ${lambdaParameter} ${conditionOperator} '${value}')`;
|
|
894
890
|
}
|
|
895
891
|
function escapeIllegalChars(string) {
|
|
896
892
|
string = string.replace(/%/g, '%25');
|
|
@@ -1028,27 +1024,40 @@ function buildTransforms(transforms, { aliases, escape = false }) {
|
|
|
1028
1024
|
// Wrap single object an array for simplified processing
|
|
1029
1025
|
const transformsArray = Array.isArray(transforms) ? transforms : [transforms];
|
|
1030
1026
|
const transformsResult = transformsArray.reduce((result, transform) => {
|
|
1031
|
-
const
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1027
|
+
for (const key of Object.keys(transform)) {
|
|
1028
|
+
switch (key) {
|
|
1029
|
+
// TODO: support as many of the following:
|
|
1030
|
+
// topcount, topsum, toppercent,
|
|
1031
|
+
// bottomsum, bottomcount, bottompercent,
|
|
1032
|
+
// identity, concat, expand, search, compute, isdefined
|
|
1033
|
+
case 'aggregate': {
|
|
1034
|
+
const aggregate = transform[key];
|
|
1035
|
+
if (aggregate) {
|
|
1036
|
+
result.push(`aggregate(${buildAggregate(aggregate)})`);
|
|
1037
|
+
}
|
|
1038
|
+
break;
|
|
1039
|
+
}
|
|
1040
|
+
case 'filter': {
|
|
1041
|
+
const filter = transform[key];
|
|
1042
|
+
if (filter) {
|
|
1043
|
+
const builtFilter = buildFilter(filter, { aliases, escape });
|
|
1044
|
+
if (builtFilter) {
|
|
1045
|
+
result.push(`filter(${builtFilter})`);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
break;
|
|
1049
|
+
}
|
|
1050
|
+
case 'groupBy': {
|
|
1051
|
+
const groupBy = transform[key];
|
|
1052
|
+
if (groupBy) {
|
|
1053
|
+
result.push(`groupby(${buildGroupBy(groupBy, { aliases, escape })})`);
|
|
1054
|
+
}
|
|
1055
|
+
break;
|
|
1056
|
+
}
|
|
1057
|
+
default:
|
|
1058
|
+
throw new Error(`Unsupported transform(s): ${key}`);
|
|
1047
1059
|
}
|
|
1048
1060
|
}
|
|
1049
|
-
if (groupBy) {
|
|
1050
|
-
result.push(`groupby(${buildGroupBy(groupBy, { aliases, escape })})`);
|
|
1051
|
-
}
|
|
1052
1061
|
return result;
|
|
1053
1062
|
}, []);
|
|
1054
1063
|
return transformsResult.join('/') || undefined;
|