angular-odata 0.122.0 → 0.124.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/esm2022/lib/api.mjs +373 -0
- package/esm2022/lib/cache/cache.mjs +175 -0
- package/{esm2020 → esm2022}/lib/cache/storage.mjs +1 -1
- package/esm2022/lib/client.mjs +252 -0
- package/{esm2020 → esm2022}/lib/helper.mjs +1 -1
- package/{esm2020 → esm2022}/lib/loaders.mjs +1 -1
- package/esm2022/lib/models/collection.mjs +865 -0
- package/esm2022/lib/models/model.mjs +535 -0
- package/esm2022/lib/models/options.mjs +1117 -0
- package/{esm2020 → esm2022}/lib/module.mjs +5 -5
- package/esm2022/lib/resources/path/segments.mjs +124 -0
- package/esm2022/lib/resources/query/builder.mjs +624 -0
- package/esm2022/lib/resources/query/expressions/base.mjs +20 -0
- package/esm2022/lib/resources/query/expressions/compute.mjs +39 -0
- package/esm2022/lib/resources/query/expressions/count.mjs +99 -0
- package/esm2022/lib/resources/query/expressions/expand.mjs +125 -0
- package/esm2022/lib/resources/query/expressions/filter.mjs +161 -0
- package/esm2022/lib/resources/query/expressions/orderby.mjs +56 -0
- package/esm2022/lib/resources/query/expressions/search.mjs +122 -0
- package/esm2022/lib/resources/query/expressions/select.mjs +31 -0
- package/esm2022/lib/resources/query/expressions/syntax.mjs +444 -0
- package/{esm2020 → esm2022}/lib/resources/query/handlers.mjs +1 -1
- package/esm2022/lib/resources/query/options.mjs +115 -0
- package/{esm2020 → esm2022}/lib/resources/request.mjs +1 -1
- package/esm2022/lib/resources/resource.mjs +257 -0
- package/{esm2020 → esm2022}/lib/resources/responses/annotations.mjs +1 -1
- package/esm2022/lib/resources/responses/csdl/csdl-annotation.mjs +33 -0
- package/{esm2020 → esm2022}/lib/resources/responses/csdl/csdl-entity-container.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/responses/csdl/csdl-entity-set.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/responses/csdl/csdl-enum-type.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/responses/csdl/csdl-function-action.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/responses/csdl/csdl-navigation-property-binding.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/responses/csdl/csdl-reference.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/responses/csdl/csdl-schema.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/responses/csdl/csdl-singleton.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/responses/csdl/csdl-structural-property.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/responses/csdl/csdl-structured-type.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/responses/csdl/csdl-type-definition.mjs +1 -1
- package/esm2022/lib/resources/responses/metadata.mjs +547 -0
- package/{esm2020 → esm2022}/lib/resources/responses/response.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/types/action.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/types/batch.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/types/count.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/types/entity-set.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/types/entity.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/types/function.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/types/media.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/types/navigation-property.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/types/property.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/types/reference.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/types/singleton.mjs +1 -1
- package/{esm2020 → esm2022}/lib/resources/types/value.mjs +1 -1
- package/{esm2020 → esm2022}/lib/schema/annotation.mjs +1 -1
- package/{esm2020 → esm2022}/lib/schema/callable.mjs +1 -1
- package/{esm2020 → esm2022}/lib/schema/element.mjs +1 -1
- package/{esm2020 → esm2022}/lib/schema/entity-container.mjs +1 -1
- package/{esm2020 → esm2022}/lib/schema/enum-type.mjs +1 -1
- package/{esm2020 → esm2022}/lib/schema/parsers/callable.mjs +1 -1
- package/esm2022/lib/schema/parsers/edm.mjs +99 -0
- package/{esm2020 → esm2022}/lib/schema/parsers/enum-type.mjs +2 -2
- package/esm2022/lib/schema/parsers/structured-type.mjs +502 -0
- package/{esm2020 → esm2022}/lib/schema/schema.mjs +1 -1
- package/esm2022/lib/schema/structured-type.mjs +207 -0
- package/esm2022/lib/services/base.mjs +29 -0
- package/{esm2020 → esm2022}/lib/services/entity-set.mjs +1 -1
- package/{esm2020 → esm2022}/lib/services/factory.mjs +4 -4
- package/{esm2020 → esm2022}/lib/services/singleton.mjs +1 -1
- package/{esm2020 → esm2022}/lib/settings.mjs +1 -1
- package/{esm2020 → esm2022}/lib/types.mjs +1 -1
- package/{esm2020 → esm2022}/lib/utils/arrays.mjs +1 -1
- package/{esm2020 → esm2022}/lib/utils/durations.mjs +1 -1
- package/esm2022/lib/utils/enums.mjs +61 -0
- package/{esm2020 → esm2022}/lib/utils/http.mjs +1 -1
- package/{esm2020 → esm2022}/lib/utils/objects.mjs +1 -1
- package/{esm2020 → esm2022}/lib/utils/odata.mjs +1 -1
- package/esm2022/lib/utils/types.mjs +136 -0
- package/{fesm2020 → fesm2022}/angular-odata.mjs +544 -373
- package/fesm2022/angular-odata.mjs.map +1 -0
- package/lib/helper.d.ts +1 -1
- package/lib/models/model.d.ts +4 -2
- package/lib/models/options.d.ts +7 -8
- package/lib/resources/path/segments.d.ts +15 -6
- package/lib/resources/query/builder.d.ts +21 -20
- package/lib/resources/query/expressions/base.d.ts +6 -4
- package/lib/resources/query/expressions/compute.d.ts +10 -8
- package/lib/resources/query/expressions/count.d.ts +14 -11
- package/lib/resources/query/expressions/expand.d.ts +23 -19
- package/lib/resources/query/expressions/filter.d.ts +22 -20
- package/lib/resources/query/expressions/orderby.d.ts +12 -9
- package/lib/resources/query/expressions/search.d.ts +12 -9
- package/lib/resources/query/expressions/select.d.ts +9 -7
- package/lib/resources/query/expressions/syntax.d.ts +75 -71
- package/lib/resources/query/handlers.d.ts +2 -2
- package/lib/resources/query/options.d.ts +15 -6
- package/lib/resources/resource.d.ts +2 -2
- package/lib/resources/responses/types.d.ts +3 -3
- package/lib/resources/types/options.d.ts +7 -7
- package/lib/schema/parsers/structured-type.d.ts +8 -5
- package/lib/schema/structured-type.d.ts +2 -1
- package/lib/types.d.ts +15 -15
- package/lib/utils/durations.d.ts +1 -1
- package/lib/utils/enums.d.ts +3 -0
- package/lib/utils/types.d.ts +1 -0
- package/package.json +9 -15
- package/esm2020/lib/api.mjs +0 -373
- package/esm2020/lib/cache/cache.mjs +0 -173
- package/esm2020/lib/client.mjs +0 -252
- package/esm2020/lib/models/collection.mjs +0 -861
- package/esm2020/lib/models/model.mjs +0 -507
- package/esm2020/lib/models/options.mjs +0 -1110
- package/esm2020/lib/resources/path/segments.mjs +0 -124
- package/esm2020/lib/resources/query/builder.mjs +0 -588
- package/esm2020/lib/resources/query/expressions/base.mjs +0 -20
- package/esm2020/lib/resources/query/expressions/compute.mjs +0 -39
- package/esm2020/lib/resources/query/expressions/count.mjs +0 -89
- package/esm2020/lib/resources/query/expressions/expand.mjs +0 -115
- package/esm2020/lib/resources/query/expressions/filter.mjs +0 -161
- package/esm2020/lib/resources/query/expressions/orderby.mjs +0 -56
- package/esm2020/lib/resources/query/expressions/search.mjs +0 -122
- package/esm2020/lib/resources/query/expressions/select.mjs +0 -31
- package/esm2020/lib/resources/query/expressions/syntax.mjs +0 -409
- package/esm2020/lib/resources/query/options.mjs +0 -115
- package/esm2020/lib/resources/resource.mjs +0 -251
- package/esm2020/lib/resources/responses/csdl/csdl-annotation.mjs +0 -33
- package/esm2020/lib/resources/responses/metadata.mjs +0 -547
- package/esm2020/lib/schema/parsers/edm.mjs +0 -104
- package/esm2020/lib/schema/parsers/structured-type.mjs +0 -490
- package/esm2020/lib/schema/structured-type.mjs +0 -202
- package/esm2020/lib/services/base.mjs +0 -29
- package/esm2020/lib/utils/enums.mjs +0 -45
- package/esm2020/lib/utils/types.mjs +0 -133
- package/fesm2015/angular-odata.mjs +0 -11811
- package/fesm2015/angular-odata.mjs.map +0 -1
- package/fesm2020/angular-odata.mjs.map +0 -1
- /package/{esm2020 → esm2022}/angular-odata.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/cache/index.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/cache/memory.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/constants.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/index.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/models/index.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/options.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/resources/index.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/resources/path/handlers.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/resources/path/index.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/resources/query/expressions/index.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/resources/query/index.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/resources/responses/index.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/resources/responses/options.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/resources/responses/types.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/resources/types/index.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/resources/types/metadata.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/resources/types/options.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/schema/entity-set.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/schema/index.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/schema/parsers/index.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/services/entity.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/services/index.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/utils/arraybuffers.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/utils/dates.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/utils/index.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/utils/strings.mjs +0 -0
- /package/{esm2020 → esm2022}/lib/utils/urls.mjs +0 -0
- /package/{esm2020 → esm2022}/public-api.mjs +0 -0
|
@@ -231,7 +231,9 @@ class ODataCache {
|
|
|
231
231
|
const tags = [];
|
|
232
232
|
const context = res.context;
|
|
233
233
|
if (context.entitySet) {
|
|
234
|
-
tags.push(context.key
|
|
234
|
+
tags.push(context.key
|
|
235
|
+
? `${context.entitySet}(${context.key})`
|
|
236
|
+
: context.entitySet);
|
|
235
237
|
}
|
|
236
238
|
if (context.type)
|
|
237
239
|
tags.push(context.type);
|
|
@@ -453,6 +455,8 @@ const binary = (value) => ({
|
|
|
453
455
|
const isQueryCustomType = (value) => typeof value === 'object' &&
|
|
454
456
|
'type' in value &&
|
|
455
457
|
value.type in QueryCustomTypes;
|
|
458
|
+
const isRawType = (value) => isQueryCustomType(value) &&
|
|
459
|
+
value.type === QueryCustomTypes.Raw;
|
|
456
460
|
const ITEM_ROOT = '';
|
|
457
461
|
function builder ({ select, search, skiptoken, format, top, skip, filter, transform, orderBy, key, count, expand, action, func, aliases, escape, } = {}) {
|
|
458
462
|
const [path, params] = buildPathAndQuery({
|
|
@@ -483,45 +487,67 @@ function buildPathAndQuery({ select, search, skiptoken, format, top, skip, filte
|
|
|
483
487
|
if (key != undefined) {
|
|
484
488
|
path += `(${normalizeValue(key, { aliases, escape })})`;
|
|
485
489
|
}
|
|
490
|
+
// Select
|
|
486
491
|
if (select) {
|
|
487
|
-
query.$select =
|
|
492
|
+
query.$select = isRawType(select)
|
|
493
|
+
? select.value
|
|
494
|
+
: Array.isArray(select)
|
|
495
|
+
? select.join(',')
|
|
496
|
+
: select;
|
|
488
497
|
}
|
|
498
|
+
// Search
|
|
489
499
|
if (search) {
|
|
490
500
|
query.$search = search;
|
|
491
501
|
}
|
|
502
|
+
// Skiptoken
|
|
492
503
|
if (skiptoken) {
|
|
493
504
|
query.$skiptoken = skiptoken;
|
|
494
505
|
}
|
|
506
|
+
// Format
|
|
495
507
|
if (format) {
|
|
496
508
|
query.$format = format;
|
|
497
509
|
}
|
|
510
|
+
// Filter
|
|
498
511
|
if (filter || typeof count === 'object') {
|
|
499
512
|
query.$filter = buildFilter(typeof count === 'object' ? count : filter, {
|
|
500
513
|
aliases,
|
|
501
514
|
escape,
|
|
502
515
|
});
|
|
503
516
|
}
|
|
517
|
+
// Transform
|
|
504
518
|
if (transform) {
|
|
505
519
|
query.$apply = buildTransforms(transform, { aliases, escape });
|
|
506
520
|
}
|
|
521
|
+
// Expand
|
|
507
522
|
if (expand) {
|
|
508
523
|
query.$expand = buildExpand(expand, { aliases, escape });
|
|
509
524
|
}
|
|
525
|
+
// OrderBy
|
|
510
526
|
if (orderBy) {
|
|
511
527
|
query.$orderby = buildOrderBy(orderBy);
|
|
512
528
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
529
|
+
// Count
|
|
530
|
+
if (isRawType(count)) {
|
|
531
|
+
query.$count = count.value;
|
|
532
|
+
}
|
|
533
|
+
else if (typeof count === 'boolean') {
|
|
534
|
+
query.$count = true;
|
|
535
|
+
}
|
|
536
|
+
else if (count) {
|
|
537
|
+
path += '/$count';
|
|
538
|
+
}
|
|
539
|
+
// Top
|
|
540
|
+
if (isRawType(top)) {
|
|
541
|
+
query.$top = top.value;
|
|
520
542
|
}
|
|
521
|
-
if (typeof top === 'number') {
|
|
543
|
+
else if (typeof top === 'number') {
|
|
522
544
|
query.$top = top;
|
|
523
545
|
}
|
|
524
|
-
|
|
546
|
+
// Skip
|
|
547
|
+
if (isRawType(skip)) {
|
|
548
|
+
query.$top = skip.value;
|
|
549
|
+
}
|
|
550
|
+
else if (typeof skip === 'number') {
|
|
525
551
|
query.$skip = skip;
|
|
526
552
|
}
|
|
527
553
|
if (action) {
|
|
@@ -572,7 +598,11 @@ function buildFilter(filters = {}, { aliases, propPrefix, escape, }) {
|
|
|
572
598
|
}, []).join(' and ');
|
|
573
599
|
function buildFilterCore(filter = {}, { aliases, propPrefix, escape, }) {
|
|
574
600
|
let filterExpr = '';
|
|
575
|
-
if (
|
|
601
|
+
if (isRawType(filter)) {
|
|
602
|
+
// Use raw query custom filter string
|
|
603
|
+
filterExpr = filter.value;
|
|
604
|
+
}
|
|
605
|
+
else if (typeof filter === 'string') {
|
|
576
606
|
// Use raw filter string
|
|
577
607
|
filterExpr = filter;
|
|
578
608
|
}
|
|
@@ -830,8 +860,11 @@ function normalizeValue(value, { aliases, escape = false, } = {}) {
|
|
|
830
860
|
}
|
|
831
861
|
return value;
|
|
832
862
|
}
|
|
833
|
-
function buildExpand(expands, { aliases, escape = false }) {
|
|
834
|
-
if (
|
|
863
|
+
function buildExpand(expands, { aliases, escape = false, }) {
|
|
864
|
+
if (isRawType(expands)) {
|
|
865
|
+
return expands.value;
|
|
866
|
+
}
|
|
867
|
+
else if (typeof expands === 'number') {
|
|
835
868
|
return expands;
|
|
836
869
|
}
|
|
837
870
|
else if (typeof expands === 'string') {
|
|
@@ -883,6 +916,8 @@ function buildExpand(expands, { aliases, escape = false }) {
|
|
|
883
916
|
case 'top':
|
|
884
917
|
case 'skip':
|
|
885
918
|
value = `${expands[key]}`;
|
|
919
|
+
if (isRawType(value))
|
|
920
|
+
value = value.value;
|
|
886
921
|
break;
|
|
887
922
|
default:
|
|
888
923
|
value = buildExpand(expands[key], { aliases, escape });
|
|
@@ -902,7 +937,7 @@ function buildExpand(expands, { aliases, escape = false }) {
|
|
|
902
937
|
}
|
|
903
938
|
return '';
|
|
904
939
|
}
|
|
905
|
-
function buildTransforms(transforms, { aliases, escape = false }) {
|
|
940
|
+
function buildTransforms(transforms, { aliases, escape = false, }) {
|
|
906
941
|
// Wrap single object an array for simplified processing
|
|
907
942
|
const transformsArray = Array.isArray(transforms) ? transforms : [transforms];
|
|
908
943
|
const transformsResult = transformsArray.reduce((result, transform) => {
|
|
@@ -952,7 +987,7 @@ function buildAggregate(aggregate) {
|
|
|
952
987
|
})
|
|
953
988
|
.join(',');
|
|
954
989
|
}
|
|
955
|
-
function buildGroupBy(groupBy, { aliases, escape = false }) {
|
|
990
|
+
function buildGroupBy(groupBy, { aliases, escape = false, }) {
|
|
956
991
|
if (!groupBy.properties) {
|
|
957
992
|
throw new Error(`'properties' property required for groupBy`);
|
|
958
993
|
}
|
|
@@ -963,7 +998,10 @@ function buildGroupBy(groupBy, { aliases, escape = false }) {
|
|
|
963
998
|
return result;
|
|
964
999
|
}
|
|
965
1000
|
function buildOrderBy(orderBy, prefix = '') {
|
|
966
|
-
if (
|
|
1001
|
+
if (isRawType(orderBy)) {
|
|
1002
|
+
return orderBy.value;
|
|
1003
|
+
}
|
|
1004
|
+
else if (Array.isArray(orderBy)) {
|
|
967
1005
|
return orderBy
|
|
968
1006
|
.map((value) => Array.isArray(value) &&
|
|
969
1007
|
value.length === 2 &&
|
|
@@ -1091,6 +1129,22 @@ const Enums = {
|
|
|
1091
1129
|
}
|
|
1092
1130
|
return [];
|
|
1093
1131
|
},
|
|
1132
|
+
toFlags(enums, value) {
|
|
1133
|
+
if (typeof value === 'number') {
|
|
1134
|
+
return this.values(enums)
|
|
1135
|
+
.filter((v) => v !== 0 && (value & v) === v)
|
|
1136
|
+
.map((v) => this.toName(enums, v));
|
|
1137
|
+
}
|
|
1138
|
+
if (typeof value === 'string') {
|
|
1139
|
+
value = value.split(',').map((o) => o.trim());
|
|
1140
|
+
}
|
|
1141
|
+
if (Array.isArray(value) && value.every((v) => v in enums)) {
|
|
1142
|
+
return value
|
|
1143
|
+
.filter((v) => enums[v])
|
|
1144
|
+
.map((v) => this.toName(enums, v));
|
|
1145
|
+
}
|
|
1146
|
+
return [];
|
|
1147
|
+
},
|
|
1094
1148
|
};
|
|
1095
1149
|
|
|
1096
1150
|
function cloneSymbol(targe) {
|
|
@@ -1106,6 +1160,9 @@ const Types = {
|
|
|
1106
1160
|
rawType(value) {
|
|
1107
1161
|
return Object.prototype.toString.call(value).slice(8, -1);
|
|
1108
1162
|
},
|
|
1163
|
+
isObject(value) {
|
|
1164
|
+
return typeof value === 'object' && value !== null;
|
|
1165
|
+
},
|
|
1109
1166
|
isPlainObject(value) {
|
|
1110
1167
|
if (this.rawType(value) !== 'Object') {
|
|
1111
1168
|
return false;
|
|
@@ -1602,39 +1659,36 @@ class Expression {
|
|
|
1602
1659
|
}
|
|
1603
1660
|
}
|
|
1604
1661
|
|
|
1605
|
-
|
|
1606
|
-
constructor(name = '') {
|
|
1607
|
-
this.name = name;
|
|
1608
|
-
}
|
|
1609
|
-
static factory(name = '') {
|
|
1610
|
-
return new Proxy({ _name: name }, new Field$1());
|
|
1611
|
-
}
|
|
1662
|
+
const FieldFactory = (names = []) => new Proxy({ _names: names }, {
|
|
1612
1663
|
get(target, key) {
|
|
1613
|
-
let
|
|
1664
|
+
let names = target['_names'];
|
|
1614
1665
|
if (key === 'render') {
|
|
1615
|
-
return ({ prefix }) => prefix ? `${prefix}/${
|
|
1666
|
+
return ({ prefix }) => prefix ? `${prefix}/${names.join('/')}` : names.join('/');
|
|
1616
1667
|
}
|
|
1617
1668
|
else if (key === 'clone') {
|
|
1618
|
-
return () =>
|
|
1669
|
+
return () => FieldFactory([...names]);
|
|
1619
1670
|
}
|
|
1620
|
-
else if (key ===
|
|
1621
|
-
return () =>
|
|
1671
|
+
else if (key === 'isField') {
|
|
1672
|
+
return () => true;
|
|
1622
1673
|
}
|
|
1623
1674
|
else if (key === 'toJSON') {
|
|
1624
1675
|
return () => ({
|
|
1625
|
-
$type:
|
|
1626
|
-
|
|
1676
|
+
$type: 'Field',
|
|
1677
|
+
names: names,
|
|
1627
1678
|
});
|
|
1628
1679
|
}
|
|
1680
|
+
else if (key === 'resolve') {
|
|
1681
|
+
return (parser) => names.reduce((acc, name) => acc.field(name), parser);
|
|
1682
|
+
}
|
|
1629
1683
|
else {
|
|
1630
|
-
|
|
1631
|
-
return new Proxy({ _name: name }, this);
|
|
1684
|
+
return FieldFactory([...names, key]);
|
|
1632
1685
|
}
|
|
1633
|
-
}
|
|
1686
|
+
},
|
|
1634
1687
|
has(target, key) {
|
|
1635
|
-
return ['toJSON', 'clone', 'render'].includes(key) ||
|
|
1636
|
-
|
|
1637
|
-
}
|
|
1688
|
+
return (['toJSON', 'isField', 'clone', 'render', 'resolve'].includes(key) ||
|
|
1689
|
+
key in target);
|
|
1690
|
+
},
|
|
1691
|
+
});
|
|
1638
1692
|
function applyMixins(derivedCtor, constructors) {
|
|
1639
1693
|
constructors.forEach((baseCtor) => {
|
|
1640
1694
|
Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
|
|
@@ -1643,24 +1697,38 @@ function applyMixins(derivedCtor, constructors) {
|
|
|
1643
1697
|
});
|
|
1644
1698
|
});
|
|
1645
1699
|
}
|
|
1646
|
-
function render(value, { aliases, normalize, escape, prefix, } = {}) {
|
|
1647
|
-
if (
|
|
1648
|
-
return render(value(syntax), { aliases, normalize, prefix });
|
|
1700
|
+
function render(value, { aliases, normalize, escape, prefix, parser, } = {}) {
|
|
1701
|
+
if (Types.isFunction(value)) {
|
|
1702
|
+
return render(value(syntax), { aliases, normalize, prefix, parser });
|
|
1649
1703
|
}
|
|
1650
|
-
if (
|
|
1651
|
-
value
|
|
1652
|
-
value.render !== undefined) {
|
|
1653
|
-
return render(value.render({ aliases, escape, prefix }), {
|
|
1704
|
+
if (Types.isObject(value) && 'render' in value) {
|
|
1705
|
+
return render(value.render({ aliases, escape, prefix, parser }), {
|
|
1654
1706
|
aliases,
|
|
1655
1707
|
normalize,
|
|
1656
1708
|
escape,
|
|
1657
1709
|
prefix,
|
|
1710
|
+
parser,
|
|
1658
1711
|
});
|
|
1659
1712
|
}
|
|
1660
1713
|
return normalize ? normalizeValue(value, { aliases, escape }) : value;
|
|
1661
1714
|
}
|
|
1715
|
+
function resolve(values, parser) {
|
|
1716
|
+
if (parser !== undefined) {
|
|
1717
|
+
let fields = values.filter((v) => Types.isObject(v) && 'isField' in v && v.isField());
|
|
1718
|
+
if (fields.length === 1 && Types.isObject(parser) && 'field' in parser) {
|
|
1719
|
+
return fields[0].resolve(parser);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
return parser;
|
|
1723
|
+
}
|
|
1724
|
+
function encode(values, parser) {
|
|
1725
|
+
if (parser !== undefined) {
|
|
1726
|
+
return values.map((v) => Types.isObject(v) || v === null ? v : parser?.encode(v));
|
|
1727
|
+
}
|
|
1728
|
+
return values;
|
|
1729
|
+
}
|
|
1662
1730
|
class Function {
|
|
1663
|
-
constructor(name, values, normalize
|
|
1731
|
+
constructor(name, values, normalize, escape = false) {
|
|
1664
1732
|
this.name = name;
|
|
1665
1733
|
this.values = values;
|
|
1666
1734
|
this.normalize = normalize;
|
|
@@ -1673,16 +1741,29 @@ class Function {
|
|
|
1673
1741
|
return {
|
|
1674
1742
|
$type: Types.rawType(this),
|
|
1675
1743
|
name: this.name,
|
|
1676
|
-
values: this.values,
|
|
1744
|
+
values: this.values.map((v) => Types.isObject(v) && 'toJSON' in v ? v.toJSON() : v),
|
|
1677
1745
|
normalize: this.normalize,
|
|
1678
1746
|
};
|
|
1679
1747
|
}
|
|
1680
|
-
render({ aliases, escape, prefix, }) {
|
|
1681
|
-
|
|
1682
|
-
|
|
1748
|
+
render({ aliases, escape, prefix, parser, }) {
|
|
1749
|
+
parser = resolve(this.values, parser);
|
|
1750
|
+
let [left, ...values] = encode(this.values, parser);
|
|
1751
|
+
left = render(left, {
|
|
1752
|
+
aliases,
|
|
1753
|
+
escape,
|
|
1754
|
+
prefix,
|
|
1755
|
+
parser,
|
|
1756
|
+
normalize: this.normalize === 'all' || this.normalize === 'left',
|
|
1757
|
+
});
|
|
1683
1758
|
const params = [
|
|
1684
|
-
|
|
1685
|
-
...values.map((v) => render(v, {
|
|
1759
|
+
left,
|
|
1760
|
+
...values.map((v) => render(v, {
|
|
1761
|
+
aliases,
|
|
1762
|
+
escape,
|
|
1763
|
+
prefix,
|
|
1764
|
+
parser,
|
|
1765
|
+
normalize: this.normalize === 'all' || this.normalize === 'right',
|
|
1766
|
+
})),
|
|
1686
1767
|
];
|
|
1687
1768
|
return `${this.name}(${params.join(', ')})`;
|
|
1688
1769
|
}
|
|
@@ -1691,135 +1772,135 @@ class Function {
|
|
|
1691
1772
|
}
|
|
1692
1773
|
}
|
|
1693
1774
|
class StringAndCollectionFunctions {
|
|
1694
|
-
concat(
|
|
1695
|
-
return new Function('concat', [
|
|
1775
|
+
concat(left, right, normalize = 'right') {
|
|
1776
|
+
return new Function('concat', [left, right], normalize);
|
|
1696
1777
|
}
|
|
1697
|
-
contains(
|
|
1698
|
-
return new Function('contains', [
|
|
1778
|
+
contains(left, right, normalize = 'right') {
|
|
1779
|
+
return new Function('contains', [left, right], normalize);
|
|
1699
1780
|
}
|
|
1700
|
-
endsWith(
|
|
1701
|
-
return new Function('endswith', [
|
|
1781
|
+
endsWith(left, right, normalize = 'right') {
|
|
1782
|
+
return new Function('endswith', [left, right], normalize);
|
|
1702
1783
|
}
|
|
1703
|
-
indexOf(
|
|
1704
|
-
return new Function('indexof', [
|
|
1784
|
+
indexOf(left, right, normalize = 'right') {
|
|
1785
|
+
return new Function('indexof', [left, right], normalize);
|
|
1705
1786
|
}
|
|
1706
|
-
length(
|
|
1707
|
-
return new Function('length', [
|
|
1787
|
+
length(left, normalize = 'right') {
|
|
1788
|
+
return new Function('length', [left], normalize);
|
|
1708
1789
|
}
|
|
1709
|
-
startsWith(
|
|
1710
|
-
return new Function('startswith', [
|
|
1790
|
+
startsWith(left, right, normalize = 'right') {
|
|
1791
|
+
return new Function('startswith', [left, right], normalize);
|
|
1711
1792
|
}
|
|
1712
|
-
subString(
|
|
1713
|
-
let values = [
|
|
1793
|
+
subString(left, right, length, normalize = 'none') {
|
|
1794
|
+
let values = [left, right];
|
|
1714
1795
|
if (length !== undefined) {
|
|
1715
1796
|
values.push(length);
|
|
1716
1797
|
}
|
|
1717
|
-
return new Function('substring', values);
|
|
1798
|
+
return new Function('substring', values, normalize);
|
|
1718
1799
|
}
|
|
1719
1800
|
}
|
|
1720
1801
|
class CollectionFunctions {
|
|
1721
|
-
hasSubset(
|
|
1722
|
-
return new Function('hassubset', [
|
|
1802
|
+
hasSubset(left, right, normalize = 'none') {
|
|
1803
|
+
return new Function('hassubset', [left, right], normalize);
|
|
1723
1804
|
}
|
|
1724
|
-
hasSubsequence(
|
|
1725
|
-
return new Function('hassubsequence', [
|
|
1805
|
+
hasSubsequence(left, right, normalize = 'none') {
|
|
1806
|
+
return new Function('hassubsequence', [left, right], normalize);
|
|
1726
1807
|
}
|
|
1727
1808
|
}
|
|
1728
1809
|
class StringFunctions {
|
|
1729
|
-
matchesPattern(
|
|
1730
|
-
return new Function('matchesPattern', [
|
|
1810
|
+
matchesPattern(left, pattern, normalize = 'none') {
|
|
1811
|
+
return new Function('matchesPattern', [left, pattern], normalize);
|
|
1731
1812
|
}
|
|
1732
|
-
toLower(
|
|
1733
|
-
return new Function('tolower', [
|
|
1813
|
+
toLower(left, normalize = 'none') {
|
|
1814
|
+
return new Function('tolower', [left], normalize);
|
|
1734
1815
|
}
|
|
1735
|
-
toUpper(
|
|
1736
|
-
return new Function('toupper', [
|
|
1816
|
+
toUpper(left, normalize = 'none') {
|
|
1817
|
+
return new Function('toupper', [left], normalize);
|
|
1737
1818
|
}
|
|
1738
|
-
trim(
|
|
1739
|
-
return new Function('trim', [
|
|
1819
|
+
trim(left, normalize = 'none') {
|
|
1820
|
+
return new Function('trim', [left], normalize);
|
|
1740
1821
|
}
|
|
1741
1822
|
}
|
|
1742
1823
|
class DateAndTimeFunctions {
|
|
1743
|
-
date(
|
|
1744
|
-
return new Function('date', [
|
|
1824
|
+
date(left, normalize = 'none') {
|
|
1825
|
+
return new Function('date', [left], normalize);
|
|
1745
1826
|
}
|
|
1746
|
-
day(
|
|
1747
|
-
return new Function('day', [
|
|
1827
|
+
day(left, normalize = 'none') {
|
|
1828
|
+
return new Function('day', [left], normalize);
|
|
1748
1829
|
}
|
|
1749
|
-
fractionalseconds(
|
|
1750
|
-
return new Function('fractionalseconds', [
|
|
1830
|
+
fractionalseconds(left, normalize = 'none') {
|
|
1831
|
+
return new Function('fractionalseconds', [left], normalize);
|
|
1751
1832
|
}
|
|
1752
|
-
hour(
|
|
1753
|
-
return new Function('hour', [
|
|
1833
|
+
hour(left, normalize = 'none') {
|
|
1834
|
+
return new Function('hour', [left], normalize);
|
|
1754
1835
|
}
|
|
1755
|
-
maxdatetime(
|
|
1756
|
-
return new Function('maxdatetime', [
|
|
1836
|
+
maxdatetime(left, normalize = 'none') {
|
|
1837
|
+
return new Function('maxdatetime', [left], normalize);
|
|
1757
1838
|
}
|
|
1758
|
-
mindatetime(
|
|
1759
|
-
return new Function('mindatetime', [
|
|
1839
|
+
mindatetime(left, normalize = 'none') {
|
|
1840
|
+
return new Function('mindatetime', [left], normalize);
|
|
1760
1841
|
}
|
|
1761
|
-
minute(
|
|
1762
|
-
return new Function('minute', [
|
|
1842
|
+
minute(left, normalize = 'none') {
|
|
1843
|
+
return new Function('minute', [left], normalize);
|
|
1763
1844
|
}
|
|
1764
|
-
month(
|
|
1765
|
-
return new Function('month', [
|
|
1845
|
+
month(left, normalize = 'none') {
|
|
1846
|
+
return new Function('month', [left], normalize);
|
|
1766
1847
|
}
|
|
1767
1848
|
now() {
|
|
1768
|
-
return new Function('now', []);
|
|
1849
|
+
return new Function('now', [], 'none');
|
|
1769
1850
|
}
|
|
1770
|
-
second(
|
|
1771
|
-
return new Function('second', [
|
|
1851
|
+
second(left, normalize = 'none') {
|
|
1852
|
+
return new Function('second', [left], normalize);
|
|
1772
1853
|
}
|
|
1773
|
-
time(
|
|
1774
|
-
return new Function('time', [
|
|
1854
|
+
time(left, normalize = 'none') {
|
|
1855
|
+
return new Function('time', [left], normalize);
|
|
1775
1856
|
}
|
|
1776
|
-
totaloffsetminutes(
|
|
1777
|
-
return new Function('totaloffsetminutes', [
|
|
1857
|
+
totaloffsetminutes(left, normalize = 'none') {
|
|
1858
|
+
return new Function('totaloffsetminutes', [left], normalize);
|
|
1778
1859
|
}
|
|
1779
|
-
totalseconds(
|
|
1780
|
-
return new Function('totalseconds', [
|
|
1860
|
+
totalseconds(left, normalize = 'none') {
|
|
1861
|
+
return new Function('totalseconds', [left], normalize);
|
|
1781
1862
|
}
|
|
1782
|
-
year(
|
|
1783
|
-
return new Function('year', [
|
|
1863
|
+
year(left, normalize = 'none') {
|
|
1864
|
+
return new Function('year', [left], normalize);
|
|
1784
1865
|
}
|
|
1785
1866
|
}
|
|
1786
1867
|
class ArithmeticFunctions {
|
|
1787
|
-
ceiling(
|
|
1788
|
-
return new Function('ceiling', [
|
|
1868
|
+
ceiling(left, normalize = 'none') {
|
|
1869
|
+
return new Function('ceiling', [left], normalize);
|
|
1789
1870
|
}
|
|
1790
|
-
floor(
|
|
1791
|
-
return new Function('floor', [
|
|
1871
|
+
floor(left, normalize = 'none') {
|
|
1872
|
+
return new Function('floor', [left], normalize);
|
|
1792
1873
|
}
|
|
1793
|
-
round(
|
|
1794
|
-
return new Function('round', [
|
|
1874
|
+
round(left, normalize = 'none') {
|
|
1875
|
+
return new Function('round', [left], normalize);
|
|
1795
1876
|
}
|
|
1796
1877
|
}
|
|
1797
1878
|
class TypeFunctions {
|
|
1798
|
-
cast(
|
|
1799
|
-
return new Function('cast', [
|
|
1879
|
+
cast(left, right, normalize = 'right') {
|
|
1880
|
+
return new Function('cast', [left, right], normalize);
|
|
1800
1881
|
}
|
|
1801
|
-
isof(
|
|
1802
|
-
return new Function('isof', [
|
|
1882
|
+
isof(left, right, normalize = 'right') {
|
|
1883
|
+
return new Function('isof', [left, right], normalize);
|
|
1803
1884
|
}
|
|
1804
1885
|
}
|
|
1805
1886
|
class GeoFunctions {
|
|
1806
|
-
geoDistance(
|
|
1807
|
-
return new Function('geo.distance', [
|
|
1887
|
+
geoDistance(left, right, normalize = 'right') {
|
|
1888
|
+
return new Function('geo.distance', [left, right], normalize);
|
|
1808
1889
|
}
|
|
1809
|
-
geoIntersects(
|
|
1810
|
-
return new Function('geo.intersects', [
|
|
1890
|
+
geoIntersects(left, right, normalize = 'right') {
|
|
1891
|
+
return new Function('geo.intersects', [left, right], normalize);
|
|
1811
1892
|
}
|
|
1812
|
-
geoLength(
|
|
1813
|
-
return new Function('geo.length', [
|
|
1893
|
+
geoLength(left, normalize = 'none') {
|
|
1894
|
+
return new Function('geo.length', [left], normalize);
|
|
1814
1895
|
}
|
|
1815
1896
|
}
|
|
1816
1897
|
class ConditionalFunctions {
|
|
1817
|
-
case(
|
|
1818
|
-
return new Function('case', [
|
|
1898
|
+
case(left, right, normalize = 'none') {
|
|
1899
|
+
return new Function('case', [left, right], normalize);
|
|
1819
1900
|
}
|
|
1820
1901
|
}
|
|
1821
1902
|
class Operator {
|
|
1822
|
-
constructor(op, values, normalize
|
|
1903
|
+
constructor(op, values, normalize) {
|
|
1823
1904
|
this.op = op;
|
|
1824
1905
|
this.values = values;
|
|
1825
1906
|
this.normalize = normalize;
|
|
@@ -1831,13 +1912,20 @@ class Operator {
|
|
|
1831
1912
|
return {
|
|
1832
1913
|
$type: Types.rawType(this),
|
|
1833
1914
|
op: this.op,
|
|
1834
|
-
values: this.values,
|
|
1915
|
+
values: this.values.map((v) => Types.isObject(v) && 'toJSON' in v ? v.toJSON() : v),
|
|
1835
1916
|
normalize: this.normalize,
|
|
1836
1917
|
};
|
|
1837
1918
|
}
|
|
1838
|
-
render({ aliases, escape, prefix, }) {
|
|
1839
|
-
|
|
1840
|
-
|
|
1919
|
+
render({ aliases, escape, prefix, parser, }) {
|
|
1920
|
+
parser = resolve(this.values, parser);
|
|
1921
|
+
let [left, right] = encode(this.values, parser);
|
|
1922
|
+
left = render(left, {
|
|
1923
|
+
aliases,
|
|
1924
|
+
escape,
|
|
1925
|
+
prefix,
|
|
1926
|
+
parser,
|
|
1927
|
+
normalize: this.normalize === 'all' || this.normalize === 'left',
|
|
1928
|
+
});
|
|
1841
1929
|
if (right !== undefined) {
|
|
1842
1930
|
right = Array.isArray(right)
|
|
1843
1931
|
? `(${right
|
|
@@ -1845,14 +1933,16 @@ class Operator {
|
|
|
1845
1933
|
aliases,
|
|
1846
1934
|
escape,
|
|
1847
1935
|
prefix,
|
|
1848
|
-
|
|
1936
|
+
parser,
|
|
1937
|
+
normalize: this.normalize === 'all' || this.normalize === 'right',
|
|
1849
1938
|
}))
|
|
1850
1939
|
.join(',')})`
|
|
1851
1940
|
: render(right, {
|
|
1852
1941
|
aliases,
|
|
1853
1942
|
escape,
|
|
1854
1943
|
prefix,
|
|
1855
|
-
|
|
1944
|
+
parser,
|
|
1945
|
+
normalize: this.normalize === 'all' || this.normalize === 'right',
|
|
1856
1946
|
});
|
|
1857
1947
|
return `${left} ${this.op} ${right}`;
|
|
1858
1948
|
}
|
|
@@ -1863,59 +1953,59 @@ class Operator {
|
|
|
1863
1953
|
}
|
|
1864
1954
|
}
|
|
1865
1955
|
class LogicalOperators {
|
|
1866
|
-
eq(left, right, normalize) {
|
|
1956
|
+
eq(left, right, normalize = 'right') {
|
|
1867
1957
|
return new Operator('eq', [left, right], normalize);
|
|
1868
1958
|
}
|
|
1869
|
-
ne(left, right, normalize) {
|
|
1959
|
+
ne(left, right, normalize = 'right') {
|
|
1870
1960
|
return new Operator('ne', [left, right], normalize);
|
|
1871
1961
|
}
|
|
1872
|
-
gt(left, right, normalize) {
|
|
1962
|
+
gt(left, right, normalize = 'right') {
|
|
1873
1963
|
return new Operator('gt', [left, right], normalize);
|
|
1874
1964
|
}
|
|
1875
|
-
ge(left, right, normalize) {
|
|
1965
|
+
ge(left, right, normalize = 'right') {
|
|
1876
1966
|
return new Operator('ge', [left, right], normalize);
|
|
1877
1967
|
}
|
|
1878
|
-
lt(left, right, normalize) {
|
|
1968
|
+
lt(left, right, normalize = 'right') {
|
|
1879
1969
|
return new Operator('lt', [left, right], normalize);
|
|
1880
1970
|
}
|
|
1881
|
-
le(left, right, normalize) {
|
|
1971
|
+
le(left, right, normalize = 'right') {
|
|
1882
1972
|
return new Operator('le', [left, right], normalize);
|
|
1883
1973
|
}
|
|
1884
1974
|
/*
|
|
1885
|
-
and(left: any, right: any, normalize
|
|
1975
|
+
and(left: any, right: any, normalize: Normalize = 'right') {
|
|
1886
1976
|
return new Operator('and', [left, right], normalize);
|
|
1887
1977
|
}
|
|
1888
|
-
or(left: any, right: any, normalize
|
|
1978
|
+
or(left: any, right: any, normalize: Normalize = 'right') {
|
|
1889
1979
|
return new Operator('or', [left, right], normalize);
|
|
1890
1980
|
}
|
|
1891
1981
|
*/
|
|
1892
|
-
not(
|
|
1893
|
-
return new Operator('not', [
|
|
1982
|
+
not(left, normalize = 'none') {
|
|
1983
|
+
return new Operator('not', [left], normalize);
|
|
1894
1984
|
}
|
|
1895
|
-
has(left, right, normalize) {
|
|
1985
|
+
has(left, right, normalize = 'right') {
|
|
1896
1986
|
return new Operator('has', [left, right], normalize);
|
|
1897
1987
|
}
|
|
1898
|
-
in(left, right, normalize) {
|
|
1988
|
+
in(left, right, normalize = 'right') {
|
|
1899
1989
|
return new Operator('in', [left, right], normalize);
|
|
1900
1990
|
}
|
|
1901
1991
|
}
|
|
1902
1992
|
class ArithmeticOperators {
|
|
1903
|
-
add(left, right, normalize) {
|
|
1993
|
+
add(left, right, normalize = 'right') {
|
|
1904
1994
|
return new Operator('add', [left, right], normalize);
|
|
1905
1995
|
}
|
|
1906
|
-
sub(left, right, normalize) {
|
|
1996
|
+
sub(left, right, normalize = 'right') {
|
|
1907
1997
|
return new Operator('sub', [left, right], normalize);
|
|
1908
1998
|
}
|
|
1909
|
-
mul(left, right, normalize) {
|
|
1999
|
+
mul(left, right, normalize = 'right') {
|
|
1910
2000
|
return new Operator('mul', [left, right], normalize);
|
|
1911
2001
|
}
|
|
1912
|
-
div(left, right, normalize) {
|
|
2002
|
+
div(left, right, normalize = 'right') {
|
|
1913
2003
|
return new Operator('div', [left, right], normalize);
|
|
1914
2004
|
}
|
|
1915
|
-
mod(left, right, normalize) {
|
|
2005
|
+
mod(left, right, normalize = 'right') {
|
|
1916
2006
|
return new Operator('mod', [left, right], normalize);
|
|
1917
2007
|
}
|
|
1918
|
-
neg(value, normalize) {
|
|
2008
|
+
neg(value, normalize = 'right') {
|
|
1919
2009
|
return new Operator('-', [value], normalize);
|
|
1920
2010
|
}
|
|
1921
2011
|
}
|
|
@@ -1932,8 +2022,8 @@ class Grouping {
|
|
|
1932
2022
|
group: this.group.toJSON(),
|
|
1933
2023
|
};
|
|
1934
2024
|
}
|
|
1935
|
-
render({ aliases, escape, prefix, }) {
|
|
1936
|
-
return `(${render(this.group, { aliases, escape, prefix })})`;
|
|
2025
|
+
render({ aliases, escape, prefix, parser, }) {
|
|
2026
|
+
return `(${render(this.group, { aliases, escape, prefix, parser })})`;
|
|
1937
2027
|
}
|
|
1938
2028
|
clone() {
|
|
1939
2029
|
return new Grouping(Objects.clone(this.group));
|
|
@@ -1952,19 +2042,21 @@ class Lambda {
|
|
|
1952
2042
|
return {
|
|
1953
2043
|
$type: Types.rawType(this),
|
|
1954
2044
|
op: this.op,
|
|
1955
|
-
values: this.values,
|
|
2045
|
+
values: this.values.map((v) => Types.isObject(v) && 'toJSON' in v ? v.toJSON() : v),
|
|
1956
2046
|
alias: this.alias,
|
|
1957
2047
|
};
|
|
1958
2048
|
}
|
|
1959
|
-
render({ aliases, escape, prefix, }) {
|
|
1960
|
-
|
|
1961
|
-
|
|
2049
|
+
render({ aliases, escape, prefix, parser, }) {
|
|
2050
|
+
parser = resolve(this.values, parser);
|
|
2051
|
+
let [left, right] = encode(this.values, parser);
|
|
2052
|
+
left = render(left, { aliases, escape, prefix, parser });
|
|
1962
2053
|
if (right) {
|
|
1963
2054
|
let alias = this.alias || left.split('/').pop().toLowerCase()[0];
|
|
1964
2055
|
return `${left}/${this.op}(${alias}:${render(right, {
|
|
1965
2056
|
aliases,
|
|
1966
2057
|
escape,
|
|
1967
2058
|
prefix: alias,
|
|
2059
|
+
parser,
|
|
1968
2060
|
})})`;
|
|
1969
2061
|
}
|
|
1970
2062
|
else {
|
|
@@ -1976,11 +2068,11 @@ class Lambda {
|
|
|
1976
2068
|
}
|
|
1977
2069
|
}
|
|
1978
2070
|
class LambdaOperators {
|
|
1979
|
-
any(
|
|
1980
|
-
return new Lambda('any', [
|
|
2071
|
+
any(left, right, alias) {
|
|
2072
|
+
return new Lambda('any', [left, right], alias);
|
|
1981
2073
|
}
|
|
1982
|
-
all(
|
|
1983
|
-
return new Lambda('all', [
|
|
2074
|
+
all(left, right, alias) {
|
|
2075
|
+
return new Lambda('all', [left, right], alias);
|
|
1984
2076
|
}
|
|
1985
2077
|
}
|
|
1986
2078
|
class ODataOperators {
|
|
@@ -2016,12 +2108,12 @@ class ComputeExpression extends Expression {
|
|
|
2016
2108
|
}
|
|
2017
2109
|
static compute(opts, current) {
|
|
2018
2110
|
return opts({
|
|
2019
|
-
t:
|
|
2111
|
+
t: FieldFactory(),
|
|
2020
2112
|
e: () => new ComputeExpression(),
|
|
2021
2113
|
}, current);
|
|
2022
2114
|
}
|
|
2023
|
-
render({ aliases, escape, prefix, } = {}) {
|
|
2024
|
-
let children = this._children.map((n) => n.render({ aliases, escape, prefix }));
|
|
2115
|
+
render({ aliases, escape, prefix, parser, } = {}) {
|
|
2116
|
+
let children = this._children.map((n) => n.render({ aliases, escape, prefix, parser }));
|
|
2025
2117
|
return this.names
|
|
2026
2118
|
.map((name, index) => `${children[index]} as ${name}`)
|
|
2027
2119
|
.join(',');
|
|
@@ -2059,7 +2151,7 @@ class CountField {
|
|
|
2059
2151
|
field: this.field.toJSON(),
|
|
2060
2152
|
};
|
|
2061
2153
|
}
|
|
2062
|
-
render({ aliases, escape, prefix, }) {
|
|
2154
|
+
render({ aliases, escape, prefix, parser, }) {
|
|
2063
2155
|
const params = [
|
|
2064
2156
|
QueryOption.filter,
|
|
2065
2157
|
QueryOption.search,
|
|
@@ -2068,11 +2160,21 @@ class CountField {
|
|
|
2068
2160
|
.reduce((acc, key) => {
|
|
2069
2161
|
let value = this.values[key];
|
|
2070
2162
|
if (Types.rawType(value).endsWith('Expression')) {
|
|
2071
|
-
value = value.render({
|
|
2163
|
+
value = value.render({
|
|
2164
|
+
aliases,
|
|
2165
|
+
prefix,
|
|
2166
|
+
escape,
|
|
2167
|
+
parser,
|
|
2168
|
+
});
|
|
2072
2169
|
}
|
|
2073
2170
|
return Object.assign(acc, { [key]: value });
|
|
2074
2171
|
}, {});
|
|
2075
|
-
let count = `${render(this.field, {
|
|
2172
|
+
let count = `${render(this.field, {
|
|
2173
|
+
aliases,
|
|
2174
|
+
escape,
|
|
2175
|
+
prefix,
|
|
2176
|
+
parser,
|
|
2177
|
+
})}/$count`;
|
|
2076
2178
|
if (!Types.isEmpty(params)) {
|
|
2077
2179
|
count = `${count}(${Object.keys(params)
|
|
2078
2180
|
.map((key) => `$${key}=${params[key]}`)
|
|
@@ -2100,7 +2202,7 @@ class CountExpression extends Expression {
|
|
|
2100
2202
|
}
|
|
2101
2203
|
static count(opts, current) {
|
|
2102
2204
|
return opts({
|
|
2103
|
-
t:
|
|
2205
|
+
t: FieldFactory(),
|
|
2104
2206
|
e: () => new CountExpression(),
|
|
2105
2207
|
}, current);
|
|
2106
2208
|
}
|
|
@@ -2108,9 +2210,9 @@ class CountExpression extends Expression {
|
|
|
2108
2210
|
this._children.push(node);
|
|
2109
2211
|
return this;
|
|
2110
2212
|
}
|
|
2111
|
-
render({ aliases, escape, prefix, } = {}) {
|
|
2213
|
+
render({ aliases, escape, prefix, parser, } = {}) {
|
|
2112
2214
|
let content = this._children
|
|
2113
|
-
.map((n) => n.render({ aliases, escape, prefix }))
|
|
2215
|
+
.map((n) => n.render({ aliases, escape, prefix, parser }))
|
|
2114
2216
|
.join(`,`);
|
|
2115
2217
|
return content;
|
|
2116
2218
|
}
|
|
@@ -2123,7 +2225,7 @@ class CountExpression extends Expression {
|
|
|
2123
2225
|
let countField = new CountField(field);
|
|
2124
2226
|
if (opts !== undefined)
|
|
2125
2227
|
opts({
|
|
2126
|
-
t:
|
|
2228
|
+
t: FieldFactory(),
|
|
2127
2229
|
f: countField,
|
|
2128
2230
|
});
|
|
2129
2231
|
return this._add(countField);
|
|
@@ -2138,8 +2240,8 @@ class FilterExpression extends Expression {
|
|
|
2138
2240
|
}
|
|
2139
2241
|
static filter(opts, current) {
|
|
2140
2242
|
return opts({
|
|
2141
|
-
t: Field$1.factory(),
|
|
2142
2243
|
e: (connector = 'and') => new FilterExpression({ connector }),
|
|
2244
|
+
t: FieldFactory(),
|
|
2143
2245
|
o: operators,
|
|
2144
2246
|
f: functions,
|
|
2145
2247
|
}, current);
|
|
@@ -2157,9 +2259,9 @@ class FilterExpression extends Expression {
|
|
|
2157
2259
|
negated() {
|
|
2158
2260
|
return this._negated;
|
|
2159
2261
|
}
|
|
2160
|
-
render({ aliases, escape, prefix, } = {}) {
|
|
2262
|
+
render({ aliases, escape, prefix, parser, } = {}) {
|
|
2161
2263
|
let content = this._children
|
|
2162
|
-
.map((n) => n.render({ aliases, escape, prefix }))
|
|
2264
|
+
.map((n) => n.render({ aliases, escape, prefix, parser }))
|
|
2163
2265
|
.join(` ${this._connector} `);
|
|
2164
2266
|
if (this._negated) {
|
|
2165
2267
|
content = `not (${content})`;
|
|
@@ -2230,44 +2332,44 @@ class FilterExpression extends Expression {
|
|
|
2230
2332
|
});
|
|
2231
2333
|
return this._add(notExp, this._connector);
|
|
2232
2334
|
}
|
|
2233
|
-
eq(left, right, normalize) {
|
|
2335
|
+
eq(left, right, normalize = 'right') {
|
|
2234
2336
|
return this._add(operators.eq(left, right, normalize));
|
|
2235
2337
|
}
|
|
2236
|
-
ne(left, right, normalize) {
|
|
2338
|
+
ne(left, right, normalize = 'right') {
|
|
2237
2339
|
return this._add(operators.ne(left, right, normalize));
|
|
2238
2340
|
}
|
|
2239
|
-
gt(left, right, normalize) {
|
|
2341
|
+
gt(left, right, normalize = 'right') {
|
|
2240
2342
|
return this._add(operators.gt(left, right, normalize));
|
|
2241
2343
|
}
|
|
2242
|
-
ge(left, right, normalize) {
|
|
2344
|
+
ge(left, right, normalize = 'right') {
|
|
2243
2345
|
return this._add(operators.ge(left, right, normalize));
|
|
2244
2346
|
}
|
|
2245
|
-
lt(left, right, normalize) {
|
|
2347
|
+
lt(left, right, normalize = 'right') {
|
|
2246
2348
|
return this._add(operators.lt(left, right, normalize));
|
|
2247
2349
|
}
|
|
2248
|
-
le(left, right, normalize) {
|
|
2350
|
+
le(left, right, normalize = 'right') {
|
|
2249
2351
|
return this._add(operators.le(left, right, normalize));
|
|
2250
2352
|
}
|
|
2251
|
-
has(left, right, normalize) {
|
|
2353
|
+
has(left, right, normalize = 'right') {
|
|
2252
2354
|
return this._add(operators.has(left, right, normalize));
|
|
2253
2355
|
}
|
|
2254
|
-
in(left, right, normalize) {
|
|
2356
|
+
in(left, right, normalize = 'right') {
|
|
2255
2357
|
return this._add(operators.in(left, right, normalize));
|
|
2256
2358
|
}
|
|
2257
|
-
contains(left, right, normalize) {
|
|
2359
|
+
contains(left, right, normalize = 'right') {
|
|
2258
2360
|
return this._add(functions.contains(left, right, normalize));
|
|
2259
2361
|
}
|
|
2260
|
-
startsWith(left, right, normalize) {
|
|
2362
|
+
startsWith(left, right, normalize = 'right') {
|
|
2261
2363
|
return this._add(functions.startsWith(left, right, normalize));
|
|
2262
2364
|
}
|
|
2263
|
-
endsWith(left, right, normalize) {
|
|
2365
|
+
endsWith(left, right, normalize = 'right') {
|
|
2264
2366
|
return this._add(functions.endsWith(left, right, normalize));
|
|
2265
2367
|
}
|
|
2266
2368
|
any(left, opts, alias) {
|
|
2267
2369
|
let exp = undefined;
|
|
2268
2370
|
if (opts !== undefined) {
|
|
2269
2371
|
exp = opts({
|
|
2270
|
-
t:
|
|
2372
|
+
t: FieldFactory(),
|
|
2271
2373
|
e: (connector = 'and') => new FilterExpression({ connector }),
|
|
2272
2374
|
});
|
|
2273
2375
|
}
|
|
@@ -2275,7 +2377,7 @@ class FilterExpression extends Expression {
|
|
|
2275
2377
|
}
|
|
2276
2378
|
all(left, opts, alias) {
|
|
2277
2379
|
const exp = opts({
|
|
2278
|
-
t:
|
|
2380
|
+
t: FieldFactory(),
|
|
2279
2381
|
e: (connector = 'and') => new FilterExpression({ connector }),
|
|
2280
2382
|
});
|
|
2281
2383
|
return this._add(syntax.all(left, exp, alias));
|
|
@@ -2302,8 +2404,8 @@ class OrderByField {
|
|
|
2302
2404
|
order: this.order,
|
|
2303
2405
|
};
|
|
2304
2406
|
}
|
|
2305
|
-
render({ aliases, escape, prefix, }) {
|
|
2306
|
-
return `${render(this.field, { aliases, escape, prefix })} ${this.order}`;
|
|
2407
|
+
render({ aliases, escape, prefix, parser, }) {
|
|
2408
|
+
return `${render(this.field, { aliases, escape, prefix, parser })} ${this.order}`;
|
|
2307
2409
|
}
|
|
2308
2410
|
clone() {
|
|
2309
2411
|
return new OrderByField(this.field.clone(), this.order);
|
|
@@ -2315,7 +2417,7 @@ class OrderByExpression extends Expression {
|
|
|
2315
2417
|
}
|
|
2316
2418
|
static orderBy(opts, current) {
|
|
2317
2419
|
return opts({
|
|
2318
|
-
t:
|
|
2420
|
+
t: FieldFactory(),
|
|
2319
2421
|
e: () => new OrderByExpression(),
|
|
2320
2422
|
}, current);
|
|
2321
2423
|
}
|
|
@@ -2323,9 +2425,9 @@ class OrderByExpression extends Expression {
|
|
|
2323
2425
|
this._children.push(node);
|
|
2324
2426
|
return this;
|
|
2325
2427
|
}
|
|
2326
|
-
render({ aliases, escape, prefix, } = {}) {
|
|
2428
|
+
render({ aliases, escape, prefix, parser, } = {}) {
|
|
2327
2429
|
let content = this._children
|
|
2328
|
-
.map((n) => n.render({ aliases, escape, prefix }))
|
|
2430
|
+
.map((n) => n.render({ aliases, escape, prefix, parser }))
|
|
2329
2431
|
.join(`,`);
|
|
2330
2432
|
return content;
|
|
2331
2433
|
}
|
|
@@ -2355,8 +2457,8 @@ class SearchTerm {
|
|
|
2355
2457
|
value: this.value,
|
|
2356
2458
|
};
|
|
2357
2459
|
}
|
|
2358
|
-
render({ aliases, escape, prefix, }) {
|
|
2359
|
-
return `${render(this.value, { aliases, escape, prefix })}`;
|
|
2460
|
+
render({ aliases, escape, prefix, parser, }) {
|
|
2461
|
+
return `${render(this.value, { aliases, escape, prefix, parser })}`;
|
|
2360
2462
|
}
|
|
2361
2463
|
clone() {
|
|
2362
2464
|
return new SearchTerm(this.value);
|
|
@@ -2416,9 +2518,9 @@ class SearchExpression extends Expression {
|
|
|
2416
2518
|
}
|
|
2417
2519
|
return this;
|
|
2418
2520
|
}
|
|
2419
|
-
render({ aliases, escape, prefix, } = {}) {
|
|
2521
|
+
render({ aliases, escape, prefix, parser, } = {}) {
|
|
2420
2522
|
let content = this._children
|
|
2421
|
-
.map((n) => n.render({ aliases, escape, prefix }))
|
|
2523
|
+
.map((n) => n.render({ aliases, escape, prefix, parser }))
|
|
2422
2524
|
.join(` ${this._connector} `);
|
|
2423
2525
|
return content;
|
|
2424
2526
|
}
|
|
@@ -2467,13 +2569,13 @@ class SelectExpression extends Expression {
|
|
|
2467
2569
|
}
|
|
2468
2570
|
static select(opts, current) {
|
|
2469
2571
|
return opts({
|
|
2470
|
-
t:
|
|
2572
|
+
t: FieldFactory(),
|
|
2471
2573
|
e: () => new SelectExpression(),
|
|
2472
2574
|
}, current);
|
|
2473
2575
|
}
|
|
2474
|
-
render({ aliases, escape, prefix, } = {}) {
|
|
2576
|
+
render({ aliases, escape, prefix, parser, } = {}) {
|
|
2475
2577
|
return this._children
|
|
2476
|
-
.map((n) => n.render({ aliases, escape, prefix }))
|
|
2578
|
+
.map((n) => n.render({ aliases, escape, prefix, parser }))
|
|
2477
2579
|
.join(',');
|
|
2478
2580
|
}
|
|
2479
2581
|
clone() {
|
|
@@ -2503,7 +2605,8 @@ class ExpandField {
|
|
|
2503
2605
|
field: this.field.toJSON(),
|
|
2504
2606
|
};
|
|
2505
2607
|
}
|
|
2506
|
-
render({ aliases, escape, prefix, }) {
|
|
2608
|
+
render({ aliases, escape, prefix, parser, }) {
|
|
2609
|
+
parser = resolve([this.field], parser);
|
|
2507
2610
|
const params = [
|
|
2508
2611
|
QueryOption.select,
|
|
2509
2612
|
QueryOption.expand,
|
|
@@ -2512,17 +2615,23 @@ class ExpandField {
|
|
|
2512
2615
|
QueryOption.orderBy,
|
|
2513
2616
|
QueryOption.skip,
|
|
2514
2617
|
QueryOption.top,
|
|
2618
|
+
QueryOption.count,
|
|
2515
2619
|
QueryOption.levels,
|
|
2516
2620
|
]
|
|
2517
2621
|
.filter((key) => !Types.isEmpty(this.values[key]))
|
|
2518
2622
|
.reduce((acc, key) => {
|
|
2519
2623
|
let value = this.values[key];
|
|
2520
2624
|
if (Types.rawType(value).endsWith('Expression')) {
|
|
2521
|
-
value = value.render({
|
|
2625
|
+
value = value.render({
|
|
2626
|
+
aliases,
|
|
2627
|
+
prefix,
|
|
2628
|
+
escape,
|
|
2629
|
+
parser,
|
|
2630
|
+
});
|
|
2522
2631
|
}
|
|
2523
2632
|
return Object.assign(acc, { [key]: value });
|
|
2524
2633
|
}, {});
|
|
2525
|
-
let expand = `${render(this.field, { aliases, escape, prefix })}`;
|
|
2634
|
+
let expand = `${render(this.field, { aliases, escape, prefix, parser })}`;
|
|
2526
2635
|
if (!Types.isEmpty(params)) {
|
|
2527
2636
|
expand = `${expand}(${Object.keys(params)
|
|
2528
2637
|
.map((key) => `$${key}=${params[key]}`)
|
|
@@ -2532,7 +2641,7 @@ class ExpandField {
|
|
|
2532
2641
|
}
|
|
2533
2642
|
clone() {
|
|
2534
2643
|
const values = Object.keys(this.values).reduce((acc, key) => Object.assign(acc, { [key]: Objects.clone(this.values[key]) }), {});
|
|
2535
|
-
return new ExpandField(this.field.clone(), values);
|
|
2644
|
+
return new ExpandField(typeof this.field === 'string' ? this.field : this.field.clone(), values);
|
|
2536
2645
|
}
|
|
2537
2646
|
select(opts) {
|
|
2538
2647
|
return this.option(QueryOption.select, SelectExpression.select(opts, this.values[QueryOption.select]));
|
|
@@ -2558,6 +2667,9 @@ class ExpandField {
|
|
|
2558
2667
|
levels(n) {
|
|
2559
2668
|
return this.option(QueryOption.levels, n);
|
|
2560
2669
|
}
|
|
2670
|
+
count() {
|
|
2671
|
+
return this.option(QueryOption.count, true);
|
|
2672
|
+
}
|
|
2561
2673
|
// Option Handler
|
|
2562
2674
|
option(name, opts) {
|
|
2563
2675
|
if (opts !== undefined)
|
|
@@ -2571,13 +2683,13 @@ class ExpandExpression extends Expression {
|
|
|
2571
2683
|
}
|
|
2572
2684
|
static expand(opts, current) {
|
|
2573
2685
|
return opts({
|
|
2574
|
-
t:
|
|
2686
|
+
t: FieldFactory(),
|
|
2575
2687
|
e: () => new ExpandExpression(),
|
|
2576
2688
|
}, current);
|
|
2577
2689
|
}
|
|
2578
|
-
render({ aliases, escape, prefix, } = {}) {
|
|
2690
|
+
render({ aliases, escape, prefix, parser, } = {}) {
|
|
2579
2691
|
return this._children
|
|
2580
|
-
.map((n) => n.render({ aliases, escape, prefix }))
|
|
2692
|
+
.map((n) => n.render({ aliases, escape, prefix, parser }))
|
|
2581
2693
|
.join(',');
|
|
2582
2694
|
}
|
|
2583
2695
|
clone() {
|
|
@@ -2986,7 +3098,7 @@ class ODataQueryOptions {
|
|
|
2986
3098
|
: new Map(Object.entries(values || {}));
|
|
2987
3099
|
}
|
|
2988
3100
|
// Params
|
|
2989
|
-
pathAndParams(escape =
|
|
3101
|
+
pathAndParams({ escape, parser, } = {}) {
|
|
2990
3102
|
let aliases = [];
|
|
2991
3103
|
let options = [
|
|
2992
3104
|
QueryOption.select,
|
|
@@ -3011,16 +3123,16 @@ class ODataQueryOptions {
|
|
|
3011
3123
|
value.some((v) => Types.rawType(v).endsWith('Expression')))) {
|
|
3012
3124
|
value = Types.isArray(value)
|
|
3013
3125
|
? value.map((v) => Types.rawType(v).endsWith('Expression')
|
|
3014
|
-
? v.render({ aliases })
|
|
3126
|
+
? raw(v.render({ aliases, escape, parser }))
|
|
3015
3127
|
: v)
|
|
3016
|
-
: value.render({ aliases });
|
|
3128
|
+
: raw(value.render({ aliases, escape, parser }));
|
|
3017
3129
|
}
|
|
3018
3130
|
return Object.assign(acc, { [key]: value });
|
|
3019
3131
|
}, {});
|
|
3020
3132
|
return buildPathAndQuery({ ...options, aliases, escape });
|
|
3021
3133
|
}
|
|
3022
|
-
toString() {
|
|
3023
|
-
const [path, params] = this.pathAndParams();
|
|
3134
|
+
toString({ escape, parser, } = {}) {
|
|
3135
|
+
const [path, params] = this.pathAndParams({ escape, parser });
|
|
3024
3136
|
return (path +
|
|
3025
3137
|
Object.entries(params)
|
|
3026
3138
|
.filter(([, value]) => !Types.isEmpty(value))
|
|
@@ -3156,7 +3268,7 @@ class ODataPathSegmentsHandler {
|
|
|
3156
3268
|
}
|
|
3157
3269
|
}
|
|
3158
3270
|
|
|
3159
|
-
function pathSegmentsBuilder(segment, escape = false) {
|
|
3271
|
+
function pathSegmentsBuilder(segment, escape = false, parser) {
|
|
3160
3272
|
if (segment.name === PathSegment.function) {
|
|
3161
3273
|
let [path, params] = segment.parameters
|
|
3162
3274
|
? buildPathAndQuery({
|
|
@@ -3184,9 +3296,9 @@ class ODataPathSegments {
|
|
|
3184
3296
|
constructor(segments) {
|
|
3185
3297
|
this._segments = segments || [];
|
|
3186
3298
|
}
|
|
3187
|
-
pathAndParams(escape =
|
|
3299
|
+
pathAndParams({ escape, parser, } = {}) {
|
|
3188
3300
|
const result = this._segments.reduce((acc, segment) => {
|
|
3189
|
-
const [path, params] = pathSegmentsBuilder(segment, escape);
|
|
3301
|
+
const [path, params] = pathSegmentsBuilder(segment, escape, parser);
|
|
3190
3302
|
acc.paths.push(path);
|
|
3191
3303
|
acc.params = Object.assign(acc.params, params);
|
|
3192
3304
|
return acc;
|
|
@@ -3213,8 +3325,8 @@ class ODataPathSegments {
|
|
|
3213
3325
|
}
|
|
3214
3326
|
return segments.map((s) => s.key());
|
|
3215
3327
|
}
|
|
3216
|
-
toString() {
|
|
3217
|
-
const [path, params] = this.pathAndParams();
|
|
3328
|
+
toString({ escape, parser, } = {}) {
|
|
3329
|
+
const [path, params] = this.pathAndParams({ escape, parser });
|
|
3218
3330
|
return (path +
|
|
3219
3331
|
Object.entries(params)
|
|
3220
3332
|
.filter(([, value]) => value)
|
|
@@ -3938,12 +4050,7 @@ const EDM_PARSERS = {
|
|
|
3938
4050
|
//Edm.Duration Signed duration in days, hours, minutes, and (sub)seconds
|
|
3939
4051
|
[EdmType.Duration]: EdmParser((v) => Durations.toDuration(v), (v) => Durations.toString(v), (v) => raw(Durations.toString(v))),
|
|
3940
4052
|
//Edm.Decimal Numeric values with fixed precision and scale
|
|
3941
|
-
[EdmType.Decimal]: EdmParser((v, o) => {
|
|
3942
|
-
if (typeof v === 'string' && o.ieee754Compatible) {
|
|
3943
|
-
return parseFloat(v);
|
|
3944
|
-
}
|
|
3945
|
-
return v;
|
|
3946
|
-
}, (v, o) => {
|
|
4053
|
+
[EdmType.Decimal]: EdmParser(toNumber, (v, o) => {
|
|
3947
4054
|
if (o.ieee754Compatible) {
|
|
3948
4055
|
let vstr = v.toPrecision(o.field.precision);
|
|
3949
4056
|
if (typeof o.field.scale === 'number') {
|
|
@@ -4055,7 +4162,7 @@ class ODataEnumTypeParser extends ODataAnnotatable {
|
|
|
4055
4162
|
// string | number -> string
|
|
4056
4163
|
const parserOptions = { ...this.parserOptions, ...options };
|
|
4057
4164
|
if (this.flags) {
|
|
4058
|
-
let names = Enums.
|
|
4165
|
+
let names = Enums.toFlags(this.members, value);
|
|
4059
4166
|
if (names.length === 0)
|
|
4060
4167
|
names = [`${value}`];
|
|
4061
4168
|
return !parserOptions?.stringAsEnum
|
|
@@ -4374,6 +4481,9 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
|
|
|
4374
4481
|
return this.parent.isSubtypeOf(type);
|
|
4375
4482
|
return false;
|
|
4376
4483
|
}
|
|
4484
|
+
isOpenType() {
|
|
4485
|
+
return this.open;
|
|
4486
|
+
}
|
|
4377
4487
|
findChildParser(predicate) {
|
|
4378
4488
|
if (predicate(this))
|
|
4379
4489
|
return this;
|
|
@@ -4394,7 +4504,9 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
|
|
|
4394
4504
|
const fields = this.fields({
|
|
4395
4505
|
include_navigation: true,
|
|
4396
4506
|
include_parents: true,
|
|
4397
|
-
}).filter((f) => f.name in value &&
|
|
4507
|
+
}).filter((f) => f.name in value &&
|
|
4508
|
+
value[f.name] !== undefined &&
|
|
4509
|
+
value[f.name] !== null);
|
|
4398
4510
|
return {
|
|
4399
4511
|
...value,
|
|
4400
4512
|
...fields.reduce((acc, f) => ({
|
|
@@ -4461,6 +4573,13 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
|
|
|
4461
4573
|
...(this._keys || []),
|
|
4462
4574
|
];
|
|
4463
4575
|
}
|
|
4576
|
+
isEntityType() {
|
|
4577
|
+
return (this._keys !== undefined ||
|
|
4578
|
+
(this.parent !== undefined && this.parent.isEntityType()));
|
|
4579
|
+
}
|
|
4580
|
+
isComplexType() {
|
|
4581
|
+
return !this.isEntityType();
|
|
4582
|
+
}
|
|
4464
4583
|
/**
|
|
4465
4584
|
* Find the field parser for the given field name.
|
|
4466
4585
|
* @param name Name of the field
|
|
@@ -4846,14 +4965,13 @@ class ODataStructuredType extends ODataSchemaElement {
|
|
|
4846
4965
|
super(config, schema);
|
|
4847
4966
|
this.children = [];
|
|
4848
4967
|
this.base = config.base;
|
|
4849
|
-
this.open = config.open || false;
|
|
4850
4968
|
this.parser = new ODataStructuredTypeParser(config, schema.namespace, schema.alias);
|
|
4851
4969
|
this.model = config.model;
|
|
4852
4970
|
this.collection = config.collection;
|
|
4853
4971
|
if (this.model !== undefined) {
|
|
4854
4972
|
const options = this.model.hasOwnProperty('options')
|
|
4855
4973
|
? this.model.options
|
|
4856
|
-
: { fields:
|
|
4974
|
+
: { fields: new Map() };
|
|
4857
4975
|
this.model.buildMeta({ options, schema: this });
|
|
4858
4976
|
}
|
|
4859
4977
|
if (this.collection !== undefined) {
|
|
@@ -4912,7 +5030,13 @@ class ODataStructuredType extends ODataSchemaElement {
|
|
|
4912
5030
|
return this.keys().length > 1;
|
|
4913
5031
|
}
|
|
4914
5032
|
isOpenType() {
|
|
4915
|
-
return this.
|
|
5033
|
+
return this.parser.isOpenType();
|
|
5034
|
+
}
|
|
5035
|
+
isEntityType() {
|
|
5036
|
+
return this.parser.isEntityType();
|
|
5037
|
+
}
|
|
5038
|
+
isComplexType() {
|
|
5039
|
+
return this.parser.isComplexType();
|
|
4916
5040
|
}
|
|
4917
5041
|
/**
|
|
4918
5042
|
* Find the field parser for the given field name.
|
|
@@ -5183,8 +5307,14 @@ class ODataResource {
|
|
|
5183
5307
|
: otherPath === selfPath && Types.isEqual(selfParams, otherParams);
|
|
5184
5308
|
}
|
|
5185
5309
|
pathAndParams(escape = false) {
|
|
5186
|
-
const
|
|
5187
|
-
|
|
5310
|
+
const parser = this.schema !== undefined && 'parser' in this.schema
|
|
5311
|
+
? this.schema.parser
|
|
5312
|
+
: undefined;
|
|
5313
|
+
const [spath, sparams] = this.pathSegments.pathAndParams({
|
|
5314
|
+
escape,
|
|
5315
|
+
parser,
|
|
5316
|
+
});
|
|
5317
|
+
const [, qparams] = this.queryOptions.pathAndParams({ escape, parser });
|
|
5188
5318
|
return [spath, { ...sparams, ...qparams }];
|
|
5189
5319
|
}
|
|
5190
5320
|
endpointUrl(params = true) {
|
|
@@ -5196,8 +5326,8 @@ class ODataResource {
|
|
|
5196
5326
|
return `${this.api.serviceRootUrl}${path}`;
|
|
5197
5327
|
}
|
|
5198
5328
|
}
|
|
5199
|
-
toString() {
|
|
5200
|
-
let [path, params] = this.pathAndParams();
|
|
5329
|
+
toString(escape = false) {
|
|
5330
|
+
let [path, params] = this.pathAndParams(escape);
|
|
5201
5331
|
let queryString = Object.entries(params)
|
|
5202
5332
|
.map((e) => `${e[0]}${VALUE_SEPARATOR}${e[1]}`)
|
|
5203
5333
|
.join(PARAM_SEPARATOR);
|
|
@@ -7504,6 +7634,79 @@ class Field {
|
|
|
7504
7634
|
}
|
|
7505
7635
|
}
|
|
7506
7636
|
class ODataMetadata {
|
|
7637
|
+
// TAGS
|
|
7638
|
+
static { this.TAG_EDMX = 'edmx:Edmx'; }
|
|
7639
|
+
static { this.TAG_DATA_SERVICES = 'edmx:DataServices'; }
|
|
7640
|
+
static { this.TAG_REFERENCE = 'edmx:Reference'; }
|
|
7641
|
+
static { this.TAG_INCLUDE = 'edmx:Include'; }
|
|
7642
|
+
static { this.TAG_INCLUDE_ANNOTATIONS = 'edmx:IncludeAnnotations'; }
|
|
7643
|
+
static { this.TAG_TERM = 'Term'; }
|
|
7644
|
+
static { this.TAG_ANNOTATIONS = 'Annotations'; }
|
|
7645
|
+
static { this.TAG_ANNOTATION = 'Annotation'; }
|
|
7646
|
+
static { this.TAG_SCHEMA = 'Schema'; }
|
|
7647
|
+
static { this.TAG_ENUM_TYPE = 'EnumType'; }
|
|
7648
|
+
static { this.TAG_MEMBER = 'Member'; }
|
|
7649
|
+
static { this.TAG_COMPLEX_TYPE = 'ComplexType'; }
|
|
7650
|
+
static { this.TAG_ENTITY_TYPE = 'EntityType'; }
|
|
7651
|
+
static { this.TAG_PROPERTY = 'Property'; }
|
|
7652
|
+
static { this.TAG_KEY = 'Key'; }
|
|
7653
|
+
static { this.TAG_PROPERTY_REF = 'PropertyRef'; }
|
|
7654
|
+
static { this.TAG_NAVIGATION_PROPERTY = 'NavigationProperty'; }
|
|
7655
|
+
static { this.TAG_REFERENTIAL_CONSTRAINT = 'ReferentialConstraint'; }
|
|
7656
|
+
static { this.TAG_ON_DELETE = 'OnDelete'; }
|
|
7657
|
+
static { this.TAG_FUNCTION = 'Function'; }
|
|
7658
|
+
static { this.TAG_RETURN_TYPE = 'ReturnType'; }
|
|
7659
|
+
static { this.TAG_PARAMETER = 'Parameter'; }
|
|
7660
|
+
static { this.TAG_ACTION = 'Action'; }
|
|
7661
|
+
static { this.TAG_ENTITY_CONTAINER = 'EntityContainer'; }
|
|
7662
|
+
static { this.TAG_ENTITY_SET = 'EntitySet'; }
|
|
7663
|
+
static { this.TAG_SINGLETON = 'Singleton'; }
|
|
7664
|
+
static { this.TAG_FUNCTION_IMPORT = 'FunctionImport'; }
|
|
7665
|
+
static { this.TAG_ACTION_IMPORT = 'ActionImport'; }
|
|
7666
|
+
static { this.TAG_NAVIGATION_PROPERTY_BINDING = 'NavigationPropertyBinding'; }
|
|
7667
|
+
static { this.TAG_TYPE_DEFINITION = 'TypeDefinition'; }
|
|
7668
|
+
// ATTRIBUTES
|
|
7669
|
+
static { this.ATTRIBUTE_VERSION = 'Version'; }
|
|
7670
|
+
static { this.ATTRIBUTE_URI = 'Uri'; }
|
|
7671
|
+
static { this.ATTRIBUTE_ALIAS = 'Alias'; }
|
|
7672
|
+
static { this.ATTRIBUTE_NAMESPACE = 'Namespace'; }
|
|
7673
|
+
static { this.ATTRIBUTE_TERM_NAMESPACE = 'TermNamespace'; }
|
|
7674
|
+
static { this.ATTRIBUTE_QUALIFIER = 'Qualifier'; }
|
|
7675
|
+
static { this.ATTRIBUTE_TARGET_NAMESPACE = 'TargetNamespace'; }
|
|
7676
|
+
static { this.ATTRIBUTE_TERM = 'Term'; }
|
|
7677
|
+
static { this.ATTRIBUTE_NAME = 'Name'; }
|
|
7678
|
+
static { this.ATTRIBUTE_VALUE = 'Value'; }
|
|
7679
|
+
static { this.ATTRIBUTE_BASE_TYPE = 'BaseType'; }
|
|
7680
|
+
static { this.ATTRIBUTE_OPEN_TYPE = 'OpenType'; }
|
|
7681
|
+
static { this.ATTRIBUTE_TYPE = 'Type'; }
|
|
7682
|
+
static { this.ATTRIBUTE_NULLABLE = 'Nullable'; }
|
|
7683
|
+
static { this.ATTRIBUTE_MAX_LENGTH = 'MaxLength'; }
|
|
7684
|
+
static { this.ATTRIBUTE_PRECISION = 'Precision'; }
|
|
7685
|
+
static { this.ATTRIBUTE_SCALE = 'Scale'; }
|
|
7686
|
+
static { this.ATTRIBUTE_UNICODE = 'Unicode'; }
|
|
7687
|
+
static { this.ATTRIBUTE_SRID = 'SRID'; }
|
|
7688
|
+
static { this.ATTRIBUTE_DEFAULT_VALUE = 'DefaultValue'; }
|
|
7689
|
+
static { this.ATTRIBUTE_PARTNER = 'Partner'; }
|
|
7690
|
+
static { this.ATTRIBUTE_PROPERTY = 'Property'; }
|
|
7691
|
+
static { this.ATTRIBUTE_REFERENCED_PROPERTY = 'ReferencedProperty'; }
|
|
7692
|
+
static { this.ATTRIBUTE_HAS_STREAM = 'HasStream'; }
|
|
7693
|
+
static { this.ATTRIBUTE_CONTAINS_TARGET = 'ContainsTarget'; }
|
|
7694
|
+
static { this.ATTRIBUTE_IS_BOUND = 'IsBound'; }
|
|
7695
|
+
static { this.ATTRIBUTE_ENTITY_SET_PATH = 'EntitySetPath'; }
|
|
7696
|
+
static { this.ATTRIBUTE_IS_COMPOSABLE = 'IsComposable'; }
|
|
7697
|
+
static { this.ATTRIBUTE_ENTITY_TYPE = 'EntityType'; }
|
|
7698
|
+
static { this.ATTRIBUTE_PATH = 'Path'; }
|
|
7699
|
+
static { this.ATTRIBUTE_TARGET = 'Target'; }
|
|
7700
|
+
static { this.ATTRIBUTE_FUNCTION = 'Function'; }
|
|
7701
|
+
static { this.ATTRIBUTE_ACTION = 'Action'; }
|
|
7702
|
+
static { this.ATTRIBUTE_ENTITY_SET = 'EntitySet'; }
|
|
7703
|
+
static { this.ATTRIBUTE_INCLUDE_IN_SERVICE_DOCUMENT = 'IncludeInServiceDocument'; }
|
|
7704
|
+
static { this.ATTRIBUTE_ABSTRACT = 'Abstract'; }
|
|
7705
|
+
static { this.ATTRIBUTE_UNDERLYING_TYPE = 'UnderlyingType'; }
|
|
7706
|
+
static { this.ATTRIBUTE_IS_FLAGS = 'IsFlags'; }
|
|
7707
|
+
static { this.ATTRIBUTE_EXTENDS = 'Extends'; }
|
|
7708
|
+
static { this.ATTRIBUTE_BASE_TERM = 'BaseTerm'; }
|
|
7709
|
+
static { this.ATTRIBUTE_APPLIES_TO = 'AppliesTo'; }
|
|
7507
7710
|
constructor(xml) {
|
|
7508
7711
|
try {
|
|
7509
7712
|
const parser = new DOMParser();
|
|
@@ -7952,79 +8155,6 @@ class ODataMetadata {
|
|
|
7952
8155
|
return attributeValue !== undefined ? attributeValue === 'true' : false;
|
|
7953
8156
|
}
|
|
7954
8157
|
}
|
|
7955
|
-
// TAGS
|
|
7956
|
-
ODataMetadata.TAG_EDMX = 'edmx:Edmx';
|
|
7957
|
-
ODataMetadata.TAG_DATA_SERVICES = 'edmx:DataServices';
|
|
7958
|
-
ODataMetadata.TAG_REFERENCE = 'edmx:Reference';
|
|
7959
|
-
ODataMetadata.TAG_INCLUDE = 'edmx:Include';
|
|
7960
|
-
ODataMetadata.TAG_INCLUDE_ANNOTATIONS = 'edmx:IncludeAnnotations';
|
|
7961
|
-
ODataMetadata.TAG_TERM = 'Term';
|
|
7962
|
-
ODataMetadata.TAG_ANNOTATIONS = 'Annotations';
|
|
7963
|
-
ODataMetadata.TAG_ANNOTATION = 'Annotation';
|
|
7964
|
-
ODataMetadata.TAG_SCHEMA = 'Schema';
|
|
7965
|
-
ODataMetadata.TAG_ENUM_TYPE = 'EnumType';
|
|
7966
|
-
ODataMetadata.TAG_MEMBER = 'Member';
|
|
7967
|
-
ODataMetadata.TAG_COMPLEX_TYPE = 'ComplexType';
|
|
7968
|
-
ODataMetadata.TAG_ENTITY_TYPE = 'EntityType';
|
|
7969
|
-
ODataMetadata.TAG_PROPERTY = 'Property';
|
|
7970
|
-
ODataMetadata.TAG_KEY = 'Key';
|
|
7971
|
-
ODataMetadata.TAG_PROPERTY_REF = 'PropertyRef';
|
|
7972
|
-
ODataMetadata.TAG_NAVIGATION_PROPERTY = 'NavigationProperty';
|
|
7973
|
-
ODataMetadata.TAG_REFERENTIAL_CONSTRAINT = 'ReferentialConstraint';
|
|
7974
|
-
ODataMetadata.TAG_ON_DELETE = 'OnDelete';
|
|
7975
|
-
ODataMetadata.TAG_FUNCTION = 'Function';
|
|
7976
|
-
ODataMetadata.TAG_RETURN_TYPE = 'ReturnType';
|
|
7977
|
-
ODataMetadata.TAG_PARAMETER = 'Parameter';
|
|
7978
|
-
ODataMetadata.TAG_ACTION = 'Action';
|
|
7979
|
-
ODataMetadata.TAG_ENTITY_CONTAINER = 'EntityContainer';
|
|
7980
|
-
ODataMetadata.TAG_ENTITY_SET = 'EntitySet';
|
|
7981
|
-
ODataMetadata.TAG_SINGLETON = 'Singleton';
|
|
7982
|
-
ODataMetadata.TAG_FUNCTION_IMPORT = 'FunctionImport';
|
|
7983
|
-
ODataMetadata.TAG_ACTION_IMPORT = 'ActionImport';
|
|
7984
|
-
ODataMetadata.TAG_NAVIGATION_PROPERTY_BINDING = 'NavigationPropertyBinding';
|
|
7985
|
-
ODataMetadata.TAG_TYPE_DEFINITION = 'TypeDefinition';
|
|
7986
|
-
// ATTRIBUTES
|
|
7987
|
-
ODataMetadata.ATTRIBUTE_VERSION = 'Version';
|
|
7988
|
-
ODataMetadata.ATTRIBUTE_URI = 'Uri';
|
|
7989
|
-
ODataMetadata.ATTRIBUTE_ALIAS = 'Alias';
|
|
7990
|
-
ODataMetadata.ATTRIBUTE_NAMESPACE = 'Namespace';
|
|
7991
|
-
ODataMetadata.ATTRIBUTE_TERM_NAMESPACE = 'TermNamespace';
|
|
7992
|
-
ODataMetadata.ATTRIBUTE_QUALIFIER = 'Qualifier';
|
|
7993
|
-
ODataMetadata.ATTRIBUTE_TARGET_NAMESPACE = 'TargetNamespace';
|
|
7994
|
-
ODataMetadata.ATTRIBUTE_TERM = 'Term';
|
|
7995
|
-
ODataMetadata.ATTRIBUTE_NAME = 'Name';
|
|
7996
|
-
ODataMetadata.ATTRIBUTE_VALUE = 'Value';
|
|
7997
|
-
ODataMetadata.ATTRIBUTE_BASE_TYPE = 'BaseType';
|
|
7998
|
-
ODataMetadata.ATTRIBUTE_OPEN_TYPE = 'OpenType';
|
|
7999
|
-
ODataMetadata.ATTRIBUTE_TYPE = 'Type';
|
|
8000
|
-
ODataMetadata.ATTRIBUTE_NULLABLE = 'Nullable';
|
|
8001
|
-
ODataMetadata.ATTRIBUTE_MAX_LENGTH = 'MaxLength';
|
|
8002
|
-
ODataMetadata.ATTRIBUTE_PRECISION = 'Precision';
|
|
8003
|
-
ODataMetadata.ATTRIBUTE_SCALE = 'Scale';
|
|
8004
|
-
ODataMetadata.ATTRIBUTE_UNICODE = 'Unicode';
|
|
8005
|
-
ODataMetadata.ATTRIBUTE_SRID = 'SRID';
|
|
8006
|
-
ODataMetadata.ATTRIBUTE_DEFAULT_VALUE = 'DefaultValue';
|
|
8007
|
-
ODataMetadata.ATTRIBUTE_PARTNER = 'Partner';
|
|
8008
|
-
ODataMetadata.ATTRIBUTE_PROPERTY = 'Property';
|
|
8009
|
-
ODataMetadata.ATTRIBUTE_REFERENCED_PROPERTY = 'ReferencedProperty';
|
|
8010
|
-
ODataMetadata.ATTRIBUTE_HAS_STREAM = 'HasStream';
|
|
8011
|
-
ODataMetadata.ATTRIBUTE_CONTAINS_TARGET = 'ContainsTarget';
|
|
8012
|
-
ODataMetadata.ATTRIBUTE_IS_BOUND = 'IsBound';
|
|
8013
|
-
ODataMetadata.ATTRIBUTE_ENTITY_SET_PATH = 'EntitySetPath';
|
|
8014
|
-
ODataMetadata.ATTRIBUTE_IS_COMPOSABLE = 'IsComposable';
|
|
8015
|
-
ODataMetadata.ATTRIBUTE_ENTITY_TYPE = 'EntityType';
|
|
8016
|
-
ODataMetadata.ATTRIBUTE_PATH = 'Path';
|
|
8017
|
-
ODataMetadata.ATTRIBUTE_TARGET = 'Target';
|
|
8018
|
-
ODataMetadata.ATTRIBUTE_FUNCTION = 'Function';
|
|
8019
|
-
ODataMetadata.ATTRIBUTE_ACTION = 'Action';
|
|
8020
|
-
ODataMetadata.ATTRIBUTE_ENTITY_SET = 'EntitySet';
|
|
8021
|
-
ODataMetadata.ATTRIBUTE_INCLUDE_IN_SERVICE_DOCUMENT = 'IncludeInServiceDocument';
|
|
8022
|
-
ODataMetadata.ATTRIBUTE_ABSTRACT = 'Abstract';
|
|
8023
|
-
ODataMetadata.ATTRIBUTE_UNDERLYING_TYPE = 'UnderlyingType';
|
|
8024
|
-
ODataMetadata.ATTRIBUTE_IS_FLAGS = 'IsFlags';
|
|
8025
|
-
ODataMetadata.ATTRIBUTE_EXTENDS = 'Extends';
|
|
8026
|
-
ODataMetadata.ATTRIBUTE_BASE_TERM = 'BaseTerm';
|
|
8027
|
-
ODataMetadata.ATTRIBUTE_APPLIES_TO = 'AppliesTo';
|
|
8028
8158
|
|
|
8029
8159
|
class ODataMetadataResource extends ODataResource {
|
|
8030
8160
|
constructor(api, segments) {
|
|
@@ -8272,12 +8402,12 @@ class ODataModelEvent {
|
|
|
8272
8402
|
}
|
|
8273
8403
|
get path() {
|
|
8274
8404
|
return this.chain
|
|
8275
|
-
.map(([,
|
|
8276
|
-
? `[${
|
|
8277
|
-
:
|
|
8405
|
+
.map(([, attr], index) => typeof attr === 'number'
|
|
8406
|
+
? `[${attr}]`
|
|
8407
|
+
: attr instanceof ODataModelAttribute
|
|
8278
8408
|
? index === 0
|
|
8279
|
-
?
|
|
8280
|
-
: `.${
|
|
8409
|
+
? attr.name
|
|
8410
|
+
: `.${attr.name}`
|
|
8281
8411
|
: '')
|
|
8282
8412
|
.join('');
|
|
8283
8413
|
}
|
|
@@ -8322,7 +8452,9 @@ function Model({ cid = CID_FIELD_NAME } = {}) {
|
|
|
8322
8452
|
return (constructor) => {
|
|
8323
8453
|
const Klass = constructor;
|
|
8324
8454
|
if (!Klass.hasOwnProperty('options'))
|
|
8325
|
-
Klass.options = {
|
|
8455
|
+
Klass.options = {
|
|
8456
|
+
fields: new Map(),
|
|
8457
|
+
};
|
|
8326
8458
|
Klass.options.cid = cid;
|
|
8327
8459
|
return constructor;
|
|
8328
8460
|
};
|
|
@@ -8331,9 +8463,11 @@ function ModelField({ name, ...options } = {}) {
|
|
|
8331
8463
|
return (target, key) => {
|
|
8332
8464
|
const Klass = target.constructor;
|
|
8333
8465
|
if (!Klass.hasOwnProperty('options'))
|
|
8334
|
-
Klass.options = {
|
|
8466
|
+
Klass.options = {
|
|
8467
|
+
fields: new Map(),
|
|
8468
|
+
};
|
|
8335
8469
|
options.field = name || key;
|
|
8336
|
-
Klass.options.fields
|
|
8470
|
+
Klass.options.fields.set(key, options);
|
|
8337
8471
|
};
|
|
8338
8472
|
}
|
|
8339
8473
|
class ODataModelField {
|
|
@@ -8556,9 +8690,7 @@ class ODataModelAttribute {
|
|
|
8556
8690
|
const current = this.get();
|
|
8557
8691
|
if (ODataModelOptions.isModel(current) ||
|
|
8558
8692
|
ODataModelOptions.isCollection(current))
|
|
8559
|
-
this.unlink(current
|
|
8560
|
-
//this.value !== current
|
|
8561
|
-
);
|
|
8693
|
+
this.unlink(current);
|
|
8562
8694
|
const changed = ODataModelOptions.isModel(current) && ODataModelOptions.isModel(value)
|
|
8563
8695
|
? !current.equals(value)
|
|
8564
8696
|
: ODataModelOptions.isCollection(current) &&
|
|
@@ -8623,10 +8755,9 @@ class ODataModelOptions {
|
|
|
8623
8755
|
};
|
|
8624
8756
|
this.name = schema.name;
|
|
8625
8757
|
this.base = schema.base;
|
|
8626
|
-
this.open = schema.open;
|
|
8627
8758
|
this.schema = schema;
|
|
8628
8759
|
this.cid = options?.cid || CID_FIELD_NAME;
|
|
8629
|
-
|
|
8760
|
+
options.fields.forEach((value, key) => this.addField(key, value));
|
|
8630
8761
|
}
|
|
8631
8762
|
get api() {
|
|
8632
8763
|
return this.schema.api;
|
|
@@ -8637,6 +8768,12 @@ class ODataModelOptions {
|
|
|
8637
8768
|
isOpenType() {
|
|
8638
8769
|
return this.schema.isOpenType();
|
|
8639
8770
|
}
|
|
8771
|
+
isEntityType() {
|
|
8772
|
+
return this.schema.isEntityType();
|
|
8773
|
+
}
|
|
8774
|
+
isComplexType() {
|
|
8775
|
+
return this.schema.isComplexType();
|
|
8776
|
+
}
|
|
8640
8777
|
isTypeOf(type) {
|
|
8641
8778
|
return this.schema.isTypeOf(type);
|
|
8642
8779
|
}
|
|
@@ -9325,6 +9462,15 @@ class ODataModelOptions {
|
|
|
9325
9462
|
}
|
|
9326
9463
|
|
|
9327
9464
|
class ODataCollection {
|
|
9465
|
+
static { this.model = null; }
|
|
9466
|
+
models() {
|
|
9467
|
+
return this._entries
|
|
9468
|
+
.filter((e) => e.state !== ODataModelState.Removed)
|
|
9469
|
+
.map((e) => e.model);
|
|
9470
|
+
}
|
|
9471
|
+
get length() {
|
|
9472
|
+
return this.models().length;
|
|
9473
|
+
}
|
|
9328
9474
|
constructor(entities = [], { parent, resource, annots, model, reset = false, } = {}) {
|
|
9329
9475
|
this._parent = null;
|
|
9330
9476
|
this._resource = null;
|
|
@@ -9356,14 +9502,6 @@ class ODataCollection {
|
|
|
9356
9502
|
entities = entities || [];
|
|
9357
9503
|
this.assign(entities, { reset });
|
|
9358
9504
|
}
|
|
9359
|
-
models() {
|
|
9360
|
-
return this._entries
|
|
9361
|
-
.filter((e) => e.state !== ODataModelState.Removed)
|
|
9362
|
-
.map((e) => e.model);
|
|
9363
|
-
}
|
|
9364
|
-
get length() {
|
|
9365
|
-
return this.models().length;
|
|
9366
|
-
}
|
|
9367
9505
|
isParentOf(child) {
|
|
9368
9506
|
return (child !== this &&
|
|
9369
9507
|
ODataModelOptions.chain(child).some((p) => p[0] === this));
|
|
@@ -9922,6 +10060,8 @@ class ODataCollection {
|
|
|
9922
10060
|
if (model.hasChanged())
|
|
9923
10061
|
toChange.push([model, position]);
|
|
9924
10062
|
}
|
|
10063
|
+
if (reset)
|
|
10064
|
+
entry.state = ODataModelState.Unchanged;
|
|
9925
10065
|
// Has Sort or Index Change?
|
|
9926
10066
|
if (toSort.length > 0 || position !== this.models().indexOf(model)) {
|
|
9927
10067
|
toSort.push([model, position]);
|
|
@@ -9931,12 +10071,14 @@ class ODataCollection {
|
|
|
9931
10071
|
// Add
|
|
9932
10072
|
model = isModel
|
|
9933
10073
|
? obj
|
|
9934
|
-
: this.modelFactory(obj
|
|
10074
|
+
: this.modelFactory(obj, {
|
|
10075
|
+
reset,
|
|
10076
|
+
});
|
|
9935
10077
|
toAdd.push([model, position]);
|
|
9936
10078
|
}
|
|
9937
10079
|
modelMap.push(model[Model.meta.cid]);
|
|
9938
10080
|
});
|
|
9939
|
-
if (remove) {
|
|
10081
|
+
if (remove || reset) {
|
|
9940
10082
|
this._entries.forEach((entry, position) => {
|
|
9941
10083
|
if (modelMap.indexOf(entry.model[Model.meta.cid]) === -1)
|
|
9942
10084
|
toRemove.push([entry.model, position]);
|
|
@@ -10175,17 +10317,39 @@ class ODataCollection {
|
|
|
10175
10317
|
}
|
|
10176
10318
|
}
|
|
10177
10319
|
}
|
|
10178
|
-
ODataCollection.model = null;
|
|
10179
10320
|
|
|
10180
10321
|
// @dynamic
|
|
10181
10322
|
class ODataModel {
|
|
10323
|
+
static buildMeta({ options, schema, }) {
|
|
10324
|
+
if (options === undefined) {
|
|
10325
|
+
let fields = schema
|
|
10326
|
+
.fields({ include_navigation: true, include_parents: true })
|
|
10327
|
+
.reduce((acc, field) => {
|
|
10328
|
+
let name = field.name;
|
|
10329
|
+
// Prevent collision with reserved keywords
|
|
10330
|
+
while (RESERVED_FIELD_NAMES.includes(name)) {
|
|
10331
|
+
name = name + '_';
|
|
10332
|
+
}
|
|
10333
|
+
return Object.assign(acc, {
|
|
10334
|
+
[name]: {
|
|
10335
|
+
field: field.name,
|
|
10336
|
+
default: field.default,
|
|
10337
|
+
required: !field.nullable,
|
|
10338
|
+
},
|
|
10339
|
+
});
|
|
10340
|
+
}, {});
|
|
10341
|
+
options = {
|
|
10342
|
+
fields: new Map(Object.entries(fields)),
|
|
10343
|
+
};
|
|
10344
|
+
}
|
|
10345
|
+
this.meta = new ODataModelOptions({ options, schema });
|
|
10346
|
+
}
|
|
10182
10347
|
constructor(data = {}, { parent, resource, annots, reset = false, } = {}) {
|
|
10183
10348
|
// Parent
|
|
10184
10349
|
this._parent = null;
|
|
10185
10350
|
this._resource = null;
|
|
10186
10351
|
this._resources = [];
|
|
10187
10352
|
this._attributes = new Map();
|
|
10188
|
-
this._annotations = null;
|
|
10189
10353
|
this._reset = false;
|
|
10190
10354
|
this._reparent = false;
|
|
10191
10355
|
this._silent = false;
|
|
@@ -10206,28 +10370,6 @@ class ODataModel {
|
|
|
10206
10370
|
reset,
|
|
10207
10371
|
});
|
|
10208
10372
|
}
|
|
10209
|
-
static buildMeta({ options, schema, }) {
|
|
10210
|
-
if (options === undefined) {
|
|
10211
|
-
let fields = schema
|
|
10212
|
-
.fields({ include_navigation: true, include_parents: true })
|
|
10213
|
-
.reduce((acc, field) => {
|
|
10214
|
-
let name = field.name;
|
|
10215
|
-
// Prevent collision with reserved keywords
|
|
10216
|
-
while (RESERVED_FIELD_NAMES.includes(name)) {
|
|
10217
|
-
name = name + '_';
|
|
10218
|
-
}
|
|
10219
|
-
return Object.assign(acc, {
|
|
10220
|
-
[name]: {
|
|
10221
|
-
field: field.name,
|
|
10222
|
-
default: field.default,
|
|
10223
|
-
required: !field.nullable,
|
|
10224
|
-
},
|
|
10225
|
-
});
|
|
10226
|
-
}, {});
|
|
10227
|
-
options = { fields };
|
|
10228
|
-
}
|
|
10229
|
-
this.meta = new ODataModelOptions({ options, schema });
|
|
10230
|
-
}
|
|
10231
10373
|
//#region Resources
|
|
10232
10374
|
resource() {
|
|
10233
10375
|
return ODataModelOptions.resource(this);
|
|
@@ -10276,8 +10418,7 @@ class ODataModel {
|
|
|
10276
10418
|
return this._meta.schema;
|
|
10277
10419
|
}
|
|
10278
10420
|
annots() {
|
|
10279
|
-
return
|
|
10280
|
-
new ODataEntityAnnotations(ODataHelper[DEFAULT_VERSION]));
|
|
10421
|
+
return this._annotations;
|
|
10281
10422
|
}
|
|
10282
10423
|
key({ field_mapping = false, resolve = true, } = {}) {
|
|
10283
10424
|
return this._meta.resolveKey(this, { field_mapping, resolve });
|
|
@@ -10502,6 +10643,13 @@ class ODataModel {
|
|
|
10502
10643
|
hasChanged({ include_navigation = false, } = {}) {
|
|
10503
10644
|
return this._meta.hasChanged(this, { include_navigation });
|
|
10504
10645
|
}
|
|
10646
|
+
encode(name, options) {
|
|
10647
|
+
let value = this[name];
|
|
10648
|
+
if (value === undefined)
|
|
10649
|
+
return undefined;
|
|
10650
|
+
let field = this._meta.field(name);
|
|
10651
|
+
return field !== undefined ? field.encode(value, options) : value;
|
|
10652
|
+
}
|
|
10505
10653
|
isNew() {
|
|
10506
10654
|
return !this._meta.hasKey(this);
|
|
10507
10655
|
}
|
|
@@ -10516,6 +10664,7 @@ class ODataModel {
|
|
|
10516
10664
|
asEntity(ctx) {
|
|
10517
10665
|
return this._meta.asEntity(this, ctx);
|
|
10518
10666
|
}
|
|
10667
|
+
//#region Callables
|
|
10519
10668
|
callFunction(name, params, responseType, { ...options } = {}) {
|
|
10520
10669
|
const resource = this.resource();
|
|
10521
10670
|
if (!(resource instanceof ODataEntityResource) || !resource.hasKey())
|
|
@@ -10556,6 +10705,7 @@ class ODataModel {
|
|
|
10556
10705
|
return action.call(params, { responseType, ...options });
|
|
10557
10706
|
}
|
|
10558
10707
|
}
|
|
10708
|
+
//#endregion
|
|
10559
10709
|
// Cast
|
|
10560
10710
|
cast(type) {
|
|
10561
10711
|
//: ODataModel<S> {
|
|
@@ -10600,7 +10750,7 @@ class ODataModel {
|
|
|
10600
10750
|
}
|
|
10601
10751
|
return of(value);
|
|
10602
10752
|
}
|
|
10603
|
-
|
|
10753
|
+
//#region References
|
|
10604
10754
|
setReference(name, model, options) {
|
|
10605
10755
|
const reference = this.navigationProperty(name).reference();
|
|
10606
10756
|
const etag = this.annots().etag;
|
|
@@ -10646,20 +10796,41 @@ class ODataModel {
|
|
|
10646
10796
|
}
|
|
10647
10797
|
return model;
|
|
10648
10798
|
}
|
|
10649
|
-
|
|
10650
|
-
|
|
10651
|
-
const thisKey = this.key();
|
|
10652
|
-
const otherKey = other.key();
|
|
10653
|
-
return (this === other ||
|
|
10654
|
-
(typeof this === typeof other &&
|
|
10655
|
-
(this[this._meta.cid] === other[this._meta.cid] ||
|
|
10656
|
-
(thisKey !== undefined &&
|
|
10657
|
-
otherKey !== undefined &&
|
|
10658
|
-
Types.isEqual(thisKey, otherKey)))));
|
|
10659
|
-
}
|
|
10799
|
+
//#endregion
|
|
10800
|
+
//#region Model Identity
|
|
10660
10801
|
get [Symbol.toStringTag]() {
|
|
10661
10802
|
return 'Model';
|
|
10662
10803
|
}
|
|
10804
|
+
equals(other) {
|
|
10805
|
+
if (this === other)
|
|
10806
|
+
return true;
|
|
10807
|
+
if (typeof this !== typeof other)
|
|
10808
|
+
return false;
|
|
10809
|
+
const meta = this._meta;
|
|
10810
|
+
const thisCid = this[meta.cid];
|
|
10811
|
+
const otherCid = other[meta.cid];
|
|
10812
|
+
if (thisCid !== undefined &&
|
|
10813
|
+
otherCid !== undefined &&
|
|
10814
|
+
Types.isEqual(thisCid, otherCid))
|
|
10815
|
+
return true;
|
|
10816
|
+
if (meta.isEntityType()) {
|
|
10817
|
+
const thisKey = this.key();
|
|
10818
|
+
const otherKey = other.key();
|
|
10819
|
+
if (thisKey !== undefined &&
|
|
10820
|
+
otherKey !== undefined &&
|
|
10821
|
+
Types.isEqual(thisKey, otherKey))
|
|
10822
|
+
return true;
|
|
10823
|
+
}
|
|
10824
|
+
else if (meta.isComplexType()) {
|
|
10825
|
+
const thisJson = this.toJSON();
|
|
10826
|
+
const otherJson = other.toJSON();
|
|
10827
|
+
if (Types.isEqual(thisJson, otherJson))
|
|
10828
|
+
return true;
|
|
10829
|
+
}
|
|
10830
|
+
return false;
|
|
10831
|
+
}
|
|
10832
|
+
//#endregion
|
|
10833
|
+
//#region Collection Tools
|
|
10663
10834
|
collection() {
|
|
10664
10835
|
return this._parent !== null &&
|
|
10665
10836
|
ODataModelOptions.isCollection(this._parent[0])
|
|
@@ -11543,10 +11714,10 @@ class ODataClient {
|
|
|
11543
11714
|
put(resource, body, options = {}) {
|
|
11544
11715
|
return this.request('PUT', resource, addBody(options, body));
|
|
11545
11716
|
}
|
|
11717
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ODataClient, deps: [{ token: i1.HttpClient }, { token: ODataConfigLoader }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
11718
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ODataClient }); }
|
|
11546
11719
|
}
|
|
11547
|
-
|
|
11548
|
-
ODataClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.6", ngImport: i0, type: ODataClient });
|
|
11549
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.6", ngImport: i0, type: ODataClient, decorators: [{
|
|
11720
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ODataClient, decorators: [{
|
|
11550
11721
|
type: Injectable
|
|
11551
11722
|
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: ODataConfigLoader }]; } });
|
|
11552
11723
|
|
|
@@ -11798,10 +11969,10 @@ class ODataServiceFactory {
|
|
|
11798
11969
|
return new (class extends ODataSingletonService {
|
|
11799
11970
|
})(this.client, singletonName, apiNameOrEntityType);
|
|
11800
11971
|
}
|
|
11972
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ODataServiceFactory, deps: [{ token: ODataClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
11973
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ODataServiceFactory }); }
|
|
11801
11974
|
}
|
|
11802
|
-
|
|
11803
|
-
ODataServiceFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.6", ngImport: i0, type: ODataServiceFactory });
|
|
11804
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.6", ngImport: i0, type: ODataServiceFactory, decorators: [{
|
|
11975
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ODataServiceFactory, decorators: [{
|
|
11805
11976
|
type: Injectable
|
|
11806
11977
|
}], ctorParameters: function () { return [{ type: ODataClient }]; } });
|
|
11807
11978
|
|
|
@@ -11828,11 +11999,11 @@ class ODataModule {
|
|
|
11828
11999
|
],
|
|
11829
12000
|
};
|
|
11830
12001
|
}
|
|
12002
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
12003
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.3", ngImport: i0, type: ODataModule, imports: [CommonModule, HttpClientModule] }); }
|
|
12004
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ODataModule, providers: [ODataClient, ODataServiceFactory], imports: [CommonModule, HttpClientModule] }); }
|
|
11831
12005
|
}
|
|
11832
|
-
|
|
11833
|
-
ODataModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.6", ngImport: i0, type: ODataModule, imports: [CommonModule, HttpClientModule] });
|
|
11834
|
-
ODataModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.6", ngImport: i0, type: ODataModule, providers: [ODataClient, ODataServiceFactory], imports: [CommonModule, HttpClientModule] });
|
|
11835
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.6", ngImport: i0, type: ODataModule, decorators: [{
|
|
12006
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ODataModule, decorators: [{
|
|
11836
12007
|
type: NgModule,
|
|
11837
12008
|
args: [{
|
|
11838
12009
|
imports: [CommonModule, HttpClientModule],
|
|
@@ -11848,5 +12019,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.6", ngImpor
|
|
|
11848
12019
|
* Generated bundle index. Do not edit.
|
|
11849
12020
|
*/
|
|
11850
12021
|
|
|
11851
|
-
export { BUBBLING, Dates, Durations, EDM_PARSERS, EdmType, Enums, Http, INCLUDE_DEEP, INCLUDE_SHALLOW, ITEM_ROOT, Model, ModelField, NONE_PARSER, ODATA_CONFIG, OData, ODataActionResource, ODataAnnotations, ODataApi, ODataBaseService, ODataBatchRequest, ODataBatchResource, ODataCache, ODataCallable, ODataCallableParser, ODataClient, ODataCollection, ODataConfigAsyncLoader, ODataConfigLoader, ODataConfigSyncLoader, ODataCountResource, ODataEntitiesAnnotations, ODataEntityAnnotations, ODataEntityContainer, ODataEntityResource, ODataEntitySet, ODataEntitySetResource, ODataEntitySetService, ODataEntityTypeKey, ODataEnumType, ODataEnumTypeFieldParser, ODataEnumTypeParser, ODataFunctionResource, ODataInMemoryCache, ODataInStorageCache, ODataMediaResource, ODataMetadata, ODataMetadataResource, ODataModel, ODataModelAttribute, ODataModelEvent, ODataModelEventType, ODataModelField, ODataModelOptions, ODataModelState, ODataModule, ODataNavigationPropertyResource, ODataParameterParser, ODataPathSegments, ODataPathSegmentsHandler, ODataPropertyAnnotations, ODataPropertyResource, ODataQueryOptionHandler, ODataQueryOptions, ODataQueryOptionsHandler, ODataReferenceResource, ODataReferential, ODataRequest, ODataResource, ODataResponse, ODataSchema, ODataServiceFactory, ODataSettings, ODataSingletonResource, ODataSingletonService, ODataStructuredType, ODataStructuredTypeFieldParser, ODataStructuredTypeParser, ODataValueResource, Objects, PathSegment, QueryCustomTypes, QueryOption, RESERVED_FIELD_NAMES, SegmentHandler, StandardAggregateMethods, Strings, Types, Urls, alias, binary, buildPathAndQuery, createSyncLoader, duration, isQueryCustomType, normalizeValue, raw };
|
|
12022
|
+
export { BUBBLING, Dates, Durations, EDM_PARSERS, EdmType, Enums, Http, INCLUDE_DEEP, INCLUDE_SHALLOW, ITEM_ROOT, Model, ModelField, NONE_PARSER, ODATA_CONFIG, OData, ODataActionResource, ODataAnnotations, ODataApi, ODataBaseService, ODataBatchRequest, ODataBatchResource, ODataCache, ODataCallable, ODataCallableParser, ODataClient, ODataCollection, ODataConfigAsyncLoader, ODataConfigLoader, ODataConfigSyncLoader, ODataCountResource, ODataEntitiesAnnotations, ODataEntityAnnotations, ODataEntityContainer, ODataEntityResource, ODataEntitySet, ODataEntitySetResource, ODataEntitySetService, ODataEntityTypeKey, ODataEnumType, ODataEnumTypeFieldParser, ODataEnumTypeParser, ODataFunctionResource, ODataInMemoryCache, ODataInStorageCache, ODataMediaResource, ODataMetadata, ODataMetadataResource, ODataModel, ODataModelAttribute, ODataModelEvent, ODataModelEventType, ODataModelField, ODataModelOptions, ODataModelState, ODataModule, ODataNavigationPropertyResource, ODataParameterParser, ODataPathSegments, ODataPathSegmentsHandler, ODataPropertyAnnotations, ODataPropertyResource, ODataQueryOptionHandler, ODataQueryOptions, ODataQueryOptionsHandler, ODataReferenceResource, ODataReferential, ODataRequest, ODataResource, ODataResponse, ODataSchema, ODataServiceFactory, ODataSettings, ODataSingletonResource, ODataSingletonService, ODataStructuredType, ODataStructuredTypeFieldParser, ODataStructuredTypeParser, ODataValueResource, Objects, PathSegment, QueryCustomTypes, QueryOption, RESERVED_FIELD_NAMES, SegmentHandler, StandardAggregateMethods, Strings, Types, Urls, alias, binary, buildPathAndQuery, createSyncLoader, duration, isQueryCustomType, isRawType, normalizeValue, raw };
|
|
11852
12023
|
//# sourceMappingURL=angular-odata.mjs.map
|