angular-odata 0.99.2 → 0.99.5

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.
Files changed (43) hide show
  1. package/esm2020/lib/cache/cache.mjs +2 -2
  2. package/esm2020/lib/client.mjs +3 -3
  3. package/esm2020/lib/models/collection.mjs +33 -44
  4. package/esm2020/lib/models/model.mjs +33 -37
  5. package/esm2020/lib/models/options.mjs +11 -1
  6. package/esm2020/lib/module.mjs +4 -4
  7. package/esm2020/lib/resources/query/builder.mjs +2 -1
  8. package/esm2020/lib/resources/query/expressions/base.mjs +1 -1
  9. package/esm2020/lib/resources/query/expressions/compute.mjs +13 -6
  10. package/esm2020/lib/resources/query/expressions/expand.mjs +77 -13
  11. package/esm2020/lib/resources/query/expressions/filter.mjs +11 -5
  12. package/esm2020/lib/resources/query/expressions/orderby.mjs +11 -3
  13. package/esm2020/lib/resources/query/expressions/search.mjs +15 -3
  14. package/esm2020/lib/resources/query/expressions/select.mjs +10 -5
  15. package/esm2020/lib/resources/query/expressions/syntax.mjs +42 -9
  16. package/esm2020/lib/resources/query/handlers.mjs +13 -13
  17. package/esm2020/lib/resources/query/options.mjs +33 -36
  18. package/esm2020/lib/resources/types/entity.mjs +3 -3
  19. package/esm2020/lib/schema/enum-type.mjs +9 -1
  20. package/esm2020/lib/services/entity-set.mjs +6 -6
  21. package/esm2020/lib/services/factory.mjs +3 -3
  22. package/esm2020/lib/types.mjs +2 -1
  23. package/esm2020/lib/utils/objects.mjs +5 -1
  24. package/fesm2015/angular-odata.mjs +337 -199
  25. package/fesm2015/angular-odata.mjs.map +1 -1
  26. package/fesm2020/angular-odata.mjs +337 -203
  27. package/fesm2020/angular-odata.mjs.map +1 -1
  28. package/lib/models/collection.d.ts +4 -2
  29. package/lib/models/options.d.ts +9 -7
  30. package/lib/resources/query/builder.d.ts +1 -0
  31. package/lib/resources/query/expressions/base.d.ts +1 -0
  32. package/lib/resources/query/expressions/compute.d.ts +3 -2
  33. package/lib/resources/query/expressions/expand.d.ts +40 -12
  34. package/lib/resources/query/expressions/filter.d.ts +22 -21
  35. package/lib/resources/query/expressions/orderby.d.ts +4 -2
  36. package/lib/resources/query/expressions/search.d.ts +5 -2
  37. package/lib/resources/query/expressions/select.d.ts +3 -2
  38. package/lib/resources/query/expressions/syntax.d.ts +12 -2
  39. package/lib/resources/query/handlers.d.ts +12 -12
  40. package/lib/resources/query/options.d.ts +10 -8
  41. package/lib/schema/enum-type.d.ts +6 -0
  42. package/lib/types.d.ts +1 -0
  43. package/package.json +1 -1
@@ -34,6 +34,7 @@ var QueryOptionNames;
34
34
  QueryOptionNames["skip"] = "skip";
35
35
  QueryOptionNames["skiptoken"] = "skiptoken";
36
36
  QueryOptionNames["format"] = "format";
37
+ QueryOptionNames["levels"] = "levels";
37
38
  QueryOptionNames["count"] = "count";
38
39
  })(QueryOptionNames || (QueryOptionNames = {}));
39
40
  const NONE_PARSER = {
@@ -214,7 +215,7 @@ class ODataCache {
214
215
  return of(cached);
215
216
  }
216
217
  else {
217
- return throwError('No Cached');
218
+ return throwError(() => new Error('No Cached'));
218
219
  }
219
220
  }
220
221
  if (policy === 'cache-first' ||
@@ -746,6 +747,7 @@ function buildExpand(expands, { aliases, escape = false }) {
746
747
  case 'levels':
747
748
  case 'count':
748
749
  case 'top':
750
+ case 'skip':
749
751
  value = `${expands[key]}`;
750
752
  break;
751
753
  default:
@@ -1332,6 +1334,10 @@ const Objects = {
1332
1334
  if (typeof target != 'object' || target == null) {
1333
1335
  return target;
1334
1336
  }
1337
+ if (Types.isObject(target) && 'clone' in target) {
1338
+ // target is a cloneable object
1339
+ return target.clone();
1340
+ }
1335
1341
  const type = Types.rawType(target);
1336
1342
  let cloneTarget = null;
1337
1343
  if (map.get(target)) {
@@ -1462,17 +1468,33 @@ class Field$1 {
1462
1468
  constructor(name = '') {
1463
1469
  this.name = name;
1464
1470
  }
1465
- static factory() {
1466
- const h = new Field$1();
1467
- return new Proxy({ _name: '' }, h);
1471
+ static factory(name = '') {
1472
+ return new Proxy({ _name: name }, new Field$1());
1468
1473
  }
1469
- get(target, p) {
1474
+ get(target, key) {
1470
1475
  let name = target['_name'];
1471
- if (p === 'render') {
1476
+ if (key === 'render') {
1472
1477
  return ({ prefix }) => prefix ? `${prefix}/${name}` : name;
1473
1478
  }
1474
- name = name ? `${name}/${p}` : p;
1475
- return new Proxy({ _name: name }, this);
1479
+ else if (key === 'clone') {
1480
+ return () => Field$1.factory(name);
1481
+ }
1482
+ else if (key === Symbol.toStringTag) {
1483
+ return () => 'Field';
1484
+ }
1485
+ else if (key === 'toJSON') {
1486
+ return () => ({
1487
+ $type: Types.rawType(this),
1488
+ name: name,
1489
+ });
1490
+ }
1491
+ else {
1492
+ name = name ? `${name}/${key}` : key;
1493
+ return new Proxy({ _name: name }, this);
1494
+ }
1495
+ }
1496
+ has(target, key) {
1497
+ return ['toJSON', 'clone', 'render'].includes(key) || key in target;
1476
1498
  }
1477
1499
  }
1478
1500
  function applyMixins(derivedCtor, constructors) {
@@ -1511,6 +1533,7 @@ class Function {
1511
1533
  }
1512
1534
  toJSON() {
1513
1535
  return {
1536
+ $type: Types.rawType(this),
1514
1537
  name: this.name,
1515
1538
  values: this.values,
1516
1539
  normalize: this.normalize,
@@ -1519,12 +1542,15 @@ class Function {
1519
1542
  render({ aliases, escape, prefix, }) {
1520
1543
  let [field, ...values] = this.values;
1521
1544
  field = render(field, { aliases, escape, prefix });
1522
- let params = [
1545
+ const params = [
1523
1546
  field,
1524
1547
  ...values.map((v) => render(v, { aliases, escape, prefix, normalize: this.normalize })),
1525
1548
  ];
1526
1549
  return `${this.name}(${params.join(', ')})`;
1527
1550
  }
1551
+ clone() {
1552
+ return new Function(this.name, this.values.map((v) => Objects.clone(v)), this.normalize, this.escape);
1553
+ }
1528
1554
  }
1529
1555
  class StringAndCollectionFunctions {
1530
1556
  concat(field, value, normalize) {
@@ -1665,6 +1691,7 @@ class Operator {
1665
1691
  }
1666
1692
  toJSON() {
1667
1693
  return {
1694
+ $type: Types.rawType(this),
1668
1695
  op: this.op,
1669
1696
  values: this.values,
1670
1697
  normalize: this.normalize,
@@ -1693,6 +1720,9 @@ class Operator {
1693
1720
  }
1694
1721
  return `${this.op}(${left})`;
1695
1722
  }
1723
+ clone() {
1724
+ return new Operator(this.op, this.values.map((v) => Objects.clone(v)), this.normalize);
1725
+ }
1696
1726
  }
1697
1727
  class LogicalOperators {
1698
1728
  eq(left, right, normalize) {
@@ -1760,12 +1790,16 @@ class Grouping {
1760
1790
  }
1761
1791
  toJSON() {
1762
1792
  return {
1793
+ $type: Types.rawType(this),
1763
1794
  group: this.group.toJSON(),
1764
1795
  };
1765
1796
  }
1766
1797
  render({ aliases, escape, prefix, }) {
1767
1798
  return `(${render(this.group, { aliases, escape, prefix })})`;
1768
1799
  }
1800
+ clone() {
1801
+ return new Grouping(Objects.clone(this.group));
1802
+ }
1769
1803
  }
1770
1804
  class Lambda {
1771
1805
  constructor(op, values, alias) {
@@ -1778,6 +1812,7 @@ class Lambda {
1778
1812
  }
1779
1813
  toJSON() {
1780
1814
  return {
1815
+ $type: Types.rawType(this),
1781
1816
  op: this.op,
1782
1817
  values: this.values,
1783
1818
  alias: this.alias,
@@ -1793,6 +1828,9 @@ class Lambda {
1793
1828
  prefix: alias,
1794
1829
  })})`;
1795
1830
  }
1831
+ clone() {
1832
+ return new Lambda(this.op, this.values.map((v) => Objects.clone(v)), this.alias);
1833
+ }
1796
1834
  }
1797
1835
  class LambdaOperators {
1798
1836
  any(field, value, alias) {
@@ -1839,16 +1877,23 @@ class ComputeExpression extends Expression {
1839
1877
  static s() {
1840
1878
  return Field$1.factory();
1841
1879
  }
1842
- static compute(opts) {
1880
+ static compute(opts, current) {
1843
1881
  return opts({
1844
1882
  s: ComputeExpression.s(),
1845
1883
  e: ComputeExpression.e,
1846
- });
1884
+ }, current);
1847
1885
  }
1848
1886
  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(',');
1887
+ let children = this._children.map((n) => n.render({ aliases, escape, prefix }));
1888
+ return this.names
1889
+ .map((name, index) => `${children[index]} as ${name}`)
1890
+ .join(',');
1891
+ }
1892
+ clone() {
1893
+ return new ComputeExpression({
1894
+ children: this._children.map((c) => c.clone()),
1895
+ names: [...this.names],
1896
+ });
1852
1897
  }
1853
1898
  _add(name, node) {
1854
1899
  this.names.push(name);
@@ -1876,13 +1921,13 @@ class FilterExpression extends Expression {
1876
1921
  static e(connector = 'and') {
1877
1922
  return new FilterExpression({ connector });
1878
1923
  }
1879
- static filter(opts) {
1924
+ static filter(opts, current) {
1880
1925
  return opts({
1881
1926
  s: FilterExpression.s(),
1882
1927
  e: FilterExpression.e,
1883
1928
  o: operators,
1884
1929
  f: functions,
1885
- });
1930
+ }, current);
1886
1931
  }
1887
1932
  toJSON() {
1888
1933
  return {
@@ -1906,6 +1951,13 @@ class FilterExpression extends Expression {
1906
1951
  }
1907
1952
  return content;
1908
1953
  }
1954
+ clone() {
1955
+ return new FilterExpression({
1956
+ children: this._children.map((c) => c.clone()),
1957
+ connector: this._connector,
1958
+ negated: this._negated,
1959
+ });
1960
+ }
1909
1961
  _add(node, connector) {
1910
1962
  if (connector !== undefined && this._connector !== connector) {
1911
1963
  let children = [];
@@ -2032,6 +2084,9 @@ class OrderByField {
2032
2084
  render({ aliases, escape, prefix, }) {
2033
2085
  return `${render(this.field, { aliases, escape, prefix })} ${this.order}`;
2034
2086
  }
2087
+ clone() {
2088
+ return new OrderByField(this.field.clone(), this.order);
2089
+ }
2035
2090
  }
2036
2091
  class OrderByExpression extends Expression {
2037
2092
  constructor({ children, } = {}) {
@@ -2043,11 +2098,11 @@ class OrderByExpression extends Expression {
2043
2098
  static s() {
2044
2099
  return Field$1.factory();
2045
2100
  }
2046
- static orderBy(opts) {
2101
+ static orderBy(opts, current) {
2047
2102
  return opts({
2048
2103
  s: OrderByExpression.s(),
2049
2104
  e: OrderByExpression.e,
2050
- });
2105
+ }, current);
2051
2106
  }
2052
2107
  _add(node) {
2053
2108
  this._children.push(node);
@@ -2059,6 +2114,11 @@ class OrderByExpression extends Expression {
2059
2114
  .join(`,`);
2060
2115
  return content;
2061
2116
  }
2117
+ clone() {
2118
+ return new OrderByExpression({
2119
+ children: this._children.map((c) => c.clone()),
2120
+ });
2121
+ }
2062
2122
  ascending(field) {
2063
2123
  return this._add(new OrderByField(field, 'asc'));
2064
2124
  }
@@ -2076,12 +2136,16 @@ class SearchTerm {
2076
2136
  }
2077
2137
  toJSON() {
2078
2138
  return {
2139
+ $type: Types.rawType(this),
2079
2140
  value: this.value,
2080
2141
  };
2081
2142
  }
2082
2143
  render({ aliases, escape, prefix, }) {
2083
2144
  return `${render(this.value, { aliases, escape, prefix })}`;
2084
2145
  }
2146
+ clone() {
2147
+ return new SearchTerm(this.value);
2148
+ }
2085
2149
  }
2086
2150
  class SearchExpression extends Expression {
2087
2151
  constructor({ children, connector, negated, } = {}) {
@@ -2092,10 +2156,10 @@ class SearchExpression extends Expression {
2092
2156
  static e(connector = 'AND') {
2093
2157
  return new SearchExpression({ connector });
2094
2158
  }
2095
- static search(opts) {
2159
+ static search(opts, current) {
2096
2160
  return opts({
2097
2161
  e: SearchExpression.e,
2098
- });
2162
+ }, current);
2099
2163
  }
2100
2164
  _add(node, connector) {
2101
2165
  if (connector !== undefined && this._connector !== connector) {
@@ -2146,6 +2210,13 @@ class SearchExpression extends Expression {
2146
2210
  .join(` ${this._connector} `);
2147
2211
  return content;
2148
2212
  }
2213
+ clone() {
2214
+ return new SearchExpression({
2215
+ children: this._children.map((c) => c.clone()),
2216
+ connector: this._connector,
2217
+ negated: this._negated,
2218
+ });
2219
+ }
2149
2220
  toJSON() {
2150
2221
  return {
2151
2222
  children: this._children.map((c) => c.toJSON()),
@@ -2178,9 +2249,45 @@ class SearchExpression extends Expression {
2178
2249
  }
2179
2250
  }
2180
2251
 
2252
+ class SelectExpression extends Expression {
2253
+ constructor({ children, } = {}) {
2254
+ super({ children });
2255
+ }
2256
+ static e() {
2257
+ return new SelectExpression();
2258
+ }
2259
+ static s() {
2260
+ return Field$1.factory();
2261
+ }
2262
+ static select(builder, current) {
2263
+ return builder({
2264
+ s: SelectExpression.s(),
2265
+ e: SelectExpression.e,
2266
+ }, current);
2267
+ }
2268
+ render({ aliases, escape, prefix, } = {}) {
2269
+ return this._children
2270
+ .map((n) => n.render({ aliases, escape, prefix }))
2271
+ .join(',');
2272
+ }
2273
+ clone() {
2274
+ return new SelectExpression({
2275
+ children: this._children.map((c) => c.clone()),
2276
+ });
2277
+ }
2278
+ _add(node) {
2279
+ this._children.push(node);
2280
+ return this;
2281
+ }
2282
+ field(field) {
2283
+ return this._add(field);
2284
+ }
2285
+ }
2286
+
2181
2287
  class ExpandField {
2182
- constructor(field) {
2288
+ constructor(field, values = {}) {
2183
2289
  this.field = field;
2290
+ this.values = values;
2184
2291
  }
2185
2292
  get [Symbol.toStringTag]() {
2186
2293
  return 'ExpandField';
@@ -2191,14 +2298,66 @@ class ExpandField {
2191
2298
  };
2192
2299
  }
2193
2300
  render({ aliases, escape, prefix, }) {
2194
- return `${render(this.field, { aliases, escape, prefix })}`;
2301
+ const params = [
2302
+ QueryOptionNames.select,
2303
+ QueryOptionNames.expand,
2304
+ QueryOptionNames.filter,
2305
+ QueryOptionNames.search,
2306
+ QueryOptionNames.orderBy,
2307
+ QueryOptionNames.skip,
2308
+ QueryOptionNames.top,
2309
+ QueryOptionNames.levels,
2310
+ ]
2311
+ .filter((key) => !Types.isEmpty(this.values[key]))
2312
+ .reduce((acc, key) => {
2313
+ let value = this.values[key];
2314
+ if (Types.rawType(value).endsWith('Expression')) {
2315
+ value = value.render({ aliases, prefix, escape });
2316
+ }
2317
+ return Object.assign(acc, { [key]: value });
2318
+ }, {});
2319
+ let expand = `${render(this.field, { aliases, escape, prefix })}`;
2320
+ if (!Types.isEmpty(params)) {
2321
+ expand = `${expand}(${Object.keys(params)
2322
+ .map((key) => `$${key}=${params[key]}`)
2323
+ .join(';')})`;
2324
+ }
2325
+ return expand;
2326
+ }
2327
+ clone() {
2328
+ const values = Object.keys(this.values).reduce((acc, key) => Object.assign(acc, { [key]: Objects.clone(this.values[key]) }), {});
2329
+ return new ExpandField(this.field.clone(), values);
2330
+ }
2331
+ select(opts) {
2332
+ return this.option(QueryOptionNames.select, SelectExpression.select(opts, this.values[QueryOptionNames.select]));
2333
+ }
2334
+ expand(opts) {
2335
+ return this.option(QueryOptionNames.expand, ExpandExpression.expand(opts, this.values[QueryOptionNames.expand]));
2336
+ }
2337
+ filter(opts) {
2338
+ return this.option(QueryOptionNames.filter, FilterExpression.filter(opts, this.values[QueryOptionNames.filter]));
2339
+ }
2340
+ search(opts) {
2341
+ return this.option(QueryOptionNames.search, SearchExpression.search(opts, this.values[QueryOptionNames.search]));
2342
+ }
2343
+ orderBy(opts) {
2344
+ return this.option(QueryOptionNames.orderBy, OrderByExpression.orderBy(opts, this.values[QueryOptionNames.orderBy]));
2345
+ }
2346
+ skip(n) {
2347
+ return this.option(QueryOptionNames.skip, n);
2348
+ }
2349
+ top(n) {
2350
+ return this.option(QueryOptionNames.top, n);
2351
+ }
2352
+ levels(n) {
2353
+ return this.option(QueryOptionNames.levels, n);
2354
+ }
2355
+ // Option Handler
2356
+ option(name, opts) {
2357
+ if (opts !== undefined)
2358
+ this.values[name] = opts;
2359
+ return this.values[name];
2195
2360
  }
2196
- select() { }
2197
- filter() { }
2198
- levels() { }
2199
- orderBy() { }
2200
- top() { }
2201
- skip() { }
2202
2361
  }
2203
2362
  class ExpandExpression extends Expression {
2204
2363
  constructor({ children, } = {}) {
@@ -2210,17 +2369,22 @@ class ExpandExpression extends Expression {
2210
2369
  static s() {
2211
2370
  return Field$1.factory();
2212
2371
  }
2213
- static expand(opts) {
2372
+ static expand(opts, current) {
2214
2373
  return opts({
2215
2374
  s: ExpandExpression.s(),
2216
2375
  e: ExpandExpression.e,
2217
- });
2376
+ }, current);
2218
2377
  }
2219
2378
  render({ aliases, escape, prefix, } = {}) {
2220
2379
  return this._children
2221
2380
  .map((n) => n.render({ aliases, escape, prefix }))
2222
2381
  .join(',');
2223
2382
  }
2383
+ clone() {
2384
+ return new ExpandExpression({
2385
+ children: this._children.map((c) => c.clone()),
2386
+ });
2387
+ }
2224
2388
  _add(node) {
2225
2389
  this._children.push(node);
2226
2390
  return this;
@@ -2233,36 +2397,6 @@ class ExpandExpression extends Expression {
2233
2397
  }
2234
2398
  }
2235
2399
 
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
- }
2264
- }
2265
-
2266
2400
  class ODataQueryOptionHandler {
2267
2401
  constructor(o, n) {
2268
2402
  this.o = o;
@@ -2360,19 +2494,19 @@ class ODataQueryOptionsHandler {
2360
2494
  }
2361
2495
  select(opts) {
2362
2496
  if (Types.isFunction(opts)) {
2363
- return this.options.expression(QueryOptionNames.select, SelectExpression.select(opts));
2497
+ return this.options.expression(QueryOptionNames.select, SelectExpression.select(opts, this.options.expression(QueryOptionNames.select)));
2364
2498
  }
2365
2499
  return this.options.option(QueryOptionNames.select, opts);
2366
2500
  }
2367
2501
  expand(opts) {
2368
2502
  if (Types.isFunction(opts)) {
2369
- return this.options.expression(QueryOptionNames.expand, ExpandExpression.expand(opts));
2503
+ return this.options.expression(QueryOptionNames.expand, ExpandExpression.expand(opts, this.options.expression(QueryOptionNames.expand)));
2370
2504
  }
2371
2505
  return this.options.option(QueryOptionNames.expand, opts);
2372
2506
  }
2373
2507
  compute(opts) {
2374
2508
  if (Types.isFunction(opts)) {
2375
- return this.options.expression(QueryOptionNames.compute, ComputeExpression.compute(opts));
2509
+ return this.options.expression(QueryOptionNames.compute, ComputeExpression.compute(opts, this.options.expression(QueryOptionNames.compute)));
2376
2510
  }
2377
2511
  return this.options.option(QueryOptionNames.compute, opts);
2378
2512
  }
@@ -2384,19 +2518,19 @@ class ODataQueryOptionsHandler {
2384
2518
  }
2385
2519
  search(opts) {
2386
2520
  if (Types.isFunction(opts)) {
2387
- return this.options.expression(QueryOptionNames.search, SearchExpression.search(opts));
2521
+ return this.options.expression(QueryOptionNames.search, SearchExpression.search(opts, this.options.expression(QueryOptionNames.search)));
2388
2522
  }
2389
2523
  return this.options.option(QueryOptionNames.search, opts);
2390
2524
  }
2391
2525
  filter(opts) {
2392
2526
  if (Types.isFunction(opts)) {
2393
- return this.options.expression(QueryOptionNames.filter, FilterExpression.filter(opts));
2527
+ return this.options.expression(QueryOptionNames.filter, FilterExpression.filter(opts, this.options.expression(QueryOptionNames.filter)));
2394
2528
  }
2395
2529
  return this.options.option(QueryOptionNames.filter, opts);
2396
2530
  }
2397
2531
  orderBy(opts) {
2398
2532
  if (Types.isFunction(opts)) {
2399
- return this.options.expression(QueryOptionNames.orderBy, OrderByExpression.orderBy(opts));
2533
+ return this.options.option(QueryOptionNames.orderBy, OrderByExpression.orderBy(opts, this.options.expression(QueryOptionNames.orderBy)));
2400
2534
  }
2401
2535
  return this.options.option(QueryOptionNames.orderBy, opts);
2402
2536
  }
@@ -2424,22 +2558,22 @@ class ODataQueryOptionsHandler {
2424
2558
  }
2425
2559
  apply(query) {
2426
2560
  if (query.select !== undefined) {
2427
- this.select(query.select);
2561
+ this.options.option(QueryOptionNames.select, query.select);
2428
2562
  }
2429
2563
  if (query.expand !== undefined) {
2430
- this.expand(query.expand);
2564
+ this.options.option(QueryOptionNames.expand, query.expand);
2431
2565
  }
2432
2566
  if (query.transform !== undefined) {
2433
- this.transform(query.transform);
2567
+ this.options.option(QueryOptionNames.transform, query.transform);
2434
2568
  }
2435
2569
  if (query.search !== undefined) {
2436
- this.search(query.search);
2570
+ this.options.option(QueryOptionNames.search, query.search);
2437
2571
  }
2438
2572
  if (query.filter !== undefined) {
2439
- this.filter(query.filter);
2573
+ this.options.option(QueryOptionNames.filter, query.filter);
2440
2574
  }
2441
2575
  if (query.orderBy !== undefined) {
2442
- this.orderBy(query.orderBy);
2576
+ this.options.option(QueryOptionNames.orderBy, query.orderBy);
2443
2577
  }
2444
2578
  this.paging(query);
2445
2579
  }
@@ -2447,7 +2581,7 @@ class ODataQueryOptionsHandler {
2447
2581
 
2448
2582
  class ODataQueryOptions {
2449
2583
  constructor(options) {
2450
- this.options = options || {};
2584
+ this.values = options || {};
2451
2585
  }
2452
2586
  // Params
2453
2587
  pathAndParams(escape = false) {
@@ -2465,11 +2599,11 @@ class ODataQueryOptions {
2465
2599
  QueryOptionNames.expand,
2466
2600
  QueryOptionNames.format,
2467
2601
  ]
2468
- .filter((key) => !Types.isEmpty(this.options[key]))
2602
+ .filter((key) => !Types.isEmpty(this.values[key]))
2469
2603
  .reduce((acc, key) => {
2470
- let value = this.options[key];
2471
- if (Types.rawType(value) === 'Expression') {
2472
- value = value.render(aliases);
2604
+ let value = this.values[key];
2605
+ if (Types.rawType(value).endsWith('Expression')) {
2606
+ value = value.render({ aliases });
2473
2607
  }
2474
2608
  return Object.assign(acc, { [key]: value });
2475
2609
  }, {});
@@ -2484,63 +2618,60 @@ class ODataQueryOptions {
2484
2618
  .join('&'));
2485
2619
  }
2486
2620
  toJSON() {
2487
- return Object.keys(this.options).reduce((acc, key) => {
2488
- let value = this.options[key];
2489
- if (Types.rawType(value) === 'Expression') {
2490
- value = value.toJSON();
2491
- }
2621
+ return Object.keys(this.values).reduce((acc, key) => {
2622
+ let value = this.values[key];
2623
+ value =
2624
+ Types.isObject(value) && 'toJSON' in value ? value.toJSON() : value;
2492
2625
  return Object.assign(acc, { [key]: value });
2493
2626
  }, {});
2494
2627
  }
2495
2628
  toQueryArguments() {
2496
2629
  return {
2497
- select: this.options[QueryOptionNames.select],
2498
- expand: this.options[QueryOptionNames.expand],
2499
- transform: this.options[QueryOptionNames.transform],
2500
- compute: this.options[QueryOptionNames.compute],
2501
- search: this.options[QueryOptionNames.search],
2502
- filter: this.options[QueryOptionNames.filter],
2503
- orderBy: this.options[QueryOptionNames.orderBy],
2504
- top: this.options[QueryOptionNames.top],
2505
- skip: this.options[QueryOptionNames.skip],
2506
- skiptoken: this.options[QueryOptionNames.skiptoken],
2630
+ select: this.values[QueryOptionNames.select],
2631
+ expand: this.values[QueryOptionNames.expand],
2632
+ transform: this.values[QueryOptionNames.transform],
2633
+ compute: this.values[QueryOptionNames.compute],
2634
+ search: this.values[QueryOptionNames.search],
2635
+ filter: this.values[QueryOptionNames.filter],
2636
+ orderBy: this.values[QueryOptionNames.orderBy],
2637
+ top: this.values[QueryOptionNames.top],
2638
+ skip: this.values[QueryOptionNames.skip],
2639
+ skiptoken: this.values[QueryOptionNames.skiptoken],
2507
2640
  };
2508
2641
  }
2509
2642
  clone() {
2510
- const options = Object.keys(this.options).reduce((acc, key) => {
2511
- let value = this.options[key];
2512
- if (Types.rawType(value) !== 'Expression') {
2513
- value = Objects.clone(value);
2514
- }
2515
- return Object.assign(acc, { [key]: value });
2516
- }, {});
2643
+ const options = Object.keys(this.values).reduce((acc, key) => Object.assign(acc, { [key]: Objects.clone(this.values[key]) }), {});
2517
2644
  return new ODataQueryOptions(options);
2518
2645
  }
2519
2646
  // Set Renderable
2520
2647
  expression(name, exp) {
2521
- return (this.options[name] = exp);
2648
+ if (exp !== undefined)
2649
+ this.values[name] = exp;
2650
+ return this.values[name];
2522
2651
  }
2523
2652
  // Option Handler
2524
2653
  option(name, opts) {
2525
2654
  if (opts !== undefined)
2526
- this.options[name] = opts;
2527
- return new ODataQueryOptionHandler(this.options, name);
2655
+ this.values[name] = opts;
2656
+ return new ODataQueryOptionHandler(this.values, name);
2528
2657
  }
2529
2658
  // Query Options tools
2530
2659
  has(name) {
2531
- return this.options[name] !== undefined;
2660
+ return this.values[name] !== undefined;
2532
2661
  }
2533
2662
  remove(...names) {
2534
- names.forEach((name) => this.option(name).clear());
2663
+ names.forEach((name) => {
2664
+ delete this.values[name];
2665
+ });
2535
2666
  }
2536
2667
  keep(...names) {
2537
- this.options = Object.keys(this.options)
2668
+ this.values = Object.keys(this.values)
2538
2669
  .filter((k) => names.indexOf(k) !== -1)
2539
- .reduce((acc, k) => Object.assign(acc, { [k]: this.options[k] }), {});
2670
+ .reduce((acc, k) => Object.assign(acc, { [k]: this.values[k] }), {});
2540
2671
  }
2541
2672
  // Clear
2542
2673
  clear() {
2543
- this.options = {};
2674
+ this.values = {};
2544
2675
  }
2545
2676
  }
2546
2677
 
@@ -4126,6 +4257,14 @@ class ODataEnumType extends ODataSchemaElement {
4126
4257
  findFieldByValue(value) {
4127
4258
  return this.fields().find((f) => f.value === value);
4128
4259
  }
4260
+ /**
4261
+ * Find a fields by flag.
4262
+ * @param value The value of the field
4263
+ * @returns The fields with the given flag
4264
+ */
4265
+ findFieldsByValue(value) {
4266
+ return this.fields().filter((f) => Boolean(f.value & value));
4267
+ }
4129
4268
  /**
4130
4269
  * Map the fields of the enum type.
4131
4270
  * @param mapper Function that maps the value to the new value
@@ -7044,7 +7183,7 @@ class ODataEntityResource extends ODataResource {
7044
7183
  if (castSchema !== undefined &&
7045
7184
  baseSchema !== undefined &&
7046
7185
  !castSchema.isSubtypeOf(baseSchema))
7047
- throw new Error(`Cannot cast to ${type}`);
7186
+ throw new Error(`cast: Cannot cast to ${type}`);
7048
7187
  const segments = this.cloneSegments();
7049
7188
  segments.add(PathSegmentNames.type, type).type(type);
7050
7189
  return new ODataEntityResource(this.api, {
@@ -7085,7 +7224,7 @@ class ODataEntityResource extends ODataResource {
7085
7224
  }
7086
7225
  fetch(options) {
7087
7226
  if (!this.hasKey())
7088
- return throwError('Entity resource without key');
7227
+ return throwError(() => new Error('fetch: Entity resource without key'));
7089
7228
  return this.get(options);
7090
7229
  }
7091
7230
  fetchEntity(options) {
@@ -7403,6 +7542,16 @@ class ODataModelEvent {
7403
7542
  : '')
7404
7543
  .join('');
7405
7544
  }
7545
+ //Identifies the current model for the event
7546
+ get currentModel() {
7547
+ const link = this.chain.find(c => ODataModelOptions.isModel(c[0]));
7548
+ return link !== undefined ? link[0] : undefined;
7549
+ }
7550
+ //Identifies the current collection for the event
7551
+ get currentCollection() {
7552
+ const link = this.chain.find(c => ODataModelOptions.isCollection(c[0]));
7553
+ return link !== undefined ? link[0] : undefined;
7554
+ }
7406
7555
  }
7407
7556
  const BUBBLING = [
7408
7557
  'change',
@@ -8328,7 +8477,7 @@ class ODataCollection {
8328
8477
  if (model === undefined && Klass.model !== null)
8329
8478
  model = Klass.model;
8330
8479
  if (model === undefined)
8331
- throw new Error('Collection need model');
8480
+ throw new Error('Collection: Collection need model');
8332
8481
  this._model = model;
8333
8482
  // Parent
8334
8483
  if (parent !== undefined) {
@@ -8366,7 +8515,7 @@ class ODataCollection {
8366
8515
  if (this._resource !== null &&
8367
8516
  this._resource.type() !== resource.type() &&
8368
8517
  !this._resource.isSubtypeOf(resource))
8369
- throw new Error(`Can't reattach ${this._resource.type()} to ${resource.type()}`);
8518
+ throw new Error(`attach: Can't reattach ${this._resource.type()} to ${resource.type()}`);
8370
8519
  this._entries.forEach(({ model }) => {
8371
8520
  const mr = this._model.meta.modelResourceFactory(resource.cloneQuery());
8372
8521
  model.attach(mr);
@@ -8386,7 +8535,7 @@ class ODataCollection {
8386
8535
  const query = this.resource().cloneQuery();
8387
8536
  let resource = this._model.meta.collectionResourceFactory(query);
8388
8537
  if (resource === undefined)
8389
- throw new Error('Collection does not have associated EntitySet endpoint');
8538
+ throw new Error('asEntitySet: Collection does not have associated EntitySet endpoint');
8390
8539
  // Store parent and resource
8391
8540
  const store = { parent: this._parent, resource: this._resource };
8392
8541
  // Replace parent and resource
@@ -8463,18 +8612,9 @@ class ODataCollection {
8463
8612
  fetch(_a = {}) {
8464
8613
  var { withCount } = _a, options = __rest(_a, ["withCount"]);
8465
8614
  const resource = this.resource();
8466
- if (resource === undefined)
8467
- return throwError('fetch: Resource is undefined');
8468
- let obs$;
8469
- if (resource instanceof ODataEntitySetResource) {
8470
- obs$ = resource.fetch(Object.assign({ withCount }, options));
8471
- }
8472
- else if (resource instanceof ODataNavigationPropertyResource) {
8473
- obs$ = resource.fetch(Object.assign({ responseType: 'entities', withCount }, options));
8474
- }
8475
- else {
8476
- obs$ = resource.fetch(Object.assign({ responseType: 'entities', withCount }, options));
8477
- }
8615
+ const obs$ = resource instanceof ODataEntitySetResource
8616
+ ? resource.fetch(Object.assign({ withCount }, options))
8617
+ : resource.fetch(Object.assign({ responseType: 'entities', withCount }, options));
8478
8618
  this.events$.emit(new ODataModelEvent('request', { collection: this, value: obs$ }));
8479
8619
  return obs$.pipe(map(({ entities, annots }) => {
8480
8620
  this._annotations = annots;
@@ -8485,10 +8625,8 @@ class ODataCollection {
8485
8625
  }
8486
8626
  fetchAll(options) {
8487
8627
  const resource = this.resource();
8488
- if (resource === undefined)
8489
- return throwError('fetchAll: Resource is undefined');
8490
8628
  if (resource instanceof ODataPropertyResource)
8491
- return throwError('fetchAll: Resource is ODataPropertyResource');
8629
+ return throwError(() => new Error('fetchAll: Resource is ODataPropertyResource'));
8492
8630
  const obs$ = resource.fetchAll(options);
8493
8631
  this.events$.emit(new ODataModelEvent('request', {
8494
8632
  collection: this,
@@ -8513,10 +8651,8 @@ class ODataCollection {
8513
8651
  save(_a = {}) {
8514
8652
  var { relModel = false, method } = _a, options = __rest(_a, ["relModel", "method"]);
8515
8653
  const resource = this.resource();
8516
- if (resource === undefined)
8517
- return throwError('saveAll: Resource is undefined');
8518
8654
  if (resource instanceof ODataPropertyResource)
8519
- return throwError('fetchAll: Resource is ODataPropertyResource');
8655
+ return throwError(() => new Error('save: Resource is ODataPropertyResource'));
8520
8656
  let toDestroyEntity = [];
8521
8657
  let toRemoveReference = [];
8522
8658
  let toDestroyContained = [];
@@ -8884,26 +9020,26 @@ class ODataCollection {
8884
9020
  return func.call(params, Object.assign({ responseType }, options));
8885
9021
  }
8886
9022
  }
8887
- return throwError(`Can't function without ODataEntitySetResource`);
9023
+ return throwError(() => new Error(`callFunction: Can't function without ODataEntitySetResource`));
8888
9024
  }
8889
9025
  callAction(name, params, responseType, _a = {}) {
8890
9026
  var options = __rest(_a, []);
8891
9027
  const resource = this.resource();
8892
- if (resource instanceof ODataEntitySetResource) {
8893
- const action = resource.action(name);
8894
- action.query((q) => q.apply(options));
8895
- switch (responseType) {
8896
- case 'property':
8897
- return action.callProperty(params, options);
8898
- case 'model':
8899
- return action.callModel(params, options);
8900
- case 'collection':
8901
- return action.callCollection(params, options);
8902
- default:
8903
- return action.call(params, Object.assign({ responseType }, options));
8904
- }
9028
+ if (!(resource instanceof ODataEntitySetResource)) {
9029
+ return throwError(() => new Error(`callAction: Can't action without ODataEntitySetResource`));
9030
+ }
9031
+ const action = resource.action(name);
9032
+ action.query((q) => q.apply(options));
9033
+ switch (responseType) {
9034
+ case 'property':
9035
+ return action.callProperty(params, options);
9036
+ case 'model':
9037
+ return action.callModel(params, options);
9038
+ case 'collection':
9039
+ return action.callCollection(params, options);
9040
+ default:
9041
+ return action.call(params, Object.assign({ responseType }, options));
8905
9042
  }
8906
- return throwError(`Can't action without ODataEntitySetResource`);
8907
9043
  }
8908
9044
  _unsubscribe(entry) {
8909
9045
  if (entry.subscription) {
@@ -8913,7 +9049,7 @@ class ODataCollection {
8913
9049
  }
8914
9050
  _subscribe(entry) {
8915
9051
  if (entry.subscription) {
8916
- throw new Error('Subscription already exists');
9052
+ throw new Error('Collection: Subscription already exists');
8917
9053
  }
8918
9054
  entry.subscription = entry.model.events$.subscribe((event) => {
8919
9055
  var _a;
@@ -8963,12 +9099,18 @@ class ODataCollection {
8963
9099
  },
8964
9100
  };
8965
9101
  }
8966
- filter(predicate) {
9102
+ filter(predicate, thisArg) {
8967
9103
  return this.models().filter(predicate);
8968
9104
  }
8969
- find(predicate) {
9105
+ map(callbackfn, thisArg) {
9106
+ return this.models().map(callbackfn, thisArg);
9107
+ }
9108
+ find(predicate, thisArg) {
8970
9109
  return this.models().find(predicate);
8971
9110
  }
9111
+ reduce(callbackfn, initialValue) {
9112
+ return this.models().reduce(callbackfn, initialValue);
9113
+ }
8972
9114
  first() {
8973
9115
  return this.models()[0];
8974
9116
  }
@@ -9076,7 +9218,7 @@ class ODataModel {
9076
9218
  this.events$ = new EventEmitter();
9077
9219
  const Klass = this.constructor;
9078
9220
  if (Klass.meta === undefined)
9079
- throw new Error(`Can't create model without metadata`);
9221
+ throw new Error(`ODataModel: Can't create model without metadata`);
9080
9222
  this._meta = Klass.meta;
9081
9223
  this._meta.bind(this, { parent, resource, annots });
9082
9224
  // Client Id
@@ -9116,19 +9258,19 @@ class ODataModel {
9116
9258
  navigationProperty(name) {
9117
9259
  const field = this._meta.field(name);
9118
9260
  if (field === undefined || !field.navigation)
9119
- throw Error(`Can't find navigation property ${name}`);
9261
+ throw Error(`navigationProperty: Can't find navigation property ${name}`);
9120
9262
  const resource = this.resource();
9121
9263
  if (!(resource instanceof ODataEntityResource) || !resource.hasKey())
9122
- throw Error("Can't get navigation without ODataEntityResource with key");
9264
+ throw Error("navigationProperty: Can't get navigation without ODataEntityResource with key");
9123
9265
  return field.resourceFactory(resource);
9124
9266
  }
9125
9267
  property(name) {
9126
9268
  const field = this._meta.field(name);
9127
9269
  if (field === undefined || field.navigation)
9128
- throw Error(`Can't find property ${name}`);
9270
+ throw Error(`property: Can't find property ${name}`);
9129
9271
  const resource = this.resource();
9130
9272
  if (!(resource instanceof ODataEntityResource) || !resource.hasKey())
9131
- throw Error("Can't get property without ODataEntityResource with key");
9273
+ throw Error("property: Can't get property without ODataEntityResource with key");
9132
9274
  return field.resourceFactory(resource);
9133
9275
  }
9134
9276
  attach(resource) {
@@ -9274,11 +9416,11 @@ class ODataModel {
9274
9416
  var options = __rest(_a, []);
9275
9417
  let resource = this.resource();
9276
9418
  if (resource === undefined)
9277
- return throwError('fetch: Resource is undefined');
9419
+ return throwError(() => new Error('fetch: Resource is undefined'));
9278
9420
  let obs$;
9279
9421
  if (resource instanceof ODataEntityResource) {
9280
9422
  if (!resource.hasKey())
9281
- return throwError("fetch: Can't fetch model without key");
9423
+ return throwError(() => new Error("fetch: Can't fetch model without key"));
9282
9424
  obs$ = resource.fetch(options);
9283
9425
  }
9284
9426
  else if (resource instanceof ODataNavigationPropertyResource) {
@@ -9293,50 +9435,46 @@ class ODataModel {
9293
9435
  var { method, navigation = false, validate = true } = _a, options = __rest(_a, ["method", "navigation", "validate"]);
9294
9436
  let resource = this.resource();
9295
9437
  if (resource === undefined)
9296
- return throwError('save: Resource is undefined');
9438
+ return throwError(() => new Error('save: Resource is undefined'));
9297
9439
  if (!(resource instanceof ODataEntityResource ||
9298
9440
  resource instanceof ODataNavigationPropertyResource))
9299
- return throwError('save: Resource type ODataEntityResource/ODataNavigationPropertyResource needed');
9441
+ return throwError(() => new Error('save: Resource type ODataEntityResource/ODataNavigationPropertyResource needed'));
9300
9442
  // Resolve method and resource key
9301
9443
  if (method === undefined && this.schema().isCompoundKey())
9302
- return throwError('save: Composite key require a specific method, use create/update/modify');
9444
+ return throwError(() => new Error('save: Composite key require a specific method, use create/update/modify'));
9303
9445
  method = method || (!resource.hasKey() ? 'create' : 'update');
9304
9446
  if (resource instanceof ODataEntityResource &&
9305
9447
  (method === 'update' || method === 'modify') &&
9306
9448
  !resource.hasKey())
9307
- return throwError('save: Update/Patch require entity key');
9449
+ return throwError(() => new Error('save: Update/Patch require entity key'));
9308
9450
  if (resource instanceof ODataNavigationPropertyResource ||
9309
9451
  method === 'create')
9310
9452
  resource.clearKey();
9311
- let obs$;
9312
- if (!validate || this.isValid({ method, navigation })) {
9313
- const _entity = this.toEntity({
9314
- changes_only: method === 'modify',
9315
- field_mapping: true,
9316
- include_concurrency: true,
9317
- include_navigation: navigation,
9318
- });
9319
- obs$ = (method === 'create'
9320
- ? resource.create(_entity, options)
9321
- : method === 'modify'
9322
- ? resource.modify(_entity, Object.assign({ etag: this.annots().etag }, options))
9323
- : resource.update(_entity, Object.assign({ etag: this.annots().etag }, options))).pipe(map(({ entity, annots }) => ({ entity: entity || _entity, annots })));
9324
- }
9325
- else {
9326
- obs$ = throwError(this._errors);
9453
+ if (validate && !this.isValid({ method, navigation })) {
9454
+ return throwError(() => new Error('save: Validation errors'));
9327
9455
  }
9328
- return this._request(obs$);
9456
+ const _entity = this.toEntity({
9457
+ changes_only: method === 'modify',
9458
+ field_mapping: true,
9459
+ include_concurrency: true,
9460
+ include_navigation: navigation,
9461
+ });
9462
+ return this._request((method === 'create'
9463
+ ? resource.create(_entity, options)
9464
+ : method === 'modify'
9465
+ ? resource.modify(_entity, Object.assign({ etag: this.annots().etag }, options))
9466
+ : resource.update(_entity, Object.assign({ etag: this.annots().etag }, options))).pipe(map(({ entity, annots }) => ({ entity: entity || _entity, annots }))));
9329
9467
  }
9330
9468
  destroy(_a = {}) {
9331
9469
  var options = __rest(_a, []);
9332
9470
  let resource = this.resource();
9333
9471
  if (resource === undefined)
9334
- return throwError('destroy: Resource is undefined');
9472
+ return throwError(() => new Error('destroy: Resource is undefined'));
9335
9473
  if (!(resource instanceof ODataEntityResource ||
9336
9474
  resource instanceof ODataNavigationPropertyResource))
9337
- return throwError('destroy: Resource type ODataEntityResource/ODataNavigationPropertyResource needed');
9475
+ return throwError(() => new Error('destroy: Resource type ODataEntityResource/ODataNavigationPropertyResource needed'));
9338
9476
  if (!resource.hasKey())
9339
- return throwError("destroy: Can't destroy model without key");
9477
+ return throwError(() => new Error("destroy: Can't destroy model without key"));
9340
9478
  const _entity = this.toEntity({ field_mapping: true });
9341
9479
  const obs$ = resource
9342
9480
  .destroy(Object.assign({ etag: this.annots().etag }, options))
@@ -9370,7 +9508,7 @@ class ODataModel {
9370
9508
  var options = __rest(_a, []);
9371
9509
  const resource = this.resource();
9372
9510
  if (!(resource instanceof ODataEntityResource) || !resource.hasKey())
9373
- return throwError("Can't call function without ODataEntityResource with key");
9511
+ return throwError(() => new Error("callFunction: Can't call function without ODataEntityResource with key"));
9374
9512
  const func = resource.function(name).query((q) => q.apply(options));
9375
9513
  switch (responseType) {
9376
9514
  case 'property':
@@ -9387,7 +9525,7 @@ class ODataModel {
9387
9525
  var options = __rest(_a, []);
9388
9526
  const resource = this.resource();
9389
9527
  if (!(resource instanceof ODataEntityResource) || !resource.hasKey())
9390
- return throwError("Can't call action without ODataEntityResource with key");
9528
+ return throwError(() => new Error("callAction: Can't call action without ODataEntityResource with key"));
9391
9529
  const action = resource.action(name).query((q) => q.apply(options));
9392
9530
  switch (responseType) {
9393
9531
  case 'property':
@@ -9404,7 +9542,7 @@ class ODataModel {
9404
9542
  cast(type) {
9405
9543
  const resource = this.resource();
9406
9544
  if (!(resource instanceof ODataEntityResource))
9407
- throw new Error(`Can't cast to derived model without ODataEntityResource`);
9545
+ throw new Error(`cast: Can't cast to derived model without ODataEntityResource`);
9408
9546
  return resource
9409
9547
  .cast(type)
9410
9548
  .asModel(this.toEntity(INCLUDE_DEEP), { annots: this.annots() });
@@ -9424,7 +9562,7 @@ class ODataModel {
9424
9562
  getValue(name, options) {
9425
9563
  const field = this._meta.field(name);
9426
9564
  if (field === undefined || field.navigation)
9427
- throw Error(`Can't find property ${name}`);
9565
+ throw Error(`getValue: Can't find property ${name}`);
9428
9566
  let value = this[name];
9429
9567
  if (value === undefined) {
9430
9568
  const prop = field.resourceFactory(this.resource());
@@ -9471,7 +9609,7 @@ class ODataModel {
9471
9609
  getReference(name) {
9472
9610
  const field = this._meta.field(name);
9473
9611
  if (field === undefined || !field.navigation)
9474
- throw Error(`Can't find navigation property ${name}`);
9612
+ throw Error(`getReference: Can't find navigation property ${name}`);
9475
9613
  let model = this[name];
9476
9614
  if (model === undefined) {
9477
9615
  const value = field.collection ? [] : this.referenced(field);
@@ -10278,9 +10416,9 @@ class ODataClient {
10278
10416
  return this.request('PUT', resource, addBody(options, body));
10279
10417
  }
10280
10418
  }
10281
- ODataClient.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ODataClient, deps: [{ token: i1.HttpClient }, { token: ODataSettings }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
10282
- ODataClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ODataClient, providedIn: 'root' });
10283
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ODataClient, decorators: [{
10419
+ ODataClient.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ODataClient, deps: [{ token: i1.HttpClient }, { token: ODataSettings }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
10420
+ ODataClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ODataClient, providedIn: 'root' });
10421
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ODataClient, decorators: [{
10284
10422
  type: Injectable,
10285
10423
  args: [{
10286
10424
  providedIn: 'root',
@@ -10393,7 +10531,7 @@ class ODataEntitySetService extends ODataEntityService {
10393
10531
  update(key, attrs, options) {
10394
10532
  const res = this.entity(key);
10395
10533
  if (!res.hasKey())
10396
- return throwError('Resource without key');
10534
+ return throwError(() => new Error('update: Resource without key'));
10397
10535
  return res.update(attrs, options);
10398
10536
  }
10399
10537
  /**
@@ -10406,7 +10544,7 @@ class ODataEntitySetService extends ODataEntityService {
10406
10544
  modify(key, attrs, options) {
10407
10545
  const res = this.entity(key);
10408
10546
  if (!res.hasKey())
10409
- return throwError('Resource without key');
10547
+ return throwError(() => new Error('modify: Resource without key'));
10410
10548
  return res.modify(attrs, options);
10411
10549
  }
10412
10550
  /**
@@ -10418,7 +10556,7 @@ class ODataEntitySetService extends ODataEntityService {
10418
10556
  destroy(key, options) {
10419
10557
  const res = this.entity(key);
10420
10558
  if (!res.hasKey())
10421
- return throwError('Resource without key');
10559
+ return throwError(() => new Error('destroy: Resource without key'));
10422
10560
  return res.destroy(options);
10423
10561
  }
10424
10562
  //#region Shortcuts
@@ -10449,12 +10587,12 @@ class ODataEntitySetService extends ODataEntityService {
10449
10587
  var { etag, method } = _a, options = __rest(_a, ["etag", "method"]);
10450
10588
  let schema = this.structuredTypeSchema;
10451
10589
  if (method === undefined && schema !== undefined && schema.isCompoundKey())
10452
- return throwError('Composite key require a specific method, use create/update/patch');
10590
+ return throwError(() => new Error('save: Composite key require a specific method, use create/update/patch'));
10453
10591
  let key = schema && schema.resolveKey(attrs);
10454
10592
  if (method === undefined)
10455
10593
  method = key !== undefined ? 'update' : 'create';
10456
10594
  if ((method === 'update' || method === 'modify') && key === undefined)
10457
- return throwError("Can't update/patch entity without key");
10595
+ return throwError(() => new Error("save: Can't update/patch entity without key"));
10458
10596
  return method === 'create'
10459
10597
  ? this.create(attrs, options)
10460
10598
  : method === 'modify'
@@ -10532,9 +10670,9 @@ class ODataServiceFactory {
10532
10670
  })(this.client, singletonName, apiNameOrEntityType);
10533
10671
  }
10534
10672
  }
10535
- ODataServiceFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ODataServiceFactory, deps: [{ token: ODataClient }], target: i0.ɵɵFactoryTarget.Injectable });
10536
- ODataServiceFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ODataServiceFactory });
10537
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ODataServiceFactory, decorators: [{
10673
+ ODataServiceFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ODataServiceFactory, deps: [{ token: ODataClient }], target: i0.ɵɵFactoryTarget.Injectable });
10674
+ ODataServiceFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ODataServiceFactory });
10675
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ODataServiceFactory, decorators: [{
10538
10676
  type: Injectable
10539
10677
  }], ctorParameters: function () { return [{ type: ODataClient }]; } });
10540
10678
 
@@ -10558,10 +10696,10 @@ class ODataModule {
10558
10696
  };
10559
10697
  }
10560
10698
  }
10561
- ODataModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
10562
- ODataModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ODataModule, imports: [HttpClientModule] });
10563
- ODataModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ODataModule, providers: [ODataClient, ODataServiceFactory], imports: [[HttpClientModule]] });
10564
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ODataModule, decorators: [{
10699
+ ODataModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
10700
+ ODataModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ODataModule, imports: [HttpClientModule] });
10701
+ ODataModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ODataModule, providers: [ODataClient, ODataServiceFactory], imports: [[HttpClientModule]] });
10702
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ODataModule, decorators: [{
10565
10703
  type: NgModule,
10566
10704
  args: [{
10567
10705
  imports: [HttpClientModule],