angular-odata 0.95.0 → 0.99.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/esm2020/lib/resources/query/expressions/base.mjs +20 -0
- package/esm2020/lib/resources/query/expressions/compute.mjs +38 -0
- package/esm2020/lib/resources/query/expressions/expand.mjs +57 -0
- package/esm2020/lib/resources/query/expressions/filter.mjs +154 -0
- package/esm2020/lib/resources/query/expressions/index.mjs +7 -0
- package/esm2020/lib/resources/query/expressions/orderby.mjs +54 -0
- package/esm2020/lib/resources/query/expressions/search.mjs +113 -0
- package/esm2020/lib/resources/query/expressions/select.mjs +32 -0
- package/esm2020/lib/resources/query/expressions/syntax.mjs +371 -0
- package/esm2020/lib/resources/query/handlers.mjs +16 -14
- package/esm2020/lib/resources/query/options.mjs +2 -2
- package/esm2020/lib/resources/resource.mjs +2 -2
- package/esm2020/lib/resources/types/batch.mjs +31 -10
- package/fesm2015/angular-odata.mjs +359 -123
- package/fesm2015/angular-odata.mjs.map +1 -1
- package/fesm2020/angular-odata.mjs +359 -123
- package/fesm2020/angular-odata.mjs.map +1 -1
- package/lib/resources/query/expressions/base.d.ts +19 -0
- package/lib/resources/query/expressions/compute.d.ts +26 -0
- package/lib/resources/query/expressions/expand.d.ts +40 -0
- package/lib/resources/query/expressions/filter.d.ts +58 -0
- package/lib/resources/query/expressions/index.d.ts +6 -0
- package/lib/resources/query/expressions/orderby.d.ts +37 -0
- package/lib/resources/query/expressions/search.d.ts +47 -0
- package/lib/resources/query/expressions/select.d.ts +21 -0
- package/lib/resources/query/{syntax.d.ts → expressions/syntax.d.ts} +8 -6
- package/lib/resources/query/handlers.d.ts +24 -9
- package/lib/resources/types/batch.d.ts +9 -0
- package/package.json +1 -1
- package/esm2020/lib/resources/query/expressions.mjs +0 -207
- package/esm2020/lib/resources/query/syntax.mjs +0 -406
- package/lib/resources/query/expressions.d.ts +0 -63
|
@@ -1438,7 +1438,26 @@ const Urls = {
|
|
|
1438
1438
|
},
|
|
1439
1439
|
};
|
|
1440
1440
|
|
|
1441
|
-
|
|
1441
|
+
class Expression {
|
|
1442
|
+
constructor({ children, } = {}) {
|
|
1443
|
+
this._children = children || [];
|
|
1444
|
+
}
|
|
1445
|
+
get [Symbol.toStringTag]() {
|
|
1446
|
+
return 'Expression';
|
|
1447
|
+
}
|
|
1448
|
+
children() {
|
|
1449
|
+
return this._children;
|
|
1450
|
+
}
|
|
1451
|
+
length() {
|
|
1452
|
+
return this._children.length;
|
|
1453
|
+
}
|
|
1454
|
+
toJSON() {
|
|
1455
|
+
return {
|
|
1456
|
+
children: this._children.map((c) => c.toJSON()),
|
|
1457
|
+
};
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1442
1461
|
class Field$1 {
|
|
1443
1462
|
constructor(name = '') {
|
|
1444
1463
|
this.name = name;
|
|
@@ -1748,39 +1767,6 @@ class Grouping {
|
|
|
1748
1767
|
return `(${render(this.group, { aliases, escape, prefix })})`;
|
|
1749
1768
|
}
|
|
1750
1769
|
}
|
|
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
|
-
}
|
|
1777
|
-
}
|
|
1778
|
-
*/
|
|
1779
|
-
class GroupingOperators {
|
|
1780
|
-
grouping(value) {
|
|
1781
|
-
return new Grouping(value);
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
1770
|
class Lambda {
|
|
1785
1771
|
constructor(op, values, alias) {
|
|
1786
1772
|
this.op = op;
|
|
@@ -1821,7 +1807,6 @@ class ODataOperators {
|
|
|
1821
1807
|
applyMixins(ODataOperators, [
|
|
1822
1808
|
LogicalOperators,
|
|
1823
1809
|
ArithmeticOperators,
|
|
1824
|
-
GroupingOperators,
|
|
1825
1810
|
LambdaOperators,
|
|
1826
1811
|
]);
|
|
1827
1812
|
const operators = new ODataOperators();
|
|
@@ -1843,33 +1828,60 @@ class ODataSyntax {
|
|
|
1843
1828
|
applyMixins(ODataSyntax, [ODataOperators, ODataFunctions]);
|
|
1844
1829
|
const syntax = new ODataSyntax();
|
|
1845
1830
|
|
|
1846
|
-
class Expression {
|
|
1831
|
+
class ComputeExpression extends Expression {
|
|
1832
|
+
constructor({ children, names, } = {}) {
|
|
1833
|
+
super({ children });
|
|
1834
|
+
this.names = names || [];
|
|
1835
|
+
}
|
|
1836
|
+
static e() {
|
|
1837
|
+
return new ComputeExpression();
|
|
1838
|
+
}
|
|
1839
|
+
static s() {
|
|
1840
|
+
return Field$1.factory();
|
|
1841
|
+
}
|
|
1842
|
+
static compute(opts) {
|
|
1843
|
+
return opts({
|
|
1844
|
+
s: ComputeExpression.s(),
|
|
1845
|
+
e: ComputeExpression.e,
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
render({ aliases, escape, prefix, } = {}) {
|
|
1849
|
+
let children = this._children
|
|
1850
|
+
.map((n) => n.render({ aliases, escape, prefix }));
|
|
1851
|
+
return this.names.map((name, index) => `${children[index]} as ${name}`).join(',');
|
|
1852
|
+
}
|
|
1853
|
+
_add(name, node) {
|
|
1854
|
+
this.names.push(name);
|
|
1855
|
+
this._children.push(node);
|
|
1856
|
+
return this;
|
|
1857
|
+
}
|
|
1858
|
+
field(name, opts) {
|
|
1859
|
+
const node = opts({
|
|
1860
|
+
o: operators,
|
|
1861
|
+
f: functions,
|
|
1862
|
+
});
|
|
1863
|
+
return this._add(name, node);
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
class FilterExpression extends Expression {
|
|
1847
1868
|
constructor({ children, connector, negated, } = {}) {
|
|
1848
|
-
|
|
1869
|
+
super({ children });
|
|
1849
1870
|
this._connector = connector || 'and';
|
|
1850
1871
|
this._negated = negated || false;
|
|
1851
1872
|
}
|
|
1852
|
-
get [Symbol.toStringTag]() {
|
|
1853
|
-
return 'Expression';
|
|
1854
|
-
}
|
|
1855
1873
|
static s() {
|
|
1856
1874
|
return Field$1.factory();
|
|
1857
1875
|
}
|
|
1858
1876
|
static e(connector = 'and') {
|
|
1859
|
-
return new
|
|
1860
|
-
}
|
|
1861
|
-
static o() {
|
|
1862
|
-
return operators;
|
|
1863
|
-
}
|
|
1864
|
-
static f() {
|
|
1865
|
-
return functions;
|
|
1877
|
+
return new FilterExpression({ connector });
|
|
1866
1878
|
}
|
|
1867
1879
|
static filter(opts) {
|
|
1868
1880
|
return opts({
|
|
1869
|
-
s:
|
|
1870
|
-
e:
|
|
1871
|
-
o:
|
|
1872
|
-
f:
|
|
1881
|
+
s: FilterExpression.s(),
|
|
1882
|
+
e: FilterExpression.e,
|
|
1883
|
+
o: operators,
|
|
1884
|
+
f: functions,
|
|
1873
1885
|
});
|
|
1874
1886
|
}
|
|
1875
1887
|
toJSON() {
|
|
@@ -1879,18 +1891,12 @@ class Expression {
|
|
|
1879
1891
|
negated: this._negated,
|
|
1880
1892
|
};
|
|
1881
1893
|
}
|
|
1882
|
-
children() {
|
|
1883
|
-
return this._children;
|
|
1884
|
-
}
|
|
1885
1894
|
connector() {
|
|
1886
1895
|
return this._connector;
|
|
1887
1896
|
}
|
|
1888
1897
|
negated() {
|
|
1889
1898
|
return this._negated;
|
|
1890
1899
|
}
|
|
1891
|
-
length() {
|
|
1892
|
-
return this._children.length;
|
|
1893
|
-
}
|
|
1894
1900
|
render({ aliases, escape, prefix, } = {}) {
|
|
1895
1901
|
let content = this._children
|
|
1896
1902
|
.map((n) => n.render({ aliases, escape, prefix }))
|
|
@@ -1908,37 +1914,37 @@ class Expression {
|
|
|
1908
1914
|
children = [...this._children];
|
|
1909
1915
|
}
|
|
1910
1916
|
else {
|
|
1911
|
-
let exp = new
|
|
1917
|
+
let exp = new FilterExpression({
|
|
1912
1918
|
children: this._children,
|
|
1913
1919
|
connector: this._connector,
|
|
1914
1920
|
negated: this._negated,
|
|
1915
1921
|
});
|
|
1916
1922
|
if (exp.length() > 1) {
|
|
1917
|
-
children.push(
|
|
1923
|
+
children.push(new Grouping(exp));
|
|
1918
1924
|
}
|
|
1919
1925
|
else {
|
|
1920
1926
|
children.push(exp);
|
|
1921
1927
|
}
|
|
1922
1928
|
}
|
|
1923
1929
|
}
|
|
1924
|
-
if (node instanceof
|
|
1930
|
+
if (node instanceof FilterExpression &&
|
|
1925
1931
|
(node.connector() === connector || node.length() === 1)) {
|
|
1926
1932
|
children = [...children, ...node.children()];
|
|
1927
1933
|
}
|
|
1928
1934
|
else {
|
|
1929
|
-
children.push(
|
|
1935
|
+
children.push(new Grouping(node));
|
|
1930
1936
|
}
|
|
1931
1937
|
this._connector = connector;
|
|
1932
1938
|
this._children = children;
|
|
1933
1939
|
}
|
|
1934
|
-
else if (node instanceof
|
|
1940
|
+
else if (node instanceof FilterExpression &&
|
|
1935
1941
|
!node.negated() &&
|
|
1936
1942
|
(node.connector() === connector || node.length() === 1)) {
|
|
1937
1943
|
this._children = [...this._children, ...node.children()];
|
|
1938
1944
|
}
|
|
1939
1945
|
else {
|
|
1940
|
-
this._children.push(node instanceof
|
|
1941
|
-
?
|
|
1946
|
+
this._children.push(node instanceof FilterExpression && !node.negated()
|
|
1947
|
+
? new Grouping(node)
|
|
1942
1948
|
: node);
|
|
1943
1949
|
}
|
|
1944
1950
|
return this;
|
|
@@ -1950,7 +1956,7 @@ class Expression {
|
|
|
1950
1956
|
return this._add(exp, 'and');
|
|
1951
1957
|
}
|
|
1952
1958
|
not(exp) {
|
|
1953
|
-
const notExp = new
|
|
1959
|
+
const notExp = new FilterExpression({
|
|
1954
1960
|
children: exp.children(),
|
|
1955
1961
|
connector: exp.connector(),
|
|
1956
1962
|
negated: true,
|
|
@@ -1993,14 +1999,14 @@ class Expression {
|
|
|
1993
1999
|
any(left, opts, alias) {
|
|
1994
2000
|
const exp = opts({
|
|
1995
2001
|
s: Field$1.factory(),
|
|
1996
|
-
e:
|
|
2002
|
+
e: FilterExpression.e,
|
|
1997
2003
|
});
|
|
1998
2004
|
return this._add(syntax.any(left, exp, alias));
|
|
1999
2005
|
}
|
|
2000
2006
|
all(left, opts, alias) {
|
|
2001
2007
|
const exp = opts({
|
|
2002
2008
|
s: Field$1.factory(),
|
|
2003
|
-
e:
|
|
2009
|
+
e: FilterExpression.e,
|
|
2004
2010
|
});
|
|
2005
2011
|
return this._add(syntax.all(left, exp, alias));
|
|
2006
2012
|
}
|
|
@@ -2008,45 +2014,254 @@ class Expression {
|
|
|
2008
2014
|
return this._add(syntax.isof(left, type));
|
|
2009
2015
|
}
|
|
2010
2016
|
}
|
|
2011
|
-
/*
|
|
2012
|
-
export class FilterExpression<T> extends Expression<T> {
|
|
2013
|
-
constructor({
|
|
2014
|
-
children,
|
|
2015
|
-
connector,
|
|
2016
|
-
negated,
|
|
2017
|
-
}: {
|
|
2018
|
-
children?: Renderable[];
|
|
2019
|
-
connector?: Connector;
|
|
2020
|
-
negated?: boolean;
|
|
2021
|
-
} = {}) {
|
|
2022
|
-
super({ children, connector, negated });
|
|
2023
|
-
}
|
|
2024
|
-
|
|
2025
|
-
get [Symbol.toStringTag]() {
|
|
2026
|
-
return 'FilterExpression';
|
|
2027
|
-
}
|
|
2028
2017
|
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2018
|
+
class OrderByField {
|
|
2019
|
+
constructor(field, order) {
|
|
2020
|
+
this.field = field;
|
|
2021
|
+
this.order = order;
|
|
2022
|
+
}
|
|
2023
|
+
get [Symbol.toStringTag]() {
|
|
2024
|
+
return 'OrderByField';
|
|
2025
|
+
}
|
|
2026
|
+
toJSON() {
|
|
2027
|
+
return {
|
|
2028
|
+
field: this.field.toJSON(),
|
|
2029
|
+
order: this.order,
|
|
2030
|
+
};
|
|
2031
|
+
}
|
|
2032
|
+
render({ aliases, escape, prefix, }) {
|
|
2033
|
+
return `${render(this.field, { aliases, escape, prefix })} ${this.order}`;
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
class OrderByExpression extends Expression {
|
|
2037
|
+
constructor({ children, } = {}) {
|
|
2038
|
+
super({ children });
|
|
2039
|
+
}
|
|
2040
|
+
static e() {
|
|
2041
|
+
return new OrderByExpression();
|
|
2042
|
+
}
|
|
2043
|
+
static s() {
|
|
2044
|
+
return Field$1.factory();
|
|
2045
|
+
}
|
|
2046
|
+
static orderBy(opts) {
|
|
2047
|
+
return opts({
|
|
2048
|
+
s: OrderByExpression.s(),
|
|
2049
|
+
e: OrderByExpression.e,
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2052
|
+
_add(node) {
|
|
2053
|
+
this._children.push(node);
|
|
2054
|
+
return this;
|
|
2055
|
+
}
|
|
2056
|
+
render({ aliases, escape, prefix, } = {}) {
|
|
2057
|
+
let content = this._children
|
|
2058
|
+
.map((n) => n.render({ aliases, escape, prefix }))
|
|
2059
|
+
.join(`,`);
|
|
2060
|
+
return content;
|
|
2061
|
+
}
|
|
2062
|
+
ascending(field) {
|
|
2063
|
+
return this._add(new OrderByField(field, 'asc'));
|
|
2064
|
+
}
|
|
2065
|
+
descending(field) {
|
|
2066
|
+
return this._add(new OrderByField(field, 'desc'));
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2032
2069
|
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2070
|
+
class SearchTerm {
|
|
2071
|
+
constructor(value) {
|
|
2072
|
+
this.value = value;
|
|
2073
|
+
}
|
|
2074
|
+
get [Symbol.toStringTag]() {
|
|
2075
|
+
return 'SearchTerm';
|
|
2076
|
+
}
|
|
2077
|
+
toJSON() {
|
|
2078
|
+
return {
|
|
2079
|
+
value: this.value,
|
|
2080
|
+
};
|
|
2081
|
+
}
|
|
2082
|
+
render({ aliases, escape, prefix, }) {
|
|
2083
|
+
return `${render(this.value, { aliases, escape, prefix })}`;
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
class SearchExpression extends Expression {
|
|
2087
|
+
constructor({ children, connector, negated, } = {}) {
|
|
2088
|
+
super({ children });
|
|
2089
|
+
this._connector = connector || 'AND';
|
|
2090
|
+
this._negated = negated || false;
|
|
2091
|
+
}
|
|
2092
|
+
static e(connector = 'AND') {
|
|
2093
|
+
return new SearchExpression({ connector });
|
|
2094
|
+
}
|
|
2095
|
+
static search(opts) {
|
|
2096
|
+
return opts({
|
|
2097
|
+
e: SearchExpression.e,
|
|
2098
|
+
});
|
|
2099
|
+
}
|
|
2100
|
+
_add(node, connector) {
|
|
2101
|
+
if (connector !== undefined && this._connector !== connector) {
|
|
2102
|
+
let children = [];
|
|
2103
|
+
if (this._children.length > 0) {
|
|
2104
|
+
if (this._children.length === 1) {
|
|
2105
|
+
children = [...this._children];
|
|
2106
|
+
}
|
|
2107
|
+
else {
|
|
2108
|
+
let exp = new SearchExpression({
|
|
2109
|
+
children: this._children,
|
|
2110
|
+
connector: this._connector,
|
|
2111
|
+
negated: this._negated,
|
|
2112
|
+
});
|
|
2113
|
+
if (exp.length() > 1) {
|
|
2114
|
+
children.push(new Grouping(exp));
|
|
2115
|
+
}
|
|
2116
|
+
else {
|
|
2117
|
+
children.push(exp);
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
if (node instanceof SearchExpression &&
|
|
2122
|
+
(node.connector() === connector || node.length() === 1)) {
|
|
2123
|
+
children = [...children, ...node.children()];
|
|
2124
|
+
}
|
|
2125
|
+
else {
|
|
2126
|
+
children.push(new Grouping(node));
|
|
2127
|
+
}
|
|
2128
|
+
this._connector = connector;
|
|
2129
|
+
this._children = children;
|
|
2130
|
+
}
|
|
2131
|
+
else if (node instanceof SearchExpression &&
|
|
2132
|
+
!node.negated() &&
|
|
2133
|
+
(node.connector() === connector || node.length() === 1)) {
|
|
2134
|
+
this._children = [...this._children, ...node.children()];
|
|
2135
|
+
}
|
|
2136
|
+
else {
|
|
2137
|
+
this._children.push(node instanceof SearchExpression && !node.negated()
|
|
2138
|
+
? new Grouping(node)
|
|
2139
|
+
: node);
|
|
2140
|
+
}
|
|
2141
|
+
return this;
|
|
2142
|
+
}
|
|
2143
|
+
render({ aliases, escape, prefix, } = {}) {
|
|
2144
|
+
let content = this._children
|
|
2145
|
+
.map((n) => n.render({ aliases, escape, prefix }))
|
|
2146
|
+
.join(` ${this._connector} `);
|
|
2147
|
+
return content;
|
|
2148
|
+
}
|
|
2149
|
+
toJSON() {
|
|
2150
|
+
return {
|
|
2151
|
+
children: this._children.map((c) => c.toJSON()),
|
|
2152
|
+
connector: this._connector,
|
|
2153
|
+
negated: this._negated,
|
|
2154
|
+
};
|
|
2155
|
+
}
|
|
2156
|
+
connector() {
|
|
2157
|
+
return this._connector;
|
|
2158
|
+
}
|
|
2159
|
+
negated() {
|
|
2160
|
+
return this._negated;
|
|
2161
|
+
}
|
|
2162
|
+
or(exp) {
|
|
2163
|
+
return this._add(exp, 'OR');
|
|
2164
|
+
}
|
|
2165
|
+
and(exp) {
|
|
2166
|
+
return this._add(exp, 'AND');
|
|
2167
|
+
}
|
|
2168
|
+
not(exp) {
|
|
2169
|
+
const notExp = new SearchExpression({
|
|
2170
|
+
children: exp.children(),
|
|
2171
|
+
connector: exp.connector(),
|
|
2172
|
+
negated: true,
|
|
2173
|
+
});
|
|
2174
|
+
return this._add(notExp, this._connector);
|
|
2175
|
+
}
|
|
2176
|
+
term(value) {
|
|
2177
|
+
return this._add(new SearchTerm(value));
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2036
2180
|
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2181
|
+
class ExpandField {
|
|
2182
|
+
constructor(field) {
|
|
2183
|
+
this.field = field;
|
|
2184
|
+
}
|
|
2185
|
+
get [Symbol.toStringTag]() {
|
|
2186
|
+
return 'ExpandField';
|
|
2187
|
+
}
|
|
2188
|
+
toJSON() {
|
|
2189
|
+
return {
|
|
2190
|
+
field: this.field.toJSON(),
|
|
2191
|
+
};
|
|
2192
|
+
}
|
|
2193
|
+
render({ aliases, escape, prefix, }) {
|
|
2194
|
+
return `${render(this.field, { aliases, escape, prefix })}`;
|
|
2195
|
+
}
|
|
2196
|
+
select() { }
|
|
2197
|
+
filter() { }
|
|
2198
|
+
levels() { }
|
|
2199
|
+
orderBy() { }
|
|
2200
|
+
top() { }
|
|
2201
|
+
skip() { }
|
|
2202
|
+
}
|
|
2203
|
+
class ExpandExpression extends Expression {
|
|
2204
|
+
constructor({ children, } = {}) {
|
|
2205
|
+
super({ children });
|
|
2206
|
+
}
|
|
2207
|
+
static e() {
|
|
2208
|
+
return new ExpandExpression();
|
|
2209
|
+
}
|
|
2210
|
+
static s() {
|
|
2211
|
+
return Field$1.factory();
|
|
2212
|
+
}
|
|
2213
|
+
static expand(opts) {
|
|
2214
|
+
return opts({
|
|
2215
|
+
s: ExpandExpression.s(),
|
|
2216
|
+
e: ExpandExpression.e,
|
|
2217
|
+
});
|
|
2218
|
+
}
|
|
2219
|
+
render({ aliases, escape, prefix, } = {}) {
|
|
2220
|
+
return this._children
|
|
2221
|
+
.map((n) => n.render({ aliases, escape, prefix }))
|
|
2222
|
+
.join(',');
|
|
2223
|
+
}
|
|
2224
|
+
_add(node) {
|
|
2225
|
+
this._children.push(node);
|
|
2226
|
+
return this;
|
|
2227
|
+
}
|
|
2228
|
+
field(field, opts) {
|
|
2229
|
+
let node = new ExpandField(field);
|
|
2230
|
+
if (opts !== undefined)
|
|
2231
|
+
opts(node);
|
|
2232
|
+
return this._add(node);
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2040
2235
|
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2236
|
+
class SelectExpression extends Expression {
|
|
2237
|
+
constructor({ children, } = {}) {
|
|
2238
|
+
super({ children });
|
|
2239
|
+
}
|
|
2240
|
+
static e() {
|
|
2241
|
+
return new SelectExpression();
|
|
2242
|
+
}
|
|
2243
|
+
static s() {
|
|
2244
|
+
return Field$1.factory();
|
|
2245
|
+
}
|
|
2246
|
+
static select(opts) {
|
|
2247
|
+
return opts({
|
|
2248
|
+
s: SelectExpression.s(),
|
|
2249
|
+
e: SelectExpression.e,
|
|
2250
|
+
});
|
|
2251
|
+
}
|
|
2252
|
+
render({ aliases, escape, prefix, } = {}) {
|
|
2253
|
+
return this._children
|
|
2254
|
+
.map((n) => n.render({ aliases, escape, prefix }))
|
|
2255
|
+
.join(',');
|
|
2256
|
+
}
|
|
2257
|
+
_add(node) {
|
|
2258
|
+
this._children.push(node);
|
|
2259
|
+
return this;
|
|
2260
|
+
}
|
|
2261
|
+
field(field) {
|
|
2262
|
+
return this._add(field);
|
|
2263
|
+
}
|
|
2048
2264
|
}
|
|
2049
|
-
*/
|
|
2050
2265
|
|
|
2051
2266
|
class ODataQueryOptionHandler {
|
|
2052
2267
|
constructor(o, n) {
|
|
@@ -2144,16 +2359,20 @@ class ODataQueryOptionsHandler {
|
|
|
2144
2359
|
return alias(value, name);
|
|
2145
2360
|
}
|
|
2146
2361
|
select(opts) {
|
|
2362
|
+
if (Types.isFunction(opts)) {
|
|
2363
|
+
return this.options.expression(QueryOptionNames.select, SelectExpression.select(opts));
|
|
2364
|
+
}
|
|
2147
2365
|
return this.options.option(QueryOptionNames.select, opts);
|
|
2148
2366
|
}
|
|
2149
2367
|
expand(opts) {
|
|
2368
|
+
if (Types.isFunction(opts)) {
|
|
2369
|
+
return this.options.expression(QueryOptionNames.expand, ExpandExpression.expand(opts));
|
|
2370
|
+
}
|
|
2150
2371
|
return this.options.option(QueryOptionNames.expand, opts);
|
|
2151
2372
|
}
|
|
2152
2373
|
compute(opts) {
|
|
2153
2374
|
if (Types.isFunction(opts)) {
|
|
2154
|
-
return this.options.expression(QueryOptionNames.compute, opts
|
|
2155
|
-
e: () => Expression.e(),
|
|
2156
|
-
}));
|
|
2375
|
+
return this.options.expression(QueryOptionNames.compute, ComputeExpression.compute(opts));
|
|
2157
2376
|
}
|
|
2158
2377
|
return this.options.option(QueryOptionNames.compute, opts);
|
|
2159
2378
|
}
|
|
@@ -2164,24 +2383,20 @@ class ODataQueryOptionsHandler {
|
|
|
2164
2383
|
return this.options.option(QueryOptionNames.transform, opts);
|
|
2165
2384
|
}
|
|
2166
2385
|
search(opts) {
|
|
2386
|
+
if (Types.isFunction(opts)) {
|
|
2387
|
+
return this.options.expression(QueryOptionNames.search, SearchExpression.search(opts));
|
|
2388
|
+
}
|
|
2167
2389
|
return this.options.option(QueryOptionNames.search, opts);
|
|
2168
2390
|
}
|
|
2169
2391
|
filter(opts) {
|
|
2170
2392
|
if (Types.isFunction(opts)) {
|
|
2171
|
-
return this.options.expression(QueryOptionNames.filter, opts
|
|
2172
|
-
s: Expression.s(),
|
|
2173
|
-
e: Expression.e,
|
|
2174
|
-
o: Expression.o(),
|
|
2175
|
-
f: Expression.f(),
|
|
2176
|
-
}));
|
|
2393
|
+
return this.options.expression(QueryOptionNames.filter, FilterExpression.filter(opts));
|
|
2177
2394
|
}
|
|
2178
2395
|
return this.options.option(QueryOptionNames.filter, opts);
|
|
2179
2396
|
}
|
|
2180
2397
|
orderBy(opts) {
|
|
2181
2398
|
if (Types.isFunction(opts)) {
|
|
2182
|
-
return this.options.expression(QueryOptionNames.orderBy, opts
|
|
2183
|
-
e: () => Expression.e(),
|
|
2184
|
-
}));
|
|
2399
|
+
return this.options.expression(QueryOptionNames.orderBy, OrderByExpression.orderBy(opts));
|
|
2185
2400
|
}
|
|
2186
2401
|
return this.options.option(QueryOptionNames.orderBy, opts);
|
|
2187
2402
|
}
|
|
@@ -2301,7 +2516,7 @@ class ODataQueryOptions {
|
|
|
2301
2516
|
}, {});
|
|
2302
2517
|
return new ODataQueryOptions(options);
|
|
2303
2518
|
}
|
|
2304
|
-
// Set
|
|
2519
|
+
// Set Renderable
|
|
2305
2520
|
expression(name, exp) {
|
|
2306
2521
|
return (this.options[name] = exp);
|
|
2307
2522
|
}
|
|
@@ -5858,14 +6073,7 @@ class ODataBatchResource extends ODataResource {
|
|
|
5858
6073
|
return new ODataBatchResource(api, { segments });
|
|
5859
6074
|
}
|
|
5860
6075
|
//#endregion
|
|
5861
|
-
|
|
5862
|
-
* Execute the batch request
|
|
5863
|
-
* @param ctx The context for the request
|
|
5864
|
-
* @param options The options of the batch request
|
|
5865
|
-
* @returns The result of execute the context
|
|
5866
|
-
*/
|
|
5867
|
-
exec(ctx, options) {
|
|
5868
|
-
// Store original requester
|
|
6076
|
+
storeRequester() {
|
|
5869
6077
|
const current = this.api.request;
|
|
5870
6078
|
// Switch to the batch requester
|
|
5871
6079
|
this.api.request = (req) => {
|
|
@@ -5876,13 +6084,31 @@ class ODataBatchResource extends ODataResource {
|
|
|
5876
6084
|
this._requests.push(new ODataBatchRequest(req));
|
|
5877
6085
|
return this._requests[this._requests.length - 1];
|
|
5878
6086
|
};
|
|
6087
|
+
return current;
|
|
6088
|
+
}
|
|
6089
|
+
restoreRequester(handler) {
|
|
6090
|
+
this.api.request = handler;
|
|
6091
|
+
}
|
|
6092
|
+
/**
|
|
6093
|
+
* Add to batch request
|
|
6094
|
+
* @param ctx The context for the request
|
|
6095
|
+
* @returns The result of execute the context
|
|
6096
|
+
*/
|
|
6097
|
+
add(ctx) {
|
|
6098
|
+
// Store original requester
|
|
6099
|
+
var handler = this.storeRequester();
|
|
5879
6100
|
// Execute the context
|
|
5880
6101
|
const obs$ = ctx(this);
|
|
5881
6102
|
// Restore original requester
|
|
5882
|
-
this.
|
|
6103
|
+
this.restoreRequester(handler);
|
|
6104
|
+
return obs$;
|
|
6105
|
+
}
|
|
6106
|
+
send(options) {
|
|
5883
6107
|
if (this._requests.length >= 0) {
|
|
5884
6108
|
const bound = Strings.uniqueId(BATCH_PREFIX);
|
|
5885
6109
|
const requests = this._requests;
|
|
6110
|
+
// Clean requests
|
|
6111
|
+
this._requests = [];
|
|
5886
6112
|
const headers = Http.mergeHttpHeaders((options && options.headers) || {}, {
|
|
5887
6113
|
[ODATA_VERSION]: VERSION_4_0,
|
|
5888
6114
|
[CONTENT_TYPE]: MULTIPART_MIXED_BOUNDARY + bound,
|
|
@@ -5903,6 +6129,16 @@ class ODataBatchResource extends ODataResource {
|
|
|
5903
6129
|
ODataBatchResource.handleResponse(requests, response);
|
|
5904
6130
|
});
|
|
5905
6131
|
}
|
|
6132
|
+
}
|
|
6133
|
+
/**
|
|
6134
|
+
* Execute the batch request
|
|
6135
|
+
* @param ctx The context for the request
|
|
6136
|
+
* @param options The options of the batch request
|
|
6137
|
+
* @returns The result of execute the context
|
|
6138
|
+
*/
|
|
6139
|
+
exec(ctx, options) {
|
|
6140
|
+
const obs$ = this.add(ctx);
|
|
6141
|
+
this.send(options);
|
|
5906
6142
|
return obs$;
|
|
5907
6143
|
}
|
|
5908
6144
|
body() {
|