angular-odata 0.115.0 → 0.121.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/README.md +4 -2
- package/esm2020/lib/api.mjs +7 -7
- package/esm2020/lib/cache/cache.mjs +3 -3
- package/esm2020/lib/client.mjs +33 -27
- package/esm2020/lib/index.mjs +2 -2
- package/esm2020/lib/loaders.mjs +33 -0
- package/esm2020/lib/models/collection.mjs +79 -48
- package/esm2020/lib/models/model.mjs +35 -9
- package/esm2020/lib/models/options.mjs +99 -39
- package/esm2020/lib/module.mjs +21 -17
- package/esm2020/lib/options.mjs +4 -3
- package/esm2020/lib/resources/path/handlers.mjs +8 -8
- package/esm2020/lib/resources/path/segments.mjs +6 -6
- package/esm2020/lib/resources/query/builder.mjs +1 -1
- package/esm2020/lib/resources/query/expressions/count.mjs +5 -5
- package/esm2020/lib/resources/query/expressions/expand.mjs +18 -18
- package/esm2020/lib/resources/query/handlers.mjs +45 -45
- package/esm2020/lib/resources/query/options.mjs +27 -27
- package/esm2020/lib/resources/request.mjs +1 -1
- package/esm2020/lib/resources/resource.mjs +11 -9
- package/esm2020/lib/resources/responses/annotations.mjs +1 -1
- package/esm2020/lib/resources/types/action.mjs +16 -7
- package/esm2020/lib/resources/types/batch.mjs +135 -31
- package/esm2020/lib/resources/types/count.mjs +4 -4
- package/esm2020/lib/resources/types/entity-set.mjs +5 -7
- package/esm2020/lib/resources/types/entity.mjs +5 -5
- package/esm2020/lib/resources/types/function.mjs +16 -7
- package/esm2020/lib/resources/types/media.mjs +3 -3
- package/esm2020/lib/resources/types/metadata.mjs +3 -3
- package/esm2020/lib/resources/types/navigation-property.mjs +7 -9
- package/esm2020/lib/resources/types/options.mjs +1 -1
- package/esm2020/lib/resources/types/property.mjs +6 -10
- package/esm2020/lib/resources/types/reference.mjs +3 -3
- package/esm2020/lib/resources/types/singleton.mjs +4 -4
- package/esm2020/lib/resources/types/value.mjs +3 -3
- package/esm2020/lib/schema/parsers/edm.mjs +18 -17
- package/esm2020/lib/schema/parsers/enum-type.mjs +1 -1
- package/esm2020/lib/schema/parsers/structured-type.mjs +31 -19
- package/esm2020/lib/schema/structured-type.mjs +7 -1
- package/esm2020/lib/services/factory.mjs +3 -3
- package/esm2020/lib/settings.mjs +2 -2
- package/esm2020/lib/types.mjs +101 -32
- package/esm2020/lib/utils/enums.mjs +20 -20
- package/esm2020/lib/utils/strings.mjs +2 -2
- package/fesm2015/angular-odata.mjs +761 -406
- package/fesm2015/angular-odata.mjs.map +1 -1
- package/fesm2020/angular-odata.mjs +763 -404
- package/fesm2020/angular-odata.mjs.map +1 -1
- package/lib/api.d.ts +3 -3
- package/lib/client.d.ts +8 -7
- package/lib/index.d.ts +1 -1
- package/lib/loaders.d.ts +15 -0
- package/lib/models/collection.d.ts +21 -13
- package/lib/models/model.d.ts +10 -5
- package/lib/models/options.d.ts +20 -7
- package/lib/module.d.ts +12 -6
- package/lib/options.d.ts +6 -2
- package/lib/resources/path/handlers.d.ts +2 -2
- package/lib/resources/path/segments.d.ts +2 -2
- package/lib/resources/query/builder.d.ts +4 -1
- package/lib/resources/query/handlers.d.ts +3 -3
- package/lib/resources/query/options.d.ts +21 -21
- package/lib/resources/request.d.ts +4 -4
- package/lib/resources/resource.d.ts +4 -6
- package/lib/resources/types/action.d.ts +19 -2
- package/lib/resources/types/batch.d.ts +16 -5
- package/lib/resources/types/entity-set.d.ts +8 -8
- package/lib/resources/types/entity.d.ts +5 -5
- package/lib/resources/types/function.d.ts +17 -2
- package/lib/resources/types/navigation-property.d.ts +11 -11
- package/lib/resources/types/options.d.ts +0 -3
- package/lib/resources/types/property.d.ts +4 -4
- package/lib/resources/types/reference.d.ts +5 -5
- package/lib/resources/types/singleton.d.ts +5 -5
- package/lib/schema/parsers/edm.d.ts +2 -2
- package/lib/schema/parsers/enum-type.d.ts +2 -2
- package/lib/schema/parsers/structured-type.d.ts +8 -7
- package/lib/schema/structured-type.d.ts +3 -1
- package/lib/services/entity-set.d.ts +1 -6
- package/lib/settings.d.ts +3 -3
- package/lib/types.d.ts +46 -3
- package/lib/utils/enums.d.ts +18 -6
- package/lib/utils/strings.d.ts +4 -1
- package/package.json +1 -1
- package/esm2020/lib/tokens.mjs +0 -3
- package/lib/tokens.d.ts +0 -3
|
@@ -1,42 +1,112 @@
|
|
|
1
1
|
import * as i1 from '@angular/common/http';
|
|
2
2
|
import { HttpHeaders, HttpParams, HttpResponse, HttpErrorResponse, HttpEventType, HttpClientModule } from '@angular/common/http';
|
|
3
|
-
import { of, throwError, Subject, map as map$1,
|
|
3
|
+
import { of, throwError, Subject, map as map$1, EMPTY, Observable, forkJoin, NEVER } from 'rxjs';
|
|
4
4
|
import { tap, startWith, map, expand, reduce, finalize, switchMap, catchError } from 'rxjs/operators';
|
|
5
5
|
import { __rest } from 'tslib';
|
|
6
6
|
import * as i0 from '@angular/core';
|
|
7
7
|
import { EventEmitter, Injectable, InjectionToken, NgModule } from '@angular/core';
|
|
8
|
+
import { CommonModule } from '@angular/common';
|
|
8
9
|
|
|
9
|
-
var
|
|
10
|
-
(function (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
})(
|
|
24
|
-
var
|
|
25
|
-
(function (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})(
|
|
10
|
+
var PathSegment;
|
|
11
|
+
(function (PathSegment) {
|
|
12
|
+
PathSegment["batch"] = "batch";
|
|
13
|
+
PathSegment["metadata"] = "metadata";
|
|
14
|
+
PathSegment["entitySet"] = "entitySet";
|
|
15
|
+
PathSegment["singleton"] = "singleton";
|
|
16
|
+
PathSegment["type"] = "type";
|
|
17
|
+
PathSegment["property"] = "property";
|
|
18
|
+
PathSegment["navigationProperty"] = "navigationProperty";
|
|
19
|
+
PathSegment["reference"] = "reference";
|
|
20
|
+
PathSegment["value"] = "value";
|
|
21
|
+
PathSegment["count"] = "count";
|
|
22
|
+
PathSegment["function"] = "function";
|
|
23
|
+
PathSegment["action"] = "action";
|
|
24
|
+
})(PathSegment || (PathSegment = {}));
|
|
25
|
+
var QueryOption;
|
|
26
|
+
(function (QueryOption) {
|
|
27
|
+
QueryOption["select"] = "select";
|
|
28
|
+
QueryOption["expand"] = "expand";
|
|
29
|
+
QueryOption["compute"] = "compute";
|
|
30
|
+
QueryOption["filter"] = "filter";
|
|
31
|
+
QueryOption["search"] = "search";
|
|
32
|
+
QueryOption["transform"] = "transform";
|
|
33
|
+
QueryOption["orderBy"] = "orderBy";
|
|
34
|
+
QueryOption["top"] = "top";
|
|
35
|
+
QueryOption["skip"] = "skip";
|
|
36
|
+
QueryOption["skiptoken"] = "skiptoken";
|
|
37
|
+
QueryOption["format"] = "format";
|
|
38
|
+
QueryOption["levels"] = "levels";
|
|
39
|
+
QueryOption["count"] = "count";
|
|
40
|
+
})(QueryOption || (QueryOption = {}));
|
|
41
|
+
var EdmType;
|
|
42
|
+
(function (EdmType) {
|
|
43
|
+
//Edm.Guid 16-byte (128-bit) unique identifier
|
|
44
|
+
EdmType["Guid"] = "Edm.Guid";
|
|
45
|
+
//Edm.Int16 Signed 16-bit integer
|
|
46
|
+
EdmType["Int16"] = "Edm.Int16";
|
|
47
|
+
//Edm.String Sequence of UTF-8 characters
|
|
48
|
+
EdmType["String"] = "Edm.String";
|
|
49
|
+
//Edm.Boolean Binary-valued logic
|
|
50
|
+
EdmType["Boolean"] = "Edm.Boolean";
|
|
51
|
+
//Edm.Byte Unsigned 8-bit integer
|
|
52
|
+
EdmType["Byte"] = "Edm.Byte";
|
|
53
|
+
//Edm.SByte Signed 8-bit integer
|
|
54
|
+
EdmType["SByte"] = "Edm.SByte";
|
|
55
|
+
//Edm.Int32 Signed 16-bit integer
|
|
56
|
+
EdmType["Int32"] = "Edm.Int32";
|
|
57
|
+
//Edm.Int64 Signed 16-bit integer
|
|
58
|
+
EdmType["Int64"] = "Edm.Int64";
|
|
59
|
+
//Edm.Date Date without a time-zone offset
|
|
60
|
+
EdmType["Date"] = "Edm.Date";
|
|
61
|
+
//Edm.TimeOfDay Clock time 00:00-23:59:59.999999999999
|
|
62
|
+
EdmType["TimeOfDay"] = "Edm.TimeOfDay";
|
|
63
|
+
//Edm.DateTimeOffset Date and time with a time-zone offset, no leap seconds
|
|
64
|
+
EdmType["DateTimeOffset"] = "Edm.DateTimeOffset";
|
|
65
|
+
//Edm.Duration Signed duration in days, hours, minutes, and (sub)seconds
|
|
66
|
+
EdmType["Duration"] = "Edm.Duration";
|
|
67
|
+
//Edm.Decimal Numeric values with fixed precision and scale
|
|
68
|
+
EdmType["Decimal"] = "Edm.Decimal";
|
|
69
|
+
//Edm.Double IEEE 754 binary64 floating-point number (15-17 decimal digits)
|
|
70
|
+
EdmType["Double"] = "Edm.Double";
|
|
71
|
+
//Edm.Single IEEE 754 binary32 floating-point number (6-9 decimal digits)
|
|
72
|
+
EdmType["Single"] = "Edm.Single";
|
|
73
|
+
//Edm.Binary Binary data
|
|
74
|
+
EdmType["Binary"] = "Edm.Binary";
|
|
75
|
+
//Edm.Stream Binary data stream
|
|
76
|
+
EdmType["Stream"] = "Edm.Stream";
|
|
77
|
+
//Edm.Geography Abstract base type for all Geography types
|
|
78
|
+
EdmType["Geography"] = "Edm.Geography";
|
|
79
|
+
//Edm.GeographyPoint A point in a round-earth coordinate system
|
|
80
|
+
EdmType["GeographyPoint"] = "Edm.GeographyPoint";
|
|
81
|
+
//Edm.GeographyLineString Line string in a round-earth coordinate system
|
|
82
|
+
EdmType["GeographyLineString"] = "Edm.GeographyLineString";
|
|
83
|
+
//Edm.GeographyPolygon Polygon in a round-earth coordinate system
|
|
84
|
+
EdmType["GeographyPolygon"] = "Edm.GeographyPolygon";
|
|
85
|
+
//Edm.GeographyMultiPoint Collection of points in a round-earth coordinate system
|
|
86
|
+
EdmType["GeographyMultiPoint"] = "Edm.GeographyMultiPoint";
|
|
87
|
+
//Edm.GeographyMultiLineString Collection of line strings in a round-earth coordinate system
|
|
88
|
+
EdmType["GeographyMultiLineString"] = "Edm.GeographyMultiLineString";
|
|
89
|
+
//Edm.GeographyMultiPolygon Collection of polygons in a round-earth coordinate system
|
|
90
|
+
EdmType["GeographyMultiPolygon"] = "Edm.GeographyMultiPolygon";
|
|
91
|
+
//Edm.GeographyCollection Collection of arbitrary Geography values
|
|
92
|
+
EdmType["GeographyCollection"] = "Edm.GeographyCollection";
|
|
93
|
+
//Edm.Geometry Abstract base type for all Geometry types
|
|
94
|
+
EdmType["Geometry"] = "Edm.Geometry";
|
|
95
|
+
//Edm.GeometryPoint Point in a flat-earth coordinate system
|
|
96
|
+
EdmType["GeometryPoint"] = "Edm.GeometryPoint";
|
|
97
|
+
//Edm.GeometryLineString Line string in a flat-earth coordinate system
|
|
98
|
+
EdmType["GeometryLineString"] = "Edm.GeometryLineString";
|
|
99
|
+
//Edm.GeometryPolygon Polygon in a flat-earth coordinate system
|
|
100
|
+
EdmType["GeometryPolygon"] = "Edm.GeometryPolygon";
|
|
101
|
+
//Edm.GeometryMultiPoint Collection of points in a flat-earth coordinate system
|
|
102
|
+
EdmType["GeometryMultiPoint"] = "Edm.GeometryMultiPoint";
|
|
103
|
+
//Edm.GeometryMultiLineString Collection of line strings in a flat-earth coordinate system
|
|
104
|
+
EdmType["GeometryMultiLineString"] = "Edm.GeometryMultiLineString";
|
|
105
|
+
//Edm.GeometryMultiPolygon Collection of polygons in a flat-earth coordinate system
|
|
106
|
+
EdmType["GeometryMultiPolygon"] = "Edm.GeometryMultiPolygon";
|
|
107
|
+
//Edm.GeometryCollection Collection of arbitrary Geometry values
|
|
108
|
+
EdmType["GeometryCollection"] = "Edm.GeometryCollection";
|
|
109
|
+
})(EdmType || (EdmType = {}));
|
|
40
110
|
const NONE_PARSER = {
|
|
41
111
|
deserialize: (value) => value,
|
|
42
112
|
serialize: (value) => value,
|
|
@@ -148,7 +218,7 @@ class ODataCache {
|
|
|
148
218
|
scope(req) {
|
|
149
219
|
const segments = req.resource.cloneSegments();
|
|
150
220
|
return segments.segments({ key: true }).reduce((acc, s) => {
|
|
151
|
-
if (s.name ===
|
|
221
|
+
if (s.name === PathSegment.entitySet)
|
|
152
222
|
acc = [...acc, s.path()];
|
|
153
223
|
return acc;
|
|
154
224
|
}, ['request']);
|
|
@@ -980,45 +1050,45 @@ const Durations = {
|
|
|
980
1050
|
};
|
|
981
1051
|
|
|
982
1052
|
const Enums = {
|
|
983
|
-
names(
|
|
984
|
-
return Object.values(
|
|
1053
|
+
names(enums) {
|
|
1054
|
+
return Object.values(enums).filter((v) => typeof v === 'string');
|
|
985
1055
|
},
|
|
986
|
-
values(
|
|
987
|
-
return Object.values(
|
|
1056
|
+
values(enums) {
|
|
1057
|
+
return Object.values(enums).filter((v) => typeof v === 'number');
|
|
988
1058
|
},
|
|
989
|
-
toValue(
|
|
990
|
-
if (value in
|
|
991
|
-
return typeof value === 'string' ?
|
|
1059
|
+
toValue(enums, value) {
|
|
1060
|
+
if (value in enums)
|
|
1061
|
+
return typeof value === 'string' ? enums[value] : value;
|
|
992
1062
|
return undefined;
|
|
993
1063
|
},
|
|
994
|
-
toValues(
|
|
1064
|
+
toValues(enums, value) {
|
|
995
1065
|
if (typeof value === 'number') {
|
|
996
|
-
return this.values(
|
|
1066
|
+
return this.values(enums).filter((v) => (value & v) === v);
|
|
997
1067
|
}
|
|
998
1068
|
if (typeof value === 'string') {
|
|
999
1069
|
value = value.split(',').map((o) => o.trim());
|
|
1000
1070
|
}
|
|
1001
|
-
if (Array.isArray(value) && value.every((v) => v in
|
|
1002
|
-
return value.map((o) => this.toValue(
|
|
1071
|
+
if (Array.isArray(value) && value.every((v) => v in enums)) {
|
|
1072
|
+
return value.map((o) => this.toValue(enums, o));
|
|
1003
1073
|
}
|
|
1004
1074
|
return [];
|
|
1005
1075
|
},
|
|
1006
|
-
toName(
|
|
1007
|
-
if (value in
|
|
1008
|
-
return typeof value === 'number' ?
|
|
1076
|
+
toName(enums, value) {
|
|
1077
|
+
if (value in enums)
|
|
1078
|
+
return typeof value === 'number' ? enums[value] : value;
|
|
1009
1079
|
return undefined;
|
|
1010
1080
|
},
|
|
1011
|
-
toNames(
|
|
1081
|
+
toNames(enums, value) {
|
|
1012
1082
|
if (typeof value === 'number') {
|
|
1013
|
-
return this.values(
|
|
1083
|
+
return this.values(enums)
|
|
1014
1084
|
.filter((v) => (value & v) === v)
|
|
1015
|
-
.map((v) => this.toName(
|
|
1085
|
+
.map((v) => this.toName(enums, v));
|
|
1016
1086
|
}
|
|
1017
1087
|
if (typeof value === 'string') {
|
|
1018
1088
|
value = value.split(',').map((o) => o.trim());
|
|
1019
1089
|
}
|
|
1020
|
-
if (Array.isArray(value) && value.every((v) => v in
|
|
1021
|
-
return value.map((o) => this.toName(
|
|
1090
|
+
if (Array.isArray(value) && value.every((v) => v in enums)) {
|
|
1091
|
+
return value.map((o) => this.toName(enums, o));
|
|
1022
1092
|
}
|
|
1023
1093
|
return [];
|
|
1024
1094
|
},
|
|
@@ -1478,7 +1548,7 @@ function now() {
|
|
|
1478
1548
|
return (glast = time > last ? time : last + 1);
|
|
1479
1549
|
}
|
|
1480
1550
|
const Strings = {
|
|
1481
|
-
uniqueId(prefix, suffix) {
|
|
1551
|
+
uniqueId({ prefix, suffix, } = {}) {
|
|
1482
1552
|
return (prefix ? prefix : '') + now().toString(36) + (suffix ? suffix : '');
|
|
1483
1553
|
},
|
|
1484
1554
|
titleCase(text) {
|
|
@@ -1992,8 +2062,8 @@ class CountField {
|
|
|
1992
2062
|
}
|
|
1993
2063
|
render({ aliases, escape, prefix, }) {
|
|
1994
2064
|
const params = [
|
|
1995
|
-
|
|
1996
|
-
|
|
2065
|
+
QueryOption.filter,
|
|
2066
|
+
QueryOption.search,
|
|
1997
2067
|
]
|
|
1998
2068
|
.filter((key) => !Types.isEmpty(this.values[key]))
|
|
1999
2069
|
.reduce((acc, key) => {
|
|
@@ -2012,7 +2082,7 @@ class CountField {
|
|
|
2012
2082
|
return count;
|
|
2013
2083
|
}
|
|
2014
2084
|
filter(opts) {
|
|
2015
|
-
return this.option(
|
|
2085
|
+
return this.option(QueryOption.filter, FilterExpression.filter(opts, this.values[QueryOption.filter]));
|
|
2016
2086
|
}
|
|
2017
2087
|
clone() {
|
|
2018
2088
|
const values = Object.keys(this.values).reduce((acc, key) => Object.assign(acc, { [key]: Objects.clone(this.values[key]) }), {});
|
|
@@ -2436,14 +2506,14 @@ class ExpandField {
|
|
|
2436
2506
|
}
|
|
2437
2507
|
render({ aliases, escape, prefix, }) {
|
|
2438
2508
|
const params = [
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2509
|
+
QueryOption.select,
|
|
2510
|
+
QueryOption.expand,
|
|
2511
|
+
QueryOption.filter,
|
|
2512
|
+
QueryOption.search,
|
|
2513
|
+
QueryOption.orderBy,
|
|
2514
|
+
QueryOption.skip,
|
|
2515
|
+
QueryOption.top,
|
|
2516
|
+
QueryOption.levels,
|
|
2447
2517
|
]
|
|
2448
2518
|
.filter((key) => !Types.isEmpty(this.values[key]))
|
|
2449
2519
|
.reduce((acc, key) => {
|
|
@@ -2466,28 +2536,28 @@ class ExpandField {
|
|
|
2466
2536
|
return new ExpandField(this.field.clone(), values);
|
|
2467
2537
|
}
|
|
2468
2538
|
select(opts) {
|
|
2469
|
-
return this.option(
|
|
2539
|
+
return this.option(QueryOption.select, SelectExpression.select(opts, this.values[QueryOption.select]));
|
|
2470
2540
|
}
|
|
2471
2541
|
expand(opts) {
|
|
2472
|
-
return this.option(
|
|
2542
|
+
return this.option(QueryOption.expand, ExpandExpression.expand(opts, this.values[QueryOption.expand]));
|
|
2473
2543
|
}
|
|
2474
2544
|
filter(opts) {
|
|
2475
|
-
return this.option(
|
|
2545
|
+
return this.option(QueryOption.filter, FilterExpression.filter(opts, this.values[QueryOption.filter]));
|
|
2476
2546
|
}
|
|
2477
2547
|
search(opts) {
|
|
2478
|
-
return this.option(
|
|
2548
|
+
return this.option(QueryOption.search, SearchExpression.search(opts, this.values[QueryOption.search]));
|
|
2479
2549
|
}
|
|
2480
2550
|
orderBy(opts) {
|
|
2481
|
-
return this.option(
|
|
2551
|
+
return this.option(QueryOption.orderBy, OrderByExpression.orderBy(opts, this.values[QueryOption.orderBy]));
|
|
2482
2552
|
}
|
|
2483
2553
|
skip(n) {
|
|
2484
|
-
return this.option(
|
|
2554
|
+
return this.option(QueryOption.skip, n);
|
|
2485
2555
|
}
|
|
2486
2556
|
top(n) {
|
|
2487
|
-
return this.option(
|
|
2557
|
+
return this.option(QueryOption.top, n);
|
|
2488
2558
|
}
|
|
2489
2559
|
levels(n) {
|
|
2490
|
-
return this.option(
|
|
2560
|
+
return this.option(QueryOption.levels, n);
|
|
2491
2561
|
}
|
|
2492
2562
|
// Option Handler
|
|
2493
2563
|
option(name, opts) {
|
|
@@ -2727,54 +2797,54 @@ class ODataQueryOptionsHandler {
|
|
|
2727
2797
|
}
|
|
2728
2798
|
select(opts) {
|
|
2729
2799
|
if (Types.isFunction(opts)) {
|
|
2730
|
-
return this.options.expression(
|
|
2800
|
+
return this.options.expression(QueryOption.select, SelectExpression.select(opts, this.options.expression(QueryOption.select)));
|
|
2731
2801
|
}
|
|
2732
|
-
return this.options.option(
|
|
2802
|
+
return this.options.option(QueryOption.select, opts);
|
|
2733
2803
|
}
|
|
2734
2804
|
expand(opts) {
|
|
2735
2805
|
if (Types.isFunction(opts)) {
|
|
2736
|
-
return this.options.expression(
|
|
2806
|
+
return this.options.expression(QueryOption.expand, ExpandExpression.expand(opts, this.options.expression(QueryOption.expand)));
|
|
2737
2807
|
}
|
|
2738
|
-
return this.options.option(
|
|
2808
|
+
return this.options.option(QueryOption.expand, opts);
|
|
2739
2809
|
}
|
|
2740
2810
|
compute(opts) {
|
|
2741
2811
|
if (Types.isFunction(opts)) {
|
|
2742
|
-
return this.options.expression(
|
|
2812
|
+
return this.options.expression(QueryOption.compute, ComputeExpression.compute(opts, this.options.expression(QueryOption.compute)));
|
|
2743
2813
|
}
|
|
2744
|
-
return this.options.option(
|
|
2814
|
+
return this.options.option(QueryOption.compute, opts);
|
|
2745
2815
|
}
|
|
2746
2816
|
format(opts) {
|
|
2747
|
-
return this.options.option(
|
|
2817
|
+
return this.options.option(QueryOption.format, opts);
|
|
2748
2818
|
}
|
|
2749
2819
|
transform(opts) {
|
|
2750
|
-
return this.options.option(
|
|
2820
|
+
return this.options.option(QueryOption.transform, opts);
|
|
2751
2821
|
}
|
|
2752
2822
|
search(opts) {
|
|
2753
2823
|
if (Types.isFunction(opts)) {
|
|
2754
|
-
return this.options.expression(
|
|
2824
|
+
return this.options.expression(QueryOption.search, SearchExpression.search(opts, this.options.expression(QueryOption.search)));
|
|
2755
2825
|
}
|
|
2756
|
-
return this.options.option(
|
|
2826
|
+
return this.options.option(QueryOption.search, opts);
|
|
2757
2827
|
}
|
|
2758
2828
|
filter(opts) {
|
|
2759
2829
|
if (Types.isFunction(opts)) {
|
|
2760
|
-
return this.options.expression(
|
|
2830
|
+
return this.options.expression(QueryOption.filter, FilterExpression.filter(opts, this.options.expression(QueryOption.filter)));
|
|
2761
2831
|
}
|
|
2762
|
-
return this.options.option(
|
|
2832
|
+
return this.options.option(QueryOption.filter, opts);
|
|
2763
2833
|
}
|
|
2764
2834
|
orderBy(opts) {
|
|
2765
2835
|
if (Types.isFunction(opts)) {
|
|
2766
|
-
return this.options.option(
|
|
2836
|
+
return this.options.option(QueryOption.orderBy, OrderByExpression.orderBy(opts, this.options.expression(QueryOption.orderBy)));
|
|
2767
2837
|
}
|
|
2768
|
-
return this.options.option(
|
|
2838
|
+
return this.options.option(QueryOption.orderBy, opts);
|
|
2769
2839
|
}
|
|
2770
2840
|
top(opts) {
|
|
2771
|
-
return this.options.option(
|
|
2841
|
+
return this.options.option(QueryOption.top, opts);
|
|
2772
2842
|
}
|
|
2773
2843
|
skip(opts) {
|
|
2774
|
-
return this.options.option(
|
|
2844
|
+
return this.options.option(QueryOption.skip, opts);
|
|
2775
2845
|
}
|
|
2776
2846
|
skiptoken(opts) {
|
|
2777
|
-
return this.options.option(
|
|
2847
|
+
return this.options.option(QueryOption.skiptoken, opts);
|
|
2778
2848
|
}
|
|
2779
2849
|
/**
|
|
2780
2850
|
* Shortcut for set $top, $skip, $skiptoken.
|
|
@@ -2786,7 +2856,7 @@ class ODataQueryOptionsHandler {
|
|
|
2786
2856
|
this.skiptoken(skiptoken);
|
|
2787
2857
|
}
|
|
2788
2858
|
else {
|
|
2789
|
-
this.options.remove(
|
|
2859
|
+
this.options.remove(QueryOption.skiptoken);
|
|
2790
2860
|
}
|
|
2791
2861
|
}
|
|
2792
2862
|
if (skip !== undefined) {
|
|
@@ -2794,7 +2864,7 @@ class ODataQueryOptionsHandler {
|
|
|
2794
2864
|
this.skip(skip);
|
|
2795
2865
|
}
|
|
2796
2866
|
else {
|
|
2797
|
-
this.options.remove(
|
|
2867
|
+
this.options.remove(QueryOption.skip);
|
|
2798
2868
|
}
|
|
2799
2869
|
}
|
|
2800
2870
|
if (top !== undefined) {
|
|
@@ -2802,7 +2872,7 @@ class ODataQueryOptionsHandler {
|
|
|
2802
2872
|
this.top(top);
|
|
2803
2873
|
}
|
|
2804
2874
|
else {
|
|
2805
|
-
this.options.remove(
|
|
2875
|
+
this.options.remove(QueryOption.top);
|
|
2806
2876
|
}
|
|
2807
2877
|
}
|
|
2808
2878
|
}
|
|
@@ -2810,9 +2880,9 @@ class ODataQueryOptionsHandler {
|
|
|
2810
2880
|
* Shortcut for clear pagination by unset $top, $skip, $skiptoken.
|
|
2811
2881
|
*/
|
|
2812
2882
|
clearPaging() {
|
|
2813
|
-
this.options.remove(
|
|
2814
|
-
this.options.remove(
|
|
2815
|
-
this.options.remove(
|
|
2883
|
+
this.options.remove(QueryOption.skip);
|
|
2884
|
+
this.options.remove(QueryOption.top);
|
|
2885
|
+
this.options.remove(QueryOption.skiptoken);
|
|
2816
2886
|
}
|
|
2817
2887
|
/**
|
|
2818
2888
|
* Shortcut for clear query.
|
|
@@ -2833,76 +2903,76 @@ class ODataQueryOptionsHandler {
|
|
|
2833
2903
|
apply(query) {
|
|
2834
2904
|
if (query.select !== undefined) {
|
|
2835
2905
|
if (query.select instanceof SelectExpression) {
|
|
2836
|
-
this.options.expression(
|
|
2906
|
+
this.options.expression(QueryOption.select, query.select);
|
|
2837
2907
|
}
|
|
2838
2908
|
else if (query.select !== null) {
|
|
2839
|
-
this.options.option(
|
|
2909
|
+
this.options.option(QueryOption.select, query.select);
|
|
2840
2910
|
}
|
|
2841
2911
|
else {
|
|
2842
|
-
this.options.remove(
|
|
2912
|
+
this.options.remove(QueryOption.select);
|
|
2843
2913
|
}
|
|
2844
2914
|
}
|
|
2845
2915
|
if (query.expand !== undefined) {
|
|
2846
2916
|
if (query.expand instanceof ExpandExpression) {
|
|
2847
|
-
this.options.expression(
|
|
2917
|
+
this.options.expression(QueryOption.expand, query.expand);
|
|
2848
2918
|
}
|
|
2849
2919
|
else if (query.expand !== null) {
|
|
2850
|
-
this.options.option(
|
|
2920
|
+
this.options.option(QueryOption.expand, query.expand);
|
|
2851
2921
|
}
|
|
2852
2922
|
else {
|
|
2853
|
-
this.options.remove(
|
|
2923
|
+
this.options.remove(QueryOption.expand);
|
|
2854
2924
|
}
|
|
2855
2925
|
}
|
|
2856
2926
|
if (query.compute !== undefined) {
|
|
2857
2927
|
if (query.compute instanceof ComputeExpression) {
|
|
2858
|
-
this.options.expression(
|
|
2928
|
+
this.options.expression(QueryOption.compute, query.compute);
|
|
2859
2929
|
}
|
|
2860
2930
|
else if (query.compute !== null) {
|
|
2861
|
-
this.options.option(
|
|
2931
|
+
this.options.option(QueryOption.compute, query.compute);
|
|
2862
2932
|
}
|
|
2863
2933
|
else {
|
|
2864
|
-
this.options.remove(
|
|
2934
|
+
this.options.remove(QueryOption.compute);
|
|
2865
2935
|
}
|
|
2866
2936
|
}
|
|
2867
2937
|
if (query.transform !== undefined) {
|
|
2868
2938
|
if (query.transform !== null) {
|
|
2869
|
-
this.options.option(
|
|
2939
|
+
this.options.option(QueryOption.transform, query.transform);
|
|
2870
2940
|
}
|
|
2871
2941
|
else {
|
|
2872
|
-
this.options.remove(
|
|
2942
|
+
this.options.remove(QueryOption.transform);
|
|
2873
2943
|
}
|
|
2874
2944
|
}
|
|
2875
2945
|
if (query.search !== undefined) {
|
|
2876
2946
|
if (query.search instanceof SearchExpression) {
|
|
2877
|
-
this.options.expression(
|
|
2947
|
+
this.options.expression(QueryOption.search, query.search);
|
|
2878
2948
|
}
|
|
2879
2949
|
else if (query.search !== null) {
|
|
2880
|
-
this.options.option(
|
|
2950
|
+
this.options.option(QueryOption.search, query.search);
|
|
2881
2951
|
}
|
|
2882
2952
|
else {
|
|
2883
|
-
this.options.remove(
|
|
2953
|
+
this.options.remove(QueryOption.search);
|
|
2884
2954
|
}
|
|
2885
2955
|
}
|
|
2886
2956
|
if (query.filter !== undefined) {
|
|
2887
2957
|
if (query.filter instanceof FilterExpression) {
|
|
2888
|
-
this.options.expression(
|
|
2958
|
+
this.options.expression(QueryOption.filter, query.filter);
|
|
2889
2959
|
}
|
|
2890
2960
|
else if (query.filter !== null) {
|
|
2891
|
-
this.options.option(
|
|
2961
|
+
this.options.option(QueryOption.filter, query.filter);
|
|
2892
2962
|
}
|
|
2893
2963
|
else {
|
|
2894
|
-
this.options.remove(
|
|
2964
|
+
this.options.remove(QueryOption.filter);
|
|
2895
2965
|
}
|
|
2896
2966
|
}
|
|
2897
2967
|
if (query.orderBy !== undefined) {
|
|
2898
2968
|
if (query.orderBy instanceof OrderByExpression) {
|
|
2899
|
-
this.options.expression(
|
|
2969
|
+
this.options.expression(QueryOption.orderBy, query.orderBy);
|
|
2900
2970
|
}
|
|
2901
2971
|
else if (query.orderBy !== null) {
|
|
2902
|
-
this.options.option(
|
|
2972
|
+
this.options.option(QueryOption.orderBy, query.orderBy);
|
|
2903
2973
|
}
|
|
2904
2974
|
else {
|
|
2905
|
-
this.options.remove(
|
|
2975
|
+
this.options.remove(QueryOption.orderBy);
|
|
2906
2976
|
}
|
|
2907
2977
|
}
|
|
2908
2978
|
this.paging(query);
|
|
@@ -2920,19 +2990,19 @@ class ODataQueryOptions {
|
|
|
2920
2990
|
pathAndParams(escape = false) {
|
|
2921
2991
|
let aliases = [];
|
|
2922
2992
|
let options = [
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2993
|
+
QueryOption.select,
|
|
2994
|
+
QueryOption.filter,
|
|
2995
|
+
QueryOption.search,
|
|
2996
|
+
QueryOption.compute,
|
|
2997
|
+
QueryOption.transform,
|
|
2998
|
+
QueryOption.orderBy,
|
|
2999
|
+
QueryOption.top,
|
|
3000
|
+
QueryOption.skip,
|
|
3001
|
+
QueryOption.skiptoken,
|
|
3002
|
+
QueryOption.expand,
|
|
3003
|
+
QueryOption.format,
|
|
3004
|
+
QueryOption.levels,
|
|
3005
|
+
QueryOption.count,
|
|
2936
3006
|
]
|
|
2937
3007
|
.filter((key) => !Types.isEmpty(this.values.get(key)))
|
|
2938
3008
|
.reduce((acc, key) => {
|
|
@@ -2967,18 +3037,18 @@ class ODataQueryOptions {
|
|
|
2967
3037
|
}
|
|
2968
3038
|
toQueryArguments() {
|
|
2969
3039
|
return {
|
|
2970
|
-
select: this.values.get(
|
|
2971
|
-
expand: this.values.get(
|
|
2972
|
-
transform: this.values.get(
|
|
2973
|
-
compute: this.values.get(
|
|
2974
|
-
search: this.values.get(
|
|
2975
|
-
filter: this.values.get(
|
|
2976
|
-
orderBy: this.values.get(
|
|
2977
|
-
top: this.values.get(
|
|
2978
|
-
skip: this.values.get(
|
|
2979
|
-
skiptoken: this.values.get(
|
|
2980
|
-
levels: this.values.get(
|
|
2981
|
-
count: this.values.get(
|
|
3040
|
+
select: this.values.get(QueryOption.select) || null,
|
|
3041
|
+
expand: this.values.get(QueryOption.expand) || null,
|
|
3042
|
+
transform: this.values.get(QueryOption.transform) || null,
|
|
3043
|
+
compute: this.values.get(QueryOption.compute) || null,
|
|
3044
|
+
search: this.values.get(QueryOption.search) || null,
|
|
3045
|
+
filter: this.values.get(QueryOption.filter) || null,
|
|
3046
|
+
orderBy: this.values.get(QueryOption.orderBy) || null,
|
|
3047
|
+
top: this.values.get(QueryOption.top) || null,
|
|
3048
|
+
skip: this.values.get(QueryOption.skip) || null,
|
|
3049
|
+
skiptoken: this.values.get(QueryOption.skiptoken) || null,
|
|
3050
|
+
levels: this.values.get(QueryOption.levels) || null,
|
|
3051
|
+
count: this.values.get(QueryOption.count) || null,
|
|
2982
3052
|
};
|
|
2983
3053
|
}
|
|
2984
3054
|
clone() {
|
|
@@ -3065,30 +3135,30 @@ class ODataPathSegmentsHandler {
|
|
|
3065
3135
|
this.segments = segments;
|
|
3066
3136
|
}
|
|
3067
3137
|
entitySet() {
|
|
3068
|
-
return this.segments.get(
|
|
3138
|
+
return this.segments.get(PathSegment.entitySet);
|
|
3069
3139
|
}
|
|
3070
3140
|
singleton() {
|
|
3071
|
-
return this.segments.get(
|
|
3141
|
+
return this.segments.get(PathSegment.singleton);
|
|
3072
3142
|
}
|
|
3073
3143
|
action() {
|
|
3074
|
-
return this.segments.get(
|
|
3144
|
+
return this.segments.get(PathSegment.action);
|
|
3075
3145
|
}
|
|
3076
3146
|
function() {
|
|
3077
|
-
return this.segments.get(
|
|
3147
|
+
return this.segments.get(PathSegment.function);
|
|
3078
3148
|
}
|
|
3079
3149
|
keys(values) {
|
|
3080
3150
|
return this.segments.keys(values);
|
|
3081
3151
|
}
|
|
3082
3152
|
property() {
|
|
3083
|
-
return this.segments.get(
|
|
3153
|
+
return this.segments.get(PathSegment.property);
|
|
3084
3154
|
}
|
|
3085
3155
|
navigationProperty() {
|
|
3086
|
-
return this.segments.get(
|
|
3156
|
+
return this.segments.get(PathSegment.navigationProperty);
|
|
3087
3157
|
}
|
|
3088
3158
|
}
|
|
3089
3159
|
|
|
3090
3160
|
function pathSegmentsBuilder(segment, escape = false) {
|
|
3091
|
-
if (segment.name ===
|
|
3161
|
+
if (segment.name === PathSegment.function) {
|
|
3092
3162
|
let [path, params] = segment.parameters
|
|
3093
3163
|
? buildPathAndQuery({
|
|
3094
3164
|
func: { [segment.path]: segment.parameters },
|
|
@@ -3179,9 +3249,9 @@ class ODataPathSegments {
|
|
|
3179
3249
|
let segments = [...this._segments];
|
|
3180
3250
|
if (key)
|
|
3181
3251
|
segments = segments.filter((s) => [
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3252
|
+
PathSegment.entitySet,
|
|
3253
|
+
PathSegment.navigationProperty,
|
|
3254
|
+
PathSegment.property,
|
|
3185
3255
|
].indexOf(s.name) !== -1);
|
|
3186
3256
|
return segments.map((s) => new SegmentHandler(s));
|
|
3187
3257
|
}
|
|
@@ -3817,31 +3887,31 @@ const toBoolean = (v) => Boolean(v);
|
|
|
3817
3887
|
const toDate = (v) => new Date(v);
|
|
3818
3888
|
const EDM_PARSERS = {
|
|
3819
3889
|
//Edm.Guid 16-byte (128-bit) unique identifier
|
|
3820
|
-
|
|
3890
|
+
[EdmType.Guid]: EdmParser(Identity, Identity, (v) => raw(v)),
|
|
3821
3891
|
//Edm.Int16 Signed 16-bit integer
|
|
3822
|
-
|
|
3892
|
+
[EdmType.Int16]: EdmParser(toNumber, toNumber, toNumber),
|
|
3823
3893
|
//Edm.String Sequence of UTF-8 characters
|
|
3824
|
-
|
|
3894
|
+
[EdmType.String]: EdmParser(toString, toString, toString),
|
|
3825
3895
|
//Edm.Boolean Binary-valued logic
|
|
3826
|
-
|
|
3896
|
+
[EdmType.Boolean]: EdmParser(toBoolean, toBoolean, toBoolean),
|
|
3827
3897
|
//Edm.Byte Unsigned 8-bit integer
|
|
3828
|
-
|
|
3898
|
+
[EdmType.Byte]: EdmParser(toNumber, toNumber, toNumber),
|
|
3829
3899
|
//Edm.SByte Signed 8-bit integer
|
|
3830
|
-
|
|
3900
|
+
[EdmType.SByte]: EdmParser(toNumber, toNumber, toNumber),
|
|
3831
3901
|
//Edm.Int32 Signed 16-bit integer
|
|
3832
|
-
|
|
3902
|
+
[EdmType.Int32]: EdmParser(toNumber, toNumber, toNumber),
|
|
3833
3903
|
//Edm.Int64 Signed 16-bit integer
|
|
3834
|
-
|
|
3904
|
+
[EdmType.Int64]: EdmParser(toNumber, toNumber, toNumber),
|
|
3835
3905
|
//Edm.Date Date without a time-zone offset
|
|
3836
|
-
|
|
3906
|
+
[EdmType.Date]: EdmParser((v) => new Date(`${v}T00:00:00.000Z`), (v) => toDate(v).toISOString().substring(0, 10), (v) => raw(toDate(v).toISOString().substring(0, 10))),
|
|
3837
3907
|
//Edm.TimeOfDay Clock time 00:00-23:59:59.999999999999
|
|
3838
|
-
|
|
3908
|
+
[EdmType.TimeOfDay]: EdmParser((v) => new Date(`1970-01-01T${v}Z`), (v) => toDate(v).toISOString().substring(11, 23), (v) => raw(toDate(v).toISOString().substring(11, 23))),
|
|
3839
3909
|
//Edm.DateTimeOffset Date and time with a time-zone offset, no leap seconds
|
|
3840
|
-
|
|
3910
|
+
[EdmType.DateTimeOffset]: EdmParser(toDate, (v) => toDate(v).toISOString(), (v) => raw(toDate(v).toISOString())),
|
|
3841
3911
|
//Edm.Duration Signed duration in days, hours, minutes, and (sub)seconds
|
|
3842
|
-
|
|
3912
|
+
[EdmType.Duration]: EdmParser((v) => Durations.toDuration(v), (v) => Durations.toString(v), (v) => raw(Durations.toString(v))),
|
|
3843
3913
|
//Edm.Decimal Numeric values with fixed precision and scale
|
|
3844
|
-
|
|
3914
|
+
[EdmType.Decimal]: EdmParser((v, o) => {
|
|
3845
3915
|
if (typeof v === 'string' && o.ieee754Compatible) {
|
|
3846
3916
|
return parseFloat(v);
|
|
3847
3917
|
}
|
|
@@ -3866,11 +3936,11 @@ const EDM_PARSERS = {
|
|
|
3866
3936
|
return v;
|
|
3867
3937
|
}),
|
|
3868
3938
|
//Edm.Double IEEE 754 binary64 floating-point number (15-17 decimal digits)
|
|
3869
|
-
|
|
3939
|
+
[EdmType.Double]: EdmParser((v) => (v === 'INF' ? Infinity : v), (v) => (v === Infinity ? 'INF' : v), (v) => raw(v === Infinity ? 'INF' : v.toString())),
|
|
3870
3940
|
//Edm.Single IEEE 754 binary32 floating-point number (6-9 decimal digits)
|
|
3871
|
-
|
|
3941
|
+
[EdmType.Single]: EdmParser((v) => (v === 'INF' ? Infinity : v), (v) => (v === Infinity ? 'INF' : v), (v) => raw(v === Infinity ? 'INF' : v.toString())),
|
|
3872
3942
|
//Edm.Binary Binary data
|
|
3873
|
-
|
|
3943
|
+
[EdmType.Binary]: EdmParser((v) => ArrayBuffers.toArrayBuffer(v), (v) => ArrayBuffers.toString(v), (v) => raw(ArrayBuffers.toString(v))),
|
|
3874
3944
|
};
|
|
3875
3945
|
/*
|
|
3876
3946
|
Edm.Stream Binary data stream
|
|
@@ -4026,6 +4096,7 @@ class ODataReferential {
|
|
|
4026
4096
|
}
|
|
4027
4097
|
class ODataStructuredTypeFieldParser extends ODataAnnotatable {
|
|
4028
4098
|
constructor(name, structuredType, field) {
|
|
4099
|
+
var _a;
|
|
4029
4100
|
super(field);
|
|
4030
4101
|
this.name = name;
|
|
4031
4102
|
this.structuredType = structuredType;
|
|
@@ -4034,7 +4105,7 @@ class ODataStructuredTypeFieldParser extends ODataAnnotatable {
|
|
|
4034
4105
|
this.referentials = (field.referentials || []).map((referential) => new ODataReferential(referential));
|
|
4035
4106
|
this.default = field.default;
|
|
4036
4107
|
this.maxLength = field.maxLength;
|
|
4037
|
-
this.nullable = field.nullable !==
|
|
4108
|
+
this.nullable = (_a = field.nullable) !== null && _a !== void 0 ? _a : true;
|
|
4038
4109
|
this.collection = Boolean(field.collection);
|
|
4039
4110
|
this.navigation = Boolean(field.navigation);
|
|
4040
4111
|
this.precision = field.precision;
|
|
@@ -4143,36 +4214,42 @@ class ODataStructuredTypeFieldParser extends ODataAnnotatable {
|
|
|
4143
4214
|
? this.parser.toJsonSchema(options)
|
|
4144
4215
|
: { title: this.name, type: 'object' };
|
|
4145
4216
|
if ([
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4217
|
+
EdmType.String,
|
|
4218
|
+
EdmType.Date,
|
|
4219
|
+
EdmType.TimeOfDay,
|
|
4220
|
+
EdmType.DateTimeOffset,
|
|
4221
|
+
EdmType.Guid,
|
|
4222
|
+
EdmType.Binary,
|
|
4152
4223
|
].indexOf(this.type) !== -1) {
|
|
4153
4224
|
schema.type = 'string';
|
|
4154
|
-
if (this.type ===
|
|
4225
|
+
if (this.type === EdmType.Date)
|
|
4155
4226
|
schema.format = 'date';
|
|
4156
|
-
else if (this.type ===
|
|
4227
|
+
else if (this.type === EdmType.TimeOfDay)
|
|
4157
4228
|
schema.format = 'time';
|
|
4158
|
-
else if (this.type ===
|
|
4229
|
+
else if (this.type === EdmType.DateTimeOffset)
|
|
4159
4230
|
schema.format = 'date-time';
|
|
4160
|
-
else if (this.type ===
|
|
4231
|
+
else if (this.type === EdmType.Guid)
|
|
4161
4232
|
schema.pattern =
|
|
4162
4233
|
'^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$';
|
|
4163
|
-
else if (this.type ===
|
|
4234
|
+
else if (this.type === EdmType.Binary)
|
|
4164
4235
|
schema.contentEncoding = 'base64';
|
|
4165
|
-
else if (this.type ===
|
|
4236
|
+
else if (this.type === EdmType.String && this.maxLength)
|
|
4166
4237
|
schema.maxLength = this.maxLength;
|
|
4167
4238
|
}
|
|
4168
|
-
else if ([
|
|
4239
|
+
else if ([
|
|
4240
|
+
EdmType.Int64,
|
|
4241
|
+
EdmType.Int32,
|
|
4242
|
+
EdmType.Int16,
|
|
4243
|
+
EdmType.Byte,
|
|
4244
|
+
EdmType.SByte,
|
|
4245
|
+
].indexOf(this.type) !== -1) {
|
|
4169
4246
|
//TODO: Range
|
|
4170
4247
|
schema.type = 'integer';
|
|
4171
4248
|
}
|
|
4172
|
-
else if ([
|
|
4249
|
+
else if ([EdmType.Decimal, EdmType.Double].indexOf(this.type) !== -1) {
|
|
4173
4250
|
schema.type = 'number';
|
|
4174
4251
|
}
|
|
4175
|
-
else if ([
|
|
4252
|
+
else if ([EdmType.Boolean].indexOf(this.type) !== -1) {
|
|
4176
4253
|
schema.type = 'boolean';
|
|
4177
4254
|
}
|
|
4178
4255
|
if (this.default)
|
|
@@ -4225,6 +4302,7 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
|
|
|
4225
4302
|
constructor(config, namespace, alias) {
|
|
4226
4303
|
super(config);
|
|
4227
4304
|
this.children = [];
|
|
4305
|
+
this._fields = [];
|
|
4228
4306
|
this.name = config.name;
|
|
4229
4307
|
this.base = config.base;
|
|
4230
4308
|
this.open = config.open || false;
|
|
@@ -4232,7 +4310,12 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
|
|
|
4232
4310
|
this.alias = alias;
|
|
4233
4311
|
if (Array.isArray(config.keys))
|
|
4234
4312
|
this._keys = config.keys.map((key) => new ODataEntityTypeKey(key));
|
|
4235
|
-
|
|
4313
|
+
Object.entries(config.fields).forEach(([name, config]) => this.addField(name, config));
|
|
4314
|
+
}
|
|
4315
|
+
addField(name, config) {
|
|
4316
|
+
const field = new ODataStructuredTypeFieldParser(name, this, config);
|
|
4317
|
+
this._fields.push(field);
|
|
4318
|
+
return field;
|
|
4236
4319
|
}
|
|
4237
4320
|
/**
|
|
4238
4321
|
* Create a nicer looking title.
|
|
@@ -4774,6 +4857,9 @@ class ODataStructuredType extends ODataSchemaElement {
|
|
|
4774
4857
|
isCompoundKey() {
|
|
4775
4858
|
return this.keys().length > 1;
|
|
4776
4859
|
}
|
|
4860
|
+
isOpenType() {
|
|
4861
|
+
return this.open;
|
|
4862
|
+
}
|
|
4777
4863
|
/**
|
|
4778
4864
|
* Find the field parser for the given field name.
|
|
4779
4865
|
* @param name Name of the field
|
|
@@ -4782,6 +4868,9 @@ class ODataStructuredType extends ODataSchemaElement {
|
|
|
4782
4868
|
field(name) {
|
|
4783
4869
|
return this.parser.field(name);
|
|
4784
4870
|
}
|
|
4871
|
+
addField(name, config) {
|
|
4872
|
+
return this.parser.addField(name, config);
|
|
4873
|
+
}
|
|
4785
4874
|
/**
|
|
4786
4875
|
* Find a parent schema of the structured type.
|
|
4787
4876
|
* @param predicate Function for evaluate the schemas in the hierarchy.
|
|
@@ -4990,38 +5079,40 @@ class ODataResource {
|
|
|
4990
5079
|
}
|
|
4991
5080
|
hasEntityKey() {
|
|
4992
5081
|
var _a;
|
|
4993
|
-
return Boolean((_a = this.pathSegments.get(
|
|
5082
|
+
return Boolean((_a = this.pathSegments.get(PathSegment.entitySet)) === null || _a === void 0 ? void 0 : _a.hasKey());
|
|
4994
5083
|
}
|
|
4995
5084
|
clearKey() {
|
|
4996
5085
|
var _a;
|
|
4997
5086
|
return (_a = this.pathSegments.last({ key: true })) === null || _a === void 0 ? void 0 : _a.clearKey();
|
|
4998
5087
|
}
|
|
4999
5088
|
//#region Models
|
|
5000
|
-
asModel(entity, { annots
|
|
5089
|
+
asModel(entity, { annots } = {}) {
|
|
5090
|
+
const reset = annots !== undefined;
|
|
5001
5091
|
let resource = this;
|
|
5002
5092
|
const type = (annots === null || annots === void 0 ? void 0 : annots.type) || this.returnType();
|
|
5003
5093
|
if (type === undefined)
|
|
5004
5094
|
throw Error('');
|
|
5005
|
-
const
|
|
5095
|
+
const ModelType = this.api.modelForType(type);
|
|
5006
5096
|
let entitySet = annots === null || annots === void 0 ? void 0 : annots.entitySet;
|
|
5007
5097
|
if (entitySet !== undefined) {
|
|
5008
5098
|
resource = this.api.entitySet(entitySet).entity(entity);
|
|
5009
5099
|
resource.query((q) => q.apply(this.queryOptions.toQueryArguments()));
|
|
5010
5100
|
}
|
|
5011
|
-
return new
|
|
5101
|
+
return new ModelType(entity, { resource, annots, reset });
|
|
5012
5102
|
}
|
|
5013
|
-
asCollection(entities, { annots
|
|
5103
|
+
asCollection(entities, { annots } = {}) {
|
|
5104
|
+
const reset = annots !== undefined;
|
|
5014
5105
|
let resource = this;
|
|
5015
5106
|
const type = (annots === null || annots === void 0 ? void 0 : annots.type) || this.returnType();
|
|
5016
5107
|
if (type === undefined)
|
|
5017
5108
|
throw Error('');
|
|
5018
|
-
const
|
|
5109
|
+
const CollectionType = this.api.collectionForType(type);
|
|
5019
5110
|
let path = annots === null || annots === void 0 ? void 0 : annots.entitySet;
|
|
5020
5111
|
if (path !== undefined) {
|
|
5021
5112
|
resource = this.api.entitySet(path);
|
|
5022
5113
|
resource.query((q) => q.apply(this.queryOptions.toQueryArguments()));
|
|
5023
5114
|
}
|
|
5024
|
-
return new
|
|
5115
|
+
return new CollectionType(entities, { resource, annots, reset });
|
|
5025
5116
|
}
|
|
5026
5117
|
//#endregion
|
|
5027
5118
|
isSubtypeOf(other) {
|
|
@@ -5210,7 +5301,7 @@ class ODataActionResource extends ODataResource {
|
|
|
5210
5301
|
path = schema !== undefined ? schema.path() : path;
|
|
5211
5302
|
if (path === undefined)
|
|
5212
5303
|
throw new Error(`ODataActionResource: path is required`);
|
|
5213
|
-
const segment = segments.add(
|
|
5304
|
+
const segment = segments.add(PathSegment.action, path);
|
|
5214
5305
|
if (schema !== undefined)
|
|
5215
5306
|
segment.type(schema.type());
|
|
5216
5307
|
return new ODataActionResource(api, {
|
|
@@ -5280,7 +5371,7 @@ class ODataActionResource extends ODataResource {
|
|
|
5280
5371
|
* @returns Observable of the result of the action
|
|
5281
5372
|
*/
|
|
5282
5373
|
callModel(params, options = {}) {
|
|
5283
|
-
return this.call(params, Object.assign({ responseType: 'entity' }, options)).pipe(map(({ entity, annots }) => entity ? this.asModel(entity, { annots
|
|
5374
|
+
return this.call(params, Object.assign({ responseType: 'entity' }, options)).pipe(map(({ entity, annots }) => entity ? this.asModel(entity, { annots }) : null));
|
|
5284
5375
|
}
|
|
5285
5376
|
/**
|
|
5286
5377
|
* Execute the action and return the result as a entities
|
|
@@ -5298,9 +5389,16 @@ class ODataActionResource extends ODataResource {
|
|
|
5298
5389
|
* @returns Observable of the result of the action
|
|
5299
5390
|
*/
|
|
5300
5391
|
callCollection(params, options = {}) {
|
|
5301
|
-
return this.call(params, Object.assign({ responseType: 'entities' }, options)).pipe(map(({ entities, annots }) => entities
|
|
5302
|
-
|
|
5303
|
-
|
|
5392
|
+
return this.call(params, Object.assign({ responseType: 'entities' }, options)).pipe(map(({ entities, annots }) => entities ? this.asCollection(entities, { annots }) : null));
|
|
5393
|
+
}
|
|
5394
|
+
//#endregion
|
|
5395
|
+
callArraybuffer(params, _a = {}) {
|
|
5396
|
+
var { alias } = _a, options = __rest(_a, ["alias"]);
|
|
5397
|
+
return this.call(params, Object.assign({ responseType: 'arraybuffer', alias }, options));
|
|
5398
|
+
}
|
|
5399
|
+
callBlob(params, _a = {}) {
|
|
5400
|
+
var { alias } = _a, options = __rest(_a, ["alias"]);
|
|
5401
|
+
return this.call(params, Object.assign({ responseType: 'blob', alias }, options));
|
|
5304
5402
|
}
|
|
5305
5403
|
}
|
|
5306
5404
|
|
|
@@ -5318,8 +5416,13 @@ class ODataBatchRequest extends Subject {
|
|
|
5318
5416
|
constructor(request) {
|
|
5319
5417
|
super();
|
|
5320
5418
|
this.request = request;
|
|
5419
|
+
this.id = Strings.uniqueId({ prefix: 'r' });
|
|
5420
|
+
this.group = Strings.uniqueId({ prefix: 'g' });
|
|
5321
5421
|
}
|
|
5322
5422
|
toString() {
|
|
5423
|
+
return this.toLegacy();
|
|
5424
|
+
}
|
|
5425
|
+
toLegacy() {
|
|
5323
5426
|
//TODO: Relative or Absolute url ?
|
|
5324
5427
|
let res = [
|
|
5325
5428
|
`${this.request.method} ${this.request.pathWithParams} ${HTTP11}`,
|
|
@@ -5338,8 +5441,34 @@ class ODataBatchRequest extends Subject {
|
|
|
5338
5441
|
.map((key) => `${key}: ${(headers.getAll(key) || []).join(',')}`),
|
|
5339
5442
|
];
|
|
5340
5443
|
}
|
|
5444
|
+
if (this.request.method === 'GET' || this.request.method === 'DELETE') {
|
|
5445
|
+
res.push(NEWLINE);
|
|
5446
|
+
}
|
|
5447
|
+
else {
|
|
5448
|
+
res.push(`${NEWLINE}${JSON.stringify(this.request.body)}`);
|
|
5449
|
+
}
|
|
5341
5450
|
return res.join(NEWLINE);
|
|
5342
5451
|
}
|
|
5452
|
+
toJson() {
|
|
5453
|
+
//TODO: Relative or Absolute url ?
|
|
5454
|
+
let res = {
|
|
5455
|
+
id: this.id,
|
|
5456
|
+
method: this.request.method,
|
|
5457
|
+
url: this.request.pathWithParams,
|
|
5458
|
+
//'atomicityGroup': this.group
|
|
5459
|
+
//"dependsOn": ["g1", "g2", "r2"]
|
|
5460
|
+
};
|
|
5461
|
+
if (this.request.headers instanceof HttpHeaders) {
|
|
5462
|
+
let headers = this.request.headers;
|
|
5463
|
+
res['headers'] = headers
|
|
5464
|
+
.keys()
|
|
5465
|
+
.map((key) => `${key}: ${(headers.getAll(key) || []).join(',')}`);
|
|
5466
|
+
}
|
|
5467
|
+
if (!(this.request.method === 'GET' || this.request.method === 'DELETE')) {
|
|
5468
|
+
res['body'] = this.request.body;
|
|
5469
|
+
}
|
|
5470
|
+
return res;
|
|
5471
|
+
}
|
|
5343
5472
|
onLoad(response) {
|
|
5344
5473
|
if (response.ok) {
|
|
5345
5474
|
this.next(response);
|
|
@@ -5374,7 +5503,7 @@ class ODataBatchResource extends ODataResource {
|
|
|
5374
5503
|
//#region Factory
|
|
5375
5504
|
static factory(api) {
|
|
5376
5505
|
let segments = new ODataPathSegments();
|
|
5377
|
-
segments.add(
|
|
5506
|
+
segments.add(PathSegment.batch, $BATCH);
|
|
5378
5507
|
return new ODataBatchResource(api, { segments });
|
|
5379
5508
|
}
|
|
5380
5509
|
clone() {
|
|
@@ -5408,16 +5537,49 @@ class ODataBatchResource extends ODataResource {
|
|
|
5408
5537
|
// Store original requester
|
|
5409
5538
|
var handler = this.storeRequester();
|
|
5410
5539
|
// Execute the context
|
|
5411
|
-
const
|
|
5540
|
+
const result = ctx(this);
|
|
5412
5541
|
// Restore original requester
|
|
5413
5542
|
this.restoreRequester(handler);
|
|
5414
|
-
return
|
|
5543
|
+
return result;
|
|
5415
5544
|
}
|
|
5416
5545
|
send(options) {
|
|
5417
|
-
if (this.
|
|
5418
|
-
return
|
|
5546
|
+
if (this.api.options.jsonBatchFormat) {
|
|
5547
|
+
return this.sendJson(options);
|
|
5419
5548
|
}
|
|
5420
|
-
|
|
5549
|
+
else {
|
|
5550
|
+
return this.sendLegacy(options);
|
|
5551
|
+
}
|
|
5552
|
+
}
|
|
5553
|
+
sendJson(options) {
|
|
5554
|
+
const headers = Http.mergeHttpHeaders((options && options.headers) || {}, {
|
|
5555
|
+
[ODATA_VERSION]: VERSION_4_0,
|
|
5556
|
+
});
|
|
5557
|
+
return this.api
|
|
5558
|
+
.request('POST', this, {
|
|
5559
|
+
body: ODataBatchResource.buildJsonBody(this._requests),
|
|
5560
|
+
responseType: 'json',
|
|
5561
|
+
observe: 'response',
|
|
5562
|
+
headers: headers,
|
|
5563
|
+
params: options ? options.params : undefined,
|
|
5564
|
+
withCredentials: options ? options.withCredentials : undefined,
|
|
5565
|
+
})
|
|
5566
|
+
.pipe(map$1((response) => {
|
|
5567
|
+
if (this._responses == null) {
|
|
5568
|
+
this._responses = [];
|
|
5569
|
+
}
|
|
5570
|
+
this._responses = [
|
|
5571
|
+
...this._responses,
|
|
5572
|
+
...ODataBatchResource.parseJsonResponse(this._requests, response),
|
|
5573
|
+
];
|
|
5574
|
+
Arrays.zip(this._requests, this._responses).forEach((tuple) => {
|
|
5575
|
+
if (!tuple[0].isStopped)
|
|
5576
|
+
tuple[0].onLoad(tuple[1]);
|
|
5577
|
+
});
|
|
5578
|
+
return response;
|
|
5579
|
+
}));
|
|
5580
|
+
}
|
|
5581
|
+
sendLegacy(options) {
|
|
5582
|
+
const bound = Strings.uniqueId({ prefix: BATCH_PREFIX });
|
|
5421
5583
|
const headers = Http.mergeHttpHeaders((options && options.headers) || {}, {
|
|
5422
5584
|
[ODATA_VERSION]: VERSION_4_0,
|
|
5423
5585
|
[CONTENT_TYPE]: MULTIPART_MIXED_BOUNDARY + bound,
|
|
@@ -5425,7 +5587,7 @@ class ODataBatchResource extends ODataResource {
|
|
|
5425
5587
|
});
|
|
5426
5588
|
return this.api
|
|
5427
5589
|
.request('POST', this, {
|
|
5428
|
-
body: ODataBatchResource.
|
|
5590
|
+
body: ODataBatchResource.buildLegacyBody(bound, this._requests),
|
|
5429
5591
|
responseType: 'text',
|
|
5430
5592
|
observe: 'response',
|
|
5431
5593
|
headers: headers,
|
|
@@ -5438,7 +5600,7 @@ class ODataBatchResource extends ODataResource {
|
|
|
5438
5600
|
}
|
|
5439
5601
|
this._responses = [
|
|
5440
5602
|
...this._responses,
|
|
5441
|
-
...ODataBatchResource.
|
|
5603
|
+
...ODataBatchResource.parseLegacyResponse(this._requests, response),
|
|
5442
5604
|
];
|
|
5443
5605
|
Arrays.zip(this._requests, this._responses).forEach((tuple) => {
|
|
5444
5606
|
if (!tuple[0].isStopped)
|
|
@@ -5454,22 +5616,22 @@ class ODataBatchResource extends ODataResource {
|
|
|
5454
5616
|
* @returns The result of execute the context
|
|
5455
5617
|
*/
|
|
5456
5618
|
exec(ctx, options) {
|
|
5457
|
-
let
|
|
5458
|
-
|
|
5459
|
-
firstValueFrom(send$);
|
|
5460
|
-
return ctx$;
|
|
5461
|
-
//return this.send(options).pipe(switchMap(() => ctx$));
|
|
5619
|
+
let result = this.add(ctx);
|
|
5620
|
+
return this.send(options).pipe(map$1((response) => [result, response]));
|
|
5462
5621
|
}
|
|
5463
5622
|
body() {
|
|
5464
|
-
return ODataBatchResource.
|
|
5623
|
+
return ODataBatchResource.buildLegacyBody(Strings.uniqueId({ prefix: BATCH_PREFIX }), this._requests);
|
|
5624
|
+
}
|
|
5625
|
+
json() {
|
|
5626
|
+
return ODataBatchResource.buildJsonBody(this._requests);
|
|
5465
5627
|
}
|
|
5466
|
-
static
|
|
5628
|
+
static buildLegacyBody(batchBoundary, requests) {
|
|
5467
5629
|
let res = [];
|
|
5468
5630
|
let changesetBoundary = null;
|
|
5469
5631
|
let changesetId = 1;
|
|
5470
|
-
for (const
|
|
5632
|
+
for (const request of requests) {
|
|
5471
5633
|
// if method is GET and there is a changeset boundary open then close it
|
|
5472
|
-
if (
|
|
5634
|
+
if (request.request.method === 'GET' && changesetBoundary !== null) {
|
|
5473
5635
|
res.push(`${BOUNDARY_PREFIX_SUFFIX}${changesetBoundary}${BOUNDARY_PREFIX_SUFFIX}`);
|
|
5474
5636
|
changesetBoundary = null;
|
|
5475
5637
|
}
|
|
@@ -5478,9 +5640,9 @@ class ODataBatchResource extends ODataResource {
|
|
|
5478
5640
|
res.push(`${BOUNDARY_PREFIX_SUFFIX}${batchBoundary}`);
|
|
5479
5641
|
}
|
|
5480
5642
|
// if method is not GET and there is no changeset boundary open then open a changeset boundary
|
|
5481
|
-
if (
|
|
5643
|
+
if (request.request.method !== 'GET') {
|
|
5482
5644
|
if (changesetBoundary === null) {
|
|
5483
|
-
changesetBoundary = Strings.uniqueId(CHANGESET_PREFIX);
|
|
5645
|
+
changesetBoundary = Strings.uniqueId({ prefix: CHANGESET_PREFIX });
|
|
5484
5646
|
res.push(`${CONTENT_TYPE}: ${MULTIPART_MIXED_BOUNDARY}${changesetBoundary}`);
|
|
5485
5647
|
res.push(NEWLINE);
|
|
5486
5648
|
}
|
|
@@ -5488,17 +5650,11 @@ class ODataBatchResource extends ODataResource {
|
|
|
5488
5650
|
}
|
|
5489
5651
|
res.push(`${CONTENT_TYPE}: ${APPLICATION_HTTP}`);
|
|
5490
5652
|
res.push(`${CONTENT_TRANSFER_ENCODING}: ${BINARY}`);
|
|
5491
|
-
if (
|
|
5653
|
+
if (request.request.method !== 'GET') {
|
|
5492
5654
|
res.push(`${CONTENT_ID}: ${changesetId++}`);
|
|
5493
5655
|
}
|
|
5494
5656
|
res.push(NEWLINE);
|
|
5495
|
-
res.push(`${
|
|
5496
|
-
if (batch.request.method === 'GET' || batch.request.method === 'DELETE') {
|
|
5497
|
-
res.push(NEWLINE);
|
|
5498
|
-
}
|
|
5499
|
-
else {
|
|
5500
|
-
res.push(`${NEWLINE}${JSON.stringify(batch.request.body)}`);
|
|
5501
|
-
}
|
|
5657
|
+
res.push(`${request.toLegacy()}`);
|
|
5502
5658
|
}
|
|
5503
5659
|
if (res.length) {
|
|
5504
5660
|
if (changesetBoundary !== null) {
|
|
@@ -5509,7 +5665,12 @@ class ODataBatchResource extends ODataResource {
|
|
|
5509
5665
|
}
|
|
5510
5666
|
return res.join(NEWLINE);
|
|
5511
5667
|
}
|
|
5512
|
-
static
|
|
5668
|
+
static buildJsonBody(requests) {
|
|
5669
|
+
return {
|
|
5670
|
+
requests: requests.map((request) => request.toJson()),
|
|
5671
|
+
};
|
|
5672
|
+
}
|
|
5673
|
+
static parseLegacyResponse(requests, response) {
|
|
5513
5674
|
let chunks = [];
|
|
5514
5675
|
const contentType = response.headers.get(CONTENT_TYPE) || '';
|
|
5515
5676
|
const batchBoundary = Http.boundaryDelimiter(contentType);
|
|
@@ -5625,13 +5786,55 @@ class ODataBatchResource extends ODataResource {
|
|
|
5625
5786
|
});
|
|
5626
5787
|
});
|
|
5627
5788
|
}
|
|
5789
|
+
static parseJsonResponse(requests, response) {
|
|
5790
|
+
var _a;
|
|
5791
|
+
const responses = (_a = (response.body ? response.body : {})['responses']) !== null && _a !== void 0 ? _a : [];
|
|
5792
|
+
return responses.map((response, index) => {
|
|
5793
|
+
let request = requests[index].request;
|
|
5794
|
+
let code = response['status'];
|
|
5795
|
+
let headers = new HttpHeaders(response['headers']);
|
|
5796
|
+
let body = response['body'];
|
|
5797
|
+
if (code === 0) {
|
|
5798
|
+
code = !!body ? 200 : 0;
|
|
5799
|
+
}
|
|
5800
|
+
let ok = code >= 200 && code < 300;
|
|
5801
|
+
if (request.responseType === 'json' && typeof body === 'string') {
|
|
5802
|
+
const originalBody = body;
|
|
5803
|
+
body = body.replace(XSSI_PREFIX, '');
|
|
5804
|
+
try {
|
|
5805
|
+
body = body !== '' ? JSON.parse(body) : null;
|
|
5806
|
+
}
|
|
5807
|
+
catch (error) {
|
|
5808
|
+
body = originalBody;
|
|
5809
|
+
if (ok) {
|
|
5810
|
+
ok = false;
|
|
5811
|
+
body = { error, text: body };
|
|
5812
|
+
}
|
|
5813
|
+
}
|
|
5814
|
+
}
|
|
5815
|
+
return ok
|
|
5816
|
+
? new HttpResponse({
|
|
5817
|
+
body,
|
|
5818
|
+
headers,
|
|
5819
|
+
status: code,
|
|
5820
|
+
url: request.urlWithParams,
|
|
5821
|
+
})
|
|
5822
|
+
: new HttpErrorResponse({
|
|
5823
|
+
// The error in this case is the response body (error from the server).
|
|
5824
|
+
error: body,
|
|
5825
|
+
headers,
|
|
5826
|
+
status: code,
|
|
5827
|
+
url: request.urlWithParams,
|
|
5828
|
+
});
|
|
5829
|
+
});
|
|
5830
|
+
}
|
|
5628
5831
|
}
|
|
5629
5832
|
|
|
5630
5833
|
class ODataCountResource extends ODataResource {
|
|
5631
5834
|
//#region Factory
|
|
5632
5835
|
static factory(api, { segments, query, }) {
|
|
5633
|
-
segments.add(
|
|
5634
|
-
query === null || query === void 0 ? void 0 : query.keep(
|
|
5836
|
+
segments.add(PathSegment.count, $COUNT).type('Edm.Int32');
|
|
5837
|
+
query === null || query === void 0 ? void 0 : query.keep(QueryOption.filter, QueryOption.search);
|
|
5635
5838
|
return new ODataCountResource(api, { segments, query });
|
|
5636
5839
|
}
|
|
5637
5840
|
clone() {
|
|
@@ -5661,7 +5864,7 @@ class ODataFunctionResource extends ODataResource {
|
|
|
5661
5864
|
path = schema !== undefined ? schema.path() : path;
|
|
5662
5865
|
if (path === undefined)
|
|
5663
5866
|
throw new Error(`ODataActionResource: path is required`);
|
|
5664
|
-
const segment = segments.add(
|
|
5867
|
+
const segment = segments.add(PathSegment.function, path);
|
|
5665
5868
|
if (schema !== undefined)
|
|
5666
5869
|
segment.type(schema.type());
|
|
5667
5870
|
return new ODataFunctionResource(api, {
|
|
@@ -5757,7 +5960,7 @@ class ODataFunctionResource extends ODataResource {
|
|
|
5757
5960
|
*/
|
|
5758
5961
|
callModel(params, _a = {}) {
|
|
5759
5962
|
var { alias } = _a, options = __rest(_a, ["alias"]);
|
|
5760
|
-
return this.call(params, Object.assign({ responseType: 'entity', alias }, options)).pipe(map(({ entity, annots }) => entity ? this.asModel(entity, { annots
|
|
5963
|
+
return this.call(params, Object.assign({ responseType: 'entity', alias }, options)).pipe(map(({ entity, annots }) => entity ? this.asModel(entity, { annots }) : null));
|
|
5761
5964
|
}
|
|
5762
5965
|
/**
|
|
5763
5966
|
* Execute the function with the given parameters and return the result as a entities
|
|
@@ -5779,16 +5982,23 @@ class ODataFunctionResource extends ODataResource {
|
|
|
5779
5982
|
*/
|
|
5780
5983
|
callCollection(params, _a = {}) {
|
|
5781
5984
|
var { alias } = _a, options = __rest(_a, ["alias"]);
|
|
5782
|
-
return this.call(params, Object.assign({ responseType: 'entities', alias }, options)).pipe(map(({ entities, annots }) => entities
|
|
5783
|
-
|
|
5784
|
-
|
|
5985
|
+
return this.call(params, Object.assign({ responseType: 'entities', alias }, options)).pipe(map(({ entities, annots }) => entities ? this.asCollection(entities, { annots }) : null));
|
|
5986
|
+
}
|
|
5987
|
+
//#endregion
|
|
5988
|
+
callArraybuffer(params, _a = {}) {
|
|
5989
|
+
var { alias } = _a, options = __rest(_a, ["alias"]);
|
|
5990
|
+
return this.call(params, Object.assign({ responseType: 'arraybuffer', alias }, options));
|
|
5991
|
+
}
|
|
5992
|
+
callBlob(params, _a = {}) {
|
|
5993
|
+
var { alias } = _a, options = __rest(_a, ["alias"]);
|
|
5994
|
+
return this.call(params, Object.assign({ responseType: 'blob', alias }, options));
|
|
5785
5995
|
}
|
|
5786
5996
|
}
|
|
5787
5997
|
|
|
5788
5998
|
class ODataMediaResource extends ODataResource {
|
|
5789
5999
|
//#region Factory
|
|
5790
6000
|
static factory(api, { segments, query, }) {
|
|
5791
|
-
segments.add(
|
|
6001
|
+
segments.add(PathSegment.value, $VALUE);
|
|
5792
6002
|
return new ODataMediaResource(api, { segments, query });
|
|
5793
6003
|
}
|
|
5794
6004
|
clone() {
|
|
@@ -5830,7 +6040,7 @@ class ODataValueResource extends ODataResource {
|
|
|
5830
6040
|
static factory(api, { type, schema, segments, query, }) {
|
|
5831
6041
|
const baseType = type;
|
|
5832
6042
|
const bindingType = schema === null || schema === void 0 ? void 0 : schema.type();
|
|
5833
|
-
const segment = segments.add(
|
|
6043
|
+
const segment = segments.add(PathSegment.value, $VALUE);
|
|
5834
6044
|
if (schema !== undefined)
|
|
5835
6045
|
segment.type(schema.type());
|
|
5836
6046
|
else if (type !== undefined)
|
|
@@ -5869,7 +6079,7 @@ class ODataValueResource extends ODataResource {
|
|
|
5869
6079
|
class ODataPropertyResource extends ODataResource {
|
|
5870
6080
|
//#region Factory
|
|
5871
6081
|
static factory(api, { path, type, schema, segments, query, }) {
|
|
5872
|
-
const segment = segments.add(
|
|
6082
|
+
const segment = segments.add(PathSegment.property, path);
|
|
5873
6083
|
if (schema !== undefined)
|
|
5874
6084
|
segment.type(schema.type());
|
|
5875
6085
|
else if (type !== undefined)
|
|
@@ -6006,7 +6216,7 @@ class ODataPropertyResource extends ODataResource {
|
|
|
6006
6216
|
* @returns The model
|
|
6007
6217
|
*/
|
|
6008
6218
|
fetchModel(options = {}) {
|
|
6009
|
-
return this.fetch(Object.assign({ responseType: 'entity' }, options)).pipe(map(({ entity, annots }) => entity ? this.asModel(entity, { annots
|
|
6219
|
+
return this.fetch(Object.assign({ responseType: 'entity' }, options)).pipe(map(({ entity, annots }) => entity ? this.asModel(entity, { annots }) : null));
|
|
6010
6220
|
}
|
|
6011
6221
|
/**
|
|
6012
6222
|
* Fetch the entities
|
|
@@ -6022,16 +6232,12 @@ class ODataPropertyResource extends ODataResource {
|
|
|
6022
6232
|
* @returns The collection
|
|
6023
6233
|
*/
|
|
6024
6234
|
fetchCollection(options = {}) {
|
|
6025
|
-
return this.fetch(Object.assign({ responseType: 'entities' }, options)).pipe(map(({ entities, annots }) => entities
|
|
6026
|
-
? this.asCollection(entities, { annots, reset: true })
|
|
6027
|
-
: null));
|
|
6235
|
+
return this.fetch(Object.assign({ responseType: 'entities' }, options)).pipe(map(({ entities, annots }) => entities ? this.asCollection(entities, { annots }) : null));
|
|
6028
6236
|
}
|
|
6029
6237
|
fetchOne(options) {
|
|
6030
6238
|
let res = this.clone();
|
|
6031
6239
|
res.query((q) => q.top(1));
|
|
6032
|
-
return res
|
|
6033
|
-
.fetch(Object.assign({ responseType: 'entities' }, options))
|
|
6034
|
-
.pipe(map(({ entities, annots }) => ({
|
|
6240
|
+
return res.fetch(Object.assign({ responseType: 'entities' }, options)).pipe(map(({ entities, annots }) => ({
|
|
6035
6241
|
entity: entities !== null ? entities[0] || null : null,
|
|
6036
6242
|
annots,
|
|
6037
6243
|
})));
|
|
@@ -6074,7 +6280,7 @@ class ODataPropertyResource extends ODataResource {
|
|
|
6074
6280
|
class ODataReferenceResource extends ODataResource {
|
|
6075
6281
|
//#region Factory
|
|
6076
6282
|
static factory(api, { segments, query, }) {
|
|
6077
|
-
segments.add(
|
|
6283
|
+
segments.add(PathSegment.reference, $REF);
|
|
6078
6284
|
query === null || query === void 0 ? void 0 : query.clear();
|
|
6079
6285
|
return new ODataReferenceResource(api, { segments, query });
|
|
6080
6286
|
}
|
|
@@ -6164,12 +6370,12 @@ class ODataReferenceResource extends ODataResource {
|
|
|
6164
6370
|
class ODataNavigationPropertyResource extends ODataResource {
|
|
6165
6371
|
//#region Factory
|
|
6166
6372
|
static factory(api, { path, type, schema, segments, query, }) {
|
|
6167
|
-
const segment = segments.add(
|
|
6373
|
+
const segment = segments.add(PathSegment.navigationProperty, path);
|
|
6168
6374
|
if (schema !== undefined)
|
|
6169
6375
|
segment.type(schema.type());
|
|
6170
6376
|
else if (type !== undefined)
|
|
6171
6377
|
segment.type(type);
|
|
6172
|
-
query === null || query === void 0 ? void 0 : query.keep(
|
|
6378
|
+
query === null || query === void 0 ? void 0 : query.keep(QueryOption.format);
|
|
6173
6379
|
return new ODataNavigationPropertyResource(api, {
|
|
6174
6380
|
segments,
|
|
6175
6381
|
query,
|
|
@@ -6258,7 +6464,7 @@ class ODataNavigationPropertyResource extends ODataResource {
|
|
|
6258
6464
|
!castSchema.isSubtypeOf(baseSchema))
|
|
6259
6465
|
throw new Error(`Cannot cast to ${type}`);
|
|
6260
6466
|
const segments = this.cloneSegments();
|
|
6261
|
-
segments.add(
|
|
6467
|
+
segments.add(PathSegment.type, type).type(type);
|
|
6262
6468
|
return new ODataNavigationPropertyResource(this.api, {
|
|
6263
6469
|
segments,
|
|
6264
6470
|
schema: castSchema,
|
|
@@ -6337,7 +6543,7 @@ class ODataNavigationPropertyResource extends ODataResource {
|
|
|
6337
6543
|
* @returns The model
|
|
6338
6544
|
*/
|
|
6339
6545
|
fetchModel(options = {}) {
|
|
6340
|
-
return this.fetch(Object.assign({ responseType: 'entity' }, options)).pipe(map(({ entity, annots }) => entity ? this.asModel(entity, { annots
|
|
6546
|
+
return this.fetch(Object.assign({ responseType: 'entity' }, options)).pipe(map(({ entity, annots }) => entity ? this.asModel(entity, { annots }) : null));
|
|
6341
6547
|
}
|
|
6342
6548
|
/**
|
|
6343
6549
|
* Fetch entities
|
|
@@ -6353,9 +6559,7 @@ class ODataNavigationPropertyResource extends ODataResource {
|
|
|
6353
6559
|
* @returns The collection
|
|
6354
6560
|
*/
|
|
6355
6561
|
fetchCollection(options = {}) {
|
|
6356
|
-
return this.fetch(Object.assign({ responseType: 'entities' }, options)).pipe(map(({ entities, annots }) => entities
|
|
6357
|
-
? this.asCollection(entities, { annots, reset: true })
|
|
6358
|
-
: null));
|
|
6562
|
+
return this.fetch(Object.assign({ responseType: 'entities' }, options)).pipe(map(({ entities, annots }) => entities ? this.asCollection(entities, { annots }) : null));
|
|
6359
6563
|
}
|
|
6360
6564
|
/**
|
|
6361
6565
|
* Fetch all entities
|
|
@@ -6402,7 +6606,7 @@ class ODataNavigationPropertyResource extends ODataResource {
|
|
|
6402
6606
|
class ODataEntityResource extends ODataResource {
|
|
6403
6607
|
//#region Factory
|
|
6404
6608
|
static factory(api, { schema, segments, query, }) {
|
|
6405
|
-
query === null || query === void 0 ? void 0 : query.keep(
|
|
6609
|
+
query === null || query === void 0 ? void 0 : query.keep(QueryOption.expand, QueryOption.select, QueryOption.format);
|
|
6406
6610
|
return new ODataEntityResource(api, { segments, query, schema });
|
|
6407
6611
|
}
|
|
6408
6612
|
clone() {
|
|
@@ -6449,7 +6653,7 @@ class ODataEntityResource extends ODataResource {
|
|
|
6449
6653
|
!castSchema.isSubtypeOf(baseSchema))
|
|
6450
6654
|
throw new Error(`cast: Cannot cast to ${type}`);
|
|
6451
6655
|
const segments = this.cloneSegments();
|
|
6452
|
-
segments.add(
|
|
6656
|
+
segments.add(PathSegment.type, type).type(type);
|
|
6453
6657
|
return new ODataEntityResource(this.api, {
|
|
6454
6658
|
segments,
|
|
6455
6659
|
schema: castSchema,
|
|
@@ -6495,7 +6699,7 @@ class ODataEntityResource extends ODataResource {
|
|
|
6495
6699
|
return this.fetch(options).pipe(map(({ entity }) => entity));
|
|
6496
6700
|
}
|
|
6497
6701
|
fetchModel(options) {
|
|
6498
|
-
return this.fetch(options).pipe(map(({ entity, annots }) => entity ? this.asModel(entity, { annots
|
|
6702
|
+
return this.fetch(options).pipe(map(({ entity, annots }) => entity ? this.asModel(entity, { annots }) : null));
|
|
6499
6703
|
}
|
|
6500
6704
|
}
|
|
6501
6705
|
|
|
@@ -6503,7 +6707,7 @@ class ODataEntitySetResource extends ODataResource {
|
|
|
6503
6707
|
//#region Factory
|
|
6504
6708
|
static factory(api, { path, schema, query, }) {
|
|
6505
6709
|
const segments = new ODataPathSegments();
|
|
6506
|
-
const segment = segments.add(
|
|
6710
|
+
const segment = segments.add(PathSegment.entitySet, path);
|
|
6507
6711
|
if (schema !== undefined)
|
|
6508
6712
|
segment.type(schema.type());
|
|
6509
6713
|
return new ODataEntitySetResource(api, { segments, query, schema });
|
|
@@ -6543,7 +6747,7 @@ class ODataEntitySetResource extends ODataResource {
|
|
|
6543
6747
|
!castSchema.isSubtypeOf(baseSchema))
|
|
6544
6748
|
throw new Error(`Cannot cast to ${type}`);
|
|
6545
6749
|
const segments = this.cloneSegments();
|
|
6546
|
-
segments.add(
|
|
6750
|
+
segments.add(PathSegment.type, type).type(type);
|
|
6547
6751
|
return new ODataEntitySetResource(this.api, {
|
|
6548
6752
|
segments,
|
|
6549
6753
|
schema: castSchema,
|
|
@@ -6603,9 +6807,7 @@ class ODataEntitySetResource extends ODataResource {
|
|
|
6603
6807
|
return this.fetch(options).pipe(map(({ entities }) => entities));
|
|
6604
6808
|
}
|
|
6605
6809
|
fetchCollection(options) {
|
|
6606
|
-
return this.fetch(options).pipe(map(({ entities, annots }) => entities
|
|
6607
|
-
? this.asCollection(entities, { annots, reset: true })
|
|
6608
|
-
: null));
|
|
6810
|
+
return this.fetch(options).pipe(map(({ entities, annots }) => entities ? this.asCollection(entities, { annots }) : null));
|
|
6609
6811
|
}
|
|
6610
6812
|
}
|
|
6611
6813
|
|
|
@@ -7776,7 +7978,7 @@ class ODataMetadataResource extends ODataResource {
|
|
|
7776
7978
|
//#region Factory
|
|
7777
7979
|
static factory(api) {
|
|
7778
7980
|
let segments = new ODataPathSegments();
|
|
7779
|
-
segments.add(
|
|
7981
|
+
segments.add(PathSegment.metadata, $METADATA);
|
|
7780
7982
|
return new ODataMetadataResource(api, segments);
|
|
7781
7983
|
}
|
|
7782
7984
|
clone() {
|
|
@@ -7798,7 +8000,7 @@ class ODataSingletonResource extends ODataResource {
|
|
|
7798
8000
|
//#region Factory
|
|
7799
8001
|
static factory(api, { path, schema, query, }) {
|
|
7800
8002
|
const segments = new ODataPathSegments();
|
|
7801
|
-
const segment = segments.add(
|
|
8003
|
+
const segment = segments.add(PathSegment.singleton, path);
|
|
7802
8004
|
if (schema !== undefined)
|
|
7803
8005
|
segment.type(schema.type());
|
|
7804
8006
|
return new ODataSingletonResource(api, { segments, query, schema });
|
|
@@ -7908,7 +8110,7 @@ class ODataSingletonResource extends ODataResource {
|
|
|
7908
8110
|
* @returns Observable of the entity.
|
|
7909
8111
|
*/
|
|
7910
8112
|
fetchModel(options) {
|
|
7911
|
-
return this.fetch(options).pipe(map(({ entity, annots }) => entity ? this.asModel(entity, { annots
|
|
8113
|
+
return this.fetch(options).pipe(map(({ entity, annots }) => entity ? this.asModel(entity, { annots }) : null));
|
|
7912
8114
|
}
|
|
7913
8115
|
}
|
|
7914
8116
|
|
|
@@ -8250,28 +8452,27 @@ class ODataModelField {
|
|
|
8250
8452
|
throw Error(`No Collection type for ${this.name}`);
|
|
8251
8453
|
return new Collection((value || []), {
|
|
8252
8454
|
annots: annots,
|
|
8253
|
-
parent: [parent, this],
|
|
8254
8455
|
reset,
|
|
8456
|
+
parent: [parent, this],
|
|
8255
8457
|
});
|
|
8256
8458
|
}
|
|
8257
8459
|
}
|
|
8258
8460
|
class ODataModelOptions {
|
|
8259
8461
|
constructor({ options, schema, }) {
|
|
8462
|
+
this._fields = [];
|
|
8260
8463
|
this.children = [];
|
|
8464
|
+
this.tsToEdm = {
|
|
8465
|
+
string: EdmType.String,
|
|
8466
|
+
number: EdmType.Int32,
|
|
8467
|
+
bigint: EdmType.Int64,
|
|
8468
|
+
boolean: EdmType.Boolean,
|
|
8469
|
+
};
|
|
8261
8470
|
this.name = schema.name;
|
|
8262
8471
|
this.base = schema.base;
|
|
8263
8472
|
this.open = schema.open;
|
|
8264
8473
|
this.schema = schema;
|
|
8265
8474
|
this.cid = (options === null || options === void 0 ? void 0 : options.cid) || CID_FIELD_NAME;
|
|
8266
|
-
|
|
8267
|
-
const { field } = options, opts = __rest(options, ["field"]);
|
|
8268
|
-
if (field === undefined || name === undefined)
|
|
8269
|
-
throw new Error('Model Properties need name and field');
|
|
8270
|
-
const parser = this.schema.field(field);
|
|
8271
|
-
if (parser === undefined)
|
|
8272
|
-
throw new Error(`No parser for ${field} with name = ${name}`);
|
|
8273
|
-
return new ODataModelField(this, Object.assign({ name, field, parser }, opts));
|
|
8274
|
-
});
|
|
8475
|
+
Object.entries(options.fields).forEach(([name, options]) => this.addField(name, options));
|
|
8275
8476
|
}
|
|
8276
8477
|
get api() {
|
|
8277
8478
|
return this.schema.api;
|
|
@@ -8279,6 +8480,9 @@ class ODataModelOptions {
|
|
|
8279
8480
|
type({ alias = false } = {}) {
|
|
8280
8481
|
return this.schema.type({ alias });
|
|
8281
8482
|
}
|
|
8483
|
+
isOpenType() {
|
|
8484
|
+
return this.schema.isOpenType();
|
|
8485
|
+
}
|
|
8282
8486
|
isTypeOf(type) {
|
|
8283
8487
|
return this.schema.isTypeOf(type);
|
|
8284
8488
|
}
|
|
@@ -8336,15 +8540,53 @@ class ODataModelOptions {
|
|
|
8336
8540
|
];
|
|
8337
8541
|
}
|
|
8338
8542
|
field(name) {
|
|
8339
|
-
let field = this.
|
|
8340
|
-
include_parents: true,
|
|
8341
|
-
include_navigation: true,
|
|
8342
|
-
}).find((modelField) => modelField.name === name || modelField.field === name);
|
|
8543
|
+
let field = this.findField(name);
|
|
8343
8544
|
//Throw error if not found
|
|
8344
8545
|
if (field === undefined)
|
|
8345
8546
|
throw new Error(`No field with name ${name}`);
|
|
8346
8547
|
return field;
|
|
8347
8548
|
}
|
|
8549
|
+
findField(name) {
|
|
8550
|
+
return this.fields({
|
|
8551
|
+
include_parents: true,
|
|
8552
|
+
include_navigation: true,
|
|
8553
|
+
}).find((modelField) => modelField.name === name || modelField.field === name);
|
|
8554
|
+
}
|
|
8555
|
+
addField(name, options) {
|
|
8556
|
+
const { field, parser } = options, opts = __rest(options, ["field", "parser"]);
|
|
8557
|
+
if (field === undefined || name === undefined)
|
|
8558
|
+
throw new Error('Model Properties need name and field');
|
|
8559
|
+
const fieldParser = parser !== null && parser !== void 0 ? parser : this.schema.field(field);
|
|
8560
|
+
if (fieldParser === undefined)
|
|
8561
|
+
throw new Error(`No parser for ${field} with name = ${name}`);
|
|
8562
|
+
const modelField = new ODataModelField(this, Object.assign({ name,
|
|
8563
|
+
field, parser: fieldParser }, opts));
|
|
8564
|
+
this._fields.push(modelField);
|
|
8565
|
+
return modelField;
|
|
8566
|
+
}
|
|
8567
|
+
modelFieldFactory(self, name, type) {
|
|
8568
|
+
const structuredFieldParser = this.schema.addField(name, { type });
|
|
8569
|
+
structuredFieldParser.configure({
|
|
8570
|
+
findOptionsForType: (type) => this.api.findOptionsForType(type),
|
|
8571
|
+
parserForType: (type) => this.api.parserForType(type),
|
|
8572
|
+
options: this.api.options,
|
|
8573
|
+
});
|
|
8574
|
+
const modelField = this.addField(name, {
|
|
8575
|
+
field: name,
|
|
8576
|
+
parser: structuredFieldParser,
|
|
8577
|
+
});
|
|
8578
|
+
modelField.configure({
|
|
8579
|
+
findOptionsForType: (type) => this.api.findOptionsForType(type),
|
|
8580
|
+
options: this.api.options,
|
|
8581
|
+
concurrency: false,
|
|
8582
|
+
});
|
|
8583
|
+
Object.defineProperty(self, modelField.name, {
|
|
8584
|
+
configurable: true,
|
|
8585
|
+
get: () => this.get(self, modelField),
|
|
8586
|
+
set: (value) => this.set(self, modelField, value),
|
|
8587
|
+
});
|
|
8588
|
+
return modelField;
|
|
8589
|
+
}
|
|
8348
8590
|
attach(self, resource) {
|
|
8349
8591
|
if (self._resource !== null &&
|
|
8350
8592
|
resource.type() !== self._resource.type() &&
|
|
@@ -8453,8 +8695,8 @@ class ODataModelOptions {
|
|
|
8453
8695
|
for (let field of fields) {
|
|
8454
8696
|
Object.defineProperty(self, field.name, {
|
|
8455
8697
|
configurable: true,
|
|
8456
|
-
get: () => this.
|
|
8457
|
-
set: (value) => this.
|
|
8698
|
+
get: () => this.get(self, field),
|
|
8699
|
+
set: (value) => this.set(self, field, value),
|
|
8458
8700
|
});
|
|
8459
8701
|
}
|
|
8460
8702
|
}
|
|
@@ -8579,17 +8821,11 @@ class ODataModelOptions {
|
|
|
8579
8821
|
hasKey(self) {
|
|
8580
8822
|
return this.resolveKey(self) !== undefined;
|
|
8581
8823
|
}
|
|
8582
|
-
|
|
8583
|
-
var _a;
|
|
8584
|
-
// Build new resource
|
|
8585
|
-
const query = (_a = self._resource) === null || _a === void 0 ? void 0 : _a.cloneQuery();
|
|
8586
|
-
let resource = this.modelResourceFactory(query);
|
|
8587
|
-
if (resource === undefined)
|
|
8588
|
-
throw new Error('Model does not have associated Entity endpoint');
|
|
8824
|
+
withResource(self, resource, ctx) {
|
|
8589
8825
|
// Push
|
|
8590
8826
|
self.pushResource(resource);
|
|
8591
8827
|
// Execute function
|
|
8592
|
-
const result =
|
|
8828
|
+
const result = ctx(self);
|
|
8593
8829
|
if (result instanceof Observable) {
|
|
8594
8830
|
return result.pipe(finalize(() => {
|
|
8595
8831
|
// Pop
|
|
@@ -8602,6 +8838,15 @@ class ODataModelOptions {
|
|
|
8602
8838
|
return result;
|
|
8603
8839
|
}
|
|
8604
8840
|
}
|
|
8841
|
+
asEntity(self, ctx) {
|
|
8842
|
+
var _a;
|
|
8843
|
+
// Build new resource
|
|
8844
|
+
const query = (_a = self._resource) === null || _a === void 0 ? void 0 : _a.cloneQuery();
|
|
8845
|
+
let resource = this.modelResourceFactory(query);
|
|
8846
|
+
if (resource === undefined)
|
|
8847
|
+
throw new Error('Model does not have associated Entity endpoint');
|
|
8848
|
+
return this.withResource(self, resource, ctx);
|
|
8849
|
+
}
|
|
8605
8850
|
toEntity(self, { client_id = false, include_navigation = false, include_concurrency = false, include_computed = false, include_key = true, include_non_field = false, changes_only = false, field_mapping = false, chain = [], } = {}) {
|
|
8606
8851
|
let attrs = self.attributes({
|
|
8607
8852
|
changes_only,
|
|
@@ -8636,6 +8881,7 @@ class ODataModelOptions {
|
|
|
8636
8881
|
client_id,
|
|
8637
8882
|
include_navigation,
|
|
8638
8883
|
include_concurrency,
|
|
8884
|
+
include_computed,
|
|
8639
8885
|
include_non_field,
|
|
8640
8886
|
field_mapping,
|
|
8641
8887
|
changes_only: changesOnly,
|
|
@@ -8651,6 +8897,7 @@ class ODataModelOptions {
|
|
|
8651
8897
|
client_id,
|
|
8652
8898
|
include_navigation,
|
|
8653
8899
|
include_concurrency,
|
|
8900
|
+
include_computed,
|
|
8654
8901
|
include_non_field,
|
|
8655
8902
|
field_mapping,
|
|
8656
8903
|
changes_only: changesOnly,
|
|
@@ -8770,7 +9017,7 @@ class ODataModelOptions {
|
|
|
8770
9017
|
}).find((field) => (self._reset && field.field === key) || field.name === key);
|
|
8771
9018
|
if (field !== undefined) {
|
|
8772
9019
|
// Delegated to private setter
|
|
8773
|
-
if (this.
|
|
9020
|
+
if (this.set(self, field, value)) {
|
|
8774
9021
|
changes.push(field.name);
|
|
8775
9022
|
}
|
|
8776
9023
|
}
|
|
@@ -8798,7 +9045,7 @@ class ODataModelOptions {
|
|
|
8798
9045
|
static isCollection(obj) {
|
|
8799
9046
|
return Types.rawType(obj) === 'Collection';
|
|
8800
9047
|
}
|
|
8801
|
-
|
|
9048
|
+
_updateCollection(self, field, collection, value) {
|
|
8802
9049
|
collection._annotations = field.annotationsFactory(self.annots());
|
|
8803
9050
|
collection.assign(value, {
|
|
8804
9051
|
reset: self._reset,
|
|
@@ -8807,7 +9054,7 @@ class ODataModelOptions {
|
|
|
8807
9054
|
});
|
|
8808
9055
|
return collection.hasChanged();
|
|
8809
9056
|
}
|
|
8810
|
-
|
|
9057
|
+
_updateModel(self, field, model, value) {
|
|
8811
9058
|
model._annotations = field.annotationsFactory(self.annots());
|
|
8812
9059
|
model.assign(value, {
|
|
8813
9060
|
reset: self._reset,
|
|
@@ -8816,13 +9063,14 @@ class ODataModelOptions {
|
|
|
8816
9063
|
});
|
|
8817
9064
|
return model.hasChanged();
|
|
8818
9065
|
}
|
|
8819
|
-
|
|
8820
|
-
|
|
8821
|
-
|
|
8822
|
-
|
|
9066
|
+
get(self, field) {
|
|
9067
|
+
const modelField = field instanceof ODataModelField ? field : this.findField(field);
|
|
9068
|
+
if (modelField !== undefined && modelField.isStructuredType()) {
|
|
9069
|
+
const relation = self._relations.get(modelField.name);
|
|
9070
|
+
if (modelField.navigation &&
|
|
8823
9071
|
((relation === null || relation === void 0 ? void 0 : relation.model) === null || ODataModelOptions.isModel(relation === null || relation === void 0 ? void 0 : relation.model))) {
|
|
8824
9072
|
// Check for reference
|
|
8825
|
-
const referenced = this.resolveReferenced(self,
|
|
9073
|
+
const referenced = this.resolveReferenced(self, modelField);
|
|
8826
9074
|
if ((relation === null || relation === void 0 ? void 0 : relation.model) !== null &&
|
|
8827
9075
|
referenced !== null &&
|
|
8828
9076
|
referenced !== undefined) {
|
|
@@ -8846,7 +9094,7 @@ class ODataModelOptions {
|
|
|
8846
9094
|
return this.attributes(self, {
|
|
8847
9095
|
include_concurrency: true,
|
|
8848
9096
|
include_computed: true,
|
|
8849
|
-
})[
|
|
9097
|
+
})[modelField !== undefined ? modelField.name : field];
|
|
8850
9098
|
}
|
|
8851
9099
|
}
|
|
8852
9100
|
_setStructured(self, field, value) {
|
|
@@ -8888,7 +9136,7 @@ class ODataModelOptions {
|
|
|
8888
9136
|
}
|
|
8889
9137
|
else if (Types.isArray(value)) {
|
|
8890
9138
|
// New value is array
|
|
8891
|
-
changed = this.
|
|
9139
|
+
changed = this._updateCollection(self, field, currentCollection, value);
|
|
8892
9140
|
}
|
|
8893
9141
|
}
|
|
8894
9142
|
else if (ODataModelOptions.isModel(current)) {
|
|
@@ -8910,7 +9158,7 @@ class ODataModelOptions {
|
|
|
8910
9158
|
}
|
|
8911
9159
|
}
|
|
8912
9160
|
else if (Types.isPlainObject(value)) {
|
|
8913
|
-
changed = this.
|
|
9161
|
+
changed = this._updateModel(self, field, currentModel, value);
|
|
8914
9162
|
}
|
|
8915
9163
|
}
|
|
8916
9164
|
else {
|
|
@@ -8987,10 +9235,20 @@ class ODataModelOptions {
|
|
|
8987
9235
|
}
|
|
8988
9236
|
return changed;
|
|
8989
9237
|
}
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
|
|
9238
|
+
set(self, field, value, { type } = {}) {
|
|
9239
|
+
var _a;
|
|
9240
|
+
let modelField = field instanceof ODataModelField ? field : this.findField(field);
|
|
9241
|
+
if (modelField === undefined &&
|
|
9242
|
+
this.isOpenType() &&
|
|
9243
|
+
typeof field === 'string') {
|
|
9244
|
+
type = (_a = type !== null && type !== void 0 ? type : this.tsToEdm[typeof value]) !== null && _a !== void 0 ? _a : '';
|
|
9245
|
+
modelField = this.modelFieldFactory(self, field, type);
|
|
9246
|
+
}
|
|
9247
|
+
if (modelField === undefined)
|
|
9248
|
+
throw new Error(`No field with name ${field}`);
|
|
9249
|
+
return modelField.isStructuredType()
|
|
9250
|
+
? this._setStructured(self, modelField, value)
|
|
9251
|
+
: this._setValue(self, modelField, value, modelField.isKey());
|
|
8994
9252
|
}
|
|
8995
9253
|
_unlink(self, relation) {
|
|
8996
9254
|
if (relation.subscription !== undefined) {
|
|
@@ -9103,8 +9361,9 @@ class ODataCollection {
|
|
|
9103
9361
|
!this._resource.isSubtypeOf(resource))
|
|
9104
9362
|
throw new Error(`attach: Can't reattach ${this._resource.type()} to ${resource.type()}`);
|
|
9105
9363
|
this._entries.forEach(({ model }) => {
|
|
9106
|
-
const
|
|
9107
|
-
|
|
9364
|
+
const modelResource = this._model.meta.modelResourceFactory(resource.cloneQuery());
|
|
9365
|
+
if (modelResource !== undefined)
|
|
9366
|
+
model.attach(modelResource);
|
|
9108
9367
|
});
|
|
9109
9368
|
const current = this._resource;
|
|
9110
9369
|
if (current === null || !current.isEqualTo(resource)) {
|
|
@@ -9116,17 +9375,11 @@ class ODataCollection {
|
|
|
9116
9375
|
}));
|
|
9117
9376
|
}
|
|
9118
9377
|
}
|
|
9119
|
-
|
|
9120
|
-
var _a;
|
|
9121
|
-
// Build new resource
|
|
9122
|
-
const query = (_a = this._resource) === null || _a === void 0 ? void 0 : _a.cloneQuery();
|
|
9123
|
-
let resource = this._model.meta.collectionResourceFactory(query);
|
|
9124
|
-
if (resource === undefined)
|
|
9125
|
-
throw new Error('asEntitySet: Collection does not have associated EntitySet endpoint');
|
|
9378
|
+
withResource(resource, ctx) {
|
|
9126
9379
|
// Push
|
|
9127
9380
|
this.pushResource(resource);
|
|
9128
9381
|
// Execute
|
|
9129
|
-
const result =
|
|
9382
|
+
const result = ctx(this);
|
|
9130
9383
|
if (result instanceof Observable) {
|
|
9131
9384
|
return result.pipe(finalize(() => this.popResource()));
|
|
9132
9385
|
}
|
|
@@ -9136,6 +9389,15 @@ class ODataCollection {
|
|
|
9136
9389
|
return result;
|
|
9137
9390
|
}
|
|
9138
9391
|
}
|
|
9392
|
+
asEntitySet(ctx) {
|
|
9393
|
+
var _a;
|
|
9394
|
+
// Build new resource
|
|
9395
|
+
const query = (_a = this._resource) === null || _a === void 0 ? void 0 : _a.cloneQuery();
|
|
9396
|
+
let resource = this._model.meta.collectionResourceFactory(query);
|
|
9397
|
+
if (resource === undefined)
|
|
9398
|
+
throw new Error('asEntitySet: Collection does not have associated EntitySet endpoint');
|
|
9399
|
+
return this.withResource(resource, ctx);
|
|
9400
|
+
}
|
|
9139
9401
|
annots() {
|
|
9140
9402
|
return this._annotations;
|
|
9141
9403
|
}
|
|
@@ -9188,44 +9450,46 @@ class ODataCollection {
|
|
|
9188
9450
|
annots: this.annots(),
|
|
9189
9451
|
});
|
|
9190
9452
|
}
|
|
9191
|
-
_request(obs
|
|
9453
|
+
_request(obs$, { remove } = {}) {
|
|
9192
9454
|
this.events$.emit(new ODataModelEvent('request', {
|
|
9193
9455
|
collection: this,
|
|
9194
9456
|
options: { observable: obs$ },
|
|
9195
9457
|
}));
|
|
9196
9458
|
return obs$.pipe(map(({ entities, annots }) => {
|
|
9197
9459
|
this._annotations = annots;
|
|
9198
|
-
|
|
9460
|
+
const models = (entities || []).map((entity) => this.modelFactory(entity, { reset: true }));
|
|
9461
|
+
this.assign(models, { reset: true, remove });
|
|
9199
9462
|
this.events$.emit(new ODataModelEvent('sync', {
|
|
9200
9463
|
collection: this,
|
|
9201
|
-
options: { entities, annots },
|
|
9464
|
+
options: { models, entities, annots },
|
|
9202
9465
|
}));
|
|
9203
|
-
return
|
|
9466
|
+
return models;
|
|
9204
9467
|
}));
|
|
9205
9468
|
}
|
|
9206
9469
|
fetch(_a = {}) {
|
|
9207
|
-
var { withCount } = _a, options = __rest(_a, ["withCount"]);
|
|
9470
|
+
var { withCount, remove } = _a, options = __rest(_a, ["withCount", "remove"]);
|
|
9208
9471
|
const resource = this.resource();
|
|
9209
9472
|
const obs$ = resource instanceof ODataEntitySetResource
|
|
9210
9473
|
? resource.fetch(Object.assign({ withCount }, options))
|
|
9211
9474
|
: resource.fetch(Object.assign({ responseType: 'entities', withCount }, options));
|
|
9212
|
-
return this._request(obs
|
|
9475
|
+
return this._request(obs$, { remove });
|
|
9213
9476
|
}
|
|
9214
9477
|
fetchAll(_a = {}) {
|
|
9215
|
-
var { withCount } = _a, options = __rest(_a, ["withCount"]);
|
|
9478
|
+
var { withCount, remove } = _a, options = __rest(_a, ["withCount", "remove"]);
|
|
9216
9479
|
const resource = this.resource();
|
|
9217
9480
|
const obs$ = resource.fetchAll(Object.assign({ withCount }, options));
|
|
9218
|
-
return this._request(obs
|
|
9481
|
+
return this._request(obs$, { remove });
|
|
9219
9482
|
}
|
|
9220
9483
|
fetchMany(top, _a = {}) {
|
|
9221
|
-
var { withCount } = _a, options = __rest(_a, ["withCount"]);
|
|
9484
|
+
var { withCount, remove } = _a, options = __rest(_a, ["withCount", "remove"]);
|
|
9222
9485
|
const resource = this.resource();
|
|
9486
|
+
resource.query((q) => remove || this.length == 0 ? q.skip().clear() : q.skip(this.length));
|
|
9223
9487
|
const obs$ = resource.fetchMany(top, Object.assign({ withCount }, options));
|
|
9224
|
-
return this._request(obs
|
|
9488
|
+
return this._request(obs$, { remove: remove !== null && remove !== void 0 ? remove : false });
|
|
9225
9489
|
}
|
|
9226
9490
|
fetchOne(_a = {}) {
|
|
9227
|
-
var { withCount } = _a, options = __rest(_a, ["withCount"]);
|
|
9228
|
-
return this.fetchMany(1, Object.assign({ withCount }, options)).pipe(map((
|
|
9491
|
+
var { withCount, remove } = _a, options = __rest(_a, ["withCount", "remove"]);
|
|
9492
|
+
return this.fetchMany(1, Object.assign({ withCount, remove }, options)).pipe(map((models) => models[0]));
|
|
9229
9493
|
}
|
|
9230
9494
|
/**
|
|
9231
9495
|
* Save all models in the collection
|
|
@@ -9445,18 +9709,33 @@ class ODataCollection {
|
|
|
9445
9709
|
return of(this.removeModel(model, { silent }));
|
|
9446
9710
|
}
|
|
9447
9711
|
}
|
|
9712
|
+
_moveModel(model, position) {
|
|
9713
|
+
const key = model.key();
|
|
9714
|
+
let entry = this._findEntry({
|
|
9715
|
+
model,
|
|
9716
|
+
key,
|
|
9717
|
+
cid: model[this._model.meta.cid],
|
|
9718
|
+
});
|
|
9719
|
+
if (entry === undefined || entry.state === ODataModelState.Removed) {
|
|
9720
|
+
return model;
|
|
9721
|
+
}
|
|
9722
|
+
// Now remove
|
|
9723
|
+
const index = this._entries.indexOf(entry);
|
|
9724
|
+
this._entries.splice(index, 1);
|
|
9725
|
+
this._entries.splice(position, 0, entry);
|
|
9726
|
+
return entry.model;
|
|
9727
|
+
}
|
|
9448
9728
|
create(attrs = {}, { silent = false, server = true, } = {}) {
|
|
9449
9729
|
const model = this.modelFactory(attrs);
|
|
9450
9730
|
return (model.isValid() && server ? model.save() : of(model)).pipe(switchMap((model) => this.add(model, { silent, server })), map(() => model));
|
|
9451
9731
|
}
|
|
9452
|
-
set(path, value) {
|
|
9453
|
-
const Model = this._model;
|
|
9732
|
+
set(path, value, {}) {
|
|
9454
9733
|
const pathArray = (Types.isArray(path) ? path : path.match(/([^[.\]])+/g));
|
|
9455
9734
|
if (pathArray.length === 0)
|
|
9456
9735
|
return undefined;
|
|
9457
9736
|
if (pathArray.length > 1) {
|
|
9458
9737
|
const model = this._entries[Number(pathArray[0])].model;
|
|
9459
|
-
return model.set(pathArray.slice(1), value);
|
|
9738
|
+
return model.set(pathArray.slice(1), value, {});
|
|
9460
9739
|
}
|
|
9461
9740
|
if (pathArray.length === 1 && ODataModelOptions.isModel(value)) {
|
|
9462
9741
|
let toAdd = [];
|
|
@@ -9485,7 +9764,6 @@ class ODataCollection {
|
|
|
9485
9764
|
}
|
|
9486
9765
|
}
|
|
9487
9766
|
get(path) {
|
|
9488
|
-
const Model = this._model;
|
|
9489
9767
|
const pathArray = (Types.isArray(path) ? path : `${path}`.match(/([^[.\]])+/g));
|
|
9490
9768
|
if (pathArray.length === 0)
|
|
9491
9769
|
return undefined;
|
|
@@ -9495,6 +9773,16 @@ class ODataCollection {
|
|
|
9495
9773
|
}
|
|
9496
9774
|
return value;
|
|
9497
9775
|
}
|
|
9776
|
+
has(path) {
|
|
9777
|
+
const pathArray = (Types.isArray(path) ? path : `${path}`.match(/([^[.\]])+/g));
|
|
9778
|
+
if (pathArray.length === 0)
|
|
9779
|
+
return false;
|
|
9780
|
+
const value = this.models()[Number(pathArray[0])];
|
|
9781
|
+
if (pathArray.length > 1 && ODataModelOptions.isModel(value)) {
|
|
9782
|
+
return value.has(pathArray.slice(1));
|
|
9783
|
+
}
|
|
9784
|
+
return value !== undefined;
|
|
9785
|
+
}
|
|
9498
9786
|
reset({ path, silent = false, } = {}) {
|
|
9499
9787
|
let toAdd = [];
|
|
9500
9788
|
let toChange = [];
|
|
@@ -9558,8 +9846,9 @@ class ODataCollection {
|
|
|
9558
9846
|
}));
|
|
9559
9847
|
}
|
|
9560
9848
|
}
|
|
9561
|
-
assign(objects, { reset = false, reparent = false, silent = false, } = {}) {
|
|
9849
|
+
assign(objects, { remove = true, reset = false, reparent = false, silent = false, } = {}) {
|
|
9562
9850
|
const Model = this._model;
|
|
9851
|
+
const offset = remove ? 0 : this.length;
|
|
9563
9852
|
let toAdd = [];
|
|
9564
9853
|
let toChange = [];
|
|
9565
9854
|
let toRemove = [];
|
|
@@ -9567,6 +9856,7 @@ class ODataCollection {
|
|
|
9567
9856
|
let modelMap = [];
|
|
9568
9857
|
objects.forEach((obj, index) => {
|
|
9569
9858
|
const isModel = ODataModelOptions.isModel(obj);
|
|
9859
|
+
const position = index + offset;
|
|
9570
9860
|
const key = Model !== null && Model.meta ? Model.meta.resolveKey(obj) : undefined;
|
|
9571
9861
|
const cid = Model.meta.cid in obj ? obj[Model.meta.cid] : undefined;
|
|
9572
9862
|
// Try find entry
|
|
@@ -9592,38 +9882,37 @@ class ODataCollection {
|
|
|
9592
9882
|
}
|
|
9593
9883
|
// Model Change?
|
|
9594
9884
|
if (model.hasChanged())
|
|
9595
|
-
toChange.push(model);
|
|
9885
|
+
toChange.push([model, position]);
|
|
9596
9886
|
}
|
|
9597
9887
|
// Has Sort or Index Change?
|
|
9598
|
-
if (toSort.length > 0 ||
|
|
9599
|
-
toSort.push([model,
|
|
9888
|
+
if (toSort.length > 0 || position !== this.models().indexOf(model)) {
|
|
9889
|
+
toSort.push([model, position]);
|
|
9600
9890
|
}
|
|
9601
9891
|
}
|
|
9602
9892
|
else {
|
|
9603
9893
|
// Add
|
|
9604
9894
|
model = isModel
|
|
9605
9895
|
? obj
|
|
9606
|
-
: this.modelFactory(obj
|
|
9607
|
-
|
|
9608
|
-
});
|
|
9609
|
-
toAdd.push([model, index]);
|
|
9896
|
+
: this.modelFactory(obj);
|
|
9897
|
+
toAdd.push([model, position]);
|
|
9610
9898
|
}
|
|
9611
9899
|
modelMap.push(model[Model.meta.cid]);
|
|
9612
9900
|
});
|
|
9613
|
-
|
|
9614
|
-
.
|
|
9615
|
-
|
|
9616
|
-
|
|
9617
|
-
|
|
9618
|
-
|
|
9619
|
-
|
|
9901
|
+
if (remove) {
|
|
9902
|
+
this._entries.forEach((entry, position) => {
|
|
9903
|
+
if (modelMap.indexOf(entry.model[Model.meta.cid]) === -1)
|
|
9904
|
+
toRemove.push([entry.model, position]);
|
|
9905
|
+
});
|
|
9906
|
+
}
|
|
9907
|
+
// Apply remove, add and sort
|
|
9908
|
+
toRemove.forEach(([model, position]) => {
|
|
9909
|
+
this._removeModel(model, { silent, reset });
|
|
9620
9910
|
});
|
|
9621
|
-
toAdd.forEach((
|
|
9622
|
-
this._addModel(
|
|
9911
|
+
toAdd.forEach(([model, position]) => {
|
|
9912
|
+
this._addModel(model, { silent, reset, reparent, position });
|
|
9623
9913
|
});
|
|
9624
|
-
toSort.forEach((
|
|
9625
|
-
this.
|
|
9626
|
-
this._addModel(m[0], { silent: true, reset, position: m[1], reparent });
|
|
9914
|
+
toSort.forEach(([model, position]) => {
|
|
9915
|
+
this._moveModel(model, position);
|
|
9627
9916
|
});
|
|
9628
9917
|
if ((!silent &&
|
|
9629
9918
|
(toAdd.length > 0 ||
|
|
@@ -9643,9 +9932,9 @@ class ODataCollection {
|
|
|
9643
9932
|
}));
|
|
9644
9933
|
}
|
|
9645
9934
|
}
|
|
9646
|
-
query(
|
|
9935
|
+
query(ctx) {
|
|
9647
9936
|
const resource = this.resource();
|
|
9648
|
-
resource.query(
|
|
9937
|
+
resource.query(ctx);
|
|
9649
9938
|
this.attach(resource);
|
|
9650
9939
|
return this;
|
|
9651
9940
|
}
|
|
@@ -9877,7 +10166,7 @@ class ODataModel {
|
|
|
9877
10166
|
// Client Id
|
|
9878
10167
|
this[this._meta.cid] =
|
|
9879
10168
|
data[this._meta.cid] ||
|
|
9880
|
-
Strings.uniqueId(`${Klass.meta.schema.name.toLowerCase()}-`);
|
|
10169
|
+
Strings.uniqueId({ prefix: `${Klass.meta.schema.name.toLowerCase()}-` });
|
|
9881
10170
|
let attrs = this.annots().attributes(data, 'full');
|
|
9882
10171
|
let defaults = this.defaults();
|
|
9883
10172
|
this.assign(Objects.merge(defaults, attrs), {
|
|
@@ -9960,6 +10249,9 @@ class ODataModel {
|
|
|
9960
10249
|
key({ field_mapping = false, resolve = true, } = {}) {
|
|
9961
10250
|
return this._meta.resolveKey(this, { field_mapping, resolve });
|
|
9962
10251
|
}
|
|
10252
|
+
isOpenModel() {
|
|
10253
|
+
return this._meta.isOpenType();
|
|
10254
|
+
}
|
|
9963
10255
|
isParentOf(child) {
|
|
9964
10256
|
return (child !== this &&
|
|
9965
10257
|
ODataModelOptions.chain(child).some((p) => p[0] === this));
|
|
@@ -10017,29 +10309,40 @@ class ODataModel {
|
|
|
10017
10309
|
field_mapping,
|
|
10018
10310
|
});
|
|
10019
10311
|
}
|
|
10020
|
-
set(path, value) {
|
|
10312
|
+
set(path, value, { type } = {}) {
|
|
10021
10313
|
const pathArray = (Types.isArray(path) ? path : path.match(/([^[.\]])+/g));
|
|
10022
10314
|
if (pathArray.length === 0)
|
|
10023
10315
|
return undefined;
|
|
10024
10316
|
if (pathArray.length > 1) {
|
|
10025
10317
|
const model = this[pathArray[0]];
|
|
10026
|
-
return model.set(pathArray.slice(1), value);
|
|
10318
|
+
return model.set(pathArray.slice(1), value, {});
|
|
10027
10319
|
}
|
|
10028
10320
|
if (pathArray.length === 1) {
|
|
10029
|
-
return (this
|
|
10321
|
+
return this._meta.set(this, pathArray[0], value, { type });
|
|
10030
10322
|
}
|
|
10031
10323
|
}
|
|
10032
10324
|
get(path) {
|
|
10033
10325
|
const pathArray = (Types.isArray(path) ? path : path.match(/([^[.\]])+/g));
|
|
10034
10326
|
if (pathArray.length === 0)
|
|
10035
10327
|
return undefined;
|
|
10036
|
-
const value = this
|
|
10328
|
+
const value = this._meta.get(this, pathArray[0]);
|
|
10037
10329
|
if (pathArray.length > 1 &&
|
|
10038
10330
|
(value instanceof ODataModel || value instanceof ODataCollection)) {
|
|
10039
10331
|
return value.get(pathArray.slice(1));
|
|
10040
10332
|
}
|
|
10041
10333
|
return value;
|
|
10042
10334
|
}
|
|
10335
|
+
has(path) {
|
|
10336
|
+
const pathArray = (Types.isArray(path) ? path : path.match(/([^[.\]])+/g));
|
|
10337
|
+
if (pathArray.length === 0)
|
|
10338
|
+
return false;
|
|
10339
|
+
const value = this._meta.get(this, pathArray[0]);
|
|
10340
|
+
if (pathArray.length > 1 &&
|
|
10341
|
+
(value instanceof ODataModel || value instanceof ODataCollection)) {
|
|
10342
|
+
return value.has(pathArray.slice(1));
|
|
10343
|
+
}
|
|
10344
|
+
return value !== undefined;
|
|
10345
|
+
}
|
|
10043
10346
|
reset({ path, silent = false, } = {}) {
|
|
10044
10347
|
const pathArray = (path === undefined
|
|
10045
10348
|
? []
|
|
@@ -10162,10 +10465,10 @@ class ODataModel {
|
|
|
10162
10465
|
}
|
|
10163
10466
|
/**
|
|
10164
10467
|
* Create an execution context for change the internal query of a resource
|
|
10165
|
-
* @param
|
|
10468
|
+
* @param ctx Function to execute
|
|
10166
10469
|
*/
|
|
10167
|
-
query(
|
|
10168
|
-
return this._meta.query(this, this.resource(),
|
|
10470
|
+
query(ctx) {
|
|
10471
|
+
return this._meta.query(this, this.resource(), ctx);
|
|
10169
10472
|
}
|
|
10170
10473
|
/**
|
|
10171
10474
|
* Perform a check on the internal state of the model and return true if the model is changed.
|
|
@@ -10178,6 +10481,9 @@ class ODataModel {
|
|
|
10178
10481
|
isNew() {
|
|
10179
10482
|
return !this._meta.hasKey(this);
|
|
10180
10483
|
}
|
|
10484
|
+
withResource(resource, ctx) {
|
|
10485
|
+
return this._meta.withResource(this, resource, ctx);
|
|
10486
|
+
}
|
|
10181
10487
|
/**
|
|
10182
10488
|
* Create an execution context for a given function, where the model is bound to its entity endpoint
|
|
10183
10489
|
* @param ctx Context function
|
|
@@ -10199,6 +10505,10 @@ class ODataModel {
|
|
|
10199
10505
|
return func.callModel(params, options);
|
|
10200
10506
|
case 'collection':
|
|
10201
10507
|
return func.callCollection(params, options);
|
|
10508
|
+
case 'blob':
|
|
10509
|
+
return func.callBlob(params, options);
|
|
10510
|
+
case 'arraybuffer':
|
|
10511
|
+
return func.callArraybuffer(params, options);
|
|
10202
10512
|
default:
|
|
10203
10513
|
return func.call(params, Object.assign({ responseType }, options));
|
|
10204
10514
|
}
|
|
@@ -10216,12 +10526,17 @@ class ODataModel {
|
|
|
10216
10526
|
return action.callModel(params, options);
|
|
10217
10527
|
case 'collection':
|
|
10218
10528
|
return action.callCollection(params, options);
|
|
10529
|
+
case 'blob':
|
|
10530
|
+
return action.callBlob(params, options);
|
|
10531
|
+
case 'arraybuffer':
|
|
10532
|
+
return action.callArraybuffer(params, options);
|
|
10219
10533
|
default:
|
|
10220
10534
|
return action.call(params, Object.assign({ responseType }, options));
|
|
10221
10535
|
}
|
|
10222
10536
|
}
|
|
10223
10537
|
// Cast
|
|
10224
10538
|
cast(type) {
|
|
10539
|
+
//: ODataModel<S> {
|
|
10225
10540
|
const resource = this.resource();
|
|
10226
10541
|
if (!(resource instanceof ODataEntityResource))
|
|
10227
10542
|
throw new Error(`cast: Can't cast to derived model without ODataEntityResource`);
|
|
@@ -10343,6 +10658,7 @@ const RESERVED_FIELD_NAMES = Object.getOwnPropertyNames(ODataModel.prototype);
|
|
|
10343
10658
|
|
|
10344
10659
|
class ODataApiOptions {
|
|
10345
10660
|
constructor(config) {
|
|
10661
|
+
var _a, _b, _c;
|
|
10346
10662
|
this.etag = { ifMatch: true, ifNoneMatch: false };
|
|
10347
10663
|
this.version = config.version || DEFAULT_VERSION;
|
|
10348
10664
|
this.stringAsEnum = config.stringAsEnum || false;
|
|
@@ -10355,9 +10671,10 @@ class ODataApiOptions {
|
|
|
10355
10671
|
this.accept = config.accept;
|
|
10356
10672
|
Object.assign(this.etag, config.etag || {});
|
|
10357
10673
|
this.prefer = config.prefer;
|
|
10358
|
-
this.deleteRefBy = config.deleteRefBy
|
|
10674
|
+
this.deleteRefBy = (_a = config.deleteRefBy) !== null && _a !== void 0 ? _a : 'path';
|
|
10359
10675
|
this.nonParenthesisForEmptyParameterFunction =
|
|
10360
|
-
config.nonParenthesisForEmptyParameterFunction
|
|
10676
|
+
(_b = config.nonParenthesisForEmptyParameterFunction) !== null && _b !== void 0 ? _b : false;
|
|
10677
|
+
this.jsonBatchFormat = (_c = config.jsonBatchFormat) !== null && _c !== void 0 ? _c : false;
|
|
10361
10678
|
}
|
|
10362
10679
|
get parserOptions() {
|
|
10363
10680
|
return Object.assign({ version: this.version, stringAsEnum: this.stringAsEnum, deleteRefBy: this.deleteRefBy, nonParenthesisForEmptyParameterFunction: this.nonParenthesisForEmptyParameterFunction }, this.accept);
|
|
@@ -10421,20 +10738,20 @@ class ODataApi {
|
|
|
10421
10738
|
const segments = new ODataPathSegments(json.segments);
|
|
10422
10739
|
const query = new ODataQueryOptions(json.options);
|
|
10423
10740
|
switch ((_a = segments.last()) === null || _a === void 0 ? void 0 : _a.name) {
|
|
10424
|
-
case
|
|
10741
|
+
case PathSegment.entitySet:
|
|
10425
10742
|
if ((_b = segments.last()) === null || _b === void 0 ? void 0 : _b.hasKey()) {
|
|
10426
10743
|
return new ODataEntityResource(this, { segments, query });
|
|
10427
10744
|
}
|
|
10428
10745
|
else {
|
|
10429
10746
|
return new ODataEntitySetResource(this, { segments, query });
|
|
10430
10747
|
}
|
|
10431
|
-
case
|
|
10748
|
+
case PathSegment.navigationProperty:
|
|
10432
10749
|
return new ODataNavigationPropertyResource(this, { segments, query });
|
|
10433
|
-
case
|
|
10750
|
+
case PathSegment.singleton:
|
|
10434
10751
|
return new ODataSingletonResource(this, { segments, query });
|
|
10435
|
-
case
|
|
10752
|
+
case PathSegment.action:
|
|
10436
10753
|
return new ODataActionResource(this, { segments, query });
|
|
10437
|
-
case
|
|
10754
|
+
case PathSegment.function:
|
|
10438
10755
|
return new ODataFunctionResource(this, { segments, query });
|
|
10439
10756
|
}
|
|
10440
10757
|
throw new Error('No Resource for json');
|
|
@@ -10747,7 +11064,7 @@ class ODataApi {
|
|
|
10747
11064
|
}
|
|
10748
11065
|
|
|
10749
11066
|
class ODataSettings {
|
|
10750
|
-
constructor(
|
|
11067
|
+
constructor(configs) {
|
|
10751
11068
|
this.apis = configs.map((config) => new ODataApi(config));
|
|
10752
11069
|
if (this.apis.length > 1) {
|
|
10753
11070
|
if (this.apis.some((c) => c.name === undefined))
|
|
@@ -10949,6 +11266,37 @@ class ODataSettings {
|
|
|
10949
11266
|
}
|
|
10950
11267
|
}
|
|
10951
11268
|
|
|
11269
|
+
class ODataConfigLoader {
|
|
11270
|
+
}
|
|
11271
|
+
class ODataConfigSyncLoader {
|
|
11272
|
+
constructor(passedConfigs) {
|
|
11273
|
+
this.passedConfigs = passedConfigs;
|
|
11274
|
+
}
|
|
11275
|
+
loadConfigs() {
|
|
11276
|
+
if (Array.isArray(this.passedConfigs)) {
|
|
11277
|
+
return of(this.passedConfigs);
|
|
11278
|
+
}
|
|
11279
|
+
return of([this.passedConfigs]);
|
|
11280
|
+
}
|
|
11281
|
+
}
|
|
11282
|
+
class ODataConfigAsyncLoader {
|
|
11283
|
+
constructor(configs$) {
|
|
11284
|
+
this.configs$ = configs$;
|
|
11285
|
+
}
|
|
11286
|
+
loadConfigs() {
|
|
11287
|
+
if (Array.isArray(this.configs$)) {
|
|
11288
|
+
return forkJoin(this.configs$);
|
|
11289
|
+
}
|
|
11290
|
+
const singleConfigOrArray = this.configs$;
|
|
11291
|
+
return singleConfigOrArray.pipe(map((value) => {
|
|
11292
|
+
if (Array.isArray(value)) {
|
|
11293
|
+
return value;
|
|
11294
|
+
}
|
|
11295
|
+
return [value];
|
|
11296
|
+
}));
|
|
11297
|
+
}
|
|
11298
|
+
}
|
|
11299
|
+
|
|
10952
11300
|
function addBody(options, body) {
|
|
10953
11301
|
return {
|
|
10954
11302
|
body,
|
|
@@ -10963,21 +11311,23 @@ function addBody(options, body) {
|
|
|
10963
11311
|
};
|
|
10964
11312
|
}
|
|
10965
11313
|
class ODataClient {
|
|
10966
|
-
constructor(http,
|
|
11314
|
+
constructor(http, loader) {
|
|
10967
11315
|
this.http = http;
|
|
10968
|
-
this.
|
|
10969
|
-
this.
|
|
10970
|
-
|
|
10971
|
-
|
|
10972
|
-
|
|
10973
|
-
|
|
10974
|
-
|
|
10975
|
-
|
|
10976
|
-
|
|
10977
|
-
|
|
10978
|
-
|
|
10979
|
-
|
|
10980
|
-
|
|
11316
|
+
this.loader = loader;
|
|
11317
|
+
this.loader.loadConfigs().subscribe((config) => {
|
|
11318
|
+
this.settings = new ODataSettings(config);
|
|
11319
|
+
this.settings.configure({
|
|
11320
|
+
requester: (req) => this.http.request(req.method, `${req.url}`, {
|
|
11321
|
+
body: req.body,
|
|
11322
|
+
context: req.context,
|
|
11323
|
+
headers: req.headers,
|
|
11324
|
+
observe: req.observe,
|
|
11325
|
+
params: req.params,
|
|
11326
|
+
reportProgress: req.reportProgress,
|
|
11327
|
+
responseType: req.responseType,
|
|
11328
|
+
withCredentials: req.withCredentials,
|
|
11329
|
+
}),
|
|
11330
|
+
});
|
|
10981
11331
|
});
|
|
10982
11332
|
}
|
|
10983
11333
|
//#region Resolve Building Blocks
|
|
@@ -10997,6 +11347,9 @@ class ODataClient {
|
|
|
10997
11347
|
this.settings.findApiForType(value);
|
|
10998
11348
|
return api || this.settings.defaultApi();
|
|
10999
11349
|
}
|
|
11350
|
+
defaultApi() {
|
|
11351
|
+
return this.settings.defaultApi();
|
|
11352
|
+
}
|
|
11000
11353
|
/**
|
|
11001
11354
|
* Resolve the parser for the given string type.
|
|
11002
11355
|
* @param type The string type of the parser.
|
|
@@ -11059,7 +11412,8 @@ class ODataClient {
|
|
|
11059
11412
|
* @returns The service for the given type.
|
|
11060
11413
|
*/
|
|
11061
11414
|
serviceForType(type) {
|
|
11062
|
-
return this.injector.get(this.settings
|
|
11415
|
+
//return this.injector.get(this.settings!.serviceForType(type));
|
|
11416
|
+
return undefined;
|
|
11063
11417
|
}
|
|
11064
11418
|
/**
|
|
11065
11419
|
* Resolve the service for the given string entity type.
|
|
@@ -11067,7 +11421,8 @@ class ODataClient {
|
|
|
11067
11421
|
* @returns The service for the given entity type.
|
|
11068
11422
|
*/
|
|
11069
11423
|
serviceForEntityType(type) {
|
|
11070
|
-
return this.injector.get(this.settings
|
|
11424
|
+
//return this.injector.get(this.settings!.serviceForEntityType(type));
|
|
11425
|
+
return undefined;
|
|
11071
11426
|
}
|
|
11072
11427
|
enumTypeByName(name) {
|
|
11073
11428
|
return this.settings.enumTypeByName(name);
|
|
@@ -11088,7 +11443,8 @@ class ODataClient {
|
|
|
11088
11443
|
return this.settings.collectionByName(name);
|
|
11089
11444
|
}
|
|
11090
11445
|
serviceByName(name) {
|
|
11091
|
-
return this.injector.get(this.settings
|
|
11446
|
+
//return this.injector.get(this.settings!.serviceByName(name));
|
|
11447
|
+
return undefined;
|
|
11092
11448
|
}
|
|
11093
11449
|
fromJSON(json, apiNameOrType) {
|
|
11094
11450
|
return this.apiFor(apiNameOrType).fromJSON(json);
|
|
@@ -11180,16 +11536,11 @@ class ODataClient {
|
|
|
11180
11536
|
return this.request('PUT', resource, addBody(options, body));
|
|
11181
11537
|
}
|
|
11182
11538
|
}
|
|
11183
|
-
ODataClient.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
11184
|
-
ODataClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.
|
|
11185
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.
|
|
11186
|
-
type: Injectable
|
|
11187
|
-
|
|
11188
|
-
providedIn: 'root',
|
|
11189
|
-
}]
|
|
11190
|
-
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: ODataSettings }, { type: i0.Injector }]; } });
|
|
11191
|
-
|
|
11192
|
-
const ODATA_CONFIGURATIONS = new InjectionToken('odata.configuraions');
|
|
11539
|
+
ODataClient.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.6", ngImport: i0, type: ODataClient, deps: [{ token: i1.HttpClient }, { token: ODataConfigLoader }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
11540
|
+
ODataClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.6", ngImport: i0, type: ODataClient });
|
|
11541
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.6", ngImport: i0, type: ODataClient, decorators: [{
|
|
11542
|
+
type: Injectable
|
|
11543
|
+
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: ODataConfigLoader }]; } });
|
|
11193
11544
|
|
|
11194
11545
|
class ODataBaseService {
|
|
11195
11546
|
constructor(client, name, apiNameOrEntityType) {
|
|
@@ -11436,25 +11787,29 @@ class ODataServiceFactory {
|
|
|
11436
11787
|
})(this.client, singletonName, apiNameOrEntityType);
|
|
11437
11788
|
}
|
|
11438
11789
|
}
|
|
11439
|
-
ODataServiceFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
11440
|
-
ODataServiceFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.
|
|
11441
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.
|
|
11790
|
+
ODataServiceFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.6", ngImport: i0, type: ODataServiceFactory, deps: [{ token: ODataClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
11791
|
+
ODataServiceFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.6", ngImport: i0, type: ODataServiceFactory });
|
|
11792
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.6", ngImport: i0, type: ODataServiceFactory, decorators: [{
|
|
11442
11793
|
type: Injectable
|
|
11443
11794
|
}], ctorParameters: function () { return [{ type: ODataClient }]; } });
|
|
11444
11795
|
|
|
11445
|
-
|
|
11446
|
-
|
|
11796
|
+
const ODATA_CONFIG = new InjectionToken('odata.config');
|
|
11797
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
11798
|
+
function createSyncLoader(passedConfig) {
|
|
11799
|
+
return new ODataConfigSyncLoader(passedConfig.config);
|
|
11447
11800
|
}
|
|
11448
11801
|
class ODataModule {
|
|
11449
|
-
static forRoot(
|
|
11802
|
+
static forRoot(passedConfig) {
|
|
11450
11803
|
return {
|
|
11451
11804
|
ngModule: ODataModule,
|
|
11452
11805
|
providers: [
|
|
11453
|
-
|
|
11454
|
-
{
|
|
11455
|
-
|
|
11456
|
-
|
|
11457
|
-
|
|
11806
|
+
// Make the ODATA_CONFIG available through injection
|
|
11807
|
+
{ provide: ODATA_CONFIG, useValue: passedConfig },
|
|
11808
|
+
// Create the loader: Either the one getting passed or a sync one
|
|
11809
|
+
(passedConfig === null || passedConfig === void 0 ? void 0 : passedConfig.loader) || {
|
|
11810
|
+
provide: ODataConfigLoader,
|
|
11811
|
+
useFactory: createSyncLoader,
|
|
11812
|
+
deps: [ODATA_CONFIG],
|
|
11458
11813
|
},
|
|
11459
11814
|
ODataClient,
|
|
11460
11815
|
ODataServiceFactory,
|
|
@@ -11462,13 +11817,13 @@ class ODataModule {
|
|
|
11462
11817
|
};
|
|
11463
11818
|
}
|
|
11464
11819
|
}
|
|
11465
|
-
ODataModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
11466
|
-
ODataModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.
|
|
11467
|
-
ODataModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.
|
|
11468
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.
|
|
11820
|
+
ODataModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.6", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
11821
|
+
ODataModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.6", ngImport: i0, type: ODataModule, imports: [CommonModule, HttpClientModule] });
|
|
11822
|
+
ODataModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.6", ngImport: i0, type: ODataModule, providers: [ODataClient, ODataServiceFactory], imports: [CommonModule, HttpClientModule] });
|
|
11823
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.6", ngImport: i0, type: ODataModule, decorators: [{
|
|
11469
11824
|
type: NgModule,
|
|
11470
11825
|
args: [{
|
|
11471
|
-
imports: [HttpClientModule],
|
|
11826
|
+
imports: [CommonModule, HttpClientModule],
|
|
11472
11827
|
providers: [ODataClient, ODataServiceFactory],
|
|
11473
11828
|
}]
|
|
11474
11829
|
}] });
|
|
@@ -11481,6 +11836,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.1", ngImpor
|
|
|
11481
11836
|
* Generated bundle index. Do not edit.
|
|
11482
11837
|
*/
|
|
11483
11838
|
|
|
11484
|
-
export { BUBBLING, Dates, Durations, EDM_PARSERS, Enums, Http, INCLUDE_DEEP, INCLUDE_SHALLOW, ITEM_ROOT, Model, ModelField, NONE_PARSER,
|
|
11839
|
+
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, ODataModelEvent, 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 };
|
|
11485
11840
|
//# sourceMappingURL=angular-odata.mjs.map
|
|
11486
11841
|
//# sourceMappingURL=angular-odata.mjs.map
|