angular-odata 0.123.0 → 0.124.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/esm2022/lib/api.mjs +1 -1
- package/esm2022/lib/cache/cache.mjs +4 -2
- package/esm2022/lib/cache/storage.mjs +1 -1
- package/esm2022/lib/client.mjs +5 -6
- package/esm2022/lib/helper.mjs +1 -1
- package/esm2022/lib/loaders.mjs +1 -1
- package/esm2022/lib/models/collection.mjs +8 -5
- package/esm2022/lib/models/model.mjs +32 -16
- package/esm2022/lib/models/options.mjs +21 -14
- package/esm2022/lib/module.mjs +6 -7
- package/esm2022/lib/resources/path/segments.mjs +6 -6
- package/esm2022/lib/resources/query/builder.mjs +11 -6
- package/esm2022/lib/resources/query/expressions/base.mjs +1 -1
- package/esm2022/lib/resources/query/expressions/compute.mjs +5 -5
- package/esm2022/lib/resources/query/expressions/count.mjs +19 -9
- package/esm2022/lib/resources/query/expressions/expand.mjs +15 -9
- package/esm2022/lib/resources/query/expressions/filter.mjs +7 -7
- package/esm2022/lib/resources/query/expressions/orderby.mjs +7 -7
- package/esm2022/lib/resources/query/expressions/search.mjs +5 -5
- package/esm2022/lib/resources/query/expressions/select.mjs +5 -5
- package/esm2022/lib/resources/query/expressions/syntax.mjs +80 -45
- package/esm2022/lib/resources/query/handlers.mjs +1 -1
- package/esm2022/lib/resources/query/options.mjs +6 -6
- package/esm2022/lib/resources/request.mjs +1 -1
- package/esm2022/lib/resources/resource.mjs +11 -5
- package/esm2022/lib/resources/responses/annotations.mjs +1 -1
- package/esm2022/lib/resources/responses/csdl/csdl-annotation.mjs +1 -1
- package/esm2022/lib/resources/responses/csdl/csdl-entity-container.mjs +1 -1
- package/esm2022/lib/resources/responses/csdl/csdl-entity-set.mjs +1 -1
- package/esm2022/lib/resources/responses/csdl/csdl-enum-type.mjs +1 -1
- package/esm2022/lib/resources/responses/csdl/csdl-function-action.mjs +1 -1
- package/esm2022/lib/resources/responses/csdl/csdl-navigation-property-binding.mjs +1 -1
- package/esm2022/lib/resources/responses/csdl/csdl-reference.mjs +1 -1
- package/esm2022/lib/resources/responses/csdl/csdl-schema.mjs +1 -1
- package/esm2022/lib/resources/responses/csdl/csdl-singleton.mjs +1 -1
- package/esm2022/lib/resources/responses/csdl/csdl-structural-property.mjs +1 -1
- package/esm2022/lib/resources/responses/csdl/csdl-structured-type.mjs +1 -1
- package/esm2022/lib/resources/responses/csdl/csdl-type-definition.mjs +1 -1
- package/esm2022/lib/resources/responses/metadata.mjs +2 -3
- package/esm2022/lib/resources/responses/response.mjs +1 -1
- package/esm2022/lib/resources/types/action.mjs +1 -1
- package/esm2022/lib/resources/types/batch.mjs +1 -1
- package/esm2022/lib/resources/types/count.mjs +1 -1
- package/esm2022/lib/resources/types/entity-set.mjs +1 -1
- package/esm2022/lib/resources/types/entity.mjs +1 -1
- package/esm2022/lib/resources/types/function.mjs +1 -1
- package/esm2022/lib/resources/types/media.mjs +1 -1
- package/esm2022/lib/resources/types/navigation-property.mjs +1 -1
- package/esm2022/lib/resources/types/property.mjs +1 -1
- package/esm2022/lib/resources/types/reference.mjs +1 -1
- package/esm2022/lib/resources/types/singleton.mjs +1 -1
- package/esm2022/lib/resources/types/value.mjs +1 -1
- package/esm2022/lib/schema/annotation.mjs +1 -1
- package/esm2022/lib/schema/callable.mjs +1 -1
- package/esm2022/lib/schema/element.mjs +1 -1
- package/esm2022/lib/schema/entity-container.mjs +1 -1
- package/esm2022/lib/schema/enum-type.mjs +1 -1
- package/esm2022/lib/schema/parsers/callable.mjs +1 -1
- package/esm2022/lib/schema/parsers/edm.mjs +1 -1
- package/esm2022/lib/schema/parsers/enum-type.mjs +1 -1
- package/esm2022/lib/schema/parsers/structured-type.mjs +14 -2
- package/esm2022/lib/schema/schema.mjs +1 -1
- package/esm2022/lib/schema/structured-type.mjs +9 -4
- package/esm2022/lib/services/base.mjs +1 -1
- package/esm2022/lib/services/entity-set.mjs +1 -1
- package/esm2022/lib/services/factory.mjs +5 -6
- package/esm2022/lib/services/singleton.mjs +1 -1
- package/esm2022/lib/settings.mjs +1 -1
- package/esm2022/lib/types.mjs +1 -1
- package/esm2022/lib/utils/arrays.mjs +1 -1
- package/esm2022/lib/utils/durations.mjs +1 -1
- package/esm2022/lib/utils/enums.mjs +1 -1
- package/esm2022/lib/utils/http.mjs +1 -1
- package/esm2022/lib/utils/objects.mjs +1 -1
- package/esm2022/lib/utils/odata.mjs +1 -1
- package/esm2022/lib/utils/types.mjs +4 -1
- package/fesm2022/angular-odata.mjs +251 -138
- package/fesm2022/angular-odata.mjs.map +1 -1
- package/lib/models/model.d.ts +1 -1
- package/lib/models/options.d.ts +3 -4
- package/lib/resources/path/segments.d.ts +14 -5
- package/lib/resources/query/expressions/base.d.ts +3 -1
- package/lib/resources/query/expressions/compute.d.ts +8 -6
- package/lib/resources/query/expressions/count.d.ts +11 -8
- package/lib/resources/query/expressions/expand.d.ts +15 -12
- package/lib/resources/query/expressions/filter.d.ts +7 -5
- package/lib/resources/query/expressions/orderby.d.ts +9 -6
- package/lib/resources/query/expressions/search.d.ts +9 -6
- package/lib/resources/query/expressions/select.d.ts +7 -5
- package/lib/resources/query/expressions/syntax.d.ts +16 -13
- package/lib/resources/query/options.d.ts +14 -5
- package/lib/resources/resource.d.ts +1 -1
- package/lib/schema/parsers/structured-type.d.ts +3 -0
- package/lib/schema/structured-type.d.ts +2 -1
- package/lib/utils/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -231,7 +231,9 @@ class ODataCache {
|
|
|
231
231
|
const tags = [];
|
|
232
232
|
const context = res.context;
|
|
233
233
|
if (context.entitySet) {
|
|
234
|
-
tags.push(context.key
|
|
234
|
+
tags.push(context.key
|
|
235
|
+
? `${context.entitySet}(${context.key})`
|
|
236
|
+
: context.entitySet);
|
|
235
237
|
}
|
|
236
238
|
if (context.type)
|
|
237
239
|
tags.push(context.type);
|
|
@@ -453,7 +455,8 @@ const binary = (value) => ({
|
|
|
453
455
|
const isQueryCustomType = (value) => typeof value === 'object' &&
|
|
454
456
|
'type' in value &&
|
|
455
457
|
value.type in QueryCustomTypes;
|
|
456
|
-
const isRawType = (value) => isQueryCustomType(value) &&
|
|
458
|
+
const isRawType = (value) => isQueryCustomType(value) &&
|
|
459
|
+
value.type === QueryCustomTypes.Raw;
|
|
457
460
|
const ITEM_ROOT = '';
|
|
458
461
|
function builder ({ select, search, skiptoken, format, top, skip, filter, transform, orderBy, key, count, expand, action, func, aliases, escape, } = {}) {
|
|
459
462
|
const [path, params] = buildPathAndQuery({
|
|
@@ -486,7 +489,11 @@ function buildPathAndQuery({ select, search, skiptoken, format, top, skip, filte
|
|
|
486
489
|
}
|
|
487
490
|
// Select
|
|
488
491
|
if (select) {
|
|
489
|
-
query.$select = isRawType(select)
|
|
492
|
+
query.$select = isRawType(select)
|
|
493
|
+
? select.value
|
|
494
|
+
: Array.isArray(select)
|
|
495
|
+
? select.join(',')
|
|
496
|
+
: select;
|
|
490
497
|
}
|
|
491
498
|
// Search
|
|
492
499
|
if (search) {
|
|
@@ -853,7 +860,7 @@ function normalizeValue(value, { aliases, escape = false, } = {}) {
|
|
|
853
860
|
}
|
|
854
861
|
return value;
|
|
855
862
|
}
|
|
856
|
-
function buildExpand(expands, { aliases, escape = false }) {
|
|
863
|
+
function buildExpand(expands, { aliases, escape = false, }) {
|
|
857
864
|
if (isRawType(expands)) {
|
|
858
865
|
return expands.value;
|
|
859
866
|
}
|
|
@@ -930,7 +937,7 @@ function buildExpand(expands, { aliases, escape = false }) {
|
|
|
930
937
|
}
|
|
931
938
|
return '';
|
|
932
939
|
}
|
|
933
|
-
function buildTransforms(transforms, { aliases, escape = false }) {
|
|
940
|
+
function buildTransforms(transforms, { aliases, escape = false, }) {
|
|
934
941
|
// Wrap single object an array for simplified processing
|
|
935
942
|
const transformsArray = Array.isArray(transforms) ? transforms : [transforms];
|
|
936
943
|
const transformsResult = transformsArray.reduce((result, transform) => {
|
|
@@ -980,7 +987,7 @@ function buildAggregate(aggregate) {
|
|
|
980
987
|
})
|
|
981
988
|
.join(',');
|
|
982
989
|
}
|
|
983
|
-
function buildGroupBy(groupBy, { aliases, escape = false }) {
|
|
990
|
+
function buildGroupBy(groupBy, { aliases, escape = false, }) {
|
|
984
991
|
if (!groupBy.properties) {
|
|
985
992
|
throw new Error(`'properties' property required for groupBy`);
|
|
986
993
|
}
|
|
@@ -1153,6 +1160,9 @@ const Types = {
|
|
|
1153
1160
|
rawType(value) {
|
|
1154
1161
|
return Object.prototype.toString.call(value).slice(8, -1);
|
|
1155
1162
|
},
|
|
1163
|
+
isObject(value) {
|
|
1164
|
+
return typeof value === 'object' && value !== null;
|
|
1165
|
+
},
|
|
1156
1166
|
isPlainObject(value) {
|
|
1157
1167
|
if (this.rawType(value) !== 'Object') {
|
|
1158
1168
|
return false;
|
|
@@ -1649,39 +1659,36 @@ class Expression {
|
|
|
1649
1659
|
}
|
|
1650
1660
|
}
|
|
1651
1661
|
|
|
1652
|
-
|
|
1653
|
-
constructor(name = '') {
|
|
1654
|
-
this.name = name;
|
|
1655
|
-
}
|
|
1656
|
-
static factory(name = '') {
|
|
1657
|
-
return new Proxy({ _name: name }, new Field());
|
|
1658
|
-
}
|
|
1662
|
+
const FieldFactory = (names = []) => new Proxy({ _names: names }, {
|
|
1659
1663
|
get(target, key) {
|
|
1660
|
-
let
|
|
1664
|
+
let names = target['_names'];
|
|
1661
1665
|
if (key === 'render') {
|
|
1662
|
-
return ({ prefix }) => prefix ? `${prefix}/${
|
|
1666
|
+
return ({ prefix }) => prefix ? `${prefix}/${names.join('/')}` : names.join('/');
|
|
1663
1667
|
}
|
|
1664
1668
|
else if (key === 'clone') {
|
|
1665
|
-
return () =>
|
|
1669
|
+
return () => FieldFactory([...names]);
|
|
1666
1670
|
}
|
|
1667
|
-
else if (key ===
|
|
1668
|
-
return () =>
|
|
1671
|
+
else if (key === 'isField') {
|
|
1672
|
+
return () => true;
|
|
1669
1673
|
}
|
|
1670
1674
|
else if (key === 'toJSON') {
|
|
1671
1675
|
return () => ({
|
|
1672
|
-
$type:
|
|
1673
|
-
|
|
1676
|
+
$type: 'Field',
|
|
1677
|
+
names: names,
|
|
1674
1678
|
});
|
|
1675
1679
|
}
|
|
1680
|
+
else if (key === 'resolve') {
|
|
1681
|
+
return (parser) => names.reduce((acc, name) => acc.field(name), parser);
|
|
1682
|
+
}
|
|
1676
1683
|
else {
|
|
1677
|
-
|
|
1678
|
-
return new Proxy({ _name: name }, this);
|
|
1684
|
+
return FieldFactory([...names, key]);
|
|
1679
1685
|
}
|
|
1680
|
-
}
|
|
1686
|
+
},
|
|
1681
1687
|
has(target, key) {
|
|
1682
|
-
return ['toJSON', 'clone', 'render'].includes(key) ||
|
|
1683
|
-
|
|
1684
|
-
}
|
|
1688
|
+
return (['toJSON', 'isField', 'clone', 'render', 'resolve'].includes(key) ||
|
|
1689
|
+
key in target);
|
|
1690
|
+
},
|
|
1691
|
+
});
|
|
1685
1692
|
function applyMixins(derivedCtor, constructors) {
|
|
1686
1693
|
constructors.forEach((baseCtor) => {
|
|
1687
1694
|
Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
|
|
@@ -1690,22 +1697,36 @@ function applyMixins(derivedCtor, constructors) {
|
|
|
1690
1697
|
});
|
|
1691
1698
|
});
|
|
1692
1699
|
}
|
|
1693
|
-
function render(value, { aliases, normalize, escape, prefix, } = {}) {
|
|
1694
|
-
if (
|
|
1695
|
-
return render(value(syntax), { aliases, normalize, prefix });
|
|
1700
|
+
function render(value, { aliases, normalize, escape, prefix, parser, } = {}) {
|
|
1701
|
+
if (Types.isFunction(value)) {
|
|
1702
|
+
return render(value(syntax), { aliases, normalize, prefix, parser });
|
|
1696
1703
|
}
|
|
1697
|
-
if (
|
|
1698
|
-
value
|
|
1699
|
-
value.render !== undefined) {
|
|
1700
|
-
return render(value.render({ aliases, escape, prefix }), {
|
|
1704
|
+
if (Types.isObject(value) && 'render' in value) {
|
|
1705
|
+
return render(value.render({ aliases, escape, prefix, parser }), {
|
|
1701
1706
|
aliases,
|
|
1702
1707
|
normalize,
|
|
1703
1708
|
escape,
|
|
1704
1709
|
prefix,
|
|
1710
|
+
parser,
|
|
1705
1711
|
});
|
|
1706
1712
|
}
|
|
1707
1713
|
return normalize ? normalizeValue(value, { aliases, escape }) : value;
|
|
1708
1714
|
}
|
|
1715
|
+
function resolve(values, parser) {
|
|
1716
|
+
if (parser !== undefined) {
|
|
1717
|
+
let fields = values.filter((v) => Types.isObject(v) && 'isField' in v && v.isField());
|
|
1718
|
+
if (fields.length === 1 && Types.isObject(parser) && 'field' in parser) {
|
|
1719
|
+
return fields[0].resolve(parser);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
return parser;
|
|
1723
|
+
}
|
|
1724
|
+
function encode(values, parser) {
|
|
1725
|
+
if (parser !== undefined) {
|
|
1726
|
+
return values.map((v) => Types.isObject(v) || v === null ? v : parser?.encode(v));
|
|
1727
|
+
}
|
|
1728
|
+
return values;
|
|
1729
|
+
}
|
|
1709
1730
|
class Function {
|
|
1710
1731
|
constructor(name, values, normalize, escape = false) {
|
|
1711
1732
|
this.name = name;
|
|
@@ -1720,16 +1741,29 @@ class Function {
|
|
|
1720
1741
|
return {
|
|
1721
1742
|
$type: Types.rawType(this),
|
|
1722
1743
|
name: this.name,
|
|
1723
|
-
values: this.values,
|
|
1744
|
+
values: this.values.map((v) => Types.isObject(v) && 'toJSON' in v ? v.toJSON() : v),
|
|
1724
1745
|
normalize: this.normalize,
|
|
1725
1746
|
};
|
|
1726
1747
|
}
|
|
1727
|
-
render({ aliases, escape, prefix, }) {
|
|
1728
|
-
|
|
1729
|
-
|
|
1748
|
+
render({ aliases, escape, prefix, parser, }) {
|
|
1749
|
+
parser = resolve(this.values, parser);
|
|
1750
|
+
let [left, ...values] = encode(this.values, parser);
|
|
1751
|
+
left = render(left, {
|
|
1752
|
+
aliases,
|
|
1753
|
+
escape,
|
|
1754
|
+
prefix,
|
|
1755
|
+
parser,
|
|
1756
|
+
normalize: this.normalize === 'all' || this.normalize === 'left',
|
|
1757
|
+
});
|
|
1730
1758
|
const params = [
|
|
1731
|
-
|
|
1732
|
-
...values.map((v) => render(v, {
|
|
1759
|
+
left,
|
|
1760
|
+
...values.map((v) => render(v, {
|
|
1761
|
+
aliases,
|
|
1762
|
+
escape,
|
|
1763
|
+
prefix,
|
|
1764
|
+
parser,
|
|
1765
|
+
normalize: this.normalize === 'all' || this.normalize === 'right',
|
|
1766
|
+
})),
|
|
1733
1767
|
];
|
|
1734
1768
|
return `${this.name}(${params.join(', ')})`;
|
|
1735
1769
|
}
|
|
@@ -1878,13 +1912,20 @@ class Operator {
|
|
|
1878
1912
|
return {
|
|
1879
1913
|
$type: Types.rawType(this),
|
|
1880
1914
|
op: this.op,
|
|
1881
|
-
values: this.values,
|
|
1915
|
+
values: this.values.map((v) => Types.isObject(v) && 'toJSON' in v ? v.toJSON() : v),
|
|
1882
1916
|
normalize: this.normalize,
|
|
1883
1917
|
};
|
|
1884
1918
|
}
|
|
1885
|
-
render({ aliases, escape, prefix, }) {
|
|
1886
|
-
|
|
1887
|
-
|
|
1919
|
+
render({ aliases, escape, prefix, parser, }) {
|
|
1920
|
+
parser = resolve(this.values, parser);
|
|
1921
|
+
let [left, right] = encode(this.values, parser);
|
|
1922
|
+
left = render(left, {
|
|
1923
|
+
aliases,
|
|
1924
|
+
escape,
|
|
1925
|
+
prefix,
|
|
1926
|
+
parser,
|
|
1927
|
+
normalize: this.normalize === 'all' || this.normalize === 'left',
|
|
1928
|
+
});
|
|
1888
1929
|
if (right !== undefined) {
|
|
1889
1930
|
right = Array.isArray(right)
|
|
1890
1931
|
? `(${right
|
|
@@ -1892,6 +1933,7 @@ class Operator {
|
|
|
1892
1933
|
aliases,
|
|
1893
1934
|
escape,
|
|
1894
1935
|
prefix,
|
|
1936
|
+
parser,
|
|
1895
1937
|
normalize: this.normalize === 'all' || this.normalize === 'right',
|
|
1896
1938
|
}))
|
|
1897
1939
|
.join(',')})`
|
|
@@ -1899,6 +1941,7 @@ class Operator {
|
|
|
1899
1941
|
aliases,
|
|
1900
1942
|
escape,
|
|
1901
1943
|
prefix,
|
|
1944
|
+
parser,
|
|
1902
1945
|
normalize: this.normalize === 'all' || this.normalize === 'right',
|
|
1903
1946
|
});
|
|
1904
1947
|
return `${left} ${this.op} ${right}`;
|
|
@@ -1979,8 +2022,8 @@ class Grouping {
|
|
|
1979
2022
|
group: this.group.toJSON(),
|
|
1980
2023
|
};
|
|
1981
2024
|
}
|
|
1982
|
-
render({ aliases, escape, prefix, }) {
|
|
1983
|
-
return `(${render(this.group, { aliases, escape, prefix })})`;
|
|
2025
|
+
render({ aliases, escape, prefix, parser, }) {
|
|
2026
|
+
return `(${render(this.group, { aliases, escape, prefix, parser })})`;
|
|
1984
2027
|
}
|
|
1985
2028
|
clone() {
|
|
1986
2029
|
return new Grouping(Objects.clone(this.group));
|
|
@@ -1999,19 +2042,21 @@ class Lambda {
|
|
|
1999
2042
|
return {
|
|
2000
2043
|
$type: Types.rawType(this),
|
|
2001
2044
|
op: this.op,
|
|
2002
|
-
values: this.values,
|
|
2045
|
+
values: this.values.map((v) => Types.isObject(v) && 'toJSON' in v ? v.toJSON() : v),
|
|
2003
2046
|
alias: this.alias,
|
|
2004
2047
|
};
|
|
2005
2048
|
}
|
|
2006
|
-
render({ aliases, escape, prefix, }) {
|
|
2007
|
-
|
|
2008
|
-
|
|
2049
|
+
render({ aliases, escape, prefix, parser, }) {
|
|
2050
|
+
parser = resolve(this.values, parser);
|
|
2051
|
+
let [left, right] = encode(this.values, parser);
|
|
2052
|
+
left = render(left, { aliases, escape, prefix, parser });
|
|
2009
2053
|
if (right) {
|
|
2010
2054
|
let alias = this.alias || left.split('/').pop().toLowerCase()[0];
|
|
2011
2055
|
return `${left}/${this.op}(${alias}:${render(right, {
|
|
2012
2056
|
aliases,
|
|
2013
2057
|
escape,
|
|
2014
2058
|
prefix: alias,
|
|
2059
|
+
parser,
|
|
2015
2060
|
})})`;
|
|
2016
2061
|
}
|
|
2017
2062
|
else {
|
|
@@ -2063,12 +2108,12 @@ class ComputeExpression extends Expression {
|
|
|
2063
2108
|
}
|
|
2064
2109
|
static compute(opts, current) {
|
|
2065
2110
|
return opts({
|
|
2066
|
-
t:
|
|
2111
|
+
t: FieldFactory(),
|
|
2067
2112
|
e: () => new ComputeExpression(),
|
|
2068
2113
|
}, current);
|
|
2069
2114
|
}
|
|
2070
|
-
render({ aliases, escape, prefix, } = {}) {
|
|
2071
|
-
let children = this._children.map((n) => n.render({ aliases, escape, prefix }));
|
|
2115
|
+
render({ aliases, escape, prefix, parser, } = {}) {
|
|
2116
|
+
let children = this._children.map((n) => n.render({ aliases, escape, prefix, parser }));
|
|
2072
2117
|
return this.names
|
|
2073
2118
|
.map((name, index) => `${children[index]} as ${name}`)
|
|
2074
2119
|
.join(',');
|
|
@@ -2106,7 +2151,7 @@ class CountField {
|
|
|
2106
2151
|
field: this.field.toJSON(),
|
|
2107
2152
|
};
|
|
2108
2153
|
}
|
|
2109
|
-
render({ aliases, escape, prefix, }) {
|
|
2154
|
+
render({ aliases, escape, prefix, parser, }) {
|
|
2110
2155
|
const params = [
|
|
2111
2156
|
QueryOption.filter,
|
|
2112
2157
|
QueryOption.search,
|
|
@@ -2115,11 +2160,21 @@ class CountField {
|
|
|
2115
2160
|
.reduce((acc, key) => {
|
|
2116
2161
|
let value = this.values[key];
|
|
2117
2162
|
if (Types.rawType(value).endsWith('Expression')) {
|
|
2118
|
-
value = value.render({
|
|
2163
|
+
value = value.render({
|
|
2164
|
+
aliases,
|
|
2165
|
+
prefix,
|
|
2166
|
+
escape,
|
|
2167
|
+
parser,
|
|
2168
|
+
});
|
|
2119
2169
|
}
|
|
2120
2170
|
return Object.assign(acc, { [key]: value });
|
|
2121
2171
|
}, {});
|
|
2122
|
-
let count = `${render(this.field, {
|
|
2172
|
+
let count = `${render(this.field, {
|
|
2173
|
+
aliases,
|
|
2174
|
+
escape,
|
|
2175
|
+
prefix,
|
|
2176
|
+
parser,
|
|
2177
|
+
})}/$count`;
|
|
2123
2178
|
if (!Types.isEmpty(params)) {
|
|
2124
2179
|
count = `${count}(${Object.keys(params)
|
|
2125
2180
|
.map((key) => `$${key}=${params[key]}`)
|
|
@@ -2147,7 +2202,7 @@ class CountExpression extends Expression {
|
|
|
2147
2202
|
}
|
|
2148
2203
|
static count(opts, current) {
|
|
2149
2204
|
return opts({
|
|
2150
|
-
t:
|
|
2205
|
+
t: FieldFactory(),
|
|
2151
2206
|
e: () => new CountExpression(),
|
|
2152
2207
|
}, current);
|
|
2153
2208
|
}
|
|
@@ -2155,9 +2210,9 @@ class CountExpression extends Expression {
|
|
|
2155
2210
|
this._children.push(node);
|
|
2156
2211
|
return this;
|
|
2157
2212
|
}
|
|
2158
|
-
render({ aliases, escape, prefix, } = {}) {
|
|
2213
|
+
render({ aliases, escape, prefix, parser, } = {}) {
|
|
2159
2214
|
let content = this._children
|
|
2160
|
-
.map((n) => n.render({ aliases, escape, prefix }))
|
|
2215
|
+
.map((n) => n.render({ aliases, escape, prefix, parser }))
|
|
2161
2216
|
.join(`,`);
|
|
2162
2217
|
return content;
|
|
2163
2218
|
}
|
|
@@ -2170,7 +2225,7 @@ class CountExpression extends Expression {
|
|
|
2170
2225
|
let countField = new CountField(field);
|
|
2171
2226
|
if (opts !== undefined)
|
|
2172
2227
|
opts({
|
|
2173
|
-
t:
|
|
2228
|
+
t: FieldFactory(),
|
|
2174
2229
|
f: countField,
|
|
2175
2230
|
});
|
|
2176
2231
|
return this._add(countField);
|
|
@@ -2185,8 +2240,8 @@ class FilterExpression extends Expression {
|
|
|
2185
2240
|
}
|
|
2186
2241
|
static filter(opts, current) {
|
|
2187
2242
|
return opts({
|
|
2188
|
-
t: Field$1.factory(),
|
|
2189
2243
|
e: (connector = 'and') => new FilterExpression({ connector }),
|
|
2244
|
+
t: FieldFactory(),
|
|
2190
2245
|
o: operators,
|
|
2191
2246
|
f: functions,
|
|
2192
2247
|
}, current);
|
|
@@ -2204,9 +2259,9 @@ class FilterExpression extends Expression {
|
|
|
2204
2259
|
negated() {
|
|
2205
2260
|
return this._negated;
|
|
2206
2261
|
}
|
|
2207
|
-
render({ aliases, escape, prefix, } = {}) {
|
|
2262
|
+
render({ aliases, escape, prefix, parser, } = {}) {
|
|
2208
2263
|
let content = this._children
|
|
2209
|
-
.map((n) => n.render({ aliases, escape, prefix }))
|
|
2264
|
+
.map((n) => n.render({ aliases, escape, prefix, parser }))
|
|
2210
2265
|
.join(` ${this._connector} `);
|
|
2211
2266
|
if (this._negated) {
|
|
2212
2267
|
content = `not (${content})`;
|
|
@@ -2314,7 +2369,7 @@ class FilterExpression extends Expression {
|
|
|
2314
2369
|
let exp = undefined;
|
|
2315
2370
|
if (opts !== undefined) {
|
|
2316
2371
|
exp = opts({
|
|
2317
|
-
t:
|
|
2372
|
+
t: FieldFactory(),
|
|
2318
2373
|
e: (connector = 'and') => new FilterExpression({ connector }),
|
|
2319
2374
|
});
|
|
2320
2375
|
}
|
|
@@ -2322,7 +2377,7 @@ class FilterExpression extends Expression {
|
|
|
2322
2377
|
}
|
|
2323
2378
|
all(left, opts, alias) {
|
|
2324
2379
|
const exp = opts({
|
|
2325
|
-
t:
|
|
2380
|
+
t: FieldFactory(),
|
|
2326
2381
|
e: (connector = 'and') => new FilterExpression({ connector }),
|
|
2327
2382
|
});
|
|
2328
2383
|
return this._add(syntax.all(left, exp, alias));
|
|
@@ -2349,8 +2404,8 @@ class OrderByField {
|
|
|
2349
2404
|
order: this.order,
|
|
2350
2405
|
};
|
|
2351
2406
|
}
|
|
2352
|
-
render({ aliases, escape, prefix, }) {
|
|
2353
|
-
return `${render(this.field, { aliases, escape, prefix })} ${this.order}`;
|
|
2407
|
+
render({ aliases, escape, prefix, parser, }) {
|
|
2408
|
+
return `${render(this.field, { aliases, escape, prefix, parser })} ${this.order}`;
|
|
2354
2409
|
}
|
|
2355
2410
|
clone() {
|
|
2356
2411
|
return new OrderByField(this.field.clone(), this.order);
|
|
@@ -2362,7 +2417,7 @@ class OrderByExpression extends Expression {
|
|
|
2362
2417
|
}
|
|
2363
2418
|
static orderBy(opts, current) {
|
|
2364
2419
|
return opts({
|
|
2365
|
-
t:
|
|
2420
|
+
t: FieldFactory(),
|
|
2366
2421
|
e: () => new OrderByExpression(),
|
|
2367
2422
|
}, current);
|
|
2368
2423
|
}
|
|
@@ -2370,9 +2425,9 @@ class OrderByExpression extends Expression {
|
|
|
2370
2425
|
this._children.push(node);
|
|
2371
2426
|
return this;
|
|
2372
2427
|
}
|
|
2373
|
-
render({ aliases, escape, prefix, } = {}) {
|
|
2428
|
+
render({ aliases, escape, prefix, parser, } = {}) {
|
|
2374
2429
|
let content = this._children
|
|
2375
|
-
.map((n) => n.render({ aliases, escape, prefix }))
|
|
2430
|
+
.map((n) => n.render({ aliases, escape, prefix, parser }))
|
|
2376
2431
|
.join(`,`);
|
|
2377
2432
|
return content;
|
|
2378
2433
|
}
|
|
@@ -2402,8 +2457,8 @@ class SearchTerm {
|
|
|
2402
2457
|
value: this.value,
|
|
2403
2458
|
};
|
|
2404
2459
|
}
|
|
2405
|
-
render({ aliases, escape, prefix, }) {
|
|
2406
|
-
return `${render(this.value, { aliases, escape, prefix })}`;
|
|
2460
|
+
render({ aliases, escape, prefix, parser, }) {
|
|
2461
|
+
return `${render(this.value, { aliases, escape, prefix, parser })}`;
|
|
2407
2462
|
}
|
|
2408
2463
|
clone() {
|
|
2409
2464
|
return new SearchTerm(this.value);
|
|
@@ -2463,9 +2518,9 @@ class SearchExpression extends Expression {
|
|
|
2463
2518
|
}
|
|
2464
2519
|
return this;
|
|
2465
2520
|
}
|
|
2466
|
-
render({ aliases, escape, prefix, } = {}) {
|
|
2521
|
+
render({ aliases, escape, prefix, parser, } = {}) {
|
|
2467
2522
|
let content = this._children
|
|
2468
|
-
.map((n) => n.render({ aliases, escape, prefix }))
|
|
2523
|
+
.map((n) => n.render({ aliases, escape, prefix, parser }))
|
|
2469
2524
|
.join(` ${this._connector} `);
|
|
2470
2525
|
return content;
|
|
2471
2526
|
}
|
|
@@ -2514,13 +2569,13 @@ class SelectExpression extends Expression {
|
|
|
2514
2569
|
}
|
|
2515
2570
|
static select(opts, current) {
|
|
2516
2571
|
return opts({
|
|
2517
|
-
t:
|
|
2572
|
+
t: FieldFactory(),
|
|
2518
2573
|
e: () => new SelectExpression(),
|
|
2519
2574
|
}, current);
|
|
2520
2575
|
}
|
|
2521
|
-
render({ aliases, escape, prefix, } = {}) {
|
|
2576
|
+
render({ aliases, escape, prefix, parser, } = {}) {
|
|
2522
2577
|
return this._children
|
|
2523
|
-
.map((n) => n.render({ aliases, escape, prefix }))
|
|
2578
|
+
.map((n) => n.render({ aliases, escape, prefix, parser }))
|
|
2524
2579
|
.join(',');
|
|
2525
2580
|
}
|
|
2526
2581
|
clone() {
|
|
@@ -2550,7 +2605,8 @@ class ExpandField {
|
|
|
2550
2605
|
field: this.field.toJSON(),
|
|
2551
2606
|
};
|
|
2552
2607
|
}
|
|
2553
|
-
render({ aliases, escape, prefix, }) {
|
|
2608
|
+
render({ aliases, escape, prefix, parser, }) {
|
|
2609
|
+
parser = resolve([this.field], parser);
|
|
2554
2610
|
const params = [
|
|
2555
2611
|
QueryOption.select,
|
|
2556
2612
|
QueryOption.expand,
|
|
@@ -2566,11 +2622,16 @@ class ExpandField {
|
|
|
2566
2622
|
.reduce((acc, key) => {
|
|
2567
2623
|
let value = this.values[key];
|
|
2568
2624
|
if (Types.rawType(value).endsWith('Expression')) {
|
|
2569
|
-
value = value.render({
|
|
2625
|
+
value = value.render({
|
|
2626
|
+
aliases,
|
|
2627
|
+
prefix,
|
|
2628
|
+
escape,
|
|
2629
|
+
parser,
|
|
2630
|
+
});
|
|
2570
2631
|
}
|
|
2571
2632
|
return Object.assign(acc, { [key]: value });
|
|
2572
2633
|
}, {});
|
|
2573
|
-
let expand = `${render(this.field, { aliases, escape, prefix })}`;
|
|
2634
|
+
let expand = `${render(this.field, { aliases, escape, prefix, parser })}`;
|
|
2574
2635
|
if (!Types.isEmpty(params)) {
|
|
2575
2636
|
expand = `${expand}(${Object.keys(params)
|
|
2576
2637
|
.map((key) => `$${key}=${params[key]}`)
|
|
@@ -2580,7 +2641,7 @@ class ExpandField {
|
|
|
2580
2641
|
}
|
|
2581
2642
|
clone() {
|
|
2582
2643
|
const values = Object.keys(this.values).reduce((acc, key) => Object.assign(acc, { [key]: Objects.clone(this.values[key]) }), {});
|
|
2583
|
-
return new ExpandField(typeof
|
|
2644
|
+
return new ExpandField(typeof this.field === 'string' ? this.field : this.field.clone(), values);
|
|
2584
2645
|
}
|
|
2585
2646
|
select(opts) {
|
|
2586
2647
|
return this.option(QueryOption.select, SelectExpression.select(opts, this.values[QueryOption.select]));
|
|
@@ -2622,13 +2683,13 @@ class ExpandExpression extends Expression {
|
|
|
2622
2683
|
}
|
|
2623
2684
|
static expand(opts, current) {
|
|
2624
2685
|
return opts({
|
|
2625
|
-
t:
|
|
2686
|
+
t: FieldFactory(),
|
|
2626
2687
|
e: () => new ExpandExpression(),
|
|
2627
2688
|
}, current);
|
|
2628
2689
|
}
|
|
2629
|
-
render({ aliases, escape, prefix, } = {}) {
|
|
2690
|
+
render({ aliases, escape, prefix, parser, } = {}) {
|
|
2630
2691
|
return this._children
|
|
2631
|
-
.map((n) => n.render({ aliases, escape, prefix }))
|
|
2692
|
+
.map((n) => n.render({ aliases, escape, prefix, parser }))
|
|
2632
2693
|
.join(',');
|
|
2633
2694
|
}
|
|
2634
2695
|
clone() {
|
|
@@ -3037,7 +3098,7 @@ class ODataQueryOptions {
|
|
|
3037
3098
|
: new Map(Object.entries(values || {}));
|
|
3038
3099
|
}
|
|
3039
3100
|
// Params
|
|
3040
|
-
pathAndParams(escape =
|
|
3101
|
+
pathAndParams({ escape, parser, } = {}) {
|
|
3041
3102
|
let aliases = [];
|
|
3042
3103
|
let options = [
|
|
3043
3104
|
QueryOption.select,
|
|
@@ -3062,16 +3123,16 @@ class ODataQueryOptions {
|
|
|
3062
3123
|
value.some((v) => Types.rawType(v).endsWith('Expression')))) {
|
|
3063
3124
|
value = Types.isArray(value)
|
|
3064
3125
|
? value.map((v) => Types.rawType(v).endsWith('Expression')
|
|
3065
|
-
? raw(v.render({ aliases }))
|
|
3126
|
+
? raw(v.render({ aliases, escape, parser }))
|
|
3066
3127
|
: v)
|
|
3067
|
-
: raw(value.render({ aliases }));
|
|
3128
|
+
: raw(value.render({ aliases, escape, parser }));
|
|
3068
3129
|
}
|
|
3069
3130
|
return Object.assign(acc, { [key]: value });
|
|
3070
3131
|
}, {});
|
|
3071
3132
|
return buildPathAndQuery({ ...options, aliases, escape });
|
|
3072
3133
|
}
|
|
3073
|
-
toString() {
|
|
3074
|
-
const [path, params] = this.pathAndParams();
|
|
3134
|
+
toString({ escape, parser, } = {}) {
|
|
3135
|
+
const [path, params] = this.pathAndParams({ escape, parser });
|
|
3075
3136
|
return (path +
|
|
3076
3137
|
Object.entries(params)
|
|
3077
3138
|
.filter(([, value]) => !Types.isEmpty(value))
|
|
@@ -3207,7 +3268,7 @@ class ODataPathSegmentsHandler {
|
|
|
3207
3268
|
}
|
|
3208
3269
|
}
|
|
3209
3270
|
|
|
3210
|
-
function pathSegmentsBuilder(segment, escape = false) {
|
|
3271
|
+
function pathSegmentsBuilder(segment, escape = false, parser) {
|
|
3211
3272
|
if (segment.name === PathSegment.function) {
|
|
3212
3273
|
let [path, params] = segment.parameters
|
|
3213
3274
|
? buildPathAndQuery({
|
|
@@ -3235,9 +3296,9 @@ class ODataPathSegments {
|
|
|
3235
3296
|
constructor(segments) {
|
|
3236
3297
|
this._segments = segments || [];
|
|
3237
3298
|
}
|
|
3238
|
-
pathAndParams(escape =
|
|
3299
|
+
pathAndParams({ escape, parser, } = {}) {
|
|
3239
3300
|
const result = this._segments.reduce((acc, segment) => {
|
|
3240
|
-
const [path, params] = pathSegmentsBuilder(segment, escape);
|
|
3301
|
+
const [path, params] = pathSegmentsBuilder(segment, escape, parser);
|
|
3241
3302
|
acc.paths.push(path);
|
|
3242
3303
|
acc.params = Object.assign(acc.params, params);
|
|
3243
3304
|
return acc;
|
|
@@ -3264,8 +3325,8 @@ class ODataPathSegments {
|
|
|
3264
3325
|
}
|
|
3265
3326
|
return segments.map((s) => s.key());
|
|
3266
3327
|
}
|
|
3267
|
-
toString() {
|
|
3268
|
-
const [path, params] = this.pathAndParams();
|
|
3328
|
+
toString({ escape, parser, } = {}) {
|
|
3329
|
+
const [path, params] = this.pathAndParams({ escape, parser });
|
|
3269
3330
|
return (path +
|
|
3270
3331
|
Object.entries(params)
|
|
3271
3332
|
.filter(([, value]) => value)
|
|
@@ -4420,6 +4481,9 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
|
|
|
4420
4481
|
return this.parent.isSubtypeOf(type);
|
|
4421
4482
|
return false;
|
|
4422
4483
|
}
|
|
4484
|
+
isOpenType() {
|
|
4485
|
+
return this.open;
|
|
4486
|
+
}
|
|
4423
4487
|
findChildParser(predicate) {
|
|
4424
4488
|
if (predicate(this))
|
|
4425
4489
|
return this;
|
|
@@ -4440,7 +4504,9 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
|
|
|
4440
4504
|
const fields = this.fields({
|
|
4441
4505
|
include_navigation: true,
|
|
4442
4506
|
include_parents: true,
|
|
4443
|
-
}).filter((f) => f.name in value &&
|
|
4507
|
+
}).filter((f) => f.name in value &&
|
|
4508
|
+
value[f.name] !== undefined &&
|
|
4509
|
+
value[f.name] !== null);
|
|
4444
4510
|
return {
|
|
4445
4511
|
...value,
|
|
4446
4512
|
...fields.reduce((acc, f) => ({
|
|
@@ -4507,6 +4573,13 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
|
|
|
4507
4573
|
...(this._keys || []),
|
|
4508
4574
|
];
|
|
4509
4575
|
}
|
|
4576
|
+
isEntityType() {
|
|
4577
|
+
return (this._keys !== undefined ||
|
|
4578
|
+
(this.parent !== undefined && this.parent.isEntityType()));
|
|
4579
|
+
}
|
|
4580
|
+
isComplexType() {
|
|
4581
|
+
return !this.isEntityType();
|
|
4582
|
+
}
|
|
4510
4583
|
/**
|
|
4511
4584
|
* Find the field parser for the given field name.
|
|
4512
4585
|
* @param name Name of the field
|
|
@@ -4892,14 +4965,13 @@ class ODataStructuredType extends ODataSchemaElement {
|
|
|
4892
4965
|
super(config, schema);
|
|
4893
4966
|
this.children = [];
|
|
4894
4967
|
this.base = config.base;
|
|
4895
|
-
this.open = config.open || false;
|
|
4896
4968
|
this.parser = new ODataStructuredTypeParser(config, schema.namespace, schema.alias);
|
|
4897
4969
|
this.model = config.model;
|
|
4898
4970
|
this.collection = config.collection;
|
|
4899
4971
|
if (this.model !== undefined) {
|
|
4900
4972
|
const options = this.model.hasOwnProperty('options')
|
|
4901
4973
|
? this.model.options
|
|
4902
|
-
: { fields:
|
|
4974
|
+
: { fields: new Map() };
|
|
4903
4975
|
this.model.buildMeta({ options, schema: this });
|
|
4904
4976
|
}
|
|
4905
4977
|
if (this.collection !== undefined) {
|
|
@@ -4958,7 +5030,13 @@ class ODataStructuredType extends ODataSchemaElement {
|
|
|
4958
5030
|
return this.keys().length > 1;
|
|
4959
5031
|
}
|
|
4960
5032
|
isOpenType() {
|
|
4961
|
-
return this.
|
|
5033
|
+
return this.parser.isOpenType();
|
|
5034
|
+
}
|
|
5035
|
+
isEntityType() {
|
|
5036
|
+
return this.parser.isEntityType();
|
|
5037
|
+
}
|
|
5038
|
+
isComplexType() {
|
|
5039
|
+
return this.parser.isComplexType();
|
|
4962
5040
|
}
|
|
4963
5041
|
/**
|
|
4964
5042
|
* Find the field parser for the given field name.
|
|
@@ -5229,8 +5307,14 @@ class ODataResource {
|
|
|
5229
5307
|
: otherPath === selfPath && Types.isEqual(selfParams, otherParams);
|
|
5230
5308
|
}
|
|
5231
5309
|
pathAndParams(escape = false) {
|
|
5232
|
-
const
|
|
5233
|
-
|
|
5310
|
+
const parser = this.schema !== undefined && 'parser' in this.schema
|
|
5311
|
+
? this.schema.parser
|
|
5312
|
+
: undefined;
|
|
5313
|
+
const [spath, sparams] = this.pathSegments.pathAndParams({
|
|
5314
|
+
escape,
|
|
5315
|
+
parser,
|
|
5316
|
+
});
|
|
5317
|
+
const [, qparams] = this.queryOptions.pathAndParams({ escape, parser });
|
|
5234
5318
|
return [spath, { ...sparams, ...qparams }];
|
|
5235
5319
|
}
|
|
5236
5320
|
endpointUrl(params = true) {
|
|
@@ -5242,8 +5326,8 @@ class ODataResource {
|
|
|
5242
5326
|
return `${this.api.serviceRootUrl}${path}`;
|
|
5243
5327
|
}
|
|
5244
5328
|
}
|
|
5245
|
-
toString() {
|
|
5246
|
-
let [path, params] = this.pathAndParams();
|
|
5329
|
+
toString(escape = false) {
|
|
5330
|
+
let [path, params] = this.pathAndParams(escape);
|
|
5247
5331
|
let queryString = Object.entries(params)
|
|
5248
5332
|
.map((e) => `${e[0]}${VALUE_SEPARATOR}${e[1]}`)
|
|
5249
5333
|
.join(PARAM_SEPARATOR);
|
|
@@ -8318,12 +8402,12 @@ class ODataModelEvent {
|
|
|
8318
8402
|
}
|
|
8319
8403
|
get path() {
|
|
8320
8404
|
return this.chain
|
|
8321
|
-
.map(([,
|
|
8322
|
-
? `[${
|
|
8323
|
-
:
|
|
8405
|
+
.map(([, attr], index) => typeof attr === 'number'
|
|
8406
|
+
? `[${attr}]`
|
|
8407
|
+
: attr instanceof ODataModelAttribute
|
|
8324
8408
|
? index === 0
|
|
8325
|
-
?
|
|
8326
|
-
: `.${
|
|
8409
|
+
? attr.name
|
|
8410
|
+
: `.${attr.name}`
|
|
8327
8411
|
: '')
|
|
8328
8412
|
.join('');
|
|
8329
8413
|
}
|
|
@@ -8368,7 +8452,9 @@ function Model({ cid = CID_FIELD_NAME } = {}) {
|
|
|
8368
8452
|
return (constructor) => {
|
|
8369
8453
|
const Klass = constructor;
|
|
8370
8454
|
if (!Klass.hasOwnProperty('options'))
|
|
8371
|
-
Klass.options = {
|
|
8455
|
+
Klass.options = {
|
|
8456
|
+
fields: new Map(),
|
|
8457
|
+
};
|
|
8372
8458
|
Klass.options.cid = cid;
|
|
8373
8459
|
return constructor;
|
|
8374
8460
|
};
|
|
@@ -8377,9 +8463,11 @@ function ModelField({ name, ...options } = {}) {
|
|
|
8377
8463
|
return (target, key) => {
|
|
8378
8464
|
const Klass = target.constructor;
|
|
8379
8465
|
if (!Klass.hasOwnProperty('options'))
|
|
8380
|
-
Klass.options = {
|
|
8466
|
+
Klass.options = {
|
|
8467
|
+
fields: new Map(),
|
|
8468
|
+
};
|
|
8381
8469
|
options.field = name || key;
|
|
8382
|
-
Klass.options.fields
|
|
8470
|
+
Klass.options.fields.set(key, options);
|
|
8383
8471
|
};
|
|
8384
8472
|
}
|
|
8385
8473
|
class ODataModelField {
|
|
@@ -8602,9 +8690,7 @@ class ODataModelAttribute {
|
|
|
8602
8690
|
const current = this.get();
|
|
8603
8691
|
if (ODataModelOptions.isModel(current) ||
|
|
8604
8692
|
ODataModelOptions.isCollection(current))
|
|
8605
|
-
this.unlink(current
|
|
8606
|
-
//this.value !== current
|
|
8607
|
-
);
|
|
8693
|
+
this.unlink(current);
|
|
8608
8694
|
const changed = ODataModelOptions.isModel(current) && ODataModelOptions.isModel(value)
|
|
8609
8695
|
? !current.equals(value)
|
|
8610
8696
|
: ODataModelOptions.isCollection(current) &&
|
|
@@ -8669,10 +8755,9 @@ class ODataModelOptions {
|
|
|
8669
8755
|
};
|
|
8670
8756
|
this.name = schema.name;
|
|
8671
8757
|
this.base = schema.base;
|
|
8672
|
-
this.open = schema.open;
|
|
8673
8758
|
this.schema = schema;
|
|
8674
8759
|
this.cid = options?.cid || CID_FIELD_NAME;
|
|
8675
|
-
|
|
8760
|
+
options.fields.forEach((value, key) => this.addField(key, value));
|
|
8676
8761
|
}
|
|
8677
8762
|
get api() {
|
|
8678
8763
|
return this.schema.api;
|
|
@@ -8683,6 +8768,12 @@ class ODataModelOptions {
|
|
|
8683
8768
|
isOpenType() {
|
|
8684
8769
|
return this.schema.isOpenType();
|
|
8685
8770
|
}
|
|
8771
|
+
isEntityType() {
|
|
8772
|
+
return this.schema.isEntityType();
|
|
8773
|
+
}
|
|
8774
|
+
isComplexType() {
|
|
8775
|
+
return this.schema.isComplexType();
|
|
8776
|
+
}
|
|
8686
8777
|
isTypeOf(type) {
|
|
8687
8778
|
return this.schema.isTypeOf(type);
|
|
8688
8779
|
}
|
|
@@ -9969,6 +10060,8 @@ class ODataCollection {
|
|
|
9969
10060
|
if (model.hasChanged())
|
|
9970
10061
|
toChange.push([model, position]);
|
|
9971
10062
|
}
|
|
10063
|
+
if (reset)
|
|
10064
|
+
entry.state = ODataModelState.Unchanged;
|
|
9972
10065
|
// Has Sort or Index Change?
|
|
9973
10066
|
if (toSort.length > 0 || position !== this.models().indexOf(model)) {
|
|
9974
10067
|
toSort.push([model, position]);
|
|
@@ -9978,12 +10071,14 @@ class ODataCollection {
|
|
|
9978
10071
|
// Add
|
|
9979
10072
|
model = isModel
|
|
9980
10073
|
? obj
|
|
9981
|
-
: this.modelFactory(obj
|
|
10074
|
+
: this.modelFactory(obj, {
|
|
10075
|
+
reset,
|
|
10076
|
+
});
|
|
9982
10077
|
toAdd.push([model, position]);
|
|
9983
10078
|
}
|
|
9984
10079
|
modelMap.push(model[Model.meta.cid]);
|
|
9985
10080
|
});
|
|
9986
|
-
if (remove) {
|
|
10081
|
+
if (remove || reset) {
|
|
9987
10082
|
this._entries.forEach((entry, position) => {
|
|
9988
10083
|
if (modelMap.indexOf(entry.model[Model.meta.cid]) === -1)
|
|
9989
10084
|
toRemove.push([entry.model, position]);
|
|
@@ -10243,7 +10338,9 @@ class ODataModel {
|
|
|
10243
10338
|
},
|
|
10244
10339
|
});
|
|
10245
10340
|
}, {});
|
|
10246
|
-
options = {
|
|
10341
|
+
options = {
|
|
10342
|
+
fields: new Map(Object.entries(fields)),
|
|
10343
|
+
};
|
|
10247
10344
|
}
|
|
10248
10345
|
this.meta = new ODataModelOptions({ options, schema });
|
|
10249
10346
|
}
|
|
@@ -10253,7 +10350,6 @@ class ODataModel {
|
|
|
10253
10350
|
this._resource = null;
|
|
10254
10351
|
this._resources = [];
|
|
10255
10352
|
this._attributes = new Map();
|
|
10256
|
-
this._annotations = null;
|
|
10257
10353
|
this._reset = false;
|
|
10258
10354
|
this._reparent = false;
|
|
10259
10355
|
this._silent = false;
|
|
@@ -10322,8 +10418,7 @@ class ODataModel {
|
|
|
10322
10418
|
return this._meta.schema;
|
|
10323
10419
|
}
|
|
10324
10420
|
annots() {
|
|
10325
|
-
return
|
|
10326
|
-
new ODataEntityAnnotations(ODataHelper[DEFAULT_VERSION]));
|
|
10421
|
+
return this._annotations;
|
|
10327
10422
|
}
|
|
10328
10423
|
key({ field_mapping = false, resolve = true, } = {}) {
|
|
10329
10424
|
return this._meta.resolveKey(this, { field_mapping, resolve });
|
|
@@ -10707,14 +10802,32 @@ class ODataModel {
|
|
|
10707
10802
|
return 'Model';
|
|
10708
10803
|
}
|
|
10709
10804
|
equals(other) {
|
|
10710
|
-
|
|
10711
|
-
|
|
10712
|
-
|
|
10713
|
-
|
|
10714
|
-
|
|
10715
|
-
|
|
10716
|
-
|
|
10717
|
-
|
|
10805
|
+
if (this === other)
|
|
10806
|
+
return true;
|
|
10807
|
+
if (typeof this !== typeof other)
|
|
10808
|
+
return false;
|
|
10809
|
+
const meta = this._meta;
|
|
10810
|
+
const thisCid = this[meta.cid];
|
|
10811
|
+
const otherCid = other[meta.cid];
|
|
10812
|
+
if (thisCid !== undefined &&
|
|
10813
|
+
otherCid !== undefined &&
|
|
10814
|
+
Types.isEqual(thisCid, otherCid))
|
|
10815
|
+
return true;
|
|
10816
|
+
if (meta.isEntityType()) {
|
|
10817
|
+
const thisKey = this.key();
|
|
10818
|
+
const otherKey = other.key();
|
|
10819
|
+
if (thisKey !== undefined &&
|
|
10820
|
+
otherKey !== undefined &&
|
|
10821
|
+
Types.isEqual(thisKey, otherKey))
|
|
10822
|
+
return true;
|
|
10823
|
+
}
|
|
10824
|
+
else if (meta.isComplexType()) {
|
|
10825
|
+
const thisJson = this.toJSON();
|
|
10826
|
+
const otherJson = other.toJSON();
|
|
10827
|
+
if (Types.isEqual(thisJson, otherJson))
|
|
10828
|
+
return true;
|
|
10829
|
+
}
|
|
10830
|
+
return false;
|
|
10718
10831
|
}
|
|
10719
10832
|
//#endregion
|
|
10720
10833
|
//#region Collection Tools
|
|
@@ -11601,10 +11714,10 @@ class ODataClient {
|
|
|
11601
11714
|
put(resource, body, options = {}) {
|
|
11602
11715
|
return this.request('PUT', resource, addBody(options, body));
|
|
11603
11716
|
}
|
|
11604
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.
|
|
11605
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.
|
|
11717
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ODataClient, deps: [{ token: i1.HttpClient }, { token: ODataConfigLoader }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
11718
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ODataClient }); }
|
|
11606
11719
|
}
|
|
11607
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.
|
|
11720
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ODataClient, decorators: [{
|
|
11608
11721
|
type: Injectable
|
|
11609
11722
|
}], ctorParameters: function () { return [{ type: i1.HttpClient }, { type: ODataConfigLoader }]; } });
|
|
11610
11723
|
|
|
@@ -11856,10 +11969,10 @@ class ODataServiceFactory {
|
|
|
11856
11969
|
return new (class extends ODataSingletonService {
|
|
11857
11970
|
})(this.client, singletonName, apiNameOrEntityType);
|
|
11858
11971
|
}
|
|
11859
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.
|
|
11860
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.
|
|
11972
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ODataServiceFactory, deps: [{ token: ODataClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
11973
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ODataServiceFactory }); }
|
|
11861
11974
|
}
|
|
11862
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.
|
|
11975
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ODataServiceFactory, decorators: [{
|
|
11863
11976
|
type: Injectable
|
|
11864
11977
|
}], ctorParameters: function () { return [{ type: ODataClient }]; } });
|
|
11865
11978
|
|
|
@@ -11886,11 +11999,11 @@ class ODataModule {
|
|
|
11886
11999
|
],
|
|
11887
12000
|
};
|
|
11888
12001
|
}
|
|
11889
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.
|
|
11890
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.
|
|
11891
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.
|
|
12002
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
12003
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.3", ngImport: i0, type: ODataModule, imports: [CommonModule, HttpClientModule] }); }
|
|
12004
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ODataModule, providers: [ODataClient, ODataServiceFactory], imports: [CommonModule, HttpClientModule] }); }
|
|
11892
12005
|
}
|
|
11893
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.
|
|
12006
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.3", ngImport: i0, type: ODataModule, decorators: [{
|
|
11894
12007
|
type: NgModule,
|
|
11895
12008
|
args: [{
|
|
11896
12009
|
imports: [CommonModule, HttpClientModule],
|