angular-odata 0.147.0 → 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 +77 -47
- 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 +32 -43
|
@@ -527,7 +527,11 @@ const binary = (value) => ({
|
|
|
527
527
|
type: QueryCustomTypes.Binary,
|
|
528
528
|
value,
|
|
529
529
|
});
|
|
530
|
-
const isQueryCustomType = (value) => value !== null &&
|
|
530
|
+
const isQueryCustomType = (value) => value !== null &&
|
|
531
|
+
value !== undefined &&
|
|
532
|
+
typeof value === 'object' &&
|
|
533
|
+
'type' in value &&
|
|
534
|
+
value.type in QueryCustomTypes;
|
|
531
535
|
const isRawType = (value) => isQueryCustomType(value) && value.type === QueryCustomTypes.Raw;
|
|
532
536
|
const ITEM_ROOT = '';
|
|
533
537
|
function builder ({ select, search, skiptoken, format, top, skip, filter, transform, compute, orderBy, key, count, expand, action, func, aliases, escape, } = {}) {
|
|
@@ -2987,8 +2991,10 @@ class ODataStructuredType extends ODataParserSchemaElement {
|
|
|
2987
2991
|
configure({ options }) {
|
|
2988
2992
|
if (this.base) {
|
|
2989
2993
|
const parent = this.api.findStructuredType(this.base);
|
|
2990
|
-
parent
|
|
2991
|
-
|
|
2994
|
+
if (parent !== undefined) {
|
|
2995
|
+
parent.children.push(this);
|
|
2996
|
+
this.parent = parent;
|
|
2997
|
+
}
|
|
2992
2998
|
}
|
|
2993
2999
|
this.parser.configure({
|
|
2994
3000
|
options,
|
|
@@ -5634,7 +5640,7 @@ class ODataQueryOptions {
|
|
|
5634
5640
|
return new ODataQueryOptions(new Map(entries));
|
|
5635
5641
|
}
|
|
5636
5642
|
toQueryArguments() {
|
|
5637
|
-
return {
|
|
5643
|
+
return Objects.clone({
|
|
5638
5644
|
select: this._values.get(QueryOption.select) ?? null,
|
|
5639
5645
|
expand: this._values.get(QueryOption.expand) ?? null,
|
|
5640
5646
|
transform: this._values.get(QueryOption.transform) ?? null,
|
|
@@ -5648,7 +5654,7 @@ class ODataQueryOptions {
|
|
|
5648
5654
|
skiptoken: this._values.get(QueryOption.skiptoken) ?? null,
|
|
5649
5655
|
levels: this._values.get(QueryOption.levels) ?? null,
|
|
5650
5656
|
count: this._values.get(QueryOption.count) ?? null,
|
|
5651
|
-
};
|
|
5657
|
+
});
|
|
5652
5658
|
}
|
|
5653
5659
|
clone() {
|
|
5654
5660
|
return new ODataQueryOptions(Objects.clone(this._values));
|
|
@@ -6170,6 +6176,7 @@ class ODataResource {
|
|
|
6170
6176
|
resource.query((q) => q.restore(this.queryOptions.toQueryArguments()));
|
|
6171
6177
|
}
|
|
6172
6178
|
return ModelType.factory(entity, {
|
|
6179
|
+
parent: null,
|
|
6173
6180
|
resource: resource,
|
|
6174
6181
|
annots,
|
|
6175
6182
|
reset,
|
|
@@ -6189,6 +6196,7 @@ class ODataResource {
|
|
|
6189
6196
|
resource.query((q) => q.restore(this.queryOptions.toQueryArguments()));
|
|
6190
6197
|
}
|
|
6191
6198
|
return CollectionType.factory(entities, {
|
|
6199
|
+
parent: null,
|
|
6192
6200
|
resource: resource,
|
|
6193
6201
|
annots,
|
|
6194
6202
|
reset,
|
|
@@ -6253,12 +6261,15 @@ class ODataResource {
|
|
|
6253
6261
|
}
|
|
6254
6262
|
toString({ escape, ...options } = {
|
|
6255
6263
|
escape: false,
|
|
6264
|
+
params: true,
|
|
6256
6265
|
}) {
|
|
6257
|
-
let [
|
|
6258
|
-
|
|
6266
|
+
let [rpath, rparams] = this.pathAndParams({ escape, ...options });
|
|
6267
|
+
if (!options.params)
|
|
6268
|
+
return rpath;
|
|
6269
|
+
let queryString = Object.entries(rparams)
|
|
6259
6270
|
.map((e) => `${e[0]}${VALUE_SEPARATOR}${e[1]}`)
|
|
6260
6271
|
.join(PARAM_SEPARATOR);
|
|
6261
|
-
return queryString ? `${
|
|
6272
|
+
return queryString ? `${rpath}${QUERY_SEPARATOR}${queryString}` : rpath;
|
|
6262
6273
|
}
|
|
6263
6274
|
clone() {
|
|
6264
6275
|
const Ctor = this.constructor;
|
|
@@ -8431,13 +8442,13 @@ class CsdlProperty extends CsdlStructuralProperty {
|
|
|
8431
8442
|
class CsdlNavigationProperty extends CsdlStructuralProperty {
|
|
8432
8443
|
Partner;
|
|
8433
8444
|
ContainsTarget;
|
|
8434
|
-
|
|
8445
|
+
ReferentialConstraint;
|
|
8435
8446
|
OnDelete;
|
|
8436
|
-
constructor({ Name, Type, Nullable, Partner, ContainsTarget,
|
|
8447
|
+
constructor({ Name, Type, Nullable, Partner, ContainsTarget, ReferentialConstraint, OnDelete, Annotation, }) {
|
|
8437
8448
|
super({ Name, Type, Nullable, Annotation });
|
|
8438
8449
|
this.Partner = Partner;
|
|
8439
8450
|
this.ContainsTarget = ContainsTarget;
|
|
8440
|
-
this.
|
|
8451
|
+
this.ReferentialConstraint = ReferentialConstraint?.map((r) => new CsdlReferentialConstraint(r));
|
|
8441
8452
|
this.OnDelete = OnDelete ? new CsdlOnDelete(OnDelete) : undefined;
|
|
8442
8453
|
}
|
|
8443
8454
|
toJson() {
|
|
@@ -8448,8 +8459,8 @@ class CsdlNavigationProperty extends CsdlStructuralProperty {
|
|
|
8448
8459
|
if (this.ContainsTarget !== undefined) {
|
|
8449
8460
|
json['ContainsTarget'] = this.ContainsTarget;
|
|
8450
8461
|
}
|
|
8451
|
-
if (Array.isArray(this.
|
|
8452
|
-
json['
|
|
8462
|
+
if (Array.isArray(this.ReferentialConstraint) && this.ReferentialConstraint.length > 0) {
|
|
8463
|
+
json['ReferentialConstraint'] = this.ReferentialConstraint.map((r) => r.toJson());
|
|
8453
8464
|
}
|
|
8454
8465
|
if (this.OnDelete !== undefined) {
|
|
8455
8466
|
json['OnDelete'] = this.OnDelete;
|
|
@@ -8464,7 +8475,7 @@ class CsdlNavigationProperty extends CsdlStructuralProperty {
|
|
|
8464
8475
|
collection: this.Collection,
|
|
8465
8476
|
nullable: this.Nullable,
|
|
8466
8477
|
navigation: true,
|
|
8467
|
-
referentials: this.
|
|
8478
|
+
referentials: this.ReferentialConstraint?.map((r) => ({
|
|
8468
8479
|
property: r.Property,
|
|
8469
8480
|
referencedProperty: r.ReferencedProperty,
|
|
8470
8481
|
})),
|
|
@@ -10371,6 +10382,7 @@ class ODataCollection {
|
|
|
10371
10382
|
}
|
|
10372
10383
|
clone() {
|
|
10373
10384
|
return new this.constructor(this.toEntities(INCLUDE_DEEP), {
|
|
10385
|
+
parent: this._parent,
|
|
10374
10386
|
resource: this.resource()?.clone(),
|
|
10375
10387
|
annots: this.annots().clone(),
|
|
10376
10388
|
});
|
|
@@ -11218,6 +11230,7 @@ class ODataModel {
|
|
|
11218
11230
|
}
|
|
11219
11231
|
clone() {
|
|
11220
11232
|
return new this.constructor(this.toEntity(INCLUDE_DEEP), {
|
|
11233
|
+
parent: this._parent,
|
|
11221
11234
|
resource: this.resource()?.clone(),
|
|
11222
11235
|
annots: this.annots().clone(),
|
|
11223
11236
|
});
|
|
@@ -11756,7 +11769,7 @@ class ODataModelField {
|
|
|
11756
11769
|
annotatedValue(term) {
|
|
11757
11770
|
return this.parser.annotatedValue(term);
|
|
11758
11771
|
}
|
|
11759
|
-
configure({ concurrency, options
|
|
11772
|
+
configure({ concurrency, options }) {
|
|
11760
11773
|
this.parserOptions = options;
|
|
11761
11774
|
if (concurrency)
|
|
11762
11775
|
this.concurrency = concurrency;
|
|
@@ -12203,8 +12216,10 @@ class ODataModelOptions {
|
|
|
12203
12216
|
// Break if no resource
|
|
12204
12217
|
if (resource === null)
|
|
12205
12218
|
break;
|
|
12206
|
-
// Resolve Key
|
|
12207
|
-
if ((prevField === null || prevField.collection) &&
|
|
12219
|
+
// Resolve Key
|
|
12220
|
+
if ((prevField === null || prevField.collection) &&
|
|
12221
|
+
ODataModelOptions.isModel(model) &&
|
|
12222
|
+
model._meta.isEntityType()) {
|
|
12208
12223
|
const key = model.key({ field_mapping: true });
|
|
12209
12224
|
if (key !== undefined) {
|
|
12210
12225
|
resource =
|
|
@@ -12828,8 +12843,7 @@ class ODataInclude {
|
|
|
12828
12843
|
this.alias = config.alias;
|
|
12829
12844
|
this.reference = reference;
|
|
12830
12845
|
}
|
|
12831
|
-
configure({ options }) {
|
|
12832
|
-
}
|
|
12846
|
+
configure({ options }) { }
|
|
12833
12847
|
}
|
|
12834
12848
|
class ODataIncludeAnnotation {
|
|
12835
12849
|
termNamespace;
|
|
@@ -12842,8 +12856,7 @@ class ODataIncludeAnnotation {
|
|
|
12842
12856
|
this.targetNamespace = config.targetNamespace;
|
|
12843
12857
|
this.reference = reference;
|
|
12844
12858
|
}
|
|
12845
|
-
configure({ options }) {
|
|
12846
|
-
}
|
|
12859
|
+
configure({ options }) { }
|
|
12847
12860
|
}
|
|
12848
12861
|
class ODataReference extends ODataAnnotatable {
|
|
12849
12862
|
api;
|
|
@@ -12885,7 +12898,7 @@ class ODataApi {
|
|
|
12885
12898
|
errorHandler;
|
|
12886
12899
|
// Base Parsers
|
|
12887
12900
|
parsers;
|
|
12888
|
-
// Populate from Metadata
|
|
12901
|
+
// Populate from Metadata
|
|
12889
12902
|
populateFromMetadata;
|
|
12890
12903
|
// Schemas
|
|
12891
12904
|
schemas;
|
|
@@ -12936,9 +12949,11 @@ class ODataApi {
|
|
|
12936
12949
|
}
|
|
12937
12950
|
}
|
|
12938
12951
|
});
|
|
12939
|
-
return
|
|
12940
|
-
firstValueFrom(this.metadata()
|
|
12941
|
-
|
|
12952
|
+
return this.populateFromMetadata
|
|
12953
|
+
? firstValueFrom(this.metadata()
|
|
12954
|
+
.fetch()
|
|
12955
|
+
.pipe(map((metadata) => this.populate(metadata))))
|
|
12956
|
+
: Promise.resolve(true);
|
|
12942
12957
|
}
|
|
12943
12958
|
populate(metadata) {
|
|
12944
12959
|
const config = metadata.toConfig();
|
|
@@ -13100,9 +13115,11 @@ class ODataApi {
|
|
|
13100
13115
|
* @returns
|
|
13101
13116
|
*/
|
|
13102
13117
|
handleRequest(req) {
|
|
13103
|
-
return
|
|
13104
|
-
|
|
13105
|
-
|
|
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);
|
|
13106
13123
|
}
|
|
13107
13124
|
handleRequester(req) {
|
|
13108
13125
|
return (this.requester !== undefined ? this.requester(req) : NEVER).pipe(map((res) => res.type === HttpEventType.Response ? ODataResponse.fromHttpResponse(req, res) : res));
|
|
@@ -13126,7 +13143,8 @@ class ODataApi {
|
|
|
13126
13143
|
? this.handleRequester(req).pipe(startWith(cached))
|
|
13127
13144
|
: of(cached)
|
|
13128
13145
|
: this.handleRequester(req);
|
|
13129
|
-
if (cached === undefined &&
|
|
13146
|
+
if (cached === undefined &&
|
|
13147
|
+
(policy === 'cache-first' || policy === 'cache-and-network' || policy === 'network-only')) {
|
|
13130
13148
|
res$ = res$.pipe(tap((res) => {
|
|
13131
13149
|
if (res.options.cacheability !== 'no-store') {
|
|
13132
13150
|
this.cache.putResponse(req, res);
|
|
@@ -13192,7 +13210,8 @@ class ODataApi {
|
|
|
13192
13210
|
}
|
|
13193
13211
|
const structuredTypes = this.schemas.reduce((acc, schema) => [...acc, ...schema.entities], []);
|
|
13194
13212
|
let structuredType = structuredTypes.find((e) => e.type() === value);
|
|
13195
|
-
structuredType =
|
|
13213
|
+
structuredType =
|
|
13214
|
+
structuredType ?? structuredTypes.find((e) => e.type({ alias: true }) === value);
|
|
13196
13215
|
structuredType = structuredType ?? structuredTypes.find((e) => e.name === value);
|
|
13197
13216
|
this.memo.structuredTypes.set(value, structuredType);
|
|
13198
13217
|
return structuredType;
|
|
@@ -13526,10 +13545,12 @@ class ODataAsyncLoader {
|
|
|
13526
13545
|
}
|
|
13527
13546
|
load() {
|
|
13528
13547
|
return firstValueFrom(Array.isArray(this.configs$)
|
|
13529
|
-
? forkJoin(this.configs$).pipe(map$1(configs => ({ configs, requester: this.requester })))
|
|
13548
|
+
? forkJoin(this.configs$).pipe(map$1((configs) => ({ configs, requester: this.requester })))
|
|
13530
13549
|
: this.configs$.pipe(map$1((value) => ({
|
|
13531
|
-
configs: Array.isArray(value)
|
|
13532
|
-
|
|
13550
|
+
configs: Array.isArray(value)
|
|
13551
|
+
? value
|
|
13552
|
+
: [value],
|
|
13553
|
+
requester: this.requester,
|
|
13533
13554
|
}))));
|
|
13534
13555
|
}
|
|
13535
13556
|
}
|
|
@@ -13546,7 +13567,7 @@ class ODataMetadataLoader {
|
|
|
13546
13567
|
const configs = Array.isArray(this.baseConfigs) ? this.baseConfigs : [this.baseConfigs];
|
|
13547
13568
|
return firstValueFrom(this.sources$.pipe(map$1((source) => ({
|
|
13548
13569
|
configs: (Array.isArray(source) ? source : [source]).map((m, i) => new ODataMetadataParser(m).metadata().toConfig(configs[i] ?? {})),
|
|
13549
|
-
requester: this.requester
|
|
13570
|
+
requester: this.requester,
|
|
13550
13571
|
}))));
|
|
13551
13572
|
}
|
|
13552
13573
|
}
|
|
@@ -13571,12 +13592,13 @@ class ODataClient {
|
|
|
13571
13592
|
this.loader = loader;
|
|
13572
13593
|
}
|
|
13573
13594
|
initialize() {
|
|
13574
|
-
return this.loader
|
|
13595
|
+
return this.loader
|
|
13596
|
+
.load()
|
|
13575
13597
|
.then(({ configs, requester }) => {
|
|
13576
13598
|
this.settings = new ODataSettings(configs);
|
|
13577
13599
|
return this.settings.initialize(requester);
|
|
13578
13600
|
})
|
|
13579
|
-
.then(results => results.every(v => v));
|
|
13601
|
+
.then((results) => results.every((v) => v));
|
|
13580
13602
|
}
|
|
13581
13603
|
//#region Resolve Building Blocks
|
|
13582
13604
|
/**
|
|
@@ -14061,13 +14083,15 @@ function provideODataClient(passedConfig) {
|
|
|
14061
14083
|
ODataServiceFactory,
|
|
14062
14084
|
];
|
|
14063
14085
|
if (passedConfig?.loader === undefined) {
|
|
14064
|
-
providers = [
|
|
14086
|
+
providers = [
|
|
14087
|
+
...providers,
|
|
14065
14088
|
provideHttpClient(),
|
|
14066
14089
|
{
|
|
14067
14090
|
provide: ODataLoader,
|
|
14068
14091
|
useFactory: defaultHttpSyncLoader,
|
|
14069
14092
|
deps: [ODATA_CONFIG, HttpClient],
|
|
14070
|
-
}
|
|
14093
|
+
},
|
|
14094
|
+
];
|
|
14071
14095
|
}
|
|
14072
14096
|
else {
|
|
14073
14097
|
providers = [...providers, passedConfig.loader];
|
|
@@ -14086,20 +14110,22 @@ class ODataModule {
|
|
|
14086
14110
|
ODataServiceFactory,
|
|
14087
14111
|
];
|
|
14088
14112
|
if (passedConfig?.loader === undefined) {
|
|
14089
|
-
providers = [
|
|
14113
|
+
providers = [
|
|
14114
|
+
...providers,
|
|
14090
14115
|
provideHttpClient(),
|
|
14091
14116
|
{
|
|
14092
14117
|
provide: ODataLoader,
|
|
14093
14118
|
useFactory: defaultHttpSyncLoader,
|
|
14094
14119
|
deps: [ODATA_CONFIG, HttpClient],
|
|
14095
|
-
}
|
|
14120
|
+
},
|
|
14121
|
+
];
|
|
14096
14122
|
}
|
|
14097
14123
|
else {
|
|
14098
14124
|
providers = [...providers, passedConfig.loader];
|
|
14099
14125
|
}
|
|
14100
14126
|
return {
|
|
14101
14127
|
ngModule: ODataModule,
|
|
14102
|
-
providers
|
|
14128
|
+
providers,
|
|
14103
14129
|
};
|
|
14104
14130
|
}
|
|
14105
14131
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
@@ -14124,7 +14150,7 @@ class ODataBaseCache {
|
|
|
14124
14150
|
* @returns Boolean indicating if the entry is expired
|
|
14125
14151
|
*/
|
|
14126
14152
|
isExpired(entry) {
|
|
14127
|
-
return entry.date <
|
|
14153
|
+
return entry.date < Date.now() - entry.maxAge;
|
|
14128
14154
|
}
|
|
14129
14155
|
/**
|
|
14130
14156
|
* Using the resource on the request build an array of string to identify the scope of the request
|
|
@@ -14278,15 +14304,17 @@ class ODataInStorageCache extends ODataBaseCache {
|
|
|
14278
14304
|
}
|
|
14279
14305
|
get(name, { scope } = {}) {
|
|
14280
14306
|
const key = this.buildKey([...(scope || []), name]);
|
|
14281
|
-
const entry = JSON.parse(this.storage.getItem(key) ??
|
|
14307
|
+
const entry = JSON.parse(this.storage.getItem(key) ?? '{}');
|
|
14282
14308
|
return entry !== undefined && !this.isExpired(entry) ? entry.payload : undefined;
|
|
14283
14309
|
}
|
|
14284
14310
|
forget({ name, scope = [], tags = [], }) {
|
|
14285
14311
|
if (name)
|
|
14286
14312
|
scope.push(name);
|
|
14287
14313
|
const key = scope.length > 0 ? this.buildKey(scope) : undefined;
|
|
14288
|
-
Object.keys(this.storage)
|
|
14289
|
-
|
|
14314
|
+
Object.keys(this.storage)
|
|
14315
|
+
.filter((k) => k.startsWith(this.prefix))
|
|
14316
|
+
.forEach((k) => {
|
|
14317
|
+
const entry = JSON.parse(this.storage.getItem(k) ?? '{}');
|
|
14290
14318
|
if (this.isExpired(entry) || // Expired
|
|
14291
14319
|
(key !== undefined && k.startsWith(key)) || // Key
|
|
14292
14320
|
(tags.length > 0 && tags.some((t) => entry.tags.indexOf(t) !== -1)) // Tags
|
|
@@ -14299,7 +14327,9 @@ class ODataInStorageCache extends ODataBaseCache {
|
|
|
14299
14327
|
* Flush the cache and clean the storage
|
|
14300
14328
|
*/
|
|
14301
14329
|
flush() {
|
|
14302
|
-
Object.keys(this.storage)
|
|
14330
|
+
Object.keys(this.storage)
|
|
14331
|
+
.filter((k) => k.startsWith(this.prefix))
|
|
14332
|
+
.forEach((k) => {
|
|
14303
14333
|
this.storage.removeItem(k);
|
|
14304
14334
|
});
|
|
14305
14335
|
}
|
|
@@ -14328,7 +14358,7 @@ class ODataInStorageCache extends ODataBaseCache {
|
|
|
14328
14358
|
return data !== undefined ? ODataResponse.fromJson(req, data) : undefined;
|
|
14329
14359
|
}
|
|
14330
14360
|
size() {
|
|
14331
|
-
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;
|
|
14332
14362
|
}
|
|
14333
14363
|
}
|
|
14334
14364
|
|