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