angular-odata 0.102.6 → 0.110.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/esm2020/lib/api.mjs +47 -7
- package/esm2020/lib/client.mjs +6 -31
- package/esm2020/lib/helper.mjs +14 -7
- package/esm2020/lib/models/collection.mjs +27 -27
- package/esm2020/lib/models/model.mjs +14 -8
- package/esm2020/lib/models/options.mjs +47 -26
- package/esm2020/lib/options.mjs +8 -2
- package/esm2020/lib/resources/query/expressions/compute.mjs +3 -9
- package/esm2020/lib/resources/query/expressions/expand.mjs +3 -9
- package/esm2020/lib/resources/query/expressions/filter.mjs +11 -14
- package/esm2020/lib/resources/query/expressions/orderby.mjs +3 -9
- package/esm2020/lib/resources/query/expressions/search.mjs +2 -5
- package/esm2020/lib/resources/query/expressions/select.mjs +3 -9
- package/esm2020/lib/resources/query/expressions/syntax.mjs +12 -7
- package/esm2020/lib/resources/query/options.mjs +9 -3
- package/esm2020/lib/resources/request.mjs +30 -2
- package/esm2020/lib/resources/resource.mjs +13 -59
- package/esm2020/lib/resources/responses/annotations.mjs +21 -3
- package/esm2020/lib/resources/responses/response.mjs +1 -1
- package/esm2020/lib/resources/responses/types.mjs +1 -1
- package/esm2020/lib/resources/types/batch.mjs +6 -9
- package/esm2020/lib/resources/types/count.mjs +1 -1
- package/esm2020/lib/resources/types/entity-set.mjs +32 -10
- package/esm2020/lib/resources/types/entity.mjs +1 -1
- package/esm2020/lib/resources/types/media.mjs +1 -1
- package/esm2020/lib/resources/types/metadata.mjs +3 -5
- package/esm2020/lib/resources/types/navigation-property.mjs +24 -6
- package/esm2020/lib/resources/types/options.mjs +1 -1
- package/esm2020/lib/resources/types/property.mjs +24 -4
- package/esm2020/lib/resources/types/reference.mjs +1 -1
- package/esm2020/lib/resources/types/singleton.mjs +1 -4
- package/esm2020/lib/resources/types/value.mjs +2 -2
- package/esm2020/lib/schema/callable.mjs +4 -4
- package/esm2020/lib/schema/enum-type.mjs +9 -6
- package/esm2020/lib/schema/parsers/callable.mjs +9 -11
- package/esm2020/lib/schema/parsers/edm.mjs +18 -10
- package/esm2020/lib/schema/parsers/enum-type.mjs +21 -23
- package/esm2020/lib/schema/parsers/structured-type.mjs +10 -10
- package/esm2020/lib/schema/schema.mjs +5 -5
- package/esm2020/lib/schema/structured-type.mjs +6 -4
- package/esm2020/lib/services/entity-set.mjs +7 -7
- package/esm2020/lib/types.mjs +1 -1
- package/esm2020/lib/utils/enums.mjs +1 -1
- package/esm2020/lib/utils/http.mjs +1 -1
- package/esm2020/lib/utils/objects.mjs +1 -1
- package/fesm2015/angular-odata.mjs +418 -350
- package/fesm2015/angular-odata.mjs.map +1 -1
- package/fesm2020/angular-odata.mjs +408 -308
- package/fesm2020/angular-odata.mjs.map +1 -1
- package/lib/api.d.ts +10 -3
- package/lib/client.d.ts +139 -1425
- package/lib/helper.d.ts +4 -1
- package/lib/models/collection.d.ts +13 -6
- package/lib/models/model.d.ts +7 -9
- package/lib/models/options.d.ts +15 -9
- package/lib/options.d.ts +8 -2
- package/lib/resources/query/expressions/compute.d.ts +1 -3
- package/lib/resources/query/expressions/expand.d.ts +1 -3
- package/lib/resources/query/expressions/filter.d.ts +2 -4
- package/lib/resources/query/expressions/orderby.d.ts +1 -3
- package/lib/resources/query/expressions/search.d.ts +0 -1
- package/lib/resources/query/expressions/select.d.ts +1 -3
- package/lib/resources/query/handlers.d.ts +3 -1
- package/lib/resources/request.d.ts +13 -2
- package/lib/resources/resource.d.ts +2 -9
- package/lib/resources/responses/annotations.d.ts +20 -12
- package/lib/resources/responses/types.d.ts +3 -3
- package/lib/resources/types/count.d.ts +1 -1
- package/lib/resources/types/entity-set.d.ts +23 -6
- package/lib/resources/types/entity.d.ts +8 -24
- package/lib/resources/types/media.d.ts +7 -15
- package/lib/resources/types/metadata.d.ts +1 -1
- package/lib/resources/types/navigation-property.d.ts +26 -28
- package/lib/resources/types/options.d.ts +4 -2
- package/lib/resources/types/property.d.ts +28 -15
- package/lib/resources/types/reference.d.ts +3 -12
- package/lib/resources/types/singleton.d.ts +8 -27
- package/lib/schema/callable.d.ts +3 -1
- package/lib/schema/enum-type.d.ts +8 -2
- package/lib/schema/parsers/callable.d.ts +6 -6
- package/lib/schema/parsers/enum-type.d.ts +5 -10
- package/lib/schema/parsers/structured-type.d.ts +7 -5
- package/lib/schema/schema.d.ts +3 -2
- package/lib/schema/structured-type.d.ts +4 -3
- package/lib/services/entity-set.d.ts +15 -6
- package/lib/types.d.ts +4 -1
- package/lib/utils/http.d.ts +1 -1
- package/lib/utils/objects.d.ts +19 -5
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i1 from '@angular/common/http';
|
|
2
2
|
import { HttpHeaders, HttpParams, HttpResponse, HttpErrorResponse, HttpEventType, HttpClientModule } from '@angular/common/http';
|
|
3
3
|
import { of, throwError, Subject, map as map$1, firstValueFrom, EMPTY, Observable, forkJoin, NEVER } from 'rxjs';
|
|
4
|
-
import { tap, startWith, map, expand,
|
|
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';
|
|
@@ -1885,12 +1885,17 @@ class Lambda {
|
|
|
1885
1885
|
render({ aliases, escape, prefix, }) {
|
|
1886
1886
|
let [left, right] = this.values;
|
|
1887
1887
|
left = render(left, { aliases, escape, prefix });
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1888
|
+
if (right) {
|
|
1889
|
+
let alias = this.alias || left.split('/').pop().toLowerCase()[0];
|
|
1890
|
+
return `${left}/${this.op}(${alias}:${render(right, {
|
|
1891
|
+
aliases,
|
|
1892
|
+
escape,
|
|
1893
|
+
prefix: alias,
|
|
1894
|
+
})})`;
|
|
1895
|
+
}
|
|
1896
|
+
else {
|
|
1897
|
+
return `${left}/${this.op}()`;
|
|
1898
|
+
}
|
|
1894
1899
|
}
|
|
1895
1900
|
clone() {
|
|
1896
1901
|
return new Lambda(this.op, this.values.map((v) => Objects.clone(v)), this.alias);
|
|
@@ -1935,16 +1940,10 @@ class ComputeExpression extends Expression {
|
|
|
1935
1940
|
super({ children });
|
|
1936
1941
|
this.names = names || [];
|
|
1937
1942
|
}
|
|
1938
|
-
static expression() {
|
|
1939
|
-
return new ComputeExpression();
|
|
1940
|
-
}
|
|
1941
|
-
static type() {
|
|
1942
|
-
return Field$1.factory();
|
|
1943
|
-
}
|
|
1944
1943
|
static compute(opts, current) {
|
|
1945
1944
|
return opts({
|
|
1946
|
-
t:
|
|
1947
|
-
e: ComputeExpression
|
|
1945
|
+
t: Field$1.factory(),
|
|
1946
|
+
e: () => new ComputeExpression(),
|
|
1948
1947
|
}, current);
|
|
1949
1948
|
}
|
|
1950
1949
|
render({ aliases, escape, prefix, } = {}) {
|
|
@@ -1979,16 +1978,10 @@ class FilterExpression extends Expression {
|
|
|
1979
1978
|
this._connector = connector || 'and';
|
|
1980
1979
|
this._negated = negated || false;
|
|
1981
1980
|
}
|
|
1982
|
-
static type() {
|
|
1983
|
-
return Field$1.factory();
|
|
1984
|
-
}
|
|
1985
|
-
static expression(connector = 'and') {
|
|
1986
|
-
return new FilterExpression({ connector });
|
|
1987
|
-
}
|
|
1988
1981
|
static filter(opts, current) {
|
|
1989
1982
|
return opts({
|
|
1990
|
-
t:
|
|
1991
|
-
e: FilterExpression
|
|
1983
|
+
t: Field$1.factory(),
|
|
1984
|
+
e: (connector = 'and') => new FilterExpression({ connector }),
|
|
1992
1985
|
o: operators,
|
|
1993
1986
|
f: functions,
|
|
1994
1987
|
}, current);
|
|
@@ -2113,16 +2106,19 @@ class FilterExpression extends Expression {
|
|
|
2113
2106
|
return this._add(functions.endsWith(left, right, normalize));
|
|
2114
2107
|
}
|
|
2115
2108
|
any(left, opts, alias) {
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2109
|
+
let exp = undefined;
|
|
2110
|
+
if (opts !== undefined) {
|
|
2111
|
+
exp = opts({
|
|
2112
|
+
t: Field$1.factory(),
|
|
2113
|
+
e: (connector = 'and') => new FilterExpression({ connector }),
|
|
2114
|
+
});
|
|
2115
|
+
}
|
|
2120
2116
|
return this._add(syntax.any(left, exp, alias));
|
|
2121
2117
|
}
|
|
2122
2118
|
all(left, opts, alias) {
|
|
2123
2119
|
const exp = opts({
|
|
2124
2120
|
t: Field$1.factory(),
|
|
2125
|
-
e: FilterExpression
|
|
2121
|
+
e: (connector = 'and') => new FilterExpression({ connector }),
|
|
2126
2122
|
});
|
|
2127
2123
|
return this._add(syntax.all(left, exp, alias));
|
|
2128
2124
|
}
|
|
@@ -2156,16 +2152,10 @@ class OrderByExpression extends Expression {
|
|
|
2156
2152
|
constructor({ children, } = {}) {
|
|
2157
2153
|
super({ children });
|
|
2158
2154
|
}
|
|
2159
|
-
static expression() {
|
|
2160
|
-
return new OrderByExpression();
|
|
2161
|
-
}
|
|
2162
|
-
static type() {
|
|
2163
|
-
return Field$1.factory();
|
|
2164
|
-
}
|
|
2165
2155
|
static orderBy(opts, current) {
|
|
2166
2156
|
return opts({
|
|
2167
|
-
t:
|
|
2168
|
-
e: OrderByExpression
|
|
2157
|
+
t: Field$1.factory(),
|
|
2158
|
+
e: () => new OrderByExpression(),
|
|
2169
2159
|
}, current);
|
|
2170
2160
|
}
|
|
2171
2161
|
_add(node) {
|
|
@@ -2217,12 +2207,9 @@ class SearchExpression extends Expression {
|
|
|
2217
2207
|
this._connector = connector || 'AND';
|
|
2218
2208
|
this._negated = negated || false;
|
|
2219
2209
|
}
|
|
2220
|
-
static expression(connector = 'AND') {
|
|
2221
|
-
return new SearchExpression({ connector });
|
|
2222
|
-
}
|
|
2223
2210
|
static search(opts, current) {
|
|
2224
2211
|
return opts({
|
|
2225
|
-
e: SearchExpression
|
|
2212
|
+
e: (connector = 'AND') => new SearchExpression({ connector }),
|
|
2226
2213
|
}, current);
|
|
2227
2214
|
}
|
|
2228
2215
|
_add(node, connector) {
|
|
@@ -2317,16 +2304,10 @@ class SelectExpression extends Expression {
|
|
|
2317
2304
|
constructor({ children, } = {}) {
|
|
2318
2305
|
super({ children });
|
|
2319
2306
|
}
|
|
2320
|
-
static expression() {
|
|
2321
|
-
return new SelectExpression();
|
|
2322
|
-
}
|
|
2323
|
-
static type() {
|
|
2324
|
-
return Field$1.factory();
|
|
2325
|
-
}
|
|
2326
2307
|
static select(opts, current) {
|
|
2327
2308
|
return opts({
|
|
2328
|
-
t:
|
|
2329
|
-
e: SelectExpression
|
|
2309
|
+
t: Field$1.factory(),
|
|
2310
|
+
e: () => new SelectExpression(),
|
|
2330
2311
|
}, current);
|
|
2331
2312
|
}
|
|
2332
2313
|
render({ aliases, escape, prefix, } = {}) {
|
|
@@ -2427,16 +2408,10 @@ class ExpandExpression extends Expression {
|
|
|
2427
2408
|
constructor({ children, } = {}) {
|
|
2428
2409
|
super({ children });
|
|
2429
2410
|
}
|
|
2430
|
-
static expression() {
|
|
2431
|
-
return new ExpandExpression();
|
|
2432
|
-
}
|
|
2433
|
-
static type() {
|
|
2434
|
-
return Field$1.factory();
|
|
2435
|
-
}
|
|
2436
2411
|
static expand(opts, current) {
|
|
2437
2412
|
return opts({
|
|
2438
|
-
t:
|
|
2439
|
-
e: ExpandExpression
|
|
2413
|
+
t: Field$1.factory(),
|
|
2414
|
+
e: () => new ExpandExpression(),
|
|
2440
2415
|
}, current);
|
|
2441
2416
|
}
|
|
2442
2417
|
render({ aliases, escape, prefix, } = {}) {
|
|
@@ -2870,8 +2845,14 @@ class ODataQueryOptions {
|
|
|
2870
2845
|
.filter((key) => !Types.isEmpty(this.values.get(key)))
|
|
2871
2846
|
.reduce((acc, key) => {
|
|
2872
2847
|
let value = this.values.get(key);
|
|
2873
|
-
if (Types.rawType(value).endsWith('Expression')
|
|
2874
|
-
|
|
2848
|
+
if (Types.rawType(value).endsWith('Expression') ||
|
|
2849
|
+
(Types.isArray(value) &&
|
|
2850
|
+
value.some((v) => Types.rawType(v).endsWith('Expression')))) {
|
|
2851
|
+
value = Types.isArray(value)
|
|
2852
|
+
? value.map((v) => Types.rawType(v).endsWith('Expression')
|
|
2853
|
+
? v.render({ aliases })
|
|
2854
|
+
: v)
|
|
2855
|
+
: value.render({ aliases });
|
|
2875
2856
|
}
|
|
2876
2857
|
return Object.assign(acc, { [key]: value });
|
|
2877
2858
|
}, {});
|
|
@@ -3141,6 +3122,7 @@ class ODataRequest {
|
|
|
3141
3122
|
this.api = init.api;
|
|
3142
3123
|
this.reportProgress = init.reportProgress;
|
|
3143
3124
|
this.observe = init.observe;
|
|
3125
|
+
this.context = init.context;
|
|
3144
3126
|
// Response Type
|
|
3145
3127
|
this._responseType = init.responseType;
|
|
3146
3128
|
// The Body
|
|
@@ -3233,6 +3215,33 @@ class ODataRequest {
|
|
|
3233
3215
|
: params;
|
|
3234
3216
|
//#endregion
|
|
3235
3217
|
}
|
|
3218
|
+
static factory(api, method, resource, options) {
|
|
3219
|
+
const apiOptions = api.options;
|
|
3220
|
+
let params = options.params || {};
|
|
3221
|
+
if (options.withCount) {
|
|
3222
|
+
params = Http.mergeHttpParams(params, apiOptions.helper.countParam());
|
|
3223
|
+
}
|
|
3224
|
+
let etag = options.etag;
|
|
3225
|
+
if (etag === undefined && Types.isPlainObject(options.body)) {
|
|
3226
|
+
etag = apiOptions.helper.etag(options.body);
|
|
3227
|
+
}
|
|
3228
|
+
return new ODataRequest({
|
|
3229
|
+
method,
|
|
3230
|
+
etag,
|
|
3231
|
+
api,
|
|
3232
|
+
resource,
|
|
3233
|
+
params,
|
|
3234
|
+
context: options.context,
|
|
3235
|
+
body: options.body,
|
|
3236
|
+
observe: options.observe,
|
|
3237
|
+
headers: options.headers,
|
|
3238
|
+
reportProgress: options.reportProgress,
|
|
3239
|
+
responseType: options.responseType,
|
|
3240
|
+
fetchPolicy: options.fetchPolicy,
|
|
3241
|
+
withCredentials: options.withCredentials,
|
|
3242
|
+
bodyQueryOptions: options.bodyQueryOptions,
|
|
3243
|
+
});
|
|
3244
|
+
}
|
|
3236
3245
|
get responseType() {
|
|
3237
3246
|
return this._responseType &&
|
|
3238
3247
|
['property', 'entity', 'entities'].indexOf(this._responseType) !== -1
|
|
@@ -3421,42 +3430,38 @@ const ODataVersionBaseHelper = {
|
|
|
3421
3430
|
};
|
|
3422
3431
|
const ODataHelper = {
|
|
3423
3432
|
//#region Version 4.0
|
|
3424
|
-
[VERSION_4_0]: Object.assign({}, ODataVersionBaseHelper, {
|
|
3425
|
-
VALUE: 'value',
|
|
3426
|
-
ODATA_ANNOTATION_PREFIX: '@odata',
|
|
3427
|
-
ODATA_FUNCTION_PREFIX: '#',
|
|
3433
|
+
[VERSION_4_0]: Object.assign(Object.assign({}, ODataVersionBaseHelper), { VALUE: 'value', ODATA_ANNOTATION_PREFIX: '@odata', ODATA_FUNCTION_PREFIX: '#',
|
|
3428
3434
|
//odata.id: the ID of the entity
|
|
3429
|
-
ODATA_ID: '@odata.id',
|
|
3435
|
+
ODATA_ID: '@odata.id',
|
|
3430
3436
|
//odata.count: the total count of a collection of entities or collection of entity references, if requested.
|
|
3431
|
-
ODATA_COUNT: '@odata.count',
|
|
3437
|
+
ODATA_COUNT: '@odata.count',
|
|
3432
3438
|
//odata.context: the context URL for a collection, entity, primitive value, or service document.
|
|
3433
|
-
ODATA_CONTEXT: '@odata.context',
|
|
3439
|
+
ODATA_CONTEXT: '@odata.context',
|
|
3434
3440
|
//odata.etag: the ETag of the entity
|
|
3435
|
-
ODATA_ETAG: '@odata.etag',
|
|
3436
|
-
ODATA_METADATA_ETAG: '@odata.metadataEtag',
|
|
3441
|
+
ODATA_ETAG: '@odata.etag', ODATA_METADATA_ETAG: '@odata.metadataEtag',
|
|
3437
3442
|
//odata.type: the type of the containing {[key: string]: any} or targeted property if the type of the {[key: string]: any} or targeted property cannot be heuristically determined
|
|
3438
|
-
ODATA_TYPE: '@odata.type',
|
|
3443
|
+
ODATA_TYPE: '@odata.type',
|
|
3439
3444
|
//odata.nextLink: the next link of a collection with partial results
|
|
3440
|
-
ODATA_NEXTLINK: '@odata.nextLink',
|
|
3445
|
+
ODATA_NEXTLINK: '@odata.nextLink',
|
|
3441
3446
|
//odata.deltaLink: the delta link for obtaining changes to the result, if requested
|
|
3442
|
-
ODATA_DELTALINK: '@odata.deltaLink',
|
|
3447
|
+
ODATA_DELTALINK: '@odata.deltaLink',
|
|
3443
3448
|
//odata.readLink: the link used to read the entity, if the edit link cannot be used to read the entity
|
|
3444
|
-
ODATA_READLINK: '@odata.readLink',
|
|
3449
|
+
ODATA_READLINK: '@odata.readLink',
|
|
3445
3450
|
//odata.editLink: the link used to edit/update the entity, if the entity is updatable and the odata.id does not represent a URL that can be used to edit the entity
|
|
3446
|
-
ODATA_EDITLINK: '@odata.editLink',
|
|
3451
|
+
ODATA_EDITLINK: '@odata.editLink',
|
|
3447
3452
|
//odata.associationLink: the link used to describe the relationship between this entity and related entities
|
|
3448
|
-
ODATA_ASSOCIATIONLINK: '@odata.associationLink',
|
|
3453
|
+
ODATA_ASSOCIATIONLINK: '@odata.associationLink',
|
|
3449
3454
|
//odata.navigationLink: the link used to retrieve the values of a navigation property
|
|
3450
|
-
ODATA_NAVIGATIONLINK: '@odata.navigationLink',
|
|
3455
|
+
ODATA_NAVIGATIONLINK: '@odata.navigationLink',
|
|
3451
3456
|
//Media entities and stream properties may in addition contain the following annotations:
|
|
3452
3457
|
//odata.mediaEtag: the ETag of the stream, as appropriate
|
|
3453
|
-
ODATA_MEDIA_ETAG: '@odata.mediaEtag',
|
|
3458
|
+
ODATA_MEDIA_ETAG: '@odata.mediaEtag',
|
|
3454
3459
|
//odata.mediaContentType: the content type of the stream
|
|
3455
|
-
ODATA_MEDIA_CONTENTTYPE: '@odata.mediaContentType',
|
|
3460
|
+
ODATA_MEDIA_CONTENTTYPE: '@odata.mediaContentType',
|
|
3456
3461
|
//odata.mediaReadLink: the link used to read the stream
|
|
3457
|
-
ODATA_MEDIA_READLINK: '@odata.mediaReadLink',
|
|
3462
|
+
ODATA_MEDIA_READLINK: '@odata.mediaReadLink',
|
|
3458
3463
|
//odata.mediaEditLink: the link used to edit/update the stream
|
|
3459
|
-
ODATA_MEDIA_EDITLINK: '@odata.mediaEditLink',
|
|
3464
|
+
ODATA_MEDIA_EDITLINK: '@odata.mediaEditLink',
|
|
3460
3465
|
//http://nb-mdp-dev01:57970/$metadata#recursos/$entity
|
|
3461
3466
|
//http://nb-mdp-dev01:57970/$metadata#categorias
|
|
3462
3467
|
//http://nb-mdp-dev01:57970/$metadata#juzgados
|
|
@@ -3505,21 +3510,10 @@ const ODataHelper = {
|
|
|
3505
3510
|
},
|
|
3506
3511
|
countParam() {
|
|
3507
3512
|
return { [$COUNT]: 'true' };
|
|
3508
|
-
},
|
|
3509
|
-
}),
|
|
3513
|
+
} }),
|
|
3510
3514
|
//#endregion
|
|
3511
3515
|
//#region Version 3.0
|
|
3512
|
-
[VERSION_3_0]: Object.assign({}, ODataVersionBaseHelper, {
|
|
3513
|
-
ODATA_ANNOTATION_PREFIX: 'odata.',
|
|
3514
|
-
ODATA_FUNCTION_PREFIX: '',
|
|
3515
|
-
ODATA_ID: 'odata.id',
|
|
3516
|
-
ODATA_ETAG: 'odata.etag',
|
|
3517
|
-
ODATA_CONTEXT: 'odata.metadata',
|
|
3518
|
-
ODATA_NEXTLINK: 'odata.nextLink',
|
|
3519
|
-
ODATA_TYPE: 'odata.type',
|
|
3520
|
-
ODATA_COUNT: 'odata.count',
|
|
3521
|
-
VALUE: 'value',
|
|
3522
|
-
context(annots) {
|
|
3516
|
+
[VERSION_3_0]: Object.assign(Object.assign({}, ODataVersionBaseHelper), { ODATA_ANNOTATION_PREFIX: 'odata.', ODATA_FUNCTION_PREFIX: '', ODATA_ID: 'odata.id', ODATA_ETAG: 'odata.etag', ODATA_CONTEXT: 'odata.metadata', ODATA_NEXTLINK: 'odata.nextLink', ODATA_TYPE: 'odata.type', ODATA_COUNT: 'odata.count', VALUE: 'value', context(annots) {
|
|
3523
3517
|
let ctx = {};
|
|
3524
3518
|
const str = annots instanceof Map
|
|
3525
3519
|
? annots.get(this.ODATA_CONTEXT)
|
|
@@ -3536,33 +3530,26 @@ const ODataHelper = {
|
|
|
3536
3530
|
},
|
|
3537
3531
|
countParam() {
|
|
3538
3532
|
return { [$INLINECOUNT]: 'allpages' };
|
|
3539
|
-
},
|
|
3540
|
-
}),
|
|
3533
|
+
} }),
|
|
3541
3534
|
//#endregion
|
|
3542
3535
|
//#region Version 2.0
|
|
3543
|
-
[VERSION_2_0]: Object.assign({}, ODataVersionBaseHelper, {
|
|
3544
|
-
ODATA_ID: 'id',
|
|
3545
|
-
ODATA_ETAG: 'etag',
|
|
3546
|
-
ODATA_ANNOTATION: '__metadata',
|
|
3547
|
-
ODATA_NEXTLINK: '__next',
|
|
3548
|
-
ODATA_COUNT: '__count',
|
|
3549
|
-
ODATA_DEFERRED: '__deferred',
|
|
3550
|
-
ODATA_TYPE: 'type',
|
|
3551
|
-
VALUE: 'results',
|
|
3552
|
-
annotations(value) {
|
|
3536
|
+
[VERSION_2_0]: Object.assign(Object.assign({}, ODataVersionBaseHelper), { ODATA_ID: 'id', ODATA_ETAG: 'etag', ODATA_ANNOTATION: '__metadata', ODATA_NEXTLINK: '__next', ODATA_COUNT: '__count', ODATA_DEFERRED: '__deferred', ODATA_TYPE: 'type', VALUE: 'results', annotations(value) {
|
|
3553
3537
|
const annots = new Map();
|
|
3554
3538
|
if (this.ODATA_ANNOTATION in value) {
|
|
3555
3539
|
Object.entries(value[this.ODATA_ANNOTATION]).forEach(([key, value]) => annots.set(key, value));
|
|
3556
3540
|
}
|
|
3557
3541
|
return annots;
|
|
3558
3542
|
},
|
|
3543
|
+
context(annots) {
|
|
3544
|
+
let ctx = {};
|
|
3545
|
+
return ctx;
|
|
3546
|
+
},
|
|
3559
3547
|
attributes(value, metadata) {
|
|
3560
3548
|
return value;
|
|
3561
3549
|
},
|
|
3562
3550
|
countParam() {
|
|
3563
3551
|
return { [$INLINECOUNT]: 'allpages' };
|
|
3564
|
-
},
|
|
3565
|
-
}),
|
|
3552
|
+
} }),
|
|
3566
3553
|
//#endregion
|
|
3567
3554
|
};
|
|
3568
3555
|
|
|
@@ -3749,13 +3736,13 @@ const EDM_PARSERS = {
|
|
|
3749
3736
|
//Edm.Int64 Signed 16-bit integer
|
|
3750
3737
|
'Edm.Int64': EdmParser(toNumber, toNumber, toNumber),
|
|
3751
3738
|
//Edm.Date Date without a time-zone offset
|
|
3752
|
-
'Edm.Date': EdmParser((v) => new Date(`${v}T00:00:00.000Z`), (v) => toDate(v).toISOString().substring(0, 10), (v) => toDate(v).toISOString().substring(0, 10)),
|
|
3739
|
+
'Edm.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))),
|
|
3753
3740
|
//Edm.TimeOfDay Clock time 00:00-23:59:59.999999999999
|
|
3754
|
-
'Edm.TimeOfDay': EdmParser((v) => new Date(`1970-01-01T${v}Z`), (v) => toDate(v).toISOString().substring(11, 23), (v) => toDate(v).toISOString().substring(11, 23)),
|
|
3741
|
+
'Edm.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))),
|
|
3755
3742
|
//Edm.DateTimeOffset Date and time with a time-zone offset, no leap seconds
|
|
3756
|
-
'Edm.DateTimeOffset': EdmParser(toDate, (v) => toDate(v).toISOString(), (v) => toDate(v).toISOString()),
|
|
3743
|
+
'Edm.DateTimeOffset': EdmParser(toDate, (v) => toDate(v).toISOString(), (v) => raw(toDate(v).toISOString())),
|
|
3757
3744
|
//Edm.Duration Signed duration in days, hours, minutes, and (sub)seconds
|
|
3758
|
-
'Edm.Duration': EdmParser((v) => Durations.toDuration(v), (v) => Durations.toString(v), (v) => Durations.toString(v)),
|
|
3745
|
+
'Edm.Duration': EdmParser((v) => Durations.toDuration(v), (v) => Durations.toString(v), (v) => raw(Durations.toString(v))),
|
|
3759
3746
|
//Edm.Decimal Numeric values with fixed precision and scale
|
|
3760
3747
|
'Edm.Decimal': EdmParser((v, o) => {
|
|
3761
3748
|
if (typeof v === 'string' && o.ieee754Compatible) {
|
|
@@ -3764,21 +3751,29 @@ const EDM_PARSERS = {
|
|
|
3764
3751
|
return v;
|
|
3765
3752
|
}, (v, o) => {
|
|
3766
3753
|
if (o.ieee754Compatible) {
|
|
3767
|
-
|
|
3754
|
+
let vstr = v.toPrecision(o.field.precision);
|
|
3755
|
+
if (typeof o.field.scale === 'number') {
|
|
3756
|
+
vstr = parseFloat(vstr).toFixed(o.field.scale);
|
|
3757
|
+
}
|
|
3758
|
+
return vstr;
|
|
3768
3759
|
}
|
|
3769
3760
|
return v;
|
|
3770
3761
|
}, (v, o) => {
|
|
3771
3762
|
if (o.ieee754Compatible) {
|
|
3772
|
-
|
|
3763
|
+
let vstr = v.toPrecision(o.field.precision);
|
|
3764
|
+
if (typeof o.field.scale === 'number') {
|
|
3765
|
+
vstr = parseFloat(vstr).toFixed(o.field.scale);
|
|
3766
|
+
}
|
|
3767
|
+
return raw(vstr);
|
|
3773
3768
|
}
|
|
3774
3769
|
return v;
|
|
3775
3770
|
}),
|
|
3776
3771
|
//Edm.Double IEEE 754 binary64 floating-point number (15-17 decimal digits)
|
|
3777
|
-
'Edm.Double': EdmParser((v) => (v === 'INF' ? Infinity : v), (v) => (v === Infinity ? 'INF' : v), (v) => (v === Infinity ? 'INF' : v)),
|
|
3772
|
+
'Edm.Double': EdmParser((v) => (v === 'INF' ? Infinity : v), (v) => (v === Infinity ? 'INF' : v), (v) => raw((v === Infinity ? 'INF' : v.toString()))),
|
|
3778
3773
|
//Edm.Single IEEE 754 binary32 floating-point number (6-9 decimal digits)
|
|
3779
|
-
'Edm.Single': EdmParser((v) => (v === 'INF' ? Infinity : v), (v) => (v === Infinity ? 'INF' : v), (v) => (v === Infinity ? 'INF' : v)),
|
|
3774
|
+
'Edm.Single': EdmParser((v) => (v === 'INF' ? Infinity : v), (v) => (v === Infinity ? 'INF' : v), (v) => raw((v === Infinity ? 'INF' : v.toString()))),
|
|
3780
3775
|
//Edm.Binary Binary data
|
|
3781
|
-
'Edm.Binary': EdmParser((v) => ArrayBuffers.toArrayBuffer(v), (v) => ArrayBuffers.toString(v), (v) => ArrayBuffers.toString(v)),
|
|
3776
|
+
'Edm.Binary': EdmParser((v) => ArrayBuffers.toArrayBuffer(v), (v) => ArrayBuffers.toString(v), (v) => raw(ArrayBuffers.toString(v))),
|
|
3782
3777
|
};
|
|
3783
3778
|
/*
|
|
3784
3779
|
Edm.Stream Binary data stream
|
|
@@ -3820,17 +3815,7 @@ class ODataEnumTypeParser extends ODataAnnotatable {
|
|
|
3820
3815
|
this.members = config.members;
|
|
3821
3816
|
this._fields = Object.entries(config.fields).map(([name, f]) => new ODataEnumTypeFieldParser(name, f));
|
|
3822
3817
|
}
|
|
3823
|
-
|
|
3824
|
-
* Create a nicer looking title.
|
|
3825
|
-
* Titleize is meant for creating pretty output.
|
|
3826
|
-
* @param term The term of the annotation to find.
|
|
3827
|
-
* @returns The titleized string.
|
|
3828
|
-
*/
|
|
3829
|
-
ttitelize(term) {
|
|
3830
|
-
return (term && this.annotatedValue(term)) || Strings.titleCase(this.name);
|
|
3831
|
-
}
|
|
3832
|
-
configure({ stringAsEnum, options, }) {
|
|
3833
|
-
this.stringAsEnum = stringAsEnum;
|
|
3818
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
3834
3819
|
this.parserOptions = options;
|
|
3835
3820
|
}
|
|
3836
3821
|
isTypeOf(type) {
|
|
@@ -3862,7 +3847,7 @@ class ODataEnumTypeParser extends ODataAnnotatable {
|
|
|
3862
3847
|
// Deserialize
|
|
3863
3848
|
deserialize(value, options) {
|
|
3864
3849
|
// string -> number
|
|
3865
|
-
const parserOptions =
|
|
3850
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
3866
3851
|
if (this.flags) {
|
|
3867
3852
|
return Enums.toValues(this.members, value).reduce((acc, v) => acc | v, 0);
|
|
3868
3853
|
}
|
|
@@ -3874,31 +3859,33 @@ class ODataEnumTypeParser extends ODataAnnotatable {
|
|
|
3874
3859
|
serialize(value, options) {
|
|
3875
3860
|
// Enum are string | number
|
|
3876
3861
|
// string | number -> string
|
|
3877
|
-
const parserOptions =
|
|
3862
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
3878
3863
|
if (this.flags) {
|
|
3879
|
-
|
|
3864
|
+
let names = Enums.toNames(this.members, value);
|
|
3880
3865
|
if (names.length === 0)
|
|
3881
|
-
|
|
3882
|
-
return !
|
|
3866
|
+
names = [`${value}`];
|
|
3867
|
+
return !(parserOptions === null || parserOptions === void 0 ? void 0 : parserOptions.stringAsEnum)
|
|
3883
3868
|
? `${this.namespace}.${this.name}'${names.join(', ')}'`
|
|
3884
3869
|
: names.join(', ');
|
|
3885
3870
|
}
|
|
3886
3871
|
else {
|
|
3887
|
-
|
|
3872
|
+
let name = Enums.toName(this.members, value);
|
|
3888
3873
|
if (name === undefined)
|
|
3889
|
-
|
|
3890
|
-
return !
|
|
3874
|
+
name = `${value}`;
|
|
3875
|
+
return !(parserOptions === null || parserOptions === void 0 ? void 0 : parserOptions.stringAsEnum)
|
|
3891
3876
|
? `${this.namespace}.${this.name}'${name}'`
|
|
3892
3877
|
: name;
|
|
3893
3878
|
}
|
|
3894
3879
|
}
|
|
3895
3880
|
//Encode
|
|
3896
3881
|
encode(value, options) {
|
|
3897
|
-
const parserOptions =
|
|
3882
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
3898
3883
|
const serialized = this.serialize(value, parserOptions);
|
|
3899
3884
|
if (serialized === undefined)
|
|
3900
3885
|
return undefined;
|
|
3901
|
-
return
|
|
3886
|
+
return (parserOptions === null || parserOptions === void 0 ? void 0 : parserOptions.stringAsEnum)
|
|
3887
|
+
? raw(`'${serialized}'`)
|
|
3888
|
+
: raw(serialized);
|
|
3902
3889
|
}
|
|
3903
3890
|
// Json Schema
|
|
3904
3891
|
toJsonSchema() {
|
|
@@ -3920,6 +3907,12 @@ class ODataEnumTypeParser extends ODataAnnotatable {
|
|
|
3920
3907
|
return !(member in this.members) ? ['mismatch'] : undefined;
|
|
3921
3908
|
}
|
|
3922
3909
|
}
|
|
3910
|
+
unpack(value) {
|
|
3911
|
+
return Enums.toValues(this.members, value);
|
|
3912
|
+
}
|
|
3913
|
+
pack(value) {
|
|
3914
|
+
return Enums.toValues(this.members, value).reduce((acc, v) => acc | v, 0);
|
|
3915
|
+
}
|
|
3923
3916
|
}
|
|
3924
3917
|
|
|
3925
3918
|
class ODataEntityTypeKey {
|
|
@@ -3998,7 +3991,7 @@ class ODataStructuredTypeFieldParser extends ODataAnnotatable {
|
|
|
3998
3991
|
return parser.deserialize(value, options);
|
|
3999
3992
|
}
|
|
4000
3993
|
deserialize(value, options) {
|
|
4001
|
-
const parserOptions =
|
|
3994
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4002
3995
|
if (this.parser instanceof ODataStructuredTypeParser) {
|
|
4003
3996
|
const parser = this.parser;
|
|
4004
3997
|
return Array.isArray(value)
|
|
@@ -4021,7 +4014,7 @@ class ODataStructuredTypeFieldParser extends ODataAnnotatable {
|
|
|
4021
4014
|
return parser.serialize(value, options);
|
|
4022
4015
|
}
|
|
4023
4016
|
serialize(value, options) {
|
|
4024
|
-
const parserOptions =
|
|
4017
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4025
4018
|
if (this.parser instanceof ODataStructuredTypeParser) {
|
|
4026
4019
|
const parser = this.parser;
|
|
4027
4020
|
return Array.isArray(value)
|
|
@@ -4033,11 +4026,11 @@ class ODataStructuredTypeFieldParser extends ODataAnnotatable {
|
|
|
4033
4026
|
//#endregion
|
|
4034
4027
|
//#region Encode
|
|
4035
4028
|
encode(value, options) {
|
|
4036
|
-
const parserOptions =
|
|
4029
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4037
4030
|
return this.parser.encode(value, Object.assign({ field: this }, parserOptions));
|
|
4038
4031
|
}
|
|
4039
4032
|
//#endregion
|
|
4040
|
-
configure({ parserForType,
|
|
4033
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
4041
4034
|
this.parserOptions = options;
|
|
4042
4035
|
this.parser = parserForType(this.type);
|
|
4043
4036
|
if (this.default !== undefined) {
|
|
@@ -4182,7 +4175,7 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
|
|
|
4182
4175
|
}
|
|
4183
4176
|
// Deserialize
|
|
4184
4177
|
deserialize(value, options) {
|
|
4185
|
-
const parserOptions =
|
|
4178
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4186
4179
|
const fields = this.fields({
|
|
4187
4180
|
include_navigation: true,
|
|
4188
4181
|
include_parents: true,
|
|
@@ -4191,7 +4184,7 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
|
|
|
4191
4184
|
}
|
|
4192
4185
|
// Serialize
|
|
4193
4186
|
serialize(value, options) {
|
|
4194
|
-
const parserOptions =
|
|
4187
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4195
4188
|
const fields = this.fields({
|
|
4196
4189
|
include_navigation: true,
|
|
4197
4190
|
include_parents: true,
|
|
@@ -4202,17 +4195,17 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
|
|
|
4202
4195
|
}
|
|
4203
4196
|
// Encode
|
|
4204
4197
|
encode(value, options) {
|
|
4205
|
-
const parserOptions =
|
|
4198
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4206
4199
|
return raw(JSON.stringify(this.serialize(value, parserOptions)));
|
|
4207
4200
|
}
|
|
4208
|
-
configure({ parserForType,
|
|
4201
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
4209
4202
|
this.parserOptions = options;
|
|
4210
4203
|
if (this.base) {
|
|
4211
4204
|
const parent = parserForType(this.base);
|
|
4212
4205
|
parent.children.push(this);
|
|
4213
4206
|
this.parent = parent;
|
|
4214
4207
|
}
|
|
4215
|
-
this._fields.forEach((f) => f.configure({ parserForType,
|
|
4208
|
+
this._fields.forEach((f) => f.configure({ options, parserForType, findOptionsForType }));
|
|
4216
4209
|
}
|
|
4217
4210
|
/**
|
|
4218
4211
|
* Returns all fields of the structured type.
|
|
@@ -4379,19 +4372,19 @@ class ODataParameterParser {
|
|
|
4379
4372
|
this.collection = parameter.collection;
|
|
4380
4373
|
}
|
|
4381
4374
|
serialize(value, options) {
|
|
4382
|
-
const parserOptions =
|
|
4375
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4383
4376
|
return Array.isArray(value)
|
|
4384
4377
|
? value.map((v) => this.parser.serialize(v, parserOptions))
|
|
4385
4378
|
: this.parser.serialize(value, parserOptions);
|
|
4386
4379
|
}
|
|
4387
4380
|
//Encode
|
|
4388
4381
|
encode(value, options) {
|
|
4389
|
-
const parserOptions =
|
|
4382
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4390
4383
|
return Array.isArray(value)
|
|
4391
4384
|
? value.map((v) => this.parser.encode(v, parserOptions))
|
|
4392
4385
|
: this.parser.encode(value, parserOptions);
|
|
4393
4386
|
}
|
|
4394
|
-
configure({ parserForType,
|
|
4387
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
4395
4388
|
this.parserOptions = options;
|
|
4396
4389
|
this.parser = parserForType(this.type);
|
|
4397
4390
|
}
|
|
@@ -4437,12 +4430,12 @@ class ODataCallableParser {
|
|
|
4437
4430
|
}
|
|
4438
4431
|
// Deserialize
|
|
4439
4432
|
deserialize(value, options) {
|
|
4440
|
-
const parserOptions =
|
|
4433
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4441
4434
|
return this.parser.deserialize(value, parserOptions);
|
|
4442
4435
|
}
|
|
4443
4436
|
// Serialize
|
|
4444
4437
|
serialize(params, options) {
|
|
4445
|
-
const parserOptions =
|
|
4438
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4446
4439
|
const parameters = this.parameters
|
|
4447
4440
|
.filter((p) => p.name !== CALLABLE_BINDING_PARAMETER)
|
|
4448
4441
|
.filter((p) => p.name in params && params[p.name] !== undefined);
|
|
@@ -4450,19 +4443,17 @@ class ODataCallableParser {
|
|
|
4450
4443
|
}
|
|
4451
4444
|
//Encode
|
|
4452
4445
|
encode(params, options) {
|
|
4453
|
-
const parserOptions =
|
|
4446
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4454
4447
|
const parameters = this.parameters
|
|
4455
4448
|
.filter((p) => p.name !== CALLABLE_BINDING_PARAMETER)
|
|
4456
4449
|
.filter((p) => p.name in params && params[p.name] !== undefined);
|
|
4457
4450
|
return parameters.reduce((acc, p) => (Object.assign(Object.assign({}, acc), { [p.name]: p.encode(params[p.name], parserOptions) })), {});
|
|
4458
4451
|
}
|
|
4459
|
-
configure({
|
|
4460
|
-
this.nonParenthesisForEmptyParameterFunction =
|
|
4461
|
-
nonParenthesisForEmptyParameterFunction;
|
|
4452
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
4462
4453
|
this.parserOptions = options;
|
|
4463
4454
|
if (this.return)
|
|
4464
4455
|
this.parser = parserForType(this.return.type) || NONE_PARSER;
|
|
4465
|
-
this.parameters.forEach((p) => p.configure({ parserForType,
|
|
4456
|
+
this.parameters.forEach((p) => p.configure({ options, parserForType, findOptionsForType }));
|
|
4466
4457
|
}
|
|
4467
4458
|
binding() {
|
|
4468
4459
|
return this.parameters.find((p) => p.name === CALLABLE_BINDING_PARAMETER);
|
|
@@ -4491,11 +4482,11 @@ class ODataCallable extends ODataSchemaElement {
|
|
|
4491
4482
|
: this.name;
|
|
4492
4483
|
return path;
|
|
4493
4484
|
}
|
|
4494
|
-
configure({ parserForType, }) {
|
|
4485
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
4495
4486
|
this.parser.configure({
|
|
4496
|
-
|
|
4497
|
-
options: this.api.options.parserOptions,
|
|
4487
|
+
options,
|
|
4498
4488
|
parserForType,
|
|
4489
|
+
findOptionsForType,
|
|
4499
4490
|
});
|
|
4500
4491
|
}
|
|
4501
4492
|
/**
|
|
@@ -4555,11 +4546,8 @@ class ODataEnumType extends ODataSchemaElement {
|
|
|
4555
4546
|
this.members = config.members;
|
|
4556
4547
|
this.parser = new ODataEnumTypeParser(config, schema.namespace, schema.alias);
|
|
4557
4548
|
}
|
|
4558
|
-
configure() {
|
|
4559
|
-
this.parser.configure({
|
|
4560
|
-
stringAsEnum: this.api.options.stringAsEnum,
|
|
4561
|
-
options: this.api.options.parserOptions,
|
|
4562
|
-
});
|
|
4549
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
4550
|
+
this.parser.configure({ options, parserForType, findOptionsForType });
|
|
4563
4551
|
}
|
|
4564
4552
|
/**
|
|
4565
4553
|
* Returns the fields of the enum type.
|
|
@@ -4611,6 +4599,12 @@ class ODataEnumType extends ODataSchemaElement {
|
|
|
4611
4599
|
encode(value, options) {
|
|
4612
4600
|
return this.parser.encode(value, options);
|
|
4613
4601
|
}
|
|
4602
|
+
unpack(value) {
|
|
4603
|
+
return this.parser.unpack(value);
|
|
4604
|
+
}
|
|
4605
|
+
pack(value) {
|
|
4606
|
+
return this.parser.pack(value);
|
|
4607
|
+
}
|
|
4614
4608
|
}
|
|
4615
4609
|
|
|
4616
4610
|
class ODataStructuredType extends ODataSchemaElement {
|
|
@@ -4632,20 +4626,22 @@ class ODataStructuredType extends ODataSchemaElement {
|
|
|
4632
4626
|
this.collection.model = this.model;
|
|
4633
4627
|
}
|
|
4634
4628
|
}
|
|
4635
|
-
configure({ parserForType, findOptionsForType, }) {
|
|
4629
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
4636
4630
|
if (this.base) {
|
|
4637
4631
|
const parent = this.api.findStructuredTypeForType(this.base);
|
|
4638
4632
|
parent.children.push(this);
|
|
4639
4633
|
this.parent = parent;
|
|
4640
4634
|
}
|
|
4641
4635
|
this.parser.configure({
|
|
4636
|
+
options,
|
|
4642
4637
|
parserForType,
|
|
4643
|
-
|
|
4638
|
+
findOptionsForType,
|
|
4644
4639
|
});
|
|
4645
4640
|
if (this.model !== undefined && this.model.options !== null) {
|
|
4646
4641
|
this.model.meta.configure({
|
|
4642
|
+
options,
|
|
4643
|
+
parserForType,
|
|
4647
4644
|
findOptionsForType,
|
|
4648
|
-
options: this.api.options.parserOptions,
|
|
4649
4645
|
});
|
|
4650
4646
|
}
|
|
4651
4647
|
}
|
|
@@ -4851,13 +4847,13 @@ class ODataSchema extends ODataAnnotatable {
|
|
|
4851
4847
|
return this.entitySets.find((e) => e.isTypeOf(type));
|
|
4852
4848
|
}
|
|
4853
4849
|
//#endregion
|
|
4854
|
-
configure({ parserForType, findOptionsForType, }) {
|
|
4850
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
4855
4851
|
// Configure Enums
|
|
4856
|
-
this.enums.forEach((enu) => enu.configure());
|
|
4852
|
+
this.enums.forEach((enu) => enu.configure({ options, parserForType, findOptionsForType }));
|
|
4857
4853
|
// Configure Entities
|
|
4858
|
-
this.entities.forEach((config) => config.configure({ parserForType, findOptionsForType }));
|
|
4854
|
+
this.entities.forEach((config) => config.configure({ options, parserForType, findOptionsForType }));
|
|
4859
4855
|
// Configure callables
|
|
4860
|
-
this.callables.forEach((callable) => callable.configure({ parserForType }));
|
|
4856
|
+
this.callables.forEach((callable) => callable.configure({ options, parserForType, findOptionsForType }));
|
|
4861
4857
|
}
|
|
4862
4858
|
}
|
|
4863
4859
|
|
|
@@ -5000,7 +4996,6 @@ class ODataResource {
|
|
|
5000
4996
|
return undefined;
|
|
5001
4997
|
}
|
|
5002
4998
|
deserialize(value, options) {
|
|
5003
|
-
const parserOptions = options || this.api.options.parserOptions;
|
|
5004
4999
|
const resourceType = this.returnType();
|
|
5005
5000
|
const _d = (value, options) => {
|
|
5006
5001
|
const parser = this.__parser(value, options, resourceType);
|
|
@@ -5009,11 +5004,10 @@ class ODataResource {
|
|
|
5009
5004
|
: value;
|
|
5010
5005
|
};
|
|
5011
5006
|
return Array.isArray(value)
|
|
5012
|
-
? value.map((v) => _d(v,
|
|
5013
|
-
: _d(value,
|
|
5007
|
+
? value.map((v) => _d(v, options))
|
|
5008
|
+
: _d(value, options);
|
|
5014
5009
|
}
|
|
5015
5010
|
serialize(value, options) {
|
|
5016
|
-
const parserOptions = options || this.api.options.parserOptions;
|
|
5017
5011
|
const resourceType = this.type();
|
|
5018
5012
|
const _s = (value, options) => {
|
|
5019
5013
|
const parser = this.__parser(value, options, resourceType);
|
|
@@ -5022,11 +5016,10 @@ class ODataResource {
|
|
|
5022
5016
|
: value;
|
|
5023
5017
|
};
|
|
5024
5018
|
return Array.isArray(value)
|
|
5025
|
-
? value.map((v) => _s(v,
|
|
5026
|
-
: _s(value,
|
|
5019
|
+
? value.map((v) => _s(v, options))
|
|
5020
|
+
: _s(value, options);
|
|
5027
5021
|
}
|
|
5028
5022
|
encode(value, options) {
|
|
5029
|
-
const parserOptions = options || this.api.options.parserOptions;
|
|
5030
5023
|
const resourceType = this.type();
|
|
5031
5024
|
const _e = (value, options) => {
|
|
5032
5025
|
const parser = this.__parser(value, options, resourceType);
|
|
@@ -5035,8 +5028,8 @@ class ODataResource {
|
|
|
5035
5028
|
: value;
|
|
5036
5029
|
};
|
|
5037
5030
|
return Array.isArray(value)
|
|
5038
|
-
? value.map((v) => _e(v,
|
|
5039
|
-
: _e(value,
|
|
5031
|
+
? value.map((v) => _e(v, options))
|
|
5032
|
+
: _e(value, options);
|
|
5040
5033
|
}
|
|
5041
5034
|
toJSON() {
|
|
5042
5035
|
return {
|
|
@@ -5096,61 +5089,20 @@ class ODataResource {
|
|
|
5096
5089
|
return ODataResource.resolveKey(value, this.schema);
|
|
5097
5090
|
}
|
|
5098
5091
|
//#endregion
|
|
5099
|
-
// Base Requests
|
|
5100
|
-
request(method, options) {
|
|
5101
|
-
const apiOptions = this.api.options;
|
|
5102
|
-
let params = options.params || {};
|
|
5103
|
-
if (options.withCount) {
|
|
5104
|
-
params = Http.mergeHttpParams(params, apiOptions.helper.countParam());
|
|
5105
|
-
}
|
|
5106
|
-
let etag = options.etag;
|
|
5107
|
-
if (etag === undefined && Types.isPlainObject(options.body)) {
|
|
5108
|
-
etag = apiOptions.helper.etag(options.body);
|
|
5109
|
-
}
|
|
5110
|
-
const request = new ODataRequest({
|
|
5111
|
-
method,
|
|
5112
|
-
etag,
|
|
5113
|
-
body: options.body,
|
|
5114
|
-
api: this.api,
|
|
5115
|
-
resource: this,
|
|
5116
|
-
observe: 'response',
|
|
5117
|
-
headers: options.headers,
|
|
5118
|
-
reportProgress: options.reportProgress,
|
|
5119
|
-
params: params,
|
|
5120
|
-
responseType: options.responseType,
|
|
5121
|
-
fetchPolicy: options.fetchPolicy,
|
|
5122
|
-
withCredentials: options.withCredentials,
|
|
5123
|
-
bodyQueryOptions: options.bodyQueryOptions,
|
|
5124
|
-
});
|
|
5125
|
-
const res$ = this.api.request(request);
|
|
5126
|
-
switch (options.responseType) {
|
|
5127
|
-
case 'entities':
|
|
5128
|
-
return res$.pipe(map((res) => res.entities()));
|
|
5129
|
-
case 'entity':
|
|
5130
|
-
return res$.pipe(map((res) => res.entity()));
|
|
5131
|
-
case 'property':
|
|
5132
|
-
return res$.pipe(map((res) => res.property()));
|
|
5133
|
-
case 'value':
|
|
5134
|
-
return res$.pipe(map((res) => res.value()));
|
|
5135
|
-
default:
|
|
5136
|
-
// Other responseTypes (arraybuffer, blob, json, text) return body
|
|
5137
|
-
return res$.pipe(map((res) => res.body));
|
|
5138
|
-
}
|
|
5139
|
-
}
|
|
5140
5092
|
get(options = {}) {
|
|
5141
|
-
return this.request('GET', options);
|
|
5093
|
+
return this.api.request('GET', this, options);
|
|
5142
5094
|
}
|
|
5143
5095
|
post(body, options = {}) {
|
|
5144
|
-
return this.request('POST', Object.assign({ body }, options));
|
|
5096
|
+
return this.api.request('POST', this, Object.assign({ body }, options));
|
|
5145
5097
|
}
|
|
5146
5098
|
put(body, options = {}) {
|
|
5147
|
-
return this.request('PUT', Object.assign({ body }, options));
|
|
5099
|
+
return this.api.request('PUT', this, Object.assign({ body }, options));
|
|
5148
5100
|
}
|
|
5149
5101
|
patch(body, options = {}) {
|
|
5150
|
-
return this.request('PATCH', Object.assign({ body }, options));
|
|
5102
|
+
return this.api.request('PATCH', this, Object.assign({ body }, options));
|
|
5151
5103
|
}
|
|
5152
5104
|
delete(options = {}) {
|
|
5153
|
-
return this.request('DELETE', options);
|
|
5105
|
+
return this.api.request('DELETE', this, options);
|
|
5154
5106
|
}
|
|
5155
5107
|
}
|
|
5156
5108
|
|
|
@@ -5374,18 +5326,16 @@ class ODataBatchResource extends ODataResource {
|
|
|
5374
5326
|
[CONTENT_TYPE]: MULTIPART_MIXED_BOUNDARY + bound,
|
|
5375
5327
|
[ACCEPT]: MULTIPART_MIXED,
|
|
5376
5328
|
});
|
|
5377
|
-
|
|
5378
|
-
|
|
5329
|
+
return this.api
|
|
5330
|
+
.request('POST', this, {
|
|
5379
5331
|
body: ODataBatchResource.buildBody(bound, this._requests),
|
|
5380
|
-
api: this.api,
|
|
5381
|
-
resource: this,
|
|
5382
|
-
observe: 'response',
|
|
5383
5332
|
responseType: 'text',
|
|
5333
|
+
observe: 'response',
|
|
5384
5334
|
headers: headers,
|
|
5385
5335
|
params: options ? options.params : undefined,
|
|
5386
5336
|
withCredentials: options ? options.withCredentials : undefined,
|
|
5387
|
-
})
|
|
5388
|
-
|
|
5337
|
+
})
|
|
5338
|
+
.pipe(map$1((response) => {
|
|
5389
5339
|
if (this._responses == null) {
|
|
5390
5340
|
this._responses = [];
|
|
5391
5341
|
}
|
|
@@ -5804,7 +5754,7 @@ class ODataValueResource extends ODataResource {
|
|
|
5804
5754
|
}
|
|
5805
5755
|
//#endregion
|
|
5806
5756
|
//#region Requests
|
|
5807
|
-
get(options) {
|
|
5757
|
+
get(options = {}) {
|
|
5808
5758
|
return super.get(Object.assign({ responseType: 'value' }, options));
|
|
5809
5759
|
}
|
|
5810
5760
|
//#endregion
|
|
@@ -5979,6 +5929,24 @@ class ODataPropertyResource extends ODataResource {
|
|
|
5979
5929
|
? this.asCollection(entities, { annots, reset: true })
|
|
5980
5930
|
: null));
|
|
5981
5931
|
}
|
|
5932
|
+
fetchOne(options) {
|
|
5933
|
+
let res = this.clone();
|
|
5934
|
+
res.query((q) => q.top(1));
|
|
5935
|
+
return res.fetch(Object.assign({ responseType: 'entities' }, options)).pipe(map(({ entities, annots }) => ({ entity: entities !== null ? entities[0] || null : null, annots })));
|
|
5936
|
+
}
|
|
5937
|
+
fetchMany(top, options) {
|
|
5938
|
+
let res = this.clone();
|
|
5939
|
+
let fetch = (opts) => {
|
|
5940
|
+
if (opts) {
|
|
5941
|
+
res.query((q) => q.paging(opts));
|
|
5942
|
+
}
|
|
5943
|
+
return res.fetch(Object.assign({ responseType: 'entities' }, options));
|
|
5944
|
+
};
|
|
5945
|
+
return fetch({ top }).pipe(expand(({ annots }) => annots.skip || annots.skiptoken ? fetch(annots) : EMPTY), map(({ entities, annots }) => ({ entities: entities || [], annots })), reduce((acc, { entities, annots }) => ({
|
|
5946
|
+
entities: [...(acc.entities || []), ...(entities || [])],
|
|
5947
|
+
annots: acc.annots.union(annots)
|
|
5948
|
+
})));
|
|
5949
|
+
}
|
|
5982
5950
|
/**
|
|
5983
5951
|
* Fetch all entities
|
|
5984
5952
|
* @param options Options for the request
|
|
@@ -5994,7 +5962,10 @@ class ODataPropertyResource extends ODataResource {
|
|
|
5994
5962
|
}
|
|
5995
5963
|
return res.fetch(Object.assign({ responseType: 'entities' }, options));
|
|
5996
5964
|
};
|
|
5997
|
-
return fetch().pipe(expand(({ annots
|
|
5965
|
+
return fetch().pipe(expand(({ annots }) => annots.skip || annots.skiptoken ? fetch(annots) : EMPTY), map(({ entities, annots }) => ({ entities: entities || [], annots })), reduce((acc, { entities, annots }) => ({
|
|
5966
|
+
entities: [...(acc.entities || []), ...(entities || [])],
|
|
5967
|
+
annots: acc.annots.union(annots)
|
|
5968
|
+
})));
|
|
5998
5969
|
}
|
|
5999
5970
|
}
|
|
6000
5971
|
|
|
@@ -6223,7 +6194,6 @@ class ODataNavigationPropertyResource extends ODataResource {
|
|
|
6223
6194
|
* Update an existing entity
|
|
6224
6195
|
* @param attrs The entity attributes
|
|
6225
6196
|
* @param options Options for the request
|
|
6226
|
-
* @param etag The etag of the entity
|
|
6227
6197
|
* @returns The updated entity with the annotations
|
|
6228
6198
|
*/
|
|
6229
6199
|
update(attrs, options) {
|
|
@@ -6233,7 +6203,6 @@ class ODataNavigationPropertyResource extends ODataResource {
|
|
|
6233
6203
|
* Modify an existing entity
|
|
6234
6204
|
* @param attrs The entity attributes
|
|
6235
6205
|
* @param options Options for the request
|
|
6236
|
-
* @param etag The etag of the entity
|
|
6237
6206
|
* @returns The modified entity with the annotations
|
|
6238
6207
|
*/
|
|
6239
6208
|
modify(attrs, options) {
|
|
@@ -6242,7 +6211,6 @@ class ODataNavigationPropertyResource extends ODataResource {
|
|
|
6242
6211
|
/**
|
|
6243
6212
|
* Delete an existing entity
|
|
6244
6213
|
* @param options Options for the request
|
|
6245
|
-
* @param etag The etag of the entity
|
|
6246
6214
|
* @returns An observable of the destroy
|
|
6247
6215
|
*/
|
|
6248
6216
|
destroy(options) {
|
|
@@ -6287,6 +6255,24 @@ class ODataNavigationPropertyResource extends ODataResource {
|
|
|
6287
6255
|
? this.asCollection(entities, { annots, reset: true })
|
|
6288
6256
|
: null));
|
|
6289
6257
|
}
|
|
6258
|
+
fetchOne(options) {
|
|
6259
|
+
let res = this.clone();
|
|
6260
|
+
res.query((q) => q.top(1));
|
|
6261
|
+
return res.fetch(Object.assign({ responseType: 'entities' }, options)).pipe(map(({ entities, annots }) => ({ entity: entities !== null ? entities[0] || null : null, annots })));
|
|
6262
|
+
}
|
|
6263
|
+
fetchMany(top, options) {
|
|
6264
|
+
let res = this.clone();
|
|
6265
|
+
let fetch = (opts) => {
|
|
6266
|
+
if (opts) {
|
|
6267
|
+
res.query((q) => q.paging(opts));
|
|
6268
|
+
}
|
|
6269
|
+
return res.fetch(Object.assign({ responseType: 'entities' }, options));
|
|
6270
|
+
};
|
|
6271
|
+
return fetch({ top }).pipe(expand(({ annots }) => annots.skip || annots.skiptoken ? fetch(annots) : EMPTY), map(({ entities, annots }) => ({ entities: entities || [], annots })), reduce((acc, { entities, annots }) => ({
|
|
6272
|
+
entities: [...(acc.entities || []), ...(entities || [])],
|
|
6273
|
+
annots: acc.annots.union(annots)
|
|
6274
|
+
})));
|
|
6275
|
+
}
|
|
6290
6276
|
/**
|
|
6291
6277
|
* Fetch all entities
|
|
6292
6278
|
* @param options Options for the request
|
|
@@ -6302,7 +6288,10 @@ class ODataNavigationPropertyResource extends ODataResource {
|
|
|
6302
6288
|
}
|
|
6303
6289
|
return res.fetch(Object.assign({ responseType: 'entities' }, options));
|
|
6304
6290
|
};
|
|
6305
|
-
return fetch().pipe(expand(({ annots
|
|
6291
|
+
return fetch().pipe(expand(({ annots }) => annots.skip || annots.skiptoken ? fetch(annots) : EMPTY), map(({ entities, annots }) => ({ entities: entities || [], annots })), reduce((acc, { entities, annots }) => ({
|
|
6292
|
+
entities: [...(acc.entities || []), ...(entities || [])],
|
|
6293
|
+
annots: acc.annots.union(annots)
|
|
6294
|
+
})));
|
|
6306
6295
|
}
|
|
6307
6296
|
}
|
|
6308
6297
|
|
|
@@ -6458,7 +6447,7 @@ class ODataEntitySetResource extends ODataResource {
|
|
|
6458
6447
|
});
|
|
6459
6448
|
}
|
|
6460
6449
|
//#region Requests
|
|
6461
|
-
post(attrs, options
|
|
6450
|
+
post(attrs, options) {
|
|
6462
6451
|
return super.post(attrs, Object.assign({ responseType: 'entity' }, options));
|
|
6463
6452
|
}
|
|
6464
6453
|
get(options = {}) {
|
|
@@ -6472,13 +6461,23 @@ class ODataEntitySetResource extends ODataResource {
|
|
|
6472
6461
|
fetch(options) {
|
|
6473
6462
|
return this.get(options);
|
|
6474
6463
|
}
|
|
6475
|
-
|
|
6476
|
-
|
|
6464
|
+
fetchOne(options) {
|
|
6465
|
+
let res = this.clone();
|
|
6466
|
+
res.query((q) => q.top(1));
|
|
6467
|
+
return res.fetch(options).pipe(map(({ entities, annots }) => ({ entity: entities !== null ? entities[0] || null : null, annots })));
|
|
6477
6468
|
}
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6469
|
+
fetchMany(top, options) {
|
|
6470
|
+
let res = this.clone();
|
|
6471
|
+
let fetch = (opts) => {
|
|
6472
|
+
if (opts) {
|
|
6473
|
+
res.query((q) => q.paging(opts));
|
|
6474
|
+
}
|
|
6475
|
+
return res.fetch(options);
|
|
6476
|
+
};
|
|
6477
|
+
return fetch({ top }).pipe(expand(({ annots }) => annots.skip || annots.skiptoken ? fetch(annots) : EMPTY), map(({ entities, annots }) => ({ entities: entities || [], annots })), reduce((acc, { entities, annots }) => ({
|
|
6478
|
+
entities: [...(acc.entities || []), ...(entities || [])],
|
|
6479
|
+
annots: acc.annots.union(annots)
|
|
6480
|
+
})));
|
|
6482
6481
|
}
|
|
6483
6482
|
fetchAll(options) {
|
|
6484
6483
|
let res = this.clone();
|
|
@@ -6490,7 +6489,19 @@ class ODataEntitySetResource extends ODataResource {
|
|
|
6490
6489
|
}
|
|
6491
6490
|
return res.fetch(options);
|
|
6492
6491
|
};
|
|
6493
|
-
return fetch().pipe(expand(({ annots
|
|
6492
|
+
return fetch().pipe(expand(({ annots }) => annots.skip || annots.skiptoken ? fetch(annots) : EMPTY), map(({ entities, annots }) => ({ entities: entities || [], annots })), reduce((acc, { entities, annots }) => ({
|
|
6493
|
+
entities: [...(acc.entities || []), ...(entities || [])],
|
|
6494
|
+
annots: acc.annots.union(annots)
|
|
6495
|
+
})));
|
|
6496
|
+
}
|
|
6497
|
+
//#endregion
|
|
6498
|
+
fetchEntities(options) {
|
|
6499
|
+
return this.fetch(options).pipe(map(({ entities }) => entities));
|
|
6500
|
+
}
|
|
6501
|
+
fetchCollection(options) {
|
|
6502
|
+
return this.fetch(options).pipe(map(({ entities, annots }) => entities
|
|
6503
|
+
? this.asCollection(entities, { annots, reset: true })
|
|
6504
|
+
: null));
|
|
6494
6505
|
}
|
|
6495
6506
|
}
|
|
6496
6507
|
|
|
@@ -6503,6 +6514,12 @@ class ODataAnnotations {
|
|
|
6503
6514
|
attributes(data, metadata) {
|
|
6504
6515
|
return this.helper.attributes(data, metadata);
|
|
6505
6516
|
}
|
|
6517
|
+
update(data) {
|
|
6518
|
+
this.annotations = new Map([
|
|
6519
|
+
...this.annotations,
|
|
6520
|
+
...this.helper.annotations(data),
|
|
6521
|
+
]);
|
|
6522
|
+
}
|
|
6506
6523
|
get entitySet() {
|
|
6507
6524
|
var _a;
|
|
6508
6525
|
return (_a = this.context) === null || _a === void 0 ? void 0 : _a.entitySet;
|
|
@@ -6513,6 +6530,9 @@ class ODataAnnotations {
|
|
|
6513
6530
|
}
|
|
6514
6531
|
}
|
|
6515
6532
|
class ODataPropertyAnnotations extends ODataAnnotations {
|
|
6533
|
+
union(other) {
|
|
6534
|
+
return new ODataPropertyAnnotations(this.helper, new Map([...this.annotations, ...other.annotations]), Object.assign({}, this.context, other.context));
|
|
6535
|
+
}
|
|
6516
6536
|
clone() {
|
|
6517
6537
|
return new ODataPropertyAnnotations(this.helper, new Map(this.annotations), this.context);
|
|
6518
6538
|
}
|
|
@@ -6521,6 +6541,9 @@ class ODataPropertyAnnotations extends ODataAnnotations {
|
|
|
6521
6541
|
}
|
|
6522
6542
|
}
|
|
6523
6543
|
class ODataEntityAnnotations extends ODataAnnotations {
|
|
6544
|
+
union(other) {
|
|
6545
|
+
return new ODataEntityAnnotations(this.helper, new Map([...this.annotations, ...other.annotations]), Object.assign({}, this.context, other.context));
|
|
6546
|
+
}
|
|
6524
6547
|
clone() {
|
|
6525
6548
|
return new ODataEntityAnnotations(this.helper, new Map(this.annotations), this.context);
|
|
6526
6549
|
}
|
|
@@ -6560,8 +6583,11 @@ class ODataEntityAnnotations extends ODataAnnotations {
|
|
|
6560
6583
|
}
|
|
6561
6584
|
return this._properties;
|
|
6562
6585
|
}
|
|
6563
|
-
property(name) {
|
|
6564
|
-
|
|
6586
|
+
property(name, type) {
|
|
6587
|
+
const props = this.properties.get(name);
|
|
6588
|
+
return type === 'collection'
|
|
6589
|
+
? new ODataEntitiesAnnotations(this.helper, props)
|
|
6590
|
+
: new ODataEntityAnnotations(this.helper, props);
|
|
6565
6591
|
}
|
|
6566
6592
|
get functions() {
|
|
6567
6593
|
if (this._functions === undefined) {
|
|
@@ -6574,6 +6600,9 @@ class ODataEntityAnnotations extends ODataAnnotations {
|
|
|
6574
6600
|
}
|
|
6575
6601
|
}
|
|
6576
6602
|
class ODataEntitiesAnnotations extends ODataAnnotations {
|
|
6603
|
+
union(other) {
|
|
6604
|
+
return new ODataEntitiesAnnotations(this.helper, new Map([...this.annotations, ...other.annotations]), Object.assign({}, this.context, other.context));
|
|
6605
|
+
}
|
|
6577
6606
|
clone() {
|
|
6578
6607
|
return new ODataEntitiesAnnotations(this.helper, new Map(this.annotations), this.context);
|
|
6579
6608
|
}
|
|
@@ -7643,14 +7672,12 @@ class ODataMetadataResource extends ODataResource {
|
|
|
7643
7672
|
//#endregion
|
|
7644
7673
|
//#region Requests
|
|
7645
7674
|
get(options) {
|
|
7646
|
-
return super
|
|
7647
|
-
.get(Object.assign({ responseType: 'text' }, options))
|
|
7648
|
-
.pipe(map((body) => new ODataMetadata(body)));
|
|
7675
|
+
return super.get(Object.assign({ responseType: 'text' }, options));
|
|
7649
7676
|
}
|
|
7650
7677
|
//#endregion
|
|
7651
7678
|
//#region Shortcuts
|
|
7652
7679
|
fetch(options) {
|
|
7653
|
-
return this.get(options);
|
|
7680
|
+
return this.get(options).pipe(map((body) => new ODataMetadata(body)));
|
|
7654
7681
|
}
|
|
7655
7682
|
}
|
|
7656
7683
|
|
|
@@ -7749,7 +7776,6 @@ class ODataSingletonResource extends ODataResource {
|
|
|
7749
7776
|
/**
|
|
7750
7777
|
* Fetch an existing entity.
|
|
7751
7778
|
* @param options The options for the request.
|
|
7752
|
-
* @param etag The etag to use for the request.
|
|
7753
7779
|
* @returns Observable of the entity with the annotations.
|
|
7754
7780
|
*/
|
|
7755
7781
|
fetch(options) {
|
|
@@ -7758,7 +7784,6 @@ class ODataSingletonResource extends ODataResource {
|
|
|
7758
7784
|
/**
|
|
7759
7785
|
* Fetch an existing entity.
|
|
7760
7786
|
* @param options The options for the request.
|
|
7761
|
-
* @param etag The etag to use for the request.
|
|
7762
7787
|
* @returns Observable of the entity.
|
|
7763
7788
|
*/
|
|
7764
7789
|
fetchEntity(options) {
|
|
@@ -7767,7 +7792,6 @@ class ODataSingletonResource extends ODataResource {
|
|
|
7767
7792
|
/**
|
|
7768
7793
|
* Fetch an existing entity and return a model.
|
|
7769
7794
|
* @param options The options for the request.
|
|
7770
|
-
* @param etag The etag to use for the request.
|
|
7771
7795
|
* @returns Observable of the entity.
|
|
7772
7796
|
*/
|
|
7773
7797
|
fetchModel(options) {
|
|
@@ -8076,30 +8100,46 @@ class ODataModelField {
|
|
|
8076
8100
|
: base.property(this.parser.name);
|
|
8077
8101
|
}
|
|
8078
8102
|
annotationsFactory(base) {
|
|
8079
|
-
return this.parser.collection
|
|
8080
|
-
|
|
8081
|
-
|
|
8103
|
+
return this.parser.collection ?
|
|
8104
|
+
base.property(this.parser.name, 'collection') :
|
|
8105
|
+
base.property(this.parser.name, 'single');
|
|
8082
8106
|
}
|
|
8083
8107
|
schemaFactory(base) {
|
|
8084
8108
|
return this.api.findStructuredTypeForType(this.parser.type);
|
|
8085
8109
|
}
|
|
8086
|
-
|
|
8110
|
+
modelFactory({ parent, value, reset, }) {
|
|
8111
|
+
var _a;
|
|
8112
|
+
// Model
|
|
8113
|
+
const annots = this.annotationsFactory(parent.annots());
|
|
8114
|
+
let Model = this.api.modelForType(this.parser.type);
|
|
8115
|
+
if (Model === undefined)
|
|
8116
|
+
throw Error(`No Model type for ${this.name}`);
|
|
8117
|
+
if (value !== undefined) {
|
|
8118
|
+
annots.update(value);
|
|
8119
|
+
}
|
|
8120
|
+
if ((annots === null || annots === void 0 ? void 0 : annots.type) !== undefined && Model.meta !== null) {
|
|
8121
|
+
let schema = (_a = Model.meta.findChildOptions((o) => o.isTypeOf(annots.type))) === null || _a === void 0 ? void 0 : _a.schema;
|
|
8122
|
+
if (schema !== undefined && schema.model !== undefined)
|
|
8123
|
+
// Change to child model
|
|
8124
|
+
Model = schema.model;
|
|
8125
|
+
}
|
|
8126
|
+
return new Model((value || {}), {
|
|
8127
|
+
annots,
|
|
8128
|
+
reset,
|
|
8129
|
+
parent: [parent, this],
|
|
8130
|
+
});
|
|
8131
|
+
}
|
|
8132
|
+
collectionFactory({ parent, value, reset, }) {
|
|
8133
|
+
// Collection Factory
|
|
8087
8134
|
const annots = this.annotationsFactory(parent.annots());
|
|
8088
|
-
const Model = this.api.modelForType(this.parser.type);
|
|
8089
8135
|
const Collection = this.api.collectionForType(this.parser.type);
|
|
8090
|
-
if (
|
|
8091
|
-
throw Error(`No
|
|
8092
|
-
return
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
})
|
|
8098
|
-
: new Model((value || {}), {
|
|
8099
|
-
annots: annots,
|
|
8100
|
-
parent: [parent, this],
|
|
8101
|
-
reset,
|
|
8102
|
-
});
|
|
8136
|
+
if (Collection === undefined)
|
|
8137
|
+
throw Error(`No Collection type for ${this.name}`);
|
|
8138
|
+
return new Collection((value || []), {
|
|
8139
|
+
annots: annots,
|
|
8140
|
+
parent: [parent, this],
|
|
8141
|
+
reset,
|
|
8142
|
+
});
|
|
8103
8143
|
}
|
|
8104
8144
|
}
|
|
8105
8145
|
class ODataModelOptions {
|
|
@@ -8153,7 +8193,7 @@ class ODataModelOptions {
|
|
|
8153
8193
|
}
|
|
8154
8194
|
return match;
|
|
8155
8195
|
}
|
|
8156
|
-
configure({
|
|
8196
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
8157
8197
|
if (this.base) {
|
|
8158
8198
|
const parent = findOptionsForType(this.base);
|
|
8159
8199
|
parent.children.push(this);
|
|
@@ -8769,11 +8809,17 @@ class ODataModelOptions {
|
|
|
8769
8809
|
ODataModelOptions.isCollection(value) ||
|
|
8770
8810
|
ODataModelOptions.isModel(value)
|
|
8771
8811
|
? value
|
|
8772
|
-
: field.
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
|
|
8812
|
+
: field.collection
|
|
8813
|
+
? field.collectionFactory({
|
|
8814
|
+
parent: self,
|
|
8815
|
+
value: value,
|
|
8816
|
+
reset: self._reset,
|
|
8817
|
+
})
|
|
8818
|
+
: field.modelFactory({
|
|
8819
|
+
parent: self,
|
|
8820
|
+
value: value,
|
|
8821
|
+
reset: self._reset,
|
|
8822
|
+
});
|
|
8777
8823
|
// Link new model/collection
|
|
8778
8824
|
this._link(self, relation);
|
|
8779
8825
|
changed = true;
|
|
@@ -8974,8 +9020,8 @@ class ODataCollection {
|
|
|
8974
9020
|
modelFactory(data, { reset = false } = {}) {
|
|
8975
9021
|
var _a;
|
|
8976
9022
|
let Model = this._model;
|
|
8977
|
-
const
|
|
8978
|
-
|
|
9023
|
+
const annots = new ODataEntityAnnotations(this._annotations.helper);
|
|
9024
|
+
annots.update(data);
|
|
8979
9025
|
if ((annots === null || annots === void 0 ? void 0 : annots.type) !== undefined && Model.meta !== null) {
|
|
8980
9026
|
let schema = (_a = Model.meta.findChildOptions((o) => o.isTypeOf(annots.type))) === null || _a === void 0 ? void 0 : _a.schema;
|
|
8981
9027
|
if (schema !== undefined && schema.model !== undefined)
|
|
@@ -9020,39 +9066,34 @@ class ODataCollection {
|
|
|
9020
9066
|
annots: this.annots(),
|
|
9021
9067
|
});
|
|
9022
9068
|
}
|
|
9069
|
+
_request(obs$) {
|
|
9070
|
+
this.events$.emit(new ODataModelEvent('request', { collection: this, options: { observable: obs$ } }));
|
|
9071
|
+
return obs$.pipe(map(({ entities, annots }) => {
|
|
9072
|
+
this._annotations = annots;
|
|
9073
|
+
this.assign(entities || [], { reset: true });
|
|
9074
|
+
this.events$.emit(new ODataModelEvent('sync', { collection: this, options: { entities, annots } }));
|
|
9075
|
+
return this;
|
|
9076
|
+
}));
|
|
9077
|
+
}
|
|
9023
9078
|
fetch(_a = {}) {
|
|
9024
9079
|
var { withCount } = _a, options = __rest(_a, ["withCount"]);
|
|
9025
9080
|
const resource = this.resource();
|
|
9026
9081
|
const obs$ = resource instanceof ODataEntitySetResource
|
|
9027
9082
|
? resource.fetch(Object.assign({ withCount }, options))
|
|
9028
9083
|
: resource.fetch(Object.assign({ responseType: 'entities', withCount }, options));
|
|
9029
|
-
this.
|
|
9030
|
-
return obs$.pipe(map(({ entities, annots }) => {
|
|
9031
|
-
this._annotations = annots;
|
|
9032
|
-
this.assign(entities || [], { reset: true });
|
|
9033
|
-
this.events$.emit(new ODataModelEvent('sync', { collection: this }));
|
|
9034
|
-
return this;
|
|
9035
|
-
}));
|
|
9084
|
+
return this._request(obs$);
|
|
9036
9085
|
}
|
|
9037
|
-
|
|
9086
|
+
fetchMany(top, _a = {}) {
|
|
9087
|
+
var { withCount } = _a, options = __rest(_a, ["withCount"]);
|
|
9038
9088
|
const resource = this.resource();
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
}));
|
|
9046
|
-
return obs
|
|
9047
|
-
var _a;
|
|
9048
|
-
this._annotations = new ODataEntitiesAnnotations(ODataHelper[((_a = resource === null || resource === void 0 ? void 0 : resource.api) === null || _a === void 0 ? void 0 : _a.options.version) || DEFAULT_VERSION]);
|
|
9049
|
-
this.assign(entities || [], { reset: true });
|
|
9050
|
-
this.events$.emit(new ODataModelEvent('sync', {
|
|
9051
|
-
collection: this,
|
|
9052
|
-
options: { entities },
|
|
9053
|
-
}));
|
|
9054
|
-
return this;
|
|
9055
|
-
}));
|
|
9089
|
+
const obs$ = resource.fetchMany(top, Object.assign({ withCount }, options));
|
|
9090
|
+
return this._request(obs$);
|
|
9091
|
+
}
|
|
9092
|
+
fetchAll(_a = {}) {
|
|
9093
|
+
var { withCount } = _a, options = __rest(_a, ["withCount"]);
|
|
9094
|
+
const resource = this.resource();
|
|
9095
|
+
const obs$ = resource.fetchAll(Object.assign({ withCount }, options));
|
|
9096
|
+
return this._request(obs$);
|
|
9056
9097
|
}
|
|
9057
9098
|
/**
|
|
9058
9099
|
* Save all models in the collection
|
|
@@ -9618,6 +9659,12 @@ class ODataCollection {
|
|
|
9618
9659
|
const m = models.find((m) => m.equals(model));
|
|
9619
9660
|
return m === undefined ? -1 : models.indexOf(m);
|
|
9620
9661
|
}
|
|
9662
|
+
isEmpty() {
|
|
9663
|
+
// Local length and if exists remote length
|
|
9664
|
+
return (this.length === 0 &&
|
|
9665
|
+
this.annots().count !== undefined &&
|
|
9666
|
+
this.annots().count === 0);
|
|
9667
|
+
}
|
|
9621
9668
|
//#region Sort
|
|
9622
9669
|
_bisect(model) {
|
|
9623
9670
|
let index = -1;
|
|
@@ -9683,6 +9730,7 @@ class ODataModel {
|
|
|
9683
9730
|
this._changes = new Map();
|
|
9684
9731
|
this._relations = new Map();
|
|
9685
9732
|
this._resource = null;
|
|
9733
|
+
this._annotations = null;
|
|
9686
9734
|
this._reset = false;
|
|
9687
9735
|
this._reparent = false;
|
|
9688
9736
|
this._silent = false;
|
|
@@ -9753,7 +9801,8 @@ class ODataModel {
|
|
|
9753
9801
|
return this._meta.schema;
|
|
9754
9802
|
}
|
|
9755
9803
|
annots() {
|
|
9756
|
-
|
|
9804
|
+
var _a;
|
|
9805
|
+
return (_a = this._annotations) !== null && _a !== void 0 ? _a : new ODataEntityAnnotations(ODataHelper[DEFAULT_VERSION]);
|
|
9757
9806
|
}
|
|
9758
9807
|
key({ field_mapping = false, resolve = true, } = {}) {
|
|
9759
9808
|
return this._meta.resolveKey(this, { field_mapping, resolve });
|
|
@@ -10094,11 +10143,14 @@ class ODataModel {
|
|
|
10094
10143
|
if (model === null)
|
|
10095
10144
|
return null;
|
|
10096
10145
|
if (model === undefined) {
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
|
|
10100
|
-
|
|
10101
|
-
|
|
10146
|
+
if (field.collection) {
|
|
10147
|
+
model = field.collectionFactory({ parent: this });
|
|
10148
|
+
}
|
|
10149
|
+
else {
|
|
10150
|
+
const value = this.referenced(field);
|
|
10151
|
+
model =
|
|
10152
|
+
value === null ? null : field.modelFactory({ parent: this, value });
|
|
10153
|
+
}
|
|
10102
10154
|
this[name] = model;
|
|
10103
10155
|
}
|
|
10104
10156
|
return model;
|
|
@@ -10153,7 +10205,7 @@ class ODataApiOptions {
|
|
|
10153
10205
|
config.nonParenthesisForEmptyParameterFunction || false;
|
|
10154
10206
|
}
|
|
10155
10207
|
get parserOptions() {
|
|
10156
|
-
return Object.assign({ version: this.version }, this.accept);
|
|
10208
|
+
return Object.assign({ version: this.version, stringAsEnum: this.stringAsEnum, deleteRefBy: this.deleteRefBy, nonParenthesisForEmptyParameterFunction: this.nonParenthesisForEmptyParameterFunction }, this.accept);
|
|
10157
10209
|
}
|
|
10158
10210
|
get helper() {
|
|
10159
10211
|
return ODataHelper[this.version];
|
|
@@ -10203,6 +10255,7 @@ class ODataApi {
|
|
|
10203
10255
|
this.requester = settings.requester;
|
|
10204
10256
|
this.schemas.forEach((schema) => {
|
|
10205
10257
|
schema.configure({
|
|
10258
|
+
options: this.options.parserOptions,
|
|
10206
10259
|
parserForType: (type) => this.parserForType(type),
|
|
10207
10260
|
findOptionsForType: (type) => this.findOptionsForType(type),
|
|
10208
10261
|
});
|
|
@@ -10287,16 +10340,54 @@ class ODataApi {
|
|
|
10287
10340
|
const schema = this.findCallableForType(path);
|
|
10288
10341
|
return ODataFunctionResource.factory(this, { path, schema });
|
|
10289
10342
|
}
|
|
10290
|
-
request(req) {
|
|
10343
|
+
//request(req: ODataRequest<any>): Observable<any> {
|
|
10344
|
+
request(method, resource, options) {
|
|
10345
|
+
let req = ODataRequest.factory(this, method, resource, {
|
|
10346
|
+
body: options.body,
|
|
10347
|
+
etag: options.etag,
|
|
10348
|
+
context: options.context,
|
|
10349
|
+
headers: options.headers,
|
|
10350
|
+
params: options.params,
|
|
10351
|
+
responseType: options.responseType,
|
|
10352
|
+
observe: (options.observe === 'events' ? 'events' : 'response'),
|
|
10353
|
+
withCount: options.withCount,
|
|
10354
|
+
bodyQueryOptions: options.bodyQueryOptions,
|
|
10355
|
+
reportProgress: options.reportProgress,
|
|
10356
|
+
fetchPolicy: options.fetchPolicy,
|
|
10357
|
+
withCredentials: options.withCredentials,
|
|
10358
|
+
});
|
|
10291
10359
|
let res$ = this.requester !== undefined ? this.requester(req) : NEVER;
|
|
10292
10360
|
res$ = res$.pipe(map((res) => res.type === HttpEventType.Response
|
|
10293
10361
|
? ODataResponse.fromHttpResponse(req, res)
|
|
10294
10362
|
: res));
|
|
10295
10363
|
if (this.errorHandler !== undefined)
|
|
10296
10364
|
res$ = res$.pipe(catchError(this.errorHandler));
|
|
10297
|
-
|
|
10298
|
-
|
|
10299
|
-
|
|
10365
|
+
if (options.observe === 'events') {
|
|
10366
|
+
return res$;
|
|
10367
|
+
}
|
|
10368
|
+
res$ = this.cache.handleRequest(req, res$);
|
|
10369
|
+
switch (options.observe || 'body') {
|
|
10370
|
+
case 'body':
|
|
10371
|
+
switch (options.responseType) {
|
|
10372
|
+
case 'entities':
|
|
10373
|
+
return res$.pipe(map((res) => res.entities()));
|
|
10374
|
+
case 'entity':
|
|
10375
|
+
return res$.pipe(map((res) => res.entity()));
|
|
10376
|
+
case 'property':
|
|
10377
|
+
return res$.pipe(map((res) => res.property()));
|
|
10378
|
+
case 'value':
|
|
10379
|
+
return res$.pipe(map((res) => res.value()));
|
|
10380
|
+
default:
|
|
10381
|
+
// Other responseTypes (arraybuffer, blob, json, text) return body
|
|
10382
|
+
return res$.pipe(map((res) => res.body));
|
|
10383
|
+
}
|
|
10384
|
+
case 'response':
|
|
10385
|
+
// The response stream was requested directly, so return it.
|
|
10386
|
+
return res$;
|
|
10387
|
+
default:
|
|
10388
|
+
// Guard against new future observe types being added.
|
|
10389
|
+
throw new Error(`Unreachable: unhandled observe type ${options.observe}}`);
|
|
10390
|
+
}
|
|
10300
10391
|
}
|
|
10301
10392
|
findSchemaForType(type) {
|
|
10302
10393
|
const schemas = this.schemas.filter((s) => s.isNamespaceOf(type));
|
|
@@ -10362,8 +10453,9 @@ class ODataApi {
|
|
|
10362
10453
|
Model.buildMeta({ schema });
|
|
10363
10454
|
// Configure
|
|
10364
10455
|
Model.meta.configure({
|
|
10365
|
-
findOptionsForType: (type) => this.findOptionsForType(type),
|
|
10366
10456
|
options: this.options.parserOptions,
|
|
10457
|
+
parserForType: (type) => this.parserForType(type),
|
|
10458
|
+
findOptionsForType: (type) => this.findOptionsForType(type),
|
|
10367
10459
|
});
|
|
10368
10460
|
// Store New Model for next time
|
|
10369
10461
|
schema.model = Model;
|
|
@@ -10706,7 +10798,6 @@ function addBody(options, body) {
|
|
|
10706
10798
|
return {
|
|
10707
10799
|
body,
|
|
10708
10800
|
etag: options.etag,
|
|
10709
|
-
apiName: options.apiName,
|
|
10710
10801
|
fetchPolicy: options.fetchPolicy,
|
|
10711
10802
|
headers: options.headers,
|
|
10712
10803
|
observe: options.observe,
|
|
@@ -10724,6 +10815,7 @@ class ODataClient {
|
|
|
10724
10815
|
this.settings.configure({
|
|
10725
10816
|
requester: (req) => this.http.request(req.method, `${req.url}`, {
|
|
10726
10817
|
body: req.body,
|
|
10818
|
+
context: req.context,
|
|
10727
10819
|
headers: req.headers,
|
|
10728
10820
|
observe: req.observe,
|
|
10729
10821
|
params: req.params,
|
|
@@ -10900,32 +10992,8 @@ class ODataClient {
|
|
|
10900
10992
|
return this.apiFor(apiNameOrType).function(path);
|
|
10901
10993
|
}
|
|
10902
10994
|
request(method, resource, options) {
|
|
10903
|
-
let api =
|
|
10904
|
-
|
|
10905
|
-
: resource.api;
|
|
10906
|
-
if (!api)
|
|
10907
|
-
throw new Error(`The types: '[${resource
|
|
10908
|
-
.types()
|
|
10909
|
-
.join(', ')}]' does not belongs to any known configuration`);
|
|
10910
|
-
const request = new ODataRequest({
|
|
10911
|
-
method,
|
|
10912
|
-
api,
|
|
10913
|
-
resource,
|
|
10914
|
-
body: options.body,
|
|
10915
|
-
observe: options.observe === 'events' ? 'events' : 'response',
|
|
10916
|
-
etag: options.etag,
|
|
10917
|
-
headers: options.headers,
|
|
10918
|
-
reportProgress: options.reportProgress,
|
|
10919
|
-
params: options.params,
|
|
10920
|
-
responseType: options.responseType,
|
|
10921
|
-
fetchPolicy: options.fetchPolicy,
|
|
10922
|
-
withCredentials: options.withCredentials,
|
|
10923
|
-
});
|
|
10924
|
-
return api
|
|
10925
|
-
.request(request)
|
|
10926
|
-
.pipe(map((res) => options.observe === undefined || options.observe === 'body'
|
|
10927
|
-
? res.body
|
|
10928
|
-
: res));
|
|
10995
|
+
let api = this.apiFor(resource);
|
|
10996
|
+
return api.request(method, resource, options);
|
|
10929
10997
|
}
|
|
10930
10998
|
delete(resource, options = {}) {
|
|
10931
10999
|
return this.request('DELETE', resource, addBody(options, null));
|
|
@@ -11042,8 +11110,8 @@ class ODataEntitySetService extends ODataEntityService {
|
|
|
11042
11110
|
* @param withCount Get the count of the entities.
|
|
11043
11111
|
* @param options The options for the request.
|
|
11044
11112
|
*/
|
|
11045
|
-
fetchMany(options) {
|
|
11046
|
-
return this.entities().
|
|
11113
|
+
fetchMany(top, options) {
|
|
11114
|
+
return this.entities().fetchMany(top, options);
|
|
11047
11115
|
}
|
|
11048
11116
|
/**
|
|
11049
11117
|
* Get an entity from the entity set.
|
|
@@ -11051,8 +11119,8 @@ class ODataEntitySetService extends ODataEntityService {
|
|
|
11051
11119
|
* @param etag The etag for the entity.
|
|
11052
11120
|
* @param options The options for the request.
|
|
11053
11121
|
*/
|
|
11054
|
-
fetchOne(
|
|
11055
|
-
return this.
|
|
11122
|
+
fetchOne(options) {
|
|
11123
|
+
return this.entities().fetchOne(options);
|
|
11056
11124
|
}
|
|
11057
11125
|
/**
|
|
11058
11126
|
* Create an entity in the entity set.
|
|
@@ -11110,11 +11178,11 @@ class ODataEntitySetService extends ODataEntityService {
|
|
|
11110
11178
|
*/
|
|
11111
11179
|
fetchOrCreate(key, attrs, _a = {}) {
|
|
11112
11180
|
var { etag } = _a, options = __rest(_a, ["etag"]);
|
|
11113
|
-
return this.
|
|
11181
|
+
return this.entity(key).fetch(Object.assign({ etag }, options)).pipe(catchError((error) => {
|
|
11114
11182
|
if (error.status === 404)
|
|
11115
11183
|
return this.create(attrs, options);
|
|
11116
11184
|
else
|
|
11117
|
-
return throwError(error);
|
|
11185
|
+
return throwError(() => error);
|
|
11118
11186
|
}));
|
|
11119
11187
|
}
|
|
11120
11188
|
/**
|