angular-odata 0.147.0 → 0.149.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 -48
- 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/files/api-config/__fileName__.ts +2 -0
- package/schematics/apigen/files/collection/__fileName__.ts +2 -0
- package/schematics/apigen/files/entity/__fileName__.ts +2 -0
- package/schematics/apigen/files/entitycontainer-service/__fileName__.ts +2 -0
- package/schematics/apigen/files/entityset-service/__fileName__.ts +2 -0
- package/schematics/apigen/files/enum/__fileName__.ts +2 -0
- package/schematics/apigen/files/model/__fileName__.ts +3 -1
- package/schematics/apigen/files/module/__fileName__.ts +2 -0
- package/schematics/apigen/files/singleton-service/__fileName__.ts +2 -0
- 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 +48 -45
|
@@ -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
|
});
|
|
@@ -11346,7 +11359,6 @@ class ODataModel {
|
|
|
11346
11359
|
asEntity(ctx) {
|
|
11347
11360
|
return this._meta.asEntity(this, ctx);
|
|
11348
11361
|
}
|
|
11349
|
-
//#region Callables
|
|
11350
11362
|
callFunction(name, params, responseType, options = {}) {
|
|
11351
11363
|
const resource = this.resource();
|
|
11352
11364
|
if (!(resource instanceof ODataEntityResource) || !resource.hasKey())
|
|
@@ -11756,7 +11768,7 @@ class ODataModelField {
|
|
|
11756
11768
|
annotatedValue(term) {
|
|
11757
11769
|
return this.parser.annotatedValue(term);
|
|
11758
11770
|
}
|
|
11759
|
-
configure({ concurrency, options
|
|
11771
|
+
configure({ concurrency, options }) {
|
|
11760
11772
|
this.parserOptions = options;
|
|
11761
11773
|
if (concurrency)
|
|
11762
11774
|
this.concurrency = concurrency;
|
|
@@ -12203,8 +12215,10 @@ class ODataModelOptions {
|
|
|
12203
12215
|
// Break if no resource
|
|
12204
12216
|
if (resource === null)
|
|
12205
12217
|
break;
|
|
12206
|
-
// Resolve Key
|
|
12207
|
-
if ((prevField === null || prevField.collection) &&
|
|
12218
|
+
// Resolve Key
|
|
12219
|
+
if ((prevField === null || prevField.collection) &&
|
|
12220
|
+
ODataModelOptions.isModel(model) &&
|
|
12221
|
+
model._meta.isEntityType()) {
|
|
12208
12222
|
const key = model.key({ field_mapping: true });
|
|
12209
12223
|
if (key !== undefined) {
|
|
12210
12224
|
resource =
|
|
@@ -12828,8 +12842,7 @@ class ODataInclude {
|
|
|
12828
12842
|
this.alias = config.alias;
|
|
12829
12843
|
this.reference = reference;
|
|
12830
12844
|
}
|
|
12831
|
-
configure({ options }) {
|
|
12832
|
-
}
|
|
12845
|
+
configure({ options }) { }
|
|
12833
12846
|
}
|
|
12834
12847
|
class ODataIncludeAnnotation {
|
|
12835
12848
|
termNamespace;
|
|
@@ -12842,8 +12855,7 @@ class ODataIncludeAnnotation {
|
|
|
12842
12855
|
this.targetNamespace = config.targetNamespace;
|
|
12843
12856
|
this.reference = reference;
|
|
12844
12857
|
}
|
|
12845
|
-
configure({ options }) {
|
|
12846
|
-
}
|
|
12858
|
+
configure({ options }) { }
|
|
12847
12859
|
}
|
|
12848
12860
|
class ODataReference extends ODataAnnotatable {
|
|
12849
12861
|
api;
|
|
@@ -12885,7 +12897,7 @@ class ODataApi {
|
|
|
12885
12897
|
errorHandler;
|
|
12886
12898
|
// Base Parsers
|
|
12887
12899
|
parsers;
|
|
12888
|
-
// Populate from Metadata
|
|
12900
|
+
// Populate from Metadata
|
|
12889
12901
|
populateFromMetadata;
|
|
12890
12902
|
// Schemas
|
|
12891
12903
|
schemas;
|
|
@@ -12936,9 +12948,11 @@ class ODataApi {
|
|
|
12936
12948
|
}
|
|
12937
12949
|
}
|
|
12938
12950
|
});
|
|
12939
|
-
return
|
|
12940
|
-
firstValueFrom(this.metadata()
|
|
12941
|
-
|
|
12951
|
+
return this.populateFromMetadata
|
|
12952
|
+
? firstValueFrom(this.metadata()
|
|
12953
|
+
.fetch()
|
|
12954
|
+
.pipe(map((metadata) => this.populate(metadata))))
|
|
12955
|
+
: Promise.resolve(true);
|
|
12942
12956
|
}
|
|
12943
12957
|
populate(metadata) {
|
|
12944
12958
|
const config = metadata.toConfig();
|
|
@@ -13100,9 +13114,11 @@ class ODataApi {
|
|
|
13100
13114
|
* @returns
|
|
13101
13115
|
*/
|
|
13102
13116
|
handleRequest(req) {
|
|
13103
|
-
return
|
|
13104
|
-
|
|
13105
|
-
|
|
13117
|
+
return this.cache !== undefined && req.isFetch()
|
|
13118
|
+
? this.handleCacheFetch(req)
|
|
13119
|
+
: this.cache !== undefined && req.isMutate()
|
|
13120
|
+
? this.handleCacheMutate(req)
|
|
13121
|
+
: this.handleRequester(req);
|
|
13106
13122
|
}
|
|
13107
13123
|
handleRequester(req) {
|
|
13108
13124
|
return (this.requester !== undefined ? this.requester(req) : NEVER).pipe(map((res) => res.type === HttpEventType.Response ? ODataResponse.fromHttpResponse(req, res) : res));
|
|
@@ -13126,7 +13142,8 @@ class ODataApi {
|
|
|
13126
13142
|
? this.handleRequester(req).pipe(startWith(cached))
|
|
13127
13143
|
: of(cached)
|
|
13128
13144
|
: this.handleRequester(req);
|
|
13129
|
-
if (cached === undefined &&
|
|
13145
|
+
if (cached === undefined &&
|
|
13146
|
+
(policy === 'cache-first' || policy === 'cache-and-network' || policy === 'network-only')) {
|
|
13130
13147
|
res$ = res$.pipe(tap((res) => {
|
|
13131
13148
|
if (res.options.cacheability !== 'no-store') {
|
|
13132
13149
|
this.cache.putResponse(req, res);
|
|
@@ -13192,7 +13209,8 @@ class ODataApi {
|
|
|
13192
13209
|
}
|
|
13193
13210
|
const structuredTypes = this.schemas.reduce((acc, schema) => [...acc, ...schema.entities], []);
|
|
13194
13211
|
let structuredType = structuredTypes.find((e) => e.type() === value);
|
|
13195
|
-
structuredType =
|
|
13212
|
+
structuredType =
|
|
13213
|
+
structuredType ?? structuredTypes.find((e) => e.type({ alias: true }) === value);
|
|
13196
13214
|
structuredType = structuredType ?? structuredTypes.find((e) => e.name === value);
|
|
13197
13215
|
this.memo.structuredTypes.set(value, structuredType);
|
|
13198
13216
|
return structuredType;
|
|
@@ -13526,10 +13544,12 @@ class ODataAsyncLoader {
|
|
|
13526
13544
|
}
|
|
13527
13545
|
load() {
|
|
13528
13546
|
return firstValueFrom(Array.isArray(this.configs$)
|
|
13529
|
-
? forkJoin(this.configs$).pipe(map$1(configs => ({ configs, requester: this.requester })))
|
|
13547
|
+
? forkJoin(this.configs$).pipe(map$1((configs) => ({ configs, requester: this.requester })))
|
|
13530
13548
|
: this.configs$.pipe(map$1((value) => ({
|
|
13531
|
-
configs: Array.isArray(value)
|
|
13532
|
-
|
|
13549
|
+
configs: Array.isArray(value)
|
|
13550
|
+
? value
|
|
13551
|
+
: [value],
|
|
13552
|
+
requester: this.requester,
|
|
13533
13553
|
}))));
|
|
13534
13554
|
}
|
|
13535
13555
|
}
|
|
@@ -13546,7 +13566,7 @@ class ODataMetadataLoader {
|
|
|
13546
13566
|
const configs = Array.isArray(this.baseConfigs) ? this.baseConfigs : [this.baseConfigs];
|
|
13547
13567
|
return firstValueFrom(this.sources$.pipe(map$1((source) => ({
|
|
13548
13568
|
configs: (Array.isArray(source) ? source : [source]).map((m, i) => new ODataMetadataParser(m).metadata().toConfig(configs[i] ?? {})),
|
|
13549
|
-
requester: this.requester
|
|
13569
|
+
requester: this.requester,
|
|
13550
13570
|
}))));
|
|
13551
13571
|
}
|
|
13552
13572
|
}
|
|
@@ -13571,12 +13591,13 @@ class ODataClient {
|
|
|
13571
13591
|
this.loader = loader;
|
|
13572
13592
|
}
|
|
13573
13593
|
initialize() {
|
|
13574
|
-
return this.loader
|
|
13594
|
+
return this.loader
|
|
13595
|
+
.load()
|
|
13575
13596
|
.then(({ configs, requester }) => {
|
|
13576
13597
|
this.settings = new ODataSettings(configs);
|
|
13577
13598
|
return this.settings.initialize(requester);
|
|
13578
13599
|
})
|
|
13579
|
-
.then(results => results.every(v => v));
|
|
13600
|
+
.then((results) => results.every((v) => v));
|
|
13580
13601
|
}
|
|
13581
13602
|
//#region Resolve Building Blocks
|
|
13582
13603
|
/**
|
|
@@ -14061,13 +14082,15 @@ function provideODataClient(passedConfig) {
|
|
|
14061
14082
|
ODataServiceFactory,
|
|
14062
14083
|
];
|
|
14063
14084
|
if (passedConfig?.loader === undefined) {
|
|
14064
|
-
providers = [
|
|
14085
|
+
providers = [
|
|
14086
|
+
...providers,
|
|
14065
14087
|
provideHttpClient(),
|
|
14066
14088
|
{
|
|
14067
14089
|
provide: ODataLoader,
|
|
14068
14090
|
useFactory: defaultHttpSyncLoader,
|
|
14069
14091
|
deps: [ODATA_CONFIG, HttpClient],
|
|
14070
|
-
}
|
|
14092
|
+
},
|
|
14093
|
+
];
|
|
14071
14094
|
}
|
|
14072
14095
|
else {
|
|
14073
14096
|
providers = [...providers, passedConfig.loader];
|
|
@@ -14086,20 +14109,22 @@ class ODataModule {
|
|
|
14086
14109
|
ODataServiceFactory,
|
|
14087
14110
|
];
|
|
14088
14111
|
if (passedConfig?.loader === undefined) {
|
|
14089
|
-
providers = [
|
|
14112
|
+
providers = [
|
|
14113
|
+
...providers,
|
|
14090
14114
|
provideHttpClient(),
|
|
14091
14115
|
{
|
|
14092
14116
|
provide: ODataLoader,
|
|
14093
14117
|
useFactory: defaultHttpSyncLoader,
|
|
14094
14118
|
deps: [ODATA_CONFIG, HttpClient],
|
|
14095
|
-
}
|
|
14119
|
+
},
|
|
14120
|
+
];
|
|
14096
14121
|
}
|
|
14097
14122
|
else {
|
|
14098
14123
|
providers = [...providers, passedConfig.loader];
|
|
14099
14124
|
}
|
|
14100
14125
|
return {
|
|
14101
14126
|
ngModule: ODataModule,
|
|
14102
|
-
providers
|
|
14127
|
+
providers,
|
|
14103
14128
|
};
|
|
14104
14129
|
}
|
|
14105
14130
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.5", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
@@ -14124,7 +14149,7 @@ class ODataBaseCache {
|
|
|
14124
14149
|
* @returns Boolean indicating if the entry is expired
|
|
14125
14150
|
*/
|
|
14126
14151
|
isExpired(entry) {
|
|
14127
|
-
return entry.date <
|
|
14152
|
+
return entry.date < Date.now() - entry.maxAge;
|
|
14128
14153
|
}
|
|
14129
14154
|
/**
|
|
14130
14155
|
* Using the resource on the request build an array of string to identify the scope of the request
|
|
@@ -14278,15 +14303,17 @@ class ODataInStorageCache extends ODataBaseCache {
|
|
|
14278
14303
|
}
|
|
14279
14304
|
get(name, { scope } = {}) {
|
|
14280
14305
|
const key = this.buildKey([...(scope || []), name]);
|
|
14281
|
-
const entry = JSON.parse(this.storage.getItem(key) ??
|
|
14306
|
+
const entry = JSON.parse(this.storage.getItem(key) ?? '{}');
|
|
14282
14307
|
return entry !== undefined && !this.isExpired(entry) ? entry.payload : undefined;
|
|
14283
14308
|
}
|
|
14284
14309
|
forget({ name, scope = [], tags = [], }) {
|
|
14285
14310
|
if (name)
|
|
14286
14311
|
scope.push(name);
|
|
14287
14312
|
const key = scope.length > 0 ? this.buildKey(scope) : undefined;
|
|
14288
|
-
Object.keys(this.storage)
|
|
14289
|
-
|
|
14313
|
+
Object.keys(this.storage)
|
|
14314
|
+
.filter((k) => k.startsWith(this.prefix))
|
|
14315
|
+
.forEach((k) => {
|
|
14316
|
+
const entry = JSON.parse(this.storage.getItem(k) ?? '{}');
|
|
14290
14317
|
if (this.isExpired(entry) || // Expired
|
|
14291
14318
|
(key !== undefined && k.startsWith(key)) || // Key
|
|
14292
14319
|
(tags.length > 0 && tags.some((t) => entry.tags.indexOf(t) !== -1)) // Tags
|
|
@@ -14299,7 +14326,9 @@ class ODataInStorageCache extends ODataBaseCache {
|
|
|
14299
14326
|
* Flush the cache and clean the storage
|
|
14300
14327
|
*/
|
|
14301
14328
|
flush() {
|
|
14302
|
-
Object.keys(this.storage)
|
|
14329
|
+
Object.keys(this.storage)
|
|
14330
|
+
.filter((k) => k.startsWith(this.prefix))
|
|
14331
|
+
.forEach((k) => {
|
|
14303
14332
|
this.storage.removeItem(k);
|
|
14304
14333
|
});
|
|
14305
14334
|
}
|
|
@@ -14328,7 +14357,7 @@ class ODataInStorageCache extends ODataBaseCache {
|
|
|
14328
14357
|
return data !== undefined ? ODataResponse.fromJson(req, data) : undefined;
|
|
14329
14358
|
}
|
|
14330
14359
|
size() {
|
|
14331
|
-
return Object.keys(this.storage).filter(k => k.startsWith(this.prefix)).length;
|
|
14360
|
+
return Object.keys(this.storage).filter((k) => k.startsWith(this.prefix)).length;
|
|
14332
14361
|
}
|
|
14333
14362
|
}
|
|
14334
14363
|
|