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
@@ -33,6 +33,7 @@ var QueryOptionNames;
33
33
  QueryOptionNames["skip"] = "skip";
34
34
  QueryOptionNames["skiptoken"] = "skiptoken";
35
35
  QueryOptionNames["format"] = "format";
36
+ QueryOptionNames["levels"] = "levels";
36
37
  QueryOptionNames["count"] = "count";
37
38
  })(QueryOptionNames || (QueryOptionNames = {}));
38
39
  const NONE_PARSER = {
@@ -213,7 +214,7 @@ class ODataCache {
213
214
  return of(cached);
214
215
  }
215
216
  else {
216
- return throwError('No Cached');
217
+ return throwError(() => new Error('No Cached'));
217
218
  }
218
219
  }
219
220
  if (policy === 'cache-first' ||
@@ -745,6 +746,7 @@ function buildExpand(expands, { aliases, escape = false }) {
745
746
  case 'levels':
746
747
  case 'count':
747
748
  case 'top':
749
+ case 'skip':
748
750
  value = `${expands[key]}`;
749
751
  break;
750
752
  default:
@@ -1331,6 +1333,10 @@ const Objects = {
1331
1333
  if (typeof target != 'object' || target == null) {
1332
1334
  return target;
1333
1335
  }
1336
+ if (Types.isObject(target) && 'clone' in target) {
1337
+ // target is a cloneable object
1338
+ return target.clone();
1339
+ }
1334
1340
  const type = Types.rawType(target);
1335
1341
  let cloneTarget = null;
1336
1342
  if (map.get(target)) {
@@ -1461,17 +1467,33 @@ class Field$1 {
1461
1467
  constructor(name = '') {
1462
1468
  this.name = name;
1463
1469
  }
1464
- static factory() {
1465
- const h = new Field$1();
1466
- return new Proxy({ _name: '' }, h);
1470
+ static factory(name = '') {
1471
+ return new Proxy({ _name: name }, new Field$1());
1467
1472
  }
1468
- get(target, p) {
1473
+ get(target, key) {
1469
1474
  let name = target['_name'];
1470
- if (p === 'render') {
1475
+ if (key === 'render') {
1471
1476
  return ({ prefix }) => prefix ? `${prefix}/${name}` : name;
1472
1477
  }
1473
- name = name ? `${name}/${p}` : p;
1474
- return new Proxy({ _name: name }, this);
1478
+ else if (key === 'clone') {
1479
+ return () => Field$1.factory(name);
1480
+ }
1481
+ else if (key === Symbol.toStringTag) {
1482
+ return () => 'Field';
1483
+ }
1484
+ else if (key === 'toJSON') {
1485
+ return () => ({
1486
+ $type: Types.rawType(this),
1487
+ name: name,
1488
+ });
1489
+ }
1490
+ else {
1491
+ name = name ? `${name}/${key}` : key;
1492
+ return new Proxy({ _name: name }, this);
1493
+ }
1494
+ }
1495
+ has(target, key) {
1496
+ return ['toJSON', 'clone', 'render'].includes(key) || key in target;
1475
1497
  }
1476
1498
  }
1477
1499
  function applyMixins(derivedCtor, constructors) {
@@ -1510,6 +1532,7 @@ class Function {
1510
1532
  }
1511
1533
  toJSON() {
1512
1534
  return {
1535
+ $type: Types.rawType(this),
1513
1536
  name: this.name,
1514
1537
  values: this.values,
1515
1538
  normalize: this.normalize,
@@ -1518,12 +1541,15 @@ class Function {
1518
1541
  render({ aliases, escape, prefix, }) {
1519
1542
  let [field, ...values] = this.values;
1520
1543
  field = render(field, { aliases, escape, prefix });
1521
- let params = [
1544
+ const params = [
1522
1545
  field,
1523
1546
  ...values.map((v) => render(v, { aliases, escape, prefix, normalize: this.normalize })),
1524
1547
  ];
1525
1548
  return `${this.name}(${params.join(', ')})`;
1526
1549
  }
1550
+ clone() {
1551
+ return new Function(this.name, this.values.map((v) => Objects.clone(v)), this.normalize, this.escape);
1552
+ }
1527
1553
  }
1528
1554
  class StringAndCollectionFunctions {
1529
1555
  concat(field, value, normalize) {
@@ -1664,6 +1690,7 @@ class Operator {
1664
1690
  }
1665
1691
  toJSON() {
1666
1692
  return {
1693
+ $type: Types.rawType(this),
1667
1694
  op: this.op,
1668
1695
  values: this.values,
1669
1696
  normalize: this.normalize,
@@ -1692,6 +1719,9 @@ class Operator {
1692
1719
  }
1693
1720
  return `${this.op}(${left})`;
1694
1721
  }
1722
+ clone() {
1723
+ return new Operator(this.op, this.values.map((v) => Objects.clone(v)), this.normalize);
1724
+ }
1695
1725
  }
1696
1726
  class LogicalOperators {
1697
1727
  eq(left, right, normalize) {
@@ -1759,12 +1789,16 @@ class Grouping {
1759
1789
  }
1760
1790
  toJSON() {
1761
1791
  return {
1792
+ $type: Types.rawType(this),
1762
1793
  group: this.group.toJSON(),
1763
1794
  };
1764
1795
  }
1765
1796
  render({ aliases, escape, prefix, }) {
1766
1797
  return `(${render(this.group, { aliases, escape, prefix })})`;
1767
1798
  }
1799
+ clone() {
1800
+ return new Grouping(Objects.clone(this.group));
1801
+ }
1768
1802
  }
1769
1803
  class Lambda {
1770
1804
  constructor(op, values, alias) {
@@ -1777,6 +1811,7 @@ class Lambda {
1777
1811
  }
1778
1812
  toJSON() {
1779
1813
  return {
1814
+ $type: Types.rawType(this),
1780
1815
  op: this.op,
1781
1816
  values: this.values,
1782
1817
  alias: this.alias,
@@ -1792,6 +1827,9 @@ class Lambda {
1792
1827
  prefix: alias,
1793
1828
  })})`;
1794
1829
  }
1830
+ clone() {
1831
+ return new Lambda(this.op, this.values.map((v) => Objects.clone(v)), this.alias);
1832
+ }
1795
1833
  }
1796
1834
  class LambdaOperators {
1797
1835
  any(field, value, alias) {
@@ -1838,16 +1876,23 @@ class ComputeExpression extends Expression {
1838
1876
  static s() {
1839
1877
  return Field$1.factory();
1840
1878
  }
1841
- static compute(opts) {
1879
+ static compute(opts, current) {
1842
1880
  return opts({
1843
1881
  s: ComputeExpression.s(),
1844
1882
  e: ComputeExpression.e,
1845
- });
1883
+ }, current);
1846
1884
  }
1847
1885
  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(',');
1886
+ let children = this._children.map((n) => n.render({ aliases, escape, prefix }));
1887
+ return this.names
1888
+ .map((name, index) => `${children[index]} as ${name}`)
1889
+ .join(',');
1890
+ }
1891
+ clone() {
1892
+ return new ComputeExpression({
1893
+ children: this._children.map((c) => c.clone()),
1894
+ names: [...this.names],
1895
+ });
1851
1896
  }
1852
1897
  _add(name, node) {
1853
1898
  this.names.push(name);
@@ -1875,13 +1920,13 @@ class FilterExpression extends Expression {
1875
1920
  static e(connector = 'and') {
1876
1921
  return new FilterExpression({ connector });
1877
1922
  }
1878
- static filter(opts) {
1923
+ static filter(opts, current) {
1879
1924
  return opts({
1880
1925
  s: FilterExpression.s(),
1881
1926
  e: FilterExpression.e,
1882
1927
  o: operators,
1883
1928
  f: functions,
1884
- });
1929
+ }, current);
1885
1930
  }
1886
1931
  toJSON() {
1887
1932
  return {
@@ -1905,6 +1950,13 @@ class FilterExpression extends Expression {
1905
1950
  }
1906
1951
  return content;
1907
1952
  }
1953
+ clone() {
1954
+ return new FilterExpression({
1955
+ children: this._children.map((c) => c.clone()),
1956
+ connector: this._connector,
1957
+ negated: this._negated,
1958
+ });
1959
+ }
1908
1960
  _add(node, connector) {
1909
1961
  if (connector !== undefined && this._connector !== connector) {
1910
1962
  let children = [];
@@ -2031,6 +2083,9 @@ class OrderByField {
2031
2083
  render({ aliases, escape, prefix, }) {
2032
2084
  return `${render(this.field, { aliases, escape, prefix })} ${this.order}`;
2033
2085
  }
2086
+ clone() {
2087
+ return new OrderByField(this.field.clone(), this.order);
2088
+ }
2034
2089
  }
2035
2090
  class OrderByExpression extends Expression {
2036
2091
  constructor({ children, } = {}) {
@@ -2042,11 +2097,11 @@ class OrderByExpression extends Expression {
2042
2097
  static s() {
2043
2098
  return Field$1.factory();
2044
2099
  }
2045
- static orderBy(opts) {
2100
+ static orderBy(opts, current) {
2046
2101
  return opts({
2047
2102
  s: OrderByExpression.s(),
2048
2103
  e: OrderByExpression.e,
2049
- });
2104
+ }, current);
2050
2105
  }
2051
2106
  _add(node) {
2052
2107
  this._children.push(node);
@@ -2058,6 +2113,11 @@ class OrderByExpression extends Expression {
2058
2113
  .join(`,`);
2059
2114
  return content;
2060
2115
  }
2116
+ clone() {
2117
+ return new OrderByExpression({
2118
+ children: this._children.map((c) => c.clone()),
2119
+ });
2120
+ }
2061
2121
  ascending(field) {
2062
2122
  return this._add(new OrderByField(field, 'asc'));
2063
2123
  }
@@ -2075,12 +2135,16 @@ class SearchTerm {
2075
2135
  }
2076
2136
  toJSON() {
2077
2137
  return {
2138
+ $type: Types.rawType(this),
2078
2139
  value: this.value,
2079
2140
  };
2080
2141
  }
2081
2142
  render({ aliases, escape, prefix, }) {
2082
2143
  return `${render(this.value, { aliases, escape, prefix })}`;
2083
2144
  }
2145
+ clone() {
2146
+ return new SearchTerm(this.value);
2147
+ }
2084
2148
  }
2085
2149
  class SearchExpression extends Expression {
2086
2150
  constructor({ children, connector, negated, } = {}) {
@@ -2091,10 +2155,10 @@ class SearchExpression extends Expression {
2091
2155
  static e(connector = 'AND') {
2092
2156
  return new SearchExpression({ connector });
2093
2157
  }
2094
- static search(opts) {
2158
+ static search(opts, current) {
2095
2159
  return opts({
2096
2160
  e: SearchExpression.e,
2097
- });
2161
+ }, current);
2098
2162
  }
2099
2163
  _add(node, connector) {
2100
2164
  if (connector !== undefined && this._connector !== connector) {
@@ -2145,6 +2209,13 @@ class SearchExpression extends Expression {
2145
2209
  .join(` ${this._connector} `);
2146
2210
  return content;
2147
2211
  }
2212
+ clone() {
2213
+ return new SearchExpression({
2214
+ children: this._children.map((c) => c.clone()),
2215
+ connector: this._connector,
2216
+ negated: this._negated,
2217
+ });
2218
+ }
2148
2219
  toJSON() {
2149
2220
  return {
2150
2221
  children: this._children.map((c) => c.toJSON()),
@@ -2177,9 +2248,45 @@ class SearchExpression extends Expression {
2177
2248
  }
2178
2249
  }
2179
2250
 
2251
+ class SelectExpression extends Expression {
2252
+ constructor({ children, } = {}) {
2253
+ super({ children });
2254
+ }
2255
+ static e() {
2256
+ return new SelectExpression();
2257
+ }
2258
+ static s() {
2259
+ return Field$1.factory();
2260
+ }
2261
+ static select(builder, current) {
2262
+ return builder({
2263
+ s: SelectExpression.s(),
2264
+ e: SelectExpression.e,
2265
+ }, current);
2266
+ }
2267
+ render({ aliases, escape, prefix, } = {}) {
2268
+ return this._children
2269
+ .map((n) => n.render({ aliases, escape, prefix }))
2270
+ .join(',');
2271
+ }
2272
+ clone() {
2273
+ return new SelectExpression({
2274
+ children: this._children.map((c) => c.clone()),
2275
+ });
2276
+ }
2277
+ _add(node) {
2278
+ this._children.push(node);
2279
+ return this;
2280
+ }
2281
+ field(field) {
2282
+ return this._add(field);
2283
+ }
2284
+ }
2285
+
2180
2286
  class ExpandField {
2181
- constructor(field) {
2287
+ constructor(field, values = {}) {
2182
2288
  this.field = field;
2289
+ this.values = values;
2183
2290
  }
2184
2291
  get [Symbol.toStringTag]() {
2185
2292
  return 'ExpandField';
@@ -2190,14 +2297,66 @@ class ExpandField {
2190
2297
  };
2191
2298
  }
2192
2299
  render({ aliases, escape, prefix, }) {
2193
- return `${render(this.field, { aliases, escape, prefix })}`;
2300
+ const params = [
2301
+ QueryOptionNames.select,
2302
+ QueryOptionNames.expand,
2303
+ QueryOptionNames.filter,
2304
+ QueryOptionNames.search,
2305
+ QueryOptionNames.orderBy,
2306
+ QueryOptionNames.skip,
2307
+ QueryOptionNames.top,
2308
+ QueryOptionNames.levels,
2309
+ ]
2310
+ .filter((key) => !Types.isEmpty(this.values[key]))
2311
+ .reduce((acc, key) => {
2312
+ let value = this.values[key];
2313
+ if (Types.rawType(value).endsWith('Expression')) {
2314
+ value = value.render({ aliases, prefix, escape });
2315
+ }
2316
+ return Object.assign(acc, { [key]: value });
2317
+ }, {});
2318
+ let expand = `${render(this.field, { aliases, escape, prefix })}`;
2319
+ if (!Types.isEmpty(params)) {
2320
+ expand = `${expand}(${Object.keys(params)
2321
+ .map((key) => `$${key}=${params[key]}`)
2322
+ .join(';')})`;
2323
+ }
2324
+ return expand;
2325
+ }
2326
+ clone() {
2327
+ const values = Object.keys(this.values).reduce((acc, key) => Object.assign(acc, { [key]: Objects.clone(this.values[key]) }), {});
2328
+ return new ExpandField(this.field.clone(), values);
2329
+ }
2330
+ select(opts) {
2331
+ return this.option(QueryOptionNames.select, SelectExpression.select(opts, this.values[QueryOptionNames.select]));
2332
+ }
2333
+ expand(opts) {
2334
+ return this.option(QueryOptionNames.expand, ExpandExpression.expand(opts, this.values[QueryOptionNames.expand]));
2335
+ }
2336
+ filter(opts) {
2337
+ return this.option(QueryOptionNames.filter, FilterExpression.filter(opts, this.values[QueryOptionNames.filter]));
2338
+ }
2339
+ search(opts) {
2340
+ return this.option(QueryOptionNames.search, SearchExpression.search(opts, this.values[QueryOptionNames.search]));
2341
+ }
2342
+ orderBy(opts) {
2343
+ return this.option(QueryOptionNames.orderBy, OrderByExpression.orderBy(opts, this.values[QueryOptionNames.orderBy]));
2344
+ }
2345
+ skip(n) {
2346
+ return this.option(QueryOptionNames.skip, n);
2347
+ }
2348
+ top(n) {
2349
+ return this.option(QueryOptionNames.top, n);
2350
+ }
2351
+ levels(n) {
2352
+ return this.option(QueryOptionNames.levels, n);
2353
+ }
2354
+ // Option Handler
2355
+ option(name, opts) {
2356
+ if (opts !== undefined)
2357
+ this.values[name] = opts;
2358
+ return this.values[name];
2194
2359
  }
2195
- select() { }
2196
- filter() { }
2197
- levels() { }
2198
- orderBy() { }
2199
- top() { }
2200
- skip() { }
2201
2360
  }
2202
2361
  class ExpandExpression extends Expression {
2203
2362
  constructor({ children, } = {}) {
@@ -2209,17 +2368,22 @@ class ExpandExpression extends Expression {
2209
2368
  static s() {
2210
2369
  return Field$1.factory();
2211
2370
  }
2212
- static expand(opts) {
2371
+ static expand(opts, current) {
2213
2372
  return opts({
2214
2373
  s: ExpandExpression.s(),
2215
2374
  e: ExpandExpression.e,
2216
- });
2375
+ }, current);
2217
2376
  }
2218
2377
  render({ aliases, escape, prefix, } = {}) {
2219
2378
  return this._children
2220
2379
  .map((n) => n.render({ aliases, escape, prefix }))
2221
2380
  .join(',');
2222
2381
  }
2382
+ clone() {
2383
+ return new ExpandExpression({
2384
+ children: this._children.map((c) => c.clone()),
2385
+ });
2386
+ }
2223
2387
  _add(node) {
2224
2388
  this._children.push(node);
2225
2389
  return this;
@@ -2232,36 +2396,6 @@ class ExpandExpression extends Expression {
2232
2396
  }
2233
2397
  }
2234
2398
 
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
- }
2263
- }
2264
-
2265
2399
  class ODataQueryOptionHandler {
2266
2400
  constructor(o, n) {
2267
2401
  this.o = o;
@@ -2359,19 +2493,19 @@ class ODataQueryOptionsHandler {
2359
2493
  }
2360
2494
  select(opts) {
2361
2495
  if (Types.isFunction(opts)) {
2362
- return this.options.expression(QueryOptionNames.select, SelectExpression.select(opts));
2496
+ return this.options.expression(QueryOptionNames.select, SelectExpression.select(opts, this.options.expression(QueryOptionNames.select)));
2363
2497
  }
2364
2498
  return this.options.option(QueryOptionNames.select, opts);
2365
2499
  }
2366
2500
  expand(opts) {
2367
2501
  if (Types.isFunction(opts)) {
2368
- return this.options.expression(QueryOptionNames.expand, ExpandExpression.expand(opts));
2502
+ return this.options.expression(QueryOptionNames.expand, ExpandExpression.expand(opts, this.options.expression(QueryOptionNames.expand)));
2369
2503
  }
2370
2504
  return this.options.option(QueryOptionNames.expand, opts);
2371
2505
  }
2372
2506
  compute(opts) {
2373
2507
  if (Types.isFunction(opts)) {
2374
- return this.options.expression(QueryOptionNames.compute, ComputeExpression.compute(opts));
2508
+ return this.options.expression(QueryOptionNames.compute, ComputeExpression.compute(opts, this.options.expression(QueryOptionNames.compute)));
2375
2509
  }
2376
2510
  return this.options.option(QueryOptionNames.compute, opts);
2377
2511
  }
@@ -2383,19 +2517,19 @@ class ODataQueryOptionsHandler {
2383
2517
  }
2384
2518
  search(opts) {
2385
2519
  if (Types.isFunction(opts)) {
2386
- return this.options.expression(QueryOptionNames.search, SearchExpression.search(opts));
2520
+ return this.options.expression(QueryOptionNames.search, SearchExpression.search(opts, this.options.expression(QueryOptionNames.search)));
2387
2521
  }
2388
2522
  return this.options.option(QueryOptionNames.search, opts);
2389
2523
  }
2390
2524
  filter(opts) {
2391
2525
  if (Types.isFunction(opts)) {
2392
- return this.options.expression(QueryOptionNames.filter, FilterExpression.filter(opts));
2526
+ return this.options.expression(QueryOptionNames.filter, FilterExpression.filter(opts, this.options.expression(QueryOptionNames.filter)));
2393
2527
  }
2394
2528
  return this.options.option(QueryOptionNames.filter, opts);
2395
2529
  }
2396
2530
  orderBy(opts) {
2397
2531
  if (Types.isFunction(opts)) {
2398
- return this.options.expression(QueryOptionNames.orderBy, OrderByExpression.orderBy(opts));
2532
+ return this.options.option(QueryOptionNames.orderBy, OrderByExpression.orderBy(opts, this.options.expression(QueryOptionNames.orderBy)));
2399
2533
  }
2400
2534
  return this.options.option(QueryOptionNames.orderBy, opts);
2401
2535
  }
@@ -2423,22 +2557,22 @@ class ODataQueryOptionsHandler {
2423
2557
  }
2424
2558
  apply(query) {
2425
2559
  if (query.select !== undefined) {
2426
- this.select(query.select);
2560
+ this.options.option(QueryOptionNames.select, query.select);
2427
2561
  }
2428
2562
  if (query.expand !== undefined) {
2429
- this.expand(query.expand);
2563
+ this.options.option(QueryOptionNames.expand, query.expand);
2430
2564
  }
2431
2565
  if (query.transform !== undefined) {
2432
- this.transform(query.transform);
2566
+ this.options.option(QueryOptionNames.transform, query.transform);
2433
2567
  }
2434
2568
  if (query.search !== undefined) {
2435
- this.search(query.search);
2569
+ this.options.option(QueryOptionNames.search, query.search);
2436
2570
  }
2437
2571
  if (query.filter !== undefined) {
2438
- this.filter(query.filter);
2572
+ this.options.option(QueryOptionNames.filter, query.filter);
2439
2573
  }
2440
2574
  if (query.orderBy !== undefined) {
2441
- this.orderBy(query.orderBy);
2575
+ this.options.option(QueryOptionNames.orderBy, query.orderBy);
2442
2576
  }
2443
2577
  this.paging(query);
2444
2578
  }
@@ -2446,7 +2580,7 @@ class ODataQueryOptionsHandler {
2446
2580
 
2447
2581
  class ODataQueryOptions {
2448
2582
  constructor(options) {
2449
- this.options = options || {};
2583
+ this.values = options || {};
2450
2584
  }
2451
2585
  // Params
2452
2586
  pathAndParams(escape = false) {
@@ -2464,11 +2598,11 @@ class ODataQueryOptions {
2464
2598
  QueryOptionNames.expand,
2465
2599
  QueryOptionNames.format,
2466
2600
  ]
2467
- .filter((key) => !Types.isEmpty(this.options[key]))
2601
+ .filter((key) => !Types.isEmpty(this.values[key]))
2468
2602
  .reduce((acc, key) => {
2469
- let value = this.options[key];
2470
- if (Types.rawType(value) === 'Expression') {
2471
- value = value.render(aliases);
2603
+ let value = this.values[key];
2604
+ if (Types.rawType(value).endsWith('Expression')) {
2605
+ value = value.render({ aliases });
2472
2606
  }
2473
2607
  return Object.assign(acc, { [key]: value });
2474
2608
  }, {});
@@ -2483,63 +2617,60 @@ class ODataQueryOptions {
2483
2617
  .join('&'));
2484
2618
  }
2485
2619
  toJSON() {
2486
- return Object.keys(this.options).reduce((acc, key) => {
2487
- let value = this.options[key];
2488
- if (Types.rawType(value) === 'Expression') {
2489
- value = value.toJSON();
2490
- }
2620
+ return Object.keys(this.values).reduce((acc, key) => {
2621
+ let value = this.values[key];
2622
+ value =
2623
+ Types.isObject(value) && 'toJSON' in value ? value.toJSON() : value;
2491
2624
  return Object.assign(acc, { [key]: value });
2492
2625
  }, {});
2493
2626
  }
2494
2627
  toQueryArguments() {
2495
2628
  return {
2496
- select: this.options[QueryOptionNames.select],
2497
- expand: this.options[QueryOptionNames.expand],
2498
- transform: this.options[QueryOptionNames.transform],
2499
- compute: this.options[QueryOptionNames.compute],
2500
- search: this.options[QueryOptionNames.search],
2501
- filter: this.options[QueryOptionNames.filter],
2502
- orderBy: this.options[QueryOptionNames.orderBy],
2503
- top: this.options[QueryOptionNames.top],
2504
- skip: this.options[QueryOptionNames.skip],
2505
- skiptoken: this.options[QueryOptionNames.skiptoken],
2629
+ select: this.values[QueryOptionNames.select],
2630
+ expand: this.values[QueryOptionNames.expand],
2631
+ transform: this.values[QueryOptionNames.transform],
2632
+ compute: this.values[QueryOptionNames.compute],
2633
+ search: this.values[QueryOptionNames.search],
2634
+ filter: this.values[QueryOptionNames.filter],
2635
+ orderBy: this.values[QueryOptionNames.orderBy],
2636
+ top: this.values[QueryOptionNames.top],
2637
+ skip: this.values[QueryOptionNames.skip],
2638
+ skiptoken: this.values[QueryOptionNames.skiptoken],
2506
2639
  };
2507
2640
  }
2508
2641
  clone() {
2509
- const options = Object.keys(this.options).reduce((acc, key) => {
2510
- let value = this.options[key];
2511
- if (Types.rawType(value) !== 'Expression') {
2512
- value = Objects.clone(value);
2513
- }
2514
- return Object.assign(acc, { [key]: value });
2515
- }, {});
2642
+ const options = Object.keys(this.values).reduce((acc, key) => Object.assign(acc, { [key]: Objects.clone(this.values[key]) }), {});
2516
2643
  return new ODataQueryOptions(options);
2517
2644
  }
2518
2645
  // Set Renderable
2519
2646
  expression(name, exp) {
2520
- return (this.options[name] = exp);
2647
+ if (exp !== undefined)
2648
+ this.values[name] = exp;
2649
+ return this.values[name];
2521
2650
  }
2522
2651
  // Option Handler
2523
2652
  option(name, opts) {
2524
2653
  if (opts !== undefined)
2525
- this.options[name] = opts;
2526
- return new ODataQueryOptionHandler(this.options, name);
2654
+ this.values[name] = opts;
2655
+ return new ODataQueryOptionHandler(this.values, name);
2527
2656
  }
2528
2657
  // Query Options tools
2529
2658
  has(name) {
2530
- return this.options[name] !== undefined;
2659
+ return this.values[name] !== undefined;
2531
2660
  }
2532
2661
  remove(...names) {
2533
- names.forEach((name) => this.option(name).clear());
2662
+ names.forEach((name) => {
2663
+ delete this.values[name];
2664
+ });
2534
2665
  }
2535
2666
  keep(...names) {
2536
- this.options = Object.keys(this.options)
2667
+ this.values = Object.keys(this.values)
2537
2668
  .filter((k) => names.indexOf(k) !== -1)
2538
- .reduce((acc, k) => Object.assign(acc, { [k]: this.options[k] }), {});
2669
+ .reduce((acc, k) => Object.assign(acc, { [k]: this.values[k] }), {});
2539
2670
  }
2540
2671
  // Clear
2541
2672
  clear() {
2542
- this.options = {};
2673
+ this.values = {};
2543
2674
  }
2544
2675
  }
2545
2676
 
@@ -4148,6 +4279,14 @@ class ODataEnumType extends ODataSchemaElement {
4148
4279
  findFieldByValue(value) {
4149
4280
  return this.fields().find((f) => f.value === value);
4150
4281
  }
4282
+ /**
4283
+ * Find a fields by flag.
4284
+ * @param value The value of the field
4285
+ * @returns The fields with the given flag
4286
+ */
4287
+ findFieldsByValue(value) {
4288
+ return this.fields().filter((f) => Boolean(f.value & value));
4289
+ }
4151
4290
  /**
4152
4291
  * Map the fields of the enum type.
4153
4292
  * @param mapper Function that maps the value to the new value
@@ -7065,7 +7204,7 @@ class ODataEntityResource extends ODataResource {
7065
7204
  if (castSchema !== undefined &&
7066
7205
  baseSchema !== undefined &&
7067
7206
  !castSchema.isSubtypeOf(baseSchema))
7068
- throw new Error(`Cannot cast to ${type}`);
7207
+ throw new Error(`cast: Cannot cast to ${type}`);
7069
7208
  const segments = this.cloneSegments();
7070
7209
  segments.add(PathSegmentNames.type, type).type(type);
7071
7210
  return new ODataEntityResource(this.api, {
@@ -7106,7 +7245,7 @@ class ODataEntityResource extends ODataResource {
7106
7245
  }
7107
7246
  fetch(options) {
7108
7247
  if (!this.hasKey())
7109
- return throwError('Entity resource without key');
7248
+ return throwError(() => new Error('fetch: Entity resource without key'));
7110
7249
  return this.get(options);
7111
7250
  }
7112
7251
  fetchEntity(options) {
@@ -7424,6 +7563,16 @@ class ODataModelEvent {
7424
7563
  : '')
7425
7564
  .join('');
7426
7565
  }
7566
+ //Identifies the current model for the event
7567
+ get currentModel() {
7568
+ const link = this.chain.find(c => ODataModelOptions.isModel(c[0]));
7569
+ return link !== undefined ? link[0] : undefined;
7570
+ }
7571
+ //Identifies the current collection for the event
7572
+ get currentCollection() {
7573
+ const link = this.chain.find(c => ODataModelOptions.isCollection(c[0]));
7574
+ return link !== undefined ? link[0] : undefined;
7575
+ }
7427
7576
  }
7428
7577
  const BUBBLING = [
7429
7578
  'change',
@@ -8348,7 +8497,7 @@ class ODataCollection {
8348
8497
  if (model === undefined && Klass.model !== null)
8349
8498
  model = Klass.model;
8350
8499
  if (model === undefined)
8351
- throw new Error('Collection need model');
8500
+ throw new Error('Collection: Collection need model');
8352
8501
  this._model = model;
8353
8502
  // Parent
8354
8503
  if (parent !== undefined) {
@@ -8386,7 +8535,7 @@ class ODataCollection {
8386
8535
  if (this._resource !== null &&
8387
8536
  this._resource.type() !== resource.type() &&
8388
8537
  !this._resource.isSubtypeOf(resource))
8389
- throw new Error(`Can't reattach ${this._resource.type()} to ${resource.type()}`);
8538
+ throw new Error(`attach: Can't reattach ${this._resource.type()} to ${resource.type()}`);
8390
8539
  this._entries.forEach(({ model }) => {
8391
8540
  const mr = this._model.meta.modelResourceFactory(resource.cloneQuery());
8392
8541
  model.attach(mr);
@@ -8406,7 +8555,7 @@ class ODataCollection {
8406
8555
  const query = this.resource().cloneQuery();
8407
8556
  let resource = this._model.meta.collectionResourceFactory(query);
8408
8557
  if (resource === undefined)
8409
- throw new Error('Collection does not have associated EntitySet endpoint');
8558
+ throw new Error('asEntitySet: Collection does not have associated EntitySet endpoint');
8410
8559
  // Store parent and resource
8411
8560
  const store = { parent: this._parent, resource: this._resource };
8412
8561
  // Replace parent and resource
@@ -8481,26 +8630,13 @@ class ODataCollection {
8481
8630
  }
8482
8631
  fetch({ withCount, ...options } = {}) {
8483
8632
  const resource = this.resource();
8484
- if (resource === undefined)
8485
- return throwError('fetch: Resource is undefined');
8486
- let obs$;
8487
- if (resource instanceof ODataEntitySetResource) {
8488
- obs$ = resource.fetch({ withCount, ...options });
8489
- }
8490
- else if (resource instanceof ODataNavigationPropertyResource) {
8491
- obs$ = resource.fetch({
8633
+ const obs$ = resource instanceof ODataEntitySetResource
8634
+ ? resource.fetch({ withCount, ...options })
8635
+ : resource.fetch({
8492
8636
  responseType: 'entities',
8493
8637
  withCount,
8494
8638
  ...options,
8495
8639
  });
8496
- }
8497
- else {
8498
- obs$ = resource.fetch({
8499
- responseType: 'entities',
8500
- withCount,
8501
- ...options,
8502
- });
8503
- }
8504
8640
  this.events$.emit(new ODataModelEvent('request', { collection: this, value: obs$ }));
8505
8641
  return obs$.pipe(map(({ entities, annots }) => {
8506
8642
  this._annotations = annots;
@@ -8511,10 +8647,8 @@ class ODataCollection {
8511
8647
  }
8512
8648
  fetchAll(options) {
8513
8649
  const resource = this.resource();
8514
- if (resource === undefined)
8515
- return throwError('fetchAll: Resource is undefined');
8516
8650
  if (resource instanceof ODataPropertyResource)
8517
- return throwError('fetchAll: Resource is ODataPropertyResource');
8651
+ return throwError(() => new Error('fetchAll: Resource is ODataPropertyResource'));
8518
8652
  const obs$ = resource.fetchAll(options);
8519
8653
  this.events$.emit(new ODataModelEvent('request', {
8520
8654
  collection: this,
@@ -8538,10 +8672,8 @@ class ODataCollection {
8538
8672
  */
8539
8673
  save({ relModel = false, method, ...options } = {}) {
8540
8674
  const resource = this.resource();
8541
- if (resource === undefined)
8542
- return throwError('saveAll: Resource is undefined');
8543
8675
  if (resource instanceof ODataPropertyResource)
8544
- return throwError('fetchAll: Resource is ODataPropertyResource');
8676
+ return throwError(() => new Error('save: Resource is ODataPropertyResource'));
8545
8677
  let toDestroyEntity = [];
8546
8678
  let toRemoveReference = [];
8547
8679
  let toDestroyContained = [];
@@ -8911,25 +9043,25 @@ class ODataCollection {
8911
9043
  return func.call(params, { responseType, ...options });
8912
9044
  }
8913
9045
  }
8914
- return throwError(`Can't function without ODataEntitySetResource`);
9046
+ return throwError(() => new Error(`callFunction: Can't function without ODataEntitySetResource`));
8915
9047
  }
8916
9048
  callAction(name, params, responseType, { ...options } = {}) {
8917
9049
  const resource = this.resource();
8918
- if (resource instanceof ODataEntitySetResource) {
8919
- const action = resource.action(name);
8920
- action.query((q) => q.apply(options));
8921
- switch (responseType) {
8922
- case 'property':
8923
- return action.callProperty(params, options);
8924
- case 'model':
8925
- return action.callModel(params, options);
8926
- case 'collection':
8927
- return action.callCollection(params, options);
8928
- default:
8929
- return action.call(params, { responseType, ...options });
8930
- }
9050
+ if (!(resource instanceof ODataEntitySetResource)) {
9051
+ return throwError(() => new Error(`callAction: Can't action without ODataEntitySetResource`));
9052
+ }
9053
+ const action = resource.action(name);
9054
+ action.query((q) => q.apply(options));
9055
+ switch (responseType) {
9056
+ case 'property':
9057
+ return action.callProperty(params, options);
9058
+ case 'model':
9059
+ return action.callModel(params, options);
9060
+ case 'collection':
9061
+ return action.callCollection(params, options);
9062
+ default:
9063
+ return action.call(params, { responseType, ...options });
8931
9064
  }
8932
- return throwError(`Can't action without ODataEntitySetResource`);
8933
9065
  }
8934
9066
  _unsubscribe(entry) {
8935
9067
  if (entry.subscription) {
@@ -8939,7 +9071,7 @@ class ODataCollection {
8939
9071
  }
8940
9072
  _subscribe(entry) {
8941
9073
  if (entry.subscription) {
8942
- throw new Error('Subscription already exists');
9074
+ throw new Error('Collection: Subscription already exists');
8943
9075
  }
8944
9076
  entry.subscription = entry.model.events$.subscribe((event) => {
8945
9077
  if (BUBBLING.indexOf(event.name) !== -1 &&
@@ -8988,12 +9120,18 @@ class ODataCollection {
8988
9120
  },
8989
9121
  };
8990
9122
  }
8991
- filter(predicate) {
9123
+ filter(predicate, thisArg) {
8992
9124
  return this.models().filter(predicate);
8993
9125
  }
8994
- find(predicate) {
9126
+ map(callbackfn, thisArg) {
9127
+ return this.models().map(callbackfn, thisArg);
9128
+ }
9129
+ find(predicate, thisArg) {
8995
9130
  return this.models().find(predicate);
8996
9131
  }
9132
+ reduce(callbackfn, initialValue) {
9133
+ return this.models().reduce(callbackfn, initialValue);
9134
+ }
8997
9135
  first() {
8998
9136
  return this.models()[0];
8999
9137
  }
@@ -9101,7 +9239,7 @@ class ODataModel {
9101
9239
  this.events$ = new EventEmitter();
9102
9240
  const Klass = this.constructor;
9103
9241
  if (Klass.meta === undefined)
9104
- throw new Error(`Can't create model without metadata`);
9242
+ throw new Error(`ODataModel: Can't create model without metadata`);
9105
9243
  this._meta = Klass.meta;
9106
9244
  this._meta.bind(this, { parent, resource, annots });
9107
9245
  // Client Id
@@ -9141,19 +9279,19 @@ class ODataModel {
9141
9279
  navigationProperty(name) {
9142
9280
  const field = this._meta.field(name);
9143
9281
  if (field === undefined || !field.navigation)
9144
- throw Error(`Can't find navigation property ${name}`);
9282
+ throw Error(`navigationProperty: Can't find navigation property ${name}`);
9145
9283
  const resource = this.resource();
9146
9284
  if (!(resource instanceof ODataEntityResource) || !resource.hasKey())
9147
- throw Error("Can't get navigation without ODataEntityResource with key");
9285
+ throw Error("navigationProperty: Can't get navigation without ODataEntityResource with key");
9148
9286
  return field.resourceFactory(resource);
9149
9287
  }
9150
9288
  property(name) {
9151
9289
  const field = this._meta.field(name);
9152
9290
  if (field === undefined || field.navigation)
9153
- throw Error(`Can't find property ${name}`);
9291
+ throw Error(`property: Can't find property ${name}`);
9154
9292
  const resource = this.resource();
9155
9293
  if (!(resource instanceof ODataEntityResource) || !resource.hasKey())
9156
- throw Error("Can't get property without ODataEntityResource with key");
9294
+ throw Error("property: Can't get property without ODataEntityResource with key");
9157
9295
  return field.resourceFactory(resource);
9158
9296
  }
9159
9297
  attach(resource) {
@@ -9298,11 +9436,11 @@ class ODataModel {
9298
9436
  fetch({ ...options } = {}) {
9299
9437
  let resource = this.resource();
9300
9438
  if (resource === undefined)
9301
- return throwError('fetch: Resource is undefined');
9439
+ return throwError(() => new Error('fetch: Resource is undefined'));
9302
9440
  let obs$;
9303
9441
  if (resource instanceof ODataEntityResource) {
9304
9442
  if (!resource.hasKey())
9305
- return throwError("fetch: Can't fetch model without key");
9443
+ return throwError(() => new Error("fetch: Can't fetch model without key"));
9306
9444
  obs$ = resource.fetch(options);
9307
9445
  }
9308
9446
  else if (resource instanceof ODataNavigationPropertyResource) {
@@ -9319,49 +9457,45 @@ class ODataModel {
9319
9457
  save({ method, navigation = false, validate = true, ...options } = {}) {
9320
9458
  let resource = this.resource();
9321
9459
  if (resource === undefined)
9322
- return throwError('save: Resource is undefined');
9460
+ return throwError(() => new Error('save: Resource is undefined'));
9323
9461
  if (!(resource instanceof ODataEntityResource ||
9324
9462
  resource instanceof ODataNavigationPropertyResource))
9325
- return throwError('save: Resource type ODataEntityResource/ODataNavigationPropertyResource needed');
9463
+ return throwError(() => new Error('save: Resource type ODataEntityResource/ODataNavigationPropertyResource needed'));
9326
9464
  // Resolve method and resource key
9327
9465
  if (method === undefined && this.schema().isCompoundKey())
9328
- return throwError('save: Composite key require a specific method, use create/update/modify');
9466
+ return throwError(() => new Error('save: Composite key require a specific method, use create/update/modify'));
9329
9467
  method = method || (!resource.hasKey() ? 'create' : 'update');
9330
9468
  if (resource instanceof ODataEntityResource &&
9331
9469
  (method === 'update' || method === 'modify') &&
9332
9470
  !resource.hasKey())
9333
- return throwError('save: Update/Patch require entity key');
9471
+ return throwError(() => new Error('save: Update/Patch require entity key'));
9334
9472
  if (resource instanceof ODataNavigationPropertyResource ||
9335
9473
  method === 'create')
9336
9474
  resource.clearKey();
9337
- let obs$;
9338
- if (!validate || this.isValid({ method, navigation })) {
9339
- const _entity = this.toEntity({
9340
- changes_only: method === 'modify',
9341
- field_mapping: true,
9342
- include_concurrency: true,
9343
- include_navigation: navigation,
9344
- });
9345
- obs$ = (method === 'create'
9346
- ? resource.create(_entity, options)
9347
- : method === 'modify'
9348
- ? resource.modify(_entity, { etag: this.annots().etag, ...options })
9349
- : resource.update(_entity, { etag: this.annots().etag, ...options })).pipe(map(({ entity, annots }) => ({ entity: entity || _entity, annots })));
9350
- }
9351
- else {
9352
- obs$ = throwError(this._errors);
9475
+ if (validate && !this.isValid({ method, navigation })) {
9476
+ return throwError(() => new Error('save: Validation errors'));
9353
9477
  }
9354
- return this._request(obs$);
9478
+ const _entity = this.toEntity({
9479
+ changes_only: method === 'modify',
9480
+ field_mapping: true,
9481
+ include_concurrency: true,
9482
+ include_navigation: navigation,
9483
+ });
9484
+ return this._request((method === 'create'
9485
+ ? resource.create(_entity, options)
9486
+ : method === 'modify'
9487
+ ? resource.modify(_entity, { etag: this.annots().etag, ...options })
9488
+ : resource.update(_entity, { etag: this.annots().etag, ...options })).pipe(map(({ entity, annots }) => ({ entity: entity || _entity, annots }))));
9355
9489
  }
9356
9490
  destroy({ ...options } = {}) {
9357
9491
  let resource = this.resource();
9358
9492
  if (resource === undefined)
9359
- return throwError('destroy: Resource is undefined');
9493
+ return throwError(() => new Error('destroy: Resource is undefined'));
9360
9494
  if (!(resource instanceof ODataEntityResource ||
9361
9495
  resource instanceof ODataNavigationPropertyResource))
9362
- return throwError('destroy: Resource type ODataEntityResource/ODataNavigationPropertyResource needed');
9496
+ return throwError(() => new Error('destroy: Resource type ODataEntityResource/ODataNavigationPropertyResource needed'));
9363
9497
  if (!resource.hasKey())
9364
- return throwError("destroy: Can't destroy model without key");
9498
+ return throwError(() => new Error("destroy: Can't destroy model without key"));
9365
9499
  const _entity = this.toEntity({ field_mapping: true });
9366
9500
  const obs$ = resource
9367
9501
  .destroy({ etag: this.annots().etag, ...options })
@@ -9394,7 +9528,7 @@ class ODataModel {
9394
9528
  callFunction(name, params, responseType, { ...options } = {}) {
9395
9529
  const resource = this.resource();
9396
9530
  if (!(resource instanceof ODataEntityResource) || !resource.hasKey())
9397
- return throwError("Can't call function without ODataEntityResource with key");
9531
+ return throwError(() => new Error("callFunction: Can't call function without ODataEntityResource with key"));
9398
9532
  const func = resource.function(name).query((q) => q.apply(options));
9399
9533
  switch (responseType) {
9400
9534
  case 'property':
@@ -9410,7 +9544,7 @@ class ODataModel {
9410
9544
  callAction(name, params, responseType, { ...options } = {}) {
9411
9545
  const resource = this.resource();
9412
9546
  if (!(resource instanceof ODataEntityResource) || !resource.hasKey())
9413
- return throwError("Can't call action without ODataEntityResource with key");
9547
+ return throwError(() => new Error("callAction: Can't call action without ODataEntityResource with key"));
9414
9548
  const action = resource.action(name).query((q) => q.apply(options));
9415
9549
  switch (responseType) {
9416
9550
  case 'property':
@@ -9427,7 +9561,7 @@ class ODataModel {
9427
9561
  cast(type) {
9428
9562
  const resource = this.resource();
9429
9563
  if (!(resource instanceof ODataEntityResource))
9430
- throw new Error(`Can't cast to derived model without ODataEntityResource`);
9564
+ throw new Error(`cast: Can't cast to derived model without ODataEntityResource`);
9431
9565
  return resource
9432
9566
  .cast(type)
9433
9567
  .asModel(this.toEntity(INCLUDE_DEEP), { annots: this.annots() });
@@ -9446,7 +9580,7 @@ class ODataModel {
9446
9580
  getValue(name, options) {
9447
9581
  const field = this._meta.field(name);
9448
9582
  if (field === undefined || field.navigation)
9449
- throw Error(`Can't find property ${name}`);
9583
+ throw Error(`getValue: Can't find property ${name}`);
9450
9584
  let value = this[name];
9451
9585
  if (value === undefined) {
9452
9586
  const prop = field.resourceFactory(this.resource());
@@ -9493,7 +9627,7 @@ class ODataModel {
9493
9627
  getReference(name) {
9494
9628
  const field = this._meta.field(name);
9495
9629
  if (field === undefined || !field.navigation)
9496
- throw Error(`Can't find navigation property ${name}`);
9630
+ throw Error(`getReference: Can't find navigation property ${name}`);
9497
9631
  let model = this[name];
9498
9632
  if (model === undefined) {
9499
9633
  const value = field.collection ? [] : this.referenced(field);
@@ -10282,9 +10416,9 @@ class ODataClient {
10282
10416
  return this.request('PUT', resource, addBody(options, body));
10283
10417
  }
10284
10418
  }
10285
- 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 });
10286
- ODataClient.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ODataClient, providedIn: 'root' });
10287
- 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: [{
10288
10422
  type: Injectable,
10289
10423
  args: [{
10290
10424
  providedIn: 'root',
@@ -10403,7 +10537,7 @@ class ODataEntitySetService extends ODataEntityService {
10403
10537
  update(key, attrs, options) {
10404
10538
  const res = this.entity(key);
10405
10539
  if (!res.hasKey())
10406
- return throwError('Resource without key');
10540
+ return throwError(() => new Error('update: Resource without key'));
10407
10541
  return res.update(attrs, options);
10408
10542
  }
10409
10543
  /**
@@ -10416,7 +10550,7 @@ class ODataEntitySetService extends ODataEntityService {
10416
10550
  modify(key, attrs, options) {
10417
10551
  const res = this.entity(key);
10418
10552
  if (!res.hasKey())
10419
- return throwError('Resource without key');
10553
+ return throwError(() => new Error('modify: Resource without key'));
10420
10554
  return res.modify(attrs, options);
10421
10555
  }
10422
10556
  /**
@@ -10428,7 +10562,7 @@ class ODataEntitySetService extends ODataEntityService {
10428
10562
  destroy(key, options) {
10429
10563
  const res = this.entity(key);
10430
10564
  if (!res.hasKey())
10431
- return throwError('Resource without key');
10565
+ return throwError(() => new Error('destroy: Resource without key'));
10432
10566
  return res.destroy(options);
10433
10567
  }
10434
10568
  //#region Shortcuts
@@ -10457,12 +10591,12 @@ class ODataEntitySetService extends ODataEntityService {
10457
10591
  save(attrs, { etag, method, ...options } = {}) {
10458
10592
  let schema = this.structuredTypeSchema;
10459
10593
  if (method === undefined && schema !== undefined && schema.isCompoundKey())
10460
- return throwError('Composite key require a specific method, use create/update/patch');
10594
+ return throwError(() => new Error('save: Composite key require a specific method, use create/update/patch'));
10461
10595
  let key = schema && schema.resolveKey(attrs);
10462
10596
  if (method === undefined)
10463
10597
  method = key !== undefined ? 'update' : 'create';
10464
10598
  if ((method === 'update' || method === 'modify') && key === undefined)
10465
- return throwError("Can't update/patch entity without key");
10599
+ return throwError(() => new Error("save: Can't update/patch entity without key"));
10466
10600
  return method === 'create'
10467
10601
  ? this.create(attrs, options)
10468
10602
  : method === 'modify'
@@ -10540,9 +10674,9 @@ class ODataServiceFactory {
10540
10674
  })(this.client, singletonName, apiNameOrEntityType);
10541
10675
  }
10542
10676
  }
10543
- ODataServiceFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ODataServiceFactory, deps: [{ token: ODataClient }], target: i0.ɵɵFactoryTarget.Injectable });
10544
- ODataServiceFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ODataServiceFactory });
10545
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ODataServiceFactory, decorators: [{
10677
+ ODataServiceFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ODataServiceFactory, deps: [{ token: ODataClient }], target: i0.ɵɵFactoryTarget.Injectable });
10678
+ ODataServiceFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ODataServiceFactory });
10679
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ODataServiceFactory, decorators: [{
10546
10680
  type: Injectable
10547
10681
  }], ctorParameters: function () { return [{ type: ODataClient }]; } });
10548
10682
 
@@ -10566,10 +10700,10 @@ class ODataModule {
10566
10700
  };
10567
10701
  }
10568
10702
  }
10569
- ODataModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
10570
- ODataModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ODataModule, imports: [HttpClientModule] });
10571
- ODataModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ODataModule, providers: [ODataClient, ODataServiceFactory], imports: [[HttpClientModule]] });
10572
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: ODataModule, decorators: [{
10703
+ ODataModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
10704
+ ODataModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ODataModule, imports: [HttpClientModule] });
10705
+ ODataModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ODataModule, providers: [ODataClient, ODataServiceFactory], imports: [[HttpClientModule]] });
10706
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.5", ngImport: i0, type: ODataModule, decorators: [{
10573
10707
  type: NgModule,
10574
10708
  args: [{
10575
10709
  imports: [HttpClientModule],