angular-odata 0.131.0 → 0.140.1

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 (139) hide show
  1. package/fesm2022/angular-odata.mjs +322 -580
  2. package/fesm2022/angular-odata.mjs.map +1 -1
  3. package/index.d.ts +6397 -3
  4. package/package.json +3 -3
  5. package/schematics/apigen/angular/base.js +2 -6
  6. package/schematics/apigen/angular/base.js.map +1 -1
  7. package/schematics/apigen/angular/entity.js +1 -2
  8. package/schematics/apigen/angular/entity.js.map +1 -1
  9. package/schematics/apigen/index.js +2 -6
  10. package/schematics/apigen/index.js.map +1 -1
  11. package/schematics/apigen/metadata/csdl/csdl-annotation.js +1 -2
  12. package/schematics/apigen/metadata/csdl/csdl-annotation.js.map +1 -1
  13. package/schematics/apigen/metadata/csdl/csdl-entity-container.js.map +1 -1
  14. package/schematics/apigen/metadata/csdl/csdl-entity-set.js.map +1 -1
  15. package/schematics/apigen/metadata/csdl/csdl-enum-type.d.ts +1 -1
  16. package/schematics/apigen/metadata/csdl/csdl-enum-type.js +1 -1
  17. package/schematics/apigen/metadata/csdl/csdl-enum-type.js.map +1 -1
  18. package/schematics/apigen/metadata/csdl/csdl-function-action.d.ts +1 -1
  19. package/schematics/apigen/metadata/csdl/csdl-reference.js +1 -2
  20. package/schematics/apigen/metadata/csdl/csdl-reference.js.map +1 -1
  21. package/schematics/apigen/metadata/csdl/csdl-schema.js +1 -2
  22. package/schematics/apigen/metadata/csdl/csdl-schema.js.map +1 -1
  23. package/schematics/apigen/metadata/csdl/csdl-singleton.js.map +1 -1
  24. package/schematics/apigen/metadata/csdl/csdl-structural-property.d.ts +1 -1
  25. package/schematics/apigen/metadata/csdl/csdl-structural-property.js +2 -3
  26. package/schematics/apigen/metadata/csdl/csdl-structural-property.js.map +1 -1
  27. package/schematics/apigen/metadata/csdl/csdl-structured-type.d.ts +1 -1
  28. package/schematics/apigen/metadata/csdl/csdl-structured-type.js +1 -2
  29. package/schematics/apigen/metadata/csdl/csdl-structured-type.js.map +1 -1
  30. package/schematics/apigen/metadata/parser.js +1 -3
  31. package/schematics/apigen/metadata/parser.js.map +1 -1
  32. package/schematics/apigen/utils.js +2 -4
  33. package/schematics/apigen/utils.js.map +1 -1
  34. package/lib/annotations.d.ts +0 -75
  35. package/lib/api.d.ts +0 -107
  36. package/lib/cache/cache.d.ts +0 -104
  37. package/lib/cache/index.d.ts +0 -3
  38. package/lib/cache/memory.d.ts +0 -19
  39. package/lib/cache/storage.d.ts +0 -35
  40. package/lib/client.d.ts +0 -613
  41. package/lib/constants.d.ts +0 -70
  42. package/lib/helper.d.ts +0 -75
  43. package/lib/index.d.ts +0 -14
  44. package/lib/loaders.d.ts +0 -21
  45. package/lib/metadata/csdl/csdl-annotation.d.ts +0 -159
  46. package/lib/metadata/csdl/csdl-entity-container.d.ts +0 -31
  47. package/lib/metadata/csdl/csdl-entity-set.d.ts +0 -25
  48. package/lib/metadata/csdl/csdl-enum-type.d.ts +0 -37
  49. package/lib/metadata/csdl/csdl-function-action.d.ts +0 -148
  50. package/lib/metadata/csdl/csdl-navigation-property-binding.d.ts +0 -12
  51. package/lib/metadata/csdl/csdl-reference.d.ts +0 -53
  52. package/lib/metadata/csdl/csdl-schema.d.ts +0 -37
  53. package/lib/metadata/csdl/csdl-singleton.d.ts +0 -21
  54. package/lib/metadata/csdl/csdl-structural-property.d.ts +0 -86
  55. package/lib/metadata/csdl/csdl-structured-type.d.ts +0 -94
  56. package/lib/metadata/csdl/csdl-type-definition.d.ts +0 -25
  57. package/lib/metadata/index.d.ts +0 -2
  58. package/lib/metadata/metadata.d.ts +0 -23
  59. package/lib/metadata/parser.d.ts +0 -110
  60. package/lib/models/collection.d.ts +0 -183
  61. package/lib/models/index.d.ts +0 -3
  62. package/lib/models/model.d.ts +0 -176
  63. package/lib/models/options.d.ts +0 -368
  64. package/lib/module.d.ts +0 -19
  65. package/lib/options.d.ts +0 -101
  66. package/lib/resources/index.d.ts +0 -6
  67. package/lib/resources/options.d.ts +0 -18
  68. package/lib/resources/path/handlers.d.ts +0 -29
  69. package/lib/resources/path/index.d.ts +0 -2
  70. package/lib/resources/path/segments.d.ts +0 -54
  71. package/lib/resources/query/builder.d.ts +0 -103
  72. package/lib/resources/query/expressions/apply.d.ts +0 -125
  73. package/lib/resources/query/expressions/base.d.ts +0 -25
  74. package/lib/resources/query/expressions/compute.d.ts +0 -39
  75. package/lib/resources/query/expressions/count.d.ts +0 -58
  76. package/lib/resources/query/expressions/expand.d.ts +0 -69
  77. package/lib/resources/query/expressions/filter.d.ts +0 -77
  78. package/lib/resources/query/expressions/index.d.ts +0 -9
  79. package/lib/resources/query/expressions/orderby.d.ts +0 -55
  80. package/lib/resources/query/expressions/search.d.ts +0 -63
  81. package/lib/resources/query/expressions/select.d.ts +0 -34
  82. package/lib/resources/query/expressions/syntax.d.ts +0 -313
  83. package/lib/resources/query/handlers.d.ts +0 -270
  84. package/lib/resources/query/index.d.ts +0 -4
  85. package/lib/resources/query/options.d.ts +0 -60
  86. package/lib/resources/request.d.ts +0 -64
  87. package/lib/resources/resource.d.ts +0 -161
  88. package/lib/resources/response.d.ts +0 -82
  89. package/lib/resources/types/action.d.ts +0 -84
  90. package/lib/resources/types/batch.d.ts +0 -62
  91. package/lib/resources/types/count.d.ts +0 -20
  92. package/lib/resources/types/entity-set.d.ts +0 -79
  93. package/lib/resources/types/entity.d.ts +0 -54
  94. package/lib/resources/types/function.d.ts +0 -108
  95. package/lib/resources/types/index.d.ts +0 -14
  96. package/lib/resources/types/media.d.ts +0 -28
  97. package/lib/resources/types/metadata.d.ts +0 -13
  98. package/lib/resources/types/navigation-property.d.ts +0 -157
  99. package/lib/resources/types/options.d.ts +0 -32
  100. package/lib/resources/types/property.d.ts +0 -115
  101. package/lib/resources/types/reference.d.ts +0 -74
  102. package/lib/resources/types/singleton.d.ts +0 -87
  103. package/lib/resources/types/value.d.ts +0 -19
  104. package/lib/schema/annotation.d.ts +0 -28
  105. package/lib/schema/callable.d.ts +0 -41
  106. package/lib/schema/element.d.ts +0 -52
  107. package/lib/schema/entity-container.d.ts +0 -10
  108. package/lib/schema/entity-set.d.ts +0 -10
  109. package/lib/schema/enum-type.d.ts +0 -55
  110. package/lib/schema/index.d.ts +0 -8
  111. package/lib/schema/parsers/callable.d.ts +0 -47
  112. package/lib/schema/parsers/edm.d.ts +0 -4
  113. package/lib/schema/parsers/enum-type.d.ts +0 -56
  114. package/lib/schema/parsers/index.d.ts +0 -4
  115. package/lib/schema/parsers/structured-type.d.ts +0 -172
  116. package/lib/schema/schema.d.ts +0 -26
  117. package/lib/schema/singleton.d.ts +0 -10
  118. package/lib/schema/structured-type.d.ts +0 -152
  119. package/lib/services/base.d.ts +0 -20
  120. package/lib/services/entity-set.d.ts +0 -120
  121. package/lib/services/entity.d.ts +0 -11
  122. package/lib/services/factory.d.ts +0 -33
  123. package/lib/services/index.d.ts +0 -4
  124. package/lib/services/singleton.d.ts +0 -44
  125. package/lib/settings.d.ts +0 -26
  126. package/lib/types.d.ts +0 -285
  127. package/lib/utils/arraybuffers.d.ts +0 -4
  128. package/lib/utils/arrays.d.ts +0 -3
  129. package/lib/utils/dates.d.ts +0 -3
  130. package/lib/utils/durations.d.ts +0 -14
  131. package/lib/utils/enums.d.ts +0 -23
  132. package/lib/utils/http.d.ts +0 -22
  133. package/lib/utils/index.d.ts +0 -9
  134. package/lib/utils/objects.d.ts +0 -37
  135. package/lib/utils/odata.d.ts +0 -4
  136. package/lib/utils/strings.d.ts +0 -7
  137. package/lib/utils/types.d.ts +0 -11
  138. package/lib/utils/urls.d.ts +0 -4
  139. package/public-api.d.ts +0 -1
@@ -1,5 +1,5 @@
1
1
  import * as i1 from '@angular/common/http';
2
- import { HttpHeaders, HttpParams, HttpResponse, HttpErrorResponse, HttpEventType, HttpClientModule } from '@angular/common/http';
2
+ import { HttpHeaders, HttpParams, HttpResponse, HttpErrorResponse, HttpEventType } from '@angular/common/http';
3
3
  import { Subject, map as map$1, EMPTY, throwError, Observable, forkJoin, of, NEVER } from 'rxjs';
4
4
  import { map, expand, reduce, finalize, defaultIfEmpty, switchMap, catchError, tap, startWith } from 'rxjs/operators';
5
5
  import * as i0 from '@angular/core';
@@ -142,10 +142,7 @@ const HTTP11 = 'HTTP/1.1';
142
142
  const ACCEPT = 'Accept';
143
143
  const PREFER = 'Prefer';
144
144
  const CACHE_CONTROL = 'Cache-Control';
145
- const CACHE_CONTROL_HEADERS = [
146
- CACHE_CONTROL,
147
- CACHE_CONTROL.toLowerCase(),
148
- ];
145
+ const CACHE_CONTROL_HEADERS = [CACHE_CONTROL, CACHE_CONTROL.toLowerCase()];
149
146
  const ODATA_VERSION = 'OData-Version';
150
147
  const ODATA_VERSION_HEADERS = [
151
148
  ODATA_VERSION,
@@ -153,20 +150,11 @@ const ODATA_VERSION_HEADERS = [
153
150
  'dataserviceversion',
154
151
  ];
155
152
  const LOCATION_HEADER = 'Location';
156
- const LOCATION_HEADERS = [
157
- LOCATION_HEADER,
158
- LOCATION_HEADER.toLowerCase(),
159
- ];
153
+ const LOCATION_HEADERS = [LOCATION_HEADER, LOCATION_HEADER.toLowerCase()];
160
154
  const ODATA_ENTITYID = 'OData-EntityId';
161
- const ODATA_ENTITYID_HEADERS = [
162
- ODATA_ENTITYID,
163
- ODATA_ENTITYID.toLowerCase(),
164
- ];
155
+ const ODATA_ENTITYID_HEADERS = [ODATA_ENTITYID, ODATA_ENTITYID.toLowerCase()];
165
156
  const PREFERENCE_APPLIED = 'Preference-Applied';
166
- const PREFERENCE_APPLIED_HEADERS = [
167
- PREFERENCE_APPLIED,
168
- PREFERENCE_APPLIED.toLowerCase(),
169
- ];
157
+ const PREFERENCE_APPLIED_HEADERS = [PREFERENCE_APPLIED, PREFERENCE_APPLIED.toLowerCase()];
170
158
  const ETAG_HEADER = 'ETag';
171
159
  const ETAG_HEADERS = [ETAG_HEADER, ETAG_HEADER.toLowerCase()];
172
160
  const RETRY_AFTER = 'Retry-After';
@@ -252,19 +240,13 @@ const ODataVersionBaseHelper = {
252
240
  return props;
253
241
  },
254
242
  id(annots) {
255
- return annots instanceof Map
256
- ? annots.get(this.ODATA_ID)
257
- : annots[this.ODATA_ID];
243
+ return annots instanceof Map ? annots.get(this.ODATA_ID) : annots[this.ODATA_ID];
258
244
  },
259
245
  etag(annots) {
260
- return annots instanceof Map
261
- ? annots.get(this.ODATA_ETAG)
262
- : annots[this.ODATA_ETAG];
246
+ return annots instanceof Map ? annots.get(this.ODATA_ETAG) : annots[this.ODATA_ETAG];
263
247
  },
264
248
  type(annots) {
265
- let type = annots instanceof Map
266
- ? annots.get(this.ODATA_TYPE)
267
- : annots[this.ODATA_TYPE];
249
+ let type = annots instanceof Map ? annots.get(this.ODATA_TYPE) : annots[this.ODATA_TYPE];
268
250
  if (!type)
269
251
  return undefined;
270
252
  type = type.substring(1);
@@ -284,9 +266,7 @@ const ODataVersionBaseHelper = {
284
266
  : undefined;
285
267
  },
286
268
  count(annots) {
287
- return annots.has(this.ODATA_COUNT)
288
- ? Number(annots.get(this.ODATA_COUNT))
289
- : undefined;
269
+ return annots.has(this.ODATA_COUNT) ? Number(annots.get(this.ODATA_COUNT)) : undefined;
290
270
  },
291
271
  annotations(value) {
292
272
  const annots = new Map();
@@ -397,9 +377,7 @@ const ODataHelper = {
397
377
  //http://nb-mdp-dev01:57970/$metadata#SIU.Api.Infrastructure.Storage.Backend.SiuUrls
398
378
  context(annots) {
399
379
  let ctx = {};
400
- const str = annots instanceof Map
401
- ? annots.get(this.ODATA_CONTEXT)
402
- : annots[this.ODATA_CONTEXT];
380
+ const str = annots instanceof Map ? annots.get(this.ODATA_CONTEXT) : annots[this.ODATA_CONTEXT];
403
381
  if (typeof str === 'string') {
404
382
  let index = str.indexOf('$metadata');
405
383
  ctx.serviceRootUrl = str.substring(0, index);
@@ -454,9 +432,7 @@ const ODataHelper = {
454
432
  VALUE: 'value',
455
433
  context(annots) {
456
434
  let ctx = {};
457
- const str = annots instanceof Map
458
- ? annots.get(this.ODATA_CONTEXT)
459
- : annots[this.ODATA_CONTEXT];
435
+ const str = annots instanceof Map ? annots.get(this.ODATA_CONTEXT) : annots[this.ODATA_CONTEXT];
460
436
  if (typeof str === 'string') {
461
437
  let index = str.indexOf('$metadata');
462
438
  ctx.serviceRootUrl = str.substring(0, index);
@@ -521,21 +497,19 @@ const SUPPORTED_EXPAND_PROPERTIES = [
521
497
  ];
522
498
  const FUNCTION_REGEX = /\((.*)\)/;
523
499
  const INDEXOF_REGEX = /(?!indexof)\((\w+)\)/;
524
- var StandardAggregateMethods;
525
- (function (StandardAggregateMethods) {
526
- StandardAggregateMethods["sum"] = "sum";
527
- StandardAggregateMethods["min"] = "min";
528
- StandardAggregateMethods["max"] = "max";
529
- StandardAggregateMethods["average"] = "average";
530
- StandardAggregateMethods["countdistinct"] = "countdistinct";
531
- })(StandardAggregateMethods || (StandardAggregateMethods = {}));
532
- var QueryCustomTypes;
533
- (function (QueryCustomTypes) {
534
- QueryCustomTypes[QueryCustomTypes["Raw"] = 0] = "Raw";
535
- QueryCustomTypes[QueryCustomTypes["Alias"] = 1] = "Alias";
536
- QueryCustomTypes[QueryCustomTypes["Duration"] = 2] = "Duration";
537
- QueryCustomTypes[QueryCustomTypes["Binary"] = 3] = "Binary";
538
- })(QueryCustomTypes || (QueryCustomTypes = {}));
500
+ const StandardAggregateMethods = {
501
+ sum: 'sum',
502
+ min: 'min',
503
+ max: 'max',
504
+ average: 'average',
505
+ countdistinct: 'countdistinct'
506
+ };
507
+ const QueryCustomTypes = {
508
+ Raw: 'Raw',
509
+ Alias: 'Alias',
510
+ Duration: 'Duration',
511
+ Binary: 'Binary'
512
+ };
539
513
  //https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_QueryOptions
540
514
  const raw = (value) => ({
541
515
  type: QueryCustomTypes.Raw,
@@ -554,11 +528,8 @@ const binary = (value) => ({
554
528
  type: QueryCustomTypes.Binary,
555
529
  value,
556
530
  });
557
- const isQueryCustomType = (value) => typeof value === 'object' &&
558
- 'type' in value &&
559
- value.type in QueryCustomTypes;
560
- const isRawType = (value) => isQueryCustomType(value) &&
561
- value.type === QueryCustomTypes.Raw;
531
+ const isQueryCustomType = (value) => typeof value === 'object' && 'type' in value && value.type in QueryCustomTypes;
532
+ const isRawType = (value) => isQueryCustomType(value) && value.type === QueryCustomTypes.Raw;
562
533
  const ITEM_ROOT = '';
563
534
  function builder ({ select, search, skiptoken, format, top, skip, filter, transform, compute, orderBy, key, count, expand, action, func, aliases, escape, } = {}) {
564
535
  const [path, params] = buildPathAndQuery({
@@ -732,14 +703,10 @@ function buildFilter(filters = {}, { aliases, propPrefix, escape, }) {
732
703
  propName = propPrefix;
733
704
  }
734
705
  else if (INDEXOF_REGEX.test(filterKey)) {
735
- propName = filterKey.replace(INDEXOF_REGEX, (_, $1) => $1.trim() === ITEM_ROOT
736
- ? `(${propPrefix})`
737
- : `(${propPrefix}/${$1.trim()})`);
706
+ propName = filterKey.replace(INDEXOF_REGEX, (_, $1) => $1.trim() === ITEM_ROOT ? `(${propPrefix})` : `(${propPrefix}/${$1.trim()})`);
738
707
  }
739
708
  else if (FUNCTION_REGEX.test(filterKey)) {
740
- propName = filterKey.replace(FUNCTION_REGEX, (_, $1) => $1.trim() === ITEM_ROOT
741
- ? `(${propPrefix})`
742
- : `(${propPrefix}/${$1.trim()})`);
709
+ propName = filterKey.replace(FUNCTION_REGEX, (_, $1) => $1.trim() === ITEM_ROOT ? `(${propPrefix})` : `(${propPrefix}/${$1.trim()})`);
743
710
  }
744
711
  else {
745
712
  propName = `${propPrefix}/${filterKey}`;
@@ -762,7 +729,7 @@ function buildFilter(filters = {}, { aliases, propPrefix, escape, }) {
762
729
  const builtFilters = value
763
730
  .map((v) => buildFilter(v, { aliases, propPrefix, escape }))
764
731
  .filter((f) => f)
765
- .map((f) => LOGICAL_OPERATORS.indexOf(op) !== -1 ? `(${f})` : f);
732
+ .map((f) => (LOGICAL_OPERATORS.indexOf(op) !== -1 ? `(${f})` : f));
766
733
  if (builtFilters.length) {
767
734
  if (LOGICAL_OPERATORS.indexOf(op) !== -1) {
768
735
  if (builtFilters.length) {
@@ -918,10 +885,8 @@ function buildFilter(filters = {}, { aliases, propPrefix, escape, }) {
918
885
  }
919
886
  }
920
887
  function getStringCollectionClause(lambdaParameter, value, collectionOperator, propName) {
921
- let clause = '';
922
888
  const conditionOperator = collectionOperator == 'all' ? 'ne' : 'eq';
923
- clause = `${propName}/${collectionOperator}(${lambdaParameter}: ${lambdaParameter} ${conditionOperator} '${value}')`;
924
- return clause;
889
+ return `${propName}/${collectionOperator}(${lambdaParameter}: ${lambdaParameter} ${conditionOperator} '${value}')`;
925
890
  }
926
891
  function escapeIllegalChars(string) {
927
892
  string = string.replace(/%/g, '%25');
@@ -933,7 +898,7 @@ function escapeIllegalChars(string) {
933
898
  string = string.replace(/'/g, "''");
934
899
  return string;
935
900
  }
936
- function normalizeValue(value, { aliases, escape = false, } = {}) {
901
+ function normalizeValue(value, { aliases, escape = false } = {}) {
937
902
  if (typeof value === 'string') {
938
903
  return escape ? `'${escapeIllegalChars(value)}'` : `'${value}'`;
939
904
  }
@@ -944,9 +909,7 @@ function normalizeValue(value, { aliases, escape = false, } = {}) {
944
909
  return value;
945
910
  }
946
911
  else if (Array.isArray(value)) {
947
- return `[${value
948
- .map((d) => normalizeValue(d, { aliases, escape }))
949
- .join(',')}]`;
912
+ return `[${value.map((d) => normalizeValue(d, { aliases, escape })).join(',')}]`;
950
913
  }
951
914
  else if (value === null) {
952
915
  return value;
@@ -977,7 +940,7 @@ function normalizeValue(value, { aliases, escape = false, } = {}) {
977
940
  }
978
941
  return value;
979
942
  }
980
- function buildExpand(expands, { aliases, escape = false, }) {
943
+ function buildExpand(expands, { aliases, escape = false }) {
981
944
  if (isRawType(expands)) {
982
945
  return expands.value;
983
946
  }
@@ -1037,7 +1000,10 @@ function buildExpand(expands, { aliases, escape = false, }) {
1037
1000
  value = value.value;
1038
1001
  break;
1039
1002
  default:
1040
- value = buildExpand(expands[key], { aliases, escape });
1003
+ value = buildExpand(expands[key], {
1004
+ aliases,
1005
+ escape,
1006
+ });
1041
1007
  }
1042
1008
  return `$${key.toLowerCase()}=${value}`;
1043
1009
  })
@@ -1054,31 +1020,44 @@ function buildExpand(expands, { aliases, escape = false, }) {
1054
1020
  }
1055
1021
  return '';
1056
1022
  }
1057
- function buildTransforms(transforms, { aliases, escape = false, }) {
1023
+ function buildTransforms(transforms, { aliases, escape = false }) {
1058
1024
  // Wrap single object an array for simplified processing
1059
1025
  const transformsArray = Array.isArray(transforms) ? transforms : [transforms];
1060
1026
  const transformsResult = transformsArray.reduce((result, transform) => {
1061
- const { aggregate, filter, groupBy, ...rest } = transform;
1062
- // TODO: support as many of the following:
1063
- // topcount, topsum, toppercent,
1064
- // bottomsum, bottomcount, bottompercent,
1065
- // identity, concat, expand, search, compute, isdefined
1066
- const unsupportedKeys = Object.keys(rest);
1067
- if (unsupportedKeys.length) {
1068
- throw new Error(`Unsupported transform(s): ${unsupportedKeys}`);
1069
- }
1070
- if (aggregate) {
1071
- result.push(`aggregate(${buildAggregate(aggregate)})`);
1072
- }
1073
- if (filter) {
1074
- const builtFilter = buildFilter(filter, { aliases, escape });
1075
- if (builtFilter) {
1076
- result.push(`filter(${buildFilter(builtFilter, { aliases, escape })})`);
1027
+ for (const key of Object.keys(transform)) {
1028
+ switch (key) {
1029
+ // TODO: support as many of the following:
1030
+ // topcount, topsum, toppercent,
1031
+ // bottomsum, bottomcount, bottompercent,
1032
+ // identity, concat, expand, search, compute, isdefined
1033
+ case 'aggregate': {
1034
+ const aggregate = transform[key];
1035
+ if (aggregate) {
1036
+ result.push(`aggregate(${buildAggregate(aggregate)})`);
1037
+ }
1038
+ break;
1039
+ }
1040
+ case 'filter': {
1041
+ const filter = transform[key];
1042
+ if (filter) {
1043
+ const builtFilter = buildFilter(filter, { aliases, escape });
1044
+ if (builtFilter) {
1045
+ result.push(`filter(${builtFilter})`);
1046
+ }
1047
+ }
1048
+ break;
1049
+ }
1050
+ case 'groupBy': {
1051
+ const groupBy = transform[key];
1052
+ if (groupBy) {
1053
+ result.push(`groupby(${buildGroupBy(groupBy, { aliases, escape })})`);
1054
+ }
1055
+ break;
1056
+ }
1057
+ default:
1058
+ throw new Error(`Unsupported transform(s): ${key}`);
1077
1059
  }
1078
1060
  }
1079
- if (groupBy) {
1080
- result.push(`groupby(${buildGroupBy(groupBy, { aliases, escape })})`);
1081
- }
1082
1061
  return result;
1083
1062
  }, []);
1084
1063
  return transformsResult.join('/') || undefined;
@@ -1104,7 +1083,7 @@ function buildAggregate(aggregate) {
1104
1083
  })
1105
1084
  .join(',');
1106
1085
  }
1107
- function buildGroupBy(groupBy, { aliases, escape = false, }) {
1086
+ function buildGroupBy(groupBy, { aliases, escape = false }) {
1108
1087
  if (!groupBy.properties) {
1109
1088
  throw new Error(`'properties' property required for groupBy`);
1110
1089
  }
@@ -1120,9 +1099,7 @@ function buildOrderBy(orderBy, prefix = '') {
1120
1099
  }
1121
1100
  else if (Array.isArray(orderBy)) {
1122
1101
  return orderBy
1123
- .map((value) => Array.isArray(value) &&
1124
- value.length === 2 &&
1125
- ['asc', 'desc'].indexOf(value[1]) !== -1
1102
+ .map((value) => Array.isArray(value) && value.length === 2 && ['asc', 'desc'].indexOf(value[1]) !== -1
1126
1103
  ? value.join(' ')
1127
1104
  : value)
1128
1105
  .map((v) => `${prefix}${v}`)
@@ -1136,11 +1113,9 @@ function buildOrderBy(orderBy, prefix = '') {
1136
1113
  }
1137
1114
  return `${prefix}${orderBy}`;
1138
1115
  }
1139
- function buildApply(apply, { aliases, escape = false, }) {
1116
+ function buildApply(apply, { aliases, escape = false }) {
1140
1117
  const applyArray = Array.isArray(apply) ? apply : [apply];
1141
- return applyArray
1142
- .map((v) => normalizeValue(v, { aliases, escape }))
1143
- .join('/');
1118
+ return applyArray.map((v) => normalizeValue(v, { aliases, escape })).join('/');
1144
1119
  }
1145
1120
  function buildUrl(path, params) {
1146
1121
  // This can be refactored using URL API. But IE does not support it.
@@ -1178,15 +1153,7 @@ const Durations = {
1178
1153
  }
1179
1154
  let duration = {};
1180
1155
  duration.sign = matches[1] === '-' ? -1 : 1;
1181
- return [
1182
- 'years',
1183
- 'months',
1184
- 'weeks',
1185
- 'days',
1186
- 'hours',
1187
- 'minutes',
1188
- 'seconds',
1189
- ].reduce((acc, name, index) => {
1156
+ return ['years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds'].reduce((acc, name, index) => {
1190
1157
  const v = parseFloat(matches[index + 2]);
1191
1158
  if (!Number.isNaN(v))
1192
1159
  acc[name] = v;
@@ -1262,9 +1229,7 @@ const Enums = {
1262
1229
  value = value.split(',').map((o) => o.trim());
1263
1230
  }
1264
1231
  if (Array.isArray(value) && value.every((v) => v in enums)) {
1265
- return value
1266
- .filter((v) => enums[v])
1267
- .map((v) => this.toName(enums, v));
1232
+ return value.filter((v) => enums[v]).map((v) => this.toName(enums, v));
1268
1233
  }
1269
1234
  return [];
1270
1235
  },
@@ -1310,8 +1275,7 @@ const Types = {
1310
1275
  (Types.isMap(value) && !value.size) ||
1311
1276
  (Types.isArray(value) && !value.length) ||
1312
1277
  (Types.isFunction(value.isEmpty) && value.isEmpty()) ||
1313
- (Types.isArray(value) &&
1314
- value.every((v) => Types.isEmpty(v))) ||
1278
+ (Types.isArray(value) && value.every((v) => Types.isEmpty(v))) ||
1315
1279
  (Types.isPlainObject(value) &&
1316
1280
  !Object.keys(value).filter((k) => value.hasOwnProperty(k)).length));
1317
1281
  },
@@ -1522,7 +1486,7 @@ const Objects = {
1522
1486
  // Check if path is string or array. Regex : ensure that we do not have '.' and brackets.
1523
1487
  const pathArray = (Types.isArray(path) ? path : path.match(/([^[.\]])+/g));
1524
1488
  // Find value if exist return otherwise return undefined value;
1525
- return (pathArray.reduce((prevObj, key) => prevObj && prevObj[key], obj) || def);
1489
+ return pathArray.reduce((prevObj, key) => prevObj && prevObj[key], obj) || def;
1526
1490
  },
1527
1491
  unset(obj, path) {
1528
1492
  // Check if path is string or array. Regex : ensure that we do not have '.' and brackets.
@@ -1563,8 +1527,7 @@ const Objects = {
1563
1527
  const val1 = object1[key];
1564
1528
  const val2 = object2[key];
1565
1529
  const areObjects = Types.isPlainObject(val1) && Types.isPlainObject(val2);
1566
- if ((areObjects && !Objects.equal(val1, val2)) ||
1567
- (!areObjects && val1 !== val2)) {
1530
+ if ((areObjects && !Objects.equal(val1, val2)) || (!areObjects && val1 !== val2)) {
1568
1531
  return false;
1569
1532
  }
1570
1533
  }
@@ -1729,7 +1692,7 @@ function now() {
1729
1692
  return (glast = time > last ? time : last + 1);
1730
1693
  }
1731
1694
  const Strings = {
1732
- uniqueId({ prefix, suffix, } = {}) {
1695
+ uniqueId({ prefix, suffix } = {}) {
1733
1696
  return (prefix ? prefix : '') + now().toString(36) + (suffix ? suffix : '');
1734
1697
  },
1735
1698
  titleCase(text) {
@@ -1739,6 +1702,16 @@ const Strings = {
1739
1702
  .map((p) => p.charAt(0).toUpperCase() + p.slice(1))
1740
1703
  .join(' ');
1741
1704
  },
1705
+ hashCode(text) {
1706
+ if (!text || text.length === 0) {
1707
+ return 0;
1708
+ }
1709
+ let hash = 0;
1710
+ for (let i = 0; i < text.length; i++) {
1711
+ hash = Math.imul(hash, 31) + text.charCodeAt(i);
1712
+ }
1713
+ return hash;
1714
+ },
1742
1715
  };
1743
1716
 
1744
1717
  const Urls = {
@@ -1787,6 +1760,15 @@ class Expression {
1787
1760
  resolve(parser) {
1788
1761
  return parser;
1789
1762
  }
1763
+ toString() {
1764
+ return this.render({
1765
+ aliases: [],
1766
+ escape: true,
1767
+ prefix: '',
1768
+ parser: undefined,
1769
+ options: {},
1770
+ });
1771
+ }
1790
1772
  }
1791
1773
 
1792
1774
  class ODataAnnotation {
@@ -1950,14 +1932,10 @@ const ArrayBuffers = {
1950
1932
  // Core EdmTypeParserBuilder
1951
1933
  const EdmParser = (_d, _s, _e) => ({
1952
1934
  deserialize(value, options) {
1953
- return Array.isArray(value)
1954
- ? value.map((v) => _d(v, options))
1955
- : _d(value, options);
1935
+ return Array.isArray(value) ? value.map((v) => _d(v, options)) : _d(value, options);
1956
1936
  },
1957
1937
  serialize(value, options) {
1958
- return Array.isArray(value)
1959
- ? value.map((v) => _s(v, options))
1960
- : _s(value, options);
1938
+ return Array.isArray(value) ? value.map((v) => _s(v, options)) : _s(value, options);
1961
1939
  },
1962
1940
  encode(value, options) {
1963
1941
  return Array.isArray(value)
@@ -2089,8 +2067,7 @@ class ODataEnumTypeParser extends ODataAnnotatable {
2089
2067
  return [...this._fields.filter((f) => namesValue.includes(f.value))];
2090
2068
  if (typeof namesValue === 'number') {
2091
2069
  return [
2092
- ...this._fields.filter((f) => (this.flags && Boolean(f.value & namesValue)) ||
2093
- f.value === namesValue),
2070
+ ...this._fields.filter((f) => (this.flags && Boolean(f.value & namesValue)) || f.value === namesValue),
2094
2071
  ];
2095
2072
  }
2096
2073
  if (typeof namesValue === 'string') {
@@ -2142,9 +2119,7 @@ class ODataEnumTypeParser extends ODataAnnotatable {
2142
2119
  let name = this.field(value)?.name;
2143
2120
  if (name === undefined)
2144
2121
  name = `${value}`;
2145
- return !parserOptions?.stringAsEnum
2146
- ? `${this.namespace}.${this.name}'${name}'`
2147
- : name;
2122
+ return !parserOptions?.stringAsEnum ? `${this.namespace}.${this.name}'${name}'` : name;
2148
2123
  }
2149
2124
  }
2150
2125
  //Encode
@@ -2153,9 +2128,7 @@ class ODataEnumTypeParser extends ODataAnnotatable {
2153
2128
  const serialized = this.serialize(value, parserOptions);
2154
2129
  if (serialized === undefined)
2155
2130
  return undefined;
2156
- return parserOptions?.stringAsEnum
2157
- ? raw(`'${serialized}'`)
2158
- : raw(serialized);
2131
+ return parserOptions?.stringAsEnum ? raw(`'${serialized}'`) : raw(serialized);
2159
2132
  }
2160
2133
  // Json Schema
2161
2134
  toJsonSchema() {
@@ -2200,7 +2173,7 @@ class ODataEntityTypeKey {
2200
2173
  class ODataReferential {
2201
2174
  property;
2202
2175
  referencedProperty;
2203
- constructor({ property, referencedProperty, }) {
2176
+ constructor({ property, referencedProperty }) {
2204
2177
  this.property = property;
2205
2178
  this.referencedProperty = referencedProperty;
2206
2179
  }
@@ -2239,16 +2212,13 @@ class ODataStructuredTypeFieldParser extends ODataAnnotatable {
2239
2212
  if (this.collection && Array.isArray(value)) {
2240
2213
  errors = value.map((v) => this.validate(v, { method, navigation }));
2241
2214
  }
2242
- else if ((this.isStructuredType() &&
2243
- typeof value === 'object' &&
2244
- value !== null) ||
2215
+ else if ((this.isStructuredType() && typeof value === 'object' && value !== null) ||
2245
2216
  (this.navigation && value !== undefined)) {
2246
2217
  errors =
2247
2218
  this.structuredType().validate(value, { method, navigation }) ||
2248
2219
  {};
2249
2220
  }
2250
- else if (this.isEnumType() &&
2251
- (typeof value === 'string' || typeof value === 'number')) {
2221
+ else if (this.isEnumType() && (typeof value === 'string' || typeof value === 'number')) {
2252
2222
  errors = this.enumType().validate(value, { method, navigation });
2253
2223
  }
2254
2224
  else {
@@ -2275,9 +2245,7 @@ class ODataStructuredTypeFieldParser extends ODataAnnotatable {
2275
2245
  ? ODataHelper[options?.version || DEFAULT_VERSION].type(value)
2276
2246
  : undefined;
2277
2247
  if (type !== undefined) {
2278
- return parser
2279
- .childParser((c) => c.isTypeOf(type))
2280
- .deserialize(value, options);
2248
+ return parser.childParser((c) => c.isTypeOf(type)).deserialize(value, options);
2281
2249
  }
2282
2250
  return parser.deserialize(value, options);
2283
2251
  }
@@ -2301,9 +2269,7 @@ class ODataStructuredTypeFieldParser extends ODataAnnotatable {
2301
2269
  ? ODataHelper[options?.version || DEFAULT_VERSION].type(value)
2302
2270
  : undefined;
2303
2271
  if (type !== undefined) {
2304
- return parser
2305
- .childParser((c) => c.isTypeOf(type))
2306
- .serialize(value, options);
2272
+ return parser.childParser((c) => c.isTypeOf(type)).serialize(value, options);
2307
2273
  }
2308
2274
  return parser.serialize(value, options);
2309
2275
  }
@@ -2407,9 +2373,7 @@ class ODataStructuredTypeFieldParser extends ODataAnnotatable {
2407
2373
  }
2408
2374
  //#endregion
2409
2375
  isKey() {
2410
- return this.structured
2411
- .keys({ include_parents: true })
2412
- .some((k) => k.name === this.name);
2376
+ return this.structured.keys({ include_parents: true }).some((k) => k.name === this.name);
2413
2377
  }
2414
2378
  hasReferentials() {
2415
2379
  return this.referentials.length !== 0;
@@ -2489,7 +2453,7 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
2489
2453
  return false;
2490
2454
  }
2491
2455
  isSupertypeOf(type) {
2492
- return (this.isTypeOf(type) || this.children.some((c) => c.isSupertypeOf(type)));
2456
+ return this.isTypeOf(type) || this.children.some((c) => c.isSupertypeOf(type));
2493
2457
  }
2494
2458
  isOpenType() {
2495
2459
  return this.open;
@@ -2514,9 +2478,7 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
2514
2478
  const fields = this.fields({
2515
2479
  include_navigation: true,
2516
2480
  include_parents: true,
2517
- }).filter((f) => f.name in value &&
2518
- value[f.name] !== undefined &&
2519
- value[f.name] !== null);
2481
+ }).filter((f) => f.name in value && value[f.name] !== undefined && value[f.name] !== null);
2520
2482
  return {
2521
2483
  ...value,
2522
2484
  ...fields.reduce((acc, f) => ({
@@ -2531,9 +2493,7 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
2531
2493
  const fields = this.fields({
2532
2494
  include_navigation: true,
2533
2495
  include_parents: true,
2534
- }).filter((f) => f.name in value &&
2535
- value[f.name] !== undefined &&
2536
- value[f.name] !== null);
2496
+ }).filter((f) => f.name in value && value[f.name] !== undefined && value[f.name] !== null);
2537
2497
  return {
2538
2498
  ...value,
2539
2499
  ...fields.reduce((acc, f) => ({
@@ -2575,7 +2535,7 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
2575
2535
  * @param include_parents Include the parent fields
2576
2536
  * @returns The keys of the structured type
2577
2537
  */
2578
- keys({ include_parents, }) {
2538
+ keys({ include_parents }) {
2579
2539
  return [
2580
2540
  ...(include_parents && this.parent !== undefined
2581
2541
  ? this.parent.keys({ include_parents })
@@ -2584,8 +2544,7 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
2584
2544
  ];
2585
2545
  }
2586
2546
  isEntityType() {
2587
- return (this._keys !== undefined ||
2588
- (this.parent !== undefined && this.parent.isEntityType()));
2547
+ return this._keys !== undefined || (this.parent !== undefined && this.parent.isEntityType());
2589
2548
  }
2590
2549
  isComplexType() {
2591
2550
  return !this.isEntityType();
@@ -2624,15 +2583,12 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
2624
2583
  }
2625
2584
  return Object.keys(attrs)
2626
2585
  .filter((key) => fields.some((f) => f.name === key) ||
2627
- (key ==
2628
- ODataHelper[parserOptions?.version || DEFAULT_VERSION].ODATA_ETAG &&
2586
+ (key == ODataHelper[parserOptions?.version || DEFAULT_VERSION].ODATA_ETAG &&
2629
2587
  include_etag) ||
2630
- (key ==
2631
- ODataHelper[parserOptions?.version || DEFAULT_VERSION].ODATA_ID &&
2632
- include_id))
2588
+ (key == ODataHelper[parserOptions?.version || DEFAULT_VERSION].ODATA_ID && include_id))
2633
2589
  .reduce((acc, key) => Object.assign(acc, { [key]: attrs[key] }), {});
2634
2590
  }
2635
- resolveKey(value, { resolve = true, single = true, } = {}) {
2591
+ resolveKey(value, { resolve = true, single = true } = {}) {
2636
2592
  const keyTypes = this.keys({ include_parents: true });
2637
2593
  const key = new Map();
2638
2594
  for (var kt of keyTypes) {
@@ -2647,9 +2603,7 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
2647
2603
  .find((f) => f.name === name);
2648
2604
  if (field !== undefined) {
2649
2605
  v = Types.isPlainObject(v) ? v[field.name] : v;
2650
- structured = field.isStructuredType()
2651
- ? field.structuredType()
2652
- : undefined;
2606
+ structured = field.isStructuredType() ? field.structuredType() : undefined;
2653
2607
  }
2654
2608
  }
2655
2609
  if (field !== undefined && v !== undefined) {
@@ -2658,9 +2612,7 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
2658
2612
  }
2659
2613
  if (key.size === 0)
2660
2614
  return undefined;
2661
- return resolve
2662
- ? Objects.resolveKey(key, { single })
2663
- : Object.fromEntries(key);
2615
+ return resolve ? Objects.resolveKey(key, { single }) : Object.fromEntries(key);
2664
2616
  }
2665
2617
  defaults() {
2666
2618
  let fields = this.fields({
@@ -2669,9 +2621,7 @@ class ODataStructuredTypeParser extends ODataAnnotatable {
2669
2621
  }).filter((f) => f.default !== undefined || f.isStructuredType());
2670
2622
  return {
2671
2623
  ...fields.reduce((acc, f) => {
2672
- let value = f.isStructuredType()
2673
- ? f.structuredType().defaults()
2674
- : f.default;
2624
+ let value = f.isStructuredType() ? f.structuredType().defaults() : f.default;
2675
2625
  return Types.isEmpty(value) ? acc : { ...acc, [f.name]: value };
2676
2626
  }, {}),
2677
2627
  };
@@ -3055,8 +3005,7 @@ class ODataStructuredType extends ODataParserSchemaElement {
3055
3005
  * @returns True if the callable is type of the given type
3056
3006
  */
3057
3007
  isSubtypeOf(schema) {
3058
- return (super.isSubtypeOf(schema) ||
3059
- (this.parent !== undefined && this.parent.isSubtypeOf(schema)));
3008
+ return (super.isSubtypeOf(schema) || (this.parent !== undefined && this.parent.isSubtypeOf(schema)));
3060
3009
  }
3061
3010
  /**
3062
3011
  * Returns a boolean indicating if the structured type is a supertype of the given type.
@@ -3064,8 +3013,7 @@ class ODataStructuredType extends ODataParserSchemaElement {
3064
3013
  * @returns True if the callable is type of the given type
3065
3014
  */
3066
3015
  isSupertypeOf(schema) {
3067
- return (super.isSupertypeOf(schema) ||
3068
- this.children.some((c) => c.isSupertypeOf(schema)));
3016
+ return super.isSupertypeOf(schema) || this.children.some((c) => c.isSupertypeOf(schema));
3069
3017
  }
3070
3018
  /**
3071
3019
  * Returns a boolean indicating if the structured type has a simple key.
@@ -3130,9 +3078,8 @@ class ODataStructuredType extends ODataParserSchemaElement {
3130
3078
  * @returns The schema of the field
3131
3079
  */
3132
3080
  findParentSchemaForField(field) {
3133
- return this.findParentSchema((p) => p
3134
- .fields({ include_parents: false, include_navigation: true })
3135
- .find((f) => f === field) !== undefined);
3081
+ return this.findParentSchema((p) => p.fields({ include_parents: false, include_navigation: true }).find((f) => f === field) !==
3082
+ undefined);
3136
3083
  }
3137
3084
  /**
3138
3085
  * Picks the fields from attributes.
@@ -3250,8 +3197,7 @@ class ODataSchema extends ODataAnnotatable {
3250
3197
  this.containers = (config.containers ?? []).map((config) => new ODataEntityContainer(config, this));
3251
3198
  }
3252
3199
  isNamespaceOf(type) {
3253
- return (type.startsWith(this.namespace) ??
3254
- (this.alias && type.startsWith(this.alias)));
3200
+ return type.startsWith(this.namespace) ?? (this.alias && type.startsWith(this.alias));
3255
3201
  }
3256
3202
  get entitySets() {
3257
3203
  return this.containers.reduce((acc, container) => [...acc, ...container.entitySets], []);
@@ -3293,10 +3239,7 @@ class CountField {
3293
3239
  };
3294
3240
  }
3295
3241
  render({ aliases, escape, prefix, parser, options, }) {
3296
- const params = [
3297
- QueryOption.filter,
3298
- QueryOption.search,
3299
- ]
3242
+ const params = [QueryOption.filter, QueryOption.search]
3300
3243
  .filter((key) => !Types.isEmpty(this.values[key]))
3301
3244
  .reduce((acc, key) => {
3302
3245
  let value = this.values[key];
@@ -3482,9 +3425,7 @@ class FilterExpression extends Expression {
3482
3425
  this._children = [...this._children, ...node.children()];
3483
3426
  }
3484
3427
  else {
3485
- this._children.push(node instanceof FilterExpression && !node.negated()
3486
- ? syntax.group(node)
3487
- : node);
3428
+ this._children.push(node instanceof FilterExpression && !node.negated() ? syntax.group(node) : node);
3488
3429
  }
3489
3430
  return this;
3490
3431
  }
@@ -3653,9 +3594,7 @@ class SearchExpression extends Expression {
3653
3594
  this._children = [...this._children, ...node.children()];
3654
3595
  }
3655
3596
  else {
3656
- this._children.push(node instanceof SearchExpression && !node.negated()
3657
- ? syntax.group(node)
3658
- : node);
3597
+ this._children.push(node instanceof SearchExpression && !node.negated() ? syntax.group(node) : node);
3659
3598
  }
3660
3599
  return this;
3661
3600
  }
@@ -3740,9 +3679,7 @@ class GroupByTransformations extends Expression {
3740
3679
  });
3741
3680
  }
3742
3681
  render({ aliases, escape, prefix, parser, options, } = {}) {
3743
- const children = this._children.map((n) => typeof n !== 'string'
3744
- ? n.render({ aliases, escape, prefix, parser, options })
3745
- : n);
3682
+ const children = this._children.map((n) => typeof n !== 'string' ? n.render({ aliases, escape, prefix, parser, options }) : n);
3746
3683
  return `aggregate(${children
3747
3684
  .map((child, index) => !child
3748
3685
  ? `${this.methods[index]} as ${this.aliases[index]}`
@@ -3751,7 +3688,7 @@ class GroupByTransformations extends Expression {
3751
3688
  }
3752
3689
  clone() {
3753
3690
  return new GroupByTransformations({
3754
- children: this._children.map((c) => typeof c !== 'string' ? c.clone() : c),
3691
+ children: this._children.map((c) => (typeof c !== 'string' ? c.clone() : c)),
3755
3692
  methods: this.methods,
3756
3693
  aliases: this.aliases,
3757
3694
  });
@@ -4053,9 +3990,7 @@ class SelectExpression extends Expression {
4053
3990
  }
4054
3991
  render({ aliases, escape, prefix, parser, options, } = {}) {
4055
3992
  return this._children
4056
- .map((n) => typeof n === 'string'
4057
- ? n
4058
- : n.render({ aliases, escape, prefix, parser, options }))
3993
+ .map((n) => typeof n === 'string' ? n : n.render({ aliases, escape, prefix, parser, options }))
4059
3994
  .join(',');
4060
3995
  }
4061
3996
  clone() {
@@ -4217,10 +4152,17 @@ class ExpandExpression extends Expression {
4217
4152
  return this;
4218
4153
  }
4219
4154
  field(field, opts) {
4220
- let node = new ExpandField(field);
4155
+ // Find ExpandField by fieldKey or create a new one if not found
4156
+ let fieldKey = field.toString();
4157
+ let node = this._children.find((n) => n.toString() === fieldKey);
4158
+ if (node === undefined) {
4159
+ // If not found, create a new ExpandField
4160
+ node = new ExpandField(field);
4161
+ this._add(node);
4162
+ }
4221
4163
  if (opts !== undefined)
4222
4164
  opts(node);
4223
- return this._add(node);
4165
+ return this;
4224
4166
  }
4225
4167
  combine(expression) {
4226
4168
  return this._add(expression);
@@ -4251,18 +4193,18 @@ const FieldFactory = (names = []) => new Proxy({ _names: names }, {
4251
4193
  names: names,
4252
4194
  });
4253
4195
  }
4196
+ else if (key === 'toString') {
4197
+ return () => names.join('.');
4198
+ }
4254
4199
  else if (key === 'resolve') {
4255
- return (parser) => names.reduce((acc, name) => typeof name === 'string'
4256
- ? acc?.field(name)
4257
- : name?.resolve(parser), parser);
4200
+ return (parser) => names.reduce((acc, name) => typeof name === 'string' ? acc?.field(name) : name?.resolve(parser), parser);
4258
4201
  }
4259
4202
  else {
4260
4203
  return FieldFactory([...names, key]);
4261
4204
  }
4262
4205
  },
4263
4206
  has(target, key) {
4264
- return (['toJson', 'isField', 'clone', 'render', 'resolve'].includes(key) ||
4265
- key in target);
4207
+ return ['toJson', 'isField', 'clone', 'render', 'resolve'].includes(key) || key in target;
4266
4208
  },
4267
4209
  });
4268
4210
  const RenderableFactory = (value) => {
@@ -4311,8 +4253,7 @@ const RenderableFactory = (value) => {
4311
4253
  function applyMixins(derivedCtor, constructors) {
4312
4254
  constructors.forEach((baseCtor) => {
4313
4255
  Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
4314
- Object.defineProperty(derivedCtor.prototype, name, Object.getOwnPropertyDescriptor(baseCtor.prototype, name) ||
4315
- Object.create(null));
4256
+ Object.defineProperty(derivedCtor.prototype, name, Object.getOwnPropertyDescriptor(baseCtor.prototype, name) || Object.create(null));
4316
4257
  });
4317
4258
  });
4318
4259
  }
@@ -4382,7 +4323,7 @@ class Function {
4382
4323
  return {
4383
4324
  $type: Types.rawType(this),
4384
4325
  name: this.name,
4385
- values: this.values.map((v) => Types.isObject(v) && 'toJson' in v ? v.toJson() : v),
4326
+ values: this.values.map((v) => (Types.isObject(v) && 'toJson' in v ? v.toJson() : v)),
4386
4327
  normalize: this.normalize,
4387
4328
  };
4388
4329
  }
@@ -4527,9 +4468,7 @@ class ArithmeticFunctions {
4527
4468
  class TypeFunctions {
4528
4469
  cast(left, type) {
4529
4470
  return FieldFactory([
4530
- type !== undefined
4531
- ? new Type('cast', type, left)
4532
- : new Type('cast', left),
4471
+ type !== undefined ? new Type('cast', type, left) : new Type('cast', left),
4533
4472
  ]);
4534
4473
  }
4535
4474
  isof(left, type) {
@@ -4570,7 +4509,7 @@ class Operator {
4570
4509
  return {
4571
4510
  $type: Types.rawType(this),
4572
4511
  op: this.op,
4573
- values: this.values.map((v) => Types.isObject(v) && 'toJson' in v ? v.toJson() : v),
4512
+ values: this.values.map((v) => (Types.isObject(v) && 'toJson' in v ? v.toJson() : v)),
4574
4513
  normalize: this.normalize,
4575
4514
  };
4576
4515
  }
@@ -4879,17 +4818,14 @@ class Type {
4879
4818
  let [left, right] = encode([this.value], parser, options);
4880
4819
  value = render(left, { aliases, escape, prefix, parser, options });
4881
4820
  }
4882
- return value
4883
- ? `${this.name}(${value}, '${this.type}')`
4884
- : `${this.name}('${this.type}')`;
4821
+ return value ? `${this.name}(${value}, '${this.type}')` : `${this.name}('${this.type}')`;
4885
4822
  }
4886
4823
  clone() {
4887
4824
  return new Type(this.name, this.type, Objects.clone(this.value));
4888
4825
  }
4889
4826
  resolve(parser) {
4890
4827
  parser =
4891
- parser instanceof ODataStructuredTypeFieldParser &&
4892
- parser.isStructuredType()
4828
+ parser instanceof ODataStructuredTypeFieldParser && parser.isStructuredType()
4893
4829
  ? parser.structuredType()
4894
4830
  : parser;
4895
4831
  return parser?.findChildParser((p) => p.isTypeOf(this.type));
@@ -4911,7 +4847,7 @@ class Lambda {
4911
4847
  return {
4912
4848
  $type: Types.rawType(this),
4913
4849
  op: this.op,
4914
- values: this.values.map((v) => Types.isObject(v) && 'toJson' in v ? v.toJson() : v),
4850
+ values: this.values.map((v) => (Types.isObject(v) && 'toJson' in v ? v.toJson() : v)),
4915
4851
  alias: this.alias,
4916
4852
  };
4917
4853
  }
@@ -4979,11 +4915,7 @@ applyMixins(ODataTransformations, [Transformations]);
4979
4915
  const transformations = new ODataTransformations();
4980
4916
  class ODataSyntax {
4981
4917
  }
4982
- applyMixins(ODataSyntax, [
4983
- ODataOperators,
4984
- ODataFunctions,
4985
- ODataTransformations,
4986
- ]);
4918
+ applyMixins(ODataSyntax, [ODataOperators, ODataFunctions, ODataTransformations]);
4987
4919
  const syntax = new ODataSyntax();
4988
4920
 
4989
4921
  class ComputeExpression extends Expression {
@@ -5015,9 +4947,7 @@ class ComputeExpression extends Expression {
5015
4947
  }
5016
4948
  render({ aliases, escape, prefix, parser, options, } = {}) {
5017
4949
  const children = this._children.map((n) => n.render({ aliases, escape, prefix, parser, options }));
5018
- return this.names
5019
- .map((name, index) => `${children[index]} as ${name}`)
5020
- .join(',');
4950
+ return this.names.map((name, index) => `${children[index]} as ${name}`).join(',');
5021
4951
  }
5022
4952
  clone() {
5023
4953
  return new ComputeExpression({
@@ -5098,8 +5028,7 @@ class ODataQueryOptionHandler {
5098
5028
  remove(value) {
5099
5029
  this.o.set(this.n, this.assertArray().filter((v) => v !== value));
5100
5030
  // If only one and not is array... down to value
5101
- if (this.o.get(this.n).length === 1 &&
5102
- !Types.isArray(this.o.get(this.n)[0]))
5031
+ if (this.o.get(this.n).length === 1 && !Types.isArray(this.o.get(this.n)[0]))
5103
5032
  this.o.set(this.n, this.o.get(this.n)[0]);
5104
5033
  }
5105
5034
  /**
@@ -5122,8 +5051,7 @@ class ODataQueryOptionHandler {
5122
5051
  //#endregion
5123
5052
  //#region HashMap Value
5124
5053
  assertObject(create) {
5125
- if (!Types.isArray(this.o.get(this.n)) &&
5126
- Types.isPlainObject(this.o.get(this.n))) {
5054
+ if (!Types.isArray(this.o.get(this.n)) && Types.isPlainObject(this.o.get(this.n))) {
5127
5055
  return this.o.get(this.n);
5128
5056
  }
5129
5057
  let arr = this.assertArray();
@@ -5191,7 +5119,7 @@ class ODataQueryOptionHandler {
5191
5119
  clear() {
5192
5120
  this.o.delete(this.n);
5193
5121
  }
5194
- toString({ escape, parser, } = {}) {
5122
+ toString({ escape, parser } = {}) {
5195
5123
  const [_, params] = pathAndParamsFromQueryOptions(new Map([[this.n, this.o.get(this.n)]]), { escape, parser });
5196
5124
  return params[`$${this.n}`];
5197
5125
  }
@@ -5562,7 +5490,7 @@ class ODataQueryOptionsHandler {
5562
5490
  fromJson(json) {
5563
5491
  this.options.fromJson(json);
5564
5492
  }
5565
- toString({ escape, parser, } = {}) {
5493
+ toString({ escape, parser } = {}) {
5566
5494
  return this.options.toString({ escape, parser });
5567
5495
  }
5568
5496
  pathAndParams({ escape, parser, options, } = {}) {
@@ -5597,8 +5525,7 @@ const pathAndParamsFromQueryOptions = (values, { escape, parser, options, } = {}
5597
5525
  .reduce((acc, key) => {
5598
5526
  let value = values.get(key);
5599
5527
  if (Types.rawType(value).endsWith('Expression') ||
5600
- (Types.isArray(value) &&
5601
- value.some((v) => Types.rawType(v).endsWith('Expression')))) {
5528
+ (Types.isArray(value) && value.some((v) => Types.rawType(v).endsWith('Expression')))) {
5602
5529
  value = Types.isArray(value)
5603
5530
  ? value.map((v) => Types.rawType(v).endsWith('Expression')
5604
5531
  ? raw(v.render({ aliases, escape, parser, options }))
@@ -5626,7 +5553,7 @@ class ODataQueryOptions {
5626
5553
  options,
5627
5554
  });
5628
5555
  }
5629
- toString({ escape, parser, } = {}) {
5556
+ toString({ escape, parser } = {}) {
5630
5557
  const [path, params] = this.pathAndParams({ escape, parser });
5631
5558
  return (path +
5632
5559
  Object.entries(params)
@@ -5800,8 +5727,7 @@ function pathSegmentsBuilder(segment, escape = false, parser, options) {
5800
5727
  path = path.slice(1);
5801
5728
  }
5802
5729
  // HACK: Remove parenthesis
5803
- if (path.endsWith('()') &&
5804
- options?.nonParenthesisForEmptyParameterFunction) {
5730
+ if (path.endsWith('()') && options?.nonParenthesisForEmptyParameterFunction) {
5805
5731
  path = path.substring(0, path.length - 2);
5806
5732
  }
5807
5733
  return [path, params];
@@ -5904,11 +5830,7 @@ class ODataPathSegments {
5904
5830
  segments({ key = false } = {}) {
5905
5831
  let segments = [...this._segments];
5906
5832
  if (key)
5907
- segments = segments.filter((s) => [
5908
- PathSegment.entitySet,
5909
- PathSegment.navigationProperty,
5910
- PathSegment.property,
5911
- ].indexOf(s.name) !== -1);
5833
+ segments = segments.filter((s) => [PathSegment.entitySet, PathSegment.navigationProperty, PathSegment.property].indexOf(s.name) !== -1);
5912
5834
  return segments.map((s) => new SegmentHandler(s));
5913
5835
  }
5914
5836
  first({ key = false } = {}) {
@@ -5961,9 +5883,7 @@ class ODataRequest {
5961
5883
  if (this._body !== null)
5962
5884
  this._body = this.resource.serialize(this._body, init.parserOptions);
5963
5885
  this.withCredentials =
5964
- init.withCredentials === undefined
5965
- ? this.api.options.withCredentials
5966
- : init.withCredentials;
5886
+ init.withCredentials === undefined ? this.api.options.withCredentials : init.withCredentials;
5967
5887
  this.fetchPolicy = init.fetchPolicy || this.api.options.fetchPolicy;
5968
5888
  this.bodyQueryOptions = [
5969
5889
  ...(this.api.options.bodyQueryOptions || []),
@@ -5975,11 +5895,9 @@ class ODataRequest {
5975
5895
  //#region Headers
5976
5896
  const customHeaders = {};
5977
5897
  if (typeof init.etag === 'string') {
5978
- if (this.api.options.etag.ifMatch &&
5979
- ['PUT', 'PATCH', 'DELETE'].indexOf(this._method) !== -1)
5898
+ if (this.api.options.etag.ifMatch && ['PUT', 'PATCH', 'DELETE'].indexOf(this._method) !== -1)
5980
5899
  customHeaders[IF_MATCH_HEADER] = init.etag;
5981
- else if (this.api.options.etag.ifNoneMatch &&
5982
- ['GET'].indexOf(this._method) !== -1)
5900
+ else if (this.api.options.etag.ifNoneMatch && ['GET'].indexOf(this._method) !== -1)
5983
5901
  customHeaders[IF_NONE_MATCH_HEADER] = init.etag;
5984
5902
  }
5985
5903
  const accept = [];
@@ -6007,20 +5925,17 @@ class ODataRequest {
6007
5925
  ['POST', 'PUT', 'PATCH'].indexOf(this._method) !== -1)
6008
5926
  prefer.push(`return=${this.api.options.prefer?.return}`);
6009
5927
  // MaxPageSize
6010
- if (this.api.options.prefer?.maxPageSize !== undefined &&
6011
- ['GET'].indexOf(this._method) !== -1)
5928
+ if (this.api.options.prefer?.maxPageSize !== undefined && ['GET'].indexOf(this._method) !== -1)
6012
5929
  prefer.push(`odata.maxpagesize=${this.api.options.prefer?.maxPageSize}`);
6013
5930
  // Annotations
6014
5931
  if (this.api.options.prefer?.includeAnnotations !== undefined &&
6015
5932
  ['GET'].indexOf(this._method) !== -1)
6016
5933
  prefer.push(`odata.include-annotations=${this.api.options.prefer?.includeAnnotations}`);
6017
5934
  // Omit Null Values
6018
- if (this.api.options.prefer?.omitNullValues === true &&
6019
- ['GET'].indexOf(this._method) !== -1)
5935
+ if (this.api.options.prefer?.omitNullValues === true && ['GET'].indexOf(this._method) !== -1)
6020
5936
  prefer.push(`omit-values=nulls`);
6021
5937
  // Continue on Error
6022
- if (this.api.options.prefer?.continueOnError === true &&
6023
- ['POST'].indexOf(this._method) !== -1)
5938
+ if (this.api.options.prefer?.continueOnError === true && ['POST'].indexOf(this._method) !== -1)
6024
5939
  prefer.push(`odata.continue-on-error`);
6025
5940
  if (prefer.length > 0)
6026
5941
  customHeaders[PREFER] = prefer;
@@ -6028,8 +5943,7 @@ class ODataRequest {
6028
5943
  //#endregion
6029
5944
  //#region Params
6030
5945
  const customParams = {};
6031
- if (['POST', 'PUT', 'PATCH'].indexOf(this._method) !== -1 &&
6032
- '$select' in resourceParams) {
5946
+ if (['POST', 'PUT', 'PATCH'].indexOf(this._method) !== -1 && '$select' in resourceParams) {
6033
5947
  customParams['$select'] = resourceParams['$select'];
6034
5948
  }
6035
5949
  if (['POST'].indexOf(this._method) !== -1 && '$expand' in resourceParams) {
@@ -6041,13 +5955,7 @@ class ODataRequest {
6041
5955
  const params = Http.mergeHttpParams(this.api.options.params, customParams, init.params || {});
6042
5956
  this._params =
6043
5957
  this._responseType === 'entity'
6044
- ? Http.withoutHttpParams(params, [
6045
- '$filter',
6046
- '$orderby',
6047
- '$count',
6048
- '$skip',
6049
- '$top',
6050
- ])
5958
+ ? Http.withoutHttpParams(params, ['$filter', '$orderby', '$count', '$skip', '$top'])
6051
5959
  : params;
6052
5960
  //#endregion
6053
5961
  }
@@ -6109,9 +6017,7 @@ class ODataRequest {
6109
6017
  : this._headers;
6110
6018
  }
6111
6019
  get pathWithParams() {
6112
- return this.params.keys().length > 0
6113
- ? `${this.path}?${this.params}`
6114
- : this.path;
6020
+ return this.params.keys().length > 0 ? `${this.path}?${this.params}` : this.path;
6115
6021
  }
6116
6022
  get url() {
6117
6023
  return `${this.api.serviceRootUrl}${this.path}`;
@@ -6120,9 +6026,7 @@ class ODataRequest {
6120
6026
  return `${this.api.serviceRootUrl}${this.pathWithParams}`;
6121
6027
  }
6122
6028
  get cacheKey() {
6123
- return this._params.keys().length > 0
6124
- ? `${this._path}?${this._params}`
6125
- : this._path;
6029
+ return this._params.keys().length > 0 ? `${this._path}?${this._params}` : this._path;
6126
6030
  }
6127
6031
  isQueryBody() {
6128
6032
  return (this._method === 'GET' &&
@@ -6322,9 +6226,7 @@ class ODataResource {
6322
6226
  const parser = this.__parser(value, options, resourceType, bindingType);
6323
6227
  return parser !== undefined ? parser.deserialize(value, options) : value;
6324
6228
  };
6325
- return Array.isArray(value)
6326
- ? value.map((v) => _d(v, options))
6327
- : _d(value, options);
6229
+ return Array.isArray(value) ? value.map((v) => _d(v, options)) : _d(value, options);
6328
6230
  }
6329
6231
  serialize(value, options) {
6330
6232
  const resourceType = this.outgoingType();
@@ -6333,9 +6235,7 @@ class ODataResource {
6333
6235
  const parser = this.__parser(value, options, resourceType, bindingType);
6334
6236
  return parser !== undefined ? parser.serialize(value, options) : value;
6335
6237
  };
6336
- return Array.isArray(value)
6337
- ? value.map((v) => _s(v, options))
6338
- : _s(value, options);
6238
+ return Array.isArray(value) ? value.map((v) => _s(v, options)) : _s(value, options);
6339
6239
  }
6340
6240
  encode(value, options) {
6341
6241
  const resourceType = this.outgoingType();
@@ -6344,9 +6244,7 @@ class ODataResource {
6344
6244
  const parser = this.__parser(value, options, resourceType, bindingType);
6345
6245
  return parser !== undefined ? parser.encode(value, options) : value;
6346
6246
  };
6347
- return Array.isArray(value)
6348
- ? value.map((v) => _e(v, options))
6349
- : _e(value, options);
6247
+ return Array.isArray(value) ? value.map((v) => _e(v, options)) : _e(value, options);
6350
6248
  }
6351
6249
  toJson() {
6352
6250
  return {
@@ -6523,9 +6421,7 @@ class ODataActionResource extends ODataResource {
6523
6421
  * @returns Observable of the result of the action
6524
6422
  */
6525
6423
  callModel(params, options = {}) {
6526
- return this.call(params, { responseType: 'entity', ...options }).pipe(map(({ entity, annots }) => entity
6527
- ? this.asModel(entity, { annots, ModelType: options?.ModelType })
6528
- : null));
6424
+ return this.call(params, { responseType: 'entity', ...options }).pipe(map(({ entity, annots }) => entity ? this.asModel(entity, { annots, ModelType: options?.ModelType }) : null));
6529
6425
  }
6530
6426
  /**
6531
6427
  * Execute the action and return the result as a entities
@@ -6600,9 +6496,7 @@ class ODataBatchRequest extends Subject {
6600
6496
  let headers = this.request.headers;
6601
6497
  res = [
6602
6498
  ...res,
6603
- ...headers
6604
- .keys()
6605
- .map((key) => `${key}: ${(headers.getAll(key) || []).join(',')}`),
6499
+ ...headers.keys().map((key) => `${key}: ${(headers.getAll(key) || []).join(',')}`),
6606
6500
  ];
6607
6501
  }
6608
6502
  if (this.request.method === 'GET' || this.request.method === 'DELETE') {
@@ -6617,9 +6511,7 @@ class ODataBatchRequest extends Subject {
6617
6511
  let res = {
6618
6512
  id: this.id,
6619
6513
  method: this.request.method,
6620
- url: relativeUrls
6621
- ? this.request.pathWithParams
6622
- : this.request.urlWithParams,
6514
+ url: relativeUrls ? this.request.pathWithParams : this.request.urlWithParams,
6623
6515
  //'atomicityGroup': this.group
6624
6516
  //"dependsOn": ["g1", "g2", "r2"]
6625
6517
  };
@@ -7122,7 +7014,7 @@ class ODataFunctionResource extends ODataResource {
7122
7014
  responseType: 'entity',
7123
7015
  alias,
7124
7016
  ...options,
7125
- }).pipe(map(({ entity, annots }) => entity ? this.asModel(entity, { annots, ModelType }) : null));
7017
+ }).pipe(map(({ entity, annots }) => (entity ? this.asModel(entity, { annots, ModelType }) : null)));
7126
7018
  }
7127
7019
  /**
7128
7020
  * Execute the function with the given parameters and return the result as a entities
@@ -7150,9 +7042,7 @@ class ODataFunctionResource extends ODataResource {
7150
7042
  responseType: 'entities',
7151
7043
  alias,
7152
7044
  ...options,
7153
- }).pipe(map(({ entities, annots }) => entities
7154
- ? this.asCollection(entities, { annots, CollectionType })
7155
- : null));
7045
+ }).pipe(map(({ entities, annots }) => entities ? this.asCollection(entities, { annots, CollectionType }) : null));
7156
7046
  }
7157
7047
  //#endregion
7158
7048
  callArraybuffer(params, { alias, ...options } = {}) {
@@ -7217,9 +7107,7 @@ class ODataValueResource extends ODataResource {
7217
7107
  }
7218
7108
  static fromResource(resource) {
7219
7109
  const baseType = resource.outgoingType();
7220
- let baseSchema = baseType !== undefined
7221
- ? resource.api.structuredType(baseType)
7222
- : undefined;
7110
+ let baseSchema = baseType !== undefined ? resource.api.structuredType(baseType) : undefined;
7223
7111
  const value = ODataValueResource.factory(resource.api, {
7224
7112
  segments: resource.cloneSegments(),
7225
7113
  });
@@ -7266,17 +7154,12 @@ class ODataPropertyResource extends ODataResource {
7266
7154
  }
7267
7155
  static fromResource(resource, path) {
7268
7156
  const baseType = resource.outgoingType();
7269
- let baseSchema = baseType !== undefined
7270
- ? resource.api.structuredType(baseType)
7271
- : undefined;
7157
+ let baseSchema = baseType !== undefined ? resource.api.structuredType(baseType) : undefined;
7272
7158
  let fieldType;
7273
7159
  if (baseSchema !== undefined) {
7274
7160
  const field = baseSchema.field(path);
7275
7161
  fieldType = field?.type;
7276
- baseSchema =
7277
- field !== undefined
7278
- ? baseSchema.findParentSchemaForField(field)
7279
- : undefined;
7162
+ baseSchema = field !== undefined ? baseSchema.findParentSchemaForField(field) : undefined;
7280
7163
  }
7281
7164
  const property = ODataPropertyResource.factory(resource.api, {
7282
7165
  path,
@@ -7370,9 +7253,7 @@ class ODataPropertyResource extends ODataResource {
7370
7253
  return this.fetch({ responseType: 'entity', ...options }).pipe(map(({ entity }) => entity));
7371
7254
  }
7372
7255
  fetchModel(options = {}) {
7373
- return this.fetch({ responseType: 'entity', ...options }).pipe(map(({ entity, annots }) => entity
7374
- ? this.asModel(entity, { annots, ModelType: options?.ModelType })
7375
- : null));
7256
+ return this.fetch({ responseType: 'entity', ...options }).pipe(map(({ entity, annots }) => entity ? this.asModel(entity, { annots, ModelType: options?.ModelType }) : null));
7376
7257
  }
7377
7258
  /**
7378
7259
  * Fetch the entities
@@ -7406,7 +7287,7 @@ class ODataPropertyResource extends ODataResource {
7406
7287
  }
7407
7288
  return res.fetch({ responseType: 'entities', ...options });
7408
7289
  };
7409
- return fetch({ top }).pipe(expand(({ annots }) => annots.skip || annots.skiptoken ? fetch(annots) : EMPTY), map(({ entities, annots }) => ({ entities: entities || [], annots })), reduce((acc, { entities, annots }) => ({
7290
+ return fetch({ top }).pipe(expand(({ annots }) => (annots.skip || annots.skiptoken ? fetch(annots) : EMPTY)), map(({ entities, annots }) => ({ entities: entities || [], annots })), reduce((acc, { entities, annots }) => ({
7410
7291
  entities: [...(acc.entities || []), ...(entities || [])],
7411
7292
  annots: acc.annots.union(annots),
7412
7293
  })));
@@ -7426,7 +7307,7 @@ class ODataPropertyResource extends ODataResource {
7426
7307
  }
7427
7308
  return res.fetch({ responseType: 'entities', ...options });
7428
7309
  };
7429
- return fetch().pipe(expand(({ annots }) => annots.skip || annots.skiptoken ? fetch(annots) : EMPTY), map(({ entities, annots }) => ({ entities: entities || [], annots })), reduce((acc, { entities, annots }) => ({
7310
+ return fetch().pipe(expand(({ annots }) => (annots.skip || annots.skiptoken ? fetch(annots) : EMPTY)), map(({ entities, annots }) => ({ entities: entities || [], annots })), reduce((acc, { entities, annots }) => ({
7430
7311
  entities: [...(acc.entities || []), ...(entities || [])],
7431
7312
  annots: acc.annots.union(annots),
7432
7313
  })));
@@ -7535,17 +7416,12 @@ class ODataNavigationPropertyResource extends ODataResource {
7535
7416
  }
7536
7417
  static fromResource(resource, path) {
7537
7418
  const baseType = resource.outgoingType();
7538
- let baseSchema = baseType !== undefined
7539
- ? resource.api.structuredType(baseType)
7540
- : undefined;
7419
+ let baseSchema = baseType !== undefined ? resource.api.structuredType(baseType) : undefined;
7541
7420
  let fieldType;
7542
7421
  if (baseSchema !== undefined) {
7543
7422
  const field = baseSchema.field(path);
7544
7423
  fieldType = field?.type;
7545
- baseSchema =
7546
- field !== undefined
7547
- ? baseSchema.findParentSchemaForField(field)
7548
- : undefined;
7424
+ baseSchema = field !== undefined ? baseSchema.findParentSchemaForField(field) : undefined;
7549
7425
  }
7550
7426
  const navigation = ODataNavigationPropertyResource.factory(resource.api, {
7551
7427
  path,
@@ -7612,9 +7488,7 @@ class ODataNavigationPropertyResource extends ODataResource {
7612
7488
  const thisType = this.incomingType();
7613
7489
  const baseSchema = thisType !== undefined ? this.api.structuredType(thisType) : undefined;
7614
7490
  const castSchema = this.api.findStructuredType(type);
7615
- if (castSchema !== undefined &&
7616
- baseSchema !== undefined &&
7617
- !castSchema.isSubtypeOf(baseSchema))
7491
+ if (castSchema !== undefined && baseSchema !== undefined && !castSchema.isSubtypeOf(baseSchema))
7618
7492
  throw new Error(`Cannot cast to ${type}`);
7619
7493
  const segments = this.cloneSegments();
7620
7494
  segments.add(PathSegment.type, type).incomingType(type);
@@ -7690,9 +7564,7 @@ class ODataNavigationPropertyResource extends ODataResource {
7690
7564
  return this.fetch({ responseType: 'entity', ...options }).pipe(map(({ entity }) => entity));
7691
7565
  }
7692
7566
  fetchModel(options = {}) {
7693
- return this.fetch({ responseType: 'entity', ...options }).pipe(map(({ entity, annots }) => entity
7694
- ? this.asModel(entity, { annots, ModelType: options?.ModelType })
7695
- : null));
7567
+ return this.fetch({ responseType: 'entity', ...options }).pipe(map(({ entity, annots }) => entity ? this.asModel(entity, { annots, ModelType: options?.ModelType }) : null));
7696
7568
  }
7697
7569
  /**
7698
7570
  * Fetch entities
@@ -7725,7 +7597,7 @@ class ODataNavigationPropertyResource extends ODataResource {
7725
7597
  }
7726
7598
  return res.fetch({ responseType: 'entities', ...options });
7727
7599
  };
7728
- return fetch().pipe(expand(({ annots }) => annots.skip || annots.skiptoken ? fetch(annots) : EMPTY), map(({ entities, annots }) => ({ entities: entities || [], annots })), reduce((acc, { entities, annots }) => ({
7600
+ return fetch().pipe(expand(({ annots }) => (annots.skip || annots.skiptoken ? fetch(annots) : EMPTY)), map(({ entities, annots }) => ({ entities: entities || [], annots })), reduce((acc, { entities, annots }) => ({
7729
7601
  entities: [...(acc.entities || []), ...(entities || [])],
7730
7602
  annots: acc.annots.union(annots),
7731
7603
  })));
@@ -7739,7 +7611,7 @@ class ODataNavigationPropertyResource extends ODataResource {
7739
7611
  }
7740
7612
  return res.fetch({ responseType: 'entities', ...options });
7741
7613
  };
7742
- return fetch({ top }).pipe(expand(({ annots }) => annots.skip || annots.skiptoken ? fetch(annots) : EMPTY), map(({ entities, annots }) => ({ entities: entities || [], annots })), reduce((acc, { entities, annots }) => ({
7614
+ return fetch({ top }).pipe(expand(({ annots }) => (annots.skip || annots.skiptoken ? fetch(annots) : EMPTY)), map(({ entities, annots }) => ({ entities: entities || [], annots })), reduce((acc, { entities, annots }) => ({
7743
7615
  entities: [...(acc.entities || []), ...(entities || [])],
7744
7616
  annots: acc.annots.union(annots),
7745
7617
  })));
@@ -7801,9 +7673,7 @@ class ODataEntityResource extends ODataResource {
7801
7673
  const baseSchema = thisType !== undefined ? this.api.structuredType(thisType) : undefined;
7802
7674
  // Downcast
7803
7675
  const castSchema = baseSchema?.findChildSchema((s) => s.type() === type);
7804
- if (castSchema !== undefined &&
7805
- baseSchema !== undefined &&
7806
- !castSchema.isSubtypeOf(baseSchema))
7676
+ if (castSchema !== undefined && baseSchema !== undefined && !castSchema.isSubtypeOf(baseSchema))
7807
7677
  throw new Error(`cast: Cannot cast to ${type}`);
7808
7678
  const segments = this.cloneSegments();
7809
7679
  segments.add(PathSegment.type, type).incomingType(type);
@@ -7851,9 +7721,7 @@ class ODataEntityResource extends ODataResource {
7851
7721
  return this.fetch(options).pipe(map(({ entity }) => entity));
7852
7722
  }
7853
7723
  fetchModel(options) {
7854
- return this.fetch(options).pipe(map(({ entity, annots }) => entity
7855
- ? this.asModel(entity, { annots, ModelType: options?.ModelType })
7856
- : null));
7724
+ return this.fetch(options).pipe(map(({ entity, annots }) => entity ? this.asModel(entity, { annots, ModelType: options?.ModelType }) : null));
7857
7725
  }
7858
7726
  }
7859
7727
 
@@ -7904,9 +7772,7 @@ class ODataEntitySetResource extends ODataResource {
7904
7772
  const thisType = this.incomingType();
7905
7773
  const baseSchema = thisType !== undefined ? this.api.structuredType(thisType) : undefined;
7906
7774
  const castSchema = this.api.findStructuredType(type);
7907
- if (castSchema !== undefined &&
7908
- baseSchema !== undefined &&
7909
- !castSchema.isSubtypeOf(baseSchema))
7775
+ if (castSchema !== undefined && baseSchema !== undefined && !castSchema.isSubtypeOf(baseSchema))
7910
7776
  throw new Error(`cast: Cannot cast to ${type}`);
7911
7777
  const segments = this.cloneSegments();
7912
7778
  segments.add(PathSegment.type, type).incomingType(type);
@@ -7940,7 +7806,7 @@ class ODataEntitySetResource extends ODataResource {
7940
7806
  }
7941
7807
  return res.fetch(options);
7942
7808
  };
7943
- return fetch().pipe(expand(({ annots }) => annots.skip || annots.skiptoken ? fetch(annots) : EMPTY), map(({ entities, annots }) => ({ entities: entities ?? [], annots })), reduce((acc, { entities, annots }) => ({
7809
+ return fetch().pipe(expand(({ annots }) => (annots.skip || annots.skiptoken ? fetch(annots) : EMPTY)), map(({ entities, annots }) => ({ entities: entities ?? [], annots })), reduce((acc, { entities, annots }) => ({
7944
7810
  entities: [...(acc.entities ?? []), ...(entities ?? [])],
7945
7811
  annots: acc.annots.union(annots),
7946
7812
  })));
@@ -7953,7 +7819,7 @@ class ODataEntitySetResource extends ODataResource {
7953
7819
  }
7954
7820
  return res.fetch(options);
7955
7821
  };
7956
- return fetch({ top }).pipe(expand(({ annots }) => annots.skip || annots.skiptoken ? fetch(annots) : EMPTY), map(({ entities, annots }) => ({ entities: entities ?? [], annots })), reduce((acc, { entities, annots }) => ({
7822
+ return fetch({ top }).pipe(expand(({ annots }) => (annots.skip || annots.skiptoken ? fetch(annots) : EMPTY)), map(({ entities, annots }) => ({ entities: entities ?? [], annots })), reduce((acc, { entities, annots }) => ({
7957
7823
  entities: [...(acc.entities ?? []), ...(entities ?? [])],
7958
7824
  annots: acc.annots.union(annots),
7959
7825
  })));
@@ -8162,8 +8028,7 @@ class CsdlCollection {
8162
8028
  if (Array.isArray(this.PropertyPath) && this.PropertyPath.length > 0) {
8163
8029
  json['PropertyPath'] = this.PropertyPath.map((p) => p.toJson());
8164
8030
  }
8165
- if (Array.isArray(this.NavigationPropertyPath) &&
8166
- this.NavigationPropertyPath.length > 0) {
8031
+ if (Array.isArray(this.NavigationPropertyPath) && this.NavigationPropertyPath.length > 0) {
8167
8032
  json['NavigationPropertyPath'] = this.NavigationPropertyPath.map((p) => p.toJson());
8168
8033
  }
8169
8034
  return json;
@@ -8267,8 +8132,7 @@ class CsdlReference extends CsdlAnnotable {
8267
8132
  if (Array.isArray(this.Include) && this.Include.length > 0) {
8268
8133
  json['Include'] = this.Include.map((i) => i.toJson());
8269
8134
  }
8270
- if (Array.isArray(this.IncludeAnnotations) &&
8271
- this.IncludeAnnotations.length > 0) {
8135
+ if (Array.isArray(this.IncludeAnnotations) && this.IncludeAnnotations.length > 0) {
8272
8136
  json['IncludeAnnotations'] = this.IncludeAnnotations.map((i) => i.toJson());
8273
8137
  }
8274
8138
  return json;
@@ -8424,7 +8288,7 @@ class CsdlEnumType extends CsdlAnnotable {
8424
8288
  class CsdlMember extends CsdlAnnotable {
8425
8289
  Name;
8426
8290
  Value;
8427
- constructor({ Name, Value, Annotation, }) {
8291
+ constructor({ Name, Value, Annotation }) {
8428
8292
  super({ Annotation });
8429
8293
  this.Name = Name;
8430
8294
  this.Value = Value;
@@ -8539,8 +8403,7 @@ class CsdlNavigationProperty extends CsdlStructuralProperty {
8539
8403
  if (this.ContainsTarget !== undefined) {
8540
8404
  json['ContainsTarget'] = this.ContainsTarget;
8541
8405
  }
8542
- if (Array.isArray(this.ReferentialConstraints) &&
8543
- this.ReferentialConstraints.length > 0) {
8406
+ if (Array.isArray(this.ReferentialConstraints) && this.ReferentialConstraints.length > 0) {
8544
8407
  json['ReferentialConstraints'] = this.ReferentialConstraints.map((r) => r.toJson());
8545
8408
  }
8546
8409
  if (this.OnDelete !== undefined) {
@@ -8566,7 +8429,7 @@ class CsdlNavigationProperty extends CsdlStructuralProperty {
8566
8429
  class CsdlReferentialConstraint {
8567
8430
  Property;
8568
8431
  ReferencedProperty;
8569
- constructor({ Property, ReferencedProperty, }) {
8432
+ constructor({ Property, ReferencedProperty }) {
8570
8433
  this.Property = Property;
8571
8434
  this.ReferencedProperty = ReferencedProperty;
8572
8435
  }
@@ -8612,8 +8475,7 @@ class CsdlStructuredType extends CsdlAnnotable {
8612
8475
  if (Array.isArray(this.Property) && this.Property.length > 0) {
8613
8476
  json['Property'] = this.Property.map((p) => p.toJson());
8614
8477
  }
8615
- if (Array.isArray(this.NavigationProperty) &&
8616
- this.NavigationProperty.length > 0) {
8478
+ if (Array.isArray(this.NavigationProperty) && this.NavigationProperty.length > 0) {
8617
8479
  json['NavigationProperty'] = this.NavigationProperty.map((n) => n.toJson());
8618
8480
  }
8619
8481
  if (this.BaseType !== undefined) {
@@ -9134,8 +8996,7 @@ class CsdlSchema {
9134
8996
  if (this.Alias !== undefined) {
9135
8997
  json['Alias'] = this.Alias;
9136
8998
  }
9137
- if (Array.isArray(this.EntityContainer) &&
9138
- this.EntityContainer.length > 0) {
8999
+ if (Array.isArray(this.EntityContainer) && this.EntityContainer.length > 0) {
9139
9000
  json['EntityContainer'] = this.EntityContainer.map((a) => a.toJson());
9140
9001
  }
9141
9002
  if (Array.isArray(this.EntityType) && this.EntityType.length > 0) {
@@ -9769,9 +9630,7 @@ class ODataMetadataParser {
9769
9630
  }
9770
9631
  getAttributeValue(attributes, attributeName) {
9771
9632
  const attribute = attributes.getNamedItem(attributeName);
9772
- return attribute !== null && attribute.nodeValue
9773
- ? attribute.nodeValue
9774
- : undefined;
9633
+ return attribute !== null && attribute.nodeValue ? attribute.nodeValue : undefined;
9775
9634
  }
9776
9635
  propertyValueToNumber(attributeValue) {
9777
9636
  return attributeValue !== undefined ? Number(attributeValue) : undefined;
@@ -9924,9 +9783,7 @@ class ODataSingletonResource extends ODataResource {
9924
9783
  return this.fetch(options).pipe(map(({ entity }) => entity));
9925
9784
  }
9926
9785
  fetchModel(options) {
9927
- return this.fetch(options).pipe(map(({ entity, annots }) => entity
9928
- ? this.asModel(entity, { annots, ModelType: options?.ModelType })
9929
- : null));
9786
+ return this.fetch(options).pipe(map(({ entity, annots }) => entity ? this.asModel(entity, { annots, ModelType: options?.ModelType }) : null));
9930
9787
  }
9931
9788
  }
9932
9789
 
@@ -10220,9 +10077,7 @@ class ODataResponse extends HttpResponse {
10220
10077
  get payload() {
10221
10078
  if (this._payload === undefined) {
10222
10079
  this._payload =
10223
- this.body && this.options.version === '2.0'
10224
- ? this.body['d']
10225
- : this.body;
10080
+ this.body && this.options.version === '2.0' ? this.body['d'] : this.body;
10226
10081
  }
10227
10082
  return this._payload;
10228
10083
  }
@@ -10323,9 +10178,7 @@ class ODataCollection {
10323
10178
  _entries = [];
10324
10179
  _model;
10325
10180
  models() {
10326
- return this._entries
10327
- .filter((e) => e.state !== ODataModelState.Removed)
10328
- .map((e) => e.model);
10181
+ return this._entries.filter((e) => e.state !== ODataModelState.Removed).map((e) => e.model);
10329
10182
  }
10330
10183
  get length() {
10331
10184
  return this.models().length;
@@ -10360,8 +10213,7 @@ class ODataCollection {
10360
10213
  this.assign(entities, { reset });
10361
10214
  }
10362
10215
  isParentOf(child) {
10363
- return (child !== this &&
10364
- ODataModelOptions.chain(child).some((p) => p[0] === this));
10216
+ return child !== this && ODataModelOptions.chain(child).some((p) => p[0] === this);
10365
10217
  }
10366
10218
  resource() {
10367
10219
  return ODataModelOptions.resource(this);
@@ -10469,8 +10321,8 @@ class ODataCollection {
10469
10321
  }
10470
10322
  clone() {
10471
10323
  return new this.constructor(this.toEntities(INCLUDE_DEEP), {
10472
- resource: this.resource(),
10473
- annots: this.annots(),
10324
+ resource: this.resource()?.clone(),
10325
+ annots: this.annots().clone(),
10474
10326
  });
10475
10327
  }
10476
10328
  _request(obs$, mapCallback) {
@@ -10523,7 +10375,7 @@ class ODataCollection {
10523
10375
  const resource = this.resource();
10524
10376
  if (!resource)
10525
10377
  return throwError(() => new Error('fetchMany: Resource is null'));
10526
- resource.query((q) => remove || this.length == 0 ? q.skip().clear() : q.skip(this.length));
10378
+ resource.query((q) => (remove || this.length == 0 ? q.skip().clear() : q.skip(this.length)));
10527
10379
  const obs$ = resource.fetchMany(top, { withCount, ...options });
10528
10380
  return this._request(obs$, ({ entities, annots }) => {
10529
10381
  this._annotations = annots;
@@ -10541,7 +10393,7 @@ class ODataCollection {
10541
10393
  const resource = this.resource();
10542
10394
  if (!resource)
10543
10395
  return throwError(() => new Error('fetchOne: Resource is null'));
10544
- resource.query((q) => remove || this.length == 0 ? q.skip().clear() : q.skip(this.length));
10396
+ resource.query((q) => (remove || this.length == 0 ? q.skip().clear() : q.skip(this.length)));
10545
10397
  const obs$ = resource.fetchOne({ withCount, ...options });
10546
10398
  return this._request(obs$, ({ entity, annots }) => {
10547
10399
  this._annotations = annots;
@@ -10731,7 +10583,7 @@ class ODataCollection {
10731
10583
  return of(model);
10732
10584
  }
10733
10585
  }
10734
- _removeModel(model, { silent = false, reset = false, } = {}) {
10586
+ _removeModel(model, { silent = false, reset = false } = {}) {
10735
10587
  const entry = this._findEntry(model);
10736
10588
  if (entry === undefined || entry.state === ODataModelState.Removed) {
10737
10589
  return model;
@@ -10771,7 +10623,7 @@ class ODataCollection {
10771
10623
  this._entries.splice(position, 0, entry);
10772
10624
  return entry.model;
10773
10625
  }
10774
- create(attrs = {}, { silent = false, server = true, } = {}) {
10626
+ create(attrs = {}, { silent = false, server = true } = {}) {
10775
10627
  const model = this.modelFactory(attrs);
10776
10628
  return (model.isValid() && server ? model.save() : of(model)).pipe(switchMap((model) => this.add(model, { silent, server })), map(() => model));
10777
10629
  }
@@ -10811,7 +10663,7 @@ class ODataCollection {
10811
10663
  }
10812
10664
  return value !== undefined;
10813
10665
  }
10814
- reset({ path, silent = false, } = {}) {
10666
+ reset({ path, silent = false } = {}) {
10815
10667
  let toAdd = [];
10816
10668
  let toChange = [];
10817
10669
  let toRemove = [];
@@ -10823,8 +10675,7 @@ class ODataCollection {
10823
10675
  const model = this.models()[index];
10824
10676
  if (ODataModelOptions.isModel(model)) {
10825
10677
  const entry = this._findEntry(model);
10826
- if (entry.state === ODataModelState.Unchanged &&
10827
- entry.model.hasChanged()) {
10678
+ if (entry.state === ODataModelState.Unchanged && entry.model.hasChanged()) {
10828
10679
  toChange = [entry];
10829
10680
  }
10830
10681
  path = pathArray.slice(1);
@@ -10847,8 +10698,7 @@ class ODataCollection {
10847
10698
  entry.model.reset({ path, silent });
10848
10699
  entry.state = ODataModelState.Unchanged;
10849
10700
  });
10850
- if (!silent &&
10851
- (toAdd.length > 0 || toRemove.length > 0 || toChange.length > 0)) {
10701
+ if (!silent && (toAdd.length > 0 || toRemove.length > 0 || toChange.length > 0)) {
10852
10702
  this.events$.trigger(ODataModelEventType.Reset, {
10853
10703
  options: {
10854
10704
  added: toAdd.map((e) => e.model),
@@ -10923,8 +10773,7 @@ class ODataCollection {
10923
10773
  models.forEach((m, i) => this._moveModel(m, i));
10924
10774
  this.events$.trigger(ODataModelEventType.Sort);
10925
10775
  }
10926
- if (!silent &&
10927
- (toAdd.length > 0 || toRemove.length > 0 || toMerge.length > 0)) {
10776
+ if (!silent && (toAdd.length > 0 || toRemove.length > 0 || toMerge.length > 0)) {
10928
10777
  this.events$.trigger(reset ? ODataModelEventType.Reset : ODataModelEventType.Update, {
10929
10778
  options: {
10930
10779
  added: toAdd,
@@ -10992,8 +10841,7 @@ class ODataCollection {
10992
10841
  if (event.type === ODataModelEventType.Destroy) {
10993
10842
  this._removeModel(entry.model, { reset: true });
10994
10843
  }
10995
- else if (event.type === ODataModelEventType.Change &&
10996
- event.options?.key) {
10844
+ else if (event.type === ODataModelEventType.Change && event.options?.key) {
10997
10845
  entry.key = entry.model.key();
10998
10846
  }
10999
10847
  }
@@ -11083,12 +10931,8 @@ class ODataCollection {
11083
10931
  }
11084
10932
  //#region Sort
11085
10933
  _compare(e1, e2, by, index) {
11086
- const m1 = ODataModelOptions.isModel(e1)
11087
- ? e1
11088
- : e1.model;
11089
- const m2 = ODataModelOptions.isModel(e2)
11090
- ? e2
11091
- : e2.model;
10934
+ const m1 = ODataModelOptions.isModel(e1) ? e1 : e1.model;
10935
+ const m2 = ODataModelOptions.isModel(e2) ? e2 : e2.model;
11092
10936
  const value1 = m1.get(by[index].field);
11093
10937
  const value2 = m2.get(by[index].field);
11094
10938
  let result = 0;
@@ -11235,16 +11079,15 @@ class ODataModel {
11235
11079
  return this._meta.isOpenType();
11236
11080
  }
11237
11081
  isParentOf(child) {
11238
- return (child !== this &&
11239
- ODataModelOptions.chain(child).some((p) => p[0] === this));
11082
+ return child !== this && ODataModelOptions.chain(child).some((p) => p[0] === this);
11240
11083
  }
11241
- referential(attr, { field_mapping = false, resolve = true, } = {}) {
11084
+ referential(attr, { field_mapping = false, resolve = true } = {}) {
11242
11085
  return this._meta.resolveReferential(this, attr, {
11243
11086
  field_mapping,
11244
11087
  resolve,
11245
11088
  });
11246
11089
  }
11247
- referenced(attr, { field_mapping = false, resolve = true, } = {}) {
11090
+ referenced(attr, { field_mapping = false, resolve = true } = {}) {
11248
11091
  return this._meta.resolveReferenced(this, attr, {
11249
11092
  field_mapping,
11250
11093
  resolve,
@@ -11301,8 +11144,7 @@ class ODataModel {
11301
11144
  if (pathArray.length === 0)
11302
11145
  return undefined;
11303
11146
  const value = this._meta.get(this, pathArray[0]);
11304
- if (pathArray.length > 1 &&
11305
- (value instanceof ODataModel || value instanceof ODataCollection)) {
11147
+ if (pathArray.length > 1 && (value instanceof ODataModel || value instanceof ODataCollection)) {
11306
11148
  return value.get(pathArray.slice(1));
11307
11149
  }
11308
11150
  return value;
@@ -11312,22 +11154,16 @@ class ODataModel {
11312
11154
  if (pathArray.length === 0)
11313
11155
  return false;
11314
11156
  const value = this._meta.get(this, pathArray[0]);
11315
- if (pathArray.length > 1 &&
11316
- (value instanceof ODataModel || value instanceof ODataCollection)) {
11157
+ if (pathArray.length > 1 && (value instanceof ODataModel || value instanceof ODataCollection)) {
11317
11158
  return value.has(pathArray.slice(1));
11318
11159
  }
11319
11160
  return value !== undefined;
11320
11161
  }
11321
- reset({ path, silent = false, } = {}) {
11322
- const pathArray = (path === undefined
11323
- ? []
11324
- : Types.isArray(path)
11325
- ? path
11326
- : path.match(/([^[.\]])+/g));
11162
+ reset({ path, silent = false } = {}) {
11163
+ const pathArray = (path === undefined ? [] : Types.isArray(path) ? path : path.match(/([^[.\]])+/g));
11327
11164
  const name = pathArray[0];
11328
11165
  const value = name !== undefined ? this[name] : undefined;
11329
- if (ODataModelOptions.isModel(value) ||
11330
- ODataModelOptions.isCollection(value)) {
11166
+ if (ODataModelOptions.isModel(value) || ODataModelOptions.isCollection(value)) {
11331
11167
  value.reset({ path: pathArray.slice(1), silent });
11332
11168
  }
11333
11169
  else {
@@ -11352,8 +11188,8 @@ class ODataModel {
11352
11188
  }
11353
11189
  clone() {
11354
11190
  return new this.constructor(this.toEntity(INCLUDE_DEEP), {
11355
- resource: this.resource(),
11356
- annots: this.annots(),
11191
+ resource: this.resource()?.clone(),
11192
+ annots: this.annots().clone(),
11357
11193
  });
11358
11194
  }
11359
11195
  _request(obs$, mapCallback) {
@@ -11399,8 +11235,7 @@ class ODataModel {
11399
11235
  (method === 'update' || method === 'modify') &&
11400
11236
  !resource.hasKey())
11401
11237
  return throwError(() => new Error('save: Update/Patch require entity key'));
11402
- if (resource instanceof ODataNavigationPropertyResource ||
11403
- method === 'create')
11238
+ if (resource instanceof ODataNavigationPropertyResource || method === 'create')
11404
11239
  resource.clearKey();
11405
11240
  if (validate && !this.isValid({ method, navigation })) {
11406
11241
  return throwError(() => new Error('save: Validation errors'));
@@ -11457,7 +11292,7 @@ class ODataModel {
11457
11292
  * @param include_navigation Check in navigation properties
11458
11293
  * @returns true if the model has changed, false otherwise
11459
11294
  */
11460
- hasChanged({ include_navigation = false, } = {}) {
11295
+ hasChanged({ include_navigation = false } = {}) {
11461
11296
  return this._meta.hasChanged(this, { include_navigation });
11462
11297
  }
11463
11298
  encode(name, options) {
@@ -11527,9 +11362,7 @@ class ODataModel {
11527
11362
  const resource = this.resource();
11528
11363
  if (!(resource instanceof ODataEntityResource))
11529
11364
  throw new Error(`cast: Can't cast to derived model without ODataEntityResource`);
11530
- return resource
11531
- .cast(type)
11532
- .asModel(this.toEntity(INCLUDE_DEEP), {
11365
+ return resource.cast(type).asModel(this.toEntity(INCLUDE_DEEP), {
11533
11366
  annots: this.annots(),
11534
11367
  ModelType,
11535
11368
  });
@@ -11600,13 +11433,8 @@ class ODataModel {
11600
11433
  model = field.collectionFactory({ parent: this });
11601
11434
  }
11602
11435
  else {
11603
- const ref = field.navigation
11604
- ? this.referenced(field)
11605
- : undefined;
11606
- model =
11607
- ref === null
11608
- ? null
11609
- : field.modelFactory({ parent: this, value: ref });
11436
+ const ref = field.navigation ? this.referenced(field) : undefined;
11437
+ model = ref === null ? null : field.modelFactory({ parent: this, value: ref });
11610
11438
  }
11611
11439
  this[name] = model;
11612
11440
  }
@@ -11617,7 +11445,10 @@ class ODataModel {
11617
11445
  const etag = this.annots().etag;
11618
11446
  let obs$ = NEVER;
11619
11447
  if (model instanceof ODataModel) {
11620
- obs$ = reference.set(model.asEntity((e) => e.resource()), { etag, ...options });
11448
+ obs$ = reference.set(model.asEntity((e) => e.resource()), {
11449
+ etag,
11450
+ ...options,
11451
+ });
11621
11452
  }
11622
11453
  else if (model instanceof ODataCollection) {
11623
11454
  obs$ = forkJoin(model
@@ -11634,7 +11465,10 @@ class ODataModel {
11634
11465
  const etag = this.annots().etag;
11635
11466
  let obs$ = NEVER;
11636
11467
  if (model instanceof ODataModel) {
11637
- obs$ = reference.set(model.asEntity((e) => e.resource()), { etag, ...options });
11468
+ obs$ = reference.set(model.asEntity((e) => e.resource()), {
11469
+ etag,
11470
+ ...options,
11471
+ });
11638
11472
  }
11639
11473
  else if (model instanceof ODataCollection) {
11640
11474
  obs$ = forkJoin(model
@@ -11658,16 +11492,12 @@ class ODataModel {
11658
11492
  const meta = this._meta;
11659
11493
  const thisCid = this[meta.cid];
11660
11494
  const otherCid = other[meta.cid];
11661
- if (thisCid !== undefined &&
11662
- otherCid !== undefined &&
11663
- Types.isEqual(thisCid, otherCid))
11495
+ if (thisCid !== undefined && otherCid !== undefined && Types.isEqual(thisCid, otherCid))
11664
11496
  return true;
11665
11497
  if (meta.isEntityType()) {
11666
11498
  const thisKey = this.key();
11667
11499
  const otherKey = other.key();
11668
- if (thisKey !== undefined &&
11669
- otherKey !== undefined &&
11670
- Types.isEqual(thisKey, otherKey))
11500
+ if (thisKey !== undefined && otherKey !== undefined && Types.isEqual(thisKey, otherKey))
11671
11501
  return true;
11672
11502
  }
11673
11503
  else if (meta.isComplexType()) {
@@ -11681,8 +11511,7 @@ class ODataModel {
11681
11511
  //#endregion
11682
11512
  //#region Collection Tools
11683
11513
  collection() {
11684
- return this._parent !== null &&
11685
- ODataModelOptions.isCollection(this._parent[0])
11514
+ return this._parent !== null && ODataModelOptions.isCollection(this._parent[0])
11686
11515
  ? this._parent[0]
11687
11516
  : undefined;
11688
11517
  }
@@ -11752,8 +11581,7 @@ class ODataModelEvent {
11752
11581
  this.bubbles = false;
11753
11582
  }
11754
11583
  visited(model) {
11755
- return (this.chain.some((c) => c[0] === model) &&
11756
- this.chain[this.chain.length - 1][0] !== model);
11584
+ return this.chain.some((c) => c[0] === model) && this.chain[this.chain.length - 1][0] !== model;
11757
11585
  }
11758
11586
  canContinueWith(self) {
11759
11587
  return this.bubbles && !this.visited(self);
@@ -11781,9 +11609,7 @@ class ODataModelEvent {
11781
11609
  //Identifies the current collection for the event
11782
11610
  get currentCollection() {
11783
11611
  const link = this.chain.find((c) => ODataModelOptions.isCollection(c[0]));
11784
- return link !== undefined
11785
- ? link[0]
11786
- : undefined;
11612
+ return link !== undefined ? link[0] : undefined;
11787
11613
  }
11788
11614
  }
11789
11615
  class ODataModelEventEmitter extends EventEmitter {
@@ -11932,9 +11758,7 @@ class ODataModelField {
11932
11758
  return this.parser.isStructuredType();
11933
11759
  }
11934
11760
  structuredType() {
11935
- const structuredType = this.structuredForType
11936
- ? this.structuredForType(this.type)
11937
- : undefined;
11761
+ const structuredType = this.structuredForType ? this.structuredForType(this.type) : undefined;
11938
11762
  //Throw error if not found
11939
11763
  if (!structuredType)
11940
11764
  throw new Error(`Could not find structured type for ${this.parser.type}`);
@@ -11955,9 +11779,7 @@ class ODataModelField {
11955
11779
  return !value.isValid({ method, navigation }) ? value._errors : undefined;
11956
11780
  }
11957
11781
  else if (ODataModelOptions.isCollection(value)) {
11958
- return value
11959
- .models()
11960
- .some((m) => !m.isValid({ method, navigation }))
11782
+ return value.models().some((m) => !m.isValid({ method, navigation }))
11961
11783
  ? value.models().map((m) => m._errors)
11962
11784
  : undefined;
11963
11785
  }
@@ -11980,31 +11802,21 @@ class ODataModelField {
11980
11802
  value.length < this.minLength) {
11981
11803
  errors['push'](`minlength`);
11982
11804
  }
11983
- if (this.min !== undefined &&
11984
- typeof value === 'number' &&
11985
- value < this.min) {
11805
+ if (this.min !== undefined && typeof value === 'number' && value < this.min) {
11986
11806
  errors['push'](`min`);
11987
11807
  }
11988
- if (this.max !== undefined &&
11989
- typeof value === 'number' &&
11990
- value > this.max) {
11808
+ if (this.max !== undefined && typeof value === 'number' && value > this.max) {
11991
11809
  errors['push'](`max`);
11992
11810
  }
11993
- if (this.pattern !== undefined &&
11994
- typeof value === 'string' &&
11995
- !this.pattern.test(value)) {
11811
+ if (this.pattern !== undefined && typeof value === 'string' && !this.pattern.test(value)) {
11996
11812
  errors['push'](`pattern`);
11997
11813
  }
11998
11814
  return !Types.isEmpty(errors) ? errors : undefined;
11999
11815
  }
12000
11816
  }
12001
11817
  defaults() {
12002
- const meta = this.optionsForType
12003
- ? this.optionsForType(this.type)
12004
- : undefined;
12005
- return this.isStructuredType() && meta !== undefined
12006
- ? meta.defaults()
12007
- : this.default;
11818
+ const meta = this.optionsForType ? this.optionsForType(this.type) : undefined;
11819
+ return this.isStructuredType() && meta !== undefined ? meta.defaults() : this.default;
12008
11820
  }
12009
11821
  deserialize(value, options) {
12010
11822
  const parserOptions = options ?? this.parserOptions;
@@ -12056,9 +11868,7 @@ class ODataModelField {
12056
11868
  collectionFactory({ parent, value, reset, }) {
12057
11869
  // Collection Factory
12058
11870
  const annots = this.annotationsFactory(parent.annots());
12059
- const Collection = this.collectionForType
12060
- ? this.collectionForType(this.type)
12061
- : undefined;
11871
+ const Collection = this.collectionForType ? this.collectionForType(this.type) : undefined;
12062
11872
  if (Collection === undefined)
12063
11873
  throw Error(`No Collection type for ${this.name}`);
12064
11874
  return new Collection((value || []), {
@@ -12109,13 +11919,11 @@ class ODataModelAttribute {
12109
11919
  }
12110
11920
  set(value, reset = false, reparent = false) {
12111
11921
  const current = this.get();
12112
- if (ODataModelOptions.isModel(current) ||
12113
- ODataModelOptions.isCollection(current))
11922
+ if (ODataModelOptions.isModel(current) || ODataModelOptions.isCollection(current))
12114
11923
  this.unlink(current);
12115
11924
  const changed = ODataModelOptions.isModel(current) && ODataModelOptions.isModel(value)
12116
11925
  ? !current.equals(value)
12117
- : ODataModelOptions.isCollection(current) &&
12118
- ODataModelOptions.isCollection(value)
11926
+ : ODataModelOptions.isCollection(current) && ODataModelOptions.isCollection(value)
12119
11927
  ? !current.equals(value)
12120
11928
  : !Types.isEqual(current, value);
12121
11929
  if (reset) {
@@ -12129,26 +11937,24 @@ class ODataModelAttribute {
12129
11937
  this.change = value;
12130
11938
  this.state = ODataModelState.Changed;
12131
11939
  }
12132
- if (ODataModelOptions.isModel(value) ||
12133
- ODataModelOptions.isCollection(value)) {
11940
+ if (ODataModelOptions.isModel(value) || ODataModelOptions.isCollection(value)) {
12134
11941
  this.link(value, reparent);
12135
11942
  }
12136
11943
  return changed;
12137
11944
  }
12138
- isChanged({ include_navigation = false, } = {}) {
11945
+ isChanged({ include_navigation = false } = {}) {
12139
11946
  const current = this.get();
12140
11947
  return (this.state === ODataModelState.Changed ||
12141
- ((ODataModelOptions.isModel(current) ||
12142
- ODataModelOptions.isCollection(current)) &&
12143
- current.hasChanged({ include_navigation })));
11948
+ ((ODataModelOptions.isModel(current) || ODataModelOptions.isCollection(current)) &&
11949
+ current.hasChanged({
11950
+ include_navigation,
11951
+ })));
12144
11952
  }
12145
11953
  reset() {
12146
- if (ODataModelOptions.isModel(this.change) ||
12147
- ODataModelOptions.isCollection(this.change))
11954
+ if (ODataModelOptions.isModel(this.change) || ODataModelOptions.isCollection(this.change))
12148
11955
  this.unlink(this.change);
12149
11956
  this.state = ODataModelState.Unchanged;
12150
- if (ODataModelOptions.isModel(this.value) ||
12151
- ODataModelOptions.isCollection(this.value))
11957
+ if (ODataModelOptions.isModel(this.value) || ODataModelOptions.isCollection(this.value))
12152
11958
  this.link(this.value);
12153
11959
  }
12154
11960
  link(value, reparent = false) {
@@ -12234,8 +12040,7 @@ class ODataModelOptions {
12234
12040
  this.entitySet = this.api.findEntitySetForEntityType(this.type());
12235
12041
  let concurrencyFields = [];
12236
12042
  if (this.entitySet !== undefined) {
12237
- concurrencyFields =
12238
- this.entitySet.annotatedValue(OPTIMISTIC_CONCURRENCY) || [];
12043
+ concurrencyFields = this.entitySet.annotatedValue(OPTIMISTIC_CONCURRENCY) || [];
12239
12044
  }
12240
12045
  this._fields.forEach((field) => {
12241
12046
  const concurrency = concurrencyFields.indexOf(field.field) !== -1;
@@ -12355,8 +12160,7 @@ class ODataModelOptions {
12355
12160
  resource = resource || model._resource;
12356
12161
  if (resource === null)
12357
12162
  break;
12358
- if (ODataModelOptions.isModel(model) &&
12359
- (prevField === null || prevField.collection)) {
12163
+ if (ODataModelOptions.isModel(model) && (prevField === null || prevField.collection)) {
12360
12164
  const m = model;
12361
12165
  // Resolve subtype if collection not is from field
12362
12166
  // FIXME
@@ -12418,8 +12222,7 @@ class ODataModelOptions {
12418
12222
  this.attach(self, resource);
12419
12223
  }
12420
12224
  // Annotations
12421
- self._annotations =
12422
- annots ?? new ODataEntityAnnotations(ODataHelper[DEFAULT_VERSION]);
12225
+ self._annotations = annots ?? new ODataEntityAnnotations(ODataHelper[DEFAULT_VERSION]);
12423
12226
  // Fields
12424
12227
  this.fields({
12425
12228
  include_navigation: true,
@@ -12451,10 +12254,7 @@ class ODataModelOptions {
12451
12254
  .fields({ include_navigation: false, include_parents: true })
12452
12255
  .find((field) => field.field === name);
12453
12256
  if (field !== undefined) {
12454
- v =
12455
- Types.isPlainObject(v) || ODataModelOptions.isModel(v)
12456
- ? v[field.name]
12457
- : v;
12257
+ v = Types.isPlainObject(v) || ODataModelOptions.isModel(v) ? v[field.name] : v;
12458
12258
  options = this.api.optionsForType(field.type);
12459
12259
  }
12460
12260
  }
@@ -12467,9 +12267,7 @@ class ODataModelOptions {
12467
12267
  }
12468
12268
  if (key.size === 0)
12469
12269
  return undefined;
12470
- return resolve
12471
- ? Objects.resolveKey(key, { single })
12472
- : Object.fromEntries(key);
12270
+ return resolve ? Objects.resolveKey(key, { single }) : Object.fromEntries(key);
12473
12271
  }
12474
12272
  resolveReferential(value, attr, { field_mapping = false, resolve = true, single = false, } = {}) {
12475
12273
  const referential = new Map();
@@ -12490,9 +12288,7 @@ class ODataModelOptions {
12490
12288
  return undefined;
12491
12289
  if (referential.size === 1 && Array.from(referential.values())[0] === null)
12492
12290
  return null;
12493
- return resolve
12494
- ? Objects.resolveKey(referential, { single })
12495
- : Object.fromEntries(referential);
12291
+ return resolve ? Objects.resolveKey(referential, { single }) : Object.fromEntries(referential);
12496
12292
  }
12497
12293
  resolveReferenced(value, attr, { field_mapping = false, resolve = true, single = false, } = {}) {
12498
12294
  const referenced = new Map();
@@ -12514,9 +12310,7 @@ class ODataModelOptions {
12514
12310
  return undefined;
12515
12311
  if (referenced.size === 1 && Array.from(referenced.values())[0] === null)
12516
12312
  return null;
12517
- return resolve
12518
- ? Objects.resolveKey(referenced, { single })
12519
- : Object.fromEntries(referenced);
12313
+ return resolve ? Objects.resolveKey(referenced, { single }) : Object.fromEntries(referenced);
12520
12314
  }
12521
12315
  validate(self, { method, navigation = false, } = {}) {
12522
12316
  const errors = this.fields({
@@ -12525,9 +12319,7 @@ class ODataModelOptions {
12525
12319
  }).reduce((acc, field) => {
12526
12320
  const value = self[field.name];
12527
12321
  const errs = field.validate(value, { method });
12528
- return errs !== undefined
12529
- ? Object.assign(acc, { [field.name]: errs })
12530
- : acc;
12322
+ return errs !== undefined ? Object.assign(acc, { [field.name]: errs }) : acc;
12531
12323
  }, {});
12532
12324
  return !Types.isEmpty(errors) ? errors : undefined;
12533
12325
  }
@@ -12537,9 +12329,7 @@ class ODataModelOptions {
12537
12329
  include_parents: true,
12538
12330
  }).reduce((acc, field) => {
12539
12331
  const value = field.defaults();
12540
- return value !== undefined
12541
- ? Object.assign(acc, { [field.name]: value })
12542
- : acc;
12332
+ return value !== undefined ? Object.assign(acc, { [field.name]: value }) : acc;
12543
12333
  }, {});
12544
12334
  return !Types.isEmpty(defs) ? defs : undefined;
12545
12335
  }
@@ -12571,9 +12361,7 @@ class ODataModelOptions {
12571
12361
  asEntity(self, ctx) {
12572
12362
  // Clone query from him or parent
12573
12363
  let query = self._resource?.cloneQuery();
12574
- if (query === undefined &&
12575
- self._parent &&
12576
- self._parent[0] instanceof ODataCollection)
12364
+ if (query === undefined && self._parent && self._parent[0] instanceof ODataCollection)
12577
12365
  query = self._parent[0]._resource?.cloneQuery();
12578
12366
  // Build new resource
12579
12367
  const resource = this.modelResourceFactory(query);
@@ -12586,12 +12374,10 @@ class ODataModelOptions {
12586
12374
  (attr) => chain.every((c) => c !== attr.get()))
12587
12375
  .filter(
12588
12376
  // Changes only
12589
- (attr) => !changes_only ||
12590
- (changes_only && attr.isChanged({ include_navigation })))
12377
+ (attr) => !changes_only || (changes_only && attr.isChanged({ include_navigation })))
12591
12378
  .filter((attr) =>
12592
12379
  // Navigation
12593
- (include_navigation && attr.navigation && attr.get() !== null) ||
12594
- !attr.navigation)
12380
+ (include_navigation && attr.navigation && attr.get() !== null) || !attr.navigation)
12595
12381
  .reduce((acc, attr) => {
12596
12382
  const name = field_mapping ? attr.fieldName : attr.name;
12597
12383
  let value = attr.get();
@@ -12673,10 +12459,8 @@ class ODataModelOptions {
12673
12459
  self._parent[1] !== null &&
12674
12460
  this.api.optionsForType(self._parent[1].type) !== self._meta) ||
12675
12461
  (ODataModelOptions.isCollection(self._parent[0]) &&
12676
- self._parent[0]._model
12677
- .meta !== self._meta))) {
12678
- entity[this.api.options.helper.ODATA_TYPE] =
12679
- `#${this.structuredType.type()}`;
12462
+ self._parent[0]._model.meta !== self._meta))) {
12463
+ entity[this.api.options.helper.ODATA_TYPE] = `#${this.structuredType.type()}`;
12680
12464
  }
12681
12465
  return entity;
12682
12466
  }
@@ -12685,8 +12469,7 @@ class ODataModelOptions {
12685
12469
  if (name !== undefined) {
12686
12470
  // Reset value
12687
12471
  const attribute = self._attributes.get(name);
12688
- if (attribute !== undefined &&
12689
- attribute.isChanged({ include_navigation: true })) {
12472
+ if (attribute !== undefined && attribute.isChanged({ include_navigation: true })) {
12690
12473
  attribute.reset();
12691
12474
  changes = [name];
12692
12475
  }
@@ -12742,7 +12525,9 @@ class ODataModelOptions {
12742
12525
  }
12743
12526
  });
12744
12527
  if (!silent && changes.length > 0) {
12745
- self.events$.trigger(reset ? ODataModelEventType.Reset : ODataModelEventType.Update, { options: { changes } });
12528
+ self.events$.trigger(reset ? ODataModelEventType.Reset : ODataModelEventType.Update, {
12529
+ options: { changes },
12530
+ });
12746
12531
  }
12747
12532
  return self;
12748
12533
  }
@@ -12756,8 +12541,7 @@ class ODataModelOptions {
12756
12541
  const attr = self._attributes.get(field instanceof ODataModelField ? field.name : field);
12757
12542
  if (attr !== undefined) {
12758
12543
  const value = attr.get();
12759
- if ((attr.navigation && value === null) ||
12760
- ODataModelOptions.isModel(value)) {
12544
+ if ((attr.navigation && value === null) || ODataModelOptions.isModel(value)) {
12761
12545
  // Check for reference
12762
12546
  const referenced = this.resolveReferenced(self, attr, {
12763
12547
  resolve: false,
@@ -12778,18 +12562,14 @@ class ODataModelOptions {
12778
12562
  }
12779
12563
  return value;
12780
12564
  }
12781
- else if (typeof field === 'string' &&
12782
- !field.startsWith('_') &&
12783
- !field.endsWith('$')) {
12565
+ else if (typeof field === 'string' && !field.startsWith('_') && !field.endsWith('$')) {
12784
12566
  return self[field];
12785
12567
  }
12786
12568
  return undefined;
12787
12569
  }
12788
12570
  set(self, field, value, { add, merge, remove, reset, reparent, silent, type, } = {}) {
12789
12571
  let modelField = field instanceof ODataModelField ? field : this.findField(field);
12790
- if (modelField === undefined &&
12791
- this.isOpenType() &&
12792
- typeof field === 'string') {
12572
+ if (modelField === undefined && this.isOpenType() && typeof field === 'string') {
12793
12573
  type = type ?? this.tsToEdm[typeof value] ?? EdmType.String;
12794
12574
  modelField = this.modelFieldFactory(self, field, type);
12795
12575
  }
@@ -12853,8 +12633,7 @@ class ODataModelOptions {
12853
12633
  else {
12854
12634
  // Current is null or undefined
12855
12635
  // create new model/collection for given value
12856
- changed = attr.set(ODataModelOptions.isCollection(value) ||
12857
- ODataModelOptions.isModel(value)
12636
+ changed = attr.set(ODataModelOptions.isCollection(value) || ODataModelOptions.isModel(value)
12858
12637
  ? value
12859
12638
  : modelField.collection
12860
12639
  ? modelField.collectionFactory({
@@ -12896,9 +12675,7 @@ class ODataModelOptions {
12896
12675
  attr.events$.subscribe((event) => {
12897
12676
  if (event.canContinueWith(self)) {
12898
12677
  if (event.model === attr.get()) {
12899
- if (event.type === ODataModelEventType.Change &&
12900
- attr.navigation &&
12901
- event.options?.key) {
12678
+ if (event.type === ODataModelEventType.Change && attr.navigation && event.options?.key) {
12902
12679
  const ref = attr.get().referential(attr);
12903
12680
  if (ref !== null && ref !== undefined) {
12904
12681
  Object.assign(self, ref);
@@ -13173,9 +12950,7 @@ class ODataApi {
13173
12950
  withCredentials: options.withCredentials,
13174
12951
  });
13175
12952
  let res$ = this.requester !== undefined ? this.requester(req) : NEVER;
13176
- res$ = res$.pipe(map((res) => res.type === HttpEventType.Response
13177
- ? ODataResponse.fromHttpResponse(req, res)
13178
- : res));
12953
+ res$ = res$.pipe(map((res) => res.type === HttpEventType.Response ? ODataResponse.fromHttpResponse(req, res) : res));
13179
12954
  if (this.errorHandler !== undefined)
13180
12955
  res$ = res$.pipe(catchError(this.errorHandler));
13181
12956
  if (options.observe === 'events') {
@@ -13232,9 +13007,7 @@ class ODataApi {
13232
13007
  return undefined;
13233
13008
  if (schemas.length === 1)
13234
13009
  return schemas[0];
13235
- return schemas
13236
- .sort((s1, s2) => s1.namespace.length - s2.namespace.length)
13237
- .pop();
13010
+ return schemas.sort((s1, s2) => s1.namespace.length - s2.namespace.length).pop();
13238
13011
  }
13239
13012
  //#region EnumTypes
13240
13013
  findEnumType(value) {
@@ -13255,8 +13028,7 @@ class ODataApi {
13255
13028
  }
13256
13029
  const structuredTypes = this.schemas.reduce((acc, schema) => [...acc, ...schema.entities], []);
13257
13030
  let structuredType = structuredTypes.find((e) => e.type() === value);
13258
- structuredType =
13259
- structuredType ?? structuredTypes.find((e) => e.name === value);
13031
+ structuredType = structuredType ?? structuredTypes.find((e) => e.name === value);
13260
13032
  this.memo.structuredTypes.set(value, structuredType);
13261
13033
  return structuredType;
13262
13034
  }
@@ -13267,9 +13039,7 @@ class ODataApi {
13267
13039
  if (this.memo.callables.has(key)) {
13268
13040
  return this.memo.callables.get(key);
13269
13041
  }
13270
- const bindingStructuredType = bindingType !== undefined
13271
- ? this.findStructuredType(bindingType)
13272
- : undefined;
13042
+ const bindingStructuredType = bindingType !== undefined ? this.findStructuredType(bindingType) : undefined;
13273
13043
  const callables = this.schemas.reduce((acc, schema) => [...acc, ...schema.callables], []);
13274
13044
  let callable = callables.find((c) => {
13275
13045
  const isCallableType = c.type() == value;
@@ -13474,9 +13244,7 @@ class ODataSettings {
13474
13244
  }
13475
13245
  //#region Configs shortcuts
13476
13246
  enumTypeForType(type) {
13477
- let values = this.apis
13478
- .map((api) => api.findEnumType(type))
13479
- .filter((e) => e);
13247
+ let values = this.apis.map((api) => api.findEnumType(type)).filter((e) => e);
13480
13248
  if (values.length === 0)
13481
13249
  throw Error(`No Enum for type ${type} was found`);
13482
13250
  if (values.length > 1)
@@ -13484,9 +13252,7 @@ class ODataSettings {
13484
13252
  return values[0];
13485
13253
  }
13486
13254
  structuredTypeForType(type) {
13487
- let values = this.apis
13488
- .map((api) => api.findStructuredType(type))
13489
- .filter((e) => e);
13255
+ let values = this.apis.map((api) => api.findStructuredType(type)).filter((e) => e);
13490
13256
  if (values.length === 0)
13491
13257
  throw Error(`No Structured for type ${type} was found`);
13492
13258
  if (values.length > 1)
@@ -13494,9 +13260,7 @@ class ODataSettings {
13494
13260
  return values[0];
13495
13261
  }
13496
13262
  callableForType(type, bindingType) {
13497
- let values = this.apis
13498
- .map((api) => api.findCallable(type, bindingType))
13499
- .filter((e) => e);
13263
+ let values = this.apis.map((api) => api.findCallable(type, bindingType)).filter((e) => e);
13500
13264
  if (values.length === 0)
13501
13265
  throw Error(`No Callable for type ${type} was found`);
13502
13266
  if (values.length > 1)
@@ -13504,9 +13268,7 @@ class ODataSettings {
13504
13268
  return values[0];
13505
13269
  }
13506
13270
  entitySetForType(type) {
13507
- let values = this.apis
13508
- .map((api) => api.findEntitySet(type))
13509
- .filter((e) => e);
13271
+ let values = this.apis.map((api) => api.findEntitySet(type)).filter((e) => e);
13510
13272
  if (values.length === 0)
13511
13273
  throw Error(`No EntitySet for type ${type} was found`);
13512
13274
  if (values.length > 1)
@@ -13514,9 +13276,7 @@ class ODataSettings {
13514
13276
  return values[0];
13515
13277
  }
13516
13278
  parserForType(type) {
13517
- let values = this.apis
13518
- .map((api) => api.parserForType(type))
13519
- .filter((e) => e);
13279
+ let values = this.apis.map((api) => api.parserForType(type)).filter((e) => e);
13520
13280
  if (values.length === 0)
13521
13281
  throw Error(`No Parser for type ${type} was found`);
13522
13282
  if (!type.startsWith('Edm.') && values.length > 1)
@@ -13532,9 +13292,7 @@ class ODataSettings {
13532
13292
  return values[0];
13533
13293
  }
13534
13294
  collectionForType(type) {
13535
- let values = this.apis
13536
- .map((api) => api.findCollection(type))
13537
- .filter((e) => e);
13295
+ let values = this.apis.map((api) => api.findCollection(type)).filter((e) => e);
13538
13296
  if (values.length === 0)
13539
13297
  throw Error(`No Collection for type ${type} was found`);
13540
13298
  if (values.length > 1)
@@ -13551,9 +13309,7 @@ class ODataConfigSyncLoader {
13551
13309
  this.passedConfigs = passedConfigs;
13552
13310
  }
13553
13311
  loadConfigs() {
13554
- return Array.isArray(this.passedConfigs)
13555
- ? of(this.passedConfigs)
13556
- : of([this.passedConfigs]);
13312
+ return Array.isArray(this.passedConfigs) ? of(this.passedConfigs) : of([this.passedConfigs]);
13557
13313
  }
13558
13314
  }
13559
13315
  class ODataConfigAsyncLoader {
@@ -13564,9 +13320,7 @@ class ODataConfigAsyncLoader {
13564
13320
  loadConfigs() {
13565
13321
  return Array.isArray(this.configs$)
13566
13322
  ? forkJoin(this.configs$)
13567
- : this.configs$.pipe(map$1((value) => Array.isArray(value)
13568
- ? value
13569
- : [value]));
13323
+ : this.configs$.pipe(map$1((value) => Array.isArray(value) ? value : [value]));
13570
13324
  }
13571
13325
  }
13572
13326
  class ODataMetadataLoader {
@@ -13577,9 +13331,7 @@ class ODataMetadataLoader {
13577
13331
  this.baseConfigs = baseConfigs;
13578
13332
  }
13579
13333
  loadConfigs() {
13580
- const configs = Array.isArray(this.baseConfigs)
13581
- ? this.baseConfigs
13582
- : [this.baseConfigs];
13334
+ const configs = Array.isArray(this.baseConfigs) ? this.baseConfigs : [this.baseConfigs];
13583
13335
  return this.sources$.pipe(map$1((source) => (Array.isArray(source) ? source : [source]).map((m, i) => new ODataMetadataParser(m).metadata().toConfig(configs[i] ?? {}))));
13584
13336
  }
13585
13337
  }
@@ -13632,9 +13384,7 @@ class ODataClient {
13632
13384
  if (value instanceof ODataResource)
13633
13385
  api = this.settings.findApiForTypes(value.types());
13634
13386
  else if (typeof value === 'string')
13635
- api =
13636
- this.settings.findApiByName(value) ||
13637
- this.settings.findApiForType(value);
13387
+ api = this.settings.findApiByName(value) || this.settings.findApiForType(value);
13638
13388
  return api ?? this.settings.defaultApi();
13639
13389
  }
13640
13390
  defaultApi() {
@@ -13785,10 +13535,10 @@ class ODataClient {
13785
13535
  put(resource, body, options = {}) {
13786
13536
  return this.request('PUT', resource, addBody(options, body));
13787
13537
  }
13788
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ODataClient, deps: [{ token: i1.HttpClient }, { token: ODataConfigLoader }], target: i0.ɵɵFactoryTarget.Injectable });
13789
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ODataClient });
13538
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.2", ngImport: i0, type: ODataClient, deps: [{ token: i1.HttpClient }, { token: ODataConfigLoader }], target: i0.ɵɵFactoryTarget.Injectable });
13539
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.2.2", ngImport: i0, type: ODataClient });
13790
13540
  }
13791
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ODataClient, decorators: [{
13541
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.2", ngImport: i0, type: ODataClient, decorators: [{
13792
13542
  type: Injectable
13793
13543
  }], ctorParameters: () => [{ type: i1.HttpClient }, { type: ODataConfigLoader }] });
13794
13544
 
@@ -14072,10 +13822,10 @@ class ODataServiceFactory {
14072
13822
  };
14073
13823
  return new Service(this.client, singletonName, apiNameOrEntityType);
14074
13824
  }
14075
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ODataServiceFactory, deps: [{ token: ODataClient }], target: i0.ɵɵFactoryTarget.Injectable });
14076
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ODataServiceFactory });
13825
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.2", ngImport: i0, type: ODataServiceFactory, deps: [{ token: ODataClient }], target: i0.ɵɵFactoryTarget.Injectable });
13826
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.2.2", ngImport: i0, type: ODataServiceFactory });
14077
13827
  }
14078
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ODataServiceFactory, decorators: [{
13828
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.2", ngImport: i0, type: ODataServiceFactory, decorators: [{
14079
13829
  type: Injectable
14080
13830
  }], ctorParameters: () => [{ type: ODataClient }] });
14081
13831
 
@@ -14115,14 +13865,14 @@ class ODataModule {
14115
13865
  ],
14116
13866
  };
14117
13867
  }
14118
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
14119
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.12", ngImport: i0, type: ODataModule, imports: [CommonModule, HttpClientModule] });
14120
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ODataModule, providers: [ODataClient, ODataServiceFactory], imports: [CommonModule, HttpClientModule] });
13868
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.2", ngImport: i0, type: ODataModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
13869
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.2.2", ngImport: i0, type: ODataModule, imports: [CommonModule] });
13870
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.2.2", ngImport: i0, type: ODataModule, providers: [ODataClient, ODataServiceFactory], imports: [CommonModule] });
14121
13871
  }
14122
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.12", ngImport: i0, type: ODataModule, decorators: [{
13872
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.2", ngImport: i0, type: ODataModule, decorators: [{
14123
13873
  type: NgModule,
14124
13874
  args: [{
14125
- imports: [CommonModule, HttpClientModule],
13875
+ imports: [CommonModule],
14126
13876
  providers: [ODataClient, ODataServiceFactory],
14127
13877
  }]
14128
13878
  }] });
@@ -14156,9 +13906,7 @@ class ODataBaseCache {
14156
13906
  const tags = [];
14157
13907
  const context = res.context;
14158
13908
  if (context.entitySet) {
14159
- tags.push(context.key
14160
- ? `${context.entitySet}(${context.key})`
14161
- : context.entitySet);
13909
+ tags.push(context.key ? `${context.entitySet}(${context.key})` : context.entitySet);
14162
13910
  }
14163
13911
  if (context.type)
14164
13912
  tags.push(context.type);
@@ -14195,7 +13943,7 @@ class ODataBaseCache {
14195
13943
  * @param scope The scope for the entry
14196
13944
  * @param tags The tags for the entry
14197
13945
  */
14198
- put(name, payload, { timeout, scope, tags, } = {}) {
13946
+ put(name, payload, { timeout, scope, tags } = {}) {
14199
13947
  const entry = this.buildEntry(payload, { timeout, tags });
14200
13948
  const key = this.buildKey([...(scope || []), name]);
14201
13949
  this.entries.set(key, entry);
@@ -14210,9 +13958,7 @@ class ODataBaseCache {
14210
13958
  get(name, { scope } = {}) {
14211
13959
  const key = this.buildKey([...(scope || []), name]);
14212
13960
  const entry = this.entries.get(key);
14213
- return entry !== undefined && !this.isExpired(entry)
14214
- ? entry.payload
14215
- : undefined;
13961
+ return entry !== undefined && !this.isExpired(entry) ? entry.payload : undefined;
14216
13962
  }
14217
13963
  /**
14218
13964
  * Remove all cache entries that are matching with the given options
@@ -14272,9 +14018,7 @@ class ODataBaseCache {
14272
14018
  return throwError(() => new Error('No Cached'));
14273
14019
  }
14274
14020
  }
14275
- if (policy === 'cache-first' ||
14276
- policy === 'cache-and-network' ||
14277
- policy === 'network-only') {
14021
+ if (policy === 'cache-first' || policy === 'cache-and-network' || policy === 'network-only') {
14278
14022
  res$ = res$.pipe(tap((res) => {
14279
14023
  if (res.options.cacheability !== 'no-store')
14280
14024
  this.putResponse(req, res);
@@ -14288,9 +14032,7 @@ class ODataBaseCache {
14288
14032
  }
14289
14033
  handleMutate(req, res$) {
14290
14034
  const requests = req.isBatch()
14291
- ? req.resource
14292
- .requests()
14293
- .filter((r) => r.isMutate())
14035
+ ? req.resource.requests().filter((r) => r.isMutate())
14294
14036
  : [req];
14295
14037
  for (var r of requests) {
14296
14038
  const scope = this.scope(r);