angular-odata 0.146.2 → 0.148.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/fesm2022/angular-odata.mjs +313 -220
- package/fesm2022/angular-odata.mjs.map +1 -1
- package/package.json +1 -1
- package/schematics/apigen/angular/enum.js +1 -1
- package/schematics/apigen/angular/enum.js.map +1 -1
- package/schematics/apigen/metadata/csdl/csdl-structural-property.d.ts +3 -3
- package/schematics/apigen/metadata/csdl/csdl-structural-property.js +4 -4
- package/schematics/apigen/metadata/csdl/csdl-structural-property.js.map +1 -1
- package/schematics/apigen/metadata/parser.js +5 -3
- package/schematics/apigen/metadata/parser.js.map +1 -1
- package/types/angular-odata.d.ts +121 -86
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { map, expand, reduce, finalize, defaultIfEmpty, switchMap, catchError, tap, startWith } from 'rxjs/operators';
|
|
1
|
+
import { HttpHeaders, HttpParams, HttpResponse, HttpErrorResponse, HttpEventType, provideHttpClient, HttpClient } from '@angular/common/http';
|
|
2
|
+
import { Subject, map as map$1, EMPTY, throwError, Observable, forkJoin, of, NEVER, firstValueFrom } from 'rxjs';
|
|
3
|
+
import { map, expand, reduce, finalize, defaultIfEmpty, switchMap, catchError, startWith, tap } from 'rxjs/operators';
|
|
5
4
|
import * as i0 from '@angular/core';
|
|
6
|
-
import { EventEmitter, Injectable, InjectionToken, makeEnvironmentProviders, NgModule } from '@angular/core';
|
|
5
|
+
import { EventEmitter, Injectable, InjectionToken, provideAppInitializer, inject, makeEnvironmentProviders, NgModule } from '@angular/core';
|
|
7
6
|
import { CommonModule } from '@angular/common';
|
|
8
7
|
|
|
9
8
|
var PathSegment;
|
|
@@ -528,7 +527,11 @@ const binary = (value) => ({
|
|
|
528
527
|
type: QueryCustomTypes.Binary,
|
|
529
528
|
value,
|
|
530
529
|
});
|
|
531
|
-
const isQueryCustomType = (value) =>
|
|
530
|
+
const isQueryCustomType = (value) => value !== null &&
|
|
531
|
+
value !== undefined &&
|
|
532
|
+
typeof value === 'object' &&
|
|
533
|
+
'type' in value &&
|
|
534
|
+
value.type in QueryCustomTypes;
|
|
532
535
|
const isRawType = (value) => isQueryCustomType(value) && value.type === QueryCustomTypes.Raw;
|
|
533
536
|
const ITEM_ROOT = '';
|
|
534
537
|
function builder ({ select, search, skiptoken, format, top, skip, filter, transform, compute, orderBy, key, count, expand, action, func, aliases, escape, } = {}) {
|
|
@@ -1849,10 +1852,7 @@ class ODataSchemaElement extends ODataAnnotatable {
|
|
|
1849
1852
|
* @returns True if the callable is type of the given type
|
|
1850
1853
|
*/
|
|
1851
1854
|
isTypeOf(element) {
|
|
1852
|
-
|
|
1853
|
-
if (this.schema.alias)
|
|
1854
|
-
names.push(`${this.schema.alias}.${this.name}`);
|
|
1855
|
-
return names.includes(element.type());
|
|
1855
|
+
return this.type() === element.type();
|
|
1856
1856
|
}
|
|
1857
1857
|
/**
|
|
1858
1858
|
* Returns a boolean indicating if the structured type is a subtype of the given type.
|
|
@@ -1946,10 +1946,10 @@ const EdmParser = (_d, _s, _e) => ({
|
|
|
1946
1946
|
},
|
|
1947
1947
|
});
|
|
1948
1948
|
const Identity = (v) => v;
|
|
1949
|
-
const toNumber = (v) => Number(v);
|
|
1950
|
-
const toString = (v) => v.toString();
|
|
1951
|
-
const toBoolean = (v) => Boolean(v);
|
|
1952
|
-
const toDate = (v) => new Date(v);
|
|
1949
|
+
const toNumber = (v) => v && Number(v);
|
|
1950
|
+
const toString = (v) => v && v.toString();
|
|
1951
|
+
const toBoolean = (v) => v && Boolean(v);
|
|
1952
|
+
const toDate = (v) => v && new Date(v);
|
|
1953
1953
|
const EDM_PARSERS = {
|
|
1954
1954
|
//Edm.Guid 16-byte (128-bit) unique identifier
|
|
1955
1955
|
[EdmType.Guid]: EdmParser(Identity, Identity, (v) => raw(v)),
|
|
@@ -2112,8 +2112,8 @@ class ODataEnumTypeParser extends ODataAnnotatable {
|
|
|
2112
2112
|
if (names.length === 0)
|
|
2113
2113
|
names = [`${value}`];
|
|
2114
2114
|
return !parserOptions?.stringAsEnum
|
|
2115
|
-
? `${this.namespace}.${this.name}'${names.join(',
|
|
2116
|
-
: names.join(',
|
|
2115
|
+
? `${this.namespace}.${this.name}'${names.join(',')}'`
|
|
2116
|
+
: names.join(',');
|
|
2117
2117
|
}
|
|
2118
2118
|
else {
|
|
2119
2119
|
let name = this.field(value)?.name;
|
|
@@ -2991,8 +2991,10 @@ class ODataStructuredType extends ODataParserSchemaElement {
|
|
|
2991
2991
|
configure({ options }) {
|
|
2992
2992
|
if (this.base) {
|
|
2993
2993
|
const parent = this.api.findStructuredType(this.base);
|
|
2994
|
-
parent
|
|
2995
|
-
|
|
2994
|
+
if (parent !== undefined) {
|
|
2995
|
+
parent.children.push(this);
|
|
2996
|
+
this.parent = parent;
|
|
2997
|
+
}
|
|
2996
2998
|
}
|
|
2997
2999
|
this.parser.configure({
|
|
2998
3000
|
options,
|
|
@@ -3067,6 +3069,15 @@ class ODataStructuredType extends ODataParserSchemaElement {
|
|
|
3067
3069
|
return undefined;
|
|
3068
3070
|
return this.parent.findParentSchema(predicate);
|
|
3069
3071
|
}
|
|
3072
|
+
/**
|
|
3073
|
+
* Find a parent schema of the structured type for the given field.
|
|
3074
|
+
* @param field Field that belongs to the structured type
|
|
3075
|
+
* @returns The schema of the field
|
|
3076
|
+
*/
|
|
3077
|
+
findParentSchemaForField(field) {
|
|
3078
|
+
return this.findParentSchema((p) => p.fields({ include_parents: false, include_navigation: true }).find((f) => f === field) !==
|
|
3079
|
+
undefined);
|
|
3080
|
+
}
|
|
3070
3081
|
findChildSchema(predicate) {
|
|
3071
3082
|
if (predicate(this))
|
|
3072
3083
|
return this;
|
|
@@ -3078,15 +3089,6 @@ class ODataStructuredType extends ODataParserSchemaElement {
|
|
|
3078
3089
|
}
|
|
3079
3090
|
return match;
|
|
3080
3091
|
}
|
|
3081
|
-
/**
|
|
3082
|
-
* Find a parent schema of the structured type for the given field.
|
|
3083
|
-
* @param field Field that belongs to the structured type
|
|
3084
|
-
* @returns The schema of the field
|
|
3085
|
-
*/
|
|
3086
|
-
findParentSchemaForField(field) {
|
|
3087
|
-
return this.findParentSchema((p) => p.fields({ include_parents: false, include_navigation: true }).find((f) => f === field) !==
|
|
3088
|
-
undefined);
|
|
3089
|
-
}
|
|
3090
3092
|
/**
|
|
3091
3093
|
* Picks the fields from attributes.
|
|
3092
3094
|
* @param attrs
|
|
@@ -5638,7 +5640,7 @@ class ODataQueryOptions {
|
|
|
5638
5640
|
return new ODataQueryOptions(new Map(entries));
|
|
5639
5641
|
}
|
|
5640
5642
|
toQueryArguments() {
|
|
5641
|
-
return {
|
|
5643
|
+
return Objects.clone({
|
|
5642
5644
|
select: this._values.get(QueryOption.select) ?? null,
|
|
5643
5645
|
expand: this._values.get(QueryOption.expand) ?? null,
|
|
5644
5646
|
transform: this._values.get(QueryOption.transform) ?? null,
|
|
@@ -5652,7 +5654,7 @@ class ODataQueryOptions {
|
|
|
5652
5654
|
skiptoken: this._values.get(QueryOption.skiptoken) ?? null,
|
|
5653
5655
|
levels: this._values.get(QueryOption.levels) ?? null,
|
|
5654
5656
|
count: this._values.get(QueryOption.count) ?? null,
|
|
5655
|
-
};
|
|
5657
|
+
});
|
|
5656
5658
|
}
|
|
5657
5659
|
clone() {
|
|
5658
5660
|
return new ODataQueryOptions(Objects.clone(this._values));
|
|
@@ -6174,6 +6176,7 @@ class ODataResource {
|
|
|
6174
6176
|
resource.query((q) => q.restore(this.queryOptions.toQueryArguments()));
|
|
6175
6177
|
}
|
|
6176
6178
|
return ModelType.factory(entity, {
|
|
6179
|
+
parent: null,
|
|
6177
6180
|
resource: resource,
|
|
6178
6181
|
annots,
|
|
6179
6182
|
reset,
|
|
@@ -6193,6 +6196,7 @@ class ODataResource {
|
|
|
6193
6196
|
resource.query((q) => q.restore(this.queryOptions.toQueryArguments()));
|
|
6194
6197
|
}
|
|
6195
6198
|
return CollectionType.factory(entities, {
|
|
6199
|
+
parent: null,
|
|
6196
6200
|
resource: resource,
|
|
6197
6201
|
annots,
|
|
6198
6202
|
reset,
|
|
@@ -6257,12 +6261,15 @@ class ODataResource {
|
|
|
6257
6261
|
}
|
|
6258
6262
|
toString({ escape, ...options } = {
|
|
6259
6263
|
escape: false,
|
|
6264
|
+
params: true,
|
|
6260
6265
|
}) {
|
|
6261
|
-
let [
|
|
6262
|
-
|
|
6266
|
+
let [rpath, rparams] = this.pathAndParams({ escape, ...options });
|
|
6267
|
+
if (!options.params)
|
|
6268
|
+
return rpath;
|
|
6269
|
+
let queryString = Object.entries(rparams)
|
|
6263
6270
|
.map((e) => `${e[0]}${VALUE_SEPARATOR}${e[1]}`)
|
|
6264
6271
|
.join(PARAM_SEPARATOR);
|
|
6265
|
-
return queryString ? `${
|
|
6272
|
+
return queryString ? `${rpath}${QUERY_SEPARATOR}${queryString}` : rpath;
|
|
6266
6273
|
}
|
|
6267
6274
|
clone() {
|
|
6268
6275
|
const Ctor = this.constructor;
|
|
@@ -6271,6 +6278,20 @@ class ODataResource {
|
|
|
6271
6278
|
query: this.cloneQuery(),
|
|
6272
6279
|
});
|
|
6273
6280
|
}
|
|
6281
|
+
cast(type) {
|
|
6282
|
+
const Ctor = this.constructor;
|
|
6283
|
+
const thisType = this.incomingType();
|
|
6284
|
+
const baseSchema = thisType !== undefined ? this.api.structuredType(thisType) : undefined;
|
|
6285
|
+
const castSchema = this.api.findStructuredType(type);
|
|
6286
|
+
if (castSchema !== undefined && baseSchema !== undefined && !castSchema.isSubtypeOf(baseSchema))
|
|
6287
|
+
throw new Error(`cast: Cannot cast to ${type}`);
|
|
6288
|
+
const segments = this.cloneSegments();
|
|
6289
|
+
segments.add(PathSegment.type, type).incomingType(type);
|
|
6290
|
+
return new Ctor(this.api, {
|
|
6291
|
+
segments,
|
|
6292
|
+
query: this.cloneQuery(),
|
|
6293
|
+
});
|
|
6294
|
+
}
|
|
6274
6295
|
__parser(value, options, resourceType, bindingType) {
|
|
6275
6296
|
const dataType = options !== undefined && Types.isPlainObject(value)
|
|
6276
6297
|
? ODataHelper[options.version ?? DEFAULT_VERSION].type(value)
|
|
@@ -7551,17 +7572,7 @@ class ODataNavigationPropertyResource extends ODataResource {
|
|
|
7551
7572
|
});
|
|
7552
7573
|
}
|
|
7553
7574
|
cast(type) {
|
|
7554
|
-
|
|
7555
|
-
const baseSchema = thisType !== undefined ? this.api.structuredType(thisType) : undefined;
|
|
7556
|
-
const castSchema = this.api.findStructuredType(type);
|
|
7557
|
-
if (castSchema !== undefined && baseSchema !== undefined && !castSchema.isSubtypeOf(baseSchema))
|
|
7558
|
-
throw new Error(`Cannot cast to ${type}`);
|
|
7559
|
-
const segments = this.cloneSegments();
|
|
7560
|
-
segments.add(PathSegment.type, type).incomingType(type);
|
|
7561
|
-
return new ODataNavigationPropertyResource(this.api, {
|
|
7562
|
-
segments,
|
|
7563
|
-
query: this.cloneQuery(),
|
|
7564
|
-
});
|
|
7575
|
+
return super.cast(type);
|
|
7565
7576
|
}
|
|
7566
7577
|
//#region Requests
|
|
7567
7578
|
post(attrs, options = {}) {
|
|
@@ -7735,18 +7746,7 @@ class ODataEntityResource extends ODataResource {
|
|
|
7735
7746
|
return ODataFunctionResource.fromResource(this, path);
|
|
7736
7747
|
}
|
|
7737
7748
|
cast(type) {
|
|
7738
|
-
|
|
7739
|
-
const baseSchema = thisType !== undefined ? this.api.structuredType(thisType) : undefined;
|
|
7740
|
-
// Downcast
|
|
7741
|
-
const castSchema = baseSchema?.findChildSchema((s) => s.type() === type);
|
|
7742
|
-
if (castSchema !== undefined && baseSchema !== undefined && !castSchema.isSubtypeOf(baseSchema))
|
|
7743
|
-
throw new Error(`cast: Cannot cast to ${type}`);
|
|
7744
|
-
const segments = this.cloneSegments();
|
|
7745
|
-
segments.add(PathSegment.type, type).incomingType(type);
|
|
7746
|
-
return new ODataEntityResource(this.api, {
|
|
7747
|
-
segments,
|
|
7748
|
-
query: this.cloneQuery(),
|
|
7749
|
-
});
|
|
7749
|
+
return super.cast(type);
|
|
7750
7750
|
}
|
|
7751
7751
|
//#region Requests
|
|
7752
7752
|
post(attrs, options = {}) {
|
|
@@ -7835,17 +7835,7 @@ class ODataEntitySetResource extends ODataResource {
|
|
|
7835
7835
|
});
|
|
7836
7836
|
}
|
|
7837
7837
|
cast(type) {
|
|
7838
|
-
|
|
7839
|
-
const baseSchema = thisType !== undefined ? this.api.structuredType(thisType) : undefined;
|
|
7840
|
-
const castSchema = this.api.findStructuredType(type);
|
|
7841
|
-
if (castSchema !== undefined && baseSchema !== undefined && !castSchema.isSubtypeOf(baseSchema))
|
|
7842
|
-
throw new Error(`cast: Cannot cast to ${type}`);
|
|
7843
|
-
const segments = this.cloneSegments();
|
|
7844
|
-
segments.add(PathSegment.type, type).incomingType(type);
|
|
7845
|
-
return new ODataEntitySetResource(this.api, {
|
|
7846
|
-
segments,
|
|
7847
|
-
query: this.cloneQuery(),
|
|
7848
|
-
});
|
|
7838
|
+
return super.cast(type);
|
|
7849
7839
|
}
|
|
7850
7840
|
//#region Requests
|
|
7851
7841
|
post(attrs, options) {
|
|
@@ -8452,13 +8442,13 @@ class CsdlProperty extends CsdlStructuralProperty {
|
|
|
8452
8442
|
class CsdlNavigationProperty extends CsdlStructuralProperty {
|
|
8453
8443
|
Partner;
|
|
8454
8444
|
ContainsTarget;
|
|
8455
|
-
|
|
8445
|
+
ReferentialConstraint;
|
|
8456
8446
|
OnDelete;
|
|
8457
|
-
constructor({ Name, Type, Nullable, Partner, ContainsTarget,
|
|
8447
|
+
constructor({ Name, Type, Nullable, Partner, ContainsTarget, ReferentialConstraint, OnDelete, Annotation, }) {
|
|
8458
8448
|
super({ Name, Type, Nullable, Annotation });
|
|
8459
8449
|
this.Partner = Partner;
|
|
8460
8450
|
this.ContainsTarget = ContainsTarget;
|
|
8461
|
-
this.
|
|
8451
|
+
this.ReferentialConstraint = ReferentialConstraint?.map((r) => new CsdlReferentialConstraint(r));
|
|
8462
8452
|
this.OnDelete = OnDelete ? new CsdlOnDelete(OnDelete) : undefined;
|
|
8463
8453
|
}
|
|
8464
8454
|
toJson() {
|
|
@@ -8469,8 +8459,8 @@ class CsdlNavigationProperty extends CsdlStructuralProperty {
|
|
|
8469
8459
|
if (this.ContainsTarget !== undefined) {
|
|
8470
8460
|
json['ContainsTarget'] = this.ContainsTarget;
|
|
8471
8461
|
}
|
|
8472
|
-
if (Array.isArray(this.
|
|
8473
|
-
json['
|
|
8462
|
+
if (Array.isArray(this.ReferentialConstraint) && this.ReferentialConstraint.length > 0) {
|
|
8463
|
+
json['ReferentialConstraint'] = this.ReferentialConstraint.map((r) => r.toJson());
|
|
8474
8464
|
}
|
|
8475
8465
|
if (this.OnDelete !== undefined) {
|
|
8476
8466
|
json['OnDelete'] = this.OnDelete;
|
|
@@ -8485,7 +8475,7 @@ class CsdlNavigationProperty extends CsdlStructuralProperty {
|
|
|
8485
8475
|
collection: this.Collection,
|
|
8486
8476
|
nullable: this.Nullable,
|
|
8487
8477
|
navigation: true,
|
|
8488
|
-
referentials: this.
|
|
8478
|
+
referentials: this.ReferentialConstraint?.map((r) => ({
|
|
8489
8479
|
property: r.Property,
|
|
8490
8480
|
referencedProperty: r.ReferencedProperty,
|
|
8491
8481
|
})),
|
|
@@ -10392,6 +10382,7 @@ class ODataCollection {
|
|
|
10392
10382
|
}
|
|
10393
10383
|
clone() {
|
|
10394
10384
|
return new this.constructor(this.toEntities(INCLUDE_DEEP), {
|
|
10385
|
+
parent: this._parent,
|
|
10395
10386
|
resource: this.resource()?.clone(),
|
|
10396
10387
|
annots: this.annots().clone(),
|
|
10397
10388
|
});
|
|
@@ -11239,6 +11230,7 @@ class ODataModel {
|
|
|
11239
11230
|
}
|
|
11240
11231
|
clone() {
|
|
11241
11232
|
return new this.constructor(this.toEntity(INCLUDE_DEEP), {
|
|
11233
|
+
parent: this._parent,
|
|
11242
11234
|
resource: this.resource()?.clone(),
|
|
11243
11235
|
annots: this.annots().clone(),
|
|
11244
11236
|
});
|
|
@@ -11409,7 +11401,6 @@ class ODataModel {
|
|
|
11409
11401
|
}
|
|
11410
11402
|
}
|
|
11411
11403
|
cast(type, ModelType) {
|
|
11412
|
-
//: ODataModel<S> {
|
|
11413
11404
|
const resource = this.resource();
|
|
11414
11405
|
if (!(resource instanceof ODataEntityResource))
|
|
11415
11406
|
throw new Error(`cast: Can't cast to derived model without ODataEntityResource`);
|
|
@@ -11743,11 +11734,6 @@ class ODataModelField {
|
|
|
11743
11734
|
field;
|
|
11744
11735
|
parser;
|
|
11745
11736
|
options;
|
|
11746
|
-
optionsForType;
|
|
11747
|
-
modelForType;
|
|
11748
|
-
collectionForType;
|
|
11749
|
-
enumForType;
|
|
11750
|
-
structuredForType;
|
|
11751
11737
|
default;
|
|
11752
11738
|
required;
|
|
11753
11739
|
concurrency;
|
|
@@ -11783,12 +11769,7 @@ class ODataModelField {
|
|
|
11783
11769
|
annotatedValue(term) {
|
|
11784
11770
|
return this.parser.annotatedValue(term);
|
|
11785
11771
|
}
|
|
11786
|
-
configure({
|
|
11787
|
-
this.optionsForType = optionsForType;
|
|
11788
|
-
this.modelForType = modelForType;
|
|
11789
|
-
this.collectionForType = collectionForType;
|
|
11790
|
-
this.enumForType = enumForType;
|
|
11791
|
-
this.structuredForType = structuredForType;
|
|
11772
|
+
configure({ concurrency, options }) {
|
|
11792
11773
|
this.parserOptions = options;
|
|
11793
11774
|
if (concurrency)
|
|
11794
11775
|
this.concurrency = concurrency;
|
|
@@ -11808,7 +11789,7 @@ class ODataModelField {
|
|
|
11808
11789
|
return this.parser.isStructuredType();
|
|
11809
11790
|
}
|
|
11810
11791
|
structuredType() {
|
|
11811
|
-
const structuredType = this.
|
|
11792
|
+
const structuredType = this.options.api.findStructuredType(this.type);
|
|
11812
11793
|
//Throw error if not found
|
|
11813
11794
|
if (!structuredType)
|
|
11814
11795
|
throw new Error(`Could not find structured type for ${this.parser.type}`);
|
|
@@ -11821,7 +11802,7 @@ class ODataModelField {
|
|
|
11821
11802
|
return this.parser.isEdmType();
|
|
11822
11803
|
}
|
|
11823
11804
|
enumType() {
|
|
11824
|
-
const enumType = this.
|
|
11805
|
+
const enumType = this.options.api.findEnumType(this.type);
|
|
11825
11806
|
//Throw error if not found
|
|
11826
11807
|
if (!enumType)
|
|
11827
11808
|
throw new Error(`Could not find enum type for ${this.parser.type}`);
|
|
@@ -11868,7 +11849,7 @@ class ODataModelField {
|
|
|
11868
11849
|
}
|
|
11869
11850
|
}
|
|
11870
11851
|
defaults() {
|
|
11871
|
-
const meta = this.
|
|
11852
|
+
const meta = this.isStructuredType() ? this.options.api.optionsForType(this.type) : undefined;
|
|
11872
11853
|
return meta !== undefined ? meta.defaults() : this.default;
|
|
11873
11854
|
}
|
|
11874
11855
|
deserialize(value, options) {
|
|
@@ -11900,7 +11881,7 @@ class ODataModelField {
|
|
|
11900
11881
|
modelFactory({ parent, value, reset, }) {
|
|
11901
11882
|
// Model
|
|
11902
11883
|
const annots = this.annotationsFactory(parent.annots());
|
|
11903
|
-
let Model = this.
|
|
11884
|
+
let Model = this.options.api.modelForType(this.type);
|
|
11904
11885
|
if (Model === undefined)
|
|
11905
11886
|
throw Error(`No Model type for ${this.name}`);
|
|
11906
11887
|
if (value !== undefined) {
|
|
@@ -11921,7 +11902,7 @@ class ODataModelField {
|
|
|
11921
11902
|
collectionFactory({ parent, value, reset, }) {
|
|
11922
11903
|
// Collection Factory
|
|
11923
11904
|
const annots = this.annotationsFactory(parent.annots());
|
|
11924
|
-
const Collection = this.
|
|
11905
|
+
const Collection = this.options.api.collectionForType(this.type);
|
|
11925
11906
|
if (Collection === undefined)
|
|
11926
11907
|
throw Error(`No Collection type for ${this.name}`);
|
|
11927
11908
|
return Collection.factory((value || []), {
|
|
@@ -12129,11 +12110,6 @@ class ODataModelOptions {
|
|
|
12129
12110
|
this._fields.forEach((field) => {
|
|
12130
12111
|
const concurrency = concurrencyFields.indexOf(field.field) !== -1;
|
|
12131
12112
|
field.configure({
|
|
12132
|
-
optionsForType: (t) => this.api.optionsForType(t),
|
|
12133
|
-
modelForType: (t) => this.api.modelForType(t),
|
|
12134
|
-
collectionForType: (t) => this.api.collectionForType(t),
|
|
12135
|
-
enumForType: (t) => this.api.findEnumType(t),
|
|
12136
|
-
structuredForType: (t) => this.api.findStructuredType(t),
|
|
12137
12113
|
concurrency,
|
|
12138
12114
|
options,
|
|
12139
12115
|
});
|
|
@@ -12195,11 +12171,6 @@ class ODataModelOptions {
|
|
|
12195
12171
|
parser: structuredFieldParser,
|
|
12196
12172
|
});
|
|
12197
12173
|
modelField.configure({
|
|
12198
|
-
optionsForType: (t) => this.api.optionsForType(t),
|
|
12199
|
-
modelForType: (t) => this.api.modelForType(t),
|
|
12200
|
-
collectionForType: (t) => this.api.collectionForType(t),
|
|
12201
|
-
enumForType: (t) => this.api.findEnumType(t),
|
|
12202
|
-
structuredForType: (t) => this.api.findStructuredType(t),
|
|
12203
12174
|
options: this.api.options,
|
|
12204
12175
|
concurrency: false,
|
|
12205
12176
|
});
|
|
@@ -12241,38 +12212,40 @@ class ODataModelOptions {
|
|
|
12241
12212
|
let resource = null;
|
|
12242
12213
|
let prevField = null;
|
|
12243
12214
|
for (const [model, field] of ODataModelOptions.chain(child)) {
|
|
12244
|
-
resource = resource
|
|
12215
|
+
resource = resource ?? model._resource?.clone();
|
|
12216
|
+
// Break if no resource
|
|
12245
12217
|
if (resource === null)
|
|
12246
12218
|
break;
|
|
12247
|
-
|
|
12248
|
-
|
|
12249
|
-
|
|
12250
|
-
|
|
12251
|
-
|
|
12252
|
-
if (
|
|
12253
|
-
const r = m._meta.modelResourceFactory(resource.cloneQuery<T>());
|
|
12254
|
-
if (r !== null && !r.isTypeOf(resource) && r.isSubtypeOf(resource)) {
|
|
12255
|
-
resource = r;
|
|
12256
|
-
}
|
|
12257
|
-
}
|
|
12258
|
-
*/
|
|
12259
|
-
// Resolve key
|
|
12260
|
-
const mKey = m.key({ field_mapping: true });
|
|
12261
|
-
if (mKey !== undefined) {
|
|
12219
|
+
// Resolve Key
|
|
12220
|
+
if ((prevField === null || prevField.collection) &&
|
|
12221
|
+
ODataModelOptions.isModel(model) &&
|
|
12222
|
+
model._meta.isEntityType()) {
|
|
12223
|
+
const key = model.key({ field_mapping: true });
|
|
12224
|
+
if (key !== undefined) {
|
|
12262
12225
|
resource =
|
|
12263
12226
|
resource instanceof ODataEntitySetResource
|
|
12264
|
-
? resource.entity(
|
|
12265
|
-
: resource.key(
|
|
12227
|
+
? resource.entity(key)
|
|
12228
|
+
: resource.key(key);
|
|
12266
12229
|
}
|
|
12267
12230
|
}
|
|
12268
|
-
|
|
12269
|
-
|
|
12270
|
-
|
|
12271
|
-
|
|
12272
|
-
|
|
12273
|
-
|
|
12231
|
+
if (field !== null) {
|
|
12232
|
+
// Resolve Structured Type Cast
|
|
12233
|
+
const resourceType = resource.structuredType();
|
|
12234
|
+
const fieldType = field.options.structuredType;
|
|
12235
|
+
if (resourceType !== undefined &&
|
|
12236
|
+
fieldType !== undefined &&
|
|
12237
|
+
fieldType !== resourceType &&
|
|
12238
|
+
fieldType.isSubtypeOf(resourceType)) {
|
|
12239
|
+
resource = resource.cast(fieldType.type());
|
|
12240
|
+
}
|
|
12241
|
+
// Build Resource from field
|
|
12274
12242
|
resource = field.resourceFactory(resource);
|
|
12275
12243
|
}
|
|
12244
|
+
else if (model._resource !== null) {
|
|
12245
|
+
// Apply parameters from model._resource to new resource
|
|
12246
|
+
model._resource.query((qs) => resource?.query((qd) => qd.restore(qs.store())));
|
|
12247
|
+
}
|
|
12248
|
+
prevField = field;
|
|
12276
12249
|
}
|
|
12277
12250
|
return resource;
|
|
12278
12251
|
}
|
|
@@ -12861,6 +12834,50 @@ class ODataApiOptions {
|
|
|
12861
12834
|
}
|
|
12862
12835
|
}
|
|
12863
12836
|
|
|
12837
|
+
class ODataInclude {
|
|
12838
|
+
namespace;
|
|
12839
|
+
alias;
|
|
12840
|
+
reference;
|
|
12841
|
+
constructor(config, reference) {
|
|
12842
|
+
this.namespace = config.namespace;
|
|
12843
|
+
this.alias = config.alias;
|
|
12844
|
+
this.reference = reference;
|
|
12845
|
+
}
|
|
12846
|
+
configure({ options }) { }
|
|
12847
|
+
}
|
|
12848
|
+
class ODataIncludeAnnotation {
|
|
12849
|
+
termNamespace;
|
|
12850
|
+
qualifier;
|
|
12851
|
+
targetNamespace;
|
|
12852
|
+
reference;
|
|
12853
|
+
constructor(config, reference) {
|
|
12854
|
+
this.termNamespace = config.termNamespace;
|
|
12855
|
+
this.qualifier = config.qualifier;
|
|
12856
|
+
this.targetNamespace = config.targetNamespace;
|
|
12857
|
+
this.reference = reference;
|
|
12858
|
+
}
|
|
12859
|
+
configure({ options }) { }
|
|
12860
|
+
}
|
|
12861
|
+
class ODataReference extends ODataAnnotatable {
|
|
12862
|
+
api;
|
|
12863
|
+
uri;
|
|
12864
|
+
includes;
|
|
12865
|
+
includeAnnotations;
|
|
12866
|
+
constructor(config, api) {
|
|
12867
|
+
super(config);
|
|
12868
|
+
this.api = api;
|
|
12869
|
+
this.uri = config.uri;
|
|
12870
|
+
this.includes = (config.includes ?? []).map((config) => new ODataInclude(config, this));
|
|
12871
|
+
this.includeAnnotations = (config.includeAnnotations ?? []).map((config) => new ODataIncludeAnnotation(config, this));
|
|
12872
|
+
}
|
|
12873
|
+
configure({ options }) {
|
|
12874
|
+
// Configure Includes
|
|
12875
|
+
this.includes.forEach((include) => include.configure({ options }));
|
|
12876
|
+
// Configure IncludeAnnotations
|
|
12877
|
+
this.includeAnnotations.forEach((includeAnnotation) => includeAnnotation.configure({ options }));
|
|
12878
|
+
}
|
|
12879
|
+
}
|
|
12880
|
+
|
|
12864
12881
|
const RESERVED_FIELD_NAMES = Object.getOwnPropertyNames(ODataModel.prototype);
|
|
12865
12882
|
/**
|
|
12866
12883
|
* Api abstraction for consuming OData services.
|
|
@@ -12881,8 +12898,12 @@ class ODataApi {
|
|
|
12881
12898
|
errorHandler;
|
|
12882
12899
|
// Base Parsers
|
|
12883
12900
|
parsers;
|
|
12901
|
+
// Populate from Metadata
|
|
12902
|
+
populateFromMetadata;
|
|
12884
12903
|
// Schemas
|
|
12885
12904
|
schemas;
|
|
12905
|
+
// References
|
|
12906
|
+
references;
|
|
12886
12907
|
// Models
|
|
12887
12908
|
models = {};
|
|
12888
12909
|
// Collections
|
|
@@ -12905,12 +12926,14 @@ class ODataApi {
|
|
|
12905
12926
|
this.cache = config.cache;
|
|
12906
12927
|
this.errorHandler = config.errorHandler;
|
|
12907
12928
|
this.parsers = new Map(Object.entries(config.parsers ?? EDM_PARSERS));
|
|
12929
|
+
this.populateFromMetadata = config.populateFromMetadata ?? false;
|
|
12908
12930
|
this.schemas = (config.schemas ?? []).map((schema) => new ODataSchema(schema, this));
|
|
12931
|
+
this.references = (config.references ?? []).map((reference) => new ODataReference(reference, this));
|
|
12909
12932
|
this.models = (config.models ?? {});
|
|
12910
12933
|
this.collections = (config.collections ?? {});
|
|
12911
12934
|
}
|
|
12912
|
-
|
|
12913
|
-
this.requester =
|
|
12935
|
+
initialize(requester) {
|
|
12936
|
+
this.requester = requester;
|
|
12914
12937
|
this.schemas.forEach((schema) => {
|
|
12915
12938
|
schema.configure({
|
|
12916
12939
|
options: this.options.parserOptions,
|
|
@@ -12926,6 +12949,11 @@ class ODataApi {
|
|
|
12926
12949
|
}
|
|
12927
12950
|
}
|
|
12928
12951
|
});
|
|
12952
|
+
return this.populateFromMetadata
|
|
12953
|
+
? firstValueFrom(this.metadata()
|
|
12954
|
+
.fetch()
|
|
12955
|
+
.pipe(map((metadata) => this.populate(metadata))))
|
|
12956
|
+
: Promise.resolve(true);
|
|
12929
12957
|
}
|
|
12930
12958
|
populate(metadata) {
|
|
12931
12959
|
const config = metadata.toConfig();
|
|
@@ -12937,6 +12965,7 @@ class ODataApi {
|
|
|
12937
12965
|
options: this.options.parserOptions,
|
|
12938
12966
|
});
|
|
12939
12967
|
});
|
|
12968
|
+
return true;
|
|
12940
12969
|
}
|
|
12941
12970
|
fromJson(json) {
|
|
12942
12971
|
const segments = ODataPathSegments.fromJson(json.segments);
|
|
@@ -13035,7 +13064,7 @@ class ODataApi {
|
|
|
13035
13064
|
}
|
|
13036
13065
|
//request(req: ODataRequest<any>): Observable<any> {
|
|
13037
13066
|
request(method, resource, options) {
|
|
13038
|
-
|
|
13067
|
+
const req = ODataRequest.factory(this, method, resource, {
|
|
13039
13068
|
body: options.body,
|
|
13040
13069
|
etag: options.etag,
|
|
13041
13070
|
context: options.context,
|
|
@@ -13051,16 +13080,12 @@ class ODataApi {
|
|
|
13051
13080
|
parserOptions: options.parserOptions,
|
|
13052
13081
|
withCredentials: options.withCredentials,
|
|
13053
13082
|
});
|
|
13054
|
-
let res$ = this.
|
|
13055
|
-
res$ = res$.pipe(map((res) => res.type === HttpEventType.Response ? ODataResponse.fromHttpResponse(req, res) : res));
|
|
13083
|
+
let res$ = this.handleRequest(req);
|
|
13056
13084
|
if (this.errorHandler !== undefined)
|
|
13057
13085
|
res$ = res$.pipe(catchError(this.errorHandler));
|
|
13058
13086
|
if (options.observe === 'events') {
|
|
13059
13087
|
return res$;
|
|
13060
13088
|
}
|
|
13061
|
-
if (this.cache !== undefined) {
|
|
13062
|
-
res$ = this.handleRequest(req, res$);
|
|
13063
|
-
}
|
|
13064
13089
|
switch (options.observe || 'body') {
|
|
13065
13090
|
case 'body':
|
|
13066
13091
|
switch (options.responseType) {
|
|
@@ -13087,43 +13112,48 @@ class ODataApi {
|
|
|
13087
13112
|
/**
|
|
13088
13113
|
* Using the request, handle the fetching of the response
|
|
13089
13114
|
* @param req The request to fetch
|
|
13090
|
-
* @param res$ Observable of the response
|
|
13091
13115
|
* @returns
|
|
13092
13116
|
*/
|
|
13093
|
-
handleRequest(req
|
|
13094
|
-
return req.isFetch()
|
|
13095
|
-
? this.
|
|
13096
|
-
: req.isMutate()
|
|
13097
|
-
? this.
|
|
13098
|
-
:
|
|
13117
|
+
handleRequest(req) {
|
|
13118
|
+
return this.cache !== undefined && req.isFetch()
|
|
13119
|
+
? this.handleCacheFetch(req)
|
|
13120
|
+
: this.cache !== undefined && req.isMutate()
|
|
13121
|
+
? this.handleCacheMutate(req)
|
|
13122
|
+
: this.handleRequester(req);
|
|
13123
|
+
}
|
|
13124
|
+
handleRequester(req) {
|
|
13125
|
+
return (this.requester !== undefined ? this.requester(req) : NEVER).pipe(map((res) => res.type === HttpEventType.Response ? ODataResponse.fromHttpResponse(req, res) : res));
|
|
13099
13126
|
}
|
|
13100
|
-
|
|
13127
|
+
handleCacheFetch(req) {
|
|
13101
13128
|
const policy = req.fetchPolicy;
|
|
13102
13129
|
const cached = this.cache.getResponse(req);
|
|
13103
13130
|
if (policy === 'no-cache') {
|
|
13104
|
-
return
|
|
13131
|
+
return this.handleRequester(req);
|
|
13105
13132
|
}
|
|
13106
13133
|
if (policy === 'cache-only') {
|
|
13107
|
-
if (cached) {
|
|
13134
|
+
if (cached !== undefined) {
|
|
13108
13135
|
return of(cached);
|
|
13109
13136
|
}
|
|
13110
13137
|
else {
|
|
13111
13138
|
return throwError(() => new Error('No Cached'));
|
|
13112
13139
|
}
|
|
13113
13140
|
}
|
|
13114
|
-
|
|
13141
|
+
let res$ = cached !== undefined && policy !== 'network-only'
|
|
13142
|
+
? policy === 'cache-and-network'
|
|
13143
|
+
? this.handleRequester(req).pipe(startWith(cached))
|
|
13144
|
+
: of(cached)
|
|
13145
|
+
: this.handleRequester(req);
|
|
13146
|
+
if (cached === undefined &&
|
|
13147
|
+
(policy === 'cache-first' || policy === 'cache-and-network' || policy === 'network-only')) {
|
|
13115
13148
|
res$ = res$.pipe(tap((res) => {
|
|
13116
|
-
if (res.options.cacheability !== 'no-store')
|
|
13149
|
+
if (res.options.cacheability !== 'no-store') {
|
|
13117
13150
|
this.cache.putResponse(req, res);
|
|
13151
|
+
}
|
|
13118
13152
|
}));
|
|
13119
13153
|
}
|
|
13120
|
-
return
|
|
13121
|
-
? policy === 'cache-and-network'
|
|
13122
|
-
? res$.pipe(startWith(cached))
|
|
13123
|
-
: of(cached)
|
|
13124
|
-
: res$;
|
|
13154
|
+
return res$;
|
|
13125
13155
|
}
|
|
13126
|
-
|
|
13156
|
+
handleCacheMutate(req) {
|
|
13127
13157
|
const requests = req.isBatch()
|
|
13128
13158
|
? req.resource.requests().filter((r) => r.isMutate())
|
|
13129
13159
|
: [req];
|
|
@@ -13131,7 +13161,7 @@ class ODataApi {
|
|
|
13131
13161
|
const scope = this.cache.scope(r);
|
|
13132
13162
|
this.cache.forget({ scope });
|
|
13133
13163
|
}
|
|
13134
|
-
return
|
|
13164
|
+
return this.handleRequester(req);
|
|
13135
13165
|
}
|
|
13136
13166
|
//# region Find by Type
|
|
13137
13167
|
// Memoize
|
|
@@ -13167,6 +13197,7 @@ class ODataApi {
|
|
|
13167
13197
|
}
|
|
13168
13198
|
const enumTypes = this.schemas.reduce((acc, schema) => [...acc, ...schema.enums], []);
|
|
13169
13199
|
let enumType = enumTypes.find((e) => e.type() === value);
|
|
13200
|
+
enumType = enumType ?? enumTypes.find((e) => e.type({ alias: true }) === value);
|
|
13170
13201
|
enumType = enumType ?? enumTypes.find((e) => e.name === value);
|
|
13171
13202
|
this.memo.enumTypes.set(value, enumType);
|
|
13172
13203
|
return enumType;
|
|
@@ -13179,6 +13210,8 @@ class ODataApi {
|
|
|
13179
13210
|
}
|
|
13180
13211
|
const structuredTypes = this.schemas.reduce((acc, schema) => [...acc, ...schema.entities], []);
|
|
13181
13212
|
let structuredType = structuredTypes.find((e) => e.type() === value);
|
|
13213
|
+
structuredType =
|
|
13214
|
+
structuredType ?? structuredTypes.find((e) => e.type({ alias: true }) === value);
|
|
13182
13215
|
structuredType = structuredType ?? structuredTypes.find((e) => e.name === value);
|
|
13183
13216
|
this.memo.structuredTypes.set(value, structuredType);
|
|
13184
13217
|
return structuredType;
|
|
@@ -13203,6 +13236,19 @@ class ODataApi {
|
|
|
13203
13236
|
(callableBindingStructuredType &&
|
|
13204
13237
|
bindingStructuredType.isSubtypeOf(callableBindingStructuredType))));
|
|
13205
13238
|
});
|
|
13239
|
+
callable =
|
|
13240
|
+
callable ??
|
|
13241
|
+
callables.find((c) => {
|
|
13242
|
+
const isCallableType = c.type({ alias: true }) == value;
|
|
13243
|
+
const callableBindingType = c.binding()?.type;
|
|
13244
|
+
const callableBindingStructuredType = callableBindingType !== undefined
|
|
13245
|
+
? this.findStructuredType(callableBindingType)
|
|
13246
|
+
: undefined;
|
|
13247
|
+
return (isCallableType &&
|
|
13248
|
+
(!bindingStructuredType ||
|
|
13249
|
+
(callableBindingStructuredType &&
|
|
13250
|
+
bindingStructuredType.isSubtypeOf(callableBindingStructuredType))));
|
|
13251
|
+
});
|
|
13206
13252
|
callable =
|
|
13207
13253
|
callable ??
|
|
13208
13254
|
callables.find((c) => {
|
|
@@ -13227,6 +13273,7 @@ class ODataApi {
|
|
|
13227
13273
|
}
|
|
13228
13274
|
const entitySets = this.schemas.reduce((acc, schema) => [...acc, ...schema.entitySets], []);
|
|
13229
13275
|
let entitySet = entitySets.find((e) => e.type() === value);
|
|
13276
|
+
entitySet = entitySet ?? entitySets.find((e) => e.type({ alias: true }) === value);
|
|
13230
13277
|
entitySet = entitySet ?? entitySets.find((e) => e.name === value);
|
|
13231
13278
|
this.memo.entitySets.set(value, entitySet);
|
|
13232
13279
|
return entitySet;
|
|
@@ -13239,6 +13286,7 @@ class ODataApi {
|
|
|
13239
13286
|
}
|
|
13240
13287
|
const singletons = this.schemas.reduce((acc, schema) => [...acc, ...schema.singletons], []);
|
|
13241
13288
|
let singleton = singletons.find((e) => e.type() === value);
|
|
13289
|
+
singleton = singleton ?? singletons.find((e) => e.type({ alias: true }) === value);
|
|
13242
13290
|
singleton = singleton ?? singletons.find((e) => e.name === value);
|
|
13243
13291
|
this.memo.singletons.set(value, singleton);
|
|
13244
13292
|
return singleton;
|
|
@@ -13388,8 +13436,8 @@ class ODataSettings {
|
|
|
13388
13436
|
if (this.apis.every((c) => !c.default))
|
|
13389
13437
|
this.apis[0].default = true;
|
|
13390
13438
|
}
|
|
13391
|
-
|
|
13392
|
-
this.apis.
|
|
13439
|
+
initialize(requester) {
|
|
13440
|
+
return Promise.all(this.apis.map((api) => api.initialize(requester)));
|
|
13393
13441
|
}
|
|
13394
13442
|
defaultApi() {
|
|
13395
13443
|
return this.apis.find((c) => c.default);
|
|
@@ -13474,38 +13522,53 @@ class ODataSettings {
|
|
|
13474
13522
|
}
|
|
13475
13523
|
}
|
|
13476
13524
|
|
|
13477
|
-
class
|
|
13525
|
+
class ODataLoader {
|
|
13478
13526
|
}
|
|
13479
|
-
class
|
|
13527
|
+
class ODataSyncLoader {
|
|
13480
13528
|
passedConfigs;
|
|
13481
|
-
|
|
13529
|
+
requester;
|
|
13530
|
+
constructor(passedConfigs, requester) {
|
|
13482
13531
|
this.passedConfigs = passedConfigs;
|
|
13532
|
+
this.requester = requester;
|
|
13483
13533
|
}
|
|
13484
|
-
|
|
13485
|
-
|
|
13534
|
+
load() {
|
|
13535
|
+
const configs = Array.isArray(this.passedConfigs) ? this.passedConfigs : [this.passedConfigs];
|
|
13536
|
+
return Promise.resolve({ configs, requester: this.requester });
|
|
13486
13537
|
}
|
|
13487
13538
|
}
|
|
13488
|
-
class
|
|
13539
|
+
class ODataAsyncLoader {
|
|
13489
13540
|
configs$;
|
|
13490
|
-
|
|
13541
|
+
requester;
|
|
13542
|
+
constructor(configs$, requester) {
|
|
13491
13543
|
this.configs$ = configs$;
|
|
13544
|
+
this.requester = requester;
|
|
13492
13545
|
}
|
|
13493
|
-
|
|
13494
|
-
return Array.isArray(this.configs$)
|
|
13495
|
-
? forkJoin(this.configs$)
|
|
13496
|
-
: this.configs$.pipe(map$1((value) =>
|
|
13546
|
+
load() {
|
|
13547
|
+
return firstValueFrom(Array.isArray(this.configs$)
|
|
13548
|
+
? forkJoin(this.configs$).pipe(map$1((configs) => ({ configs, requester: this.requester })))
|
|
13549
|
+
: this.configs$.pipe(map$1((value) => ({
|
|
13550
|
+
configs: Array.isArray(value)
|
|
13551
|
+
? value
|
|
13552
|
+
: [value],
|
|
13553
|
+
requester: this.requester,
|
|
13554
|
+
}))));
|
|
13497
13555
|
}
|
|
13498
13556
|
}
|
|
13499
13557
|
class ODataMetadataLoader {
|
|
13500
13558
|
sources$;
|
|
13501
13559
|
baseConfigs;
|
|
13502
|
-
|
|
13560
|
+
requester;
|
|
13561
|
+
constructor(sources$, baseConfigs, requester) {
|
|
13503
13562
|
this.sources$ = sources$;
|
|
13504
13563
|
this.baseConfigs = baseConfigs;
|
|
13564
|
+
this.requester = requester;
|
|
13505
13565
|
}
|
|
13506
|
-
|
|
13566
|
+
load() {
|
|
13507
13567
|
const configs = Array.isArray(this.baseConfigs) ? this.baseConfigs : [this.baseConfigs];
|
|
13508
|
-
return this.sources$.pipe(map$1((source) => (
|
|
13568
|
+
return firstValueFrom(this.sources$.pipe(map$1((source) => ({
|
|
13569
|
+
configs: (Array.isArray(source) ? source : [source]).map((m, i) => new ODataMetadataParser(m).metadata().toConfig(configs[i] ?? {})),
|
|
13570
|
+
requester: this.requester,
|
|
13571
|
+
}))));
|
|
13509
13572
|
}
|
|
13510
13573
|
}
|
|
13511
13574
|
|
|
@@ -13523,27 +13586,19 @@ function addBody(options, body) {
|
|
|
13523
13586
|
};
|
|
13524
13587
|
}
|
|
13525
13588
|
class ODataClient {
|
|
13526
|
-
http;
|
|
13527
13589
|
loader;
|
|
13528
13590
|
settings;
|
|
13529
|
-
constructor(
|
|
13530
|
-
this.http = http;
|
|
13591
|
+
constructor(loader) {
|
|
13531
13592
|
this.loader = loader;
|
|
13532
|
-
|
|
13593
|
+
}
|
|
13594
|
+
initialize() {
|
|
13595
|
+
return this.loader
|
|
13596
|
+
.load()
|
|
13597
|
+
.then(({ configs, requester }) => {
|
|
13533
13598
|
this.settings = new ODataSettings(configs);
|
|
13534
|
-
this.settings.
|
|
13535
|
-
|
|
13536
|
-
|
|
13537
|
-
context: req.context,
|
|
13538
|
-
headers: req.headers,
|
|
13539
|
-
observe: req.observe,
|
|
13540
|
-
params: req.params,
|
|
13541
|
-
reportProgress: req.reportProgress,
|
|
13542
|
-
responseType: req.responseType,
|
|
13543
|
-
withCredentials: req.withCredentials,
|
|
13544
|
-
}),
|
|
13545
|
-
});
|
|
13546
|
-
});
|
|
13599
|
+
return this.settings.initialize(requester);
|
|
13600
|
+
})
|
|
13601
|
+
.then((results) => results.every((v) => v));
|
|
13547
13602
|
}
|
|
13548
13603
|
//#region Resolve Building Blocks
|
|
13549
13604
|
/**
|
|
@@ -13708,12 +13763,13 @@ class ODataClient {
|
|
|
13708
13763
|
put(resource, body, options = {}) {
|
|
13709
13764
|
return this.request('PUT', resource, addBody(options, body));
|
|
13710
13765
|
}
|
|
13711
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: ODataClient, deps: [{ token:
|
|
13712
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: ODataClient });
|
|
13766
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: ODataClient, deps: [{ token: ODataLoader }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
13767
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: ODataClient, providedIn: 'root' });
|
|
13713
13768
|
}
|
|
13714
13769
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: ODataClient, decorators: [{
|
|
13715
|
-
type: Injectable
|
|
13716
|
-
|
|
13770
|
+
type: Injectable,
|
|
13771
|
+
args: [{ providedIn: 'root' }]
|
|
13772
|
+
}], ctorParameters: () => [{ type: ODataLoader }] });
|
|
13717
13773
|
|
|
13718
13774
|
class ODataBaseService {
|
|
13719
13775
|
client;
|
|
@@ -13996,57 +14052,90 @@ class ODataServiceFactory {
|
|
|
13996
14052
|
return new Service(this.client, singletonName, apiNameOrEntityType);
|
|
13997
14053
|
}
|
|
13998
14054
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: ODataServiceFactory, deps: [{ token: ODataClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
13999
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: ODataServiceFactory });
|
|
14055
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: ODataServiceFactory, providedIn: 'root' });
|
|
14000
14056
|
}
|
|
14001
14057
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: ODataServiceFactory, decorators: [{
|
|
14002
|
-
type: Injectable
|
|
14058
|
+
type: Injectable,
|
|
14059
|
+
args: [{ providedIn: 'root' }]
|
|
14003
14060
|
}], ctorParameters: () => [{ type: ODataClient }] });
|
|
14004
14061
|
|
|
14005
14062
|
const ODATA_CONFIG = new InjectionToken('odata.config');
|
|
14006
|
-
function
|
|
14007
|
-
return new
|
|
14063
|
+
function defaultHttpSyncLoader(config, http) {
|
|
14064
|
+
return new ODataSyncLoader(config, (req) => http.request(req.method, `${req.url}`, {
|
|
14065
|
+
body: req.body,
|
|
14066
|
+
context: req.context,
|
|
14067
|
+
headers: req.headers,
|
|
14068
|
+
observe: req.observe,
|
|
14069
|
+
params: req.params,
|
|
14070
|
+
reportProgress: req.reportProgress,
|
|
14071
|
+
responseType: req.responseType,
|
|
14072
|
+
withCredentials: req.withCredentials,
|
|
14073
|
+
}));
|
|
14008
14074
|
}
|
|
14009
14075
|
// Standalone version
|
|
14010
14076
|
function provideODataClient(passedConfig) {
|
|
14011
|
-
|
|
14012
|
-
|
|
14013
|
-
passedConfig
|
|
14014
|
-
|
|
14015
|
-
|
|
14016
|
-
deps: [ODATA_CONFIG],
|
|
14017
|
-
},
|
|
14077
|
+
let providers = [
|
|
14078
|
+
// Make the ODATA_CONFIG available through injection
|
|
14079
|
+
{ provide: ODATA_CONFIG, useValue: passedConfig.config ?? [] },
|
|
14080
|
+
// Register the startup task
|
|
14081
|
+
provideAppInitializer(() => inject(ODataClient).initialize()),
|
|
14018
14082
|
ODataClient,
|
|
14019
14083
|
ODataServiceFactory,
|
|
14020
|
-
]
|
|
14084
|
+
];
|
|
14085
|
+
if (passedConfig?.loader === undefined) {
|
|
14086
|
+
providers = [
|
|
14087
|
+
...providers,
|
|
14088
|
+
provideHttpClient(),
|
|
14089
|
+
{
|
|
14090
|
+
provide: ODataLoader,
|
|
14091
|
+
useFactory: defaultHttpSyncLoader,
|
|
14092
|
+
deps: [ODATA_CONFIG, HttpClient],
|
|
14093
|
+
},
|
|
14094
|
+
];
|
|
14095
|
+
}
|
|
14096
|
+
else {
|
|
14097
|
+
providers = [...providers, passedConfig.loader];
|
|
14098
|
+
}
|
|
14099
|
+
return makeEnvironmentProviders(providers);
|
|
14021
14100
|
}
|
|
14022
14101
|
// Module version
|
|
14023
14102
|
class ODataModule {
|
|
14024
14103
|
static forRoot(passedConfig) {
|
|
14104
|
+
let providers = [
|
|
14105
|
+
// Make the ODATA_CONFIG available through injection
|
|
14106
|
+
{ provide: ODATA_CONFIG, useValue: passedConfig.config ?? [] },
|
|
14107
|
+
// Register the startup task
|
|
14108
|
+
provideAppInitializer(() => inject(ODataClient).initialize()),
|
|
14109
|
+
ODataClient,
|
|
14110
|
+
ODataServiceFactory,
|
|
14111
|
+
];
|
|
14112
|
+
if (passedConfig?.loader === undefined) {
|
|
14113
|
+
providers = [
|
|
14114
|
+
...providers,
|
|
14115
|
+
provideHttpClient(),
|
|
14116
|
+
{
|
|
14117
|
+
provide: ODataLoader,
|
|
14118
|
+
useFactory: defaultHttpSyncLoader,
|
|
14119
|
+
deps: [ODATA_CONFIG, HttpClient],
|
|
14120
|
+
},
|
|
14121
|
+
];
|
|
14122
|
+
}
|
|
14123
|
+
else {
|
|
14124
|
+
providers = [...providers, passedConfig.loader];
|
|
14125
|
+
}
|
|
14025
14126
|
return {
|
|
14026
14127
|
ngModule: ODataModule,
|
|
14027
|
-
providers
|
|
14028
|
-
// Make the ODATA_CONFIG available through injection
|
|
14029
|
-
{ provide: ODATA_CONFIG, useValue: passedConfig },
|
|
14030
|
-
// Create the loader: Either the one getting passed or a sync one
|
|
14031
|
-
passedConfig?.loader ?? {
|
|
14032
|
-
provide: ODataConfigLoader,
|
|
14033
|
-
useFactory: createSyncLoader,
|
|
14034
|
-
deps: [ODATA_CONFIG],
|
|
14035
|
-
},
|
|
14036
|
-
ODataClient,
|
|
14037
|
-
ODataServiceFactory,
|
|
14038
|
-
],
|
|
14128
|
+
providers,
|
|
14039
14129
|
};
|
|
14040
14130
|
}
|
|
14041
14131
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
14042
14132
|
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.0.5", ngImport: i0, type: ODataModule, imports: [CommonModule] });
|
|
14043
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: ODataModule,
|
|
14133
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: ODataModule, imports: [CommonModule] });
|
|
14044
14134
|
}
|
|
14045
14135
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: ODataModule, decorators: [{
|
|
14046
14136
|
type: NgModule,
|
|
14047
14137
|
args: [{
|
|
14048
14138
|
imports: [CommonModule],
|
|
14049
|
-
providers: [ODataClient, ODataServiceFactory],
|
|
14050
14139
|
}]
|
|
14051
14140
|
}] });
|
|
14052
14141
|
|
|
@@ -14061,7 +14150,7 @@ class ODataBaseCache {
|
|
|
14061
14150
|
* @returns Boolean indicating if the entry is expired
|
|
14062
14151
|
*/
|
|
14063
14152
|
isExpired(entry) {
|
|
14064
|
-
return entry.date <
|
|
14153
|
+
return entry.date < Date.now() - entry.maxAge;
|
|
14065
14154
|
}
|
|
14066
14155
|
/**
|
|
14067
14156
|
* Using the resource on the request build an array of string to identify the scope of the request
|
|
@@ -14215,15 +14304,17 @@ class ODataInStorageCache extends ODataBaseCache {
|
|
|
14215
14304
|
}
|
|
14216
14305
|
get(name, { scope } = {}) {
|
|
14217
14306
|
const key = this.buildKey([...(scope || []), name]);
|
|
14218
|
-
const entry = JSON.parse(this.storage.getItem(key) ??
|
|
14307
|
+
const entry = JSON.parse(this.storage.getItem(key) ?? '{}');
|
|
14219
14308
|
return entry !== undefined && !this.isExpired(entry) ? entry.payload : undefined;
|
|
14220
14309
|
}
|
|
14221
14310
|
forget({ name, scope = [], tags = [], }) {
|
|
14222
14311
|
if (name)
|
|
14223
14312
|
scope.push(name);
|
|
14224
14313
|
const key = scope.length > 0 ? this.buildKey(scope) : undefined;
|
|
14225
|
-
Object.keys(this.storage)
|
|
14226
|
-
|
|
14314
|
+
Object.keys(this.storage)
|
|
14315
|
+
.filter((k) => k.startsWith(this.prefix))
|
|
14316
|
+
.forEach((k) => {
|
|
14317
|
+
const entry = JSON.parse(this.storage.getItem(k) ?? '{}');
|
|
14227
14318
|
if (this.isExpired(entry) || // Expired
|
|
14228
14319
|
(key !== undefined && k.startsWith(key)) || // Key
|
|
14229
14320
|
(tags.length > 0 && tags.some((t) => entry.tags.indexOf(t) !== -1)) // Tags
|
|
@@ -14236,7 +14327,9 @@ class ODataInStorageCache extends ODataBaseCache {
|
|
|
14236
14327
|
* Flush the cache and clean the storage
|
|
14237
14328
|
*/
|
|
14238
14329
|
flush() {
|
|
14239
|
-
Object.keys(this.storage)
|
|
14330
|
+
Object.keys(this.storage)
|
|
14331
|
+
.filter((k) => k.startsWith(this.prefix))
|
|
14332
|
+
.forEach((k) => {
|
|
14240
14333
|
this.storage.removeItem(k);
|
|
14241
14334
|
});
|
|
14242
14335
|
}
|
|
@@ -14265,7 +14358,7 @@ class ODataInStorageCache extends ODataBaseCache {
|
|
|
14265
14358
|
return data !== undefined ? ODataResponse.fromJson(req, data) : undefined;
|
|
14266
14359
|
}
|
|
14267
14360
|
size() {
|
|
14268
|
-
return Object.keys(this.storage).filter(k => k.startsWith(this.prefix)).length;
|
|
14361
|
+
return Object.keys(this.storage).filter((k) => k.startsWith(this.prefix)).length;
|
|
14269
14362
|
}
|
|
14270
14363
|
}
|
|
14271
14364
|
|
|
@@ -14409,5 +14502,5 @@ class ODataIndexedDBCache extends ODataBaseCache {
|
|
|
14409
14502
|
* Generated bundle index. Do not edit.
|
|
14410
14503
|
*/
|
|
14411
14504
|
|
|
14412
|
-
export { Aggregate, ApplyExpression, ArithmeticFunctions, ArithmeticOperators, BUBBLES, Casting, CastingOperators, CollectionFunctions, ComputeExpression, ConditionalFunctions, DateAndTimeFunctions, Dates, Durations, EDM_PARSERS, EdmType, Enums, ExpandExpression, ExpandField, Expression, FieldFactory, FilterExpression, Function, GeoFunctions, GroupBy, GroupByTransformations, Grouping, GroupingOperators, Http, INCLUDE_DEEP, INCLUDE_SHALLOW, ITEM_ROOT, JsonSchemaType, Lambda, LambdaOperators, LogicalOperators, Model, ModelField, NONE_PARSER, ODATA_CONFIG, OData, ODataActionResource, ODataAnnotations, ODataApi, ODataBaseCache, ODataBaseService, ODataBatchRequest, ODataBatchResource, ODataCallable, ODataCallableParser, ODataClient, ODataCollection,
|
|
14505
|
+
export { Aggregate, ApplyExpression, ArithmeticFunctions, ArithmeticOperators, BUBBLES, Casting, CastingOperators, CollectionFunctions, ComputeExpression, ConditionalFunctions, DateAndTimeFunctions, Dates, Durations, EDM_PARSERS, EdmType, Enums, ExpandExpression, ExpandField, Expression, FieldFactory, FilterExpression, Function, GeoFunctions, GroupBy, GroupByTransformations, Grouping, GroupingOperators, Http, INCLUDE_DEEP, INCLUDE_SHALLOW, ITEM_ROOT, JsonSchemaType, Lambda, LambdaOperators, LogicalOperators, Model, ModelField, NONE_PARSER, ODATA_CONFIG, OData, ODataActionResource, ODataAnnotations, ODataApi, ODataAsyncLoader, ODataBaseCache, ODataBaseService, ODataBatchRequest, ODataBatchResource, ODataCallable, ODataCallableParser, ODataClient, ODataCollection, ODataCountResource, ODataEntitiesAnnotations, ODataEntityAnnotations, ODataEntityContainer, ODataEntityResource, ODataEntitySet, ODataEntitySetResource, ODataEntitySetService, ODataEntityTypeKey, ODataEnumType, ODataEnumTypeFieldParser, ODataEnumTypeParser, ODataFunctionResource, ODataFunctions, ODataInMemoryCache, ODataInStorageCache, ODataIndexedDBCache, ODataLoader, ODataMediaResource, ODataMetadata, ODataMetadataLoader, ODataMetadataParser, ODataMetadataResource, ODataModel, ODataModelAttribute, ODataModelEvent, ODataModelEventEmitter, ODataModelEventType, ODataModelField, ODataModelOptions, ODataModelState, ODataModule, ODataNavigationPropertyResource, ODataOperators, ODataParameterParser, ODataPathSegments, ODataPathSegmentsHandler, ODataPropertyAnnotations, ODataPropertyResource, ODataQueryOptionHandler, ODataQueryOptions, ODataQueryOptionsHandler, ODataReferenceResource, ODataReferential, ODataRequest, ODataResource, ODataResponse, ODataSchema, ODataServiceFactory, ODataSettings, ODataSingleton, ODataSingletonResource, ODataSingletonService, ODataStructuredType, ODataStructuredTypeFieldParser, ODataStructuredTypeParser, ODataSyncLoader, ODataTransformations, ODataValueResource, Objects, Operator, OrderByExpression, OrderByField, PathSegment, QueryCustomTypes, QueryOption, RenderableFactory, SearchExpression, SearchTerm, SegmentHandler, SelectExpression, StandardAggregateMethods, StringAndCollectionFunctions, StringFunctions, Strings, Transformations, Type, TypeFunctions, Types, Urls, alias, binary, buildPathAndQuery, defaultHttpSyncLoader, duration, encode, functions, isQueryCustomType, isRawType, normalizeValue, operators, pathAndParamsFromQueryOptions, pathAndParamsFromSegments, provideODataClient, raw, render, resolve, transformations };
|
|
14413
14506
|
//# sourceMappingURL=angular-odata.mjs.map
|