angular-odata 0.92.0 → 0.95.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/{esm2015/angular-odata.js → esm2020/angular-odata.mjs} +0 -0
- package/esm2020/lib/api.mjs +303 -0
- package/{esm2015/lib/cache/cache.js → esm2020/lib/cache/cache.mjs} +3 -3
- package/{esm2015/lib/cache/index.js → esm2020/lib/cache/index.mjs} +0 -0
- package/{esm2015/lib/cache/memory.js → esm2020/lib/cache/memory.mjs} +1 -1
- package/{esm2015/lib/cache/storage.js → esm2020/lib/cache/storage.mjs} +2 -2
- package/esm2020/lib/client.mjs +271 -0
- package/{esm2015/lib/constants.js → esm2020/lib/constants.mjs} +3 -1
- package/esm2020/lib/helper.mjs +268 -0
- package/{esm2015/lib/index.js → esm2020/lib/index.mjs} +0 -0
- package/esm2020/lib/models/collection.mjs +741 -0
- package/{esm2015/lib/models/index.js → esm2020/lib/models/index.mjs} +0 -0
- package/esm2020/lib/models/model.mjs +453 -0
- package/esm2020/lib/models/options.mjs +945 -0
- package/{esm2015/lib/module.js → esm2020/lib/module.mjs} +7 -7
- package/esm2020/lib/options.mjs +32 -0
- package/{esm2015/lib/resources/index.js → esm2020/lib/resources/index.mjs} +0 -0
- package/{esm2015/lib/resources/path/handlers.js → esm2020/lib/resources/path/handlers.mjs} +1 -1
- package/{esm2015/lib/resources/path/index.js → esm2020/lib/resources/path/index.mjs} +0 -0
- package/esm2020/lib/resources/path/segments.mjs +124 -0
- package/esm2020/lib/resources/query/builder.mjs +590 -0
- package/esm2020/lib/resources/query/expressions.mjs +207 -0
- package/esm2020/lib/resources/query/handlers.mjs +186 -0
- package/{esm2015/lib/resources/query/index.js → esm2020/lib/resources/query/index.mjs} +0 -0
- package/esm2020/lib/resources/query/options.mjs +103 -0
- package/esm2020/lib/resources/query/syntax.mjs +406 -0
- package/esm2020/lib/resources/request.mjs +167 -0
- package/esm2020/lib/resources/resource.mjs +326 -0
- package/esm2020/lib/resources/responses/annotations.mjs +119 -0
- package/{esm2015/lib/resources/responses/csdl/csdl-annotation.js → esm2020/lib/resources/responses/csdl/csdl-annotation.mjs} +0 -0
- package/{esm2015/lib/resources/responses/csdl/csdl-entity-container.js → esm2020/lib/resources/responses/csdl/csdl-entity-container.mjs} +0 -0
- package/{esm2015/lib/resources/responses/csdl/csdl-entity-set.js → esm2020/lib/resources/responses/csdl/csdl-entity-set.mjs} +0 -0
- package/{esm2015/lib/resources/responses/csdl/csdl-enum-type.js → esm2020/lib/resources/responses/csdl/csdl-enum-type.mjs} +0 -0
- package/{esm2015/lib/resources/responses/csdl/csdl-function-action.js → esm2020/lib/resources/responses/csdl/csdl-function-action.mjs} +0 -0
- package/{esm2015/lib/resources/responses/csdl/csdl-navigation-property-binding.js → esm2020/lib/resources/responses/csdl/csdl-navigation-property-binding.mjs} +0 -0
- package/{esm2015/lib/resources/responses/csdl/csdl-reference.js → esm2020/lib/resources/responses/csdl/csdl-reference.mjs} +0 -0
- package/{esm2015/lib/resources/responses/csdl/csdl-schema.js → esm2020/lib/resources/responses/csdl/csdl-schema.mjs} +0 -0
- package/{esm2015/lib/resources/responses/csdl/csdl-singleton.js → esm2020/lib/resources/responses/csdl/csdl-singleton.mjs} +0 -0
- package/{esm2015/lib/resources/responses/csdl/csdl-structural-property.js → esm2020/lib/resources/responses/csdl/csdl-structural-property.mjs} +0 -0
- package/{esm2015/lib/resources/responses/csdl/csdl-structured-type.js → esm2020/lib/resources/responses/csdl/csdl-structured-type.mjs} +0 -0
- package/{esm2015/lib/resources/responses/csdl/csdl-type-definition.js → esm2020/lib/resources/responses/csdl/csdl-type-definition.mjs} +0 -0
- package/{esm2015/lib/resources/responses/index.js → esm2020/lib/resources/responses/index.mjs} +0 -0
- package/esm2020/lib/resources/responses/metadata.mjs +547 -0
- package/{esm2015/lib/resources/responses/options.js → esm2020/lib/resources/responses/options.mjs} +0 -0
- package/{esm2015/lib/resources/responses/response.js → esm2020/lib/resources/responses/response.mjs} +0 -0
- package/{esm2015/lib/resources/responses/types.js → esm2020/lib/resources/responses/types.mjs} +0 -0
- package/esm2020/lib/resources/types/action.mjs +101 -0
- package/esm2020/lib/resources/types/batch.mjs +288 -0
- package/esm2020/lib/resources/types/count.mjs +27 -0
- package/esm2020/lib/resources/types/entity-set.mjs +94 -0
- package/esm2020/lib/resources/types/entity.mjs +106 -0
- package/esm2020/lib/resources/types/function.mjs +137 -0
- package/{esm2015/lib/resources/types/index.js → esm2020/lib/resources/types/index.mjs} +0 -0
- package/esm2020/lib/resources/types/media.mjs +41 -0
- package/esm2020/lib/resources/types/metadata.mjs +30 -0
- package/esm2020/lib/resources/types/navigation-property.mjs +226 -0
- package/esm2020/lib/resources/types/options.mjs +2 -0
- package/esm2020/lib/resources/types/property.mjs +183 -0
- package/esm2020/lib/resources/types/reference.mjs +85 -0
- package/esm2020/lib/resources/types/singleton.mjs +126 -0
- package/esm2020/lib/resources/types/value.mjs +41 -0
- package/esm2020/lib/schema/annotation.mjs +37 -0
- package/esm2020/lib/schema/callable.mjs +62 -0
- package/esm2020/lib/schema/element.mjs +51 -0
- package/esm2020/lib/schema/entity-container.mjs +9 -0
- package/esm2020/lib/schema/entity-set.mjs +9 -0
- package/esm2020/lib/schema/enum-type.mjs +71 -0
- package/{esm2015/lib/schema/index.js → esm2020/lib/schema/index.mjs} +0 -0
- package/esm2020/lib/schema/parsers/callable.mjs +113 -0
- package/{esm2015/lib/schema/parsers/edm.js → esm2020/lib/schema/parsers/edm.mjs} +2 -2
- package/esm2020/lib/schema/parsers/enum-type.mjs +107 -0
- package/{esm2015/lib/schema/parsers/index.js → esm2020/lib/schema/parsers/index.mjs} +0 -0
- package/esm2020/lib/schema/parsers/structured-type.mjs +412 -0
- package/esm2020/lib/schema/schema.mjs +61 -0
- package/esm2020/lib/schema/structured-type.mjs +198 -0
- package/esm2020/lib/services/base.mjs +29 -0
- package/esm2020/lib/services/entity-set.mjs +143 -0
- package/esm2020/lib/services/entity.mjs +12 -0
- package/{esm2015/lib/services/factory.js → esm2020/lib/services/factory.mjs} +3 -3
- package/{esm2015/lib/services/index.js → esm2020/lib/services/index.mjs} +0 -0
- package/{esm2015/lib/services/singleton.js → esm2020/lib/services/singleton.mjs} +1 -1
- package/{esm2015/lib/settings.js → esm2020/lib/settings.mjs} +1 -1
- package/{esm2015/lib/tokens.js → esm2020/lib/tokens.mjs} +0 -0
- package/esm2020/lib/types.mjs +37 -0
- package/{esm2015/lib/utils/arraybuffers.js → esm2020/lib/utils/arraybuffers.mjs} +0 -0
- package/{esm2015/lib/utils/dates.js → esm2020/lib/utils/dates.mjs} +0 -0
- package/{esm2015/lib/utils/durations.js → esm2020/lib/utils/durations.mjs} +0 -0
- package/{esm2015/lib/utils/enums.js → esm2020/lib/utils/enums.mjs} +0 -0
- package/{esm2015/lib/utils/http.js → esm2020/lib/utils/http.mjs} +0 -0
- package/{esm2015/lib/utils/index.js → esm2020/lib/utils/index.mjs} +0 -0
- package/{esm2015/lib/utils/objects.js → esm2020/lib/utils/objects.mjs} +0 -0
- package/esm2020/lib/utils/odata.mjs +22 -0
- package/{esm2015/lib/utils/strings.js → esm2020/lib/utils/strings.mjs} +0 -0
- package/{esm2015/lib/utils/types.js → esm2020/lib/utils/types.mjs} +0 -0
- package/{esm2015/lib/utils/urls.js → esm2020/lib/utils/urls.mjs} +0 -0
- package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
- package/fesm2015/{angular-odata.js → angular-odata.mjs} +849 -750
- package/fesm2015/angular-odata.mjs.map +1 -0
- package/fesm2020/angular-odata.mjs +10274 -0
- package/fesm2020/angular-odata.mjs.map +1 -0
- package/lib/api.d.ts +10 -10
- package/lib/cache/cache.d.ts +2 -2
- package/lib/cache/storage.d.ts +1 -1
- package/lib/client.d.ts +3 -3
- package/lib/constants.d.ts +1 -0
- package/lib/models/collection.d.ts +11 -19
- package/lib/models/model.d.ts +22 -18
- package/lib/models/options.d.ts +16 -21
- package/lib/module.d.ts +1 -1
- package/lib/options.d.ts +1 -0
- package/lib/resources/path/segments.d.ts +1 -1
- package/lib/resources/query/expressions.d.ts +37 -27
- package/lib/resources/query/handlers.d.ts +7 -11
- package/lib/resources/query/options.d.ts +2 -2
- package/lib/resources/query/syntax.d.ts +52 -54
- package/lib/resources/request.d.ts +1 -1
- package/lib/resources/resource.d.ts +25 -8
- package/lib/resources/types/action.d.ts +12 -19
- package/lib/resources/types/batch.d.ts +1 -3
- package/lib/resources/types/count.d.ts +5 -4
- package/lib/resources/types/entity-set.d.ts +11 -15
- package/lib/resources/types/entity.d.ts +12 -15
- package/lib/resources/types/function.d.ts +11 -18
- package/lib/resources/types/media.d.ts +6 -5
- package/lib/resources/types/metadata.d.ts +3 -5
- package/lib/resources/types/navigation-property.d.ts +15 -21
- package/lib/resources/types/property.d.ts +13 -19
- package/lib/resources/types/reference.d.ts +39 -6
- package/lib/resources/types/singleton.d.ts +12 -16
- package/lib/resources/types/value.d.ts +9 -5
- package/lib/schema/{base.d.ts → annotation.d.ts} +0 -0
- package/lib/schema/callable.d.ts +2 -18
- package/lib/schema/element.d.ts +39 -0
- package/lib/schema/entity-container.d.ts +2 -12
- package/lib/schema/entity-set.d.ts +2 -18
- package/lib/schema/enum-type.d.ts +2 -26
- package/lib/schema/parsers/enum-type.d.ts +4 -4
- package/lib/schema/parsers/structured-type.d.ts +4 -4
- package/lib/schema/schema.d.ts +2 -2
- package/lib/schema/structured-type.d.ts +8 -26
- package/lib/services/base.d.ts +2 -2
- package/lib/services/entity-set.d.ts +2 -2
- package/lib/services/entity.d.ts +1 -1
- package/lib/services/singleton.d.ts +2 -2
- package/lib/settings.d.ts +5 -5
- package/lib/types.d.ts +1 -0
- package/package.json +21 -8
- package/bundles/angular-odata.umd.js +0 -11861
- package/bundles/angular-odata.umd.js.map +0 -1
- package/esm2015/lib/api.js +0 -296
- package/esm2015/lib/client.js +0 -272
- package/esm2015/lib/helper.js +0 -268
- package/esm2015/lib/models/collection.js +0 -734
- package/esm2015/lib/models/model.js +0 -438
- package/esm2015/lib/models/options.js +0 -942
- package/esm2015/lib/options.js +0 -31
- package/esm2015/lib/resources/path/segments.js +0 -124
- package/esm2015/lib/resources/query/builder.js +0 -591
- package/esm2015/lib/resources/query/expressions.js +0 -194
- package/esm2015/lib/resources/query/handlers.js +0 -192
- package/esm2015/lib/resources/query/options.js +0 -103
- package/esm2015/lib/resources/query/syntax.js +0 -367
- package/esm2015/lib/resources/request.js +0 -168
- package/esm2015/lib/resources/resource.js +0 -243
- package/esm2015/lib/resources/responses/annotations.js +0 -121
- package/esm2015/lib/resources/responses/metadata.js +0 -548
- package/esm2015/lib/resources/types/action.js +0 -105
- package/esm2015/lib/resources/types/batch.js +0 -294
- package/esm2015/lib/resources/types/count.js +0 -33
- package/esm2015/lib/resources/types/entity-set.js +0 -101
- package/esm2015/lib/resources/types/entity.js +0 -137
- package/esm2015/lib/resources/types/function.js +0 -130
- package/esm2015/lib/resources/types/media.js +0 -47
- package/esm2015/lib/resources/types/metadata.js +0 -36
- package/esm2015/lib/resources/types/navigation-property.js +0 -205
- package/esm2015/lib/resources/types/options.js +0 -2
- package/esm2015/lib/resources/types/property.js +0 -151
- package/esm2015/lib/resources/types/reference.js +0 -74
- package/esm2015/lib/resources/types/singleton.js +0 -167
- package/esm2015/lib/resources/types/value.js +0 -35
- package/esm2015/lib/schema/base.js +0 -37
- package/esm2015/lib/schema/callable.js +0 -82
- package/esm2015/lib/schema/entity-container.js +0 -24
- package/esm2015/lib/schema/entity-set.js +0 -35
- package/esm2015/lib/schema/enum-type.js +0 -102
- package/esm2015/lib/schema/parsers/callable.js +0 -107
- package/esm2015/lib/schema/parsers/enum-type.js +0 -107
- package/esm2015/lib/schema/parsers/structured-type.js +0 -392
- package/esm2015/lib/schema/schema.js +0 -52
- package/esm2015/lib/schema/structured-type.js +0 -220
- package/esm2015/lib/services/base.js +0 -23
- package/esm2015/lib/services/entity-set.js +0 -146
- package/esm2015/lib/services/entity.js +0 -12
- package/esm2015/lib/types.js +0 -37
- package/esm2015/lib/utils/odata.js +0 -21
- package/fesm2015/angular-odata.js.map +0 -1
|
@@ -119,6 +119,8 @@ const ODATA_ALIAS_PREFIX = '@';
|
|
|
119
119
|
const NEWLINE = '\r\n';
|
|
120
120
|
const NEWLINE_REGEXP = /\r?\n/;
|
|
121
121
|
const CACHE_KEY_SEPARATOR = ':';
|
|
122
|
+
// Models
|
|
123
|
+
const CID_FIELD_NAME = '_cid';
|
|
122
124
|
// Standard vocabularies for annotating OData services
|
|
123
125
|
// http://docs.oasis-open.org/odata/odata-vocabularies/v4.0/csprd01/odata-vocabularies-v4.0-csprd01.html
|
|
124
126
|
const COMPUTED = /.*Computed$/;
|
|
@@ -1376,11 +1378,12 @@ const Objects = {
|
|
|
1376
1378
|
const OData = {
|
|
1377
1379
|
// Merge callables parameters
|
|
1378
1380
|
mergeCallableParameters(callables) {
|
|
1381
|
+
const areEqual = (a, b) => a.name === b.name &&
|
|
1382
|
+
Objects.equal((a.parameters || {})[CALLABLE_BINDING_PARAMETER] || {}, (b.parameters || {})[CALLABLE_BINDING_PARAMETER] || {});
|
|
1379
1383
|
return callables.reduce((acc, config) => {
|
|
1380
|
-
if (acc.every((c) => c
|
|
1384
|
+
if (acc.every((c) => !areEqual(c, config))) {
|
|
1381
1385
|
config = callables
|
|
1382
|
-
.filter((c) => c
|
|
1383
|
-
Objects.equal((c.parameters || {})[CALLABLE_BINDING_PARAMETER] || {}, (config.parameters || {})[CALLABLE_BINDING_PARAMETER] || {}))
|
|
1386
|
+
.filter((c) => areEqual(c, config))
|
|
1384
1387
|
.reduce((acc, c) => {
|
|
1385
1388
|
acc.parameters = Object.assign(acc.parameters || {}, c.parameters || {});
|
|
1386
1389
|
return acc;
|
|
@@ -1435,6 +1438,24 @@ const Urls = {
|
|
|
1435
1438
|
},
|
|
1436
1439
|
};
|
|
1437
1440
|
|
|
1441
|
+
//export type Field<T> = keyof T | Funcs<keyof T>;
|
|
1442
|
+
class Field$1 {
|
|
1443
|
+
constructor(name = '') {
|
|
1444
|
+
this.name = name;
|
|
1445
|
+
}
|
|
1446
|
+
static factory() {
|
|
1447
|
+
const h = new Field$1();
|
|
1448
|
+
return new Proxy({ _name: '' }, h);
|
|
1449
|
+
}
|
|
1450
|
+
get(target, p) {
|
|
1451
|
+
let name = target['_name'];
|
|
1452
|
+
if (p === 'render') {
|
|
1453
|
+
return ({ prefix }) => prefix ? `${prefix}/${name}` : name;
|
|
1454
|
+
}
|
|
1455
|
+
name = name ? `${name}/${p}` : p;
|
|
1456
|
+
return new Proxy({ _name: name }, this);
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1438
1459
|
function applyMixins(derivedCtor, constructors) {
|
|
1439
1460
|
constructors.forEach((baseCtor) => {
|
|
1440
1461
|
Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
|
|
@@ -1443,15 +1464,18 @@ function applyMixins(derivedCtor, constructors) {
|
|
|
1443
1464
|
});
|
|
1444
1465
|
});
|
|
1445
1466
|
}
|
|
1446
|
-
function render(value, { aliases, normalize, escape, } = {}) {
|
|
1467
|
+
function render(value, { aliases, normalize, escape, prefix, } = {}) {
|
|
1447
1468
|
if (typeof value === 'function') {
|
|
1448
|
-
return render(value(syntax), { aliases, normalize });
|
|
1469
|
+
return render(value(syntax), { aliases, normalize, prefix });
|
|
1449
1470
|
}
|
|
1450
|
-
if (typeof value === 'object' &&
|
|
1451
|
-
|
|
1471
|
+
if (typeof value === 'object' &&
|
|
1472
|
+
value !== null &&
|
|
1473
|
+
value.render !== undefined) {
|
|
1474
|
+
return render(value.render({ aliases, escape, prefix }), {
|
|
1452
1475
|
aliases,
|
|
1453
1476
|
normalize,
|
|
1454
1477
|
escape,
|
|
1478
|
+
prefix,
|
|
1455
1479
|
});
|
|
1456
1480
|
}
|
|
1457
1481
|
return normalize ? normalizeValue(value, { aliases, escape }) : value;
|
|
@@ -1473,12 +1497,12 @@ class Function {
|
|
|
1473
1497
|
normalize: this.normalize,
|
|
1474
1498
|
};
|
|
1475
1499
|
}
|
|
1476
|
-
render({ aliases, escape, }) {
|
|
1500
|
+
render({ aliases, escape, prefix, }) {
|
|
1477
1501
|
let [field, ...values] = this.values;
|
|
1478
|
-
field = render(field);
|
|
1502
|
+
field = render(field, { aliases, escape, prefix });
|
|
1479
1503
|
let params = [
|
|
1480
1504
|
field,
|
|
1481
|
-
...values.map((v) => render(v, { aliases, escape, normalize: this.normalize })),
|
|
1505
|
+
...values.map((v) => render(v, { aliases, escape, prefix, normalize: this.normalize })),
|
|
1482
1506
|
];
|
|
1483
1507
|
return `${this.name}(${params.join(', ')})`;
|
|
1484
1508
|
}
|
|
@@ -1627,21 +1651,23 @@ class Operator {
|
|
|
1627
1651
|
normalize: this.normalize,
|
|
1628
1652
|
};
|
|
1629
1653
|
}
|
|
1630
|
-
render({ aliases, escape, }) {
|
|
1654
|
+
render({ aliases, escape, prefix, }) {
|
|
1631
1655
|
let [left, right] = this.values;
|
|
1632
|
-
left = render(left, { aliases, escape });
|
|
1656
|
+
left = render(left, { aliases, escape, prefix });
|
|
1633
1657
|
if (right !== undefined) {
|
|
1634
1658
|
right = Array.isArray(right)
|
|
1635
1659
|
? `(${right
|
|
1636
1660
|
.map((v) => render(v, {
|
|
1637
1661
|
aliases,
|
|
1638
1662
|
escape,
|
|
1663
|
+
prefix,
|
|
1639
1664
|
normalize: this.normalize,
|
|
1640
1665
|
}))
|
|
1641
1666
|
.join(',')})`
|
|
1642
1667
|
: render(right, {
|
|
1643
1668
|
aliases,
|
|
1644
1669
|
escape,
|
|
1670
|
+
prefix,
|
|
1645
1671
|
normalize: this.normalize,
|
|
1646
1672
|
});
|
|
1647
1673
|
return `${left} ${this.op} ${right}`;
|
|
@@ -1668,12 +1694,14 @@ class LogicalOperators {
|
|
|
1668
1694
|
le(left, right, normalize) {
|
|
1669
1695
|
return new Operator('le', [left, right], normalize);
|
|
1670
1696
|
}
|
|
1671
|
-
|
|
1672
|
-
|
|
1697
|
+
/*
|
|
1698
|
+
and(left: any, right: any, normalize?: boolean) {
|
|
1699
|
+
return new Operator('and', [left, right], normalize);
|
|
1673
1700
|
}
|
|
1674
|
-
or(left, right, normalize) {
|
|
1675
|
-
|
|
1701
|
+
or(left: any, right: any, normalize?: boolean) {
|
|
1702
|
+
return new Operator('or', [left, right], normalize);
|
|
1676
1703
|
}
|
|
1704
|
+
*/
|
|
1677
1705
|
not(value, normalize) {
|
|
1678
1706
|
return new Operator('not', [value], normalize);
|
|
1679
1707
|
}
|
|
@@ -1716,62 +1744,76 @@ class Grouping {
|
|
|
1716
1744
|
group: this.group.toJSON(),
|
|
1717
1745
|
};
|
|
1718
1746
|
}
|
|
1719
|
-
render({ aliases, escape, }) {
|
|
1720
|
-
return `(${render(this.group, { aliases })})`;
|
|
1747
|
+
render({ aliases, escape, prefix, }) {
|
|
1748
|
+
return `(${render(this.group, { aliases, escape, prefix })})`;
|
|
1721
1749
|
}
|
|
1722
1750
|
}
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1751
|
+
/*
|
|
1752
|
+
export class Navigation<T, N> implements Renderable {
|
|
1753
|
+
constructor(protected field: T, protected value: Field<N>) {}
|
|
1754
|
+
|
|
1755
|
+
get [Symbol.toStringTag]() {
|
|
1756
|
+
return 'Navigation';
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
toJSON() {
|
|
1760
|
+
return {
|
|
1761
|
+
field: this.field,
|
|
1762
|
+
value: this.value,
|
|
1763
|
+
};
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
render({
|
|
1767
|
+
aliases,
|
|
1768
|
+
escape,
|
|
1769
|
+
prefix,
|
|
1770
|
+
}: {
|
|
1771
|
+
aliases?: QueryCustomType[];
|
|
1772
|
+
escape?: boolean;
|
|
1773
|
+
prefix?: string;
|
|
1774
|
+
}): string {
|
|
1775
|
+
return `${this.field}/${render(this.value, { aliases, escape, prefix })}`;
|
|
1776
|
+
}
|
|
1740
1777
|
}
|
|
1741
|
-
|
|
1778
|
+
*/
|
|
1779
|
+
class GroupingOperators {
|
|
1742
1780
|
grouping(value) {
|
|
1743
1781
|
return new Grouping(value);
|
|
1744
1782
|
}
|
|
1745
|
-
navigation(field, value) {
|
|
1746
|
-
return new Navigation(field, value);
|
|
1747
|
-
}
|
|
1748
1783
|
}
|
|
1749
|
-
class Lambda
|
|
1750
|
-
constructor(op, values,
|
|
1751
|
-
super(op, values, normalize);
|
|
1784
|
+
class Lambda {
|
|
1785
|
+
constructor(op, values, alias) {
|
|
1752
1786
|
this.op = op;
|
|
1753
1787
|
this.values = values;
|
|
1754
|
-
this.
|
|
1788
|
+
this.alias = alias;
|
|
1755
1789
|
}
|
|
1756
1790
|
get [Symbol.toStringTag]() {
|
|
1757
1791
|
return 'Lambda';
|
|
1758
1792
|
}
|
|
1759
|
-
|
|
1793
|
+
toJSON() {
|
|
1794
|
+
return {
|
|
1795
|
+
op: this.op,
|
|
1796
|
+
values: this.values,
|
|
1797
|
+
alias: this.alias,
|
|
1798
|
+
};
|
|
1799
|
+
}
|
|
1800
|
+
render({ aliases, escape, prefix, }) {
|
|
1760
1801
|
let [left, right] = this.values;
|
|
1761
|
-
left = render(left, { aliases, escape });
|
|
1762
|
-
let alias = left.split('/').pop().toLowerCase();
|
|
1763
|
-
return `${left}/${this.op}(${alias}:${
|
|
1802
|
+
left = render(left, { aliases, escape, prefix });
|
|
1803
|
+
let alias = this.alias || left.split('/').pop().toLowerCase()[0];
|
|
1804
|
+
return `${left}/${this.op}(${alias}:${render(right, {
|
|
1764
1805
|
aliases,
|
|
1765
1806
|
escape,
|
|
1807
|
+
prefix: alias,
|
|
1766
1808
|
})})`;
|
|
1767
1809
|
}
|
|
1768
1810
|
}
|
|
1769
1811
|
class LambdaOperators {
|
|
1770
|
-
any(field, value) {
|
|
1771
|
-
return new Lambda('any', [field, value]);
|
|
1812
|
+
any(field, value, alias) {
|
|
1813
|
+
return new Lambda('any', [field, value], alias);
|
|
1772
1814
|
}
|
|
1773
|
-
all(field, value) {
|
|
1774
|
-
return new Lambda('all', [field, value]);
|
|
1815
|
+
all(field, value, alias) {
|
|
1816
|
+
return new Lambda('all', [field, value], alias);
|
|
1775
1817
|
}
|
|
1776
1818
|
}
|
|
1777
1819
|
class ODataOperators {
|
|
@@ -1779,7 +1821,7 @@ class ODataOperators {
|
|
|
1779
1821
|
applyMixins(ODataOperators, [
|
|
1780
1822
|
LogicalOperators,
|
|
1781
1823
|
ArithmeticOperators,
|
|
1782
|
-
|
|
1824
|
+
GroupingOperators,
|
|
1783
1825
|
LambdaOperators,
|
|
1784
1826
|
]);
|
|
1785
1827
|
const operators = new ODataOperators();
|
|
@@ -1801,34 +1843,33 @@ class ODataSyntax {
|
|
|
1801
1843
|
applyMixins(ODataSyntax, [ODataOperators, ODataFunctions]);
|
|
1802
1844
|
const syntax = new ODataSyntax();
|
|
1803
1845
|
|
|
1804
|
-
var Connector;
|
|
1805
|
-
(function (Connector) {
|
|
1806
|
-
Connector["AND"] = "and";
|
|
1807
|
-
Connector["OR"] = "or";
|
|
1808
|
-
})(Connector || (Connector = {}));
|
|
1809
1846
|
class Expression {
|
|
1810
1847
|
constructor({ children, connector, negated, } = {}) {
|
|
1811
1848
|
this._children = children || [];
|
|
1812
|
-
this._connector = connector ||
|
|
1849
|
+
this._connector = connector || 'and';
|
|
1813
1850
|
this._negated = negated || false;
|
|
1814
1851
|
}
|
|
1815
1852
|
get [Symbol.toStringTag]() {
|
|
1816
1853
|
return 'Expression';
|
|
1817
1854
|
}
|
|
1818
|
-
static
|
|
1819
|
-
return
|
|
1855
|
+
static s() {
|
|
1856
|
+
return Field$1.factory();
|
|
1820
1857
|
}
|
|
1821
|
-
static and
|
|
1822
|
-
return new Expression({ connector
|
|
1858
|
+
static e(connector = 'and') {
|
|
1859
|
+
return new Expression({ connector });
|
|
1823
1860
|
}
|
|
1824
|
-
static
|
|
1825
|
-
return
|
|
1861
|
+
static o() {
|
|
1862
|
+
return operators;
|
|
1826
1863
|
}
|
|
1827
|
-
static
|
|
1828
|
-
return
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1864
|
+
static f() {
|
|
1865
|
+
return functions;
|
|
1866
|
+
}
|
|
1867
|
+
static filter(opts) {
|
|
1868
|
+
return opts({
|
|
1869
|
+
s: Expression.s(),
|
|
1870
|
+
e: Expression.e,
|
|
1871
|
+
o: Expression.o(),
|
|
1872
|
+
f: Expression.f(),
|
|
1832
1873
|
});
|
|
1833
1874
|
}
|
|
1834
1875
|
toJSON() {
|
|
@@ -1850,9 +1891,9 @@ class Expression {
|
|
|
1850
1891
|
length() {
|
|
1851
1892
|
return this._children.length;
|
|
1852
1893
|
}
|
|
1853
|
-
render({ aliases, escape, } = {}) {
|
|
1894
|
+
render({ aliases, escape, prefix, } = {}) {
|
|
1854
1895
|
let content = this._children
|
|
1855
|
-
.map((n) => n.render({ aliases, escape }))
|
|
1896
|
+
.map((n) => n.render({ aliases, escape, prefix }))
|
|
1856
1897
|
.join(` ${this._connector} `);
|
|
1857
1898
|
if (this._negated) {
|
|
1858
1899
|
content = `not (${content})`;
|
|
@@ -1903,52 +1944,65 @@ class Expression {
|
|
|
1903
1944
|
return this;
|
|
1904
1945
|
}
|
|
1905
1946
|
or(exp) {
|
|
1906
|
-
return this._add(
|
|
1947
|
+
return this._add(exp, 'or');
|
|
1907
1948
|
}
|
|
1908
1949
|
and(exp) {
|
|
1909
|
-
return this._add(
|
|
1950
|
+
return this._add(exp, 'and');
|
|
1910
1951
|
}
|
|
1911
1952
|
not(exp) {
|
|
1912
|
-
|
|
1953
|
+
const notExp = new Expression({
|
|
1954
|
+
children: exp.children(),
|
|
1955
|
+
connector: exp.connector(),
|
|
1956
|
+
negated: true,
|
|
1957
|
+
});
|
|
1958
|
+
return this._add(notExp, this._connector);
|
|
1913
1959
|
}
|
|
1914
1960
|
eq(left, right, normalize) {
|
|
1915
|
-
return this._add(
|
|
1961
|
+
return this._add(operators.eq(left, right, normalize));
|
|
1916
1962
|
}
|
|
1917
1963
|
ne(left, right, normalize) {
|
|
1918
|
-
return this._add(
|
|
1964
|
+
return this._add(operators.ne(left, right, normalize));
|
|
1919
1965
|
}
|
|
1920
1966
|
gt(left, right, normalize) {
|
|
1921
|
-
return this._add(
|
|
1967
|
+
return this._add(operators.gt(left, right, normalize));
|
|
1922
1968
|
}
|
|
1923
1969
|
ge(left, right, normalize) {
|
|
1924
|
-
return this._add(
|
|
1970
|
+
return this._add(operators.ge(left, right, normalize));
|
|
1925
1971
|
}
|
|
1926
1972
|
lt(left, right, normalize) {
|
|
1927
|
-
return this._add(
|
|
1973
|
+
return this._add(operators.lt(left, right, normalize));
|
|
1928
1974
|
}
|
|
1929
1975
|
le(left, right, normalize) {
|
|
1930
|
-
return this._add(
|
|
1976
|
+
return this._add(operators.le(left, right, normalize));
|
|
1931
1977
|
}
|
|
1932
1978
|
has(left, right, normalize) {
|
|
1933
|
-
return this._add(
|
|
1979
|
+
return this._add(operators.has(left, right, normalize));
|
|
1934
1980
|
}
|
|
1935
1981
|
in(left, right, normalize) {
|
|
1936
|
-
return this._add(
|
|
1982
|
+
return this._add(operators.in(left, right, normalize));
|
|
1937
1983
|
}
|
|
1938
1984
|
contains(left, right, normalize) {
|
|
1939
|
-
return this._add(
|
|
1985
|
+
return this._add(functions.contains(left, right, normalize));
|
|
1940
1986
|
}
|
|
1941
1987
|
startsWith(left, right, normalize) {
|
|
1942
|
-
return this._add(
|
|
1988
|
+
return this._add(functions.startsWith(left, right, normalize));
|
|
1943
1989
|
}
|
|
1944
1990
|
endsWith(left, right, normalize) {
|
|
1945
|
-
return this._add(
|
|
1991
|
+
return this._add(functions.endsWith(left, right, normalize));
|
|
1946
1992
|
}
|
|
1947
|
-
any(left,
|
|
1948
|
-
|
|
1993
|
+
any(left, opts, alias) {
|
|
1994
|
+
const exp = opts({
|
|
1995
|
+
s: Field$1.factory(),
|
|
1996
|
+
e: Expression.e,
|
|
1997
|
+
});
|
|
1998
|
+
return this._add(syntax.any(left, exp, alias));
|
|
1949
1999
|
}
|
|
1950
|
-
all(left,
|
|
1951
|
-
|
|
2000
|
+
all(left, opts, alias) {
|
|
2001
|
+
const exp = opts({
|
|
2002
|
+
s: Field$1.factory(),
|
|
2003
|
+
e: Expression.e,
|
|
2004
|
+
});
|
|
2005
|
+
return this._add(syntax.all(left, exp, alias));
|
|
1952
2006
|
}
|
|
1953
2007
|
isof(left, type) {
|
|
1954
2008
|
return this._add(syntax.isof(left, type));
|
|
@@ -2099,9 +2153,6 @@ class ODataQueryOptionsHandler {
|
|
|
2099
2153
|
if (Types.isFunction(opts)) {
|
|
2100
2154
|
return this.options.expression(QueryOptionNames.compute, opts({
|
|
2101
2155
|
e: () => Expression.e(),
|
|
2102
|
-
and: () => Expression.and(),
|
|
2103
|
-
or: () => Expression.or(),
|
|
2104
|
-
not: (e) => Expression.not(e),
|
|
2105
2156
|
}));
|
|
2106
2157
|
}
|
|
2107
2158
|
return this.options.option(QueryOptionNames.compute, opts);
|
|
@@ -2118,10 +2169,10 @@ class ODataQueryOptionsHandler {
|
|
|
2118
2169
|
filter(opts) {
|
|
2119
2170
|
if (Types.isFunction(opts)) {
|
|
2120
2171
|
return this.options.expression(QueryOptionNames.filter, opts({
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2172
|
+
s: Expression.s(),
|
|
2173
|
+
e: Expression.e,
|
|
2174
|
+
o: Expression.o(),
|
|
2175
|
+
f: Expression.f(),
|
|
2125
2176
|
}));
|
|
2126
2177
|
}
|
|
2127
2178
|
return this.options.option(QueryOptionNames.filter, opts);
|
|
@@ -2130,9 +2181,6 @@ class ODataQueryOptionsHandler {
|
|
|
2130
2181
|
if (Types.isFunction(opts)) {
|
|
2131
2182
|
return this.options.expression(QueryOptionNames.orderBy, opts({
|
|
2132
2183
|
e: () => Expression.e(),
|
|
2133
|
-
and: () => Expression.and(),
|
|
2134
|
-
or: () => Expression.or(),
|
|
2135
|
-
not: (e) => Expression.not(e),
|
|
2136
2184
|
}));
|
|
2137
2185
|
}
|
|
2138
2186
|
return this.options.option(QueryOptionNames.orderBy, opts);
|
|
@@ -2670,6 +2718,55 @@ class ODataAnnotatable {
|
|
|
2670
2718
|
}
|
|
2671
2719
|
}
|
|
2672
2720
|
|
|
2721
|
+
class ODataSchemaElement extends ODataAnnotatable {
|
|
2722
|
+
constructor(config, schema) {
|
|
2723
|
+
super(config);
|
|
2724
|
+
this.schema = schema;
|
|
2725
|
+
this.name = config.name;
|
|
2726
|
+
}
|
|
2727
|
+
get api() {
|
|
2728
|
+
return this.schema.api;
|
|
2729
|
+
}
|
|
2730
|
+
/**
|
|
2731
|
+
* Create a nicer looking title.
|
|
2732
|
+
* Titleize is meant for creating pretty output.
|
|
2733
|
+
* @param term The term of the annotation to find.
|
|
2734
|
+
* @returns The titleized string.
|
|
2735
|
+
*/
|
|
2736
|
+
titleize(term) {
|
|
2737
|
+
return (term && this.annotatedValue(term)) || Strings.titleCase(this.name);
|
|
2738
|
+
}
|
|
2739
|
+
/**
|
|
2740
|
+
* Returns a full type of the structured type including the namespace/alias.
|
|
2741
|
+
* @param alias Use the alias of the namespace instead of the namespace.
|
|
2742
|
+
* @returns The string representation of the type.
|
|
2743
|
+
*/
|
|
2744
|
+
type({ alias = false } = {}) {
|
|
2745
|
+
return `${alias ? this.schema.alias : this.schema.namespace}.${this.name}`;
|
|
2746
|
+
}
|
|
2747
|
+
/**
|
|
2748
|
+
* Returns a boolean indicating if the structured type is of the given type.
|
|
2749
|
+
* @param type String representation of the type
|
|
2750
|
+
* @returns True if the callable is type of the given type
|
|
2751
|
+
*/
|
|
2752
|
+
isTypeOf(type) {
|
|
2753
|
+
var names = [`${this.schema.namespace}.${this.name}`];
|
|
2754
|
+
if (this.schema.alias)
|
|
2755
|
+
names.push(`${this.schema.alias}.${this.name}`);
|
|
2756
|
+
return names.indexOf(type) !== -1;
|
|
2757
|
+
}
|
|
2758
|
+
/**
|
|
2759
|
+
* Returns a boolean indicating if the structured type is a sub type of the given type.
|
|
2760
|
+
* @param type String representation of the type
|
|
2761
|
+
* @returns True if the callable is type of the given type
|
|
2762
|
+
*/
|
|
2763
|
+
isSubtypeOf(schema) {
|
|
2764
|
+
if (this.isTypeOf(schema.type()))
|
|
2765
|
+
return true;
|
|
2766
|
+
return false;
|
|
2767
|
+
}
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2673
2770
|
//https://github.com/niklasvh/base64-arraybuffer
|
|
2674
2771
|
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
2675
2772
|
// Use a lookup table to find the index.
|
|
@@ -3089,6 +3186,7 @@ class ODataApiOptions {
|
|
|
3089
3186
|
this.accept = config.accept;
|
|
3090
3187
|
Object.assign(this.etag, config.etag || {});
|
|
3091
3188
|
this.prefer = config.prefer;
|
|
3189
|
+
this.deleteRefBy = config.deleteRefBy || 'path';
|
|
3092
3190
|
}
|
|
3093
3191
|
get helper() {
|
|
3094
3192
|
return ODataHelper[this.version];
|
|
@@ -3111,7 +3209,7 @@ class ODataEnumTypeFieldParser extends ODataAnnotatable {
|
|
|
3111
3209
|
this.value = field.value;
|
|
3112
3210
|
}
|
|
3113
3211
|
titleize(term) {
|
|
3114
|
-
return this.annotatedValue(term) || this.name;
|
|
3212
|
+
return (term && this.annotatedValue(term)) || this.name;
|
|
3115
3213
|
}
|
|
3116
3214
|
}
|
|
3117
3215
|
class ODataEnumTypeParser extends ODataAnnotatable {
|
|
@@ -3130,8 +3228,8 @@ class ODataEnumTypeParser extends ODataAnnotatable {
|
|
|
3130
3228
|
* @param term The term of the annotation to find.
|
|
3131
3229
|
* @returns The titleized string.
|
|
3132
3230
|
*/
|
|
3133
|
-
|
|
3134
|
-
return this.annotatedValue(term) || Strings.titleCase(this.name);
|
|
3231
|
+
ttitelize(term) {
|
|
3232
|
+
return (term && this.annotatedValue(term)) || Strings.titleCase(this.name);
|
|
3135
3233
|
}
|
|
3136
3234
|
configure({ options }) {
|
|
3137
3235
|
this.optionsHelper = options;
|
|
@@ -3435,8 +3533,8 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
|
|
|
3435
3533
|
* @param term The term of the annotation to find.
|
|
3436
3534
|
* @returns The titleized string.
|
|
3437
3535
|
*/
|
|
3438
|
-
|
|
3439
|
-
return this.annotatedValue(term) || Strings.titleCase(this.name);
|
|
3536
|
+
titleize(term) {
|
|
3537
|
+
return (term && this.annotatedValue(term)) || Strings.titleCase(this.name);
|
|
3440
3538
|
}
|
|
3441
3539
|
isTypeOf(type) {
|
|
3442
3540
|
var names = [`${this.namespace}.${this.name}`];
|
|
@@ -3444,11 +3542,12 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
|
|
|
3444
3542
|
names.push(`${this.alias}.${this.name}`);
|
|
3445
3543
|
return names.indexOf(type) !== -1;
|
|
3446
3544
|
}
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3545
|
+
isSubtypeOf(type) {
|
|
3546
|
+
if (this.isTypeOf(type))
|
|
3547
|
+
return true;
|
|
3548
|
+
if (this.parent)
|
|
3549
|
+
return this.parent.isSubtypeOf(type);
|
|
3550
|
+
return false;
|
|
3452
3551
|
}
|
|
3453
3552
|
findChildParser(predicate) {
|
|
3454
3553
|
if (predicate(this))
|
|
@@ -3547,7 +3646,7 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
|
|
|
3547
3646
|
let schema = ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.toJsonSchema(options)) || {
|
|
3548
3647
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
3549
3648
|
$id: `${this.namespace}.${this.name}`,
|
|
3550
|
-
title: this.
|
|
3649
|
+
title: this.titleize(DESCRIPTION),
|
|
3551
3650
|
description: this.annotatedValue(LONG_DESCRIPTION),
|
|
3552
3651
|
type: 'object',
|
|
3553
3652
|
properties: {},
|
|
@@ -3694,10 +3793,9 @@ class ODataCallableParser {
|
|
|
3694
3793
|
}
|
|
3695
3794
|
}
|
|
3696
3795
|
|
|
3697
|
-
class ODataCallable {
|
|
3796
|
+
class ODataCallable extends ODataSchemaElement {
|
|
3698
3797
|
constructor(config, schema) {
|
|
3699
|
-
|
|
3700
|
-
this.name = config.name;
|
|
3798
|
+
super(config, schema);
|
|
3701
3799
|
this.entitySetPath = config.entitySetPath;
|
|
3702
3800
|
this.bound = config.bound;
|
|
3703
3801
|
this.composable = config.composable;
|
|
@@ -3717,25 +3815,6 @@ class ODataCallable {
|
|
|
3717
3815
|
: this.name;
|
|
3718
3816
|
return path;
|
|
3719
3817
|
}
|
|
3720
|
-
/**
|
|
3721
|
-
* Returns a full type of the callable including the namespace/alias.
|
|
3722
|
-
* @param alias Use the alias of the namespace instead of the namespace.
|
|
3723
|
-
* @returns The string representation of the type.
|
|
3724
|
-
*/
|
|
3725
|
-
type({ alias = false } = {}) {
|
|
3726
|
-
return `${alias ? this.schema.alias : this.schema.namespace}.${this.name}`;
|
|
3727
|
-
}
|
|
3728
|
-
/**
|
|
3729
|
-
* Returns a boolean indicating if the callable is of the given type.
|
|
3730
|
-
* @param type String representation of the type
|
|
3731
|
-
* @returns True if the callable is type of the given type
|
|
3732
|
-
*/
|
|
3733
|
-
isTypeOf(type) {
|
|
3734
|
-
return this.parser.isTypeOf(type);
|
|
3735
|
-
}
|
|
3736
|
-
get api() {
|
|
3737
|
-
return this.schema.api;
|
|
3738
|
-
}
|
|
3739
3818
|
configure({ parserForType, }) {
|
|
3740
3819
|
this.parser.configure({ options: this.api.options, parserForType });
|
|
3741
3820
|
}
|
|
@@ -3775,96 +3854,27 @@ class ODataCallable {
|
|
|
3775
3854
|
}
|
|
3776
3855
|
}
|
|
3777
3856
|
|
|
3778
|
-
class ODataEntitySet extends
|
|
3857
|
+
class ODataEntitySet extends ODataSchemaElement {
|
|
3779
3858
|
constructor(config, schema) {
|
|
3780
|
-
super(config);
|
|
3781
|
-
this.schema = schema;
|
|
3782
|
-
this.name = config.name;
|
|
3859
|
+
super(config, schema);
|
|
3783
3860
|
this.entityType = config.entityType;
|
|
3784
3861
|
this.service = config.service;
|
|
3785
3862
|
}
|
|
3786
|
-
/**
|
|
3787
|
-
* Create a nicer looking title.
|
|
3788
|
-
* Titleize is meant for creating pretty output.
|
|
3789
|
-
* @param term The term of the annotation to find.
|
|
3790
|
-
* @returns The titleized string.
|
|
3791
|
-
*/
|
|
3792
|
-
titelize(term) {
|
|
3793
|
-
return this.annotatedValue(term) || Strings.titleCase(this.name);
|
|
3794
|
-
}
|
|
3795
|
-
/**
|
|
3796
|
-
* Returns a boolean indicating if the entity set is of the given type.
|
|
3797
|
-
* @param type String representation of the type
|
|
3798
|
-
* @returns True if the callable is type of the given type
|
|
3799
|
-
*/
|
|
3800
|
-
isTypeOf(type) {
|
|
3801
|
-
var names = [`${this.schema.namespace}.${this.name}`];
|
|
3802
|
-
if (this.schema.alias)
|
|
3803
|
-
names.push(`${this.schema.alias}.${this.name}`);
|
|
3804
|
-
return names.indexOf(type) !== -1;
|
|
3805
|
-
}
|
|
3806
|
-
get api() {
|
|
3807
|
-
return this.schema.api;
|
|
3808
|
-
}
|
|
3809
3863
|
}
|
|
3810
3864
|
|
|
3811
|
-
class ODataEntityContainer extends
|
|
3865
|
+
class ODataEntityContainer extends ODataSchemaElement {
|
|
3812
3866
|
constructor(config, schema) {
|
|
3813
|
-
super(config);
|
|
3814
|
-
this.schema = schema;
|
|
3815
|
-
this.name = config.name;
|
|
3867
|
+
super(config, schema);
|
|
3816
3868
|
this.entitySets = (config.entitySets || []).map((config) => new ODataEntitySet(config, schema));
|
|
3817
3869
|
}
|
|
3818
|
-
get api() {
|
|
3819
|
-
return this.schema.api;
|
|
3820
|
-
}
|
|
3821
|
-
/**
|
|
3822
|
-
* Create a nicer looking title.
|
|
3823
|
-
* Titleize is meant for creating pretty output.
|
|
3824
|
-
* @param term The term of the annotation to find.
|
|
3825
|
-
* @returns The titleized string.
|
|
3826
|
-
*/
|
|
3827
|
-
titelize(term) {
|
|
3828
|
-
return this.annotatedValue(term) || Strings.titleCase(this.name);
|
|
3829
|
-
}
|
|
3830
3870
|
}
|
|
3831
3871
|
|
|
3832
|
-
class ODataEnumType extends
|
|
3872
|
+
class ODataEnumType extends ODataSchemaElement {
|
|
3833
3873
|
constructor(config, schema) {
|
|
3834
|
-
super(config);
|
|
3835
|
-
this.schema = schema;
|
|
3836
|
-
this.name = config.name;
|
|
3874
|
+
super(config, schema);
|
|
3837
3875
|
this.members = config.members;
|
|
3838
3876
|
this.parser = new ODataEnumTypeParser(config, schema.namespace, schema.alias);
|
|
3839
3877
|
}
|
|
3840
|
-
/**
|
|
3841
|
-
* Create a nicer looking title.
|
|
3842
|
-
* Titleize is meant for creating pretty output.
|
|
3843
|
-
* @param term The term of the annotation to find.
|
|
3844
|
-
* @returns The titleized string.
|
|
3845
|
-
*/
|
|
3846
|
-
titelize(term) {
|
|
3847
|
-
return this.annotatedValue(term) || Strings.titleCase(this.name);
|
|
3848
|
-
}
|
|
3849
|
-
/**
|
|
3850
|
-
* Returns a full type of the enum type including the namespace/alias.
|
|
3851
|
-
* @param alias Use the alias of the namespace instead of the namespace.
|
|
3852
|
-
* @returns The string representation of the type.
|
|
3853
|
-
*/
|
|
3854
|
-
type({ alias = false } = {}) {
|
|
3855
|
-
return `${alias ? this.schema.alias : this.schema.namespace}.${this.name}`;
|
|
3856
|
-
}
|
|
3857
|
-
/**
|
|
3858
|
-
* Returns a boolean indicating if the enum type is of the given type.
|
|
3859
|
-
* @param type String representation of the type
|
|
3860
|
-
* @returns True if the callable is type of the given type
|
|
3861
|
-
*/
|
|
3862
|
-
isTypeOf(type) {
|
|
3863
|
-
return this.parser.isTypeOf(type);
|
|
3864
|
-
}
|
|
3865
|
-
get api() {
|
|
3866
|
-
return this.schema.api;
|
|
3867
|
-
}
|
|
3868
3878
|
configure() {
|
|
3869
3879
|
this.parser.configure({ options: this.api.options });
|
|
3870
3880
|
}
|
|
@@ -3928,12 +3938,10 @@ class ODataEnumType extends ODataAnnotatable {
|
|
|
3928
3938
|
}
|
|
3929
3939
|
}
|
|
3930
3940
|
|
|
3931
|
-
class ODataStructuredType extends
|
|
3941
|
+
class ODataStructuredType extends ODataSchemaElement {
|
|
3932
3942
|
constructor(config, schema) {
|
|
3933
|
-
super(config);
|
|
3943
|
+
super(config, schema);
|
|
3934
3944
|
this.children = [];
|
|
3935
|
-
this.schema = schema;
|
|
3936
|
-
this.name = config.name;
|
|
3937
3945
|
this.base = config.base;
|
|
3938
3946
|
this.open = config.open || false;
|
|
3939
3947
|
this.parser = new ODataStructuredTypeParser(config, schema.namespace, schema.alias);
|
|
@@ -3943,15 +3951,12 @@ class ODataStructuredType extends ODataAnnotatable {
|
|
|
3943
3951
|
const options = this.model.hasOwnProperty('options')
|
|
3944
3952
|
? this.model.options
|
|
3945
3953
|
: { fields: {} };
|
|
3946
|
-
this.model.buildMeta(options, this);
|
|
3954
|
+
this.model.buildMeta({ options, schema: this });
|
|
3947
3955
|
}
|
|
3948
3956
|
if (this.collection !== undefined) {
|
|
3949
3957
|
this.collection.model = this.model;
|
|
3950
3958
|
}
|
|
3951
3959
|
}
|
|
3952
|
-
get api() {
|
|
3953
|
-
return this.schema.api;
|
|
3954
|
-
}
|
|
3955
3960
|
configure({ parserForType, findOptionsForType, }) {
|
|
3956
3961
|
if (this.base) {
|
|
3957
3962
|
const parent = this.api.findStructuredTypeForType(this.base);
|
|
@@ -3967,29 +3972,13 @@ class ODataStructuredType extends ODataAnnotatable {
|
|
|
3967
3972
|
}
|
|
3968
3973
|
}
|
|
3969
3974
|
/**
|
|
3970
|
-
*
|
|
3971
|
-
* Titleize is meant for creating pretty output.
|
|
3972
|
-
* @param term The term of the annotation to find.
|
|
3973
|
-
* @returns The titleized string.
|
|
3974
|
-
*/
|
|
3975
|
-
titelize(term) {
|
|
3976
|
-
return this.annotatedValue(term) || Strings.titleCase(this.name);
|
|
3977
|
-
}
|
|
3978
|
-
/**
|
|
3979
|
-
* Returns a full type of the structured type including the namespace/alias.
|
|
3980
|
-
* @param alias Use the alias of the namespace instead of the namespace.
|
|
3981
|
-
* @returns The string representation of the type.
|
|
3982
|
-
*/
|
|
3983
|
-
type({ alias = false } = {}) {
|
|
3984
|
-
return `${alias ? this.schema.alias : this.schema.namespace}.${this.name}`;
|
|
3985
|
-
}
|
|
3986
|
-
/**
|
|
3987
|
-
* Returns a boolean indicating if the structured type is of the given type.
|
|
3975
|
+
* Returns a boolean indicating if the structured type is a sub type of the given type.
|
|
3988
3976
|
* @param type String representation of the type
|
|
3989
3977
|
* @returns True if the callable is type of the given type
|
|
3990
3978
|
*/
|
|
3991
|
-
|
|
3992
|
-
return
|
|
3979
|
+
isSubtypeOf(schema) {
|
|
3980
|
+
return (super.isSubtypeOf(schema) ||
|
|
3981
|
+
(this.parent !== undefined && this.parent.isSubtypeOf(schema)));
|
|
3993
3982
|
}
|
|
3994
3983
|
/**
|
|
3995
3984
|
* Returns a boolean indicating if the structured type has a simple key.
|
|
@@ -4171,10 +4160,20 @@ class ODataSchema extends ODataAnnotatable {
|
|
|
4171
4160
|
return this.entities.find((e) => e.isTypeOf(type));
|
|
4172
4161
|
}
|
|
4173
4162
|
findCallableForType(type, bindingType) {
|
|
4163
|
+
const bindingStructuredType = bindingType !== undefined
|
|
4164
|
+
? this.api.findStructuredTypeForType(bindingType)
|
|
4165
|
+
: undefined;
|
|
4174
4166
|
return this.callables.find((c) => {
|
|
4175
4167
|
var _a;
|
|
4176
|
-
|
|
4177
|
-
|
|
4168
|
+
const isCallableType = c.isTypeOf(type);
|
|
4169
|
+
const callableBindingType = (_a = c.binding()) === null || _a === void 0 ? void 0 : _a.type;
|
|
4170
|
+
const callableBindingStructuredType = callableBindingType !== undefined
|
|
4171
|
+
? this.api.findStructuredTypeForType(callableBindingType)
|
|
4172
|
+
: undefined;
|
|
4173
|
+
return (isCallableType &&
|
|
4174
|
+
(!bindingStructuredType ||
|
|
4175
|
+
(callableBindingStructuredType &&
|
|
4176
|
+
bindingStructuredType.isSubtypeOf(callableBindingStructuredType))));
|
|
4178
4177
|
});
|
|
4179
4178
|
}
|
|
4180
4179
|
findEntitySetForType(type) {
|
|
@@ -4192,10 +4191,11 @@ class ODataSchema extends ODataAnnotatable {
|
|
|
4192
4191
|
}
|
|
4193
4192
|
|
|
4194
4193
|
class ODataResource {
|
|
4195
|
-
constructor(api, segments, query) {
|
|
4194
|
+
constructor(api, { segments, query, schema, } = {}) {
|
|
4196
4195
|
this.api = api;
|
|
4197
4196
|
this.pathSegments = segments || new ODataPathSegments();
|
|
4198
4197
|
this.queryOptions = query || new ODataQueryOptions();
|
|
4198
|
+
this.schema = schema;
|
|
4199
4199
|
}
|
|
4200
4200
|
/**
|
|
4201
4201
|
* @returns string The type of the resource
|
|
@@ -4228,28 +4228,53 @@ class ODataResource {
|
|
|
4228
4228
|
var _a;
|
|
4229
4229
|
return (_a = this.pathSegments.last({ key: true })) === null || _a === void 0 ? void 0 : _a.clearKey();
|
|
4230
4230
|
}
|
|
4231
|
+
//#region Models
|
|
4232
|
+
asModel(entity, { annots, reset } = {}) {
|
|
4233
|
+
let resource = this;
|
|
4234
|
+
const type = (annots === null || annots === void 0 ? void 0 : annots.type) || this.returnType();
|
|
4235
|
+
if (type === undefined)
|
|
4236
|
+
throw Error('');
|
|
4237
|
+
const Model = this.api.modelForType(type);
|
|
4238
|
+
let entitySet = annots === null || annots === void 0 ? void 0 : annots.entitySet;
|
|
4239
|
+
if (entitySet !== undefined) {
|
|
4240
|
+
resource = this.api.entitySet(entitySet).entity(entity);
|
|
4241
|
+
resource.query((q) => q.apply(this.queryOptions.toQueryArguments()));
|
|
4242
|
+
}
|
|
4243
|
+
return new Model(entity, { resource, annots, reset });
|
|
4244
|
+
}
|
|
4245
|
+
asCollection(entities, { annots, reset, } = {}) {
|
|
4246
|
+
let resource = this;
|
|
4247
|
+
const type = (annots === null || annots === void 0 ? void 0 : annots.type) || this.returnType();
|
|
4248
|
+
if (type === undefined)
|
|
4249
|
+
throw Error('');
|
|
4250
|
+
const Collection = this.api.collectionForType(type);
|
|
4251
|
+
let path = annots === null || annots === void 0 ? void 0 : annots.entitySet;
|
|
4252
|
+
if (path !== undefined) {
|
|
4253
|
+
resource = this.api.entitySet(path);
|
|
4254
|
+
resource.query((q) => q.apply(this.queryOptions.toQueryArguments()));
|
|
4255
|
+
}
|
|
4256
|
+
return new Collection(entities, { resource, annots, reset });
|
|
4257
|
+
}
|
|
4258
|
+
//#endregion
|
|
4231
4259
|
isSubtypeOf(other) {
|
|
4232
4260
|
var _a;
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
if (selfType !== undefined && otherType !== undefined) {
|
|
4237
|
-
const otherParser = (_a = other.schema()) === null || _a === void 0 ? void 0 : _a.parser;
|
|
4238
|
-
return (otherParser !== undefined &&
|
|
4239
|
-
otherParser.findChildParser((c) => c.isTypeOf(selfType)) !== undefined);
|
|
4240
|
-
}
|
|
4241
|
-
return false;
|
|
4261
|
+
return (this.schema !== undefined &&
|
|
4262
|
+
other.schema !== undefined &&
|
|
4263
|
+
((_a = this.schema) === null || _a === void 0 ? void 0 : _a.isSubtypeOf(other.schema)));
|
|
4242
4264
|
}
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4265
|
+
/*
|
|
4266
|
+
isParentOf(other: ODataResource<any>) {
|
|
4267
|
+
const [selfPath] = this.pathAndParams();
|
|
4268
|
+
const [otherPath] = other.pathAndParams();
|
|
4269
|
+
return otherPath !== selfPath && otherPath.startsWith(selfPath);
|
|
4247
4270
|
}
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4271
|
+
|
|
4272
|
+
isChildOf(other: ODataResource<any>) {
|
|
4273
|
+
const [selfPath] = this.pathAndParams();
|
|
4274
|
+
const [otherPath] = other.pathAndParams();
|
|
4275
|
+
return otherPath !== selfPath && selfPath.startsWith(otherPath);
|
|
4252
4276
|
}
|
|
4277
|
+
*/
|
|
4253
4278
|
isEqualTo(other, test) {
|
|
4254
4279
|
const [selfPath, selfParams] = this.pathAndParams();
|
|
4255
4280
|
const [otherPath, otherParams] = other.pathAndParams();
|
|
@@ -4280,11 +4305,37 @@ class ODataResource {
|
|
|
4280
4305
|
.join(PARAM_SEPARATOR);
|
|
4281
4306
|
return queryString ? `${path}${QUERY_SEPARATOR}${queryString}` : path;
|
|
4282
4307
|
}
|
|
4308
|
+
clone() {
|
|
4309
|
+
const Ctor = this.constructor;
|
|
4310
|
+
return new Ctor(this.api, {
|
|
4311
|
+
schema: this.schema,
|
|
4312
|
+
segments: this.cloneSegments(),
|
|
4313
|
+
query: this.cloneQuery(),
|
|
4314
|
+
});
|
|
4315
|
+
}
|
|
4283
4316
|
deserialize(value, options) {
|
|
4284
|
-
const
|
|
4317
|
+
const resourceType = this.returnType();
|
|
4318
|
+
const resourceSchema = this.schema;
|
|
4319
|
+
const _p = (value, options) => {
|
|
4320
|
+
const dataType = Types.isPlainObject(value)
|
|
4321
|
+
? options.helper.type(value)
|
|
4322
|
+
: undefined;
|
|
4323
|
+
if (dataType !== undefined) {
|
|
4324
|
+
// Parser from data type
|
|
4325
|
+
return this.api.parserForType(dataType);
|
|
4326
|
+
}
|
|
4327
|
+
else if (resourceSchema !== undefined && 'parser' in resourceSchema) {
|
|
4328
|
+
// Parser from resource schema
|
|
4329
|
+
return resourceSchema.parser;
|
|
4330
|
+
}
|
|
4331
|
+
else if (resourceType !== undefined) {
|
|
4332
|
+
// Parser from resource type
|
|
4333
|
+
return this.api.parserForType(resourceType);
|
|
4334
|
+
}
|
|
4335
|
+
return undefined;
|
|
4336
|
+
};
|
|
4285
4337
|
const _d = (value, options) => {
|
|
4286
|
-
const
|
|
4287
|
-
const parser = type !== undefined ? this.api.parserForType(type) : undefined;
|
|
4338
|
+
const parser = _p(value, options);
|
|
4288
4339
|
return parser !== undefined && 'deserialize' in parser
|
|
4289
4340
|
? parser.deserialize(value, options)
|
|
4290
4341
|
: value;
|
|
@@ -4294,10 +4345,28 @@ class ODataResource {
|
|
|
4294
4345
|
: _d(value, options || this.api.options);
|
|
4295
4346
|
}
|
|
4296
4347
|
serialize(value, options) {
|
|
4297
|
-
const
|
|
4348
|
+
const resourceType = this.type();
|
|
4349
|
+
const resourceSchema = this.schema;
|
|
4350
|
+
const _p = (value, options) => {
|
|
4351
|
+
const dataType = Types.isPlainObject(value)
|
|
4352
|
+
? options.helper.type(value)
|
|
4353
|
+
: undefined;
|
|
4354
|
+
if (dataType !== undefined) {
|
|
4355
|
+
// Parser from data type
|
|
4356
|
+
return this.api.parserForType(dataType);
|
|
4357
|
+
}
|
|
4358
|
+
else if (resourceSchema !== undefined && 'parser' in resourceSchema) {
|
|
4359
|
+
// Parser from resource schema
|
|
4360
|
+
return resourceSchema.parser;
|
|
4361
|
+
}
|
|
4362
|
+
else if (resourceType !== undefined) {
|
|
4363
|
+
// Parser from resource type
|
|
4364
|
+
return this.api.parserForType(resourceType);
|
|
4365
|
+
}
|
|
4366
|
+
return undefined;
|
|
4367
|
+
};
|
|
4298
4368
|
const _s = (value, options) => {
|
|
4299
|
-
const
|
|
4300
|
-
const parser = type !== undefined ? this.api.parserForType(type) : undefined;
|
|
4369
|
+
const parser = _p(value, options);
|
|
4301
4370
|
return parser !== undefined && 'serialize' in parser
|
|
4302
4371
|
? parser.serialize(value, options)
|
|
4303
4372
|
: value;
|
|
@@ -4307,10 +4376,28 @@ class ODataResource {
|
|
|
4307
4376
|
: _s(value, options || this.api.options);
|
|
4308
4377
|
}
|
|
4309
4378
|
encode(value, options) {
|
|
4310
|
-
const
|
|
4379
|
+
const resourceType = this.type();
|
|
4380
|
+
const resourceSchema = this.schema;
|
|
4381
|
+
const _p = (value, options) => {
|
|
4382
|
+
const dataType = Types.isPlainObject(value)
|
|
4383
|
+
? options.helper.type(value)
|
|
4384
|
+
: undefined;
|
|
4385
|
+
if (dataType !== undefined) {
|
|
4386
|
+
// Parser from data type
|
|
4387
|
+
return this.api.parserForType(dataType);
|
|
4388
|
+
}
|
|
4389
|
+
else if (resourceSchema !== undefined && 'parser' in resourceSchema) {
|
|
4390
|
+
// Parser from resource schema
|
|
4391
|
+
return resourceSchema.parser;
|
|
4392
|
+
}
|
|
4393
|
+
else if (resourceType !== undefined) {
|
|
4394
|
+
// Parser from resource type
|
|
4395
|
+
return this.api.parserForType(resourceType);
|
|
4396
|
+
}
|
|
4397
|
+
return undefined;
|
|
4398
|
+
};
|
|
4311
4399
|
const _e = (value, options) => {
|
|
4312
|
-
const
|
|
4313
|
-
const parser = type !== undefined ? this.api.parserForType(type) : undefined;
|
|
4400
|
+
const parser = _p(value, options);
|
|
4314
4401
|
return parser !== undefined && 'encode' in parser
|
|
4315
4402
|
? parser.encode(value, options)
|
|
4316
4403
|
: value;
|
|
@@ -4366,7 +4453,7 @@ class ODataResource {
|
|
|
4366
4453
|
return value;
|
|
4367
4454
|
}
|
|
4368
4455
|
resolveKey(value) {
|
|
4369
|
-
return ODataResource.resolveKey(value, this.schema
|
|
4456
|
+
return ODataResource.resolveKey(value, this.schema);
|
|
4370
4457
|
}
|
|
4371
4458
|
//#endregion
|
|
4372
4459
|
// Base Requests
|
|
@@ -4429,49 +4516,45 @@ class ODataResource {
|
|
|
4429
4516
|
|
|
4430
4517
|
class ODataActionResource extends ODataResource {
|
|
4431
4518
|
//#region Factory
|
|
4432
|
-
static factory(api, path,
|
|
4519
|
+
static factory(api, { path, schema, segments, query, }) {
|
|
4520
|
+
segments = segments || new ODataPathSegments();
|
|
4521
|
+
path = schema !== undefined ? schema.path() : path;
|
|
4522
|
+
if (path === undefined)
|
|
4523
|
+
throw new Error(`ODataActionResource: path is required`);
|
|
4433
4524
|
const segment = segments.add(PathSegmentNames.action, path);
|
|
4434
|
-
if (
|
|
4435
|
-
segment.type(type);
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
}
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
let path = annots === null || annots === void 0 ? void 0 : annots.entitySet;
|
|
4459
|
-
if (path !== undefined) {
|
|
4460
|
-
resource = this.api.entitySet(path).entity(entity);
|
|
4461
|
-
resource.query((q) => q.apply(this.queryOptions.toQueryArguments()));
|
|
4462
|
-
}
|
|
4463
|
-
return new Model(entity, { resource, annots, reset });
|
|
4464
|
-
}
|
|
4465
|
-
asCollection(entities, { annots, reset, } = {}) {
|
|
4466
|
-
let resource;
|
|
4467
|
-
const type = (annots === null || annots === void 0 ? void 0 : annots.type) || this.returnType();
|
|
4468
|
-
const Collection = this.api.collectionForType(type);
|
|
4469
|
-
let path = annots === null || annots === void 0 ? void 0 : annots.entitySet;
|
|
4470
|
-
if (path !== undefined) {
|
|
4471
|
-
resource = this.api.entitySet(path);
|
|
4472
|
-
resource.query((q) => q.apply(this.queryOptions.toQueryArguments()));
|
|
4525
|
+
if (schema !== undefined)
|
|
4526
|
+
segment.type(schema.type());
|
|
4527
|
+
return new ODataActionResource(api, {
|
|
4528
|
+
segments,
|
|
4529
|
+
query,
|
|
4530
|
+
schema,
|
|
4531
|
+
});
|
|
4532
|
+
}
|
|
4533
|
+
static fromResource(resource, path) {
|
|
4534
|
+
var _a;
|
|
4535
|
+
const baseType = resource.type();
|
|
4536
|
+
const actionSchema = resource.api.findCallableForType(path, baseType);
|
|
4537
|
+
const bindingType = (_a = actionSchema === null || actionSchema === void 0 ? void 0 : actionSchema.binding()) === null || _a === void 0 ? void 0 : _a.type;
|
|
4538
|
+
const action = ODataActionResource.factory(resource.api, {
|
|
4539
|
+
path,
|
|
4540
|
+
schema: actionSchema,
|
|
4541
|
+
segments: resource.cloneSegments(),
|
|
4542
|
+
});
|
|
4543
|
+
// Switch entitySet to binding type if available
|
|
4544
|
+
if (bindingType !== undefined && bindingType !== baseType) {
|
|
4545
|
+
let entitySet = resource.api.findEntitySetForType(bindingType);
|
|
4546
|
+
if (entitySet !== undefined) {
|
|
4547
|
+
action.segment((s) => s.entitySet().path(entitySet.name));
|
|
4548
|
+
}
|
|
4473
4549
|
}
|
|
4474
|
-
return
|
|
4550
|
+
return action;
|
|
4551
|
+
}
|
|
4552
|
+
//#endregion
|
|
4553
|
+
returnType() {
|
|
4554
|
+
var _a;
|
|
4555
|
+
return this.schema instanceof ODataCallable
|
|
4556
|
+
? (_a = this.schema.parser.return) === null || _a === void 0 ? void 0 : _a.type
|
|
4557
|
+
: undefined;
|
|
4475
4558
|
}
|
|
4476
4559
|
//#region Requests
|
|
4477
4560
|
post(params, options) {
|
|
@@ -5772,15 +5855,9 @@ class ODataBatchResource extends ODataResource {
|
|
|
5772
5855
|
static factory(api) {
|
|
5773
5856
|
let segments = new ODataPathSegments();
|
|
5774
5857
|
segments.add(PathSegmentNames.batch, $BATCH);
|
|
5775
|
-
return new ODataBatchResource(api, segments);
|
|
5776
|
-
}
|
|
5777
|
-
clone() {
|
|
5778
|
-
return new ODataBatchResource(this.api, this.cloneSegments());
|
|
5858
|
+
return new ODataBatchResource(api, { segments });
|
|
5779
5859
|
}
|
|
5780
5860
|
//#endregion
|
|
5781
|
-
schema() {
|
|
5782
|
-
return undefined;
|
|
5783
|
-
}
|
|
5784
5861
|
/**
|
|
5785
5862
|
* Execute the batch request
|
|
5786
5863
|
* @param ctx The context for the request
|
|
@@ -5949,18 +6026,12 @@ class ODataBatchResource extends ODataResource {
|
|
|
5949
6026
|
|
|
5950
6027
|
class ODataCountResource extends ODataResource {
|
|
5951
6028
|
//#region Factory
|
|
5952
|
-
static factory(api, segments, query) {
|
|
6029
|
+
static factory(api, { segments, query, }) {
|
|
5953
6030
|
segments.add(PathSegmentNames.count, $COUNT).type('Edm.Int32');
|
|
5954
|
-
query.keep(QueryOptionNames.filter, QueryOptionNames.search);
|
|
5955
|
-
return new ODataCountResource(api, segments, query);
|
|
5956
|
-
}
|
|
5957
|
-
clone() {
|
|
5958
|
-
return new ODataCountResource(this.api, this.cloneSegments(), this.cloneQuery());
|
|
6031
|
+
query === null || query === void 0 ? void 0 : query.keep(QueryOptionNames.filter, QueryOptionNames.search);
|
|
6032
|
+
return new ODataCountResource(api, { segments, query });
|
|
5959
6033
|
}
|
|
5960
6034
|
//#endregion
|
|
5961
|
-
schema() {
|
|
5962
|
-
return undefined;
|
|
5963
|
-
}
|
|
5964
6035
|
//#region Requests
|
|
5965
6036
|
get(options) {
|
|
5966
6037
|
return super.get(Object.assign({ responseType: 'value' }, options));
|
|
@@ -5979,61 +6050,56 @@ class ODataCountResource extends ODataResource {
|
|
|
5979
6050
|
|
|
5980
6051
|
class ODataFunctionResource extends ODataResource {
|
|
5981
6052
|
//#region Factory
|
|
5982
|
-
static factory(api, path,
|
|
6053
|
+
static factory(api, { path, schema, segments, query, }) {
|
|
6054
|
+
segments = segments || new ODataPathSegments();
|
|
6055
|
+
path = schema !== undefined ? schema.path() : path;
|
|
6056
|
+
if (path === undefined)
|
|
6057
|
+
throw new Error(`ODataActionResource: path is required`);
|
|
5983
6058
|
const segment = segments.add(PathSegmentNames.function, path);
|
|
5984
|
-
if (
|
|
5985
|
-
segment.type(type);
|
|
5986
|
-
|
|
5987
|
-
|
|
6059
|
+
if (schema !== undefined)
|
|
6060
|
+
segment.type(schema.type());
|
|
6061
|
+
return new ODataFunctionResource(api, {
|
|
6062
|
+
segments,
|
|
6063
|
+
query,
|
|
6064
|
+
schema,
|
|
6065
|
+
});
|
|
5988
6066
|
}
|
|
5989
|
-
|
|
5990
|
-
|
|
6067
|
+
static fromResource(resource, path) {
|
|
6068
|
+
var _a;
|
|
6069
|
+
const baseType = resource.type();
|
|
6070
|
+
const schema = resource.api.findCallableForType(path, baseType);
|
|
6071
|
+
const bindingType = (_a = schema === null || schema === void 0 ? void 0 : schema.binding()) === null || _a === void 0 ? void 0 : _a.type;
|
|
6072
|
+
const func = ODataFunctionResource.factory(resource.api, {
|
|
6073
|
+
path,
|
|
6074
|
+
schema,
|
|
6075
|
+
segments: resource.cloneSegments(),
|
|
6076
|
+
});
|
|
6077
|
+
// Switch entitySet to binding type if available
|
|
6078
|
+
if (bindingType !== undefined && bindingType !== baseType) {
|
|
6079
|
+
let entitySet = resource.api.findEntitySetForType(bindingType);
|
|
6080
|
+
if (entitySet !== undefined) {
|
|
6081
|
+
func.segment((s) => s.entitySet().path(entitySet.name));
|
|
6082
|
+
}
|
|
6083
|
+
}
|
|
6084
|
+
return func;
|
|
5991
6085
|
}
|
|
5992
6086
|
//#endregion
|
|
5993
6087
|
returnType() {
|
|
5994
|
-
var _a
|
|
5995
|
-
return
|
|
5996
|
-
|
|
5997
|
-
schema() {
|
|
5998
|
-
//TODO: Binding Type
|
|
5999
|
-
let type = this.type();
|
|
6000
|
-
return type !== undefined
|
|
6001
|
-
? this.api.findCallableForType(type)
|
|
6088
|
+
var _a;
|
|
6089
|
+
return this.schema instanceof ODataCallable
|
|
6090
|
+
? (_a = this.schema.parser.return) === null || _a === void 0 ? void 0 : _a.type
|
|
6002
6091
|
: undefined;
|
|
6003
6092
|
}
|
|
6004
|
-
|
|
6005
|
-
let resource;
|
|
6006
|
-
const type = (annots === null || annots === void 0 ? void 0 : annots.type) || this.returnType();
|
|
6007
|
-
const Model = this.api.modelForType(type);
|
|
6008
|
-
let path = annots === null || annots === void 0 ? void 0 : annots.entitySet;
|
|
6009
|
-
if (path !== undefined) {
|
|
6010
|
-
resource = this.api.entitySet(path).entity(entity);
|
|
6011
|
-
resource.query((q) => q.apply(this.queryOptions.toQueryArguments()));
|
|
6012
|
-
}
|
|
6013
|
-
return new Model(entity, { resource, annots, reset });
|
|
6014
|
-
}
|
|
6015
|
-
asCollection(entities, { annots, reset, } = {}) {
|
|
6016
|
-
let resource;
|
|
6017
|
-
const type = (annots === null || annots === void 0 ? void 0 : annots.type) || this.returnType();
|
|
6018
|
-
const Collection = this.api.collectionForType(type);
|
|
6019
|
-
let path = annots === null || annots === void 0 ? void 0 : annots.entitySet;
|
|
6020
|
-
if (path !== undefined) {
|
|
6021
|
-
resource = this.api.entitySet(path);
|
|
6022
|
-
resource.query((q) => q.apply(this.queryOptions.toQueryArguments()));
|
|
6023
|
-
}
|
|
6024
|
-
return new Collection(entities, { resource, annots, reset });
|
|
6025
|
-
}
|
|
6026
|
-
parameters(params, { alias: alias$1 } = {}) {
|
|
6027
|
-
const segments = this.cloneSegments();
|
|
6028
|
-
const segment = segments.get(PathSegmentNames.function);
|
|
6093
|
+
parameters(params, { alias } = {}) {
|
|
6029
6094
|
let parameters = params !== null ? this.encode(params) : null;
|
|
6030
|
-
if (alias
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6095
|
+
if (alias && parameters !== null) {
|
|
6096
|
+
this.query((q) => {
|
|
6097
|
+
parameters = Object.entries(parameters).reduce((acc, [name, param]) => {
|
|
6098
|
+
return Object.assign(acc, { [name]: q.alias(param, name) });
|
|
6099
|
+
}, {});
|
|
6100
|
+
});
|
|
6034
6101
|
}
|
|
6035
|
-
segment.parameters(parameters);
|
|
6036
|
-
return new ODataFunctionResource(this.api, segments, this.cloneQuery());
|
|
6102
|
+
return this.clone().segment((s) => s.function().parameters(parameters));
|
|
6037
6103
|
}
|
|
6038
6104
|
//#region Requests
|
|
6039
6105
|
get(options) {
|
|
@@ -6104,17 +6170,11 @@ class ODataFunctionResource extends ODataResource {
|
|
|
6104
6170
|
|
|
6105
6171
|
class ODataMediaResource extends ODataResource {
|
|
6106
6172
|
//#region Factory
|
|
6107
|
-
static factory(api, segments,
|
|
6173
|
+
static factory(api, { segments, query, }) {
|
|
6108
6174
|
segments.add(PathSegmentNames.value, $VALUE);
|
|
6109
|
-
return new ODataMediaResource(api, segments,
|
|
6110
|
-
}
|
|
6111
|
-
clone() {
|
|
6112
|
-
return new ODataMediaResource(this.api, this.cloneSegments(), this.cloneQuery());
|
|
6175
|
+
return new ODataMediaResource(api, { segments, query });
|
|
6113
6176
|
}
|
|
6114
6177
|
//#endregion
|
|
6115
|
-
schema() {
|
|
6116
|
-
return undefined;
|
|
6117
|
-
}
|
|
6118
6178
|
//#region Requests
|
|
6119
6179
|
get(options) {
|
|
6120
6180
|
return super.get(options);
|
|
@@ -6147,20 +6207,26 @@ class ODataMediaResource extends ODataResource {
|
|
|
6147
6207
|
|
|
6148
6208
|
class ODataValueResource extends ODataResource {
|
|
6149
6209
|
//#region Factory
|
|
6150
|
-
static factory(api, type, segments,
|
|
6210
|
+
static factory(api, { type, schema, segments, query, }) {
|
|
6211
|
+
const baseType = type;
|
|
6212
|
+
const bindingType = schema === null || schema === void 0 ? void 0 : schema.type();
|
|
6151
6213
|
const segment = segments.add(PathSegmentNames.value, $VALUE);
|
|
6152
|
-
if (
|
|
6214
|
+
if (schema !== undefined)
|
|
6215
|
+
segment.type(schema.type());
|
|
6216
|
+
else if (type !== undefined)
|
|
6153
6217
|
segment.type(type);
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6218
|
+
query === null || query === void 0 ? void 0 : query.clear();
|
|
6219
|
+
const value = new ODataValueResource(api, { segments, query, schema });
|
|
6220
|
+
// Switch entitySet to binding type if available
|
|
6221
|
+
if (bindingType !== undefined && bindingType !== baseType) {
|
|
6222
|
+
let entitySet = api.findEntitySetForType(bindingType);
|
|
6223
|
+
if (entitySet !== undefined) {
|
|
6224
|
+
value.segment((s) => s.entitySet().path(entitySet.name));
|
|
6225
|
+
}
|
|
6226
|
+
}
|
|
6227
|
+
return value;
|
|
6159
6228
|
}
|
|
6160
6229
|
//#endregion
|
|
6161
|
-
schema() {
|
|
6162
|
-
return undefined;
|
|
6163
|
-
}
|
|
6164
6230
|
//#region Requests
|
|
6165
6231
|
get(options) {
|
|
6166
6232
|
return super.get(Object.assign({ responseType: 'value' }, options));
|
|
@@ -6179,33 +6245,53 @@ class ODataValueResource extends ODataResource {
|
|
|
6179
6245
|
|
|
6180
6246
|
class ODataPropertyResource extends ODataResource {
|
|
6181
6247
|
//#region Factory
|
|
6182
|
-
static factory(api, path, type, segments,
|
|
6248
|
+
static factory(api, { path, type, schema, segments, query, }) {
|
|
6183
6249
|
const segment = segments.add(PathSegmentNames.property, path);
|
|
6184
|
-
if (
|
|
6250
|
+
if (schema !== undefined)
|
|
6251
|
+
segment.type(schema.type());
|
|
6252
|
+
else if (type !== undefined)
|
|
6185
6253
|
segment.type(type);
|
|
6186
|
-
|
|
6187
|
-
return new ODataPropertyResource(api,
|
|
6254
|
+
query === null || query === void 0 ? void 0 : query.clear();
|
|
6255
|
+
return new ODataPropertyResource(api, {
|
|
6256
|
+
segments,
|
|
6257
|
+
query,
|
|
6258
|
+
schema,
|
|
6259
|
+
});
|
|
6188
6260
|
}
|
|
6189
|
-
|
|
6190
|
-
|
|
6261
|
+
static fromResource(resource, path) {
|
|
6262
|
+
const baseType = resource.type();
|
|
6263
|
+
let baseSchema = resource.schema;
|
|
6264
|
+
let fieldType;
|
|
6265
|
+
let fieldSchema;
|
|
6266
|
+
if (baseSchema !== undefined) {
|
|
6267
|
+
const field = baseSchema.findFieldByName(path);
|
|
6268
|
+
fieldType = field === null || field === void 0 ? void 0 : field.type;
|
|
6269
|
+
fieldSchema =
|
|
6270
|
+
fieldType !== undefined
|
|
6271
|
+
? resource.api.findStructuredTypeForType(fieldType)
|
|
6272
|
+
: undefined;
|
|
6273
|
+
baseSchema =
|
|
6274
|
+
field !== undefined
|
|
6275
|
+
? baseSchema.findSchemaForField(field)
|
|
6276
|
+
: undefined;
|
|
6277
|
+
}
|
|
6278
|
+
const property = ODataPropertyResource.factory(resource.api, {
|
|
6279
|
+
path,
|
|
6280
|
+
type: fieldType,
|
|
6281
|
+
schema: fieldSchema,
|
|
6282
|
+
segments: resource.cloneSegments(),
|
|
6283
|
+
query: resource.cloneQuery(),
|
|
6284
|
+
});
|
|
6285
|
+
// Switch entitySet to binding type if available
|
|
6286
|
+
if (baseSchema !== undefined && baseSchema.type() !== baseType) {
|
|
6287
|
+
let entitySet = resource.api.findEntitySetForType(baseSchema.type());
|
|
6288
|
+
if (entitySet !== undefined) {
|
|
6289
|
+
property.segment((s) => s.entitySet().path(entitySet.name));
|
|
6290
|
+
}
|
|
6291
|
+
}
|
|
6292
|
+
return property;
|
|
6191
6293
|
}
|
|
6192
6294
|
//#endregion
|
|
6193
|
-
schema() {
|
|
6194
|
-
let type = this.type();
|
|
6195
|
-
return type !== undefined
|
|
6196
|
-
? this.api.findStructuredTypeForType(type)
|
|
6197
|
-
: undefined;
|
|
6198
|
-
}
|
|
6199
|
-
asModel(entity, { annots, reset } = {}) {
|
|
6200
|
-
const type = (annots === null || annots === void 0 ? void 0 : annots.type) || this.type();
|
|
6201
|
-
const Model = this.api.modelForType(type);
|
|
6202
|
-
return new Model(entity, { resource: this, annots, reset });
|
|
6203
|
-
}
|
|
6204
|
-
asCollection(entities, { annots, reset, } = {}) {
|
|
6205
|
-
const type = (annots === null || annots === void 0 ? void 0 : annots.type) || this.type();
|
|
6206
|
-
const Collection = this.api.collectionForType(type);
|
|
6207
|
-
return new Collection(entities, { resource: this, annots, reset });
|
|
6208
|
-
}
|
|
6209
6295
|
key(value) {
|
|
6210
6296
|
const property = this.clone();
|
|
6211
6297
|
var key = this.resolveKey(value);
|
|
@@ -6221,37 +6307,49 @@ class ODataPropertyResource extends ODataResource {
|
|
|
6221
6307
|
return property;
|
|
6222
6308
|
}
|
|
6223
6309
|
value() {
|
|
6224
|
-
return ODataValueResource.factory(this.api,
|
|
6310
|
+
return ODataValueResource.factory(this.api, {
|
|
6311
|
+
type: this.returnType(),
|
|
6312
|
+
schema: this.schema,
|
|
6313
|
+
segments: this.cloneSegments(),
|
|
6314
|
+
query: this.cloneQuery(),
|
|
6315
|
+
});
|
|
6225
6316
|
}
|
|
6226
6317
|
/*
|
|
6227
6318
|
navigationProperty<N>(path: string) {
|
|
6228
|
-
let
|
|
6229
|
-
if (
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
?
|
|
6319
|
+
let schema: ODataStructuredType<N> | undefined;
|
|
6320
|
+
if (this.schema instanceof ODataStructuredType) {
|
|
6321
|
+
const field = this.schema.findFieldByName<any>(path as keyof T);
|
|
6322
|
+
schema =
|
|
6323
|
+
field !== undefined
|
|
6324
|
+
? this.schema.findSchemaForField<N>(field)
|
|
6234
6325
|
: undefined;
|
|
6235
6326
|
}
|
|
6236
|
-
return ODataNavigationPropertyResource.factory<N>(
|
|
6237
|
-
this.api,
|
|
6327
|
+
return ODataNavigationPropertyResource.factory<N>(this.api, {
|
|
6238
6328
|
path,
|
|
6239
|
-
|
|
6240
|
-
this.cloneSegments(),
|
|
6241
|
-
this.cloneQuery<N>()
|
|
6242
|
-
);
|
|
6329
|
+
schema,
|
|
6330
|
+
segments: this.cloneSegments(),
|
|
6331
|
+
query: this.cloneQuery<N>(),
|
|
6332
|
+
});
|
|
6243
6333
|
}
|
|
6244
6334
|
*/
|
|
6245
6335
|
property(path) {
|
|
6246
|
-
let type
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6336
|
+
let type;
|
|
6337
|
+
let schema;
|
|
6338
|
+
if (this.schema instanceof ODataStructuredType) {
|
|
6339
|
+
const field = this.schema.findFieldByName(path);
|
|
6340
|
+
type = field === null || field === void 0 ? void 0 : field.type;
|
|
6341
|
+
schema =
|
|
6342
|
+
field !== undefined
|
|
6343
|
+
? this.schema.findSchemaForField(field)
|
|
6252
6344
|
: undefined;
|
|
6253
6345
|
}
|
|
6254
|
-
return ODataPropertyResource.factory(this.api,
|
|
6346
|
+
return ODataPropertyResource.factory(this.api, {
|
|
6347
|
+
path,
|
|
6348
|
+
type,
|
|
6349
|
+
schema,
|
|
6350
|
+
segments: this.cloneSegments(),
|
|
6351
|
+
query: this.cloneQuery(),
|
|
6352
|
+
});
|
|
6255
6353
|
}
|
|
6256
6354
|
//#region Requests
|
|
6257
6355
|
get(options) {
|
|
@@ -6323,18 +6421,12 @@ class ODataPropertyResource extends ODataResource {
|
|
|
6323
6421
|
|
|
6324
6422
|
class ODataReferenceResource extends ODataResource {
|
|
6325
6423
|
//#region Factory
|
|
6326
|
-
static factory(api, segments,
|
|
6424
|
+
static factory(api, { segments, query, }) {
|
|
6327
6425
|
segments.add(PathSegmentNames.reference, $REF);
|
|
6328
|
-
|
|
6329
|
-
return new ODataReferenceResource(api, segments,
|
|
6330
|
-
}
|
|
6331
|
-
clone() {
|
|
6332
|
-
return new ODataReferenceResource(this.api, this.cloneSegments(), this.cloneQuery());
|
|
6426
|
+
query === null || query === void 0 ? void 0 : query.clear();
|
|
6427
|
+
return new ODataReferenceResource(api, { segments, query });
|
|
6333
6428
|
}
|
|
6334
6429
|
//#endregion
|
|
6335
|
-
schema() {
|
|
6336
|
-
return undefined;
|
|
6337
|
-
}
|
|
6338
6430
|
//#region Requests
|
|
6339
6431
|
post(target, options) {
|
|
6340
6432
|
return super.post({ [ODATA_ID]: target.endpointUrl(false) }, options);
|
|
@@ -6342,7 +6434,6 @@ class ODataReferenceResource extends ODataResource {
|
|
|
6342
6434
|
put(target, options) {
|
|
6343
6435
|
return super.put({ [ODATA_ID]: target.endpointUrl(false) }, options);
|
|
6344
6436
|
}
|
|
6345
|
-
//TODO: https://github.com/OData/AspNetCoreOData/blob/08b00758dac691b28aa675f5aa3522fc1caa089e/sample/ODataRoutingSample/Controllers/v1/OrganizationsController.cs#L178
|
|
6346
6437
|
delete(_a = {}) {
|
|
6347
6438
|
var { etag, target } = _a, options = __rest(_a, ["etag", "target"]);
|
|
6348
6439
|
if (target) {
|
|
@@ -6389,6 +6480,25 @@ class ODataReferenceResource extends ODataResource {
|
|
|
6389
6480
|
unset(options) {
|
|
6390
6481
|
return this.delete(options);
|
|
6391
6482
|
}
|
|
6483
|
+
fetch(options = {}) {
|
|
6484
|
+
return this.get(options);
|
|
6485
|
+
}
|
|
6486
|
+
/**
|
|
6487
|
+
* Fetch the entity
|
|
6488
|
+
* @param options Options for the request
|
|
6489
|
+
* @returns The entity
|
|
6490
|
+
*/
|
|
6491
|
+
fetchEntity(options = {}) {
|
|
6492
|
+
return this.fetch(Object.assign({ responseType: 'entity' }, options)).pipe(map(({ entity }) => entity));
|
|
6493
|
+
}
|
|
6494
|
+
/**
|
|
6495
|
+
* Fetch entities
|
|
6496
|
+
* @param options Options for the request
|
|
6497
|
+
* @returns The entities
|
|
6498
|
+
*/
|
|
6499
|
+
fetchEntities(options = {}) {
|
|
6500
|
+
return this.fetch(Object.assign({ responseType: 'entities' }, options)).pipe(map(({ entities }) => entities));
|
|
6501
|
+
}
|
|
6392
6502
|
}
|
|
6393
6503
|
|
|
6394
6504
|
/**
|
|
@@ -6398,33 +6508,53 @@ class ODataReferenceResource extends ODataResource {
|
|
|
6398
6508
|
*/
|
|
6399
6509
|
class ODataNavigationPropertyResource extends ODataResource {
|
|
6400
6510
|
//#region Factory
|
|
6401
|
-
static factory(api, path, type, segments,
|
|
6511
|
+
static factory(api, { path, type, schema, segments, query, }) {
|
|
6402
6512
|
const segment = segments.add(PathSegmentNames.navigationProperty, path);
|
|
6403
|
-
if (
|
|
6513
|
+
if (schema !== undefined)
|
|
6514
|
+
segment.type(schema.type());
|
|
6515
|
+
else if (type !== undefined)
|
|
6404
6516
|
segment.type(type);
|
|
6405
|
-
|
|
6406
|
-
return new ODataNavigationPropertyResource(api,
|
|
6517
|
+
query === null || query === void 0 ? void 0 : query.keep(QueryOptionNames.format);
|
|
6518
|
+
return new ODataNavigationPropertyResource(api, {
|
|
6519
|
+
segments,
|
|
6520
|
+
query,
|
|
6521
|
+
schema,
|
|
6522
|
+
});
|
|
6407
6523
|
}
|
|
6408
|
-
|
|
6409
|
-
|
|
6524
|
+
static fromResource(resource, path) {
|
|
6525
|
+
const baseType = resource.type();
|
|
6526
|
+
let baseSchema = resource.schema;
|
|
6527
|
+
let fieldType;
|
|
6528
|
+
let fieldSchema;
|
|
6529
|
+
if (baseSchema !== undefined) {
|
|
6530
|
+
const field = baseSchema.findFieldByName(path);
|
|
6531
|
+
fieldType = field === null || field === void 0 ? void 0 : field.type;
|
|
6532
|
+
fieldSchema =
|
|
6533
|
+
fieldType !== undefined
|
|
6534
|
+
? resource.api.findStructuredTypeForType(fieldType)
|
|
6535
|
+
: undefined;
|
|
6536
|
+
baseSchema =
|
|
6537
|
+
field !== undefined
|
|
6538
|
+
? baseSchema.findSchemaForField(field)
|
|
6539
|
+
: undefined;
|
|
6540
|
+
}
|
|
6541
|
+
const navigation = ODataNavigationPropertyResource.factory(resource.api, {
|
|
6542
|
+
path,
|
|
6543
|
+
type: fieldType,
|
|
6544
|
+
schema: fieldSchema,
|
|
6545
|
+
segments: resource.cloneSegments(),
|
|
6546
|
+
query: resource.cloneQuery(),
|
|
6547
|
+
});
|
|
6548
|
+
// Switch entitySet to binding type if available
|
|
6549
|
+
if (baseSchema !== undefined && baseSchema.type() !== baseType) {
|
|
6550
|
+
let entitySet = resource.api.findEntitySetForType(baseSchema.type());
|
|
6551
|
+
if (entitySet !== undefined) {
|
|
6552
|
+
navigation.segment((s) => s.entitySet().path(entitySet.name));
|
|
6553
|
+
}
|
|
6554
|
+
}
|
|
6555
|
+
return navigation;
|
|
6410
6556
|
}
|
|
6411
6557
|
//#endregion
|
|
6412
|
-
schema() {
|
|
6413
|
-
let type = this.type();
|
|
6414
|
-
return type !== undefined
|
|
6415
|
-
? this.api.findStructuredTypeForType(type)
|
|
6416
|
-
: undefined;
|
|
6417
|
-
}
|
|
6418
|
-
asModel(entity, { annots, reset } = {}) {
|
|
6419
|
-
const type = (annots === null || annots === void 0 ? void 0 : annots.type) || this.type();
|
|
6420
|
-
const Model = this.api.modelForType(type);
|
|
6421
|
-
return new Model(entity, { resource: this, annots, reset });
|
|
6422
|
-
}
|
|
6423
|
-
asCollection(entities, { annots, reset, } = {}) {
|
|
6424
|
-
const type = (annots === null || annots === void 0 ? void 0 : annots.type) || this.type();
|
|
6425
|
-
const Collection = this.api.collectionForType(type);
|
|
6426
|
-
return new Collection(entities, { resource: this, annots, reset });
|
|
6427
|
-
}
|
|
6428
6558
|
key(value) {
|
|
6429
6559
|
const navigation = this.clone();
|
|
6430
6560
|
var key = this.resolveKey(value);
|
|
@@ -6440,40 +6570,42 @@ class ODataNavigationPropertyResource extends ODataResource {
|
|
|
6440
6570
|
return navigation;
|
|
6441
6571
|
}
|
|
6442
6572
|
media() {
|
|
6443
|
-
return ODataMediaResource.factory(this.api,
|
|
6573
|
+
return ODataMediaResource.factory(this.api, {
|
|
6574
|
+
segments: this.cloneSegments(),
|
|
6575
|
+
query: this.cloneQuery(),
|
|
6576
|
+
});
|
|
6444
6577
|
}
|
|
6445
6578
|
reference() {
|
|
6446
|
-
return ODataReferenceResource.factory(this.api,
|
|
6579
|
+
return ODataReferenceResource.factory(this.api, {
|
|
6580
|
+
segments: this.cloneSegments(),
|
|
6581
|
+
});
|
|
6447
6582
|
}
|
|
6448
6583
|
navigationProperty(path) {
|
|
6449
|
-
|
|
6450
|
-
if (type !== undefined) {
|
|
6451
|
-
let parser = this.api.parserForType(type);
|
|
6452
|
-
type =
|
|
6453
|
-
parser instanceof ODataStructuredTypeParser
|
|
6454
|
-
? parser.typeFor(path)
|
|
6455
|
-
: undefined;
|
|
6456
|
-
}
|
|
6457
|
-
return ODataNavigationPropertyResource.factory(this.api, path, type, this.cloneSegments(), this.cloneQuery());
|
|
6584
|
+
return ODataNavigationPropertyResource.fromResource(this, path);
|
|
6458
6585
|
}
|
|
6459
6586
|
property(path) {
|
|
6460
|
-
|
|
6461
|
-
if (type !== undefined) {
|
|
6462
|
-
let parser = this.api.parserForType(type);
|
|
6463
|
-
type =
|
|
6464
|
-
parser instanceof ODataStructuredTypeParser
|
|
6465
|
-
? parser.typeFor(path)
|
|
6466
|
-
: undefined;
|
|
6467
|
-
}
|
|
6468
|
-
return ODataPropertyResource.factory(this.api, path, type, this.cloneSegments(), this.cloneQuery());
|
|
6587
|
+
return ODataPropertyResource.fromResource(this, path);
|
|
6469
6588
|
}
|
|
6470
6589
|
count() {
|
|
6471
|
-
return ODataCountResource.factory(this.api,
|
|
6590
|
+
return ODataCountResource.factory(this.api, {
|
|
6591
|
+
segments: this.cloneSegments(),
|
|
6592
|
+
query: this.cloneQuery(),
|
|
6593
|
+
});
|
|
6472
6594
|
}
|
|
6473
6595
|
cast(type) {
|
|
6474
|
-
|
|
6596
|
+
const baseSchema = this.schema;
|
|
6597
|
+
const castSchema = this.api.findStructuredTypeForType(type);
|
|
6598
|
+
if (castSchema !== undefined &&
|
|
6599
|
+
baseSchema !== undefined &&
|
|
6600
|
+
!castSchema.isSubtypeOf(baseSchema))
|
|
6601
|
+
throw new Error(`Cannot cast to ${type}`);
|
|
6602
|
+
const segments = this.cloneSegments();
|
|
6475
6603
|
segments.add(PathSegmentNames.type, type).type(type);
|
|
6476
|
-
return new ODataNavigationPropertyResource(this.api,
|
|
6604
|
+
return new ODataNavigationPropertyResource(this.api, {
|
|
6605
|
+
segments,
|
|
6606
|
+
schema: castSchema,
|
|
6607
|
+
query: this.cloneQuery(),
|
|
6608
|
+
});
|
|
6477
6609
|
}
|
|
6478
6610
|
//#region Requests
|
|
6479
6611
|
post(attrs, options = {}) {
|
|
@@ -6589,25 +6721,11 @@ class ODataNavigationPropertyResource extends ODataResource {
|
|
|
6589
6721
|
|
|
6590
6722
|
class ODataEntityResource extends ODataResource {
|
|
6591
6723
|
//#region Factory
|
|
6592
|
-
static factory(api, segments,
|
|
6593
|
-
|
|
6594
|
-
return new ODataEntityResource(api, segments,
|
|
6595
|
-
}
|
|
6596
|
-
clone() {
|
|
6597
|
-
return new ODataEntityResource(this.api, this.cloneSegments(), this.cloneQuery());
|
|
6724
|
+
static factory(api, { schema, segments, query, }) {
|
|
6725
|
+
query === null || query === void 0 ? void 0 : query.keep(QueryOptionNames.expand, QueryOptionNames.select, QueryOptionNames.format);
|
|
6726
|
+
return new ODataEntityResource(api, { segments, query, schema });
|
|
6598
6727
|
}
|
|
6599
6728
|
//#endregion
|
|
6600
|
-
schema() {
|
|
6601
|
-
let type = this.type();
|
|
6602
|
-
return type !== undefined
|
|
6603
|
-
? this.api.findStructuredTypeForType(type)
|
|
6604
|
-
: undefined;
|
|
6605
|
-
}
|
|
6606
|
-
asModel(entity, { annots, reset } = {}) {
|
|
6607
|
-
const type = (annots === null || annots === void 0 ? void 0 : annots.type) || this.type();
|
|
6608
|
-
const Model = this.api.modelForType(type);
|
|
6609
|
-
return new Model(entity, { resource: this, annots, reset });
|
|
6610
|
-
}
|
|
6611
6729
|
key(value) {
|
|
6612
6730
|
const entity = this.clone();
|
|
6613
6731
|
var key = this.resolveKey(value);
|
|
@@ -6623,53 +6741,37 @@ class ODataEntityResource extends ODataResource {
|
|
|
6623
6741
|
return entity;
|
|
6624
6742
|
}
|
|
6625
6743
|
media() {
|
|
6626
|
-
return ODataMediaResource.factory(this.api,
|
|
6744
|
+
return ODataMediaResource.factory(this.api, {
|
|
6745
|
+
segments: this.cloneSegments(),
|
|
6746
|
+
query: this.cloneQuery(),
|
|
6747
|
+
});
|
|
6627
6748
|
}
|
|
6628
6749
|
navigationProperty(path) {
|
|
6629
|
-
|
|
6630
|
-
if (type !== undefined) {
|
|
6631
|
-
let parser = this.api.parserForType(type);
|
|
6632
|
-
type =
|
|
6633
|
-
parser instanceof ODataStructuredTypeParser
|
|
6634
|
-
? parser.typeFor(path)
|
|
6635
|
-
: undefined;
|
|
6636
|
-
}
|
|
6637
|
-
return ODataNavigationPropertyResource.factory(this.api, path, type, this.cloneSegments(), this.cloneQuery());
|
|
6750
|
+
return ODataNavigationPropertyResource.fromResource(this, path);
|
|
6638
6751
|
}
|
|
6639
6752
|
property(path) {
|
|
6640
|
-
|
|
6641
|
-
if (type !== undefined) {
|
|
6642
|
-
let parser = this.api.parserForType(type);
|
|
6643
|
-
type =
|
|
6644
|
-
parser instanceof ODataStructuredTypeParser
|
|
6645
|
-
? parser.typeFor(path)
|
|
6646
|
-
: undefined;
|
|
6647
|
-
}
|
|
6648
|
-
return ODataPropertyResource.factory(this.api, path, type, this.cloneSegments(), this.cloneQuery());
|
|
6753
|
+
return ODataPropertyResource.fromResource(this, path);
|
|
6649
6754
|
}
|
|
6650
6755
|
action(path) {
|
|
6651
|
-
|
|
6652
|
-
const callable = this.api.findCallableForType(path, this.type());
|
|
6653
|
-
if (callable !== undefined) {
|
|
6654
|
-
path = callable.path();
|
|
6655
|
-
type = callable.type();
|
|
6656
|
-
}
|
|
6657
|
-
return ODataActionResource.factory(this.api, path, type, this.cloneSegments(), this.cloneQuery());
|
|
6756
|
+
return ODataActionResource.fromResource(this, path);
|
|
6658
6757
|
}
|
|
6659
6758
|
function(path) {
|
|
6660
|
-
|
|
6661
|
-
const callable = this.api.findCallableForType(path, this.type());
|
|
6662
|
-
if (callable !== undefined) {
|
|
6663
|
-
path = callable.path();
|
|
6664
|
-
type = callable.type();
|
|
6665
|
-
}
|
|
6666
|
-
return ODataFunctionResource.factory(this.api, path, type, this.cloneSegments(), this.cloneQuery());
|
|
6759
|
+
return ODataFunctionResource.fromResource(this, path);
|
|
6667
6760
|
}
|
|
6668
|
-
//TODO: Check
|
|
6669
6761
|
cast(type) {
|
|
6670
|
-
|
|
6762
|
+
const baseSchema = this.schema;
|
|
6763
|
+
const castSchema = this.api.findStructuredTypeForType(type);
|
|
6764
|
+
if (castSchema !== undefined &&
|
|
6765
|
+
baseSchema !== undefined &&
|
|
6766
|
+
!castSchema.isSubtypeOf(baseSchema))
|
|
6767
|
+
throw new Error(`Cannot cast to ${type}`);
|
|
6768
|
+
const segments = this.cloneSegments();
|
|
6671
6769
|
segments.add(PathSegmentNames.type, type).type(type);
|
|
6672
|
-
return new ODataEntityResource(this.api,
|
|
6770
|
+
return new ODataEntityResource(this.api, {
|
|
6771
|
+
segments,
|
|
6772
|
+
schema: castSchema,
|
|
6773
|
+
query: this.cloneQuery(),
|
|
6774
|
+
});
|
|
6673
6775
|
}
|
|
6674
6776
|
//#region Requests
|
|
6675
6777
|
post(attrs, options = {}) {
|
|
@@ -6716,59 +6818,51 @@ class ODataEntityResource extends ODataResource {
|
|
|
6716
6818
|
|
|
6717
6819
|
class ODataEntitySetResource extends ODataResource {
|
|
6718
6820
|
//#region Factory
|
|
6719
|
-
static factory(api, path,
|
|
6821
|
+
static factory(api, { path, schema, query, }) {
|
|
6822
|
+
const segments = new ODataPathSegments();
|
|
6720
6823
|
const segment = segments.add(PathSegmentNames.entitySet, path);
|
|
6721
|
-
if (
|
|
6722
|
-
segment.type(type);
|
|
6723
|
-
return new ODataEntitySetResource(api, segments, query);
|
|
6724
|
-
}
|
|
6725
|
-
clone() {
|
|
6726
|
-
return new ODataEntitySetResource(this.api, this.cloneSegments(), this.cloneQuery());
|
|
6824
|
+
if (schema !== undefined)
|
|
6825
|
+
segment.type(schema.type());
|
|
6826
|
+
return new ODataEntitySetResource(api, { segments, query, schema });
|
|
6727
6827
|
}
|
|
6728
6828
|
//#endregion
|
|
6729
|
-
schema() {
|
|
6730
|
-
let type = this.type();
|
|
6731
|
-
return type !== undefined
|
|
6732
|
-
? this.api.findStructuredTypeForType(type)
|
|
6733
|
-
: undefined;
|
|
6734
|
-
}
|
|
6735
|
-
asCollection(entities, { annots, reset = false, } = {}) {
|
|
6736
|
-
const type = (annots === null || annots === void 0 ? void 0 : annots.type) || this.type();
|
|
6737
|
-
const Collection = this.api.collectionForType(type);
|
|
6738
|
-
return new Collection(entities, { resource: this, annots, reset });
|
|
6739
|
-
}
|
|
6740
6829
|
entity(key) {
|
|
6741
|
-
const entity = ODataEntityResource.factory(this.api,
|
|
6830
|
+
const entity = ODataEntityResource.factory(this.api, {
|
|
6831
|
+
schema: this.schema,
|
|
6832
|
+
segments: this.cloneSegments(),
|
|
6833
|
+
query: this.cloneQuery(),
|
|
6834
|
+
});
|
|
6742
6835
|
if (key !== undefined) {
|
|
6743
6836
|
return entity.key(key);
|
|
6744
6837
|
}
|
|
6745
6838
|
return entity;
|
|
6746
6839
|
}
|
|
6747
|
-
cast(type) {
|
|
6748
|
-
let segments = this.cloneSegments();
|
|
6749
|
-
segments.add(PathSegmentNames.type, type).type(type);
|
|
6750
|
-
return new ODataEntitySetResource(this.api, segments, this.cloneQuery());
|
|
6751
|
-
}
|
|
6752
6840
|
action(path) {
|
|
6753
|
-
|
|
6754
|
-
const callable = this.api.findCallableForType(path, this.type());
|
|
6755
|
-
if (callable !== undefined) {
|
|
6756
|
-
path = callable.path();
|
|
6757
|
-
type = callable.type();
|
|
6758
|
-
}
|
|
6759
|
-
return ODataActionResource.factory(this.api, path, type, this.cloneSegments(), this.cloneQuery());
|
|
6841
|
+
return ODataActionResource.fromResource(this, path);
|
|
6760
6842
|
}
|
|
6761
6843
|
function(path) {
|
|
6762
|
-
|
|
6763
|
-
const callable = this.api.findCallableForType(path, this.type());
|
|
6764
|
-
if (callable !== undefined) {
|
|
6765
|
-
path = callable.path();
|
|
6766
|
-
type = callable.type();
|
|
6767
|
-
}
|
|
6768
|
-
return ODataFunctionResource.factory(this.api, path, type, this.cloneSegments(), this.cloneQuery());
|
|
6844
|
+
return ODataFunctionResource.fromResource(this, path);
|
|
6769
6845
|
}
|
|
6770
6846
|
count() {
|
|
6771
|
-
return ODataCountResource.factory(this.api,
|
|
6847
|
+
return ODataCountResource.factory(this.api, {
|
|
6848
|
+
segments: this.cloneSegments(),
|
|
6849
|
+
query: this.cloneQuery(),
|
|
6850
|
+
});
|
|
6851
|
+
}
|
|
6852
|
+
cast(type) {
|
|
6853
|
+
const baseSchema = this.schema;
|
|
6854
|
+
const castSchema = this.api.findStructuredTypeForType(type);
|
|
6855
|
+
if (castSchema !== undefined &&
|
|
6856
|
+
baseSchema !== undefined &&
|
|
6857
|
+
!castSchema.isSubtypeOf(baseSchema))
|
|
6858
|
+
throw new Error(`Cannot cast to ${type}`);
|
|
6859
|
+
const segments = this.cloneSegments();
|
|
6860
|
+
segments.add(PathSegmentNames.type, type).type(type);
|
|
6861
|
+
return new ODataEntitySetResource(this.api, {
|
|
6862
|
+
segments,
|
|
6863
|
+
schema: castSchema,
|
|
6864
|
+
query: this.cloneQuery(),
|
|
6865
|
+
});
|
|
6772
6866
|
}
|
|
6773
6867
|
//#region Requests
|
|
6774
6868
|
post(attrs, options = {}) {
|
|
@@ -6809,7 +6903,7 @@ class ODataEntitySetResource extends ODataResource {
|
|
|
6809
6903
|
|
|
6810
6904
|
class ODataMetadataResource extends ODataResource {
|
|
6811
6905
|
constructor(api, segments) {
|
|
6812
|
-
super(api, segments);
|
|
6906
|
+
super(api, { segments });
|
|
6813
6907
|
}
|
|
6814
6908
|
//#region Factory
|
|
6815
6909
|
static factory(api) {
|
|
@@ -6817,13 +6911,7 @@ class ODataMetadataResource extends ODataResource {
|
|
|
6817
6911
|
segments.add(PathSegmentNames.metadata, $METADATA);
|
|
6818
6912
|
return new ODataMetadataResource(api, segments);
|
|
6819
6913
|
}
|
|
6820
|
-
clone() {
|
|
6821
|
-
return new ODataMetadataResource(this.api, this.cloneSegments());
|
|
6822
|
-
}
|
|
6823
6914
|
//#endregion
|
|
6824
|
-
schema() {
|
|
6825
|
-
return undefined;
|
|
6826
|
-
}
|
|
6827
6915
|
//#region Requests
|
|
6828
6916
|
get(options) {
|
|
6829
6917
|
return super
|
|
@@ -6839,27 +6927,14 @@ class ODataMetadataResource extends ODataResource {
|
|
|
6839
6927
|
|
|
6840
6928
|
class ODataSingletonResource extends ODataResource {
|
|
6841
6929
|
//#region Factory
|
|
6842
|
-
static factory(api, path,
|
|
6930
|
+
static factory(api, { path, schema, query, }) {
|
|
6931
|
+
const segments = new ODataPathSegments();
|
|
6843
6932
|
const segment = segments.add(PathSegmentNames.singleton, path);
|
|
6844
|
-
if (
|
|
6845
|
-
segment.type(type);
|
|
6846
|
-
|
|
6847
|
-
return new ODataSingletonResource(api, segments, options);
|
|
6848
|
-
}
|
|
6849
|
-
clone() {
|
|
6850
|
-
return new ODataSingletonResource(this.api, this.cloneSegments(), this.cloneQuery());
|
|
6933
|
+
if (schema !== undefined)
|
|
6934
|
+
segment.type(schema.type());
|
|
6935
|
+
return new ODataSingletonResource(api, { segments, query, schema });
|
|
6851
6936
|
}
|
|
6852
6937
|
//#endregion
|
|
6853
|
-
schema() {
|
|
6854
|
-
let type = this.type();
|
|
6855
|
-
return type !== undefined
|
|
6856
|
-
? this.api.findStructuredTypeForType(type)
|
|
6857
|
-
: undefined;
|
|
6858
|
-
}
|
|
6859
|
-
asModel(entity, { annots, reset } = {}) {
|
|
6860
|
-
const Model = this.api.modelForType((annots === null || annots === void 0 ? void 0 : annots.type) || this.type());
|
|
6861
|
-
return new Model(entity, { resource: this, annots, reset });
|
|
6862
|
-
}
|
|
6863
6938
|
key(value) {
|
|
6864
6939
|
const singleton = this.clone();
|
|
6865
6940
|
var key = this.resolveKey(value);
|
|
@@ -6875,44 +6950,16 @@ class ODataSingletonResource extends ODataResource {
|
|
|
6875
6950
|
return singleton;
|
|
6876
6951
|
}
|
|
6877
6952
|
navigationProperty(path) {
|
|
6878
|
-
|
|
6879
|
-
if (type !== undefined) {
|
|
6880
|
-
let parser = this.api.parserForType(type);
|
|
6881
|
-
type =
|
|
6882
|
-
parser instanceof ODataStructuredTypeParser
|
|
6883
|
-
? parser.typeFor(path)
|
|
6884
|
-
: undefined;
|
|
6885
|
-
}
|
|
6886
|
-
return ODataNavigationPropertyResource.factory(this.api, path, type, this.cloneSegments(), this.cloneQuery());
|
|
6953
|
+
return ODataNavigationPropertyResource.fromResource(this, path);
|
|
6887
6954
|
}
|
|
6888
6955
|
property(path) {
|
|
6889
|
-
|
|
6890
|
-
if (type !== undefined) {
|
|
6891
|
-
let parser = this.api.parserForType(type);
|
|
6892
|
-
type =
|
|
6893
|
-
parser instanceof ODataStructuredTypeParser
|
|
6894
|
-
? parser.typeFor(path)
|
|
6895
|
-
: undefined;
|
|
6896
|
-
}
|
|
6897
|
-
return ODataPropertyResource.factory(this.api, path, type, this.cloneSegments(), this.cloneQuery());
|
|
6956
|
+
return ODataPropertyResource.fromResource(this, path);
|
|
6898
6957
|
}
|
|
6899
6958
|
action(path) {
|
|
6900
|
-
|
|
6901
|
-
const callable = this.api.findCallableForType(path, this.type());
|
|
6902
|
-
if (callable !== undefined) {
|
|
6903
|
-
path = callable.path();
|
|
6904
|
-
type = callable.type();
|
|
6905
|
-
}
|
|
6906
|
-
return ODataActionResource.factory(this.api, path, type, this.cloneSegments(), this.cloneQuery());
|
|
6959
|
+
return ODataActionResource.fromResource(this, path);
|
|
6907
6960
|
}
|
|
6908
6961
|
function(path) {
|
|
6909
|
-
|
|
6910
|
-
const callable = this.api.findCallableForType(path, this.type());
|
|
6911
|
-
if (callable !== undefined) {
|
|
6912
|
-
path = callable.path();
|
|
6913
|
-
type = callable.type();
|
|
6914
|
-
}
|
|
6915
|
-
return ODataFunctionResource.factory(this.api, path, type, this.cloneSegments(), this.cloneQuery());
|
|
6962
|
+
return ODataFunctionResource.fromResource(this, path);
|
|
6916
6963
|
}
|
|
6917
6964
|
//#region Requests
|
|
6918
6965
|
post(attrs, options = {}) {
|
|
@@ -7030,7 +7077,6 @@ class ODataInStorageCache extends ODataCache {
|
|
|
7030
7077
|
}
|
|
7031
7078
|
}
|
|
7032
7079
|
|
|
7033
|
-
const CID = '_cid';
|
|
7034
7080
|
class ODataModelEvent {
|
|
7035
7081
|
constructor(name, { model, collection, previous, value, track, options, } = {}) {
|
|
7036
7082
|
this.bubbling = true;
|
|
@@ -7090,7 +7136,7 @@ var ODataModelState;
|
|
|
7090
7136
|
ODataModelState[ODataModelState["Changed"] = 2] = "Changed";
|
|
7091
7137
|
ODataModelState[ODataModelState["Unchanged"] = 3] = "Unchanged";
|
|
7092
7138
|
})(ODataModelState || (ODataModelState = {}));
|
|
7093
|
-
function Model({ cid =
|
|
7139
|
+
function Model({ cid = CID_FIELD_NAME } = {}) {
|
|
7094
7140
|
return (constructor) => {
|
|
7095
7141
|
const Klass = constructor;
|
|
7096
7142
|
if (!Klass.hasOwnProperty('options'))
|
|
@@ -7160,15 +7206,21 @@ class ODataModelField {
|
|
|
7160
7206
|
return this.parser.isStructuredType();
|
|
7161
7207
|
}
|
|
7162
7208
|
structured() {
|
|
7163
|
-
|
|
7164
|
-
|
|
7209
|
+
let structuredType = this.api.findStructuredTypeForType(this.parser.type);
|
|
7210
|
+
//Throw error if not found
|
|
7211
|
+
if (!structuredType)
|
|
7212
|
+
throw new Error(`Could not find structured type for ${this.parser.type}`);
|
|
7213
|
+
return structuredType;
|
|
7165
7214
|
}
|
|
7166
7215
|
isEnumType() {
|
|
7167
7216
|
return this.parser.isEnumType();
|
|
7168
7217
|
}
|
|
7169
7218
|
enum() {
|
|
7170
|
-
|
|
7171
|
-
|
|
7219
|
+
let enumType = this.api.findEnumTypeForType(this.parser.type);
|
|
7220
|
+
//Throw error if not found
|
|
7221
|
+
if (!enumType)
|
|
7222
|
+
throw new Error(`Could not find enum type for ${this.parser.type}`);
|
|
7223
|
+
return enumType;
|
|
7172
7224
|
}
|
|
7173
7225
|
validate(value, { method, navigation = false, } = {}) {
|
|
7174
7226
|
var _a;
|
|
@@ -7194,32 +7246,32 @@ class ODataModelField {
|
|
|
7194
7246
|
(value === null || (value === undefined && method !== 'modify')) && // Is null or undefined without patch?
|
|
7195
7247
|
!(computed && method === 'create') // Not (Is Computed field and create) ?
|
|
7196
7248
|
) {
|
|
7197
|
-
errors
|
|
7249
|
+
errors['push'](`required`);
|
|
7198
7250
|
}
|
|
7199
7251
|
if (this.maxLength !== undefined &&
|
|
7200
7252
|
typeof value === 'string' &&
|
|
7201
7253
|
value.length > this.maxLength) {
|
|
7202
|
-
errors
|
|
7254
|
+
errors['push'](`maxlength`);
|
|
7203
7255
|
}
|
|
7204
7256
|
if (this.minLength !== undefined &&
|
|
7205
7257
|
typeof value === 'string' &&
|
|
7206
7258
|
value.length < this.minLength) {
|
|
7207
|
-
errors
|
|
7259
|
+
errors['push'](`minlength`);
|
|
7208
7260
|
}
|
|
7209
7261
|
if (this.min !== undefined &&
|
|
7210
7262
|
typeof value === 'number' &&
|
|
7211
7263
|
value < this.min) {
|
|
7212
|
-
errors
|
|
7264
|
+
errors['push'](`min`);
|
|
7213
7265
|
}
|
|
7214
7266
|
if (this.max !== undefined &&
|
|
7215
7267
|
typeof value === 'number' &&
|
|
7216
7268
|
value > this.max) {
|
|
7217
|
-
errors
|
|
7269
|
+
errors['push'](`max`);
|
|
7218
7270
|
}
|
|
7219
7271
|
if (this.pattern !== undefined &&
|
|
7220
7272
|
typeof value === 'string' &&
|
|
7221
7273
|
!this.pattern.test(value)) {
|
|
7222
|
-
errors
|
|
7274
|
+
errors['push'](`pattern`);
|
|
7223
7275
|
}
|
|
7224
7276
|
return !Types.isEmpty(errors) ? errors : undefined;
|
|
7225
7277
|
}
|
|
@@ -7265,10 +7317,9 @@ class ODataModelField {
|
|
|
7265
7317
|
return this.api.findStructuredTypeForType(this.parser.type);
|
|
7266
7318
|
}
|
|
7267
7319
|
modelCollectionFactory({ parent, value, reset, }) {
|
|
7268
|
-
const schema = this.schemaFactory(parent.schema());
|
|
7269
7320
|
const annots = this.annotationsFactory(parent.annots());
|
|
7270
|
-
const Model =
|
|
7271
|
-
const Collection =
|
|
7321
|
+
const Model = this.api.modelForType(this.parser.type);
|
|
7322
|
+
const Collection = this.api.collectionForType(this.parser.type);
|
|
7272
7323
|
if (Model === undefined || Collection === undefined)
|
|
7273
7324
|
throw Error(`No model for ${this.name}`);
|
|
7274
7325
|
return this.parser.collection
|
|
@@ -7285,22 +7336,18 @@ class ODataModelField {
|
|
|
7285
7336
|
}
|
|
7286
7337
|
}
|
|
7287
7338
|
class ODataModelOptions {
|
|
7288
|
-
constructor(options, schema) {
|
|
7339
|
+
constructor({ options, schema, }) {
|
|
7289
7340
|
this.children = [];
|
|
7290
7341
|
this.name = schema.name;
|
|
7291
7342
|
this.base = schema.base;
|
|
7292
7343
|
this.open = schema.open;
|
|
7293
7344
|
this.schema = schema;
|
|
7294
|
-
this.cid = options.cid ||
|
|
7295
|
-
const schemaFields = this.schema.fields({
|
|
7296
|
-
include_navigation: true,
|
|
7297
|
-
include_parents: true,
|
|
7298
|
-
});
|
|
7345
|
+
this.cid = (options === null || options === void 0 ? void 0 : options.cid) || CID_FIELD_NAME;
|
|
7299
7346
|
this._fields = Object.entries(options.fields).map(([name, options]) => {
|
|
7300
7347
|
const { field } = options, opts = __rest(options, ["field"]);
|
|
7301
7348
|
if (field === undefined || name === undefined)
|
|
7302
7349
|
throw new Error('Model Properties need name and field');
|
|
7303
|
-
const parser =
|
|
7350
|
+
const parser = this.schema.findFieldByName(field);
|
|
7304
7351
|
if (parser === undefined)
|
|
7305
7352
|
throw new Error(`No parser for ${field} with name = ${name}`);
|
|
7306
7353
|
return new ODataModelField(this, Object.assign({ name, field, parser }, opts));
|
|
@@ -7356,19 +7403,22 @@ class ODataModelOptions {
|
|
|
7356
7403
|
];
|
|
7357
7404
|
}
|
|
7358
7405
|
field(name) {
|
|
7359
|
-
|
|
7360
|
-
return this.fields({
|
|
7406
|
+
let field = this.fields({
|
|
7361
7407
|
include_parents: true,
|
|
7362
7408
|
include_navigation: true,
|
|
7363
7409
|
}).find((modelField) => modelField.name === name || modelField.field === name);
|
|
7410
|
+
//Throw error if not found
|
|
7411
|
+
if (field === undefined)
|
|
7412
|
+
throw new Error(`No field with name ${name}`);
|
|
7413
|
+
return field;
|
|
7364
7414
|
}
|
|
7365
7415
|
attach(self, resource) {
|
|
7366
|
-
if (self._resource !==
|
|
7416
|
+
if (self._resource !== null &&
|
|
7367
7417
|
resource.type() !== self._resource.type() &&
|
|
7368
7418
|
!resource.isSubtypeOf(self._resource))
|
|
7369
7419
|
throw new Error(`Can't reattach ${resource.type()} to ${self._resource.type()}`);
|
|
7370
7420
|
const current = self._resource;
|
|
7371
|
-
if (current ===
|
|
7421
|
+
if (current === null || !current.isEqualTo(resource)) {
|
|
7372
7422
|
self._resource = resource;
|
|
7373
7423
|
self.events$.emit(new ODataModelEvent('attach', {
|
|
7374
7424
|
model: self,
|
|
@@ -7424,24 +7474,25 @@ class ODataModelOptions {
|
|
|
7424
7474
|
throw new Error(`resource: Can't build resource for ${child}`);
|
|
7425
7475
|
return resource;
|
|
7426
7476
|
}
|
|
7427
|
-
collectionResourceFactory(
|
|
7428
|
-
if (this.entitySet
|
|
7429
|
-
return
|
|
7430
|
-
|
|
7431
|
-
|
|
7432
|
-
|
|
7477
|
+
collectionResourceFactory(query) {
|
|
7478
|
+
if (this.entitySet === undefined)
|
|
7479
|
+
return undefined;
|
|
7480
|
+
return ODataEntitySetResource.factory(this.api, {
|
|
7481
|
+
path: this.entitySet.name,
|
|
7482
|
+
schema: this.schema,
|
|
7483
|
+
query,
|
|
7484
|
+
});
|
|
7433
7485
|
}
|
|
7434
|
-
modelResourceFactory(
|
|
7435
|
-
const resource = this.collectionResourceFactory(
|
|
7486
|
+
modelResourceFactory(query) {
|
|
7487
|
+
const resource = this.collectionResourceFactory(query);
|
|
7436
7488
|
if (resource instanceof ODataEntitySetResource)
|
|
7437
7489
|
return resource.entity();
|
|
7438
7490
|
return resource;
|
|
7439
7491
|
}
|
|
7440
7492
|
entityResource(self) {
|
|
7441
|
-
let resource = this.modelResourceFactory(
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
});
|
|
7493
|
+
let resource = this.modelResourceFactory(self._resource !== null ? self._resource.cloneQuery() : undefined);
|
|
7494
|
+
if (resource === undefined)
|
|
7495
|
+
throw new Error(`entityResource: Can't build resource for ${self}`);
|
|
7445
7496
|
const key = self.key({ field_mapping: true });
|
|
7446
7497
|
if (key !== undefined)
|
|
7447
7498
|
return resource.key(key);
|
|
@@ -7453,8 +7504,9 @@ class ODataModelOptions {
|
|
|
7453
7504
|
if (parent !== undefined) {
|
|
7454
7505
|
self._parent = parent;
|
|
7455
7506
|
}
|
|
7456
|
-
|
|
7457
|
-
|
|
7507
|
+
// Resource
|
|
7508
|
+
resource = resource || this.modelResourceFactory();
|
|
7509
|
+
if (resource !== undefined) {
|
|
7458
7510
|
this.attach(self, resource);
|
|
7459
7511
|
}
|
|
7460
7512
|
// Annotations
|
|
@@ -7765,7 +7817,7 @@ class ODataModelOptions {
|
|
|
7765
7817
|
changes.push(key);
|
|
7766
7818
|
}
|
|
7767
7819
|
});
|
|
7768
|
-
if (!self._silent && changes.length > 0) {
|
|
7820
|
+
if ((!self._silent && changes.length > 0) || self._reset) {
|
|
7769
7821
|
self.events$.emit(new ODataModelEvent(self._reset ? 'reset' : 'update', {
|
|
7770
7822
|
model: self,
|
|
7771
7823
|
options: { changes },
|
|
@@ -7967,6 +8019,7 @@ class ODataModelOptions {
|
|
|
7967
8019
|
class ODataCollection {
|
|
7968
8020
|
constructor(entities = [], { parent, resource, annots, model, reset = false, } = {}) {
|
|
7969
8021
|
this._parent = null;
|
|
8022
|
+
this._resource = null;
|
|
7970
8023
|
this._entries = [];
|
|
7971
8024
|
//Events
|
|
7972
8025
|
this.events$ = new EventEmitter();
|
|
@@ -7981,11 +8034,9 @@ class ODataCollection {
|
|
|
7981
8034
|
if (parent !== undefined) {
|
|
7982
8035
|
this._parent = parent;
|
|
7983
8036
|
}
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
if (resource === undefined)
|
|
7988
|
-
throw new Error(`Can't create collection without resource`);
|
|
8037
|
+
// Resource
|
|
8038
|
+
resource = (resource || this._model.meta.collectionResourceFactory());
|
|
8039
|
+
if (resource !== undefined) {
|
|
7989
8040
|
this.attach(resource);
|
|
7990
8041
|
}
|
|
7991
8042
|
// Annotations
|
|
@@ -8011,18 +8062,16 @@ class ODataCollection {
|
|
|
8011
8062
|
return ODataModelOptions.resource(this);
|
|
8012
8063
|
}
|
|
8013
8064
|
attach(resource) {
|
|
8014
|
-
if (this._resource !==
|
|
8065
|
+
if (this._resource !== null &&
|
|
8015
8066
|
this._resource.type() !== resource.type() &&
|
|
8016
8067
|
!resource.isSubtypeOf(this._resource))
|
|
8017
8068
|
throw new Error(`Can't reattach ${resource.type()} to ${this._resource.type()}`);
|
|
8018
8069
|
this._entries.forEach(({ model }) => {
|
|
8019
|
-
const mr = this._model.meta.modelResourceFactory(
|
|
8020
|
-
baseResource: resource,
|
|
8021
|
-
});
|
|
8070
|
+
const mr = this._model.meta.modelResourceFactory(resource.cloneQuery());
|
|
8022
8071
|
model.attach(mr);
|
|
8023
8072
|
});
|
|
8024
8073
|
const current = this._resource;
|
|
8025
|
-
if (current ===
|
|
8074
|
+
if (current === null || !current.isEqualTo(resource)) {
|
|
8026
8075
|
this._resource = resource;
|
|
8027
8076
|
this.events$.emit(new ODataModelEvent('attach', {
|
|
8028
8077
|
collection: this,
|
|
@@ -8288,11 +8337,17 @@ class ODataCollection {
|
|
|
8288
8337
|
}
|
|
8289
8338
|
}
|
|
8290
8339
|
removeReference(model, options) {
|
|
8291
|
-
|
|
8340
|
+
let resource = this.resource();
|
|
8292
8341
|
if (!model.isNew() && resource instanceof ODataNavigationPropertyResource) {
|
|
8342
|
+
let target = this._model.meta.api.options.deleteRefBy === 'id'
|
|
8343
|
+
? model._meta.entityResource(model)
|
|
8344
|
+
: undefined;
|
|
8345
|
+
if (this._model.meta.api.options.deleteRefBy === 'path') {
|
|
8346
|
+
resource = resource.key(model.key());
|
|
8347
|
+
}
|
|
8293
8348
|
return resource
|
|
8294
8349
|
.reference()
|
|
8295
|
-
.remove(
|
|
8350
|
+
.remove(target, options)
|
|
8296
8351
|
.pipe(map(() => model));
|
|
8297
8352
|
}
|
|
8298
8353
|
return of(model);
|
|
@@ -8472,22 +8527,22 @@ class ODataCollection {
|
|
|
8472
8527
|
this._removeModel(m[0], { silent: true, reset });
|
|
8473
8528
|
this._addModel(m[0], { silent: true, reset, position: m[1], reparent });
|
|
8474
8529
|
});
|
|
8475
|
-
if (
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8530
|
+
if ((!silent &&
|
|
8531
|
+
(toAdd.length > 0 ||
|
|
8532
|
+
toRemove.length > 0 ||
|
|
8533
|
+
toMerge.length > 0 ||
|
|
8534
|
+
toSort.length > 0)) ||
|
|
8535
|
+
reset) {
|
|
8479
8536
|
this._sortBy = null;
|
|
8480
|
-
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
}));
|
|
8490
|
-
}
|
|
8537
|
+
this.events$.emit(new ODataModelEvent(reset ? 'reset' : 'update', {
|
|
8538
|
+
collection: this,
|
|
8539
|
+
options: {
|
|
8540
|
+
added: toAdd,
|
|
8541
|
+
removed: toRemove,
|
|
8542
|
+
merged: toMerge,
|
|
8543
|
+
sorted: toSort,
|
|
8544
|
+
},
|
|
8545
|
+
}));
|
|
8491
8546
|
}
|
|
8492
8547
|
}
|
|
8493
8548
|
query(func) {
|
|
@@ -8697,6 +8752,7 @@ class ODataModel {
|
|
|
8697
8752
|
this._attributes = {};
|
|
8698
8753
|
this._changes = {};
|
|
8699
8754
|
this._relations = {};
|
|
8755
|
+
this._resource = null;
|
|
8700
8756
|
this._reset = false;
|
|
8701
8757
|
this._reparent = false;
|
|
8702
8758
|
this._silent = false;
|
|
@@ -8715,8 +8771,27 @@ class ODataModel {
|
|
|
8715
8771
|
let defaults = this.defaults();
|
|
8716
8772
|
this.assign(Objects.merge(defaults, attrs), { reset });
|
|
8717
8773
|
}
|
|
8718
|
-
static buildMeta(options, schema) {
|
|
8719
|
-
|
|
8774
|
+
static buildMeta({ options, schema, }) {
|
|
8775
|
+
if (options === undefined) {
|
|
8776
|
+
let fields = schema
|
|
8777
|
+
.fields({ include_navigation: true, include_parents: true })
|
|
8778
|
+
.reduce((acc, f) => {
|
|
8779
|
+
let name = f.name;
|
|
8780
|
+
// Prevent collision with reserved keywords
|
|
8781
|
+
while (RESERVED_FIELD_NAMES.includes(name)) {
|
|
8782
|
+
name = name + '_';
|
|
8783
|
+
}
|
|
8784
|
+
return Object.assign(acc, {
|
|
8785
|
+
[name]: {
|
|
8786
|
+
field: f.name,
|
|
8787
|
+
default: f.default,
|
|
8788
|
+
required: !f.nullable,
|
|
8789
|
+
},
|
|
8790
|
+
});
|
|
8791
|
+
}, {});
|
|
8792
|
+
options = { fields };
|
|
8793
|
+
}
|
|
8794
|
+
this.meta = new ODataModelOptions({ options, schema });
|
|
8720
8795
|
}
|
|
8721
8796
|
//#region Resources
|
|
8722
8797
|
resource() {
|
|
@@ -9118,6 +9193,7 @@ class ODataModel {
|
|
|
9118
9193
|
return (_a = this.collection()) === null || _a === void 0 ? void 0 : _a.prev(this);
|
|
9119
9194
|
}
|
|
9120
9195
|
}
|
|
9196
|
+
const RESERVED_FIELD_NAMES = Object.getOwnPropertyNames(ODataModel.prototype);
|
|
9121
9197
|
|
|
9122
9198
|
/**
|
|
9123
9199
|
* Api abstraction for consuming OData services.
|
|
@@ -9169,19 +9245,19 @@ class ODataApi {
|
|
|
9169
9245
|
switch ((_a = segments.last()) === null || _a === void 0 ? void 0 : _a.name) {
|
|
9170
9246
|
case PathSegmentNames.entitySet:
|
|
9171
9247
|
if ((_b = segments.last()) === null || _b === void 0 ? void 0 : _b.hasKey()) {
|
|
9172
|
-
return new ODataEntityResource(this, segments, query);
|
|
9248
|
+
return new ODataEntityResource(this, { segments, query });
|
|
9173
9249
|
}
|
|
9174
9250
|
else {
|
|
9175
|
-
return new ODataEntitySetResource(this, segments, query);
|
|
9251
|
+
return new ODataEntitySetResource(this, { segments, query });
|
|
9176
9252
|
}
|
|
9177
9253
|
case PathSegmentNames.navigationProperty:
|
|
9178
|
-
return new ODataNavigationPropertyResource(this, segments, query);
|
|
9254
|
+
return new ODataNavigationPropertyResource(this, { segments, query });
|
|
9179
9255
|
case PathSegmentNames.singleton:
|
|
9180
|
-
return new ODataSingletonResource(this, segments, query);
|
|
9256
|
+
return new ODataSingletonResource(this, { segments, query });
|
|
9181
9257
|
case PathSegmentNames.action:
|
|
9182
|
-
return new ODataActionResource(this, segments, query);
|
|
9258
|
+
return new ODataActionResource(this, { segments, query });
|
|
9183
9259
|
case PathSegmentNames.function:
|
|
9184
|
-
return new ODataFunctionResource(this, segments, query);
|
|
9260
|
+
return new ODataFunctionResource(this, { segments, query });
|
|
9185
9261
|
}
|
|
9186
9262
|
throw new Error('No Resource for json');
|
|
9187
9263
|
}
|
|
@@ -9201,51 +9277,45 @@ class ODataApi {
|
|
|
9201
9277
|
}
|
|
9202
9278
|
/**
|
|
9203
9279
|
* Build a singleton resource.
|
|
9204
|
-
* @param
|
|
9280
|
+
* @param path Name of the singleton
|
|
9205
9281
|
* @returns
|
|
9206
9282
|
*/
|
|
9207
|
-
singleton(
|
|
9208
|
-
|
|
9209
|
-
const
|
|
9210
|
-
|
|
9283
|
+
singleton(path) {
|
|
9284
|
+
const entitySet = this.findEntitySetByName(path);
|
|
9285
|
+
const schema = entitySet !== undefined
|
|
9286
|
+
? this.findStructuredTypeForType(entitySet.entityType)
|
|
9287
|
+
: undefined;
|
|
9288
|
+
return ODataSingletonResource.factory(this, { path, schema });
|
|
9211
9289
|
}
|
|
9212
9290
|
/**
|
|
9213
9291
|
* Build an entity set resource.
|
|
9214
|
-
* @param
|
|
9292
|
+
* @param path Name of the entity set
|
|
9215
9293
|
* @returns
|
|
9216
9294
|
*/
|
|
9217
|
-
entitySet(
|
|
9218
|
-
|
|
9219
|
-
const
|
|
9220
|
-
|
|
9295
|
+
entitySet(path) {
|
|
9296
|
+
const entitySet = this.findEntitySetByName(path);
|
|
9297
|
+
const schema = entitySet !== undefined
|
|
9298
|
+
? this.findStructuredTypeForType(entitySet.entityType)
|
|
9299
|
+
: undefined;
|
|
9300
|
+
return ODataEntitySetResource.factory(this, { path, schema });
|
|
9221
9301
|
}
|
|
9222
9302
|
/**
|
|
9223
9303
|
* Unbound Action
|
|
9224
|
-
* @param {string}
|
|
9304
|
+
* @param {string} path?
|
|
9225
9305
|
* @returns ODataActionResource
|
|
9226
9306
|
*/
|
|
9227
|
-
action(
|
|
9228
|
-
|
|
9229
|
-
|
|
9230
|
-
if (callable !== undefined) {
|
|
9231
|
-
name = callable.path();
|
|
9232
|
-
type = callable.type();
|
|
9233
|
-
}
|
|
9234
|
-
return ODataActionResource.factory(this, name, type, new ODataPathSegments(), new ODataQueryOptions());
|
|
9307
|
+
action(path) {
|
|
9308
|
+
const schema = this.findCallableForType(path);
|
|
9309
|
+
return ODataActionResource.factory(this, { path, schema });
|
|
9235
9310
|
}
|
|
9236
9311
|
/**
|
|
9237
9312
|
* Unbound Function
|
|
9238
|
-
* @param {string}
|
|
9313
|
+
* @param {string} path?
|
|
9239
9314
|
* @returns ODataFunctionResource
|
|
9240
9315
|
*/
|
|
9241
|
-
function(
|
|
9242
|
-
|
|
9243
|
-
|
|
9244
|
-
if (callable !== undefined) {
|
|
9245
|
-
name = callable.path();
|
|
9246
|
-
type = callable.type();
|
|
9247
|
-
}
|
|
9248
|
-
return ODataFunctionResource.factory(this, name, type, new ODataPathSegments(), new ODataQueryOptions());
|
|
9316
|
+
function(path) {
|
|
9317
|
+
const schema = this.findCallableForType(path);
|
|
9318
|
+
return ODataFunctionResource.factory(this, { path, schema });
|
|
9249
9319
|
}
|
|
9250
9320
|
request(req) {
|
|
9251
9321
|
let res$ = this.requester !== undefined ? this.requester(req) : NEVER;
|
|
@@ -9301,14 +9371,43 @@ class ODataApi {
|
|
|
9301
9371
|
return (_a = this.findStructuredTypeForType(type)) === null || _a === void 0 ? void 0 : _a.model;
|
|
9302
9372
|
}
|
|
9303
9373
|
modelForType(type) {
|
|
9304
|
-
|
|
9374
|
+
let Model = this.findModelForType(type);
|
|
9375
|
+
if (Model === undefined) {
|
|
9376
|
+
// Build Ad-hoc model
|
|
9377
|
+
let schema = this.findStructuredTypeForType(type);
|
|
9378
|
+
if (schema === undefined)
|
|
9379
|
+
throw Error(`No schema for ${type}`);
|
|
9380
|
+
Model = class extends ODataModel {
|
|
9381
|
+
};
|
|
9382
|
+
// Build Meta
|
|
9383
|
+
Model.buildMeta({ schema });
|
|
9384
|
+
// Configure
|
|
9385
|
+
Model.meta.configure({
|
|
9386
|
+
findOptionsForType: (type) => this.findOptionsForType(type),
|
|
9387
|
+
options: this.options,
|
|
9388
|
+
});
|
|
9389
|
+
// Store New Model for next time
|
|
9390
|
+
schema.model = Model;
|
|
9391
|
+
}
|
|
9392
|
+
return Model;
|
|
9305
9393
|
}
|
|
9306
9394
|
findCollectionForType(type) {
|
|
9307
9395
|
var _a;
|
|
9308
9396
|
return (_a = this.findStructuredTypeForType(type)) === null || _a === void 0 ? void 0 : _a.collection;
|
|
9309
9397
|
}
|
|
9310
9398
|
collectionForType(type) {
|
|
9311
|
-
|
|
9399
|
+
let Collection = this.findCollectionForType(type);
|
|
9400
|
+
if (Collection === undefined) {
|
|
9401
|
+
let schema = this.findStructuredTypeForType(type);
|
|
9402
|
+
if (schema === undefined)
|
|
9403
|
+
throw Error('');
|
|
9404
|
+
Collection = class extends ODataCollection {
|
|
9405
|
+
};
|
|
9406
|
+
Collection.model = this.modelForType(type);
|
|
9407
|
+
// Store New Collection for next time
|
|
9408
|
+
schema.collection = Collection;
|
|
9409
|
+
}
|
|
9410
|
+
return Collection;
|
|
9312
9411
|
}
|
|
9313
9412
|
findServiceForType(type) {
|
|
9314
9413
|
var _a;
|
|
@@ -9863,9 +9962,9 @@ class ODataClient {
|
|
|
9863
9962
|
return this.request('PUT', resource, addBody(options, body));
|
|
9864
9963
|
}
|
|
9865
9964
|
}
|
|
9866
|
-
ODataClient.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
9867
|
-
ODataClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
9868
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
9965
|
+
ODataClient.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ODataClient, deps: [{ token: i1.HttpClient }, { token: ODataSettings }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
9966
|
+
ODataClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ODataClient, providedIn: 'root' });
|
|
9967
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ODataClient, decorators: [{
|
|
9869
9968
|
type: Injectable,
|
|
9870
9969
|
args: [{
|
|
9871
9970
|
providedIn: 'root',
|
|
@@ -10117,9 +10216,9 @@ class ODataServiceFactory {
|
|
|
10117
10216
|
})(this.client, singletonName, apiNameOrEntityType);
|
|
10118
10217
|
}
|
|
10119
10218
|
}
|
|
10120
|
-
ODataServiceFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
10121
|
-
ODataServiceFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
10122
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
10219
|
+
ODataServiceFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ODataServiceFactory, deps: [{ token: ODataClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
10220
|
+
ODataServiceFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ODataServiceFactory });
|
|
10221
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ODataServiceFactory, decorators: [{
|
|
10123
10222
|
type: Injectable
|
|
10124
10223
|
}], ctorParameters: function () { return [{ type: ODataClient }]; } });
|
|
10125
10224
|
|
|
@@ -10143,10 +10242,10 @@ class ODataModule {
|
|
|
10143
10242
|
};
|
|
10144
10243
|
}
|
|
10145
10244
|
}
|
|
10146
|
-
ODataModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
10147
|
-
ODataModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "
|
|
10148
|
-
ODataModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
10149
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
10245
|
+
ODataModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
10246
|
+
ODataModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ODataModule, imports: [HttpClientModule] });
|
|
10247
|
+
ODataModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ODataModule, providers: [ODataClient, ODataServiceFactory], imports: [[HttpClientModule]] });
|
|
10248
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: ODataModule, decorators: [{
|
|
10150
10249
|
type: NgModule,
|
|
10151
10250
|
args: [{
|
|
10152
10251
|
imports: [HttpClientModule],
|
|
@@ -10162,5 +10261,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImpor
|
|
|
10162
10261
|
* Generated bundle index. Do not edit.
|
|
10163
10262
|
*/
|
|
10164
10263
|
|
|
10165
|
-
export { BUBBLING,
|
|
10166
|
-
//# sourceMappingURL=angular-odata.
|
|
10264
|
+
export { BUBBLING, Dates, Durations, EDM_PARSERS, Enums, Http, INCLUDE_DEEP, INCLUDE_SHALLOW, ITEM_ROOT, Model, ModelField, NONE_PARSER, ODATA_CONFIGURATIONS, OData, ODataActionResource, ODataAnnotations, ODataApi, ODataBaseService, ODataBatchRequest, ODataBatchResource, ODataCache, ODataCallable, ODataCallableParser, ODataClient, ODataCollection, ODataCountResource, ODataEntitiesAnnotations, ODataEntityAnnotations, ODataEntityContainer, ODataEntityResource, ODataEntitySet, ODataEntitySetResource, ODataEntitySetService, ODataEntityTypeKey, ODataEnumType, ODataEnumTypeFieldParser, ODataEnumTypeParser, ODataFunctionResource, ODataInMemoryCache, ODataInStorageCache, ODataMediaResource, ODataMetadata, ODataMetadataResource, ODataModel, ODataModelEvent, ODataModelField, ODataModelOptions, ODataModelState, ODataModule, ODataNavigationPropertyResource, ODataParameterParser, ODataPathSegments, ODataPathSegmentsHandler, ODataPropertyAnnotations, ODataPropertyResource, ODataQueryOptionHandler, ODataQueryOptions, ODataQueryOptionsHandler, ODataReferenceResource, ODataReferential, ODataRequest, ODataResource, ODataResponse, ODataSchema, ODataServiceFactory, ODataSettings, ODataSingletonResource, ODataSingletonService, ODataStructuredType, ODataStructuredTypeFieldParser, ODataStructuredTypeParser, ODataValueResource, Objects, PathSegmentNames, QueryCustomTypes, QueryOptionNames, RESERVED_FIELD_NAMES, SegmentHandler, StandardAggregateMethods, Strings, Types, Urls, alias, binary, buildPathAndQuery, createSettings, duration, isQueryCustomType, normalizeValue, raw };
|
|
10265
|
+
//# sourceMappingURL=angular-odata.mjs.map
|