angular-odata 0.100.0 → 0.100.1
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 +64 -54
- package/esm2020/lib/client.mjs +3 -3
- package/esm2020/lib/helper.mjs +91 -86
- package/esm2020/lib/models/collection.mjs +3 -3
- package/esm2020/lib/models/model.mjs +4 -4
- package/esm2020/lib/models/options.mjs +46 -39
- package/esm2020/lib/module.mjs +4 -4
- package/esm2020/lib/resources/query/builder.mjs +2 -2
- package/esm2020/lib/resources/query/handlers.mjs +29 -18
- package/esm2020/lib/resources/query/options.mjs +41 -35
- package/esm2020/lib/resources/resource.mjs +1 -1
- package/esm2020/lib/resources/responses/annotations.mjs +6 -6
- package/esm2020/lib/resources/responses/response.mjs +3 -3
- package/esm2020/lib/resources/types/function.mjs +3 -2
- package/esm2020/lib/schema/parsers/structured-type.mjs +5 -5
- package/esm2020/lib/schema/structured-type.mjs +4 -9
- package/esm2020/lib/services/factory.mjs +3 -3
- package/esm2020/lib/utils/urls.mjs +2 -2
- package/fesm2015/angular-odata.mjs +299 -264
- package/fesm2015/angular-odata.mjs.map +1 -1
- package/fesm2020/angular-odata.mjs +299 -264
- package/fesm2020/angular-odata.mjs.map +1 -1
- package/lib/helper.d.ts +28 -57
- package/lib/models/model.d.ts +3 -9
- package/lib/resources/query/builder.d.ts +1 -1
- package/lib/resources/query/handlers.d.ts +7 -3
- package/lib/resources/query/options.d.ts +7 -9
- package/lib/resources/responses/annotations.d.ts +12 -18
- package/lib/resources/responses/response.d.ts +1 -3
- package/package.json +3 -3
|
@@ -649,7 +649,7 @@ function escapeIllegalChars(string) {
|
|
|
649
649
|
string = string.replace(/'/g, "''");
|
|
650
650
|
return string;
|
|
651
651
|
}
|
|
652
|
-
function normalizeValue(value, { aliases, escape = false }) {
|
|
652
|
+
function normalizeValue(value, { aliases, escape = false, } = {}) {
|
|
653
653
|
if (typeof value === 'string') {
|
|
654
654
|
return escape ? `'${escapeIllegalChars(value)}'` : `'${value}'`;
|
|
655
655
|
}
|
|
@@ -1424,7 +1424,7 @@ const Urls = {
|
|
|
1424
1424
|
let index = param.indexOf(VALUE_SEPARATOR);
|
|
1425
1425
|
if (index !== -1)
|
|
1426
1426
|
Object.assign(acc, {
|
|
1427
|
-
[param.
|
|
1427
|
+
[param.substring(0, index)]: param.substring(index + 1),
|
|
1428
1428
|
});
|
|
1429
1429
|
return acc;
|
|
1430
1430
|
}, {});
|
|
@@ -2403,30 +2403,32 @@ class ODataQueryOptionHandler {
|
|
|
2403
2403
|
return this.n;
|
|
2404
2404
|
}
|
|
2405
2405
|
toJSON() {
|
|
2406
|
-
return this.o
|
|
2406
|
+
return this.o.get(this.n);
|
|
2407
2407
|
}
|
|
2408
2408
|
empty() {
|
|
2409
|
-
return Types.isEmpty(this.o
|
|
2409
|
+
return Types.isEmpty(this.o.get(this.n));
|
|
2410
2410
|
}
|
|
2411
2411
|
//#region Primitive Value
|
|
2412
2412
|
value(v) {
|
|
2413
|
-
|
|
2413
|
+
if (v !== undefined)
|
|
2414
|
+
this.o.set(this.n, v);
|
|
2415
|
+
return this.o.get(this.n);
|
|
2414
2416
|
}
|
|
2415
2417
|
//#endregion
|
|
2416
2418
|
//#region Array Value
|
|
2417
2419
|
assertArray() {
|
|
2418
|
-
if (!Types.isArray(this.o
|
|
2419
|
-
this.o
|
|
2420
|
-
return this.o
|
|
2420
|
+
if (!Types.isArray(this.o.get(this.n)))
|
|
2421
|
+
this.o.set(this.n, this.o.has(this.n) ? [this.o.get(this.n)] : []);
|
|
2422
|
+
return this.o.get(this.n);
|
|
2421
2423
|
}
|
|
2422
2424
|
push(value) {
|
|
2423
2425
|
this.assertArray().push(value);
|
|
2424
2426
|
}
|
|
2425
2427
|
remove(value) {
|
|
2426
|
-
this.o
|
|
2428
|
+
this.o.set(this.n, this.assertArray().filter((v) => v !== value));
|
|
2427
2429
|
// If only one... down to value
|
|
2428
|
-
if (this.o
|
|
2429
|
-
this.o
|
|
2430
|
+
if (this.o.get(this.n).length === 1)
|
|
2431
|
+
this.o.set(this.n, this.o.get(this.n)[0]);
|
|
2430
2432
|
}
|
|
2431
2433
|
at(index) {
|
|
2432
2434
|
return this.assertArray()[index];
|
|
@@ -2434,8 +2436,9 @@ class ODataQueryOptionHandler {
|
|
|
2434
2436
|
//#endregion
|
|
2435
2437
|
//#region HashMap Value
|
|
2436
2438
|
assertObject(create) {
|
|
2437
|
-
if (!Types.isArray(this.o
|
|
2438
|
-
|
|
2439
|
+
if (!Types.isArray(this.o.get(this.n)) &&
|
|
2440
|
+
Types.isPlainObject(this.o.get(this.n))) {
|
|
2441
|
+
return this.o.get(this.n);
|
|
2439
2442
|
}
|
|
2440
2443
|
let arr = this.assertArray();
|
|
2441
2444
|
let obj = arr.find((v) => Types.isPlainObject(v));
|
|
@@ -2456,10 +2459,10 @@ class ODataQueryOptionHandler {
|
|
|
2456
2459
|
unset(path) {
|
|
2457
2460
|
let obj = this.assertObject(true);
|
|
2458
2461
|
Objects.unset(obj, path);
|
|
2459
|
-
if (Types.isArray(this.o
|
|
2460
|
-
this.o
|
|
2461
|
-
if (this.o
|
|
2462
|
-
this.o
|
|
2462
|
+
if (Types.isArray(this.o.get(this.n))) {
|
|
2463
|
+
this.o.set(this.n, this.o.get(this.n).filter((v) => !Types.isEmpty(v)));
|
|
2464
|
+
if (this.o.get(this.n).length === 1)
|
|
2465
|
+
this.o.set(this.n, this.o.get(this.n)[0]);
|
|
2463
2466
|
}
|
|
2464
2467
|
}
|
|
2465
2468
|
has(path) {
|
|
@@ -2472,7 +2475,7 @@ class ODataQueryOptionHandler {
|
|
|
2472
2475
|
}
|
|
2473
2476
|
//#endregion
|
|
2474
2477
|
clear() {
|
|
2475
|
-
|
|
2478
|
+
this.o.delete(this.n);
|
|
2476
2479
|
}
|
|
2477
2480
|
}
|
|
2478
2481
|
class ODataQueryOptionsHandler {
|
|
@@ -2489,6 +2492,14 @@ class ODataQueryOptionsHandler {
|
|
|
2489
2492
|
alias(value, name) {
|
|
2490
2493
|
return alias(value, name);
|
|
2491
2494
|
}
|
|
2495
|
+
/**
|
|
2496
|
+
* Normalize the given value to a valid odata value
|
|
2497
|
+
* @param value The value to normalize
|
|
2498
|
+
* @returns The normalized value
|
|
2499
|
+
*/
|
|
2500
|
+
normalize(value) {
|
|
2501
|
+
return normalizeValue(value);
|
|
2502
|
+
}
|
|
2492
2503
|
select(opts) {
|
|
2493
2504
|
if (Types.isFunction(opts)) {
|
|
2494
2505
|
return this.options.expression(QueryOptionNames.select, SelectExpression.select(opts, this.options.expression(QueryOptionNames.select)));
|
|
@@ -2577,8 +2588,11 @@ class ODataQueryOptionsHandler {
|
|
|
2577
2588
|
}
|
|
2578
2589
|
|
|
2579
2590
|
class ODataQueryOptions {
|
|
2580
|
-
constructor(
|
|
2581
|
-
this.values =
|
|
2591
|
+
constructor(values) {
|
|
2592
|
+
this.values =
|
|
2593
|
+
values instanceof Map
|
|
2594
|
+
? values
|
|
2595
|
+
: new Map(Object.entries(values || {}));
|
|
2582
2596
|
}
|
|
2583
2597
|
// Params
|
|
2584
2598
|
pathAndParams(escape = false) {
|
|
@@ -2596,9 +2610,9 @@ class ODataQueryOptions {
|
|
|
2596
2610
|
QueryOptionNames.expand,
|
|
2597
2611
|
QueryOptionNames.format,
|
|
2598
2612
|
]
|
|
2599
|
-
.filter((key) => !Types.isEmpty(this.values
|
|
2613
|
+
.filter((key) => !Types.isEmpty(this.values.get(key)))
|
|
2600
2614
|
.reduce((acc, key) => {
|
|
2601
|
-
let value = this.values
|
|
2615
|
+
let value = this.values.get(key);
|
|
2602
2616
|
if (Types.rawType(value).endsWith('Expression')) {
|
|
2603
2617
|
value = value.render({ aliases });
|
|
2604
2618
|
}
|
|
@@ -2615,8 +2629,8 @@ class ODataQueryOptions {
|
|
|
2615
2629
|
.join('&'));
|
|
2616
2630
|
}
|
|
2617
2631
|
toJSON() {
|
|
2618
|
-
return
|
|
2619
|
-
let value = this.values
|
|
2632
|
+
return [...this.values.keys()].reduce((acc, key) => {
|
|
2633
|
+
let value = this.values.get(key);
|
|
2620
2634
|
value =
|
|
2621
2635
|
Types.isObject(value) && 'toJSON' in value ? value.toJSON() : value;
|
|
2622
2636
|
return Object.assign(acc, { [key]: value });
|
|
@@ -2624,51 +2638,54 @@ class ODataQueryOptions {
|
|
|
2624
2638
|
}
|
|
2625
2639
|
toQueryArguments() {
|
|
2626
2640
|
return {
|
|
2627
|
-
select: this.values
|
|
2628
|
-
expand: this.values
|
|
2629
|
-
transform: this.values
|
|
2630
|
-
compute: this.values
|
|
2631
|
-
search: this.values
|
|
2632
|
-
filter: this.values
|
|
2633
|
-
orderBy: this.values
|
|
2634
|
-
top: this.values
|
|
2635
|
-
skip: this.values
|
|
2636
|
-
skiptoken: this.values
|
|
2641
|
+
select: this.values.get(QueryOptionNames.select),
|
|
2642
|
+
expand: this.values.get(QueryOptionNames.expand),
|
|
2643
|
+
transform: this.values.get(QueryOptionNames.transform),
|
|
2644
|
+
compute: this.values.get(QueryOptionNames.compute),
|
|
2645
|
+
search: this.values.get(QueryOptionNames.search),
|
|
2646
|
+
filter: this.values.get(QueryOptionNames.filter),
|
|
2647
|
+
orderBy: this.values.get(QueryOptionNames.orderBy),
|
|
2648
|
+
top: this.values.get(QueryOptionNames.top),
|
|
2649
|
+
skip: this.values.get(QueryOptionNames.skip),
|
|
2650
|
+
skiptoken: this.values.get(QueryOptionNames.skiptoken),
|
|
2637
2651
|
};
|
|
2638
2652
|
}
|
|
2639
2653
|
clone() {
|
|
2640
|
-
|
|
2641
|
-
return new ODataQueryOptions(options);
|
|
2654
|
+
return new ODataQueryOptions(Objects.clone(this.values));
|
|
2642
2655
|
}
|
|
2643
2656
|
// Set Renderable
|
|
2644
|
-
expression(
|
|
2657
|
+
expression(key, exp) {
|
|
2645
2658
|
if (exp !== undefined)
|
|
2646
|
-
this.values
|
|
2647
|
-
return this.values
|
|
2659
|
+
this.values.set(key, exp);
|
|
2660
|
+
return this.values.get(key);
|
|
2648
2661
|
}
|
|
2649
2662
|
// Option Handler
|
|
2650
|
-
option(
|
|
2663
|
+
option(key, opts) {
|
|
2651
2664
|
if (opts !== undefined)
|
|
2652
|
-
this.values
|
|
2653
|
-
return new ODataQueryOptionHandler(this.values,
|
|
2665
|
+
this.values.set(key, opts);
|
|
2666
|
+
return new ODataQueryOptionHandler(this.values, key);
|
|
2654
2667
|
}
|
|
2655
2668
|
// Query Options tools
|
|
2656
|
-
has(
|
|
2657
|
-
return this.values
|
|
2658
|
-
}
|
|
2659
|
-
remove(...
|
|
2660
|
-
|
|
2661
|
-
|
|
2669
|
+
has(key) {
|
|
2670
|
+
return this.values.has(key);
|
|
2671
|
+
}
|
|
2672
|
+
remove(...keys) {
|
|
2673
|
+
[...this.values.keys()]
|
|
2674
|
+
.filter((k) => keys.indexOf(k) !== -1)
|
|
2675
|
+
.forEach((key) => {
|
|
2676
|
+
this.values.delete(key);
|
|
2662
2677
|
});
|
|
2663
2678
|
}
|
|
2664
|
-
keep(...
|
|
2665
|
-
this.values
|
|
2666
|
-
.filter((k) =>
|
|
2667
|
-
.
|
|
2679
|
+
keep(...keys) {
|
|
2680
|
+
[...this.values.keys()]
|
|
2681
|
+
.filter((k) => keys.indexOf(k) === -1)
|
|
2682
|
+
.forEach((key) => {
|
|
2683
|
+
this.values.delete(key);
|
|
2684
|
+
});
|
|
2668
2685
|
}
|
|
2669
2686
|
// Clear
|
|
2670
2687
|
clear() {
|
|
2671
|
-
this.values
|
|
2688
|
+
this.values.clear();
|
|
2672
2689
|
}
|
|
2673
2690
|
}
|
|
2674
2691
|
|
|
@@ -3271,70 +3288,69 @@ const ODataVersionBaseHelper = {
|
|
|
3271
3288
|
property(data) {
|
|
3272
3289
|
return this.VALUE in data ? data[this.VALUE] : data;
|
|
3273
3290
|
},
|
|
3274
|
-
functions(
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
.
|
|
3291
|
+
functions(annots) {
|
|
3292
|
+
const funcs = new Map();
|
|
3293
|
+
[...annots.keys()]
|
|
3294
|
+
.filter((key) => key.startsWith(this.ODATA_FUNCTION_PREFIX))
|
|
3295
|
+
.forEach((key) => funcs.set(key.substring(this.ODATA_FUNCTION_PREFIX.length), annots.get(key)));
|
|
3296
|
+
return funcs;
|
|
3278
3297
|
},
|
|
3279
|
-
properties(
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
.
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
return acc;
|
|
3291
|
-
}, {});
|
|
3298
|
+
properties(annots) {
|
|
3299
|
+
const props = new Map();
|
|
3300
|
+
[...annots.keys()]
|
|
3301
|
+
.filter((key) => key.indexOf(this.ODATA_ANNOTATION_PREFIX) > 0)
|
|
3302
|
+
.forEach((key) => {
|
|
3303
|
+
let name = key.substring(0, key.indexOf(this.ODATA_ANNOTATION_PREFIX));
|
|
3304
|
+
let prop = props.has(name) ? props.get(name) : new Map();
|
|
3305
|
+
prop.set(key.substring(key.indexOf(this.ODATA_ANNOTATION_PREFIX)), annots.get(key));
|
|
3306
|
+
props.set(name, prop);
|
|
3307
|
+
});
|
|
3308
|
+
return props;
|
|
3292
3309
|
},
|
|
3293
|
-
id(
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
? value[this.ODATA_ID]
|
|
3298
|
-
: undefined;
|
|
3310
|
+
id(annots) {
|
|
3311
|
+
return annots instanceof Map
|
|
3312
|
+
? annots.get(this.ODATA_ID)
|
|
3313
|
+
: annots[this.ODATA_ID];
|
|
3299
3314
|
},
|
|
3300
|
-
etag(
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
? value[this.ODATA_ETAG]
|
|
3305
|
-
: undefined;
|
|
3315
|
+
etag(annots) {
|
|
3316
|
+
return annots instanceof Map
|
|
3317
|
+
? annots.get(this.ODATA_ETAG)
|
|
3318
|
+
: annots[this.ODATA_ETAG];
|
|
3306
3319
|
},
|
|
3307
|
-
type(
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3320
|
+
type(annots) {
|
|
3321
|
+
let type = annots instanceof Map
|
|
3322
|
+
? annots.get(this.ODATA_TYPE)
|
|
3323
|
+
: annots[this.ODATA_TYPE];
|
|
3324
|
+
if (!type)
|
|
3311
3325
|
return undefined;
|
|
3312
|
-
|
|
3313
|
-
const matches = COLLECTION.exec(
|
|
3326
|
+
type = type.substring(1);
|
|
3327
|
+
const matches = COLLECTION.exec(type);
|
|
3314
3328
|
if (matches)
|
|
3315
3329
|
return matches[1].indexOf('.') === -1 ? `Edm.${matches[1]}` : matches[1];
|
|
3316
|
-
return
|
|
3330
|
+
return type;
|
|
3317
3331
|
},
|
|
3318
|
-
mediaEtag(
|
|
3319
|
-
return this.ODATA_MEDIA_ETAG
|
|
3320
|
-
? decodeURIComponent(
|
|
3332
|
+
mediaEtag(annots) {
|
|
3333
|
+
return annots.has(this.ODATA_MEDIA_ETAG)
|
|
3334
|
+
? decodeURIComponent(annots.get(this.ODATA_MEDIA_ETAG))
|
|
3321
3335
|
: undefined;
|
|
3322
3336
|
},
|
|
3323
|
-
metadataEtag(
|
|
3324
|
-
return this.ODATA_METADATA_ETAG
|
|
3325
|
-
? decodeURIComponent(
|
|
3337
|
+
metadataEtag(annots) {
|
|
3338
|
+
return annots.has(this.ODATA_METADATA_ETAG)
|
|
3339
|
+
? decodeURIComponent(annots.get(this.ODATA_METADATA_ETAG))
|
|
3326
3340
|
: undefined;
|
|
3327
3341
|
},
|
|
3328
|
-
count(
|
|
3329
|
-
return this.ODATA_COUNT
|
|
3330
|
-
? Number(
|
|
3342
|
+
count(annots) {
|
|
3343
|
+
return annots.has(this.ODATA_COUNT)
|
|
3344
|
+
? Number(annots.get(this.ODATA_COUNT))
|
|
3331
3345
|
: undefined;
|
|
3332
3346
|
},
|
|
3333
3347
|
annotations(value) {
|
|
3334
|
-
|
|
3335
|
-
|
|
3348
|
+
const annots = new Map();
|
|
3349
|
+
Object.entries(value)
|
|
3350
|
+
.filter(([key]) => key.indexOf(this.ODATA_ANNOTATION_PREFIX) !== -1 ||
|
|
3336
3351
|
key.startsWith(this.ODATA_FUNCTION_PREFIX))
|
|
3337
|
-
.
|
|
3352
|
+
.forEach(([key, value]) => annots.set(key, value));
|
|
3353
|
+
return annots;
|
|
3338
3354
|
},
|
|
3339
3355
|
attributes(value, metadata) {
|
|
3340
3356
|
return Object.entries(value)
|
|
@@ -3348,39 +3364,39 @@ const ODataVersionBaseHelper = {
|
|
|
3348
3364
|
!k.startsWith(this.ODATA_FUNCTION_PREFIX)))
|
|
3349
3365
|
.reduce((acc, e) => (Object.assign(Object.assign({}, acc), { [e[0]]: e[1] })), {});
|
|
3350
3366
|
},
|
|
3351
|
-
nextLink(
|
|
3352
|
-
return this.ODATA_NEXTLINK
|
|
3353
|
-
? decodeURIComponent(
|
|
3367
|
+
nextLink(annots) {
|
|
3368
|
+
return annots.has(this.ODATA_NEXTLINK)
|
|
3369
|
+
? decodeURIComponent(annots.get(this.ODATA_NEXTLINK))
|
|
3354
3370
|
: undefined;
|
|
3355
3371
|
},
|
|
3356
|
-
readLink(
|
|
3357
|
-
return this.ODATA_READLINK
|
|
3358
|
-
? decodeURIComponent(
|
|
3372
|
+
readLink(annots) {
|
|
3373
|
+
return annots.has(this.ODATA_READLINK)
|
|
3374
|
+
? decodeURIComponent(annots.get(this.ODATA_READLINK))
|
|
3359
3375
|
: undefined;
|
|
3360
3376
|
},
|
|
3361
|
-
mediaReadLink(
|
|
3362
|
-
return this.ODATA_MEDIA_READLINK
|
|
3363
|
-
? decodeURIComponent(
|
|
3377
|
+
mediaReadLink(annots) {
|
|
3378
|
+
return annots.has(this.ODATA_MEDIA_READLINK)
|
|
3379
|
+
? decodeURIComponent(annots.get(this.ODATA_MEDIA_READLINK))
|
|
3364
3380
|
: undefined;
|
|
3365
3381
|
},
|
|
3366
|
-
editLink(
|
|
3367
|
-
return this.ODATA_EDITLINK
|
|
3368
|
-
? decodeURIComponent(
|
|
3382
|
+
editLink(annots) {
|
|
3383
|
+
return annots.has(this.ODATA_EDITLINK)
|
|
3384
|
+
? decodeURIComponent(annots.get(this.ODATA_EDITLINK))
|
|
3369
3385
|
: undefined;
|
|
3370
3386
|
},
|
|
3371
|
-
mediaEditLink(
|
|
3372
|
-
return this.ODATA_MEDIA_EDITLINK
|
|
3373
|
-
? decodeURIComponent(
|
|
3387
|
+
mediaEditLink(annots) {
|
|
3388
|
+
return annots.has(this.ODATA_MEDIA_EDITLINK)
|
|
3389
|
+
? decodeURIComponent(annots.get(this.ODATA_MEDIA_EDITLINK))
|
|
3374
3390
|
: undefined;
|
|
3375
3391
|
},
|
|
3376
|
-
deltaLink(
|
|
3377
|
-
return this.ODATA_DELTALINK
|
|
3378
|
-
? decodeURIComponent(
|
|
3392
|
+
deltaLink(annots) {
|
|
3393
|
+
return annots.has(this.ODATA_DELTALINK)
|
|
3394
|
+
? decodeURIComponent(annots.get(this.ODATA_DELTALINK))
|
|
3379
3395
|
: undefined;
|
|
3380
3396
|
},
|
|
3381
|
-
mediaContentType(
|
|
3382
|
-
return this.ODATA_MEDIA_CONTENTTYPE
|
|
3383
|
-
? decodeURIComponent(
|
|
3397
|
+
mediaContentType(annots) {
|
|
3398
|
+
return annots.has(this.ODATA_MEDIA_CONTENTTYPE)
|
|
3399
|
+
? decodeURIComponent(annots.get(this.ODATA_MEDIA_CONTENTTYPE))
|
|
3384
3400
|
: undefined;
|
|
3385
3401
|
},
|
|
3386
3402
|
};
|
|
@@ -3399,7 +3415,7 @@ const ODataHelper = {
|
|
|
3399
3415
|
//odata.etag: the ETag of the entity
|
|
3400
3416
|
ODATA_ETAG: '@odata.etag',
|
|
3401
3417
|
ODATA_METADATA_ETAG: '@odata.metadataEtag',
|
|
3402
|
-
//odata.type: the type of the containing {[
|
|
3418
|
+
//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
|
|
3403
3419
|
ODATA_TYPE: '@odata.type',
|
|
3404
3420
|
//odata.nextLink: the next link of a collection with partial results
|
|
3405
3421
|
ODATA_NEXTLINK: '@odata.nextLink',
|
|
@@ -3430,15 +3446,17 @@ const ODataHelper = {
|
|
|
3430
3446
|
//http://nb-mdp-dev01:57970/$metadata#categorias(children(children(children(children(children(children(children(children(children(children()))))))))))/$entity
|
|
3431
3447
|
//http://nb-mdp-dev01:57970/$metadata#recursos/SIU.Documentos.Documento/$entity
|
|
3432
3448
|
//http://nb-mdp-dev01:57970/$metadata#SIU.Api.Infrastructure.Storage.Backend.SiuUrls
|
|
3433
|
-
context(
|
|
3449
|
+
context(annots) {
|
|
3434
3450
|
let ctx = {};
|
|
3435
|
-
|
|
3436
|
-
|
|
3451
|
+
const str = annots instanceof Map
|
|
3452
|
+
? annots.get(this.ODATA_CONTEXT)
|
|
3453
|
+
: annots[this.ODATA_CONTEXT];
|
|
3454
|
+
if (typeof str === 'string') {
|
|
3437
3455
|
let index = str.indexOf('$metadata');
|
|
3438
|
-
ctx.serviceRootUrl = str.
|
|
3456
|
+
ctx.serviceRootUrl = str.substring(0, index);
|
|
3439
3457
|
index = str.indexOf('#');
|
|
3440
|
-
ctx.metadataUrl = str.
|
|
3441
|
-
const parts = str.
|
|
3458
|
+
ctx.metadataUrl = str.substring(0, index);
|
|
3459
|
+
const parts = str.substring(index + 1).split('/');
|
|
3442
3460
|
const col = COLLECTION.exec(parts[0]);
|
|
3443
3461
|
if (col) {
|
|
3444
3462
|
ctx.type = col[1];
|
|
@@ -3482,15 +3500,17 @@ const ODataHelper = {
|
|
|
3482
3500
|
ODATA_TYPE: 'odata.type',
|
|
3483
3501
|
ODATA_COUNT: 'odata.count',
|
|
3484
3502
|
VALUE: 'value',
|
|
3485
|
-
context(
|
|
3503
|
+
context(annots) {
|
|
3486
3504
|
let ctx = {};
|
|
3487
|
-
|
|
3488
|
-
|
|
3505
|
+
const str = annots instanceof Map
|
|
3506
|
+
? annots.get(this.ODATA_CONTEXT)
|
|
3507
|
+
: annots[this.ODATA_CONTEXT];
|
|
3508
|
+
if (typeof str === 'string') {
|
|
3489
3509
|
let index = str.indexOf('$metadata');
|
|
3490
|
-
ctx.serviceRootUrl = str.
|
|
3510
|
+
ctx.serviceRootUrl = str.substring(0, index);
|
|
3491
3511
|
index = str.indexOf('#');
|
|
3492
|
-
ctx.metadataUrl = str.
|
|
3493
|
-
const parts = str.
|
|
3512
|
+
ctx.metadataUrl = str.substring(0, index);
|
|
3513
|
+
const parts = str.substring(index + 1).split('/');
|
|
3494
3514
|
ctx.entitySet = parts[0];
|
|
3495
3515
|
}
|
|
3496
3516
|
return ctx;
|
|
@@ -3511,9 +3531,11 @@ const ODataHelper = {
|
|
|
3511
3531
|
ODATA_TYPE: 'type',
|
|
3512
3532
|
VALUE: 'results',
|
|
3513
3533
|
annotations(value) {
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3534
|
+
const annots = new Map();
|
|
3535
|
+
if (this.ODATA_ANNOTATION in value) {
|
|
3536
|
+
Object.entries(value[this.ODATA_ANNOTATION]).forEach(([key, value]) => annots.set(key, value));
|
|
3537
|
+
}
|
|
3538
|
+
return annots;
|
|
3517
3539
|
},
|
|
3518
3540
|
attributes(value, metadata) {
|
|
3519
3541
|
return value;
|
|
@@ -3725,8 +3747,8 @@ class ODataStructuredTypeFieldParser extends ODataAnnotatable {
|
|
|
3725
3747
|
}
|
|
3726
3748
|
//#region Deserialize
|
|
3727
3749
|
parse(parser, value, options) {
|
|
3728
|
-
const type = Types.isPlainObject(value)
|
|
3729
|
-
? options
|
|
3750
|
+
const type = options !== undefined && Types.isPlainObject(value)
|
|
3751
|
+
? options.helper.type(value)
|
|
3730
3752
|
: undefined;
|
|
3731
3753
|
if (type !== undefined) {
|
|
3732
3754
|
return parser
|
|
@@ -3750,8 +3772,8 @@ class ODataStructuredTypeFieldParser extends ODataAnnotatable {
|
|
|
3750
3772
|
//#endregion
|
|
3751
3773
|
//#region Serialize
|
|
3752
3774
|
toJson(parser, value, options) {
|
|
3753
|
-
const type = Types.isPlainObject(value)
|
|
3754
|
-
? options
|
|
3775
|
+
const type = options !== undefined && Types.isPlainObject(value)
|
|
3776
|
+
? options.helper.type(value)
|
|
3755
3777
|
: undefined;
|
|
3756
3778
|
if (type !== undefined) {
|
|
3757
3779
|
return parser
|
|
@@ -4441,14 +4463,9 @@ class ODataStructuredType extends ODataSchemaElement {
|
|
|
4441
4463
|
*/
|
|
4442
4464
|
pick(attrs, { include_parents = true, include_navigation = false, include_etag = true, } = {}) {
|
|
4443
4465
|
const names = this.fields({ include_parents, include_navigation }).map((f) => f.name);
|
|
4444
|
-
|
|
4445
|
-
.filter((
|
|
4446
|
-
.reduce((acc,
|
|
4447
|
-
if (include_etag) {
|
|
4448
|
-
const etag = this.api.options.helper.etag(attrs);
|
|
4449
|
-
this.api.options.helper.etag(attrs, etag);
|
|
4450
|
-
}
|
|
4451
|
-
return values;
|
|
4466
|
+
return Object.keys(attrs)
|
|
4467
|
+
.filter((key) => names.indexOf(key) !== -1 || (key == this.api.options.helper.ODATA_ETAG && include_etag))
|
|
4468
|
+
.reduce((acc, key) => Object.assign(acc, { [key]: attrs[key] }), {});
|
|
4452
4469
|
}
|
|
4453
4470
|
/**
|
|
4454
4471
|
* Deseialize the given value from the structured type.
|
|
@@ -4947,7 +4964,7 @@ class ODataActionResource extends ODataResource {
|
|
|
4947
4964
|
}
|
|
4948
4965
|
|
|
4949
4966
|
class ODataAnnotations {
|
|
4950
|
-
constructor(helper, annotations =
|
|
4967
|
+
constructor(helper, annotations = new Map(), context) {
|
|
4951
4968
|
this.helper = helper;
|
|
4952
4969
|
this.annotations = annotations;
|
|
4953
4970
|
this.context = context;
|
|
@@ -4966,7 +4983,7 @@ class ODataAnnotations {
|
|
|
4966
4983
|
}
|
|
4967
4984
|
class ODataPropertyAnnotations extends ODataAnnotations {
|
|
4968
4985
|
clone() {
|
|
4969
|
-
return new ODataPropertyAnnotations(this.helper,
|
|
4986
|
+
return new ODataPropertyAnnotations(this.helper, new Map(this.annotations), this.context);
|
|
4970
4987
|
}
|
|
4971
4988
|
data(data) {
|
|
4972
4989
|
return this.helper.property(data);
|
|
@@ -4974,7 +4991,7 @@ class ODataPropertyAnnotations extends ODataAnnotations {
|
|
|
4974
4991
|
}
|
|
4975
4992
|
class ODataEntityAnnotations extends ODataAnnotations {
|
|
4976
4993
|
clone() {
|
|
4977
|
-
return new ODataEntityAnnotations(this.helper,
|
|
4994
|
+
return new ODataEntityAnnotations(this.helper, new Map(this.annotations), this.context);
|
|
4978
4995
|
}
|
|
4979
4996
|
data(data) {
|
|
4980
4997
|
return this.helper.entity(data);
|
|
@@ -5013,7 +5030,7 @@ class ODataEntityAnnotations extends ODataAnnotations {
|
|
|
5013
5030
|
return this._properties;
|
|
5014
5031
|
}
|
|
5015
5032
|
property(name) {
|
|
5016
|
-
return this.properties
|
|
5033
|
+
return this.properties.get(name);
|
|
5017
5034
|
}
|
|
5018
5035
|
get functions() {
|
|
5019
5036
|
if (this._functions === undefined) {
|
|
@@ -5027,7 +5044,7 @@ class ODataEntityAnnotations extends ODataAnnotations {
|
|
|
5027
5044
|
}
|
|
5028
5045
|
class ODataEntitiesAnnotations extends ODataAnnotations {
|
|
5029
5046
|
clone() {
|
|
5030
|
-
return new ODataEntitiesAnnotations(this.helper,
|
|
5047
|
+
return new ODataEntitiesAnnotations(this.helper, new Map(this.annotations), this.context);
|
|
5031
5048
|
}
|
|
5032
5049
|
data(data) {
|
|
5033
5050
|
return this.helper.entities(data);
|
|
@@ -5208,13 +5225,13 @@ class ODataResponse extends HttpResponse {
|
|
|
5208
5225
|
if (key) {
|
|
5209
5226
|
const etag = this.headers.get(key);
|
|
5210
5227
|
if (etag)
|
|
5211
|
-
options.helper.
|
|
5228
|
+
this._annotations.set(options.helper.ODATA_ETAG, etag);
|
|
5212
5229
|
}
|
|
5213
5230
|
key = Http.resolveHeaderKey(this.headers, ODATA_ENTITYID_HEADERS);
|
|
5214
5231
|
if (key) {
|
|
5215
5232
|
const entityId = this.headers.get(key);
|
|
5216
5233
|
if (entityId)
|
|
5217
|
-
options.helper.
|
|
5234
|
+
this._annotations.set(options.helper.ODATA_ID, entityId);
|
|
5218
5235
|
}
|
|
5219
5236
|
}
|
|
5220
5237
|
return this._annotations;
|
|
@@ -6457,7 +6474,8 @@ class ODataFunctionResource extends ODataResource {
|
|
|
6457
6474
|
}
|
|
6458
6475
|
pathAndParams(escape = false) {
|
|
6459
6476
|
let [path, params] = super.pathAndParams(escape);
|
|
6460
|
-
if (path.endsWith('()') &&
|
|
6477
|
+
if (path.endsWith('()') &&
|
|
6478
|
+
this.api.options.nonParenthesisForEmptyParameterFunction) {
|
|
6461
6479
|
path = path.substring(0, path.length - 2);
|
|
6462
6480
|
}
|
|
6463
6481
|
return [path, params];
|
|
@@ -7515,13 +7533,15 @@ class ODataModelEvent {
|
|
|
7515
7533
|
}
|
|
7516
7534
|
//Identifies the current model for the event
|
|
7517
7535
|
get currentModel() {
|
|
7518
|
-
const link = this.chain.find(c => ODataModelOptions.isModel(c[0]));
|
|
7536
|
+
const link = this.chain.find((c) => ODataModelOptions.isModel(c[0]));
|
|
7519
7537
|
return link !== undefined ? link[0] : undefined;
|
|
7520
7538
|
}
|
|
7521
7539
|
//Identifies the current collection for the event
|
|
7522
7540
|
get currentCollection() {
|
|
7523
|
-
const link = this.chain.find(c => ODataModelOptions.isCollection(c[0]));
|
|
7524
|
-
return link !== undefined
|
|
7541
|
+
const link = this.chain.find((c) => ODataModelOptions.isCollection(c[0]));
|
|
7542
|
+
return link !== undefined
|
|
7543
|
+
? link[0]
|
|
7544
|
+
: undefined;
|
|
7525
7545
|
}
|
|
7526
7546
|
}
|
|
7527
7547
|
const BUBBLING = [
|
|
@@ -7719,8 +7739,8 @@ class ODataModelField {
|
|
|
7719
7739
|
}
|
|
7720
7740
|
annotationsFactory(base) {
|
|
7721
7741
|
return this.parser.collection
|
|
7722
|
-
? new ODataEntitiesAnnotations(base.helper, base.property(this.parser.name)
|
|
7723
|
-
: new ODataEntityAnnotations(base.helper, base.property(this.parser.name)
|
|
7742
|
+
? new ODataEntitiesAnnotations(base.helper, base.property(this.parser.name))
|
|
7743
|
+
: new ODataEntityAnnotations(base.helper, base.property(this.parser.name));
|
|
7724
7744
|
}
|
|
7725
7745
|
schemaFactory(base) {
|
|
7726
7746
|
return this.api.findStructuredTypeForType(this.parser.type);
|
|
@@ -7851,30 +7871,35 @@ class ODataModelOptions {
|
|
|
7851
7871
|
}
|
|
7852
7872
|
static resource(child) {
|
|
7853
7873
|
var _a;
|
|
7854
|
-
let resource =
|
|
7874
|
+
let resource = null;
|
|
7875
|
+
let prevField = null;
|
|
7855
7876
|
for (let [model, field] of ODataModelOptions.chain(child)) {
|
|
7856
7877
|
resource = resource || model._resource;
|
|
7857
|
-
if (resource ===
|
|
7878
|
+
if (resource === null)
|
|
7858
7879
|
break;
|
|
7859
|
-
if (ODataModelOptions.isModel(model)
|
|
7860
|
-
|
|
7880
|
+
if (ODataModelOptions.isModel(model) &&
|
|
7881
|
+
(prevField === null || prevField.collection)) {
|
|
7882
|
+
// Resolve key
|
|
7883
|
+
let modelKey = model.key({
|
|
7861
7884
|
field_mapping: true,
|
|
7862
7885
|
});
|
|
7863
|
-
if (
|
|
7886
|
+
if (modelKey !== undefined)
|
|
7864
7887
|
resource =
|
|
7865
7888
|
resource instanceof ODataEntitySetResource
|
|
7866
|
-
? resource.entity(
|
|
7867
|
-
: resource.key(
|
|
7889
|
+
? resource.entity(modelKey)
|
|
7890
|
+
: resource.key(modelKey);
|
|
7868
7891
|
}
|
|
7892
|
+
prevField = field;
|
|
7869
7893
|
if (field === null) {
|
|
7894
|
+
// Apply the query from model to new resource
|
|
7870
7895
|
const query = (_a = model._resource) === null || _a === void 0 ? void 0 : _a.cloneQuery().toQueryArguments();
|
|
7871
|
-
if (query !== undefined
|
|
7896
|
+
if (query !== undefined)
|
|
7872
7897
|
resource.query((q) => q.apply(query));
|
|
7873
7898
|
continue;
|
|
7874
7899
|
}
|
|
7875
7900
|
resource = field.resourceFactory(resource);
|
|
7876
7901
|
}
|
|
7877
|
-
if (resource ===
|
|
7902
|
+
if (resource === null)
|
|
7878
7903
|
throw new Error(`resource: Can't build resource for ${child}`);
|
|
7879
7904
|
return resource;
|
|
7880
7905
|
}
|
|
@@ -8025,8 +8050,8 @@ class ODataModelOptions {
|
|
|
8025
8050
|
return !Types.isEmpty(defs) ? defs : undefined;
|
|
8026
8051
|
}
|
|
8027
8052
|
hasChanged(self, { include_navigation = false } = {}) {
|
|
8028
|
-
return (
|
|
8029
|
-
|
|
8053
|
+
return (self._changes.size != 0 ||
|
|
8054
|
+
[...self._relations.values()]
|
|
8030
8055
|
.filter(({ field }) => !field.navigation || include_navigation)
|
|
8031
8056
|
.some(({ field, state, model }) => (!include_navigation || field.navigation) &&
|
|
8032
8057
|
(state === ODataModelState.Changed ||
|
|
@@ -8067,7 +8092,7 @@ class ODataModelOptions {
|
|
|
8067
8092
|
include_computed,
|
|
8068
8093
|
include_non_field,
|
|
8069
8094
|
});
|
|
8070
|
-
let relations =
|
|
8095
|
+
let relations = [...self._relations.entries()]
|
|
8071
8096
|
.filter(
|
|
8072
8097
|
// Chain
|
|
8073
8098
|
([, { model }]) => chain.every((c) => c !== model))
|
|
@@ -8142,19 +8167,19 @@ class ODataModelOptions {
|
|
|
8142
8167
|
(ODataModelOptions.isCollection(self._parent[0]) &&
|
|
8143
8168
|
self._parent[0]._model
|
|
8144
8169
|
.meta !== self._meta))) {
|
|
8145
|
-
this.api.options.helper.
|
|
8170
|
+
entity[this.api.options.helper.ODATA_TYPE] = `#${this.schema.type()}`;
|
|
8146
8171
|
}
|
|
8147
8172
|
return entity;
|
|
8148
8173
|
}
|
|
8149
8174
|
attributes(self, { changes_only = false, include_concurrency = false, include_computed = false, include_non_field = false, field_mapping = false, } = {}) {
|
|
8150
8175
|
// Attributes by fields (attributes for the model type)
|
|
8151
8176
|
const fieldAttrs = this.fields().reduce((acc, f) => {
|
|
8152
|
-
const isChanged = f.name
|
|
8177
|
+
const isChanged = self._changes.has(f.name);
|
|
8153
8178
|
const name = field_mapping ? f.field : f.name;
|
|
8154
8179
|
const computed = f.annotatedValue(COMPUTED);
|
|
8155
8180
|
const value = isChanged
|
|
8156
|
-
? self._changes
|
|
8157
|
-
: self._attributes
|
|
8181
|
+
? self._changes.get(f.name)
|
|
8182
|
+
: self._attributes.get(f.name);
|
|
8158
8183
|
if (f.concurrency && include_concurrency) {
|
|
8159
8184
|
return Object.assign(acc, { [name]: value });
|
|
8160
8185
|
}
|
|
@@ -8181,10 +8206,10 @@ class ODataModelOptions {
|
|
|
8181
8206
|
return Object.assign(Object.assign({}, fieldAttrs), nonFieldAttrs);
|
|
8182
8207
|
}
|
|
8183
8208
|
reset(self, { name, silent = false } = {}) {
|
|
8184
|
-
if (!Types.isEmpty(name) &&
|
|
8185
|
-
const value = self._attributes
|
|
8186
|
-
const previous = self._changes
|
|
8187
|
-
|
|
8209
|
+
if (!Types.isEmpty(name) && self._changes.has(name)) {
|
|
8210
|
+
const value = self._attributes.get(name);
|
|
8211
|
+
const previous = self._changes.get(name);
|
|
8212
|
+
self._changes.delete(name);
|
|
8188
8213
|
if (!silent) {
|
|
8189
8214
|
self.events$.emit(new ODataModelEvent('change', {
|
|
8190
8215
|
model: self,
|
|
@@ -8195,14 +8220,14 @@ class ODataModelOptions {
|
|
|
8195
8220
|
}
|
|
8196
8221
|
}
|
|
8197
8222
|
else if (Types.isEmpty(name)) {
|
|
8198
|
-
const entries =
|
|
8199
|
-
self._changes
|
|
8223
|
+
const entries = [...self._changes.entries()];
|
|
8224
|
+
self._changes.clear();
|
|
8200
8225
|
if (!silent) {
|
|
8201
8226
|
entries.forEach((entry) => {
|
|
8202
8227
|
self.events$.emit(new ODataModelEvent('change', {
|
|
8203
8228
|
track: entry[0],
|
|
8204
8229
|
model: self,
|
|
8205
|
-
value: self._attributes
|
|
8230
|
+
value: self._attributes.get(entry[0]),
|
|
8206
8231
|
previous: entry[1],
|
|
8207
8232
|
}));
|
|
8208
8233
|
});
|
|
@@ -8274,7 +8299,7 @@ class ODataModelOptions {
|
|
|
8274
8299
|
_get(self, field) {
|
|
8275
8300
|
var _a;
|
|
8276
8301
|
if (field.isStructuredType()) {
|
|
8277
|
-
return (_a = self._relations
|
|
8302
|
+
return (_a = self._relations.get(field.name)) === null || _a === void 0 ? void 0 : _a.model;
|
|
8278
8303
|
}
|
|
8279
8304
|
else {
|
|
8280
8305
|
return this.attributes(self, {
|
|
@@ -8287,13 +8312,13 @@ class ODataModelOptions {
|
|
|
8287
8312
|
var _a;
|
|
8288
8313
|
let changed = false;
|
|
8289
8314
|
// Ensures that the relation exists
|
|
8290
|
-
if (!(field.name
|
|
8291
|
-
self._relations
|
|
8315
|
+
if (!self._relations.has(field.name)) {
|
|
8316
|
+
self._relations.set(field.name, {
|
|
8292
8317
|
state: ODataModelState.Unchanged,
|
|
8293
8318
|
field: field,
|
|
8294
|
-
};
|
|
8319
|
+
});
|
|
8295
8320
|
}
|
|
8296
|
-
const relation = self._relations
|
|
8321
|
+
const relation = self._relations.get(field.name);
|
|
8297
8322
|
const currentModel = relation.model;
|
|
8298
8323
|
if (value === null) {
|
|
8299
8324
|
relation.model = value;
|
|
@@ -8376,14 +8401,14 @@ class ODataModelOptions {
|
|
|
8376
8401
|
const currentValue = attrs[field];
|
|
8377
8402
|
changed = !Types.isEqual(currentValue, value);
|
|
8378
8403
|
if (self._reset) {
|
|
8379
|
-
|
|
8380
|
-
self._attributes
|
|
8404
|
+
self._changes.delete(field);
|
|
8405
|
+
self._attributes.set(field, value);
|
|
8381
8406
|
}
|
|
8382
|
-
else if (Types.isEqual(value, self._attributes
|
|
8383
|
-
|
|
8407
|
+
else if (Types.isEqual(value, self._attributes.get(field))) {
|
|
8408
|
+
self._changes.delete(field);
|
|
8384
8409
|
}
|
|
8385
8410
|
else if (changed) {
|
|
8386
|
-
self._changes
|
|
8411
|
+
self._changes.set(field, value);
|
|
8387
8412
|
}
|
|
8388
8413
|
if (!self._silent && changed) {
|
|
8389
8414
|
self.events$.emit(new ODataModelEvent('change', {
|
|
@@ -8535,7 +8560,7 @@ class ODataCollection {
|
|
|
8535
8560
|
var _a;
|
|
8536
8561
|
let Model = this._model;
|
|
8537
8562
|
const helper = this._annotations.helper;
|
|
8538
|
-
const annots = new ODataEntityAnnotations(helper, helper.annotations(data)
|
|
8563
|
+
const annots = new ODataEntityAnnotations(helper, helper.annotations(data));
|
|
8539
8564
|
if ((annots === null || annots === void 0 ? void 0 : annots.type) !== undefined && Model.meta !== null) {
|
|
8540
8565
|
let schema = (_a = Model.meta.findChildOptions((o) => o.isTypeOf(annots.type))) === null || _a === void 0 ? void 0 : _a.schema;
|
|
8541
8566
|
if (schema !== undefined && schema.model !== undefined)
|
|
@@ -8910,7 +8935,7 @@ class ODataCollection {
|
|
|
8910
8935
|
}
|
|
8911
8936
|
else {
|
|
8912
8937
|
const helper = this._annotations.helper;
|
|
8913
|
-
const annots = new ODataEntityAnnotations(helper, helper.annotations(obj)
|
|
8938
|
+
const annots = new ODataEntityAnnotations(helper, helper.annotations(obj));
|
|
8914
8939
|
const entity = annots.attributes(obj, 'full');
|
|
8915
8940
|
model._annotations = annots;
|
|
8916
8941
|
model.assign(entity, { reset, silent });
|
|
@@ -9178,9 +9203,9 @@ class ODataModel {
|
|
|
9178
9203
|
constructor(data = {}, { parent, resource, annots, reset = false, } = {}) {
|
|
9179
9204
|
// Parent
|
|
9180
9205
|
this._parent = null;
|
|
9181
|
-
this._attributes =
|
|
9182
|
-
this._changes =
|
|
9183
|
-
this._relations =
|
|
9206
|
+
this._attributes = new Map();
|
|
9207
|
+
this._changes = new Map();
|
|
9208
|
+
this._relations = new Map();
|
|
9184
9209
|
this._resource = null;
|
|
9185
9210
|
this._reset = false;
|
|
9186
9211
|
this._reparent = false;
|
|
@@ -9629,14 +9654,19 @@ class ODataApi {
|
|
|
9629
9654
|
// Memoize
|
|
9630
9655
|
this.memo = {
|
|
9631
9656
|
forType: {
|
|
9632
|
-
enum:
|
|
9633
|
-
structured:
|
|
9634
|
-
callable:
|
|
9635
|
-
entitySet:
|
|
9636
|
-
parser:
|
|
9637
|
-
options:
|
|
9657
|
+
enum: new Map(),
|
|
9658
|
+
structured: new Map(),
|
|
9659
|
+
callable: new Map(),
|
|
9660
|
+
entitySet: new Map(),
|
|
9661
|
+
parser: new Map(),
|
|
9662
|
+
options: new Map(),
|
|
9663
|
+
},
|
|
9664
|
+
byName: {
|
|
9665
|
+
enum: new Map(),
|
|
9666
|
+
structured: new Map(),
|
|
9667
|
+
callable: new Map(),
|
|
9668
|
+
entitySet: new Map(),
|
|
9638
9669
|
},
|
|
9639
|
-
byName: { enum: {}, structured: {}, callable: {}, entitySet: {} },
|
|
9640
9670
|
};
|
|
9641
9671
|
this.serviceRootUrl = config.serviceRootUrl;
|
|
9642
9672
|
if (this.serviceRootUrl.indexOf('?') != -1)
|
|
@@ -9765,31 +9795,32 @@ class ODataApi {
|
|
|
9765
9795
|
}
|
|
9766
9796
|
findEnumTypeForType(type) {
|
|
9767
9797
|
var _a;
|
|
9768
|
-
if (!
|
|
9769
|
-
this.memo.forType.enum
|
|
9770
|
-
|
|
9771
|
-
return this.memo.forType.enum
|
|
9798
|
+
if (!this.memo.forType.enum.has(type)) {
|
|
9799
|
+
this.memo.forType.enum.set(type, (_a = this.findSchemaForType(type)) === null || _a === void 0 ? void 0 : _a.findEnumTypeForType(type));
|
|
9800
|
+
}
|
|
9801
|
+
return this.memo.forType.enum.get(type);
|
|
9772
9802
|
}
|
|
9773
9803
|
findStructuredTypeForType(type) {
|
|
9774
9804
|
var _a;
|
|
9775
|
-
if (!
|
|
9776
|
-
this.memo.forType.structured
|
|
9777
|
-
|
|
9778
|
-
return this.memo.forType.structured
|
|
9805
|
+
if (!this.memo.forType.structured.has(type)) {
|
|
9806
|
+
this.memo.forType.structured.set(type, (_a = this.findSchemaForType(type)) === null || _a === void 0 ? void 0 : _a.findStructuredTypeForType(type));
|
|
9807
|
+
}
|
|
9808
|
+
return this.memo.forType.structured.get(type);
|
|
9779
9809
|
}
|
|
9780
9810
|
findCallableForType(type, bindingType) {
|
|
9781
9811
|
var _a;
|
|
9782
9812
|
const key = bindingType !== undefined ? `${bindingType}/${type}` : type;
|
|
9783
|
-
if (!
|
|
9784
|
-
this.memo.forType.callable
|
|
9785
|
-
|
|
9813
|
+
if (!this.memo.forType.callable.has(key)) {
|
|
9814
|
+
this.memo.forType.callable.set(key, (_a = this.findSchemaForType(type)) === null || _a === void 0 ? void 0 : _a.findCallableForType(type, bindingType));
|
|
9815
|
+
}
|
|
9816
|
+
return this.memo.forType.callable.get(key);
|
|
9786
9817
|
}
|
|
9787
9818
|
findEntitySetForType(type) {
|
|
9788
9819
|
var _a;
|
|
9789
|
-
if (!
|
|
9790
|
-
this.memo.forType.entitySet
|
|
9791
|
-
|
|
9792
|
-
return this.memo.forType.entitySet
|
|
9820
|
+
if (!this.memo.forType.entitySet.has(type)) {
|
|
9821
|
+
this.memo.forType.entitySet.set(type, (_a = this.findSchemaForType(type)) === null || _a === void 0 ? void 0 : _a.findEntitySetForType(type));
|
|
9822
|
+
}
|
|
9823
|
+
return this.memo.forType.entitySet.get(type);
|
|
9793
9824
|
}
|
|
9794
9825
|
findModelForType(type) {
|
|
9795
9826
|
var _a;
|
|
@@ -9839,48 +9870,53 @@ class ODataApi {
|
|
|
9839
9870
|
return (_a = this.findEntitySetForType(type)) === null || _a === void 0 ? void 0 : _a.service;
|
|
9840
9871
|
}
|
|
9841
9872
|
findEntitySetForEntityType(entityType) {
|
|
9842
|
-
if (!
|
|
9843
|
-
this.memo.forType.entitySet
|
|
9873
|
+
if (!this.memo.forType.entitySet.has(entityType)) {
|
|
9874
|
+
this.memo.forType.entitySet.set(entityType, this.schemas
|
|
9844
9875
|
.reduce((acc, schema) => [...acc, ...schema.entitySets], [])
|
|
9845
|
-
.find((e) => e.entityType === entityType);
|
|
9846
|
-
|
|
9876
|
+
.find((e) => e.entityType === entityType));
|
|
9877
|
+
}
|
|
9878
|
+
return this.memo.forType.entitySet.get(entityType);
|
|
9847
9879
|
}
|
|
9848
9880
|
findServiceForEntityType(entityType) {
|
|
9849
9881
|
var _a;
|
|
9850
9882
|
return (_a = this.findEntitySetForEntityType(entityType)) === null || _a === void 0 ? void 0 : _a.service;
|
|
9851
9883
|
}
|
|
9852
9884
|
findEnumTypeByName(name) {
|
|
9853
|
-
if (!
|
|
9854
|
-
this.memo.byName.enum
|
|
9885
|
+
if (!this.memo.byName.enum.has(name)) {
|
|
9886
|
+
this.memo.byName.enum.set(name, this.schemas
|
|
9855
9887
|
.reduce((acc, schema) => [...acc, ...schema.enums], [])
|
|
9856
|
-
.find((e) => e.name === name);
|
|
9857
|
-
|
|
9888
|
+
.find((e) => e.name === name));
|
|
9889
|
+
}
|
|
9890
|
+
return this.memo.byName.enum.get(name);
|
|
9858
9891
|
}
|
|
9859
9892
|
findStructuredTypeByName(name) {
|
|
9860
|
-
if (!
|
|
9861
|
-
this.memo.byName.structured
|
|
9893
|
+
if (!this.memo.byName.structured.has(name)) {
|
|
9894
|
+
this.memo.byName.structured.set(name, this.schemas
|
|
9862
9895
|
.reduce((acc, schema) => [...acc, ...schema.entities], [])
|
|
9863
|
-
.find((e) => e.name === name);
|
|
9864
|
-
|
|
9896
|
+
.find((e) => e.name === name));
|
|
9897
|
+
}
|
|
9898
|
+
return this.memo.byName.structured.get(name);
|
|
9865
9899
|
}
|
|
9866
9900
|
findCallableByName(name, bindingType) {
|
|
9867
9901
|
const key = bindingType !== undefined ? `${bindingType}/${name}` : name;
|
|
9868
|
-
if (!
|
|
9869
|
-
this.memo.byName.callable
|
|
9902
|
+
if (!this.memo.byName.callable.has(key)) {
|
|
9903
|
+
this.memo.byName.callable.set(key, this.schemas
|
|
9870
9904
|
.reduce((acc, schema) => [...acc, ...schema.callables], [])
|
|
9871
9905
|
.find((c) => {
|
|
9872
9906
|
var _a;
|
|
9873
9907
|
return c.name === name &&
|
|
9874
9908
|
(bindingType === undefined || ((_a = c.binding()) === null || _a === void 0 ? void 0 : _a.type) === bindingType);
|
|
9875
|
-
});
|
|
9876
|
-
|
|
9909
|
+
}));
|
|
9910
|
+
}
|
|
9911
|
+
return this.memo.byName.callable.get(key);
|
|
9877
9912
|
}
|
|
9878
9913
|
findEntitySetByName(name) {
|
|
9879
|
-
if (!
|
|
9880
|
-
this.memo.byName.entitySet
|
|
9914
|
+
if (!this.memo.byName.entitySet.has(name)) {
|
|
9915
|
+
this.memo.byName.entitySet.set(name, this.schemas
|
|
9881
9916
|
.reduce((acc, schema) => [...acc, ...schema.entitySets], [])
|
|
9882
|
-
.find((e) => e.name === name);
|
|
9883
|
-
|
|
9917
|
+
.find((e) => e.name === name));
|
|
9918
|
+
}
|
|
9919
|
+
return this.memo.byName.entitySet.get(name);
|
|
9884
9920
|
}
|
|
9885
9921
|
findModelByName(name) {
|
|
9886
9922
|
var _a;
|
|
@@ -9896,36 +9932,35 @@ class ODataApi {
|
|
|
9896
9932
|
}
|
|
9897
9933
|
parserForType(type, bindingType) {
|
|
9898
9934
|
const key = bindingType !== undefined ? `${bindingType}/${type}` : type;
|
|
9899
|
-
if (!
|
|
9935
|
+
if (!this.memo.forType.parser.has(key)) {
|
|
9900
9936
|
if (type in this.parsers) {
|
|
9901
9937
|
// Edm, Base Parsers
|
|
9902
|
-
this.memo.forType.parser
|
|
9938
|
+
this.memo.forType.parser.set(key, this.parsers[type]);
|
|
9903
9939
|
}
|
|
9904
9940
|
else if (!type.startsWith('Edm.')) {
|
|
9905
9941
|
// EnumType, ComplexType and EntityType Parsers
|
|
9906
9942
|
let value = this.findCallableForType(type, bindingType) ||
|
|
9907
9943
|
this.findEnumTypeForType(type) ||
|
|
9908
9944
|
this.findStructuredTypeForType(type);
|
|
9909
|
-
this.memo.forType.parser
|
|
9945
|
+
this.memo.forType.parser.set(key, value === null || value === void 0 ? void 0 : value.parser);
|
|
9910
9946
|
}
|
|
9911
9947
|
else {
|
|
9912
9948
|
// None Parser
|
|
9913
|
-
this.memo.forType.parser
|
|
9949
|
+
this.memo.forType.parser.set(key, NONE_PARSER);
|
|
9914
9950
|
}
|
|
9915
9951
|
}
|
|
9916
|
-
return this.memo.forType.parser
|
|
9952
|
+
return this.memo.forType.parser.get(key);
|
|
9917
9953
|
}
|
|
9918
9954
|
findOptionsForType(type) {
|
|
9919
9955
|
var _a;
|
|
9920
9956
|
// Strucutred Options
|
|
9921
|
-
if (!
|
|
9957
|
+
if (!this.memo.forType.options.has(type)) {
|
|
9922
9958
|
let st = this.findStructuredTypeForType(type);
|
|
9923
|
-
this.memo.forType.options
|
|
9924
|
-
|
|
9925
|
-
|
|
9926
|
-
: undefined;
|
|
9959
|
+
this.memo.forType.options.set(type, st !== undefined && st.model !== undefined && ((_a = st.model) === null || _a === void 0 ? void 0 : _a.meta) !== null
|
|
9960
|
+
? st.model.meta
|
|
9961
|
+
: undefined);
|
|
9927
9962
|
}
|
|
9928
|
-
return this.memo.forType.options
|
|
9963
|
+
return this.memo.forType.options.get(type);
|
|
9929
9964
|
}
|
|
9930
9965
|
}
|
|
9931
9966
|
|
|
@@ -10387,9 +10422,9 @@ class ODataClient {
|
|
|
10387
10422
|
return this.request('PUT', resource, addBody(options, body));
|
|
10388
10423
|
}
|
|
10389
10424
|
}
|
|
10390
|
-
ODataClient.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
10391
|
-
ODataClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.
|
|
10392
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
10425
|
+
ODataClient.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ODataClient, deps: [{ token: i1.HttpClient }, { token: ODataSettings }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
10426
|
+
ODataClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ODataClient, providedIn: 'root' });
|
|
10427
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ODataClient, decorators: [{
|
|
10393
10428
|
type: Injectable,
|
|
10394
10429
|
args: [{
|
|
10395
10430
|
providedIn: 'root',
|
|
@@ -10641,9 +10676,9 @@ class ODataServiceFactory {
|
|
|
10641
10676
|
})(this.client, singletonName, apiNameOrEntityType);
|
|
10642
10677
|
}
|
|
10643
10678
|
}
|
|
10644
|
-
ODataServiceFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
10645
|
-
ODataServiceFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.
|
|
10646
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
10679
|
+
ODataServiceFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ODataServiceFactory, deps: [{ token: ODataClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
10680
|
+
ODataServiceFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ODataServiceFactory });
|
|
10681
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ODataServiceFactory, decorators: [{
|
|
10647
10682
|
type: Injectable
|
|
10648
10683
|
}], ctorParameters: function () { return [{ type: ODataClient }]; } });
|
|
10649
10684
|
|
|
@@ -10667,10 +10702,10 @@ class ODataModule {
|
|
|
10667
10702
|
};
|
|
10668
10703
|
}
|
|
10669
10704
|
}
|
|
10670
|
-
ODataModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
10671
|
-
ODataModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.
|
|
10672
|
-
ODataModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.
|
|
10673
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
10705
|
+
ODataModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
10706
|
+
ODataModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ODataModule, imports: [HttpClientModule] });
|
|
10707
|
+
ODataModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ODataModule, providers: [ODataClient, ODataServiceFactory], imports: [[HttpClientModule]] });
|
|
10708
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: ODataModule, decorators: [{
|
|
10674
10709
|
type: NgModule,
|
|
10675
10710
|
args: [{
|
|
10676
10711
|
imports: [HttpClientModule],
|