angular-odata 0.102.5 → 0.105.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 +4 -2
- package/esm2020/lib/client.mjs +3 -3
- package/esm2020/lib/helper.mjs +7 -10
- package/esm2020/lib/models/collection.mjs +10 -4
- package/esm2020/lib/models/model.mjs +9 -6
- package/esm2020/lib/models/options.mjs +44 -23
- package/esm2020/lib/module.mjs +4 -4
- 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/resource.mjs +7 -10
- package/esm2020/lib/resources/responses/annotations.mjs +7 -1
- 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 +11 -3
- 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/factory.mjs +3 -3
- package/esm2020/lib/types.mjs +1 -1
- package/esm2020/lib/utils/enums.mjs +1 -1
- package/fesm2015/angular-odata.mjs +214 -212
- package/fesm2015/angular-odata.mjs.map +1 -1
- package/fesm2020/angular-odata.mjs +202 -174
- package/fesm2020/angular-odata.mjs.map +1 -1
- package/lib/helper.d.ts +3 -0
- package/lib/models/collection.d.ts +3 -2
- package/lib/models/options.d.ts +12 -6
- 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/responses/annotations.d.ts +3 -0
- 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/types.d.ts +4 -1
- package/package.json +1 -1
|
@@ -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
|
}, {});
|
|
@@ -3421,42 +3402,38 @@ const ODataVersionBaseHelper = {
|
|
|
3421
3402
|
};
|
|
3422
3403
|
const ODataHelper = {
|
|
3423
3404
|
//#region Version 4.0
|
|
3424
|
-
[VERSION_4_0]: Object.assign({}, ODataVersionBaseHelper, {
|
|
3425
|
-
VALUE: 'value',
|
|
3426
|
-
ODATA_ANNOTATION_PREFIX: '@odata',
|
|
3427
|
-
ODATA_FUNCTION_PREFIX: '#',
|
|
3405
|
+
[VERSION_4_0]: Object.assign(Object.assign({}, ODataVersionBaseHelper), { VALUE: 'value', ODATA_ANNOTATION_PREFIX: '@odata', ODATA_FUNCTION_PREFIX: '#',
|
|
3428
3406
|
//odata.id: the ID of the entity
|
|
3429
|
-
ODATA_ID: '@odata.id',
|
|
3407
|
+
ODATA_ID: '@odata.id',
|
|
3430
3408
|
//odata.count: the total count of a collection of entities or collection of entity references, if requested.
|
|
3431
|
-
ODATA_COUNT: '@odata.count',
|
|
3409
|
+
ODATA_COUNT: '@odata.count',
|
|
3432
3410
|
//odata.context: the context URL for a collection, entity, primitive value, or service document.
|
|
3433
|
-
ODATA_CONTEXT: '@odata.context',
|
|
3411
|
+
ODATA_CONTEXT: '@odata.context',
|
|
3434
3412
|
//odata.etag: the ETag of the entity
|
|
3435
|
-
ODATA_ETAG: '@odata.etag',
|
|
3436
|
-
ODATA_METADATA_ETAG: '@odata.metadataEtag',
|
|
3413
|
+
ODATA_ETAG: '@odata.etag', ODATA_METADATA_ETAG: '@odata.metadataEtag',
|
|
3437
3414
|
//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',
|
|
3415
|
+
ODATA_TYPE: '@odata.type',
|
|
3439
3416
|
//odata.nextLink: the next link of a collection with partial results
|
|
3440
|
-
ODATA_NEXTLINK: '@odata.nextLink',
|
|
3417
|
+
ODATA_NEXTLINK: '@odata.nextLink',
|
|
3441
3418
|
//odata.deltaLink: the delta link for obtaining changes to the result, if requested
|
|
3442
|
-
ODATA_DELTALINK: '@odata.deltaLink',
|
|
3419
|
+
ODATA_DELTALINK: '@odata.deltaLink',
|
|
3443
3420
|
//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',
|
|
3421
|
+
ODATA_READLINK: '@odata.readLink',
|
|
3445
3422
|
//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',
|
|
3423
|
+
ODATA_EDITLINK: '@odata.editLink',
|
|
3447
3424
|
//odata.associationLink: the link used to describe the relationship between this entity and related entities
|
|
3448
|
-
ODATA_ASSOCIATIONLINK: '@odata.associationLink',
|
|
3425
|
+
ODATA_ASSOCIATIONLINK: '@odata.associationLink',
|
|
3449
3426
|
//odata.navigationLink: the link used to retrieve the values of a navigation property
|
|
3450
|
-
ODATA_NAVIGATIONLINK: '@odata.navigationLink',
|
|
3427
|
+
ODATA_NAVIGATIONLINK: '@odata.navigationLink',
|
|
3451
3428
|
//Media entities and stream properties may in addition contain the following annotations:
|
|
3452
3429
|
//odata.mediaEtag: the ETag of the stream, as appropriate
|
|
3453
|
-
ODATA_MEDIA_ETAG: '@odata.mediaEtag',
|
|
3430
|
+
ODATA_MEDIA_ETAG: '@odata.mediaEtag',
|
|
3454
3431
|
//odata.mediaContentType: the content type of the stream
|
|
3455
|
-
ODATA_MEDIA_CONTENTTYPE: '@odata.mediaContentType',
|
|
3432
|
+
ODATA_MEDIA_CONTENTTYPE: '@odata.mediaContentType',
|
|
3456
3433
|
//odata.mediaReadLink: the link used to read the stream
|
|
3457
|
-
ODATA_MEDIA_READLINK: '@odata.mediaReadLink',
|
|
3434
|
+
ODATA_MEDIA_READLINK: '@odata.mediaReadLink',
|
|
3458
3435
|
//odata.mediaEditLink: the link used to edit/update the stream
|
|
3459
|
-
ODATA_MEDIA_EDITLINK: '@odata.mediaEditLink',
|
|
3436
|
+
ODATA_MEDIA_EDITLINK: '@odata.mediaEditLink',
|
|
3460
3437
|
//http://nb-mdp-dev01:57970/$metadata#recursos/$entity
|
|
3461
3438
|
//http://nb-mdp-dev01:57970/$metadata#categorias
|
|
3462
3439
|
//http://nb-mdp-dev01:57970/$metadata#juzgados
|
|
@@ -3505,21 +3482,10 @@ const ODataHelper = {
|
|
|
3505
3482
|
},
|
|
3506
3483
|
countParam() {
|
|
3507
3484
|
return { [$COUNT]: 'true' };
|
|
3508
|
-
},
|
|
3509
|
-
}),
|
|
3485
|
+
} }),
|
|
3510
3486
|
//#endregion
|
|
3511
3487
|
//#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) {
|
|
3488
|
+
[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
3489
|
let ctx = {};
|
|
3524
3490
|
const str = annots instanceof Map
|
|
3525
3491
|
? annots.get(this.ODATA_CONTEXT)
|
|
@@ -3536,20 +3502,10 @@ const ODataHelper = {
|
|
|
3536
3502
|
},
|
|
3537
3503
|
countParam() {
|
|
3538
3504
|
return { [$INLINECOUNT]: 'allpages' };
|
|
3539
|
-
},
|
|
3540
|
-
}),
|
|
3505
|
+
} }),
|
|
3541
3506
|
//#endregion
|
|
3542
3507
|
//#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) {
|
|
3508
|
+
[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
3509
|
const annots = new Map();
|
|
3554
3510
|
if (this.ODATA_ANNOTATION in value) {
|
|
3555
3511
|
Object.entries(value[this.ODATA_ANNOTATION]).forEach(([key, value]) => annots.set(key, value));
|
|
@@ -3561,8 +3517,7 @@ const ODataHelper = {
|
|
|
3561
3517
|
},
|
|
3562
3518
|
countParam() {
|
|
3563
3519
|
return { [$INLINECOUNT]: 'allpages' };
|
|
3564
|
-
},
|
|
3565
|
-
}),
|
|
3520
|
+
} }),
|
|
3566
3521
|
//#endregion
|
|
3567
3522
|
};
|
|
3568
3523
|
|
|
@@ -3764,12 +3719,20 @@ const EDM_PARSERS = {
|
|
|
3764
3719
|
return v;
|
|
3765
3720
|
}, (v, o) => {
|
|
3766
3721
|
if (o.ieee754Compatible) {
|
|
3767
|
-
|
|
3722
|
+
let vstr = v.toPrecision(o.field.precision);
|
|
3723
|
+
if (typeof o.field.scale === 'number') {
|
|
3724
|
+
vstr = parseFloat(vstr).toFixed(o.field.scale);
|
|
3725
|
+
}
|
|
3726
|
+
return vstr;
|
|
3768
3727
|
}
|
|
3769
3728
|
return v;
|
|
3770
3729
|
}, (v, o) => {
|
|
3771
3730
|
if (o.ieee754Compatible) {
|
|
3772
|
-
|
|
3731
|
+
let vstr = v.toPrecision(o.field.precision);
|
|
3732
|
+
if (typeof o.field.scale === 'number') {
|
|
3733
|
+
vstr = parseFloat(vstr).toFixed(o.field.scale);
|
|
3734
|
+
}
|
|
3735
|
+
return vstr;
|
|
3773
3736
|
}
|
|
3774
3737
|
return v;
|
|
3775
3738
|
}),
|
|
@@ -3820,17 +3783,7 @@ class ODataEnumTypeParser extends ODataAnnotatable {
|
|
|
3820
3783
|
this.members = config.members;
|
|
3821
3784
|
this._fields = Object.entries(config.fields).map(([name, f]) => new ODataEnumTypeFieldParser(name, f));
|
|
3822
3785
|
}
|
|
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;
|
|
3786
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
3834
3787
|
this.parserOptions = options;
|
|
3835
3788
|
}
|
|
3836
3789
|
isTypeOf(type) {
|
|
@@ -3862,7 +3815,7 @@ class ODataEnumTypeParser extends ODataAnnotatable {
|
|
|
3862
3815
|
// Deserialize
|
|
3863
3816
|
deserialize(value, options) {
|
|
3864
3817
|
// string -> number
|
|
3865
|
-
const parserOptions =
|
|
3818
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
3866
3819
|
if (this.flags) {
|
|
3867
3820
|
return Enums.toValues(this.members, value).reduce((acc, v) => acc | v, 0);
|
|
3868
3821
|
}
|
|
@@ -3874,31 +3827,33 @@ class ODataEnumTypeParser extends ODataAnnotatable {
|
|
|
3874
3827
|
serialize(value, options) {
|
|
3875
3828
|
// Enum are string | number
|
|
3876
3829
|
// string | number -> string
|
|
3877
|
-
const parserOptions =
|
|
3830
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
3878
3831
|
if (this.flags) {
|
|
3879
|
-
|
|
3832
|
+
let names = Enums.toNames(this.members, value);
|
|
3880
3833
|
if (names.length === 0)
|
|
3881
|
-
|
|
3882
|
-
return !
|
|
3834
|
+
names = [`${value}`];
|
|
3835
|
+
return !(parserOptions === null || parserOptions === void 0 ? void 0 : parserOptions.stringAsEnum)
|
|
3883
3836
|
? `${this.namespace}.${this.name}'${names.join(', ')}'`
|
|
3884
3837
|
: names.join(', ');
|
|
3885
3838
|
}
|
|
3886
3839
|
else {
|
|
3887
|
-
|
|
3840
|
+
let name = Enums.toName(this.members, value);
|
|
3888
3841
|
if (name === undefined)
|
|
3889
|
-
|
|
3890
|
-
return !
|
|
3842
|
+
name = `${value}`;
|
|
3843
|
+
return !(parserOptions === null || parserOptions === void 0 ? void 0 : parserOptions.stringAsEnum)
|
|
3891
3844
|
? `${this.namespace}.${this.name}'${name}'`
|
|
3892
3845
|
: name;
|
|
3893
3846
|
}
|
|
3894
3847
|
}
|
|
3895
3848
|
//Encode
|
|
3896
3849
|
encode(value, options) {
|
|
3897
|
-
const parserOptions =
|
|
3850
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
3898
3851
|
const serialized = this.serialize(value, parserOptions);
|
|
3899
3852
|
if (serialized === undefined)
|
|
3900
3853
|
return undefined;
|
|
3901
|
-
return
|
|
3854
|
+
return (parserOptions === null || parserOptions === void 0 ? void 0 : parserOptions.stringAsEnum)
|
|
3855
|
+
? raw(`'${serialized}'`)
|
|
3856
|
+
: raw(serialized);
|
|
3902
3857
|
}
|
|
3903
3858
|
// Json Schema
|
|
3904
3859
|
toJsonSchema() {
|
|
@@ -3920,6 +3875,12 @@ class ODataEnumTypeParser extends ODataAnnotatable {
|
|
|
3920
3875
|
return !(member in this.members) ? ['mismatch'] : undefined;
|
|
3921
3876
|
}
|
|
3922
3877
|
}
|
|
3878
|
+
unpack(value) {
|
|
3879
|
+
return Enums.toValues(this.members, value);
|
|
3880
|
+
}
|
|
3881
|
+
pack(value) {
|
|
3882
|
+
return Enums.toValues(this.members, value).reduce((acc, v) => acc | v, 0);
|
|
3883
|
+
}
|
|
3923
3884
|
}
|
|
3924
3885
|
|
|
3925
3886
|
class ODataEntityTypeKey {
|
|
@@ -3998,7 +3959,7 @@ class ODataStructuredTypeFieldParser extends ODataAnnotatable {
|
|
|
3998
3959
|
return parser.deserialize(value, options);
|
|
3999
3960
|
}
|
|
4000
3961
|
deserialize(value, options) {
|
|
4001
|
-
const parserOptions =
|
|
3962
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4002
3963
|
if (this.parser instanceof ODataStructuredTypeParser) {
|
|
4003
3964
|
const parser = this.parser;
|
|
4004
3965
|
return Array.isArray(value)
|
|
@@ -4021,7 +3982,7 @@ class ODataStructuredTypeFieldParser extends ODataAnnotatable {
|
|
|
4021
3982
|
return parser.serialize(value, options);
|
|
4022
3983
|
}
|
|
4023
3984
|
serialize(value, options) {
|
|
4024
|
-
const parserOptions =
|
|
3985
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4025
3986
|
if (this.parser instanceof ODataStructuredTypeParser) {
|
|
4026
3987
|
const parser = this.parser;
|
|
4027
3988
|
return Array.isArray(value)
|
|
@@ -4033,11 +3994,11 @@ class ODataStructuredTypeFieldParser extends ODataAnnotatable {
|
|
|
4033
3994
|
//#endregion
|
|
4034
3995
|
//#region Encode
|
|
4035
3996
|
encode(value, options) {
|
|
4036
|
-
const parserOptions =
|
|
3997
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4037
3998
|
return this.parser.encode(value, Object.assign({ field: this }, parserOptions));
|
|
4038
3999
|
}
|
|
4039
4000
|
//#endregion
|
|
4040
|
-
configure({ parserForType,
|
|
4001
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
4041
4002
|
this.parserOptions = options;
|
|
4042
4003
|
this.parser = parserForType(this.type);
|
|
4043
4004
|
if (this.default !== undefined) {
|
|
@@ -4182,7 +4143,7 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
|
|
|
4182
4143
|
}
|
|
4183
4144
|
// Deserialize
|
|
4184
4145
|
deserialize(value, options) {
|
|
4185
|
-
const parserOptions =
|
|
4146
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4186
4147
|
const fields = this.fields({
|
|
4187
4148
|
include_navigation: true,
|
|
4188
4149
|
include_parents: true,
|
|
@@ -4191,7 +4152,7 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
|
|
|
4191
4152
|
}
|
|
4192
4153
|
// Serialize
|
|
4193
4154
|
serialize(value, options) {
|
|
4194
|
-
const parserOptions =
|
|
4155
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4195
4156
|
const fields = this.fields({
|
|
4196
4157
|
include_navigation: true,
|
|
4197
4158
|
include_parents: true,
|
|
@@ -4202,17 +4163,17 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
|
|
|
4202
4163
|
}
|
|
4203
4164
|
// Encode
|
|
4204
4165
|
encode(value, options) {
|
|
4205
|
-
const parserOptions =
|
|
4166
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4206
4167
|
return raw(JSON.stringify(this.serialize(value, parserOptions)));
|
|
4207
4168
|
}
|
|
4208
|
-
configure({ parserForType,
|
|
4169
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
4209
4170
|
this.parserOptions = options;
|
|
4210
4171
|
if (this.base) {
|
|
4211
4172
|
const parent = parserForType(this.base);
|
|
4212
4173
|
parent.children.push(this);
|
|
4213
4174
|
this.parent = parent;
|
|
4214
4175
|
}
|
|
4215
|
-
this._fields.forEach((f) => f.configure({ parserForType,
|
|
4176
|
+
this._fields.forEach((f) => f.configure({ options, parserForType, findOptionsForType }));
|
|
4216
4177
|
}
|
|
4217
4178
|
/**
|
|
4218
4179
|
* Returns all fields of the structured type.
|
|
@@ -4379,19 +4340,19 @@ class ODataParameterParser {
|
|
|
4379
4340
|
this.collection = parameter.collection;
|
|
4380
4341
|
}
|
|
4381
4342
|
serialize(value, options) {
|
|
4382
|
-
const parserOptions =
|
|
4343
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4383
4344
|
return Array.isArray(value)
|
|
4384
4345
|
? value.map((v) => this.parser.serialize(v, parserOptions))
|
|
4385
4346
|
: this.parser.serialize(value, parserOptions);
|
|
4386
4347
|
}
|
|
4387
4348
|
//Encode
|
|
4388
4349
|
encode(value, options) {
|
|
4389
|
-
const parserOptions =
|
|
4350
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4390
4351
|
return Array.isArray(value)
|
|
4391
4352
|
? value.map((v) => this.parser.encode(v, parserOptions))
|
|
4392
4353
|
: this.parser.encode(value, parserOptions);
|
|
4393
4354
|
}
|
|
4394
|
-
configure({ parserForType,
|
|
4355
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
4395
4356
|
this.parserOptions = options;
|
|
4396
4357
|
this.parser = parserForType(this.type);
|
|
4397
4358
|
}
|
|
@@ -4437,12 +4398,12 @@ class ODataCallableParser {
|
|
|
4437
4398
|
}
|
|
4438
4399
|
// Deserialize
|
|
4439
4400
|
deserialize(value, options) {
|
|
4440
|
-
const parserOptions =
|
|
4401
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4441
4402
|
return this.parser.deserialize(value, parserOptions);
|
|
4442
4403
|
}
|
|
4443
4404
|
// Serialize
|
|
4444
4405
|
serialize(params, options) {
|
|
4445
|
-
const parserOptions =
|
|
4406
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4446
4407
|
const parameters = this.parameters
|
|
4447
4408
|
.filter((p) => p.name !== CALLABLE_BINDING_PARAMETER)
|
|
4448
4409
|
.filter((p) => p.name in params && params[p.name] !== undefined);
|
|
@@ -4450,19 +4411,17 @@ class ODataCallableParser {
|
|
|
4450
4411
|
}
|
|
4451
4412
|
//Encode
|
|
4452
4413
|
encode(params, options) {
|
|
4453
|
-
const parserOptions =
|
|
4414
|
+
const parserOptions = Object.assign(Object.assign({}, this.parserOptions), options);
|
|
4454
4415
|
const parameters = this.parameters
|
|
4455
4416
|
.filter((p) => p.name !== CALLABLE_BINDING_PARAMETER)
|
|
4456
4417
|
.filter((p) => p.name in params && params[p.name] !== undefined);
|
|
4457
4418
|
return parameters.reduce((acc, p) => (Object.assign(Object.assign({}, acc), { [p.name]: p.encode(params[p.name], parserOptions) })), {});
|
|
4458
4419
|
}
|
|
4459
|
-
configure({
|
|
4460
|
-
this.nonParenthesisForEmptyParameterFunction =
|
|
4461
|
-
nonParenthesisForEmptyParameterFunction;
|
|
4420
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
4462
4421
|
this.parserOptions = options;
|
|
4463
4422
|
if (this.return)
|
|
4464
4423
|
this.parser = parserForType(this.return.type) || NONE_PARSER;
|
|
4465
|
-
this.parameters.forEach((p) => p.configure({ parserForType,
|
|
4424
|
+
this.parameters.forEach((p) => p.configure({ options, parserForType, findOptionsForType }));
|
|
4466
4425
|
}
|
|
4467
4426
|
binding() {
|
|
4468
4427
|
return this.parameters.find((p) => p.name === CALLABLE_BINDING_PARAMETER);
|
|
@@ -4491,11 +4450,11 @@ class ODataCallable extends ODataSchemaElement {
|
|
|
4491
4450
|
: this.name;
|
|
4492
4451
|
return path;
|
|
4493
4452
|
}
|
|
4494
|
-
configure({ parserForType, }) {
|
|
4453
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
4495
4454
|
this.parser.configure({
|
|
4496
|
-
|
|
4497
|
-
options: this.api.options.parserOptions,
|
|
4455
|
+
options,
|
|
4498
4456
|
parserForType,
|
|
4457
|
+
findOptionsForType,
|
|
4499
4458
|
});
|
|
4500
4459
|
}
|
|
4501
4460
|
/**
|
|
@@ -4555,11 +4514,8 @@ class ODataEnumType extends ODataSchemaElement {
|
|
|
4555
4514
|
this.members = config.members;
|
|
4556
4515
|
this.parser = new ODataEnumTypeParser(config, schema.namespace, schema.alias);
|
|
4557
4516
|
}
|
|
4558
|
-
configure() {
|
|
4559
|
-
this.parser.configure({
|
|
4560
|
-
stringAsEnum: this.api.options.stringAsEnum,
|
|
4561
|
-
options: this.api.options.parserOptions,
|
|
4562
|
-
});
|
|
4517
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
4518
|
+
this.parser.configure({ options, parserForType, findOptionsForType });
|
|
4563
4519
|
}
|
|
4564
4520
|
/**
|
|
4565
4521
|
* Returns the fields of the enum type.
|
|
@@ -4611,6 +4567,12 @@ class ODataEnumType extends ODataSchemaElement {
|
|
|
4611
4567
|
encode(value, options) {
|
|
4612
4568
|
return this.parser.encode(value, options);
|
|
4613
4569
|
}
|
|
4570
|
+
unpack(value) {
|
|
4571
|
+
return this.parser.unpack(value);
|
|
4572
|
+
}
|
|
4573
|
+
pack(value) {
|
|
4574
|
+
return this.parser.pack(value);
|
|
4575
|
+
}
|
|
4614
4576
|
}
|
|
4615
4577
|
|
|
4616
4578
|
class ODataStructuredType extends ODataSchemaElement {
|
|
@@ -4632,20 +4594,22 @@ class ODataStructuredType extends ODataSchemaElement {
|
|
|
4632
4594
|
this.collection.model = this.model;
|
|
4633
4595
|
}
|
|
4634
4596
|
}
|
|
4635
|
-
configure({ parserForType, findOptionsForType, }) {
|
|
4597
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
4636
4598
|
if (this.base) {
|
|
4637
4599
|
const parent = this.api.findStructuredTypeForType(this.base);
|
|
4638
4600
|
parent.children.push(this);
|
|
4639
4601
|
this.parent = parent;
|
|
4640
4602
|
}
|
|
4641
4603
|
this.parser.configure({
|
|
4604
|
+
options,
|
|
4642
4605
|
parserForType,
|
|
4643
|
-
|
|
4606
|
+
findOptionsForType,
|
|
4644
4607
|
});
|
|
4645
4608
|
if (this.model !== undefined && this.model.options !== null) {
|
|
4646
4609
|
this.model.meta.configure({
|
|
4610
|
+
options,
|
|
4611
|
+
parserForType,
|
|
4647
4612
|
findOptionsForType,
|
|
4648
|
-
options: this.api.options.parserOptions,
|
|
4649
4613
|
});
|
|
4650
4614
|
}
|
|
4651
4615
|
}
|
|
@@ -4851,13 +4815,13 @@ class ODataSchema extends ODataAnnotatable {
|
|
|
4851
4815
|
return this.entitySets.find((e) => e.isTypeOf(type));
|
|
4852
4816
|
}
|
|
4853
4817
|
//#endregion
|
|
4854
|
-
configure({ parserForType, findOptionsForType, }) {
|
|
4818
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
4855
4819
|
// Configure Enums
|
|
4856
|
-
this.enums.forEach((enu) => enu.configure());
|
|
4820
|
+
this.enums.forEach((enu) => enu.configure({ options, parserForType, findOptionsForType }));
|
|
4857
4821
|
// Configure Entities
|
|
4858
|
-
this.entities.forEach((config) => config.configure({ parserForType, findOptionsForType }));
|
|
4822
|
+
this.entities.forEach((config) => config.configure({ options, parserForType, findOptionsForType }));
|
|
4859
4823
|
// Configure callables
|
|
4860
|
-
this.callables.forEach((callable) => callable.configure({ parserForType }));
|
|
4824
|
+
this.callables.forEach((callable) => callable.configure({ options, parserForType, findOptionsForType }));
|
|
4861
4825
|
}
|
|
4862
4826
|
}
|
|
4863
4827
|
|
|
@@ -5000,7 +4964,6 @@ class ODataResource {
|
|
|
5000
4964
|
return undefined;
|
|
5001
4965
|
}
|
|
5002
4966
|
deserialize(value, options) {
|
|
5003
|
-
const parserOptions = options || this.api.options.parserOptions;
|
|
5004
4967
|
const resourceType = this.returnType();
|
|
5005
4968
|
const _d = (value, options) => {
|
|
5006
4969
|
const parser = this.__parser(value, options, resourceType);
|
|
@@ -5009,11 +4972,10 @@ class ODataResource {
|
|
|
5009
4972
|
: value;
|
|
5010
4973
|
};
|
|
5011
4974
|
return Array.isArray(value)
|
|
5012
|
-
? value.map((v) => _d(v,
|
|
5013
|
-
: _d(value,
|
|
4975
|
+
? value.map((v) => _d(v, options))
|
|
4976
|
+
: _d(value, options);
|
|
5014
4977
|
}
|
|
5015
4978
|
serialize(value, options) {
|
|
5016
|
-
const parserOptions = options || this.api.options.parserOptions;
|
|
5017
4979
|
const resourceType = this.type();
|
|
5018
4980
|
const _s = (value, options) => {
|
|
5019
4981
|
const parser = this.__parser(value, options, resourceType);
|
|
@@ -5022,11 +4984,10 @@ class ODataResource {
|
|
|
5022
4984
|
: value;
|
|
5023
4985
|
};
|
|
5024
4986
|
return Array.isArray(value)
|
|
5025
|
-
? value.map((v) => _s(v,
|
|
5026
|
-
: _s(value,
|
|
4987
|
+
? value.map((v) => _s(v, options))
|
|
4988
|
+
: _s(value, options);
|
|
5027
4989
|
}
|
|
5028
4990
|
encode(value, options) {
|
|
5029
|
-
const parserOptions = options || this.api.options.parserOptions;
|
|
5030
4991
|
const resourceType = this.type();
|
|
5031
4992
|
const _e = (value, options) => {
|
|
5032
4993
|
const parser = this.__parser(value, options, resourceType);
|
|
@@ -5035,8 +4996,8 @@ class ODataResource {
|
|
|
5035
4996
|
: value;
|
|
5036
4997
|
};
|
|
5037
4998
|
return Array.isArray(value)
|
|
5038
|
-
? value.map((v) => _e(v,
|
|
5039
|
-
: _e(value,
|
|
4999
|
+
? value.map((v) => _e(v, options))
|
|
5000
|
+
: _e(value, options);
|
|
5040
5001
|
}
|
|
5041
5002
|
toJSON() {
|
|
5042
5003
|
return {
|
|
@@ -6503,6 +6464,12 @@ class ODataAnnotations {
|
|
|
6503
6464
|
attributes(data, metadata) {
|
|
6504
6465
|
return this.helper.attributes(data, metadata);
|
|
6505
6466
|
}
|
|
6467
|
+
update(data) {
|
|
6468
|
+
this.annotations = new Map([
|
|
6469
|
+
...this.annotations,
|
|
6470
|
+
...this.helper.annotations(data),
|
|
6471
|
+
]);
|
|
6472
|
+
}
|
|
6506
6473
|
get entitySet() {
|
|
6507
6474
|
var _a;
|
|
6508
6475
|
return (_a = this.context) === null || _a === void 0 ? void 0 : _a.entitySet;
|
|
@@ -8083,23 +8050,39 @@ class ODataModelField {
|
|
|
8083
8050
|
schemaFactory(base) {
|
|
8084
8051
|
return this.api.findStructuredTypeForType(this.parser.type);
|
|
8085
8052
|
}
|
|
8086
|
-
|
|
8053
|
+
modelFactory({ parent, value, reset, }) {
|
|
8054
|
+
var _a;
|
|
8055
|
+
// Model
|
|
8056
|
+
const annots = this.annotationsFactory(parent.annots());
|
|
8057
|
+
let Model = this.api.modelForType(this.parser.type);
|
|
8058
|
+
if (Model === undefined)
|
|
8059
|
+
throw Error(`No Model type for ${this.name}`);
|
|
8060
|
+
if (value !== undefined) {
|
|
8061
|
+
annots.update(value);
|
|
8062
|
+
}
|
|
8063
|
+
if ((annots === null || annots === void 0 ? void 0 : annots.type) !== undefined && Model.meta !== null) {
|
|
8064
|
+
let schema = (_a = Model.meta.findChildOptions((o) => o.isTypeOf(annots.type))) === null || _a === void 0 ? void 0 : _a.schema;
|
|
8065
|
+
if (schema !== undefined && schema.model !== undefined)
|
|
8066
|
+
// Change to child model
|
|
8067
|
+
Model = schema.model;
|
|
8068
|
+
}
|
|
8069
|
+
return new Model((value || {}), {
|
|
8070
|
+
annots,
|
|
8071
|
+
reset,
|
|
8072
|
+
parent: [parent, this],
|
|
8073
|
+
});
|
|
8074
|
+
}
|
|
8075
|
+
collectionFactory({ parent, value, reset, }) {
|
|
8076
|
+
// Collection Factory
|
|
8087
8077
|
const annots = this.annotationsFactory(parent.annots());
|
|
8088
|
-
const Model = this.api.modelForType(this.parser.type);
|
|
8089
8078
|
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
|
-
});
|
|
8079
|
+
if (Collection === undefined)
|
|
8080
|
+
throw Error(`No Collection type for ${this.name}`);
|
|
8081
|
+
return new Collection((value || []), {
|
|
8082
|
+
annots: annots,
|
|
8083
|
+
parent: [parent, this],
|
|
8084
|
+
reset,
|
|
8085
|
+
});
|
|
8103
8086
|
}
|
|
8104
8087
|
}
|
|
8105
8088
|
class ODataModelOptions {
|
|
@@ -8153,7 +8136,7 @@ class ODataModelOptions {
|
|
|
8153
8136
|
}
|
|
8154
8137
|
return match;
|
|
8155
8138
|
}
|
|
8156
|
-
configure({
|
|
8139
|
+
configure({ options, parserForType, findOptionsForType, }) {
|
|
8157
8140
|
if (this.base) {
|
|
8158
8141
|
const parent = findOptionsForType(this.base);
|
|
8159
8142
|
parent.children.push(this);
|
|
@@ -8424,8 +8407,9 @@ class ODataModelOptions {
|
|
|
8424
8407
|
(model != undefined && model.hasChanged({ include_navigation })))));
|
|
8425
8408
|
}
|
|
8426
8409
|
asEntity(self, func) {
|
|
8410
|
+
var _a;
|
|
8427
8411
|
// Build new resource
|
|
8428
|
-
const query = self.
|
|
8412
|
+
const query = (_a = self._resource) === null || _a === void 0 ? void 0 : _a.cloneQuery();
|
|
8429
8413
|
let resource = this.modelResourceFactory(query);
|
|
8430
8414
|
if (resource === undefined)
|
|
8431
8415
|
throw new Error('Model does not have associated Entity endpoint');
|
|
@@ -8768,11 +8752,17 @@ class ODataModelOptions {
|
|
|
8768
8752
|
ODataModelOptions.isCollection(value) ||
|
|
8769
8753
|
ODataModelOptions.isModel(value)
|
|
8770
8754
|
? value
|
|
8771
|
-
: field.
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
|
|
8755
|
+
: field.collection
|
|
8756
|
+
? field.collectionFactory({
|
|
8757
|
+
parent: self,
|
|
8758
|
+
value: value,
|
|
8759
|
+
reset: self._reset,
|
|
8760
|
+
})
|
|
8761
|
+
: field.modelFactory({
|
|
8762
|
+
parent: self,
|
|
8763
|
+
value: value,
|
|
8764
|
+
reset: self._reset,
|
|
8765
|
+
});
|
|
8776
8766
|
// Link new model/collection
|
|
8777
8767
|
this._link(self, relation);
|
|
8778
8768
|
changed = true;
|
|
@@ -8913,6 +8903,12 @@ class ODataCollection {
|
|
|
8913
8903
|
get length() {
|
|
8914
8904
|
return this.models().length;
|
|
8915
8905
|
}
|
|
8906
|
+
isEmpty() {
|
|
8907
|
+
// Local length and if exists remote length
|
|
8908
|
+
return (this.length === 0 &&
|
|
8909
|
+
this.annots().count !== undefined &&
|
|
8910
|
+
this.annots().count === 0);
|
|
8911
|
+
}
|
|
8916
8912
|
isParentOf(child) {
|
|
8917
8913
|
return (child !== this &&
|
|
8918
8914
|
ODataModelOptions.chain(child).some((p) => p[0] === this));
|
|
@@ -8940,8 +8936,9 @@ class ODataCollection {
|
|
|
8940
8936
|
}
|
|
8941
8937
|
}
|
|
8942
8938
|
asEntitySet(func) {
|
|
8939
|
+
var _a;
|
|
8943
8940
|
// Build new resource
|
|
8944
|
-
const query = this.
|
|
8941
|
+
const query = (_a = this._resource) === null || _a === void 0 ? void 0 : _a.cloneQuery();
|
|
8945
8942
|
let resource = this._model.meta.collectionResourceFactory(query);
|
|
8946
8943
|
if (resource === undefined)
|
|
8947
8944
|
throw new Error('asEntitySet: Collection does not have associated EntitySet endpoint');
|
|
@@ -8972,8 +8969,8 @@ class ODataCollection {
|
|
|
8972
8969
|
modelFactory(data, { reset = false } = {}) {
|
|
8973
8970
|
var _a;
|
|
8974
8971
|
let Model = this._model;
|
|
8975
|
-
const
|
|
8976
|
-
|
|
8972
|
+
const annots = new ODataEntityAnnotations(this._annotations.helper);
|
|
8973
|
+
annots.update(data);
|
|
8977
8974
|
if ((annots === null || annots === void 0 ? void 0 : annots.type) !== undefined && Model.meta !== null) {
|
|
8978
8975
|
let schema = (_a = Model.meta.findChildOptions((o) => o.isTypeOf(annots.type))) === null || _a === void 0 ? void 0 : _a.schema;
|
|
8979
8976
|
if (schema !== undefined && schema.model !== undefined)
|
|
@@ -10092,11 +10089,14 @@ class ODataModel {
|
|
|
10092
10089
|
if (model === null)
|
|
10093
10090
|
return null;
|
|
10094
10091
|
if (model === undefined) {
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
|
|
10092
|
+
if (field.collection) {
|
|
10093
|
+
model = field.collectionFactory({ parent: this });
|
|
10094
|
+
}
|
|
10095
|
+
else {
|
|
10096
|
+
const value = this.referenced(field);
|
|
10097
|
+
model =
|
|
10098
|
+
value === null ? null : field.modelFactory({ parent: this, value });
|
|
10099
|
+
}
|
|
10100
10100
|
this[name] = model;
|
|
10101
10101
|
}
|
|
10102
10102
|
return model;
|
|
@@ -10151,7 +10151,7 @@ class ODataApiOptions {
|
|
|
10151
10151
|
config.nonParenthesisForEmptyParameterFunction || false;
|
|
10152
10152
|
}
|
|
10153
10153
|
get parserOptions() {
|
|
10154
|
-
return Object.assign({ version: this.version }, this.accept);
|
|
10154
|
+
return Object.assign({ version: this.version, stringAsEnum: this.stringAsEnum, deleteRefBy: this.deleteRefBy, nonParenthesisForEmptyParameterFunction: this.nonParenthesisForEmptyParameterFunction }, this.accept);
|
|
10155
10155
|
}
|
|
10156
10156
|
get helper() {
|
|
10157
10157
|
return ODataHelper[this.version];
|
|
@@ -10201,6 +10201,7 @@ class ODataApi {
|
|
|
10201
10201
|
this.requester = settings.requester;
|
|
10202
10202
|
this.schemas.forEach((schema) => {
|
|
10203
10203
|
schema.configure({
|
|
10204
|
+
options: this.options.parserOptions,
|
|
10204
10205
|
parserForType: (type) => this.parserForType(type),
|
|
10205
10206
|
findOptionsForType: (type) => this.findOptionsForType(type),
|
|
10206
10207
|
});
|
|
@@ -10360,8 +10361,9 @@ class ODataApi {
|
|
|
10360
10361
|
Model.buildMeta({ schema });
|
|
10361
10362
|
// Configure
|
|
10362
10363
|
Model.meta.configure({
|
|
10363
|
-
findOptionsForType: (type) => this.findOptionsForType(type),
|
|
10364
10364
|
options: this.options.parserOptions,
|
|
10365
|
+
parserForType: (type) => this.parserForType(type),
|
|
10366
|
+
findOptionsForType: (type) => this.findOptionsForType(type),
|
|
10365
10367
|
});
|
|
10366
10368
|
// Store New Model for next time
|
|
10367
10369
|
schema.model = Model;
|
|
@@ -10955,9 +10957,9 @@ class ODataClient {
|
|
|
10955
10957
|
return this.request('PUT', resource, addBody(options, body));
|
|
10956
10958
|
}
|
|
10957
10959
|
}
|
|
10958
|
-
ODataClient.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.
|
|
10959
|
-
ODataClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.
|
|
10960
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.
|
|
10960
|
+
ODataClient.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: ODataClient, deps: [{ token: i1.HttpClient }, { token: ODataSettings }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
10961
|
+
ODataClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: ODataClient, providedIn: 'root' });
|
|
10962
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: ODataClient, decorators: [{
|
|
10961
10963
|
type: Injectable,
|
|
10962
10964
|
args: [{
|
|
10963
10965
|
providedIn: 'root',
|
|
@@ -11209,9 +11211,9 @@ class ODataServiceFactory {
|
|
|
11209
11211
|
})(this.client, singletonName, apiNameOrEntityType);
|
|
11210
11212
|
}
|
|
11211
11213
|
}
|
|
11212
|
-
ODataServiceFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.
|
|
11213
|
-
ODataServiceFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.
|
|
11214
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.
|
|
11214
|
+
ODataServiceFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: ODataServiceFactory, deps: [{ token: ODataClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
11215
|
+
ODataServiceFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: ODataServiceFactory });
|
|
11216
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: ODataServiceFactory, decorators: [{
|
|
11215
11217
|
type: Injectable
|
|
11216
11218
|
}], ctorParameters: function () { return [{ type: ODataClient }]; } });
|
|
11217
11219
|
|
|
@@ -11235,10 +11237,10 @@ class ODataModule {
|
|
|
11235
11237
|
};
|
|
11236
11238
|
}
|
|
11237
11239
|
}
|
|
11238
|
-
ODataModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.
|
|
11239
|
-
ODataModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.
|
|
11240
|
-
ODataModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.
|
|
11241
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.
|
|
11240
|
+
ODataModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
11241
|
+
ODataModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.1", ngImport: i0, type: ODataModule, imports: [HttpClientModule] });
|
|
11242
|
+
ODataModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: ODataModule, providers: [ODataClient, ODataServiceFactory], imports: [HttpClientModule] });
|
|
11243
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: ODataModule, decorators: [{
|
|
11242
11244
|
type: NgModule,
|
|
11243
11245
|
args: [{
|
|
11244
11246
|
imports: [HttpClientModule],
|