@ui5/task-adaptation 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/dist/annotationManager.d.ts +3 -3
  3. package/dist/annotationManager.js +15 -16
  4. package/dist/annotations/comparator/comparator.js +30 -26
  5. package/dist/annotations/comparator/diffCase.js +1 -2
  6. package/dist/annotations/comparator/interchangableCase.d.ts +1 -1
  7. package/dist/annotations/comparator/interchangableCase.js +7 -12
  8. package/dist/annotations/converter/metadataJsonReferenceUtil.js +7 -9
  9. package/dist/annotations/converter/metadataJsonUtil.js +7 -10
  10. package/dist/annotations/converter/ui5JsonConverter.js +5 -6
  11. package/dist/annotations/converter/ui5MetadataJsonUtil.js +1 -4
  12. package/dist/annotations/converter/ui5XmlConverter.js +4 -7
  13. package/dist/annotations/dataSource/dataSource.d.ts +5 -5
  14. package/dist/annotations/dataSource/dataSource.js +8 -8
  15. package/dist/annotations/dataSource/dataSourceManager.d.ts +3 -3
  16. package/dist/annotations/dataSource/dataSourceManager.js +8 -13
  17. package/dist/annotations/dataSource/dataSourceOData.d.ts +3 -3
  18. package/dist/annotations/dataSource/dataSourceOData.js +13 -15
  19. package/dist/annotations/dataSource/dataSourceODataAnnotation.d.ts +1 -1
  20. package/dist/annotations/dataSource/dataSourceODataAnnotation.js +5 -7
  21. package/dist/annotations/serviceRequestor.d.ts +3 -3
  22. package/dist/annotations/serviceRequestor.js +15 -13
  23. package/dist/annotations/transformers/convertV2ToV4.d.ts +1 -1
  24. package/dist/annotations/transformers/convertV2ToV4.js +7 -10
  25. package/dist/annotations/transformers/makeAnnotationNamespaceUnique.d.ts +1 -1
  26. package/dist/annotations/transformers/makeAnnotationNamespaceUnique.js +8 -11
  27. package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.d.ts +1 -1
  28. package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.js +3 -6
  29. package/dist/annotations/transformers/transformer.d.ts +2 -2
  30. package/dist/annotations/transformers/transformer.js +1 -2
  31. package/dist/annotations/transformers/traverseReferences.d.ts +1 -1
  32. package/dist/annotations/transformers/traverseReferences.js +16 -17
  33. package/dist/appVariantManager.d.ts +1 -1
  34. package/dist/appVariantManager.js +17 -20
  35. package/dist/baseAppManager.d.ts +2 -2
  36. package/dist/baseAppManager.js +18 -20
  37. package/dist/buildStrategy.js +2 -4
  38. package/dist/bundle.d.ts +25 -0
  39. package/dist/bundle.js +3696 -219
  40. package/dist/cache/annotationsCacheManager.d.ts +2 -2
  41. package/dist/cache/annotationsCacheManager.js +3 -5
  42. package/dist/cache/baseAppFilesCacheManager.d.ts +1 -1
  43. package/dist/cache/baseAppFilesCacheManager.js +3 -6
  44. package/dist/cache/cacheManager.d.ts +1 -1
  45. package/dist/cache/cacheManager.js +9 -12
  46. package/dist/i18nManager.d.ts +3 -3
  47. package/dist/i18nManager.js +23 -23
  48. package/dist/index.d.ts +6 -1
  49. package/dist/index.js +14 -16
  50. package/dist/model/annotationDiffStructureError.js +1 -4
  51. package/dist/model/language.js +4 -4
  52. package/dist/model/noAuthorizationProvidedError.js +1 -4
  53. package/dist/model/serverError.js +1 -4
  54. package/dist/model/types.d.ts +1 -1
  55. package/dist/model/types.js +1 -2
  56. package/dist/processors/abapProcessor.d.ts +5 -5
  57. package/dist/processors/abapProcessor.js +9 -8
  58. package/dist/processors/cfProcessor.d.ts +3 -3
  59. package/dist/processors/cfProcessor.js +7 -8
  60. package/dist/processors/processor.d.ts +1 -1
  61. package/dist/processors/processor.js +11 -15
  62. package/dist/repositories/abapRepoManager.d.ts +1 -1
  63. package/dist/repositories/abapRepoManager.js +14 -14
  64. package/dist/repositories/html5RepoManager.d.ts +1 -1
  65. package/dist/repositories/html5RepoManager.js +12 -14
  66. package/dist/util/cfUtil.d.ts +1 -1
  67. package/dist/util/cfUtil.js +12 -14
  68. package/dist/util/commonUtil.d.ts +2 -2
  69. package/dist/util/commonUtil.js +19 -32
  70. package/dist/util/i18nMerger.d.ts +6 -2
  71. package/dist/util/i18nMerger.js +10 -14
  72. package/dist/util/requestUtil.d.ts +1 -1
  73. package/dist/util/requestUtil.js +9 -12
  74. package/dist/util/resourceUtil.js +8 -11
  75. package/dist/util/urlUtil.d.ts +2 -2
  76. package/dist/util/urlUtil.js +3 -6
  77. package/dist/util/xmlUtil.js +2 -5
  78. package/dist/util/zipUtil.js +2 -6
  79. package/eslint.config.js +52 -0
  80. package/package.json +44 -51
  81. package/scripts/metadataDownloadHelper.ts +8 -7
  82. package/scripts/rollup/bundle.d.ts +25 -0
  83. package/scripts/rollup/bundleDefinition.js +11 -1
  84. package/scripts/{bundler.ts → rollup/bundler.ts} +6 -17
  85. package/scripts/rollup/overrides/sap/base/config.js +10 -0
  86. package/scripts/rollup/project/package.json +2 -1
  87. package/scripts/rollup/project/ui5.yaml +1 -1
  88. package/scripts/rollup/ui5Resolve.ts +14 -38
  89. package/scripts/rollup.ts +67 -23
  90. package/types/ui5.d.ts +44 -0
  91. package/dist/bundle-odata.js +0 -5498
  92. package/scripts/rollup/bundleDefinition-odata.js +0 -9
package/dist/bundle.js CHANGED
@@ -1,8 +1,4 @@
1
1
  var window = {};
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
2
  var fnIsEmptyObject = function isEmptyObject(obj) {
7
3
  for (var sName in obj) {
8
4
  return false;
@@ -20,7 +16,7 @@ function getDescriptorChanges(oManifest) {
20
16
  });
21
17
  }
22
18
  var Applier = {
23
- applyChanges: function (oUpdatedManifest, aAppDescriptorChanges, mStrategy) {
19
+ applyChanges(oUpdatedManifest, aAppDescriptorChanges, mStrategy) {
24
20
  return mStrategy.registry().then(function (Registry) {
25
21
  var aChangeHandlerPromises = aAppDescriptorChanges.map(function (oChange) {
26
22
  return Registry[oChange.getChangeType()] && Registry[oChange.getChangeType()]();
@@ -41,7 +37,7 @@ var Applier = {
41
37
  return oUpdatedManifest;
42
38
  });
43
39
  },
44
- applyChangesIncludedInManifest: function (oManifest, mStrategy) {
40
+ applyChangesIncludedInManifest(oManifest, mStrategy) {
45
41
  var aDescriptorChanges = getDescriptorChanges(oManifest);
46
42
  var oManifestJSON = oManifest.getJson();
47
43
  delete oManifestJSON[CHANGES_NAMESPACE];
@@ -1846,11 +1842,11 @@ p.escapeQuerySpace = function (v) {
1846
1842
  };
1847
1843
 
1848
1844
  var ApplyUtil = {
1849
- formatBundleName: function (sId, sBundleUrl) {
1845
+ formatBundleName(sId, sBundleUrl) {
1850
1846
  if (sBundleUrl.startsWith("/")) {
1851
1847
  throw Error("Absolute paths are not supported");
1852
1848
  }
1853
- var sNormalizedUrl = new URI(sId + "/" + sBundleUrl).normalize().path();
1849
+ var sNormalizedUrl = new URI(`${sId}/${sBundleUrl}`).normalize().path();
1854
1850
  return sNormalizedUrl.replace(/\//g, ".").replace("..", ".").replace(/.properties$/g, "");
1855
1851
  }
1856
1852
  };
@@ -1929,27 +1925,6 @@ function changePropertyValueByPath (vChanges, oRootPath) {
1929
1925
  }
1930
1926
  }
1931
1927
 
1932
- var fnValues = function values(mObject) {
1933
- if (typeof mObject === "undefined" || mObject === null || mObject !== mObject) {
1934
- return [];
1935
- }
1936
- return Object.values(mObject);
1937
- };
1938
-
1939
- var fnIncludes = function (vCollection, vValue, iFromIndex) {
1940
- if (typeof iFromIndex !== "number") {
1941
- iFromIndex = 0;
1942
- }
1943
- if (Array.isArray(vCollection) || typeof vCollection === "string") {
1944
- if (iFromIndex < 0) {
1945
- iFromIndex = vCollection.length + iFromIndex < 0 ? 0 : vCollection.length + iFromIndex;
1946
- }
1947
- return vCollection.includes(vValue, iFromIndex);
1948
- } else {
1949
- return fnIncludes(fnValues(vCollection), vValue, iFromIndex);
1950
- }
1951
- };
1952
-
1953
1928
  var Layer = {
1954
1929
  USER: "USER",
1955
1930
  PUBLIC: "PUBLIC",
@@ -1960,14 +1935,12 @@ var Layer = {
1960
1935
  BASE: "BASE"
1961
1936
  };
1962
1937
 
1963
- function checkChange(oEntityPropertyChange, aSupportedProperties, aSupportedOperations) {
1964
- if (Array.isArray(oEntityPropertyChange)) {
1965
- oEntityPropertyChange.forEach(function (change) {
1966
- formatEntityCheck(change, aSupportedProperties, aSupportedOperations);
1967
- });
1968
- } else {
1969
- formatEntityCheck(oEntityPropertyChange, aSupportedProperties, aSupportedOperations);
1970
- }
1938
+ function checkChange(oEntityPropertyChange, aSupportedProperties, aSupportedOperations, oSupportedPropertyPattern) {
1939
+ const aEntityPropertyChanges = Array.isArray(oEntityPropertyChange) ? oEntityPropertyChange : [oEntityPropertyChange];
1940
+ aEntityPropertyChanges.forEach(function (oChange) {
1941
+ formatEntityCheck(oChange, aSupportedProperties, aSupportedOperations);
1942
+ checkPropertyValuePattern(oChange, oSupportedPropertyPattern);
1943
+ });
1971
1944
  }
1972
1945
  function getClearedGenericPath(aSupportedProperties) {
1973
1946
  var aPropertiesClearedGenericPath = [];
@@ -2000,24 +1973,24 @@ function formatEntityCheck(oChangeEntity, aSupportedProperties, aSupportedOperat
2000
1973
  throw new Error("Invalid change format: The mandatory 'propertyValue' is not defined. Please define the mandatory property 'propertyValue'");
2001
1974
  }
2002
1975
  }
2003
- if (!fnIncludes(aSupportedProperties, oChangeEntity.propertyPath) && !isGenericPropertyPathSupported(aSupportedProperties, oChangeEntity.propertyPath)) {
2004
- throw new Error("Changing " + oChangeEntity.propertyPath + " is not supported. The supported 'propertyPath' is: " + aSupportedProperties.join("|"));
1976
+ if (!aSupportedProperties.includes(oChangeEntity.propertyPath) && !isGenericPropertyPathSupported(aSupportedProperties, oChangeEntity.propertyPath)) {
1977
+ throw new Error(`Changing ${oChangeEntity.propertyPath} is not supported. The supported 'propertyPath' is: ${aSupportedProperties.join("|")}`);
2005
1978
  }
2006
- if (!fnIncludes(aSupportedOperations, oChangeEntity.operation)) {
2007
- throw new Error("Operation " + oChangeEntity.operation + " is not supported. The supported 'operation' is " + aSupportedOperations.join("|"));
1979
+ if (!aSupportedOperations.includes(oChangeEntity.operation)) {
1980
+ throw new Error(`Operation ${oChangeEntity.operation} is not supported. The supported 'operation' is ${aSupportedOperations.join("|")}`);
2008
1981
  }
2009
1982
  }
2010
- function checkEntityPropertyChange(oChange, aSupportedProperties, aSupportedOperations) {
2011
- var id = Object.keys(oChange).filter(function (key) {
2012
- return key.endsWith("Id");
1983
+ function checkEntityPropertyChange(oChange, aSupportedProperties, aSupportedOperations, oSupportedPropertyPattern) {
1984
+ var sId = Object.keys(oChange).filter(function (sKey) {
1985
+ return sKey.endsWith("Id");
2013
1986
  }).shift();
2014
- if (!oChange[id]) {
2015
- throw new Error("Mandatory \"" + id + "\" parameter is not provided.");
1987
+ if (!oChange[sId]) {
1988
+ throw new Error(`Mandatory "${sId}" parameter is not provided.`);
2016
1989
  }
2017
1990
  if (!oChange.entityPropertyChange) {
2018
- throw new Error("Changes for \"" + oChange[id] + "\" are not provided.");
1991
+ throw new Error(`Changes for "${oChange[sId]}" are not provided.`);
2019
1992
  }
2020
- checkChange(oChange.entityPropertyChange, aSupportedProperties, aSupportedOperations);
1993
+ checkChange(oChange.entityPropertyChange, aSupportedProperties, aSupportedOperations, oSupportedPropertyPattern);
2021
1994
  }
2022
1995
  var layer_prefixes = {};
2023
1996
  layer_prefixes[Layer.CUSTOMER] = "customer.";
@@ -2033,41 +2006,50 @@ function checkIdNamespaceCompliance(sId, oChange) {
2033
2006
  if (sPrefix === null) {
2034
2007
  Object.keys(layer_prefixes).forEach(function (sKey) {
2035
2008
  if (layer_prefixes[sKey] && sId.startsWith(layer_prefixes[sKey])) {
2036
- throw new Error("Id " + sId + " must not start with reserved " + layer_prefixes[sKey]);
2009
+ throw new Error(`Id ${sId} must not start with reserved ${layer_prefixes[sKey]}`);
2037
2010
  }
2038
2011
  });
2039
2012
  } else if (!sId.startsWith(sPrefix)) {
2040
- throw new Error("Id " + sId + " must start with " + sPrefix);
2013
+ throw new Error(`Id ${sId} must start with ${sPrefix}`);
2041
2014
  }
2042
2015
  }
2043
2016
  function getNamespacePrefixForLayer(sLayer) {
2044
2017
  var sPrefix = layer_prefixes[sLayer];
2045
2018
  if (sPrefix === undefined) {
2046
- throw new Error("Layer " + sLayer + " not supported.");
2019
+ throw new Error(`Layer ${sLayer} not supported.`);
2047
2020
  }
2048
2021
  return sPrefix;
2049
2022
  }
2023
+ function checkPropertyValuePattern(oChange, oSupportedPattern) {
2024
+ if (!Object.keys(oSupportedPattern).includes(oChange.propertyPath)) {
2025
+ return;
2026
+ }
2027
+ if (!oChange.propertyValue.match(oSupportedPattern[oChange.propertyPath])) {
2028
+ throw new Error(`Not supported format for propertyPath ${oChange.propertyPath}. ` + `The supported pattern is ${oSupportedPattern[oChange.propertyPath]}`);
2029
+ }
2030
+ }
2050
2031
  var DescriptorChangeCheck = {
2051
- checkEntityPropertyChange: checkEntityPropertyChange,
2052
- checkIdNamespaceCompliance: checkIdNamespaceCompliance,
2053
- getNamespacePrefixForLayer: getNamespacePrefixForLayer,
2054
- getClearedGenericPath: getClearedGenericPath,
2055
- isGenericPropertyPathSupported: isGenericPropertyPathSupported
2032
+ checkEntityPropertyChange,
2033
+ checkIdNamespaceCompliance,
2034
+ getNamespacePrefixForLayer,
2035
+ getClearedGenericPath,
2036
+ isGenericPropertyPathSupported
2056
2037
  };
2057
2038
 
2058
2039
  var SUPPORTED_OPERATIONS$1 = ["UPDATE", "UPSERT"];
2059
2040
  var SUPPORTED_PROPERTIES$1 = ["uri", "settings/maxAge"];
2041
+ var PROPERTIES_PATTERNS$1 = {};
2060
2042
  var ChangeDataSource = {
2061
- applyChange: function (oManifest, oChange) {
2043
+ applyChange(oManifest, oChange) {
2062
2044
  var oDataSources = oManifest["sap.app"].dataSources;
2063
2045
  var oChangeContent = oChange.getContent();
2064
- DescriptorChangeCheck.checkEntityPropertyChange(oChangeContent, SUPPORTED_PROPERTIES$1, SUPPORTED_OPERATIONS$1);
2046
+ DescriptorChangeCheck.checkEntityPropertyChange(oChangeContent, SUPPORTED_PROPERTIES$1, SUPPORTED_OPERATIONS$1, PROPERTIES_PATTERNS$1);
2065
2047
  if (oDataSources) {
2066
2048
  var oDataSource = oDataSources[oChangeContent.dataSourceId];
2067
2049
  if (oDataSource) {
2068
2050
  changePropertyValueByPath(oChangeContent.entityPropertyChange, oDataSource);
2069
2051
  } else {
2070
- throw new Error("Nothing to update. DataSource with ID \"" + oChangeContent.dataSourceId + "\" does not exist.");
2052
+ throw new Error(`Nothing to update. DataSource with ID "${oChangeContent.dataSourceId}" does not exist.`);
2071
2053
  }
2072
2054
  } else {
2073
2055
  throw Error("No sap.app/dataSource found in manifest.json");
@@ -2077,7 +2059,7 @@ var ChangeDataSource = {
2077
2059
  };
2078
2060
 
2079
2061
  var AddNewModelEnhanceWith = {
2080
- applyChange: function (oManifest, oChange) {
2062
+ applyChange(oManifest, oChange) {
2081
2063
  var sModelId = oChange.getContent().modelId;
2082
2064
  var sI18N = ApplyUtil.formatBundleName(oManifest["sap.app"].id, oChange.getTexts().i18n);
2083
2065
  var oModel = oManifest["sap.ui5"].models[sModelId];
@@ -2098,15 +2080,13 @@ var AddNewModelEnhanceWith = {
2098
2080
  };
2099
2081
 
2100
2082
  var AddComponentUsages = {
2101
- applyChange: function (oManifest, oChange) {
2083
+ applyChange(oManifest, oChange) {
2102
2084
  var oChangeComponentUsages = oChange.getContent().componentUsages;
2103
- if (!oManifest["sap.ui5"]["componentUsages"]) {
2104
- oManifest["sap.ui5"]["componentUsages"] = {};
2105
- }
2085
+ oManifest["sap.ui5"].componentUsages ||= {};
2106
2086
  var oManifestComponentUsages = oManifest["sap.ui5"].componentUsages;
2107
2087
  Object.keys(oChangeComponentUsages).forEach(function (sComponentUsageName) {
2108
2088
  if (oManifestComponentUsages[sComponentUsageName]) {
2109
- throw new Error("Component usage '" + sComponentUsageName + "' already exists");
2089
+ throw new Error(`Component usage '${sComponentUsageName}' already exists`);
2110
2090
  } else {
2111
2091
  oManifestComponentUsages[sComponentUsageName] = oChangeComponentUsages[sComponentUsageName];
2112
2092
  }
@@ -2165,7 +2145,7 @@ Version.prototype.inRange = function (vMin, vMax) {
2165
2145
  };
2166
2146
 
2167
2147
  var SetMinUI5Version = {
2168
- applyChange: function (oManifest, oChange) {
2148
+ applyChange(oManifest, oChange) {
2169
2149
  var vCurrentVersion = new Version(oManifest["sap.ui5"].dependencies.minUI5Version);
2170
2150
  if (vCurrentVersion.compareTo(oChange.getContent().minUI5Version) <= 0) {
2171
2151
  oManifest["sap.ui5"].dependencies.minUI5Version = oChange.getContent().minUI5Version;
@@ -2175,14 +2155,14 @@ var SetMinUI5Version = {
2175
2155
  };
2176
2156
 
2177
2157
  var SetRegistrationIds = {
2178
- applyChange: function (oManifest, oChange) {
2158
+ applyChange(oManifest, oChange) {
2179
2159
  ObjectPath.set(["sap.fiori", "registrationIds"], oChange.getContent().registrationIds, oManifest);
2180
2160
  return oManifest;
2181
2161
  }
2182
2162
  };
2183
2163
 
2184
2164
  var SetFlexExtensionPointEnabled = {
2185
- applyChange: function (oManifest, oChange) {
2165
+ applyChange(oManifest, oChange) {
2186
2166
  if (!oChange.getContent().flexExtensionPointEnabled) {
2187
2167
  throw new Error("No flexExtensionPointEnabled in change content provided");
2188
2168
  }
@@ -2194,11 +2174,11 @@ var SetFlexExtensionPointEnabled = {
2194
2174
  var SUPPORTED_MODEL_DATASOURCE_TYPES = ["OData", "INA", "XML", "JSON", "FHIR", "http", "WebSocket"];
2195
2175
  var SUPPORTED_DATASOURCE_TYPES = SUPPORTED_MODEL_DATASOURCE_TYPES.concat(["ODataAnnotation"]);
2196
2176
  function isDataSourceTypeSupported(oChangeDataSource, sDataSource, aSupportedTypes) {
2197
- return !oChangeDataSource[sDataSource].type || aSupportedTypes.indexOf(oChangeDataSource[sDataSource]["type"]) >= 0;
2177
+ return !oChangeDataSource[sDataSource].type || aSupportedTypes.indexOf(oChangeDataSource[sDataSource].type) >= 0;
2198
2178
  }
2199
2179
  function isODataDefinedForODataAnnotation(oChangeDataSources, sODataAnnotationName) {
2200
2180
  return getObjectAsArray(oChangeDataSources).some(function (oDataSource) {
2201
- return (!oDataSource.type || oDataSource["type"] === "OData") && oDataSource["settings"]["annotations"].indexOf(sODataAnnotationName) >= 0;
2181
+ return (!oDataSource.type || oDataSource.type === "OData") && oDataSource.settings.annotations.indexOf(sODataAnnotationName) >= 0;
2202
2182
  });
2203
2183
  }
2204
2184
  function isReferencedModelDataSourceExisting(oManifestDataSource, oChangeDataSource, sDataSource) {
@@ -2209,8 +2189,8 @@ function isExistingAndSupported(oDataSources, sDataSource, aSupportedTypes) {
2209
2189
  }
2210
2190
  function isDataSourceExistingInManifest(oDataSources, sDataSource) {
2211
2191
  if (hasSearchType(oDataSources, sDataSource)) {
2212
- if (oDataSources[sDataSource].type && oDataSources[sDataSource]["type"] === "ODataAnnotation") {
2213
- throw new Error("The already existing dataSource '" + sDataSource + "' in the manifest is type of 'ODataAnnotation'. A model must not reference to a dataSource which is of type 'ODataAnnotation'");
2192
+ if (oDataSources[sDataSource].type && oDataSources[sDataSource].type === "ODataAnnotation") {
2193
+ throw new Error(`The already existing dataSource '${sDataSource}' in the manifest is type of 'ODataAnnotation'. A model must not reference to a dataSource which is of type 'ODataAnnotation'`);
2214
2194
  }
2215
2195
  return true;
2216
2196
  }
@@ -2223,16 +2203,14 @@ function mergeChange(oManifestContent, oChangeContent, sErrorMessage) {
2223
2203
  if (oChangeContent) {
2224
2204
  Object.keys(oChangeContent).forEach(function (sNewModelName) {
2225
2205
  if (oManifestContent[sNewModelName]) {
2226
- throw new Error("The " + sErrorMessage + " '" + sNewModelName + "' already exists");
2206
+ throw new Error(`The ${sErrorMessage} '${sNewModelName}' already exists`);
2227
2207
  }
2228
2208
  oManifestContent[sNewModelName] = oChangeContent[sNewModelName];
2229
2209
  });
2230
2210
  }
2231
2211
  }
2232
2212
  function merge$2(oManifest, oChange, sRootPath, sChildPath, sModelPath) {
2233
- if (!oManifest[sRootPath][sChildPath]) {
2234
- oManifest[sRootPath][sChildPath] = {};
2235
- }
2213
+ oManifest[sRootPath][sChildPath] ||= {};
2236
2214
  mergeChange(oManifest[sRootPath][sChildPath], oChange.getContent()[sModelPath], sModelPath);
2237
2215
  return oManifest[sRootPath][sChildPath];
2238
2216
  }
@@ -2241,7 +2219,7 @@ function isChangeDataSourceUsedByChangeModel(oChangeDataSource, oChangeModel, sD
2241
2219
  return true;
2242
2220
  }
2243
2221
  return getObjectAsArray(oChangeModel).some(function (oModel) {
2244
- return oModel.dataSource && oModel["dataSource"] === sDataSource;
2222
+ return oModel.dataSource && oModel.dataSource === sDataSource;
2245
2223
  });
2246
2224
  }
2247
2225
  function hasModelPropertyTypOrDataSource(oChangeModel, sModel) {
@@ -2253,20 +2231,20 @@ function getObjectAsArray(oObject) {
2253
2231
  });
2254
2232
  }
2255
2233
  var AddNewModel = {
2256
- applyChange: function (oManifest, oChange) {
2234
+ applyChange(oManifest, oChange) {
2257
2235
  var oChangeModel = oChange.getContent().model;
2258
2236
  var oChangeDataSource = oChange.getContent().dataSource;
2259
2237
  if (oChangeModel) {
2260
2238
  if (Object.keys(oChangeModel).length !== 1) {
2261
- throw new Error("There are currently '" + Object.keys(oChangeModel).length + "' models in the change. Currently it is only allowed to add '1' model");
2239
+ throw new Error(`There are currently '${Object.keys(oChangeModel).length}' models in the change. Currently it is only allowed to add '1' model`);
2262
2240
  }
2263
2241
  Object.keys(oChangeModel).forEach(function (sModel) {
2264
2242
  if (!hasModelPropertyTypOrDataSource(oChangeModel, sModel)) {
2265
- throw new Error("There is no 'dataSource' or 'type' in the change model defined. Please define either 'type' or 'dataSource' in property '" + sModel + "'");
2243
+ throw new Error(`There is no 'dataSource' or 'type' in the change model defined. Please define either 'type' or 'dataSource' in property '${sModel}'`);
2266
2244
  }
2267
2245
  if (oChangeModel[sModel].dataSource) {
2268
- if (!isReferencedModelDataSourceExisting(oManifest["sap.app"]["dataSources"], oChangeDataSource, oChangeModel[sModel]["dataSource"])) {
2269
- throw new Error("The defined dataSource '" + oChangeModel[sModel]["dataSource"] + "' in the model does not exists as dataSource or must be allowed type of " + SUPPORTED_MODEL_DATASOURCE_TYPES.join("|"));
2246
+ if (!isReferencedModelDataSourceExisting(oManifest["sap.app"].dataSources, oChangeDataSource, oChangeModel[sModel].dataSource)) {
2247
+ throw new Error(`The defined dataSource '${oChangeModel[sModel].dataSource}' in the model does not exists as dataSource or must be allowed type of ${SUPPORTED_MODEL_DATASOURCE_TYPES.join("|")}`);
2270
2248
  }
2271
2249
  }
2272
2250
  });
@@ -2276,14 +2254,14 @@ var AddNewModel = {
2276
2254
  if (oChangeDataSource) {
2277
2255
  Object.keys(oChangeDataSource).forEach(function (sDataSource) {
2278
2256
  if (!isDataSourceTypeSupported(oChangeDataSource, sDataSource, SUPPORTED_DATASOURCE_TYPES)) {
2279
- throw new Error("The dataSource '" + sDataSource + "' has the type '" + oChangeDataSource[sDataSource]["type"] + "', but only dataSources with the follwing types are supported: " + SUPPORTED_DATASOURCE_TYPES.join("|"));
2257
+ throw new Error(`The dataSource '${sDataSource}' has the type '${oChangeDataSource[sDataSource].type}', but only dataSources with the follwing types are supported: ${SUPPORTED_DATASOURCE_TYPES.join("|")}`);
2280
2258
  }
2281
2259
  if (!isChangeDataSourceUsedByChangeModel(oChangeDataSource, oChangeModel, sDataSource)) {
2282
- throw new Error("The dataSource in the change '" + sDataSource + "' is not used by any model in the change. A dataSource in the change must be used by model in the change");
2260
+ throw new Error(`The dataSource in the change '${sDataSource}' is not used by any model in the change. A dataSource in the change must be used by model in the change`);
2283
2261
  }
2284
- if (oChangeDataSource[sDataSource]["type"] === "ODataAnnotation") {
2262
+ if (oChangeDataSource[sDataSource].type === "ODataAnnotation") {
2285
2263
  if (!isODataDefinedForODataAnnotation(oChangeDataSource, sDataSource)) {
2286
- throw new Error("There is no dataSource with type 'OData' defined which includes the annotation '" + sDataSource + "'");
2264
+ throw new Error(`There is no dataSource with type 'OData' defined which includes the annotation '${sDataSource}'`);
2287
2265
  }
2288
2266
  }
2289
2267
  });
@@ -2314,10 +2292,10 @@ function checkingDataSourceId(oManifestDataSources, sChangeDataSourceId) {
2314
2292
  if (sChangeDataSourceId) {
2315
2293
  if (Object.keys(oManifestDataSources).length > 0) {
2316
2294
  if (!isDataSourceIdExistingInManifest(oManifestDataSources, sChangeDataSourceId)) {
2317
- throw new Error("There is no dataSource '" + sChangeDataSourceId + "' existing in the manifest. You can only add annotations to already existing dataSources in the manifest");
2295
+ throw new Error(`There is no dataSource '${sChangeDataSourceId}' existing in the manifest. You can only add annotations to already existing dataSources in the manifest`);
2318
2296
  }
2319
2297
  if (!isDataSourceTypeOData(oManifestDataSources, sChangeDataSourceId)) {
2320
- throw new Error("The dataSource '" + sChangeDataSourceId + "' is existing in the manifest but is not type of 'OData'. The type of the dataSource in the manifest is '" + oManifestDataSources[sChangeDataSourceId].type + "'");
2298
+ throw new Error(`The dataSource '${sChangeDataSourceId}' is existing in the manifest but is not type of 'OData'. The type of the dataSource in the manifest is '${oManifestDataSources[sChangeDataSourceId].type}'`);
2321
2299
  }
2322
2300
  } else {
2323
2301
  throw new Error("There are no dataSources in the manifest at all");
@@ -2337,7 +2315,7 @@ function checkingAnnotationArray(aChangeAnnotations) {
2337
2315
  }
2338
2316
  function checkingAnnotationsInsertPosition(sChangeAnnotationsInsertPosition) {
2339
2317
  if (!(SUPPORTED_INSERT_POSITION.indexOf(sChangeAnnotationsInsertPosition) >= 0) && !(sChangeAnnotationsInsertPosition === undefined)) {
2340
- throw new Error("The defined insert position '" + sChangeAnnotationsInsertPosition + "' is not supported. The supported insert positions are: " + SUPPORTED_INSERT_POSITION.join("|"));
2318
+ throw new Error(`The defined insert position '${sChangeAnnotationsInsertPosition}' is not supported. The supported insert positions are: ${SUPPORTED_INSERT_POSITION.join("|")}`);
2341
2319
  }
2342
2320
  }
2343
2321
  function checkingAnnotationDataSource(oChangeDataSource, aChangeAnnotations, oChange) {
@@ -2348,10 +2326,10 @@ function checkingAnnotationDataSource(oChangeDataSource, aChangeAnnotations, oCh
2348
2326
  Object.keys(oChangeDataSource).forEach(function (sAnnotation) {
2349
2327
  DescriptorChangeCheck.checkIdNamespaceCompliance(sAnnotation, oChange);
2350
2328
  if (!isAnnotationTypeOfOdataAnnotation(oChangeDataSource, sAnnotation)) {
2351
- throw new Error("The dataSource annotation '" + sAnnotation + "' is type of '" + oChangeDataSource[sAnnotation].type + "'. Only dataSource annotations of type 'ODataAnnotation' is supported");
2329
+ throw new Error(`The dataSource annotation '${sAnnotation}' is type of '${oChangeDataSource[sAnnotation].type}'. Only dataSource annotations of type 'ODataAnnotation' is supported`);
2352
2330
  }
2353
2331
  if (!isAnnotationPartOfAnnotationsArray(aChangeAnnotations, sAnnotation)) {
2354
- throw new Error("The annotation '" + sAnnotation + "' is not part of 'annotations' array property. Please add the annotation '" + sAnnotation + "' in the 'annotations' array property");
2332
+ throw new Error(`The annotation '${sAnnotation}' is not part of 'annotations' array property. Please add the annotation '${sAnnotation}' in the 'annotations' array property`);
2355
2333
  }
2356
2334
  });
2357
2335
  } else {
@@ -2363,20 +2341,16 @@ function merge$1(oManifestDataSources, sChangeDataSourceId, aChangeAnnotations,
2363
2341
  mergeAnnotationDataSources(oManifestDataSources, oChangeDataSource);
2364
2342
  }
2365
2343
  function mergeAnnotationArray(oManifestDataSourceId, aChangeAnnotations, sChangeAnnotationsInsertPosition) {
2366
- if (!oManifestDataSourceId["settings"]) {
2367
- oManifestDataSourceId["settings"] = {};
2368
- }
2369
- if (!oManifestDataSourceId["settings"].annotations) {
2370
- oManifestDataSourceId["settings"].annotations = [];
2371
- }
2372
- var aNotExistingAnnotationsInChange = oManifestDataSourceId["settings"].annotations.filter(function (annotation) {
2344
+ oManifestDataSourceId.settings ||= {};
2345
+ oManifestDataSourceId.settings.annotations ||= [];
2346
+ var aNotExistingAnnotationsInChange = oManifestDataSourceId.settings.annotations.filter(function (annotation) {
2373
2347
  return aChangeAnnotations.indexOf(annotation) < 0;
2374
2348
  });
2375
- oManifestDataSourceId["settings"].annotations = aNotExistingAnnotationsInChange;
2349
+ oManifestDataSourceId.settings.annotations = aNotExistingAnnotationsInChange;
2376
2350
  if (sChangeAnnotationsInsertPosition === "END") {
2377
- oManifestDataSourceId["settings"].annotations = oManifestDataSourceId["settings"].annotations.concat(aChangeAnnotations);
2351
+ oManifestDataSourceId.settings.annotations = oManifestDataSourceId.settings.annotations.concat(aChangeAnnotations);
2378
2352
  } else {
2379
- oManifestDataSourceId["settings"].annotations = aChangeAnnotations.concat(oManifestDataSourceId["settings"].annotations);
2353
+ oManifestDataSourceId.settings.annotations = aChangeAnnotations.concat(oManifestDataSourceId.settings.annotations);
2380
2354
  }
2381
2355
  }
2382
2356
  function mergeAnnotationDataSources(oManifestDataSources, oChangeDataSource) {
@@ -2385,12 +2359,12 @@ function mergeAnnotationDataSources(oManifestDataSources, oChangeDataSource) {
2385
2359
  function postChecks(oManifestDataSources, oChangeDataSource, aChangeAnnotations) {
2386
2360
  aChangeAnnotations.forEach(function (sAnnotation) {
2387
2361
  if (!isAnnotationExisting(oManifestDataSources, oChangeDataSource, sAnnotation)) {
2388
- throw new Error("The annotation '" + sAnnotation + "' is part of 'annotations' array property but does not exists in the change property 'dataSource' and in the manifest (or it is not type of 'ODataAnnotation' in the manifest)");
2362
+ throw new Error(`The annotation '${sAnnotation}' is part of 'annotations' array property but does not exists in the change property 'dataSource' and in the manifest (or it is not type of 'ODataAnnotation' in the manifest)`);
2389
2363
  }
2390
2364
  });
2391
2365
  }
2392
2366
  var AddAnnotationsToOData = {
2393
- applyChange: function (oManifest, oChange) {
2367
+ applyChange(oManifest, oChange) {
2394
2368
  var sChangeDataSourceId = oChange.getContent().dataSourceId;
2395
2369
  var aChangeAnnotations = oChange.getContent().annotations;
2396
2370
  var sChangeAnnotationsInsertPosition = oChange.getContent().annotationsInsertPosition;
@@ -2399,8 +2373,8 @@ var AddAnnotationsToOData = {
2399
2373
  checkingAnnotationArray(aChangeAnnotations);
2400
2374
  checkingAnnotationsInsertPosition(sChangeAnnotationsInsertPosition);
2401
2375
  checkingAnnotationDataSource(oChangeDataSource, aChangeAnnotations, oChange);
2402
- postChecks(oManifest["sap.app"]["dataSources"], oChangeDataSource, aChangeAnnotations);
2403
- merge$1(oManifest["sap.app"]["dataSources"], sChangeDataSourceId, aChangeAnnotations, sChangeAnnotationsInsertPosition, oChangeDataSource);
2376
+ postChecks(oManifest["sap.app"].dataSources, oChangeDataSource, aChangeAnnotations);
2377
+ merge$1(oManifest["sap.app"].dataSources, sChangeDataSourceId, aChangeAnnotations, sChangeAnnotationsInsertPosition, oChangeDataSource);
2404
2378
  return oManifest;
2405
2379
  }
2406
2380
  };
@@ -2409,12 +2383,12 @@ function checkManifestPath(oManifest) {
2409
2383
  if (!oManifest["sap.app"].hasOwnProperty("crossNavigation")) {
2410
2384
  throw new Error("No sap.app/crossNavigation path exists in the manifest");
2411
2385
  }
2412
- if (!oManifest["sap.app"]["crossNavigation"].hasOwnProperty("inbounds")) {
2386
+ if (!oManifest["sap.app"].crossNavigation.hasOwnProperty("inbounds")) {
2413
2387
  throw new Error("No sap.app/crossNavigation/inbounds path exists in the manifest");
2414
2388
  }
2415
2389
  }
2416
2390
  function getAndCheckInboundId$1(oChangeContent) {
2417
- var sInbounds = oChangeContent["inboundId"];
2391
+ var sInbounds = oChangeContent.inboundId;
2418
2392
  if (sInbounds === "") {
2419
2393
  throw new Error("The ID of your inbound is empty");
2420
2394
  }
@@ -2425,35 +2399,39 @@ function getAndCheckInboundId$1(oChangeContent) {
2425
2399
  }
2426
2400
  function merge(oManifest, sInboundId) {
2427
2401
  var oInbound = {};
2428
- oInbound[sInboundId] = oManifest["sap.app"]["crossNavigation"]["inbounds"][sInboundId];
2429
- oManifest["sap.app"]["crossNavigation"]["inbounds"] = oInbound;
2402
+ oInbound[sInboundId] = oManifest["sap.app"].crossNavigation.inbounds[sInboundId];
2403
+ oManifest["sap.app"].crossNavigation.inbounds = oInbound;
2430
2404
  }
2431
2405
  var RemoveAllInboundsExceptOne = {
2432
- applyChange: function (oManifest, oChange) {
2406
+ applyChange(oManifest, oChange) {
2433
2407
  checkManifestPath(oManifest);
2434
2408
  var sInboundId = getAndCheckInboundId$1(oChange.getContent());
2435
- if (oManifest["sap.app"]["crossNavigation"]["inbounds"][sInboundId]) {
2409
+ if (oManifest["sap.app"].crossNavigation.inbounds[sInboundId]) {
2436
2410
  merge(oManifest, sInboundId);
2437
2411
  } else {
2438
- throw new Error("No inbound exists with the ID \"" + sInboundId + "\" in sap.app/crossNavigation/inbounds");
2412
+ throw new Error(`No inbound exists with the ID "${sInboundId}" in sap.app/crossNavigation/inbounds`);
2439
2413
  }
2440
2414
  return oManifest;
2441
2415
  }
2442
2416
  };
2443
2417
 
2444
2418
  var SUPPORTED_OPERATIONS = ["UPDATE", "UPSERT"];
2445
- var SUPPORTED_PROPERTIES = ["title", "subTitle", "icon", "signature/parameters/*"];
2419
+ var SUPPORTED_PROPERTIES = ["semanticObject", "action", "title", "subTitle", "icon", "signature/parameters/*"];
2420
+ var PROPERTIES_PATTERNS = {
2421
+ semanticObject: "^[\\w\\*]{0,30}$",
2422
+ action: "^[\\w\\*]{0,60}$"
2423
+ };
2446
2424
  var ChangeInbound = {
2447
- applyChange: function (oManifest, oChange) {
2425
+ applyChange(oManifest, oChange) {
2448
2426
  var oCrossNavigation = oManifest["sap.app"].crossNavigation;
2449
2427
  var oChangeContent = oChange.getContent();
2450
- DescriptorChangeCheck.checkEntityPropertyChange(oChangeContent, SUPPORTED_PROPERTIES, SUPPORTED_OPERATIONS);
2428
+ DescriptorChangeCheck.checkEntityPropertyChange(oChangeContent, SUPPORTED_PROPERTIES, SUPPORTED_OPERATIONS, PROPERTIES_PATTERNS);
2451
2429
  if (oCrossNavigation && oCrossNavigation.inbounds) {
2452
2430
  var oInbound = oCrossNavigation.inbounds[oChangeContent.inboundId];
2453
2431
  if (oInbound) {
2454
2432
  changePropertyValueByPath(oChangeContent.entityPropertyChange, oInbound);
2455
2433
  } else {
2456
- throw new Error("Nothing to update. Inbound with ID \"" + oChangeContent.inboundId + "\" does not exist.");
2434
+ throw new Error(`Nothing to update. Inbound with ID "${oChangeContent.inboundId}" does not exist.`);
2457
2435
  }
2458
2436
  } else {
2459
2437
  throw new Error("sap.app/crossNavigation or sap.app/crossNavigation/inbounds sections have not been found in manifest.json");
@@ -2463,7 +2441,7 @@ var ChangeInbound = {
2463
2441
  };
2464
2442
 
2465
2443
  function getAndCheckInboundId(oChangeContent) {
2466
- var aInbounds = Object.keys(oChangeContent["inbound"]);
2444
+ var aInbounds = Object.keys(oChangeContent.inbound);
2467
2445
  if (aInbounds.length > 1) {
2468
2446
  throw new Error("It is not allowed to add more than one inbound");
2469
2447
  }
@@ -2476,33 +2454,29 @@ function getAndCheckInboundId(oChangeContent) {
2476
2454
  return aInbounds[aInbounds.length - 1];
2477
2455
  }
2478
2456
  var AddNewInbound = {
2479
- applyChange: function (oManifest, oChange) {
2480
- if (!oManifest["sap.app"]["crossNavigation"]) {
2481
- oManifest["sap.app"]["crossNavigation"] = {};
2482
- }
2483
- if (!oManifest["sap.app"]["crossNavigation"]["inbounds"]) {
2484
- oManifest["sap.app"]["crossNavigation"]["inbounds"] = {};
2485
- }
2457
+ applyChange(oManifest, oChange) {
2458
+ oManifest["sap.app"].crossNavigation ||= {};
2459
+ oManifest["sap.app"].crossNavigation.inbounds ||= {};
2486
2460
  var oChangeContent = oChange.getContent();
2487
2461
  var sInboundId = getAndCheckInboundId(oChangeContent);
2488
- var oInboundInManifest = oManifest["sap.app"]["crossNavigation"]["inbounds"][sInboundId];
2462
+ var oInboundInManifest = oManifest["sap.app"].crossNavigation.inbounds[sInboundId];
2489
2463
  if (!oInboundInManifest) {
2490
2464
  DescriptorChangeCheck.checkIdNamespaceCompliance(sInboundId, oChange);
2491
- oManifest["sap.app"]["crossNavigation"]["inbounds"][sInboundId] = oChangeContent["inbound"][sInboundId];
2465
+ oManifest["sap.app"].crossNavigation.inbounds[sInboundId] = oChangeContent.inbound[sInboundId];
2492
2466
  } else {
2493
- throw new Error("Inbound with ID \"" + sInboundId + "\" already exist.");
2467
+ throw new Error(`Inbound with ID "${sInboundId}" already exist.`);
2494
2468
  }
2495
2469
  return oManifest;
2496
2470
  }
2497
2471
  };
2498
2472
 
2499
2473
  var SetAbstract = {
2500
- applyChange: function (oManifest, oChange) {
2474
+ applyChange(oManifest, oChange) {
2501
2475
  if (!oChange.getContent().hasOwnProperty("abstract")) {
2502
2476
  throw new Error("No abstract in change content provided");
2503
2477
  }
2504
2478
  if (oChange.getContent().abstract !== false) {
2505
- throw new Error("The current change value of property abstract is '" + oChange.getContent().abstract + "'. Only allowed value for property abstract is boolean 'false'");
2479
+ throw new Error(`The current change value of property abstract is '${oChange.getContent().abstract}'. Only allowed value for property abstract is boolean 'false'`);
2506
2480
  }
2507
2481
  ObjectPath.set(["sap.fiori", "abstract"], oChange.getContent().abstract, oManifest);
2508
2482
  return oManifest;
@@ -2521,11 +2495,9 @@ function _mergeExistingLibrary(oManifestLib, oChangeLib) {
2521
2495
  return oUpdatedLibrary;
2522
2496
  }
2523
2497
  var AddLibrary = {
2524
- applyChange: function (oManifest, oChange) {
2525
- if (!oManifest["sap.ui5"]["dependencies"]["libs"]) {
2526
- oManifest["sap.ui5"]["dependencies"]["libs"] = {};
2527
- }
2528
- var oManifestLibs = oManifest["sap.ui5"]["dependencies"]["libs"];
2498
+ applyChange(oManifest, oChange) {
2499
+ oManifest["sap.ui5"].dependencies.libs ||= {};
2500
+ var oManifestLibs = oManifest["sap.ui5"].dependencies.libs;
2529
2501
  var oChangeLibs = oChange.getContent().libraries;
2530
2502
  Object.keys(oChangeLibs).forEach(function (sLibName) {
2531
2503
  if (oManifestLibs[sLibName]) {
@@ -2539,14 +2511,14 @@ var AddLibrary = {
2539
2511
  };
2540
2512
 
2541
2513
  var SetTitle = {
2542
- applyChange: function (oManifest) {
2543
- oManifest["sap.app"].title = "{{" + oManifest["sap.app"].id + "_sap.app.title}}";
2514
+ applyChange(oManifest) {
2515
+ oManifest["sap.app"].title = `{{${oManifest["sap.app"].id}_sap.app.title}}`;
2544
2516
  return oManifest;
2545
2517
  }
2546
2518
  };
2547
2519
 
2548
2520
  var ChangeCard = {
2549
- applyChange: function (oManifest, oChange) {
2521
+ applyChange(oManifest, oChange) {
2550
2522
  var oChangedCard = oChange.getContent();
2551
2523
  var bIsOperationValid = oChangedCard.entityPropertyChange.operation === "UPSERT";
2552
2524
  var oOldCards = oManifest["sap.ovp"].cards;
@@ -2567,7 +2539,7 @@ var ChangeCard = {
2567
2539
  };
2568
2540
 
2569
2541
  var AddNewCard = {
2570
- applyChange: function (oManifest, oChange) {
2542
+ applyChange(oManifest, oChange) {
2571
2543
  var oNewCard = oChange.getContent();
2572
2544
  var oOldCards = oManifest["sap.ovp"].cards;
2573
2545
  if (("card" in oNewCard) && Object.keys(oNewCard.card).length > 0 && !((Object.keys(oNewCard.card) in oOldCards))) {
@@ -2580,7 +2552,7 @@ var AddNewCard = {
2580
2552
  };
2581
2553
 
2582
2554
  var DeleteCard = {
2583
- applyChange: function (oManifest, oChange) {
2555
+ applyChange(oManifest, oChange) {
2584
2556
  var oDeleteCard = oChange.getContent();
2585
2557
  var oOldCards = oManifest["sap.ovp"].cards;
2586
2558
  if ((oDeleteCard.cardId in oOldCards)) {
@@ -2599,12 +2571,20 @@ var fnAssert = function (bResult, vMessage) {
2599
2571
  }
2600
2572
  };
2601
2573
 
2602
- var fnNow = !(typeof window != "undefined" && window.performance && performance.now && performance.timing) ? Date.now : (function () {
2603
- var iNavigationStart = performance.timing.navigationStart;
2604
- return function perfnow() {
2605
- return iNavigationStart + performance.now();
2606
- };
2607
- })();
2574
+ class config {
2575
+ static get Type() {
2576
+ return {
2577
+ String: "string"
2578
+ };
2579
+ }
2580
+ static get({name}) {
2581
+ return name === "sapUiLogLevel" ? "Error" : undefined;
2582
+ }
2583
+ }
2584
+
2585
+ var fnNow = function now() {
2586
+ return performance.timeOrigin + performance.now();
2587
+ };
2608
2588
 
2609
2589
  var Log = {};
2610
2590
  Log.Level = {
@@ -2846,6 +2826,17 @@ Log.getLogger = function (sComponent, iDefaultLogLevel) {
2846
2826
  }
2847
2827
  return new Logger(sComponent);
2848
2828
  };
2829
+ const sLogLevel = config.get({
2830
+ name: "sapUiLogLevel",
2831
+ type: config.Type.String,
2832
+ defaultValue: undefined,
2833
+ external: true
2834
+ });
2835
+ if (sLogLevel) {
2836
+ Log.setLevel(Log.Level[sLogLevel.toUpperCase()] || parseInt(sLogLevel));
2837
+ } else if (!globalThis["sap-ui-optimized"]) {
2838
+ Log.setLevel(Log.Level.DEBUG);
2839
+ }
2849
2840
 
2850
2841
  var fnUniqueSort = function (aArray) {
2851
2842
  fnAssert(Array.isArray(aArray), "uniqueSort: input parameter must be an Array");
@@ -2871,13 +2862,16 @@ function isFunction(obj) {
2871
2862
  var Metadata = function (sClassName, oClassInfo) {
2872
2863
  fnAssert(typeof sClassName === "string" && sClassName, "Metadata: sClassName must be a non-empty string");
2873
2864
  fnAssert(typeof oClassInfo === "object", "Metadata: oClassInfo must be empty or an object");
2874
- if (!oClassInfo || typeof oClassInfo.metadata !== "object") {
2875
- oClassInfo = {
2876
- metadata: oClassInfo || ({}),
2877
- constructor: ObjectPath.get(sClassName)
2878
- };
2879
- oClassInfo.metadata.__version = 1;
2880
- }
2865
+ (() => {
2866
+ if (!oClassInfo || typeof oClassInfo.metadata !== "object") {
2867
+ oClassInfo = {
2868
+ metadata: oClassInfo || ({}),
2869
+ constructor: ObjectPath.get(sClassName)
2870
+ };
2871
+ oClassInfo.metadata.__version = 1;
2872
+ }
2873
+ })();
2874
+ oClassInfo.metadata ??= {};
2881
2875
  oClassInfo.metadata.__version = oClassInfo.metadata.__version || 2;
2882
2876
  if (!isFunction(oClassInfo.constructor)) {
2883
2877
  throw Error("constructor for class " + sClassName + " must have been declared before creating metadata for it");
@@ -2893,13 +2887,14 @@ Metadata.prototype.extend = function (oClassInfo) {
2893
2887
  Metadata.prototype.applySettings = function (oClassInfo) {
2894
2888
  var that = this, oStaticInfo = oClassInfo.metadata, oPrototype;
2895
2889
  if (oStaticInfo.baseType) {
2896
- var oParentClass;
2897
- if (isFunction(oStaticInfo.baseType)) {
2890
+ var oParentClass, bValidBaseType = isFunction(oStaticInfo.baseType);
2891
+ if (bValidBaseType) {
2898
2892
  oParentClass = oStaticInfo.baseType;
2899
2893
  if (!isFunction(oParentClass.getMetadata)) {
2900
2894
  throw new TypeError("baseType must be a UI5 class with a static getMetadata function");
2901
2895
  }
2902
- } else {
2896
+ }
2897
+ if (!bValidBaseType) {
2903
2898
  oParentClass = ObjectPath.get(oStaticInfo.baseType);
2904
2899
  if (!isFunction(oParentClass)) {
2905
2900
  Log.fatal("base class '" + oStaticInfo.baseType + "' does not exist");
@@ -3125,6 +3120,9 @@ BaseObject.prototype.isA = function (vTypeName) {
3125
3120
  BaseObject.isA = function (oObject, vTypeName) {
3126
3121
  return oObject instanceof BaseObject && oObject.isA(vTypeName);
3127
3122
  };
3123
+ BaseObject.isObjectA = function (oObject, vTypeName) {
3124
+ return oObject instanceof BaseObject && oObject.isA(vTypeName);
3125
+ };
3128
3126
  BaseObject._Interface = function (oObject, aMethods, _bReturnFacade) {
3129
3127
  if (!oObject) {
3130
3128
  return oObject;
@@ -3170,7 +3168,7 @@ var fnIsPlainObject = function (obj) {
3170
3168
  };
3171
3169
 
3172
3170
  var oToken = Object.create(null);
3173
- var fnMerge = function () {
3171
+ var fnMerge$1 = function () {
3174
3172
  var src, copyIsArray, copy, name, options, clone, target = arguments[2] || ({}), i = 3, length = arguments.length, deep = arguments[0] || false, skipToken = arguments[1] ? undefined : oToken;
3175
3173
  if (typeof target !== "object" && typeof target !== "function") {
3176
3174
  target = {};
@@ -3190,7 +3188,7 @@ var fnMerge = function () {
3190
3188
  } else {
3191
3189
  clone = src && fnIsPlainObject(src) ? src : {};
3192
3190
  }
3193
- target[name] = fnMerge(deep, arguments[1], clone, copy);
3191
+ target[name] = fnMerge$1(deep, arguments[1], clone, copy);
3194
3192
  } else if (copy !== skipToken) {
3195
3193
  target[name] = copy;
3196
3194
  }
@@ -3203,7 +3201,7 @@ var fnMerge = function () {
3203
3201
  var fnExtend = function () {
3204
3202
  var args = [false, true];
3205
3203
  args.push.apply(args, arguments);
3206
- return fnMerge.apply(null, args);
3204
+ return fnMerge$1.apply(null, args);
3207
3205
  };
3208
3206
 
3209
3207
  var sFioriComponent = "FioriElements: ";
@@ -3284,12 +3282,12 @@ var mergerUtil = {
3284
3282
  }
3285
3283
  var aChildkeys = Object.keys(oChangeContent.childPage.definition);
3286
3284
  aChildkeys.forEach(function (sKey) {
3287
- if (!fnIncludes(aSupportedProperties, sKey)) {
3285
+ if (!aSupportedProperties.includes(sKey)) {
3288
3286
  throw new Error("Changing " + sKey + " is not supported. The supported 'propertyPath' is: " + aSupportedProperties.join(","));
3289
3287
  }
3290
3288
  });
3291
3289
  var aMandatoryParams = aSupportedProperties.filter(function (sComponentKey) {
3292
- return !fnIncludes(aChildkeys, sComponentKey);
3290
+ return !aChildkeys.includes(sComponentKey);
3293
3291
  });
3294
3292
  if (aMandatoryParams.length) {
3295
3293
  throw new Error("Mandatory parameter " + aMandatoryParams + " is not defined.");
@@ -3370,76 +3368,76 @@ var changePageConfiguration = {
3370
3368
  }
3371
3369
  };
3372
3370
 
3373
- var o = {};
3374
- let e = {};
3375
- function i(n, o) {
3376
- const e = o.getContent();
3377
- const i = e === null || e === void 0 ? void 0 : e.page;
3378
- const a = e === null || e === void 0 ? void 0 : e.entityPropertyChange;
3379
- if ((a === null || a === void 0 ? void 0 : a.operation) !== "UPSERT" || !(a !== null && a !== void 0 && a.propertyPath) || (a === null || a === void 0 ? void 0 : a.propertyValue) === undefined || a !== null && a !== void 0 && a.propertyPath.startsWith("/")) {
3371
+ var _exports = {};
3372
+ let pageConfigurationChanges = {};
3373
+ function applyChange(manifest, change) {
3374
+ const changeContent = change.getContent();
3375
+ const pageId = changeContent === null || changeContent === void 0 ? void 0 : changeContent.page;
3376
+ const propertyChange = changeContent === null || changeContent === void 0 ? void 0 : changeContent.entityPropertyChange;
3377
+ if ((propertyChange === null || propertyChange === void 0 ? void 0 : propertyChange.operation) !== "UPSERT" || !(propertyChange !== null && propertyChange !== void 0 && propertyChange.propertyPath) || (propertyChange === null || propertyChange === void 0 ? void 0 : propertyChange.propertyValue) === undefined || propertyChange !== null && propertyChange !== void 0 && propertyChange.propertyPath.startsWith("/")) {
3380
3378
  Log.error("Change content is not a valid");
3381
- return n;
3379
+ return manifest;
3382
3380
  }
3383
- return r(n, i, a.propertyPath, a.propertyValue);
3381
+ return changeConfiguration(manifest, pageId, propertyChange.propertyPath, propertyChange.propertyValue);
3384
3382
  }
3385
- o.applyChange = i;
3386
- function r(o, i, r, l, u) {
3387
- const c = s(o, i);
3388
- if (c) {
3389
- const t = a(r);
3390
- ObjectPath.set(t, l, c);
3391
- if (u) {
3392
- e[i] = e[i] || [];
3393
- e[i].push(r);
3383
+ _exports.applyChange = applyChange;
3384
+ function changeConfiguration(manifest, pageId, path, value, lateChange) {
3385
+ const pageSettings = getPageSettings(manifest, pageId);
3386
+ if (pageSettings) {
3387
+ const propertyPath = retrievePropertyPath(path);
3388
+ ObjectPath.set(propertyPath, value, pageSettings);
3389
+ if (lateChange) {
3390
+ pageConfigurationChanges[pageId] = pageConfigurationChanges[pageId] || [];
3391
+ pageConfigurationChanges[pageId].push(path);
3394
3392
  }
3395
3393
  } else {
3396
- Log.error(`No Fiori elements page with ID ${i} found in routing targets.`);
3397
- }
3398
- return o;
3399
- }
3400
- o.changeConfiguration = r;
3401
- function a(t) {
3402
- let n = t.split("/");
3403
- if (n[0] === "controlConfiguration") {
3404
- let t = "";
3405
- for (let o = 1; o < n.length; o++) {
3406
- t += (o > 1 ? "/" : "") + n[o];
3407
- if (t.indexOf("@") > -1) {
3408
- n = ["controlConfiguration", t].concat(n.slice(o + 1));
3394
+ Log.error(`No Fiori elements page with ID ${pageId} found in routing targets.`);
3395
+ }
3396
+ return manifest;
3397
+ }
3398
+ _exports.changeConfiguration = changeConfiguration;
3399
+ function retrievePropertyPath(path) {
3400
+ let propertyPath = path.split("/");
3401
+ if (propertyPath[0] === "controlConfiguration") {
3402
+ let annotationPath = "";
3403
+ for (let i = 1; i < propertyPath.length; i++) {
3404
+ annotationPath += (i > 1 ? "/" : "") + propertyPath[i];
3405
+ if (annotationPath.includes("@")) {
3406
+ propertyPath = ["controlConfiguration", annotationPath].concat(propertyPath.slice(i + 1));
3409
3407
  break;
3410
3408
  }
3411
3409
  }
3412
3410
  }
3413
- return n;
3411
+ return propertyPath;
3414
3412
  }
3415
- function s(t, n) {
3416
- var o, e;
3417
- let i;
3418
- const r = ((o = t["sap.ui5"]) === null || o === void 0 ? void 0 : (e = o.routing) === null || e === void 0 ? void 0 : e.targets) ?? ({});
3419
- for (const t in r) {
3420
- if (r[t].id === n && r[t].name.startsWith("sap.fe.templates.")) {
3421
- var a;
3422
- i = ((a = r[t].options) === null || a === void 0 ? void 0 : a.settings) ?? ({});
3413
+ function getPageSettings(manifest, pageId) {
3414
+ var _manifest$sapUi, _manifest$sapUi$routi;
3415
+ let pageSettings;
3416
+ const targets = ((_manifest$sapUi = manifest["sap.ui5"]) === null || _manifest$sapUi === void 0 ? void 0 : (_manifest$sapUi$routi = _manifest$sapUi.routing) === null || _manifest$sapUi$routi === void 0 ? void 0 : _manifest$sapUi$routi.targets) ?? ({});
3417
+ for (const p in targets) {
3418
+ if (targets[p].id === pageId && targets[p].name.startsWith("sap.fe.templates.")) {
3419
+ var _targets$p$options;
3420
+ pageSettings = ((_targets$p$options = targets[p].options) === null || _targets$p$options === void 0 ? void 0 : _targets$p$options.settings) ?? ({});
3423
3421
  break;
3424
3422
  }
3425
3423
  }
3426
- return i;
3424
+ return pageSettings;
3427
3425
  }
3428
- function l(t, o, i, r) {
3429
- o = o ?? ({});
3430
- const s = e[r] || [];
3431
- for (const e of s) {
3432
- const i = a(e);
3433
- const r = ObjectPath.get(i, t);
3434
- ObjectPath.set(i, r, o);
3435
- }
3436
- return o;
3426
+ function applyPageConfigurationChanges(manifest, viewData, appComponent, pageId) {
3427
+ viewData = viewData ?? ({});
3428
+ const pageChanges = pageConfigurationChanges[pageId] || [];
3429
+ for (const path of pageChanges) {
3430
+ const propertyPath = retrievePropertyPath(path);
3431
+ const manifestValue = ObjectPath.get(propertyPath, manifest);
3432
+ ObjectPath.set(propertyPath, manifestValue, viewData);
3433
+ }
3434
+ return viewData;
3437
3435
  }
3438
- o.applyPageConfigurationChanges = l;
3439
- function u() {
3440
- e = {};
3436
+ _exports.applyPageConfigurationChanges = applyPageConfigurationChanges;
3437
+ function cleanPageConfigurationChanges() {
3438
+ pageConfigurationChanges = {};
3441
3439
  }
3442
- o.cleanPageConfigurationChanges = u;
3440
+ _exports.cleanPageConfigurationChanges = cleanPageConfigurationChanges;
3443
3441
 
3444
3442
  var Registration = {
3445
3443
  appdescr_ui5_addLibraries: () => Promise.resolve(AddLibrary),
@@ -3449,7 +3447,7 @@ var Registration = {
3449
3447
  appdescr_ovp_removeCard: () => Promise.resolve(DeleteCard),
3450
3448
  appdescr_ui_generic_app_addNewObjectPage: () => Promise.resolve(addNewObjectPage),
3451
3449
  appdescr_ui_generic_app_changePageConfiguration: () => Promise.resolve(changePageConfiguration),
3452
- appdescr_fe_changePageConfiguration: () => Promise.resolve(o)
3450
+ appdescr_fe_changePageConfiguration: () => Promise.resolve(_exports)
3453
3451
  };
3454
3452
 
3455
3453
  var RegistrationBuild = {
@@ -3469,7 +3467,3486 @@ var RegistrationBuild = {
3469
3467
  var RegistrationCopy = Object.assign({}, Registration);
3470
3468
  var RegistrationBuild$1 = Object.assign(RegistrationCopy, RegistrationBuild);
3471
3469
 
3472
- exports.Applier = Applier;
3473
- exports.ApplyUtil = ApplyUtil;
3474
- exports.Change = Change;
3475
- exports.RegistrationBuild = RegistrationBuild$1;
3470
+ var fnEqual = function (a, b, maxDepth, contains, depth) {
3471
+ if (typeof maxDepth == "boolean") {
3472
+ contains = maxDepth;
3473
+ maxDepth = undefined;
3474
+ }
3475
+ if (!depth) {
3476
+ depth = 0;
3477
+ }
3478
+ if (!maxDepth) {
3479
+ maxDepth = 10;
3480
+ }
3481
+ if (depth > maxDepth) {
3482
+ Log.warning("deepEqual comparison exceeded maximum recursion depth of " + maxDepth + ". Treating values as unequal");
3483
+ return false;
3484
+ }
3485
+ if (a === b || Number.isNaN(a) && Number.isNaN(b)) {
3486
+ return true;
3487
+ }
3488
+ if (Array.isArray(a) && Array.isArray(b)) {
3489
+ if (!contains && a.length !== b.length) {
3490
+ return false;
3491
+ }
3492
+ if (a.length > b.length) {
3493
+ return false;
3494
+ }
3495
+ for (var i = 0; i < a.length; i++) {
3496
+ if (!fnEqual(a[i], b[i], maxDepth, contains, depth + 1)) {
3497
+ return false;
3498
+ }
3499
+ }
3500
+ return true;
3501
+ }
3502
+ if (typeof a == "object" && typeof b == "object") {
3503
+ if (!a || !b) {
3504
+ return false;
3505
+ }
3506
+ if (a.constructor !== b.constructor) {
3507
+ return false;
3508
+ }
3509
+ if (!contains && Object.keys(a).length !== Object.keys(b).length) {
3510
+ return false;
3511
+ }
3512
+ if (a instanceof Node) {
3513
+ return a.isEqualNode(b);
3514
+ }
3515
+ if (a instanceof Date) {
3516
+ return a.valueOf() === b.valueOf();
3517
+ }
3518
+ for (var i in a) {
3519
+ if (!fnEqual(a[i], b[i], maxDepth, contains, depth + 1)) {
3520
+ return false;
3521
+ }
3522
+ }
3523
+ return true;
3524
+ }
3525
+ return false;
3526
+ };
3527
+
3528
+ var fnMerge = function () {
3529
+ var args = [true, false];
3530
+ args.push.apply(args, arguments);
3531
+ return fnMerge$1.apply(null, args);
3532
+ };
3533
+
3534
+ var iIdCounter = 0;
3535
+ var fnUid = function uid() {
3536
+ return "id-" + new Date().valueOf() + "-" + iIdCounter++;
3537
+ };
3538
+
3539
+ var oResolved = new SyncPromise(function (resolve, reject) {
3540
+ resolve();
3541
+ }), oResolvedNull = new SyncPromise(function (resolve, reject) {
3542
+ resolve(null);
3543
+ });
3544
+ function call(fnThen, resolve, reject) {
3545
+ var bOnce;
3546
+ function rejectPromise(vReason) {
3547
+ if (!bOnce) {
3548
+ bOnce = true;
3549
+ reject(vReason);
3550
+ }
3551
+ }
3552
+ function resolvePromise(vResult) {
3553
+ if (!bOnce) {
3554
+ bOnce = true;
3555
+ resolve(vResult);
3556
+ }
3557
+ }
3558
+ try {
3559
+ fnThen(resolvePromise, rejectPromise);
3560
+ } catch (e) {
3561
+ rejectPromise(e);
3562
+ }
3563
+ }
3564
+ function hasThen(vValue) {
3565
+ return vValue && (typeof vValue === "function" || typeof vValue === "object") && ("then" in vValue);
3566
+ }
3567
+ function SyncPromise(fnExecutor) {
3568
+ var bCaught = false, iState, fnReject, fnResolve, vResult, that = this;
3569
+ function reject(vReason) {
3570
+ vResult = vReason;
3571
+ iState = -1;
3572
+ if (!bCaught && SyncPromise.listener) {
3573
+ SyncPromise.listener(that, false);
3574
+ }
3575
+ if (fnReject) {
3576
+ fnReject(vReason);
3577
+ fnReject = fnResolve = null;
3578
+ }
3579
+ }
3580
+ function resolve(vResult0) {
3581
+ var fnThen;
3582
+ if (vResult0 === that) {
3583
+ reject(new TypeError("A promise cannot be resolved with itself."));
3584
+ return;
3585
+ }
3586
+ if (vResult0 instanceof SyncPromise) {
3587
+ if (vResult0.isFulfilled()) {
3588
+ resolve(vResult0.getResult());
3589
+ return;
3590
+ } else if (vResult0.isRejected()) {
3591
+ vResult0.caught();
3592
+ reject(vResult0.getResult());
3593
+ return;
3594
+ } else {
3595
+ vResult0.caught();
3596
+ vResult0 = vResult0.getResult();
3597
+ }
3598
+ }
3599
+ iState = 0;
3600
+ vResult = vResult0;
3601
+ if (hasThen(vResult)) {
3602
+ try {
3603
+ fnThen = vResult.then;
3604
+ } catch (e) {
3605
+ reject(e);
3606
+ return;
3607
+ }
3608
+ if (typeof fnThen === "function") {
3609
+ call(fnThen.bind(vResult), resolve, reject);
3610
+ return;
3611
+ }
3612
+ }
3613
+ iState = 1;
3614
+ if (fnResolve) {
3615
+ fnResolve(vResult);
3616
+ fnReject = fnResolve = null;
3617
+ }
3618
+ }
3619
+ this.caught = function () {
3620
+ if (!bCaught) {
3621
+ bCaught = true;
3622
+ if (SyncPromise.listener && this.isRejected()) {
3623
+ SyncPromise.listener(this, true);
3624
+ }
3625
+ }
3626
+ };
3627
+ this.getResult = function () {
3628
+ return vResult;
3629
+ };
3630
+ this.isFulfilled = function () {
3631
+ return iState === 1;
3632
+ };
3633
+ this.isPending = function () {
3634
+ return !iState;
3635
+ };
3636
+ this.isRejected = function () {
3637
+ return iState === -1;
3638
+ };
3639
+ call(fnExecutor, resolve, reject);
3640
+ if (iState === undefined) {
3641
+ vResult = new Promise(function (resolve, reject) {
3642
+ fnResolve = resolve;
3643
+ fnReject = reject;
3644
+ });
3645
+ vResult.catch(function () {});
3646
+ }
3647
+ }
3648
+ SyncPromise.prototype.catch = function (fnOnRejected) {
3649
+ return this.then(undefined, fnOnRejected);
3650
+ };
3651
+ SyncPromise.prototype.finally = function (fnOnFinally) {
3652
+ if (typeof fnOnFinally === "function") {
3653
+ return this.then(function (vResult) {
3654
+ return SyncPromise.resolve(fnOnFinally()).then(function () {
3655
+ return vResult;
3656
+ }).unwrap();
3657
+ }, function (vReason) {
3658
+ return SyncPromise.resolve(fnOnFinally()).then(function () {
3659
+ throw vReason;
3660
+ }).unwrap();
3661
+ });
3662
+ }
3663
+ return this.then(fnOnFinally, fnOnFinally);
3664
+ };
3665
+ SyncPromise.prototype.then = function (fnOnFulfilled, fnOnRejected) {
3666
+ var fnCallback = this.isFulfilled() ? fnOnFulfilled : fnOnRejected, bCallbackIsFunction = typeof fnCallback === "function", bPending = this.isPending(), that = this;
3667
+ if (bPending || bCallbackIsFunction) {
3668
+ this.caught();
3669
+ }
3670
+ if (!bPending) {
3671
+ return bCallbackIsFunction ? new SyncPromise(function (resolve, reject) {
3672
+ resolve(fnCallback(that.getResult()));
3673
+ }) : this;
3674
+ }
3675
+ return SyncPromise.resolve(this.getResult().then(fnOnFulfilled, fnOnRejected));
3676
+ };
3677
+ SyncPromise.prototype.toString = function () {
3678
+ if (this.isPending()) {
3679
+ return "SyncPromise: pending";
3680
+ }
3681
+ return String(this.getResult());
3682
+ };
3683
+ SyncPromise.prototype.unwrap = function () {
3684
+ this.caught();
3685
+ if (this.isRejected()) {
3686
+ throw this.getResult();
3687
+ }
3688
+ return this.getResult();
3689
+ };
3690
+ SyncPromise.all = function (aValues) {
3691
+ return new SyncPromise(function (resolve, reject) {
3692
+ var bDone = false, iPending = 0;
3693
+ function checkFulfilled() {
3694
+ if (bDone && iPending === 0) {
3695
+ resolve(aValues);
3696
+ }
3697
+ }
3698
+ aValues = Array.prototype.slice.call(aValues);
3699
+ aValues.forEach(function (vValue, i) {
3700
+ if (vValue !== aValues[i + 1] && hasThen(vValue)) {
3701
+ iPending += 1;
3702
+ vValue.then(function (vResult0) {
3703
+ do {
3704
+ aValues[i] = vResult0;
3705
+ i -= 1;
3706
+ } while (i >= 0 && vValue === aValues[i]);
3707
+ iPending -= 1;
3708
+ checkFulfilled();
3709
+ }, function (vReason) {
3710
+ reject(vReason);
3711
+ });
3712
+ }
3713
+ });
3714
+ bDone = true;
3715
+ checkFulfilled();
3716
+ });
3717
+ };
3718
+ SyncPromise.isThenable = function (vValue) {
3719
+ try {
3720
+ return !!hasThen(vValue) && typeof vValue.then === "function";
3721
+ } catch (e) {
3722
+ return false;
3723
+ }
3724
+ };
3725
+ SyncPromise.reject = function (vReason) {
3726
+ return new SyncPromise(function (resolve, reject) {
3727
+ reject(vReason);
3728
+ });
3729
+ };
3730
+ SyncPromise.resolve = function (vResult) {
3731
+ if (vResult === undefined) {
3732
+ return oResolved;
3733
+ }
3734
+ if (vResult === null) {
3735
+ return oResolvedNull;
3736
+ }
3737
+ if (vResult instanceof SyncPromise) {
3738
+ return vResult;
3739
+ }
3740
+ return new SyncPromise(function (resolve, reject) {
3741
+ resolve(vResult);
3742
+ });
3743
+ };
3744
+
3745
+ var rAmpersand = /&/g, rApplicationGroupID = /^\w+$/, sClassName$2 = "sap.ui.model.odata.v4.lib._Helper", rEquals = /\=/g, rEscapedCloseBracket = /%29/g, rEscapedOpenBracket = /%28/g, rEscapedTick = /%27/g, rGroupID = /^(\$auto(\.\w+)?|\$direct|\w+)$/, rHash = /#/g, rNotMetaContext = /\([^/]*|\/-?\d+/g, rPlus = /\+/g, rSingleQuote = /'/g, rSingleQuoteTwice = /''/g, rWhitespace = /\s+/g, _Helper;
3746
+ function preserveKeyPredicates(sUrl) {
3747
+ return sUrl.replace(rEscapedTick, "'").replace(rEscapedOpenBracket, "(").replace(rEscapedCloseBracket, ")");
3748
+ }
3749
+ _Helper = {
3750
+ addByPath: function (mMap, sPath, oItem) {
3751
+ if (oItem) {
3752
+ if (!mMap[sPath]) {
3753
+ mMap[sPath] = [oItem];
3754
+ } else if (!mMap[sPath].includes(oItem)) {
3755
+ mMap[sPath].push(oItem);
3756
+ }
3757
+ }
3758
+ },
3759
+ addChildrenWithAncestor: function (aChildren, aAncestors, mChildren) {
3760
+ if (aAncestors.length) {
3761
+ aChildren.forEach(function (sPath) {
3762
+ var aSegments;
3763
+ if (aAncestors.includes(sPath)) {
3764
+ mChildren[sPath] = true;
3765
+ return;
3766
+ }
3767
+ aSegments = sPath.split("/");
3768
+ aSegments.pop();
3769
+ while (aSegments.length) {
3770
+ if (aAncestors.indexOf(aSegments.join("/")) >= 0) {
3771
+ mChildren[sPath] = true;
3772
+ break;
3773
+ }
3774
+ aSegments.pop();
3775
+ }
3776
+ });
3777
+ }
3778
+ },
3779
+ addPromise: function (oElement) {
3780
+ return new SyncPromise(function (_fnResolve, fnReject) {
3781
+ _Helper.setPrivateAnnotation(oElement, "reject", fnReject);
3782
+ });
3783
+ },
3784
+ addToCount: function (mChangeListeners, sPath, aCollection, iDelta) {
3785
+ if (aCollection.$count !== undefined) {
3786
+ _Helper.setCount(mChangeListeners, sPath, aCollection, aCollection.$count + iDelta);
3787
+ }
3788
+ },
3789
+ addToSelect: function (mQueryOptions, aSelectPaths) {
3790
+ mQueryOptions.$select = mQueryOptions.$select || [];
3791
+ aSelectPaths.forEach(function (sPath) {
3792
+ if (!mQueryOptions.$select.includes(sPath)) {
3793
+ mQueryOptions.$select.push(sPath);
3794
+ }
3795
+ });
3796
+ },
3797
+ adjustTargets: function (oMessage, oOperationMetadata, sParameterContextPath, sContextPath) {
3798
+ var sAdditionalTargetsKey = _Helper.getAnnotationKey(oMessage, ".additionalTargets"), aTargets;
3799
+ aTargets = [oMessage.target].concat(oMessage[sAdditionalTargetsKey]).map(function (sTarget) {
3800
+ return sTarget && _Helper.getAdjustedTarget(sTarget, oOperationMetadata, sParameterContextPath, sContextPath);
3801
+ }).filter(function (sTarget) {
3802
+ return sTarget;
3803
+ });
3804
+ oMessage.target = aTargets[0];
3805
+ if (sAdditionalTargetsKey) {
3806
+ oMessage[sAdditionalTargetsKey] = aTargets.slice(1);
3807
+ }
3808
+ },
3809
+ adjustTargetsInError: function (oError, oOperationMetadata, sParameterContextPath, sContextPath) {
3810
+ if (!oError.error) {
3811
+ return;
3812
+ }
3813
+ _Helper.adjustTargets(oError.error, oOperationMetadata, sParameterContextPath, sContextPath);
3814
+ if (oError.error.details) {
3815
+ oError.error.details.forEach(function (oMessage) {
3816
+ _Helper.adjustTargets(oMessage, oOperationMetadata, sParameterContextPath, sContextPath);
3817
+ });
3818
+ }
3819
+ },
3820
+ aggregateExpandSelect: function (mAggregatedQueryOptions, mQueryOptions) {
3821
+ if (mQueryOptions.$select) {
3822
+ _Helper.addToSelect(mAggregatedQueryOptions, mQueryOptions.$select);
3823
+ }
3824
+ if (mQueryOptions.$expand) {
3825
+ mAggregatedQueryOptions.$expand = mAggregatedQueryOptions.$expand || ({});
3826
+ Object.keys(mQueryOptions.$expand).forEach(function (sPath) {
3827
+ if (mAggregatedQueryOptions.$expand[sPath]) {
3828
+ _Helper.aggregateExpandSelect(mAggregatedQueryOptions.$expand[sPath], mQueryOptions.$expand[sPath]);
3829
+ } else {
3830
+ mAggregatedQueryOptions.$expand[sPath] = mQueryOptions.$expand[sPath];
3831
+ }
3832
+ });
3833
+ }
3834
+ },
3835
+ buildPath: function () {
3836
+ var sPath = "", sSegment, i;
3837
+ for (i = 0; i < arguments.length; i += 1) {
3838
+ sSegment = arguments[i];
3839
+ if (sSegment || sSegment === 0) {
3840
+ if (sPath && sPath !== "/" && sSegment[0] !== "(") {
3841
+ sPath += "/";
3842
+ }
3843
+ sPath += sSegment;
3844
+ }
3845
+ }
3846
+ return sPath;
3847
+ },
3848
+ buildQuery: function (mParameters) {
3849
+ var aKeys, aQuery;
3850
+ if (!mParameters) {
3851
+ return "";
3852
+ }
3853
+ aKeys = Object.keys(mParameters);
3854
+ if (aKeys.length === 0) {
3855
+ return "";
3856
+ }
3857
+ aQuery = [];
3858
+ aKeys.forEach(function (sKey) {
3859
+ var vValue = mParameters[sKey];
3860
+ if (Array.isArray(vValue)) {
3861
+ vValue.forEach(function (sItem) {
3862
+ aQuery.push(_Helper.encodePair(sKey, sItem));
3863
+ });
3864
+ } else {
3865
+ aQuery.push(_Helper.encodePair(sKey, vValue));
3866
+ }
3867
+ });
3868
+ return "?" + aQuery.join("&");
3869
+ },
3870
+ buildSelect: function (aSelect) {
3871
+ var oSelect = {};
3872
+ if (!aSelect || aSelect.includes("*")) {
3873
+ return true;
3874
+ }
3875
+ aSelect.forEach(function (sPath) {
3876
+ var aSegments = sPath.split("/"), iLast = aSegments.length - 1, oSubSelect = oSelect;
3877
+ aSegments.some(function (sSegment, i) {
3878
+ if (i === iLast || aSegments[i + 1] === "*") {
3879
+ oSubSelect[sSegment] = true;
3880
+ return true;
3881
+ }
3882
+ if (oSubSelect[sSegment] === true) {
3883
+ return true;
3884
+ }
3885
+ oSubSelect = oSubSelect[sSegment] = oSubSelect[sSegment] || ({});
3886
+ });
3887
+ });
3888
+ return oSelect;
3889
+ },
3890
+ cancelNestedCreates: function (oElement, sMessage) {
3891
+ Object.keys(oElement).forEach(function (sKey) {
3892
+ var oError, vProperty = oElement[sKey];
3893
+ if (vProperty && vProperty.$postBodyCollection) {
3894
+ oError = new Error(sMessage);
3895
+ oError.canceled = true;
3896
+ vProperty.forEach(function (oChildElement) {
3897
+ _Helper.getPrivateAnnotation(oChildElement, "reject")(oError);
3898
+ _Helper.cancelNestedCreates(oChildElement, sMessage);
3899
+ });
3900
+ }
3901
+ });
3902
+ },
3903
+ checkGroupId: function (sGroupId, bApplicationGroup, bAllowSingle, sErrorMessage) {
3904
+ if (!bApplicationGroup && sGroupId === undefined || typeof sGroupId === "string" && (bApplicationGroup ? rApplicationGroupID : rGroupID).test(sGroupId) || bAllowSingle && sGroupId === "$single") {
3905
+ return;
3906
+ }
3907
+ throw new Error((sErrorMessage || "Invalid group ID: ") + sGroupId);
3908
+ },
3909
+ clone: function clone(vValue, fnReplacer, bAsString) {
3910
+ var sStringified;
3911
+ if (vValue === undefined || vValue === Infinity || vValue === -Infinity || Number.isNaN(vValue)) {
3912
+ return vValue;
3913
+ }
3914
+ sStringified = JSON.stringify(vValue, fnReplacer);
3915
+ return bAsString ? sStringified : JSON.parse(sStringified);
3916
+ },
3917
+ cloneNo$: function cloneNo$(vValue) {
3918
+ return _Helper.clone(vValue, function (sKey, vValue) {
3919
+ return sKey[0] === "$" ? undefined : vValue;
3920
+ });
3921
+ },
3922
+ convertExpandSelectToPaths: function (mQueryOptions) {
3923
+ var aPaths = [];
3924
+ function convert(mQueryOptions0, sPathPrefix) {
3925
+ if (mQueryOptions0.$select) {
3926
+ mQueryOptions0.$select.forEach(function (sSelect) {
3927
+ aPaths.push(_Helper.buildPath(sPathPrefix, sSelect));
3928
+ });
3929
+ }
3930
+ if (mQueryOptions0.$expand) {
3931
+ Object.keys(mQueryOptions0.$expand).forEach(function (sExpandPath) {
3932
+ convert(mQueryOptions0.$expand[sExpandPath], _Helper.buildPath(sPathPrefix, sExpandPath));
3933
+ });
3934
+ }
3935
+ }
3936
+ convert(mQueryOptions, "");
3937
+ return aPaths;
3938
+ },
3939
+ copyPrivateAnnotation: function (oSource, sAnnotation, oTarget) {
3940
+ if (_Helper.hasPrivateAnnotation(oSource, sAnnotation)) {
3941
+ if (_Helper.hasPrivateAnnotation(oTarget, sAnnotation)) {
3942
+ throw new Error("Must not overwrite: " + sAnnotation);
3943
+ }
3944
+ _Helper.setPrivateAnnotation(oTarget, sAnnotation, _Helper.getPrivateAnnotation(oSource, sAnnotation));
3945
+ }
3946
+ },
3947
+ createError: function (jqXHR, sMessage, sRequestUrl, sResourcePath) {
3948
+ var sBody = jqXHR.responseText, sContentType = jqXHR.getResponseHeader("Content-Type"), sPreference, oResult = new Error(sMessage + ": " + jqXHR.status + " " + jqXHR.statusText), sRetryAfter = jqXHR.getResponseHeader("Retry-After"), iRetryAfter;
3949
+ oResult.status = jqXHR.status;
3950
+ oResult.statusText = jqXHR.statusText;
3951
+ oResult.requestUrl = sRequestUrl;
3952
+ oResult.resourcePath = sResourcePath;
3953
+ if (jqXHR.status === 0) {
3954
+ oResult.message = "Network error";
3955
+ return oResult;
3956
+ }
3957
+ if (sContentType) {
3958
+ sContentType = sContentType.split(";")[0];
3959
+ }
3960
+ if (jqXHR.status === 412) {
3961
+ sPreference = jqXHR.getResponseHeader("Preference-Applied");
3962
+ if (sPreference && sPreference.replace(rWhitespace, "") === "handling=strict") {
3963
+ oResult.strictHandlingFailed = true;
3964
+ } else {
3965
+ oResult.isConcurrentModification = true;
3966
+ }
3967
+ }
3968
+ if (sRetryAfter) {
3969
+ iRetryAfter = parseInt(sRetryAfter);
3970
+ oResult.retryAfter = new Date(Number.isNaN(iRetryAfter) ? sRetryAfter : Date.now() + iRetryAfter * 1000);
3971
+ }
3972
+ if (sContentType === "application/json") {
3973
+ try {
3974
+ oResult.error = JSON.parse(sBody).error;
3975
+ oResult.message = oResult.error.message;
3976
+ if (typeof oResult.message === "object") {
3977
+ oResult.message = oResult.error.message.value;
3978
+ }
3979
+ } catch (e) {
3980
+ Log.warning(e.toString(), sBody, sClassName$2);
3981
+ }
3982
+ } else if (sContentType === "text/plain") {
3983
+ oResult.message = sBody;
3984
+ }
3985
+ return oResult;
3986
+ },
3987
+ createGetMethod: function (sFetch, bThrow) {
3988
+ return function () {
3989
+ var oSyncPromise = this[sFetch].apply(this, arguments);
3990
+ if (oSyncPromise.isFulfilled()) {
3991
+ return oSyncPromise.getResult();
3992
+ } else if (bThrow) {
3993
+ if (oSyncPromise.isRejected()) {
3994
+ oSyncPromise.caught();
3995
+ throw oSyncPromise.getResult();
3996
+ } else {
3997
+ throw new Error("Result pending");
3998
+ }
3999
+ }
4000
+ };
4001
+ },
4002
+ createMissing: function (oObject, aSegments) {
4003
+ aSegments.reduce(function (oCurrent, sSegment, i) {
4004
+ if (!((sSegment in oCurrent))) {
4005
+ oCurrent[sSegment] = i + 1 < aSegments.length ? {} : null;
4006
+ }
4007
+ return oCurrent[sSegment];
4008
+ }, oObject);
4009
+ },
4010
+ createRequestMethod: function (sFetch) {
4011
+ return function () {
4012
+ return Promise.resolve(this[sFetch].apply(this, arguments));
4013
+ };
4014
+ },
4015
+ createTechnicalDetails: function (oMessage) {
4016
+ var oClonedMessage, oError = oMessage["@$ui5.error"], oOriginalMessage = oMessage["@$ui5.originalMessage"] || oMessage, oTechnicalDetails = {};
4017
+ if (oError && (oError.status || oError.cause)) {
4018
+ oError = oError.cause || oError;
4019
+ oTechnicalDetails.httpStatus = oError.status;
4020
+ if (oError.isConcurrentModification) {
4021
+ oTechnicalDetails.isConcurrentModification = true;
4022
+ }
4023
+ if (oError.retryAfter) {
4024
+ oTechnicalDetails.retryAfter = oError.retryAfter;
4025
+ }
4026
+ }
4027
+ if (!(oOriginalMessage instanceof Error)) {
4028
+ Object.defineProperty(oTechnicalDetails, "originalMessage", {
4029
+ enumerable: true,
4030
+ get: function () {
4031
+ if (!oClonedMessage) {
4032
+ oClonedMessage = _Helper.publicClone(oOriginalMessage);
4033
+ }
4034
+ return oClonedMessage;
4035
+ }
4036
+ });
4037
+ }
4038
+ return oTechnicalDetails;
4039
+ },
4040
+ decomposeError: function (oError, aRequests, sServiceUrl) {
4041
+ var aDetailContentIDs = oError.error.details && oError.error.details.map(function (oDetail) {
4042
+ return _Helper.getContentID(oDetail);
4043
+ }), sTopLevelContentID = _Helper.getContentID(oError.error);
4044
+ return aRequests.map(function (oRequest, i) {
4045
+ var oClone = new Error(oError.message);
4046
+ function isRelevant(oMessage, sContentID) {
4047
+ if (i === 0 && !sContentID) {
4048
+ if (oMessage.target) {
4049
+ oMessage.message = oMessage.target + ": " + oMessage.message;
4050
+ }
4051
+ delete oMessage.target;
4052
+ return true;
4053
+ }
4054
+ return sContentID === oRequest.$ContentID;
4055
+ }
4056
+ oClone.error = _Helper.clone(oError.error);
4057
+ oClone.requestUrl = sServiceUrl + oRequest.url;
4058
+ oClone.resourcePath = oRequest.$resourcePath;
4059
+ oClone.status = oError.status;
4060
+ oClone.statusText = oError.statusText;
4061
+ if (!isRelevant(oClone.error, sTopLevelContentID)) {
4062
+ oClone.error.$ignoreTopLevel = true;
4063
+ }
4064
+ if (oError.strictHandlingFailed) {
4065
+ oClone.strictHandlingFailed = true;
4066
+ }
4067
+ if (oClone.error.details) {
4068
+ oClone.error.details = oClone.error.details.filter(function (oDetail, j) {
4069
+ return isRelevant(oDetail, aDetailContentIDs[j]);
4070
+ });
4071
+ }
4072
+ return oClone;
4073
+ });
4074
+ },
4075
+ deepEqual: fnEqual,
4076
+ deletePrivateAnnotation: function (oObject, sAnnotation) {
4077
+ var oPrivateNamespace = oObject["@$ui5._"];
4078
+ if (oPrivateNamespace) {
4079
+ delete oPrivateNamespace[sAnnotation];
4080
+ }
4081
+ },
4082
+ deleteProperty: function (oObject, sPath) {
4083
+ var aSegments;
4084
+ if (sPath.includes("/")) {
4085
+ aSegments = sPath.split("/");
4086
+ sPath = aSegments.pop();
4087
+ oObject = _Helper.drillDown(oObject, aSegments);
4088
+ if (!oObject) {
4089
+ return;
4090
+ }
4091
+ }
4092
+ delete oObject[sPath];
4093
+ },
4094
+ deleteUpdating: function (sPropertyPath, oEntity) {
4095
+ var oData = oEntity;
4096
+ sPropertyPath.split("/").some(function (sSegment) {
4097
+ var vValue = oData[sSegment];
4098
+ if (vValue === null || Array.isArray(vValue)) {
4099
+ return true;
4100
+ }
4101
+ if (typeof vValue === "object") {
4102
+ oData = vValue;
4103
+ return false;
4104
+ }
4105
+ delete oData[sSegment + "@$ui5.updating"];
4106
+ });
4107
+ },
4108
+ drillDown: function (oObject, vSegments) {
4109
+ if (typeof vSegments === "string") {
4110
+ vSegments = vSegments.split("/");
4111
+ }
4112
+ return vSegments.reduce(function (oCurrent, sSegment) {
4113
+ return oCurrent && (sSegment in oCurrent) ? oCurrent[sSegment] : undefined;
4114
+ }, oObject);
4115
+ },
4116
+ encode: function (sPart, bEncodeEquals) {
4117
+ var sEncoded = encodeURI(sPart).replace(rAmpersand, "%26").replace(rHash, "%23").replace(rPlus, "%2B");
4118
+ if (bEncodeEquals) {
4119
+ sEncoded = sEncoded.replace(rEquals, "%3D");
4120
+ }
4121
+ return sEncoded;
4122
+ },
4123
+ encodePair: function (sKey, sValue) {
4124
+ return _Helper.encode(sKey, true) + "=" + _Helper.encode(sValue, false);
4125
+ },
4126
+ extractMessages: function (oError) {
4127
+ var aMessages = [];
4128
+ function addMessage(oMessage, iNumericSeverity, bTechnical) {
4129
+ var oRawMessage = {
4130
+ additionalTargets: _Helper.getAdditionalTargets(oMessage),
4131
+ code: oMessage.code,
4132
+ message: oMessage.message,
4133
+ numericSeverity: iNumericSeverity,
4134
+ technical: bTechnical || oMessage.technical,
4135
+ "@$ui5.error": oError,
4136
+ "@$ui5.originalMessage": oMessage
4137
+ };
4138
+ Object.keys(oMessage).forEach(function (sProperty) {
4139
+ if (sProperty[0] === "@") {
4140
+ if (sProperty.endsWith(".numericSeverity")) {
4141
+ oRawMessage.numericSeverity = oMessage[sProperty];
4142
+ } else if (sProperty.endsWith(".longtextUrl") && oError.requestUrl && oMessage[sProperty]) {
4143
+ oRawMessage.longtextUrl = _Helper.makeAbsolute(oMessage[sProperty], oError.requestUrl);
4144
+ }
4145
+ }
4146
+ });
4147
+ if (typeof oMessage.target === "string") {
4148
+ if (oMessage.target[0] === "$" || !oError.resourcePath) {
4149
+ oRawMessage.message = oMessage.target + ": " + oMessage.message;
4150
+ } else {
4151
+ oRawMessage.target = oMessage.target;
4152
+ }
4153
+ }
4154
+ oRawMessage.transition = true;
4155
+ aMessages.push(oRawMessage);
4156
+ }
4157
+ if (oError.error) {
4158
+ if (!oError.error.$ignoreTopLevel) {
4159
+ addMessage(oError.error, 4, true);
4160
+ }
4161
+ if (oError.error.details) {
4162
+ oError.error.details.forEach(function (oMessage) {
4163
+ addMessage(oMessage);
4164
+ });
4165
+ }
4166
+ } else {
4167
+ addMessage(oError, 4, true);
4168
+ }
4169
+ return aMessages;
4170
+ },
4171
+ extractMergeableQueryOptions: function (mQueryOptions) {
4172
+ var mExtractedQueryOptions = {};
4173
+ if (("$expand" in mQueryOptions)) {
4174
+ mExtractedQueryOptions.$expand = mQueryOptions.$expand;
4175
+ mQueryOptions.$expand = "~";
4176
+ }
4177
+ if (("$select" in mQueryOptions)) {
4178
+ mExtractedQueryOptions.$select = mQueryOptions.$select;
4179
+ mQueryOptions.$select = "~";
4180
+ }
4181
+ return mExtractedQueryOptions;
4182
+ },
4183
+ fetchPropertyAndType: function (fnFetchMetadata, sMetaPath) {
4184
+ return fnFetchMetadata(sMetaPath).then(function (oProperty) {
4185
+ if (oProperty && oProperty.$kind === "NavigationProperty") {
4186
+ return fnFetchMetadata(sMetaPath + "/").then(function () {
4187
+ return oProperty;
4188
+ });
4189
+ }
4190
+ return oProperty;
4191
+ });
4192
+ },
4193
+ filterPaths: function (aMetaPaths, aPathsToFilter) {
4194
+ return aPathsToFilter.filter(function (sPathToFilter) {
4195
+ var sMetaPathToFilter = _Helper.getMetaPath(sPathToFilter);
4196
+ return aMetaPaths.every(function (sMetaPath) {
4197
+ return !_Helper.hasPathPrefix(sMetaPathToFilter, sMetaPath);
4198
+ });
4199
+ });
4200
+ },
4201
+ fireChange: function (mChangeListeners, sPropertyPath, vValue, bForceUpdate) {
4202
+ var aListeners = mChangeListeners[sPropertyPath], i;
4203
+ if (aListeners) {
4204
+ for (i = 0; i < aListeners.length; i += 1) {
4205
+ aListeners[i].onChange(vValue, bForceUpdate);
4206
+ }
4207
+ }
4208
+ },
4209
+ fireChanges: function (mChangeListeners, sPath, oValue, bRemoved) {
4210
+ Object.keys(oValue).forEach(function (sProperty) {
4211
+ var sPropertyPath = _Helper.buildPath(sPath, sProperty), vValue = oValue[sProperty];
4212
+ if (vValue && typeof vValue === "object") {
4213
+ _Helper.fireChanges(mChangeListeners, sPropertyPath, vValue, bRemoved);
4214
+ } else {
4215
+ _Helper.fireChange(mChangeListeners, sPropertyPath, bRemoved ? undefined : vValue);
4216
+ }
4217
+ });
4218
+ _Helper.fireChange(mChangeListeners, sPath, bRemoved ? undefined : oValue);
4219
+ },
4220
+ formatLiteral: function (vValue, sType) {
4221
+ if (vValue === undefined) {
4222
+ throw new Error("Illegal value: undefined");
4223
+ }
4224
+ if (vValue === null) {
4225
+ return "null";
4226
+ }
4227
+ switch (sType) {
4228
+ case "Edm.Binary":
4229
+ return "binary'" + vValue + "'";
4230
+ case "Edm.Boolean":
4231
+ case "Edm.Byte":
4232
+ case "Edm.Double":
4233
+ case "Edm.Int16":
4234
+ case "Edm.Int32":
4235
+ case "Edm.SByte":
4236
+ case "Edm.Single":
4237
+ return String(vValue);
4238
+ case "Edm.Date":
4239
+ case "Edm.DateTimeOffset":
4240
+ case "Edm.Decimal":
4241
+ case "Edm.Guid":
4242
+ case "Edm.Int64":
4243
+ case "Edm.TimeOfDay":
4244
+ return vValue;
4245
+ case "Edm.Duration":
4246
+ return "duration'" + vValue + "'";
4247
+ case "Edm.String":
4248
+ return "'" + String(vValue).replace(rSingleQuote, "''") + "'";
4249
+ default:
4250
+ throw new Error("Unsupported type: " + sType);
4251
+ }
4252
+ },
4253
+ getAdditionalTargets: function (oMessage) {
4254
+ return _Helper.getAnnotation(oMessage, ".additionalTargets");
4255
+ },
4256
+ getAdjustedTarget: function (sTarget, oOperationMetadata, sParameterContextPath, sContextPath) {
4257
+ var bIsParameterName, sParameterName, aSegments;
4258
+ aSegments = sTarget.split("/");
4259
+ sParameterName = aSegments.shift();
4260
+ if (sParameterName === "$Parameter") {
4261
+ sTarget = aSegments.join("/");
4262
+ sParameterName = aSegments.shift();
4263
+ }
4264
+ if (oOperationMetadata.$IsBound && sParameterName === oOperationMetadata.$Parameter[0].$Name) {
4265
+ sTarget = _Helper.buildPath(sContextPath, aSegments.join("/"));
4266
+ return sTarget;
4267
+ }
4268
+ bIsParameterName = oOperationMetadata.$Parameter.some(function (oParameter) {
4269
+ return sParameterName === oParameter.$Name;
4270
+ });
4271
+ if (bIsParameterName) {
4272
+ sTarget = sParameterContextPath + "/" + sTarget;
4273
+ return sTarget;
4274
+ }
4275
+ },
4276
+ getAnnotation: function (oMessage, sName) {
4277
+ var sAnnotationKey = _Helper.getAnnotationKey(oMessage, sName);
4278
+ return sAnnotationKey && oMessage[sAnnotationKey];
4279
+ },
4280
+ getAnnotationKey: function (oObject, sName, sProperty) {
4281
+ var sAnnotationKey, bDuplicate, sPrefix = (sProperty || "") + "@";
4282
+ Object.keys(oObject).forEach(function (sKey) {
4283
+ if (sKey.startsWith(sPrefix) && sKey.endsWith(sName)) {
4284
+ if (sAnnotationKey) {
4285
+ Log.warning("Cannot distinguish " + sAnnotationKey + " from " + sKey, undefined, sClassName$2);
4286
+ bDuplicate = true;
4287
+ }
4288
+ sAnnotationKey = sKey;
4289
+ }
4290
+ });
4291
+ return bDuplicate ? undefined : sAnnotationKey;
4292
+ },
4293
+ getContentID: function (oMessage) {
4294
+ return _Helper.getAnnotation(oMessage, ".ContentID");
4295
+ },
4296
+ getKeyFilter: function (oInstance, sMetaPath, mTypeForMetaPath, aKeyProperties) {
4297
+ var aFilters = [], sKey, mKey2Value = _Helper.getKeyProperties(oInstance, sMetaPath, mTypeForMetaPath, aKeyProperties);
4298
+ if (!mKey2Value) {
4299
+ return undefined;
4300
+ }
4301
+ for (sKey in mKey2Value) {
4302
+ aFilters.push(sKey + " eq " + mKey2Value[sKey]);
4303
+ }
4304
+ return aFilters.join(" and ");
4305
+ },
4306
+ getKeyPredicate: function (oInstance, sMetaPath, mTypeForMetaPath, aKeyProperties, bKeepSingleProperty) {
4307
+ var mKey2Value = _Helper.getKeyProperties(oInstance, sMetaPath, mTypeForMetaPath, aKeyProperties, true);
4308
+ if (!mKey2Value) {
4309
+ return undefined;
4310
+ }
4311
+ aKeyProperties = Object.keys(mKey2Value).map(function (sAlias, _iIndex, aKeys) {
4312
+ var vValue = encodeURIComponent(mKey2Value[sAlias]);
4313
+ return bKeepSingleProperty || aKeys.length > 1 ? encodeURIComponent(sAlias) + "=" + vValue : vValue;
4314
+ });
4315
+ return "(" + aKeyProperties.join(",") + ")";
4316
+ },
4317
+ getKeyProperties: function (oInstance, sMetaPath, mTypeForMetaPath, aKeyProperties, bReturnAlias) {
4318
+ var bFailed, mKey2Value = {};
4319
+ aKeyProperties = aKeyProperties || mTypeForMetaPath[sMetaPath].$Key;
4320
+ bFailed = aKeyProperties.some(function (vKey) {
4321
+ var sKey, sKeyPath, oObject, sPropertyName, aSegments, oType, vValue;
4322
+ if (typeof vKey === "string") {
4323
+ sKey = sKeyPath = vKey;
4324
+ } else {
4325
+ sKey = Object.keys(vKey)[0];
4326
+ sKeyPath = vKey[sKey];
4327
+ if (!bReturnAlias) {
4328
+ sKey = sKeyPath;
4329
+ }
4330
+ }
4331
+ aSegments = sKeyPath.split("/");
4332
+ sPropertyName = aSegments.pop();
4333
+ oObject = _Helper.drillDown(oInstance, aSegments);
4334
+ vValue = oObject[sPropertyName];
4335
+ if (vValue === undefined || (sPropertyName + "@odata.type" in oObject)) {
4336
+ return true;
4337
+ }
4338
+ oType = mTypeForMetaPath[_Helper.buildPath(sMetaPath, aSegments.join("/"))];
4339
+ vValue = _Helper.formatLiteral(vValue, oType[sPropertyName].$Type);
4340
+ mKey2Value[sKey] = vValue;
4341
+ });
4342
+ return bFailed ? undefined : mKey2Value;
4343
+ },
4344
+ getMetaPath: function (sPath) {
4345
+ if (sPath[0] === "/") {
4346
+ return sPath.replace(rNotMetaContext, "");
4347
+ }
4348
+ if (sPath[0] !== "(") {
4349
+ sPath = "/" + sPath;
4350
+ }
4351
+ return sPath.replace(rNotMetaContext, "").slice(1);
4352
+ },
4353
+ getMissingPropertyPaths: function (vEntityOrCollection, mQueryOptions) {
4354
+ return (mQueryOptions.$select || []).concat(Object.keys(mQueryOptions.$expand || ({}))).filter(function (sPath) {
4355
+ return _Helper.isMissingProperty(vEntityOrCollection, sPath);
4356
+ });
4357
+ },
4358
+ getPredicates: function (aContexts) {
4359
+ var bMissingPredicate, aPredicates = aContexts.map(getPredicate);
4360
+ function getPredicate(oContext) {
4361
+ var sPredicate = _Helper.getPrivateAnnotation(oContext.getValue(), "predicate");
4362
+ if (!sPredicate) {
4363
+ bMissingPredicate = true;
4364
+ }
4365
+ return sPredicate;
4366
+ }
4367
+ return bMissingPredicate ? null : aPredicates;
4368
+ },
4369
+ getPredicateIndex: function (sPath) {
4370
+ var iPredicateIndex = sPath ? sPath.indexOf("(", sPath.lastIndexOf("/")) : -1;
4371
+ if (iPredicateIndex < 0 || !sPath.endsWith(")")) {
4372
+ throw new Error("Not a list context path to an entity: " + sPath);
4373
+ }
4374
+ return iPredicateIndex;
4375
+ },
4376
+ getPrivateAnnotation: function (oObject, sAnnotation, vDefault) {
4377
+ const vResult = oObject["@$ui5._"]?.[sAnnotation];
4378
+ return vResult === undefined ? vDefault : vResult;
4379
+ },
4380
+ getQueryOptionsForPath: function (mQueryOptions, sPath) {
4381
+ sPath = _Helper.getMetaPath(sPath);
4382
+ if (sPath) {
4383
+ sPath.split("/").some(function (sSegment) {
4384
+ mQueryOptions = mQueryOptions && mQueryOptions.$expand && mQueryOptions.$expand[sSegment];
4385
+ if (!mQueryOptions || mQueryOptions === true) {
4386
+ mQueryOptions = {};
4387
+ return true;
4388
+ }
4389
+ });
4390
+ }
4391
+ return mQueryOptions || ({});
4392
+ },
4393
+ getRelativePath: function (sPath, sBasePath) {
4394
+ if (sBasePath.length) {
4395
+ if (!sPath.startsWith(sBasePath)) {
4396
+ return undefined;
4397
+ }
4398
+ sPath = sPath.slice(sBasePath.length);
4399
+ if (sPath) {
4400
+ if (sPath[0] === "/") {
4401
+ return sPath.slice(1);
4402
+ }
4403
+ if (sPath[0] !== "(") {
4404
+ return undefined;
4405
+ }
4406
+ }
4407
+ }
4408
+ return sPath;
4409
+ },
4410
+ hasPathPrefix: function (sPath, sBasePath) {
4411
+ return _Helper.getRelativePath(sPath, sBasePath) !== undefined;
4412
+ },
4413
+ hasPrivateAnnotation: function (oObject, sAnnotation) {
4414
+ var oPrivateNamespace = oObject["@$ui5._"];
4415
+ return oPrivateNamespace ? (sAnnotation in oPrivateNamespace) : false;
4416
+ },
4417
+ informAll: function (mChangeListeners, sPath, vOld, vNew, bAllowUndefined) {
4418
+ if (vNew === vOld) {
4419
+ return;
4420
+ }
4421
+ if (vNew && typeof vNew === "object") {
4422
+ Object.keys(vNew).forEach(function (sProperty) {
4423
+ _Helper.informAll(mChangeListeners, _Helper.buildPath(sPath, sProperty), vOld && vOld[sProperty], vNew[sProperty], bAllowUndefined);
4424
+ });
4425
+ } else {
4426
+ _Helper.fireChange(mChangeListeners, sPath, !bAllowUndefined && vNew === undefined ? null : vNew);
4427
+ vNew = {};
4428
+ }
4429
+ if (vOld && typeof vOld === "object") {
4430
+ Object.keys(vOld).forEach(function (sProperty) {
4431
+ if (!Object.hasOwn(vNew, sProperty)) {
4432
+ _Helper.informAll(mChangeListeners, _Helper.buildPath(sPath, sProperty), vOld[sProperty], undefined, bAllowUndefined);
4433
+ }
4434
+ });
4435
+ }
4436
+ },
4437
+ inheritPathValue: function (aSegments, oSource, oTarget, bTolerateNull) {
4438
+ aSegments.forEach(function (sSegment, i) {
4439
+ var bMissing = !((sSegment in oTarget)) || bTolerateNull && oTarget[sSegment] === null;
4440
+ if (i + 1 < aSegments.length) {
4441
+ if (bMissing) {
4442
+ oTarget[sSegment] = {};
4443
+ }
4444
+ oSource = oSource[sSegment];
4445
+ oTarget = oTarget[sSegment];
4446
+ } else if (bMissing) {
4447
+ oTarget[sSegment] = oSource[sSegment];
4448
+ }
4449
+ });
4450
+ },
4451
+ intersectQueryOptions: function (mCacheQueryOptions, aPaths, fnFetchMetadata, sRootMetaPath, sPrefix, bWithMessages) {
4452
+ var aExpands = [], mExpands = {}, sMessagesPath = bWithMessages && fnFetchMetadata(sRootMetaPath + "/@com.sap.vocabularies.Common.v1.Messages/$Path").getResult(), mResult, oRootMetaData, aSelects, mSelects = {};
4453
+ function filterStructural(bSkipFirstSegment, sMetaPath) {
4454
+ var aSegments = sMetaPath.split("/");
4455
+ return aSegments.every(function (sSegment, i) {
4456
+ return i === 0 && bSkipFirstSegment || sSegment === "$count" || fnFetchMetadata(sRootMetaPath + "/" + aSegments.slice(0, i + 1).join("/")).getResult().$kind === "Property";
4457
+ });
4458
+ }
4459
+ if (aPaths.indexOf("") >= 0) {
4460
+ throw new Error("Unsupported empty navigation property path");
4461
+ }
4462
+ if (aPaths.indexOf("*") >= 0) {
4463
+ aSelects = (mCacheQueryOptions && mCacheQueryOptions.$select || []).slice();
4464
+ if (sMessagesPath && !aSelects.includes(sMessagesPath)) {
4465
+ aSelects.push(sMessagesPath);
4466
+ }
4467
+ } else if (mCacheQueryOptions && mCacheQueryOptions.$select && mCacheQueryOptions.$select.indexOf("*") < 0) {
4468
+ _Helper.addChildrenWithAncestor(aPaths, mCacheQueryOptions.$select, mSelects);
4469
+ _Helper.addChildrenWithAncestor(mCacheQueryOptions.$select, aPaths, mSelects);
4470
+ if (sMessagesPath && aPaths.includes(sMessagesPath)) {
4471
+ mSelects[sMessagesPath] = true;
4472
+ }
4473
+ aSelects = Object.keys(mSelects).filter(filterStructural.bind(null, true));
4474
+ } else {
4475
+ aSelects = aPaths.filter(filterStructural.bind(null, false));
4476
+ }
4477
+ if (mCacheQueryOptions && mCacheQueryOptions.$expand) {
4478
+ aExpands = Object.keys(mCacheQueryOptions.$expand);
4479
+ aExpands.forEach(function (sNavigationPropertyPath) {
4480
+ var mChildQueryOptions, sMetaPath = sRootMetaPath + "/" + sNavigationPropertyPath, sPrefixedNavigationPropertyPath = _Helper.buildPath(sPrefix, sNavigationPropertyPath), mSet = {}, aStrippedPaths;
4481
+ _Helper.addChildrenWithAncestor([sNavigationPropertyPath], aPaths, mSet);
4482
+ if (!fnIsEmptyObject(mSet)) {
4483
+ mExpands[sNavigationPropertyPath] = mCacheQueryOptions.$expand[sNavigationPropertyPath];
4484
+ return;
4485
+ }
4486
+ aStrippedPaths = _Helper.stripPathPrefix(sNavigationPropertyPath, aPaths);
4487
+ if (aStrippedPaths.length) {
4488
+ if (fnFetchMetadata(sMetaPath).getResult().$isCollection) {
4489
+ throw new Error("Unsupported collection-valued navigation property " + sMetaPath);
4490
+ }
4491
+ mChildQueryOptions = _Helper.intersectQueryOptions(mCacheQueryOptions.$expand[sNavigationPropertyPath] || ({}), aStrippedPaths, fnFetchMetadata, sMetaPath, sPrefixedNavigationPropertyPath);
4492
+ if (mChildQueryOptions) {
4493
+ mExpands[sNavigationPropertyPath] = mChildQueryOptions;
4494
+ }
4495
+ }
4496
+ });
4497
+ }
4498
+ if (!aSelects.length && fnIsEmptyObject(mExpands)) {
4499
+ return null;
4500
+ }
4501
+ mResult = Object.assign({}, mCacheQueryOptions, {
4502
+ $select: aSelects
4503
+ });
4504
+ oRootMetaData = fnFetchMetadata(sRootMetaPath).getResult();
4505
+ if (oRootMetaData.$kind === "NavigationProperty" && !oRootMetaData.$isCollection) {
4506
+ _Helper.selectKeyProperties(mResult, fnFetchMetadata(sRootMetaPath + "/").getResult());
4507
+ }
4508
+ if (fnIsEmptyObject(mExpands)) {
4509
+ delete mResult.$expand;
4510
+ } else {
4511
+ mResult.$expand = mExpands;
4512
+ }
4513
+ return mResult;
4514
+ },
4515
+ isDataAggregation: function (mParameters) {
4516
+ return mParameters && mParameters.$$aggregation && !mParameters.$$aggregation.hierarchyQualifier;
4517
+ },
4518
+ isEmptyObject: fnIsEmptyObject,
4519
+ isMissingProperty: function (vEntityOrCollection, sPath) {
4520
+ var aSegments = sPath.split("/");
4521
+ function isMissing(vValue, i) {
4522
+ var vProperty;
4523
+ if (Array.isArray(vValue)) {
4524
+ return vValue.some(function (vItem) {
4525
+ return isMissing(vItem, i);
4526
+ });
4527
+ }
4528
+ vProperty = vValue[aSegments[i]];
4529
+ if (vProperty && typeof vProperty === "object" && i + 1 < aSegments.length) {
4530
+ return isMissing(vProperty, i + 1);
4531
+ }
4532
+ return vProperty === undefined;
4533
+ }
4534
+ if (sPath.includes("*")) {
4535
+ throw new Error("Unsupported property path " + sPath);
4536
+ }
4537
+ return isMissing(vEntityOrCollection, 0);
4538
+ },
4539
+ isSafeInteger: function (iNumber) {
4540
+ if (typeof iNumber !== "number" || !isFinite(iNumber)) {
4541
+ return false;
4542
+ }
4543
+ iNumber = Math.abs(iNumber);
4544
+ return iNumber <= 9007199254740991 && Math.floor(iNumber) === iNumber;
4545
+ },
4546
+ isSelected: function (sPropertyPath, mQueryOptions) {
4547
+ var sPath, sRelativePath;
4548
+ if (!mQueryOptions) {
4549
+ return false;
4550
+ }
4551
+ if (mQueryOptions.$expand) {
4552
+ for (sPath in mQueryOptions.$expand) {
4553
+ sRelativePath = _Helper.getRelativePath(sPropertyPath, sPath);
4554
+ if (sRelativePath) {
4555
+ return _Helper.isSelected(sRelativePath, mQueryOptions.$expand[sPath]);
4556
+ }
4557
+ }
4558
+ }
4559
+ return !mQueryOptions.$select || mQueryOptions.$select.includes("*") || mQueryOptions.$select.some(function (sSelect) {
4560
+ return _Helper.hasPathPrefix(sPropertyPath, sSelect);
4561
+ });
4562
+ },
4563
+ makeAbsolute: function (sUrl, sBase) {
4564
+ return preserveKeyPredicates(new URI(sUrl).absoluteTo(sBase).toString());
4565
+ },
4566
+ makeRelativeUrl: function (sUrl, sBase) {
4567
+ return preserveKeyPredicates(new URI(sUrl).relativeTo(sBase).toString());
4568
+ },
4569
+ makeUpdateData: function (aPropertyPath, vValue, bUpdating) {
4570
+ return aPropertyPath.reduceRight(function (vValue0, sSegment) {
4571
+ var oResult = {};
4572
+ oResult[sSegment] = vValue0;
4573
+ if (bUpdating) {
4574
+ oResult[sSegment + "@$ui5.updating"] = true;
4575
+ bUpdating = false;
4576
+ }
4577
+ return oResult;
4578
+ }, vValue);
4579
+ },
4580
+ merge: fnMerge,
4581
+ mergeQueryOptions: function (mQueryOptions, sOrderby, aFilters) {
4582
+ var mResult;
4583
+ function set(sProperty, sValue) {
4584
+ if (sValue && (!mQueryOptions || mQueryOptions[sProperty] !== sValue)) {
4585
+ if (!mResult) {
4586
+ mResult = mQueryOptions ? _Helper.clone(mQueryOptions) : {};
4587
+ }
4588
+ mResult[sProperty] = sValue;
4589
+ }
4590
+ }
4591
+ set("$orderby", sOrderby);
4592
+ if (aFilters) {
4593
+ set("$filter", aFilters[0]);
4594
+ set("$$filterBeforeAggregate", aFilters[1]);
4595
+ }
4596
+ return mResult || mQueryOptions;
4597
+ },
4598
+ namespace: function (sName) {
4599
+ var iIndex;
4600
+ sName = sName.split("/")[0].split("(")[0];
4601
+ iIndex = sName.lastIndexOf(".");
4602
+ return iIndex < 0 ? "" : sName.slice(0, iIndex);
4603
+ },
4604
+ parseLiteral: function (sLiteral, sType, sPath) {
4605
+ function checkNaN(nValue) {
4606
+ if (!isFinite(nValue)) {
4607
+ throw new Error(sPath + ": Not a valid " + sType + " literal: " + sLiteral);
4608
+ }
4609
+ return nValue;
4610
+ }
4611
+ if (sLiteral === "null") {
4612
+ return null;
4613
+ }
4614
+ switch (sType) {
4615
+ case "Edm.Boolean":
4616
+ return sLiteral === "true";
4617
+ case "Edm.Byte":
4618
+ case "Edm.Int16":
4619
+ case "Edm.Int32":
4620
+ case "Edm.SByte":
4621
+ return checkNaN(parseInt(sLiteral));
4622
+ case "Edm.Date":
4623
+ case "Edm.DateTimeOffset":
4624
+ case "Edm.Decimal":
4625
+ case "Edm.Guid":
4626
+ case "Edm.Int64":
4627
+ case "Edm.TimeOfDay":
4628
+ return sLiteral;
4629
+ case "Edm.Double":
4630
+ case "Edm.Single":
4631
+ return sLiteral === "INF" || sLiteral === "-INF" || sLiteral === "NaN" ? sLiteral : checkNaN(parseFloat(sLiteral));
4632
+ case "Edm.String":
4633
+ return sLiteral.slice(1, -1).replace(rSingleQuoteTwice, "'");
4634
+ default:
4635
+ throw new Error(sPath + ": Unsupported type: " + sType);
4636
+ }
4637
+ },
4638
+ publicClone: function (vValue, bRemoveClientAnnotations, bAsString) {
4639
+ return _Helper.clone(vValue, function (sKey, vValue) {
4640
+ if (bRemoveClientAnnotations ? !sKey.startsWith("@$ui5.") : sKey !== "@$ui5._") {
4641
+ return vValue;
4642
+ }
4643
+ }, bAsString);
4644
+ },
4645
+ removeByPath: function (mMap, sPath, oItem) {
4646
+ var aItems = mMap[sPath], iIndex;
4647
+ if (aItems) {
4648
+ iIndex = aItems.indexOf(oItem);
4649
+ if (iIndex >= 0) {
4650
+ if (aItems.length === 1) {
4651
+ delete mMap[sPath];
4652
+ } else {
4653
+ aItems.splice(iIndex, 1);
4654
+ }
4655
+ }
4656
+ }
4657
+ },
4658
+ resetInactiveEntity: function (mChangeListeners, sPath, oEntity) {
4659
+ var oInitialData = _Helper.getPrivateAnnotation(oEntity, "initialData"), oPostBody = _Helper.getPrivateAnnotation(oEntity, "postBody"), oOldPostBody = Object.assign({}, oPostBody);
4660
+ Object.keys(oPostBody).forEach(function (sKey) {
4661
+ if ((sKey in oInitialData)) {
4662
+ oEntity[sKey] = oPostBody[sKey] = _Helper.clone(oInitialData[sKey]);
4663
+ } else {
4664
+ delete oPostBody[sKey];
4665
+ delete oEntity[sKey];
4666
+ }
4667
+ });
4668
+ _Helper.informAll(mChangeListeners, sPath, oOldPostBody, oPostBody, true);
4669
+ _Helper.updateAll(mChangeListeners, sPath, oEntity, {
4670
+ "@$ui5.context.isInactive": true
4671
+ });
4672
+ _Helper.getPrivateAnnotation(oEntity, "context").setInactive();
4673
+ },
4674
+ resolveIfMatchHeader: function (mHeaders, bIgnoreETag) {
4675
+ var vIfMatchValue = mHeaders && mHeaders["If-Match"];
4676
+ if (vIfMatchValue && typeof vIfMatchValue === "object") {
4677
+ vIfMatchValue = vIfMatchValue["@odata.etag"];
4678
+ mHeaders = Object.assign({}, mHeaders);
4679
+ if (vIfMatchValue === undefined) {
4680
+ delete mHeaders["If-Match"];
4681
+ } else {
4682
+ mHeaders["If-Match"] = bIgnoreETag ? "*" : vIfMatchValue;
4683
+ }
4684
+ }
4685
+ return mHeaders;
4686
+ },
4687
+ restoreUpdatingProperties: function (oOld, oNew) {
4688
+ var oTempNew = oNew || ({});
4689
+ Object.keys(oOld || ({})).forEach(function (sProperty) {
4690
+ if (sProperty.startsWith("@")) {
4691
+ return;
4692
+ }
4693
+ if (Array.isArray(oOld[sProperty])) {
4694
+ return;
4695
+ }
4696
+ if (typeof oOld[sProperty] === "object") {
4697
+ oTempNew[sProperty] = _Helper.restoreUpdatingProperties(oOld[sProperty], oTempNew[sProperty]);
4698
+ }
4699
+ if (oOld[sProperty + "@$ui5.updating"]) {
4700
+ oTempNew[sProperty] = oOld[sProperty];
4701
+ oTempNew[sProperty + "@$ui5.updating"] = oOld[sProperty + "@$ui5.updating"];
4702
+ oNew = oTempNew;
4703
+ }
4704
+ });
4705
+ return oNew;
4706
+ },
4707
+ selectKeyProperties: function (mQueryOptions, oType) {
4708
+ if (oType && oType.$Key) {
4709
+ _Helper.addToSelect(mQueryOptions, oType.$Key.map(function (vKey) {
4710
+ if (typeof vKey === "object") {
4711
+ return vKey[Object.keys(vKey)[0]];
4712
+ }
4713
+ return vKey;
4714
+ }));
4715
+ }
4716
+ },
4717
+ setAnnotation: function (oObject, sAnnotation, vValue) {
4718
+ if (vValue !== undefined) {
4719
+ oObject[sAnnotation] = vValue;
4720
+ } else {
4721
+ delete oObject[sAnnotation];
4722
+ }
4723
+ },
4724
+ setCount: function (mChangeListeners, sPath, aCollection, vCount) {
4725
+ if (typeof vCount === "string") {
4726
+ vCount = parseInt(vCount);
4727
+ }
4728
+ _Helper.updateExisting(mChangeListeners, sPath, aCollection, {
4729
+ $count: vCount
4730
+ });
4731
+ },
4732
+ setLanguage: function (sUrl, sLanguage) {
4733
+ if (sLanguage && !sUrl.includes("?sap-language=") && !sUrl.includes("&sap-language=")) {
4734
+ sUrl += (sUrl.includes("?") ? "&" : "?") + "sap-language=" + _Helper.encode(sLanguage);
4735
+ }
4736
+ return sUrl;
4737
+ },
4738
+ setPrivateAnnotation: function (oObject, sAnnotation, vValue) {
4739
+ var oPrivateNamespace = oObject["@$ui5._"];
4740
+ if (!oPrivateNamespace) {
4741
+ oPrivateNamespace = oObject["@$ui5._"] = {};
4742
+ }
4743
+ oPrivateNamespace[sAnnotation] = vValue;
4744
+ },
4745
+ stripPathPrefix: function (sPrefix, aPaths) {
4746
+ var sPathPrefix = sPrefix + "/";
4747
+ if (sPrefix === "") {
4748
+ return aPaths;
4749
+ }
4750
+ return aPaths.filter(function (sPath) {
4751
+ return sPath === sPrefix || sPath.startsWith(sPathPrefix);
4752
+ }).map(function (sPath) {
4753
+ return sPath.slice(sPathPrefix.length);
4754
+ });
4755
+ },
4756
+ toArray: function (vElement) {
4757
+ if (vElement === undefined || vElement === null) {
4758
+ return [];
4759
+ }
4760
+ if (Array.isArray(vElement)) {
4761
+ return vElement.slice();
4762
+ }
4763
+ return [vElement];
4764
+ },
4765
+ uid: fnUid,
4766
+ updateAll: function (mChangeListeners, sPath, oTarget, oSource) {
4767
+ Object.keys(oSource).forEach(function (sProperty) {
4768
+ var sPropertyPath = _Helper.buildPath(sPath, sProperty), vSourceProperty = oSource[sProperty], vTargetProperty = oTarget[sProperty];
4769
+ if (sProperty === "@$ui5._") {
4770
+ _Helper.setPrivateAnnotation(oTarget, "predicate", _Helper.getPrivateAnnotation(oSource, "predicate"));
4771
+ } else if (Array.isArray(vSourceProperty)) {
4772
+ oTarget[sProperty] = vSourceProperty;
4773
+ } else if (vSourceProperty && typeof vSourceProperty === "object") {
4774
+ oTarget[sProperty] = _Helper.updateAll(mChangeListeners, sPropertyPath, vTargetProperty || ({}), vSourceProperty);
4775
+ } else if (vTargetProperty !== vSourceProperty) {
4776
+ oTarget[sProperty] = vSourceProperty;
4777
+ if (vTargetProperty && typeof vTargetProperty === "object") {
4778
+ _Helper.fireChanges(mChangeListeners, sPropertyPath, vTargetProperty, true);
4779
+ } else {
4780
+ _Helper.fireChange(mChangeListeners, sPropertyPath, vSourceProperty);
4781
+ }
4782
+ }
4783
+ });
4784
+ return oTarget;
4785
+ },
4786
+ updateExisting: function (mChangeListeners, sPath, oOldObject, oNewObject) {
4787
+ if (!oNewObject) {
4788
+ return;
4789
+ }
4790
+ Object.keys(oOldObject).forEach(function (sProperty) {
4791
+ var sPropertyPath = _Helper.buildPath(sPath, sProperty), vOldProperty = oOldObject[sProperty], vNewProperty = oNewObject[sProperty];
4792
+ if ((sProperty in oNewObject) || sProperty[0] === "#") {
4793
+ if (Array.isArray(vNewProperty)) {
4794
+ oOldObject[sProperty] = vNewProperty;
4795
+ } else if (vNewProperty && typeof vNewProperty === "object") {
4796
+ if (vOldProperty) {
4797
+ _Helper.updateExisting(mChangeListeners, sPropertyPath, vOldProperty, vNewProperty);
4798
+ } else {
4799
+ oOldObject[sProperty] = vNewProperty;
4800
+ _Helper.fireChanges(mChangeListeners, sPropertyPath, vNewProperty, false);
4801
+ }
4802
+ } else if (vOldProperty !== vNewProperty) {
4803
+ oOldObject[sProperty] = vNewProperty;
4804
+ if (vOldProperty && typeof vOldProperty === "object") {
4805
+ _Helper.fireChanges(mChangeListeners, sPropertyPath, vOldProperty, true);
4806
+ } else {
4807
+ _Helper.fireChange(mChangeListeners, sPropertyPath, vNewProperty);
4808
+ }
4809
+ }
4810
+ }
4811
+ });
4812
+ Object.keys(oNewObject).filter(function (sProperty) {
4813
+ return sProperty[0] === "#";
4814
+ }).filter(function (sAdvertisedAction) {
4815
+ return !((sAdvertisedAction in oOldObject));
4816
+ }).forEach(function (sNewAdvertisedAction) {
4817
+ var vNewProperty = oNewObject[sNewAdvertisedAction], sPropertyPath = _Helper.buildPath(sPath, sNewAdvertisedAction);
4818
+ oOldObject[sNewAdvertisedAction] = vNewProperty;
4819
+ _Helper.fireChanges(mChangeListeners, sPropertyPath, vNewProperty, false);
4820
+ });
4821
+ },
4822
+ updateNestedCreates: function (mChangeListeners, mQueryOptions, sPath, oTargetEntity, oCreatedEntity, mSelectForMetaPath) {
4823
+ let bDeepCreate = false;
4824
+ const mQueryOptionsForEntity = _Helper.getQueryOptionsForPath(mQueryOptions, sPath);
4825
+ Object.keys(mQueryOptionsForEntity.$expand || ({})).forEach(function (sExpandPath) {
4826
+ const oNestedTargetEntity = _Helper.drillDown(oTargetEntity, sExpandPath);
4827
+ if (oNestedTargetEntity && !Array.isArray(oNestedTargetEntity)) {
4828
+ bDeepCreate = true;
4829
+ }
4830
+ });
4831
+ Object.keys(mSelectForMetaPath || ({})).filter(function (sMetaPath) {
4832
+ return !sMetaPath.includes("/");
4833
+ }).forEach(function (sSegment) {
4834
+ const aNestedCreatedEntities = oCreatedEntity[sSegment];
4835
+ if (!aNestedCreatedEntities) {
4836
+ delete oTargetEntity[sSegment];
4837
+ return;
4838
+ }
4839
+ oTargetEntity[sSegment] = aNestedCreatedEntities;
4840
+ aNestedCreatedEntities.$count = undefined;
4841
+ aNestedCreatedEntities.$created = 0;
4842
+ aNestedCreatedEntities.$byPredicate = {};
4843
+ if (mSelectForMetaPath[sSegment]) {
4844
+ aNestedCreatedEntities.$transfer = true;
4845
+ }
4846
+ const sCollectionPath = sPath + "/" + sSegment;
4847
+ _Helper.setCount(mChangeListeners, sCollectionPath, aNestedCreatedEntities, aNestedCreatedEntities.length);
4848
+ const mSelectForChildMetaPath = {};
4849
+ const sPrefix = sSegment + "/";
4850
+ Object.keys(mSelectForMetaPath).forEach(function (sMetaPath) {
4851
+ if (sMetaPath.startsWith(sPrefix)) {
4852
+ mSelectForChildMetaPath[sMetaPath.slice(sPrefix.length)] = mSelectForMetaPath[sMetaPath];
4853
+ }
4854
+ });
4855
+ aNestedCreatedEntities.forEach(function (oCreatedChildEntity) {
4856
+ const sPredicate = _Helper.getPrivateAnnotation(oCreatedChildEntity, "predicate");
4857
+ aNestedCreatedEntities.$byPredicate[sPredicate] = oCreatedChildEntity;
4858
+ _Helper.updateNestedCreates(mChangeListeners, mQueryOptions, sCollectionPath + sPredicate, oCreatedChildEntity, oCreatedChildEntity, mSelectForChildMetaPath);
4859
+ });
4860
+ bDeepCreate = true;
4861
+ });
4862
+ return bDeepCreate;
4863
+ },
4864
+ updateNonExisting: function (oTarget, oSource) {
4865
+ Object.keys(oSource).forEach(function (sKey) {
4866
+ var vSourceValue = oSource[sKey], vTargetValue;
4867
+ if ((sKey in oTarget)) {
4868
+ vTargetValue = oTarget[sKey];
4869
+ if (vSourceValue && vTargetValue && typeof vSourceValue === "object" && !Array.isArray(vSourceValue)) {
4870
+ _Helper.updateNonExisting(vTargetValue, vSourceValue);
4871
+ }
4872
+ } else {
4873
+ oTarget[sKey] = vSourceValue;
4874
+ }
4875
+ });
4876
+ },
4877
+ updateSelected: function (mChangeListeners, sBasePath, oOldValue, oNewValue, aSelect, fnCheckKeyPredicate, bOkIfMissing) {
4878
+ function getSelect(vSelect, sProperty) {
4879
+ var iAt;
4880
+ if (vSelect === true) {
4881
+ return true;
4882
+ }
4883
+ if (vSelect[sProperty]) {
4884
+ return vSelect[sProperty];
4885
+ }
4886
+ iAt = sProperty.indexOf("@");
4887
+ if (iAt === 0 || iAt > 0 && vSelect[sProperty.slice(0, iAt)]) {
4888
+ return true;
4889
+ }
4890
+ }
4891
+ function update(sPath, vSelect, oTarget, oSource) {
4892
+ Object.keys(oTarget).forEach(function (sProperty) {
4893
+ if (!((sProperty in oSource)) && sProperty.includes("@") && !sProperty.startsWith("@$ui5.") && getSelect(vSelect, sProperty) && !sProperty.endsWith("@$ui5.updating")) {
4894
+ delete oTarget[sProperty];
4895
+ _Helper.fireChange(mChangeListeners, _Helper.buildPath(sPath, sProperty), undefined);
4896
+ }
4897
+ });
4898
+ Object.keys(oSource).forEach(function (sProperty) {
4899
+ var sPropertyPath = _Helper.buildPath(sPath, sProperty), vSelected = getSelect(vSelect, sProperty), sSourcePredicate, vSourceProperty = oSource[sProperty], sTargetPredicate, vTargetProperty = oTarget[sProperty];
4900
+ if (!vSelected) {
4901
+ return;
4902
+ }
4903
+ if (sProperty === "@$ui5._") {
4904
+ sSourcePredicate = _Helper.getPrivateAnnotation(oSource, "predicate");
4905
+ if (fnCheckKeyPredicate && fnCheckKeyPredicate(sPath)) {
4906
+ sTargetPredicate = _Helper.getPrivateAnnotation(oTarget, "predicate");
4907
+ if (sSourcePredicate !== sTargetPredicate) {
4908
+ throw new Error("Key predicate of '" + sPath + "' changed from " + sTargetPredicate + " to " + sSourcePredicate);
4909
+ }
4910
+ } else {
4911
+ _Helper.setPrivateAnnotation(oTarget, "predicate", sSourcePredicate);
4912
+ }
4913
+ } else if (Array.isArray(vSourceProperty)) {
4914
+ if (!(vTargetProperty && vTargetProperty.$postBodyCollection)) {
4915
+ oTarget[sProperty] = vSourceProperty;
4916
+ }
4917
+ } else if (vSourceProperty && typeof vSourceProperty === "object" && !sProperty.includes("@")) {
4918
+ oTarget[sProperty] = update(sPropertyPath, vSelected, vTargetProperty || ({}), vSourceProperty);
4919
+ } else if (vTargetProperty !== vSourceProperty && !oTarget[sProperty + "@$ui5.updating"]) {
4920
+ oTarget[sProperty] = vSourceProperty;
4921
+ if (vTargetProperty && typeof vTargetProperty === "object") {
4922
+ _Helper.fireChanges(mChangeListeners, sPropertyPath, vTargetProperty, true);
4923
+ } else if (vSelected === true) {
4924
+ _Helper.fireChange(mChangeListeners, sPropertyPath, vSourceProperty);
4925
+ }
4926
+ }
4927
+ });
4928
+ if (bOkIfMissing) {
4929
+ return oTarget;
4930
+ }
4931
+ Object.keys(vSelect).forEach(function (sProperty) {
4932
+ if (!((sProperty in oTarget)) && sProperty !== "*") {
4933
+ oTarget[sProperty + "@$ui5.noData"] = true;
4934
+ _Helper.fireChange(mChangeListeners, _Helper.buildPath(sPath, sProperty), undefined, true);
4935
+ }
4936
+ });
4937
+ return oTarget;
4938
+ }
4939
+ update(sBasePath, _Helper.buildSelect(aSelect), oOldValue, oNewValue);
4940
+ },
4941
+ updateTransientPaths: function (mMap, sTransientPredicate, sPredicate) {
4942
+ var sPath;
4943
+ for (sPath in mMap) {
4944
+ if (sPath.includes(sTransientPredicate)) {
4945
+ mMap[sPath.replace(sTransientPredicate, sPredicate)] = mMap[sPath];
4946
+ delete mMap[sPath];
4947
+ }
4948
+ }
4949
+ },
4950
+ copySelected: function (oSource, oTarget) {
4951
+ if (oSource["@$ui5.context.isSelected"] === true) {
4952
+ oTarget["@$ui5.context.isSelected"] = true;
4953
+ }
4954
+ },
4955
+ wrapChildQueryOptions: function (sBaseMetaPath, sChildMetaPath, mChildQueryOptions, fnFetchMetadata) {
4956
+ var sExpandSelectPath = "", aMetaPathSegments = sChildMetaPath.split("/"), oProperty, sPropertyMetaPath = sBaseMetaPath, mQueryOptions = {}, mQueryOptionsForPathPrefix = mQueryOptions, i;
4957
+ if (sChildMetaPath === "") {
4958
+ return mChildQueryOptions;
4959
+ }
4960
+ for (i = 0; i < aMetaPathSegments.length; i += 1) {
4961
+ sPropertyMetaPath = _Helper.buildPath(sPropertyMetaPath, aMetaPathSegments[i]);
4962
+ sExpandSelectPath = _Helper.buildPath(sExpandSelectPath, aMetaPathSegments[i]);
4963
+ if (aMetaPathSegments[i].endsWith("*")) {
4964
+ oProperty = null;
4965
+ continue;
4966
+ }
4967
+ oProperty = fnFetchMetadata(sPropertyMetaPath).getResult();
4968
+ if (oProperty.$kind === "NavigationProperty") {
4969
+ mQueryOptionsForPathPrefix.$expand = {};
4970
+ if (i === aMetaPathSegments.length - 1) {
4971
+ mChildQueryOptions = Object.assign({}, mChildQueryOptions);
4972
+ mChildQueryOptions.$select = mChildQueryOptions.$select && mChildQueryOptions.$select.slice();
4973
+ }
4974
+ mQueryOptionsForPathPrefix = mQueryOptionsForPathPrefix.$expand[sExpandSelectPath] = i === aMetaPathSegments.length - 1 ? mChildQueryOptions : {};
4975
+ _Helper.selectKeyProperties(mQueryOptionsForPathPrefix, fnFetchMetadata(sPropertyMetaPath + "/").getResult());
4976
+ sExpandSelectPath = "";
4977
+ } else if (oProperty.$kind !== "Property") {
4978
+ return undefined;
4979
+ }
4980
+ }
4981
+ if (!oProperty || oProperty.$kind === "Property") {
4982
+ if (!fnIsEmptyObject(mChildQueryOptions)) {
4983
+ Log.error("Failed to enhance query options for auto-$expand/$select as the" + " child binding has query options, but its path '" + sChildMetaPath + "' points to a structural property", JSON.stringify(mChildQueryOptions), sClassName$2);
4984
+ return undefined;
4985
+ }
4986
+ _Helper.addToSelect(mQueryOptionsForPathPrefix, [sExpandSelectPath]);
4987
+ }
4988
+ if (("$apply" in mChildQueryOptions)) {
4989
+ Log.debug("Cannot wrap $apply into $expand: " + sChildMetaPath, JSON.stringify(mChildQueryOptions), sClassName$2);
4990
+ return undefined;
4991
+ }
4992
+ return mQueryOptions;
4993
+ }
4994
+ };
4995
+ var _Helper$1 = _Helper;
4996
+
4997
+ var sClassName$1 = "sap.ui.model.odata.v4.lib._MetadataConverter";
4998
+ function _MetadataConverter() {
4999
+ this.aliases = {};
5000
+ this.oAnnotatable = null;
5001
+ this.entityContainer = null;
5002
+ this.entitySet = null;
5003
+ this.namespace = null;
5004
+ this.oOperation = null;
5005
+ this.reference = null;
5006
+ this.schema = null;
5007
+ this.type = null;
5008
+ this.result = null;
5009
+ this.url = null;
5010
+ this.xmlns = null;
5011
+ }
5012
+ _MetadataConverter.prototype.rCollection = /^Collection\((.*)\)$/;
5013
+ _MetadataConverter.prototype.sEdmNamespace = "http://docs.oasis-open.org/odata/ns/edm";
5014
+ _MetadataConverter.prototype.sEdmxNamespace = "http://docs.oasis-open.org/odata/ns/edmx";
5015
+ _MetadataConverter.prototype.addToResult = function (sQualifiedName, vValue) {
5016
+ if ((sQualifiedName in this.result)) {
5017
+ Log.warning("Duplicate qualified name " + sQualifiedName, undefined, sClassName$1);
5018
+ }
5019
+ this.result[sQualifiedName] = vValue;
5020
+ };
5021
+ _MetadataConverter.prototype.annotatable = function (vTarget, sPrefix, sQualifier) {
5022
+ var oAnnotatable, oAnnotations, sPath;
5023
+ if (typeof vTarget === "string") {
5024
+ oAnnotatable = this.oAnnotatable;
5025
+ if (oAnnotatable) {
5026
+ vTarget = _Helper$1.buildPath(oAnnotatable.path, vTarget);
5027
+ }
5028
+ sPath = vTarget;
5029
+ oAnnotations = this.schema.$Annotations;
5030
+ if (oAnnotations && oAnnotations[vTarget]) {
5031
+ vTarget = oAnnotations[vTarget];
5032
+ }
5033
+ }
5034
+ this.oAnnotatable = {
5035
+ parent: this.oAnnotatable,
5036
+ path: sPath,
5037
+ prefix: sPrefix || "",
5038
+ qualifiedName: undefined,
5039
+ qualifier: sQualifier,
5040
+ target: vTarget
5041
+ };
5042
+ };
5043
+ _MetadataConverter.prototype.convertXMLMetadata = function (oDocument, sUrl, bIgnoreAnnotations) {
5044
+ var oElement;
5045
+ oElement = oDocument.documentElement;
5046
+ if (oElement.localName !== "Edmx" || oElement.namespaceURI !== this.sRootNamespace) {
5047
+ throw new Error(sUrl + ": expected <Edmx> in namespace '" + this.sRootNamespace + "'");
5048
+ }
5049
+ this.result = {};
5050
+ this.url = sUrl;
5051
+ this.bIgnoreAnnotations = bIgnoreAnnotations;
5052
+ this.traverse(oElement, this.oAliasConfig);
5053
+ this.traverse(oElement, this.oFullConfig, true);
5054
+ this.finalize();
5055
+ return this.result;
5056
+ };
5057
+ _MetadataConverter.prototype.getAnnotationValue = function (sType, sValue) {
5058
+ var vValue, aValues, i;
5059
+ switch (sType) {
5060
+ case "AnnotationPath":
5061
+ case "NavigationPropertyPath":
5062
+ case "Path":
5063
+ case "PropertyPath":
5064
+ sValue = this.resolveAliasInPath(sValue);
5065
+ case "Binary":
5066
+ case "Date":
5067
+ case "DateTimeOffset":
5068
+ case "Decimal":
5069
+ case "Duration":
5070
+ case "Guid":
5071
+ case "TimeOfDay":
5072
+ case "UrlRef":
5073
+ vValue = {};
5074
+ vValue["$" + sType] = sValue;
5075
+ return vValue;
5076
+ case "Bool":
5077
+ return sValue === "true";
5078
+ case "EnumMember":
5079
+ aValues = sValue.trim().replace(/ +/g, " ").split(" ");
5080
+ for (i = 0; i < aValues.length; i += 1) {
5081
+ aValues[i] = this.resolveAliasInPath(aValues[i]);
5082
+ }
5083
+ return {
5084
+ $EnumMember: aValues.join(" ")
5085
+ };
5086
+ case "Float":
5087
+ if (sValue === "NaN" || sValue === "INF" || sValue === "-INF") {
5088
+ return {
5089
+ $Float: sValue
5090
+ };
5091
+ }
5092
+ return parseFloat(sValue);
5093
+ case "Int":
5094
+ vValue = parseInt(sValue);
5095
+ return _Helper$1.isSafeInteger(vValue) ? vValue : {
5096
+ $Int: sValue
5097
+ };
5098
+ case "String":
5099
+ return sValue;
5100
+ default:
5101
+ return undefined;
5102
+ }
5103
+ };
5104
+ _MetadataConverter.prototype.getInlineAnnotationValue = function (oElement) {
5105
+ var oAttribute, oAttributeList = oElement.attributes, vValue, i;
5106
+ for (i = oAttributeList.length - 1; i >= 0; i -= 1) {
5107
+ oAttribute = oAttributeList.item(i);
5108
+ vValue = this.getAnnotationValue(oAttribute.name, oAttribute.value);
5109
+ if (vValue !== undefined) {
5110
+ return vValue;
5111
+ }
5112
+ }
5113
+ return true;
5114
+ };
5115
+ _MetadataConverter.prototype.getOrCreateArray = function (oParent, sProperty) {
5116
+ var oResult = oParent[sProperty];
5117
+ if (!oResult) {
5118
+ oResult = oParent[sProperty] = [];
5119
+ }
5120
+ return oResult;
5121
+ };
5122
+ _MetadataConverter.prototype.getOrCreateObject = function (oParent, sProperty) {
5123
+ var oResult = oParent[sProperty];
5124
+ if (!oResult) {
5125
+ oResult = oParent[sProperty] = {};
5126
+ }
5127
+ return oResult;
5128
+ };
5129
+ _MetadataConverter.prototype.postProcessAnnotation = function (oElement, aResult) {
5130
+ var oAnnotatable = this.oAnnotatable.parent;
5131
+ if (!this.bIgnoreAnnotations) {
5132
+ oAnnotatable.target[oAnnotatable.qualifiedName] = aResult.length ? aResult[0] : this.getInlineAnnotationValue(oElement);
5133
+ }
5134
+ };
5135
+ _MetadataConverter.prototype.postProcessApply = function (oElement, aResult) {
5136
+ var oResult = this.oAnnotatable.target;
5137
+ oResult.$Apply = aResult;
5138
+ oResult.$Function = this.resolveAlias(oElement.getAttribute("Function"));
5139
+ return oResult;
5140
+ };
5141
+ _MetadataConverter.prototype.postProcessCastOrIsOf = function (oElement, aResult) {
5142
+ var sName = oElement.localName, oResult = this.oAnnotatable.target;
5143
+ oResult["$" + sName] = aResult[0];
5144
+ this.processTypedCollection(oElement.getAttribute("Type"), oResult);
5145
+ this.processFacetAttributes(oElement, oResult);
5146
+ return oResult;
5147
+ };
5148
+ _MetadataConverter.prototype.postProcessCollection = function (_oElement, aResult) {
5149
+ return aResult;
5150
+ };
5151
+ _MetadataConverter.prototype.postProcessLabeledElement = function (oElement, aResult) {
5152
+ var oResult = this.oAnnotatable.target;
5153
+ oResult.$LabeledElement = aResult.length ? aResult[0] : this.getInlineAnnotationValue(oElement);
5154
+ oResult.$Name = oElement.getAttribute("Name");
5155
+ return oResult;
5156
+ };
5157
+ _MetadataConverter.prototype.postProcessLabeledElementReference = function (oElement, _aRes) {
5158
+ return {
5159
+ $LabeledElementReference: this.resolveAlias(oElement.textContent)
5160
+ };
5161
+ };
5162
+ _MetadataConverter.prototype.postProcessLeaf = function (oElement, _aResult) {
5163
+ return this.getAnnotationValue(oElement.localName, oElement.textContent);
5164
+ };
5165
+ _MetadataConverter.prototype.postProcessNot = function (_oElement, aResult) {
5166
+ var oResult = this.oAnnotatable.target;
5167
+ oResult.$Not = aResult[0];
5168
+ return oResult;
5169
+ };
5170
+ _MetadataConverter.prototype.postProcessNull = function (_oElement, _aResult) {
5171
+ var oAnnotatable = this.oAnnotatable, vResult = null;
5172
+ if (oAnnotatable.qualifiedName) {
5173
+ vResult = oAnnotatable.target;
5174
+ vResult.$Null = null;
5175
+ }
5176
+ return vResult;
5177
+ };
5178
+ _MetadataConverter.prototype.postProcessOperation = function (oElement, aResult) {
5179
+ var oResult = this.oAnnotatable.target;
5180
+ oResult["$" + oElement.localName] = aResult;
5181
+ return oResult;
5182
+ };
5183
+ _MetadataConverter.prototype.postProcessPropertyValue = function (oElement, aResult) {
5184
+ return {
5185
+ property: oElement.getAttribute("Property"),
5186
+ value: aResult.length ? aResult[0] : this.getInlineAnnotationValue(oElement)
5187
+ };
5188
+ };
5189
+ _MetadataConverter.prototype.postProcessRecord = function (oElement, aResult) {
5190
+ var oPropertyValue, oResult = this.oAnnotatable.target, oType = oElement.getAttribute("Type"), i;
5191
+ if (oType) {
5192
+ oResult.$Type = this.resolveAlias(oType);
5193
+ }
5194
+ for (i = 0; i < aResult.length; i += 1) {
5195
+ oPropertyValue = aResult[i];
5196
+ oResult[oPropertyValue.property] = oPropertyValue.value;
5197
+ }
5198
+ return oResult;
5199
+ };
5200
+ _MetadataConverter.prototype.postProcessUrlRef = function (_oElement, aResult) {
5201
+ return {
5202
+ $UrlRef: aResult[0]
5203
+ };
5204
+ };
5205
+ _MetadataConverter.prototype.processAlias = function (oElement) {
5206
+ var sAlias = oElement.getAttribute("Alias");
5207
+ if (sAlias) {
5208
+ this.aliases[sAlias] = oElement.getAttribute("Namespace") + ".";
5209
+ }
5210
+ };
5211
+ _MetadataConverter.prototype.processAnnotatableExpression = function (_oElement) {
5212
+ this.annotatable({});
5213
+ };
5214
+ _MetadataConverter.prototype.processAnnotation = function (oElement) {
5215
+ var oAnnotatable = this.oAnnotatable, oAnnotations, sQualifiedName = oAnnotatable.prefix + "@" + this.resolveAlias(oElement.getAttribute("Term")), sQualifier = oAnnotatable.qualifier || oElement.getAttribute("Qualifier");
5216
+ if (sQualifier) {
5217
+ sQualifiedName += "#" + sQualifier;
5218
+ }
5219
+ if (typeof oAnnotatable.target === "string") {
5220
+ oAnnotations = this.getOrCreateObject(this.schema, "$Annotations");
5221
+ if (this.bIgnoreAnnotations) {
5222
+ return;
5223
+ }
5224
+ oAnnotatable.target = oAnnotations[oAnnotatable.target] = {};
5225
+ }
5226
+ oAnnotatable.qualifiedName = sQualifiedName;
5227
+ this.annotatable(oAnnotatable.target, sQualifiedName);
5228
+ };
5229
+ _MetadataConverter.prototype.processAnnotations = function (oElement) {
5230
+ this.annotatable(this.resolveAliasInPath(oElement.getAttribute("Target"), true), undefined, oElement.getAttribute("Qualifier"));
5231
+ };
5232
+ _MetadataConverter.prototype.processAttributes = function (oElement, oTarget, oConfig) {
5233
+ var sProperty, sValue;
5234
+ for (sProperty in oConfig) {
5235
+ sValue = oConfig[sProperty](oElement.getAttribute(sProperty));
5236
+ if (sValue !== undefined && sValue !== null) {
5237
+ oTarget["$" + sProperty] = sValue;
5238
+ }
5239
+ }
5240
+ };
5241
+ _MetadataConverter.prototype.processInclude = function (oElement) {
5242
+ var oInclude = this.getOrCreateArray(this.reference, "$Include");
5243
+ oInclude.push(oElement.getAttribute("Namespace") + ".");
5244
+ };
5245
+ _MetadataConverter.prototype.processIncludeAnnotations = function (oElement) {
5246
+ var oReference = this.reference, oIncludeAnnotation = {
5247
+ $TermNamespace: oElement.getAttribute("TermNamespace") + "."
5248
+ }, aIncludeAnnotations = this.getOrCreateArray(oReference, "$IncludeAnnotations");
5249
+ this.processAttributes(oElement, oIncludeAnnotation, {
5250
+ TargetNamespace: function setValue(sValue) {
5251
+ return sValue ? sValue + "." : sValue;
5252
+ },
5253
+ Qualifier: this.setValue
5254
+ });
5255
+ aIncludeAnnotations.push(oIncludeAnnotation);
5256
+ };
5257
+ _MetadataConverter.prototype.processPropertyValue = function (oElement) {
5258
+ this.annotatable(this.oAnnotatable.target, oElement.getAttribute("Property"));
5259
+ };
5260
+ _MetadataConverter.prototype.processReference = function (oElement) {
5261
+ var oReference = this.getOrCreateObject(this.result, "$Reference");
5262
+ this.reference = oReference[oElement.getAttribute("Uri")] = {};
5263
+ this.annotatable(this.reference);
5264
+ };
5265
+ _MetadataConverter.prototype.resolveAlias = function (sName) {
5266
+ var iDot = sName ? sName.indexOf(".") : -1, sNamespace;
5267
+ if (iDot >= 0 && !sName.includes(".", iDot + 1)) {
5268
+ sNamespace = this.aliases[sName.slice(0, iDot)];
5269
+ if (sNamespace) {
5270
+ return sNamespace + sName.slice(iDot + 1);
5271
+ }
5272
+ }
5273
+ return sName;
5274
+ };
5275
+ _MetadataConverter.prototype.resolveAliasInParentheses = function (bHandleParentheses, sSegment) {
5276
+ var iParentheses = bHandleParentheses ? sSegment.indexOf("(") : -1;
5277
+ if (iParentheses >= 0) {
5278
+ return this.resolveAlias(sSegment.slice(0, iParentheses)) + "(" + sSegment.slice(iParentheses + 1, -1).split(",").map(this.resolveAliasInParentheses.bind(this, bHandleParentheses)).join(",") + ")";
5279
+ }
5280
+ return this.resolveAlias(sSegment);
5281
+ };
5282
+ _MetadataConverter.prototype.resolveAliasInPath = function (sPath, bHandleParentheses) {
5283
+ var iAt, sTerm = "";
5284
+ if (!sPath.includes(".")) {
5285
+ return sPath;
5286
+ }
5287
+ iAt = sPath.indexOf("@");
5288
+ if (iAt >= 0) {
5289
+ sTerm = "@" + this.resolveAlias(sPath.slice(iAt + 1));
5290
+ sPath = sPath.slice(0, iAt);
5291
+ }
5292
+ return sPath.split("/").map(this.resolveAliasInParentheses.bind(this, bHandleParentheses)).join("/") + sTerm;
5293
+ };
5294
+ _MetadataConverter.prototype.setIfFalse = function (sValue) {
5295
+ return sValue === "false" ? false : undefined;
5296
+ };
5297
+ _MetadataConverter.prototype.setIfTrue = function (sValue) {
5298
+ return sValue === "true" ? true : undefined;
5299
+ };
5300
+ _MetadataConverter.prototype.setNumber = function (sValue) {
5301
+ return sValue ? parseInt(sValue) : undefined;
5302
+ };
5303
+ _MetadataConverter.prototype.setValue = function (sValue) {
5304
+ return sValue;
5305
+ };
5306
+ _MetadataConverter.prototype.traverse = function (oElement, oConfig, bUseProcessElementHook) {
5307
+ var oAnnotatable = this.oAnnotatable, oChildConfig, oChildList = oElement.childNodes, oChildNode, vChildResult, aIncludes, sName, sPreviousNamespace = this.xmlns, vResult, aResult = [], sXmlNamespace = oConfig.__xmlns || this.xmlns, i, j;
5308
+ if (sXmlNamespace && sXmlNamespace !== oElement.namespaceURI) {
5309
+ return undefined;
5310
+ }
5311
+ this.xmlns = sXmlNamespace;
5312
+ if (bUseProcessElementHook) {
5313
+ this.processElement(oElement, oConfig.__processor);
5314
+ } else if (oConfig.__processor) {
5315
+ oConfig.__processor.call(this, oElement);
5316
+ }
5317
+ for (i = 0; i < oChildList.length; i += 1) {
5318
+ oChildNode = oChildList.item(i);
5319
+ if (oChildNode.nodeType === 1) {
5320
+ sName = oChildNode.localName;
5321
+ oChildConfig = oConfig[sName];
5322
+ if (!oChildConfig && oConfig.__include) {
5323
+ aIncludes = oConfig.__include;
5324
+ for (j = 0; j < aIncludes.length; j += 1) {
5325
+ oChildConfig = aIncludes[j][sName];
5326
+ if (oChildConfig) {
5327
+ break;
5328
+ }
5329
+ }
5330
+ }
5331
+ if (oChildConfig) {
5332
+ vChildResult = this.traverse(oChildNode, oChildConfig, bUseProcessElementHook);
5333
+ if (vChildResult !== undefined && oConfig.__postProcessor) {
5334
+ aResult.push(vChildResult);
5335
+ }
5336
+ }
5337
+ }
5338
+ }
5339
+ if (oConfig.__postProcessor) {
5340
+ vResult = oConfig.__postProcessor.call(this, oElement, aResult);
5341
+ }
5342
+ this.oAnnotatable = oAnnotatable;
5343
+ this.xmlns = sPreviousNamespace;
5344
+ return vResult;
5345
+ };
5346
+ (function ($$) {
5347
+ var aAnnotatableExpressionInclude, oAnnotationExpressionConfig, oAnnotationLeafConfig, aExpressionInclude, oOperatorConfig;
5348
+ oAnnotationLeafConfig = {
5349
+ AnnotationPath: {
5350
+ __postProcessor: $$.postProcessLeaf
5351
+ },
5352
+ Binary: {
5353
+ __postProcessor: $$.postProcessLeaf
5354
+ },
5355
+ Bool: {
5356
+ __postProcessor: $$.postProcessLeaf
5357
+ },
5358
+ Date: {
5359
+ __postProcessor: $$.postProcessLeaf
5360
+ },
5361
+ DateTimeOffset: {
5362
+ __postProcessor: $$.postProcessLeaf
5363
+ },
5364
+ Decimal: {
5365
+ __postProcessor: $$.postProcessLeaf
5366
+ },
5367
+ Duration: {
5368
+ __postProcessor: $$.postProcessLeaf
5369
+ },
5370
+ EnumMember: {
5371
+ __postProcessor: $$.postProcessLeaf
5372
+ },
5373
+ Float: {
5374
+ __postProcessor: $$.postProcessLeaf
5375
+ },
5376
+ Guid: {
5377
+ __postProcessor: $$.postProcessLeaf
5378
+ },
5379
+ Int: {
5380
+ __postProcessor: $$.postProcessLeaf
5381
+ },
5382
+ LabeledElementReference: {
5383
+ __postProcessor: $$.postProcessLabeledElementReference
5384
+ },
5385
+ NavigationPropertyPath: {
5386
+ __postProcessor: $$.postProcessLeaf
5387
+ },
5388
+ Path: {
5389
+ __postProcessor: $$.postProcessLeaf
5390
+ },
5391
+ PropertyPath: {
5392
+ __postProcessor: $$.postProcessLeaf
5393
+ },
5394
+ String: {
5395
+ __postProcessor: $$.postProcessLeaf
5396
+ },
5397
+ TimeOfDay: {
5398
+ __postProcessor: $$.postProcessLeaf
5399
+ }
5400
+ };
5401
+ aExpressionInclude = [oAnnotationLeafConfig];
5402
+ $$.oAnnotationConfig = {
5403
+ Annotation: {
5404
+ __xmlns: $$.sEdmNamespace,
5405
+ __processor: $$.processAnnotation,
5406
+ __postProcessor: $$.postProcessAnnotation,
5407
+ __include: aExpressionInclude
5408
+ }
5409
+ };
5410
+ aAnnotatableExpressionInclude = [oAnnotationLeafConfig, $$.oAnnotationConfig];
5411
+ oOperatorConfig = {
5412
+ __processor: $$.processAnnotatableExpression,
5413
+ __postProcessor: $$.postProcessOperation,
5414
+ __include: aAnnotatableExpressionInclude
5415
+ };
5416
+ oAnnotationExpressionConfig = {
5417
+ And: oOperatorConfig,
5418
+ Apply: {
5419
+ __processor: $$.processAnnotatableExpression,
5420
+ __postProcessor: $$.postProcessApply,
5421
+ __include: aAnnotatableExpressionInclude
5422
+ },
5423
+ Cast: {
5424
+ __processor: $$.processAnnotatableExpression,
5425
+ __postProcessor: $$.postProcessCastOrIsOf,
5426
+ __include: aAnnotatableExpressionInclude
5427
+ },
5428
+ Collection: {
5429
+ __postProcessor: $$.postProcessCollection,
5430
+ __include: aExpressionInclude
5431
+ },
5432
+ Eq: oOperatorConfig,
5433
+ Ge: oOperatorConfig,
5434
+ Gt: oOperatorConfig,
5435
+ If: oOperatorConfig,
5436
+ IsOf: {
5437
+ __processor: $$.processAnnotatableExpression,
5438
+ __postProcessor: $$.postProcessCastOrIsOf,
5439
+ __include: aAnnotatableExpressionInclude
5440
+ },
5441
+ LabeledElement: {
5442
+ __processor: $$.processAnnotatableExpression,
5443
+ __postProcessor: $$.postProcessLabeledElement,
5444
+ __include: aAnnotatableExpressionInclude
5445
+ },
5446
+ Le: oOperatorConfig,
5447
+ Lt: oOperatorConfig,
5448
+ Ne: oOperatorConfig,
5449
+ Null: {
5450
+ __processor: $$.processAnnotatableExpression,
5451
+ __postProcessor: $$.postProcessNull,
5452
+ __include: [$$.oAnnotationConfig]
5453
+ },
5454
+ Not: {
5455
+ __processor: $$.processAnnotatableExpression,
5456
+ __postProcessor: $$.postProcessNot,
5457
+ __include: aAnnotatableExpressionInclude
5458
+ },
5459
+ Or: oOperatorConfig,
5460
+ Record: {
5461
+ __processor: $$.processAnnotatableExpression,
5462
+ __postProcessor: $$.postProcessRecord,
5463
+ __include: [$$.oAnnotationConfig],
5464
+ PropertyValue: {
5465
+ __processor: $$.processPropertyValue,
5466
+ __postProcessor: $$.postProcessPropertyValue,
5467
+ __include: aAnnotatableExpressionInclude
5468
+ }
5469
+ },
5470
+ UrlRef: {
5471
+ __postProcessor: $$.postProcessUrlRef,
5472
+ __include: aExpressionInclude
5473
+ }
5474
+ };
5475
+ $$.oAnnotationsConfig = {
5476
+ Annotations: {
5477
+ __processor: $$.processAnnotations,
5478
+ __include: [$$.oAnnotationConfig]
5479
+ }
5480
+ };
5481
+ aExpressionInclude.push(oAnnotationExpressionConfig);
5482
+ aAnnotatableExpressionInclude.push(oAnnotationExpressionConfig);
5483
+ $$.oAnnotationConfig.Annotation.Annotation = $$.oAnnotationConfig.Annotation;
5484
+ $$.oReferenceInclude = {
5485
+ Reference: {
5486
+ __xmlns: $$.sEdmxNamespace,
5487
+ __processor: $$.processReference,
5488
+ __include: [$$.oAnnotationConfig],
5489
+ Include: {
5490
+ __processor: $$.processInclude
5491
+ },
5492
+ IncludeAnnotations: {
5493
+ __processor: $$.processIncludeAnnotations
5494
+ }
5495
+ }
5496
+ };
5497
+ })(_MetadataConverter.prototype);
5498
+
5499
+ var sClassName = "sap.ui.model.odata.v4.lib._V2MetadataConverter", rHttpMethods = /^(?:DELETE|GET|MERGE|PATCH|POST|PUT)$/, sEdmxNamespace = "http://schemas.microsoft.com/ado/2007/06/edmx", sMicrosoftNamespace = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata", sSapNamespace = "http://www.sap.com/Protocols/SAPData", mV2toV4 = {
5500
+ creatable: {
5501
+ property: "Insertable",
5502
+ term: "@Org.OData.Capabilities.V1.InsertRestrictions"
5503
+ },
5504
+ deletable: {
5505
+ property: "Deletable",
5506
+ term: "@Org.OData.Capabilities.V1.DeleteRestrictions"
5507
+ },
5508
+ "deletable-path": {
5509
+ property: "Deletable",
5510
+ term: "@Org.OData.Capabilities.V1.DeleteRestrictions"
5511
+ },
5512
+ "field-control": {
5513
+ term: "@com.sap.vocabularies.Common.v1.FieldControl"
5514
+ },
5515
+ heading: {
5516
+ term: "@com.sap.vocabularies.Common.v1.Heading"
5517
+ },
5518
+ label: {
5519
+ term: "@com.sap.vocabularies.Common.v1.Label"
5520
+ },
5521
+ precision: {
5522
+ term: "@Org.OData.Measures.V1.Scale"
5523
+ },
5524
+ quickinfo: {
5525
+ term: "@com.sap.vocabularies.Common.v1.QuickInfo"
5526
+ },
5527
+ "requires-filter": {
5528
+ property: "RequiresFilter",
5529
+ term: "@Org.OData.Capabilities.V1.FilterRestrictions"
5530
+ },
5531
+ searchable: {
5532
+ property: "Searchable",
5533
+ term: "@Org.OData.Capabilities.V1.SearchRestrictions"
5534
+ },
5535
+ text: {
5536
+ term: "@com.sap.vocabularies.Common.v1.Text"
5537
+ },
5538
+ topable: {
5539
+ term: "@Org.OData.Capabilities.V1.TopSupported"
5540
+ },
5541
+ updatable: {
5542
+ property: "Updatable",
5543
+ term: "@Org.OData.Capabilities.V1.UpdateRestrictions"
5544
+ },
5545
+ "updatable-path": {
5546
+ property: "Updatable",
5547
+ term: "@Org.OData.Capabilities.V1.UpdateRestrictions"
5548
+ }
5549
+ }, mV2toV4ComplexSemantics = {
5550
+ bday: {
5551
+ TermName: "Contact"
5552
+ },
5553
+ city: {
5554
+ Path: "adr",
5555
+ TermName: "Contact",
5556
+ V4Attribute: "locality"
5557
+ },
5558
+ country: {
5559
+ Path: "adr",
5560
+ TermName: "Contact"
5561
+ },
5562
+ email: {
5563
+ Path: "address",
5564
+ TermName: "Contact",
5565
+ V4Attribute: "uri",
5566
+ typeMapping: {
5567
+ home: "home",
5568
+ pref: "preferred",
5569
+ work: "work"
5570
+ },
5571
+ v4EnumType: "com.sap.vocabularies.Communication.v1.ContactInformationType",
5572
+ v4PropertyAnnotation: "@com.sap.vocabularies.Communication.v1.IsEmailAddress"
5573
+ },
5574
+ familyname: {
5575
+ Path: "n",
5576
+ TermName: "Contact",
5577
+ V4Attribute: "surname"
5578
+ },
5579
+ givenname: {
5580
+ Path: "n",
5581
+ TermName: "Contact",
5582
+ V4Attribute: "given"
5583
+ },
5584
+ honorific: {
5585
+ Path: "n",
5586
+ TermName: "Contact",
5587
+ V4Attribute: "prefix"
5588
+ },
5589
+ middlename: {
5590
+ Path: "n",
5591
+ TermName: "Contact",
5592
+ V4Attribute: "additional"
5593
+ },
5594
+ name: {
5595
+ TermName: "Contact",
5596
+ V4Attribute: "fn"
5597
+ },
5598
+ nickname: {
5599
+ TermName: "Contact"
5600
+ },
5601
+ note: {
5602
+ TermName: "Contact"
5603
+ },
5604
+ org: {
5605
+ TermName: "Contact"
5606
+ },
5607
+ "org-role": {
5608
+ TermName: "Contact",
5609
+ V4Attribute: "role"
5610
+ },
5611
+ "org-unit": {
5612
+ TermName: "Contact",
5613
+ V4Attribute: "orgunit"
5614
+ },
5615
+ photo: {
5616
+ TermName: "Contact"
5617
+ },
5618
+ pobox: {
5619
+ Path: "adr",
5620
+ TermName: "Contact"
5621
+ },
5622
+ region: {
5623
+ Path: "adr",
5624
+ TermName: "Contact"
5625
+ },
5626
+ street: {
5627
+ Path: "adr",
5628
+ TermName: "Contact"
5629
+ },
5630
+ suffix: {
5631
+ Path: "n",
5632
+ TermName: "Contact"
5633
+ },
5634
+ tel: {
5635
+ Path: "tel",
5636
+ TermName: "Contact",
5637
+ V4Attribute: "uri",
5638
+ typeMapping: {
5639
+ cell: "cell",
5640
+ fax: "fax",
5641
+ home: "home",
5642
+ pref: "preferred",
5643
+ video: "video",
5644
+ voice: "voice",
5645
+ work: "work"
5646
+ },
5647
+ v4EnumType: "com.sap.vocabularies.Communication.v1.PhoneType",
5648
+ v4PropertyAnnotation: "@com.sap.vocabularies.Communication.v1.IsPhoneNumber"
5649
+ },
5650
+ title: {
5651
+ TermName: "Contact"
5652
+ },
5653
+ zip: {
5654
+ Path: "adr",
5655
+ TermName: "Contact",
5656
+ V4Attribute: "code"
5657
+ },
5658
+ class: {
5659
+ TermName: "Event"
5660
+ },
5661
+ dtend: {
5662
+ TermName: "Event"
5663
+ },
5664
+ dtstart: {
5665
+ TermName: "Event"
5666
+ },
5667
+ duration: {
5668
+ TermName: "Event"
5669
+ },
5670
+ fbtype: {
5671
+ TermName: "Event"
5672
+ },
5673
+ location: {
5674
+ TermName: "Event"
5675
+ },
5676
+ status: {
5677
+ TermName: "Event"
5678
+ },
5679
+ transp: {
5680
+ TermName: "Event"
5681
+ },
5682
+ wholeday: {
5683
+ TermName: "Event"
5684
+ },
5685
+ body: {
5686
+ TermName: "Message"
5687
+ },
5688
+ from: {
5689
+ TermName: "Message"
5690
+ },
5691
+ received: {
5692
+ TermName: "Message"
5693
+ },
5694
+ sender: {
5695
+ TermName: "Message"
5696
+ },
5697
+ subject: {
5698
+ TermName: "Message"
5699
+ },
5700
+ completed: {
5701
+ TermName: "Task"
5702
+ },
5703
+ due: {
5704
+ TermName: "Task"
5705
+ },
5706
+ "percent-complete": {
5707
+ TermName: "Task",
5708
+ V4Attribute: "percentcomplete"
5709
+ },
5710
+ priority: {
5711
+ TermName: "Task"
5712
+ }
5713
+ }, mV2toV4SimpleSemantics = {
5714
+ fiscalyear: "@com.sap.vocabularies.Common.v1.IsFiscalYear",
5715
+ fiscalyearperiod: "@com.sap.vocabularies.Common.v1.IsFiscalYearPeriod",
5716
+ year: "@com.sap.vocabularies.Common.v1.IsCalendarYear",
5717
+ yearmonth: "@com.sap.vocabularies.Common.v1.IsCalendarYearMonth",
5718
+ yearmonthday: "@com.sap.vocabularies.Common.v1.IsCalendarDate",
5719
+ yearquarter: "@com.sap.vocabularies.Common.v1.IsCalendarYearQuarter",
5720
+ yearweek: "@com.sap.vocabularies.Common.v1.IsCalendarYearWeek",
5721
+ url: "@Org.OData.Core.V1.IsURL"
5722
+ };
5723
+ function Annotatable(oConverter, sTarget) {
5724
+ var oParent = oConverter.oAnnotatable;
5725
+ if (oParent) {
5726
+ sTarget = _Helper$1.buildPath(oParent.sPath, sTarget);
5727
+ }
5728
+ this.oConverter = oConverter;
5729
+ this.sPath = sTarget;
5730
+ this.oParent = oParent;
5731
+ this.mSapAttributes = oConverter.mSapAttributes;
5732
+ this.mAnnotationsForTarget = null;
5733
+ }
5734
+ Annotatable.prototype.annotate = function (sTerm, vValue) {
5735
+ this.getTarget()[sTerm] = vValue;
5736
+ };
5737
+ Annotatable.prototype.consume = function (sName) {
5738
+ return this.oConverter.consumeSapAnnotation(sName);
5739
+ };
5740
+ Annotatable.prototype.convert = function (sV2Name, vValue) {
5741
+ var oAnnotation, mAnnotationInfo;
5742
+ if (vValue === undefined || vValue === "") {
5743
+ return;
5744
+ }
5745
+ mAnnotationInfo = mV2toV4[sV2Name];
5746
+ if (mAnnotationInfo.property) {
5747
+ oAnnotation = this.getOrCreateAnnotationRecord(mAnnotationInfo.term);
5748
+ oAnnotation[mAnnotationInfo.property] = vValue;
5749
+ } else {
5750
+ this.annotate(mAnnotationInfo.term, vValue);
5751
+ }
5752
+ };
5753
+ Annotatable.prototype.getOrCreateAnnotationRecord = function (sTerm) {
5754
+ return this.oConverter.getOrCreateObject(this.getTarget(), sTerm);
5755
+ };
5756
+ Annotatable.prototype.getTarget = function () {
5757
+ if (!this.mAnnotationsForTarget) {
5758
+ this.mAnnotationsForTarget = this.oConverter.convertedV2Annotations[this.sPath] = {};
5759
+ }
5760
+ return this.mAnnotationsForTarget;
5761
+ };
5762
+ Annotatable.prototype.peek = function (sName) {
5763
+ return this.oConverter.mSapAnnotations[sName];
5764
+ };
5765
+ function _V2MetadataConverter() {
5766
+ this.association = null;
5767
+ this.associations = {};
5768
+ this.associationSet = null;
5769
+ this.associationSets = [];
5770
+ this.aBoundOperations = [];
5771
+ this.constraintRole = null;
5772
+ this.convertedV2Annotations = {};
5773
+ this.defaultEntityContainer = null;
5774
+ this.mEntityContainersOfSchema = {};
5775
+ this.mEntityType2EntitySetAnnotation = {};
5776
+ this.mProperty2Semantics = {};
5777
+ this.sPropertyName = null;
5778
+ this.navigationProperties = [];
5779
+ this.mSapAnnotations = {};
5780
+ this.sTypeName = null;
5781
+ this.mProperty2Unit = {};
5782
+ _MetadataConverter.call(this);
5783
+ }
5784
+ _V2MetadataConverter.prototype = Object.create(_MetadataConverter.prototype);
5785
+ _V2MetadataConverter.prototype.collectSapAnnotations = function (oElement) {
5786
+ var oAttribute, oAttributeList = oElement.attributes, i, n;
5787
+ this.mSapAnnotations = {};
5788
+ for ((i = 0, n = oAttributeList.length); i < n; i += 1) {
5789
+ oAttribute = oAttributeList.item(i);
5790
+ if (oAttribute.namespaceURI === sSapNamespace && oAttribute.localName !== "content-version") {
5791
+ this.mSapAnnotations[oAttribute.localName] = oAttribute.value;
5792
+ }
5793
+ }
5794
+ };
5795
+ _V2MetadataConverter.prototype.consumeSapAnnotation = function (sName) {
5796
+ var sValue = this.mSapAnnotations[sName];
5797
+ delete this.mSapAnnotations[sName];
5798
+ return sValue;
5799
+ };
5800
+ _V2MetadataConverter.prototype.convertEntitySetAnnotation = function (oAnnotatable, sName) {
5801
+ var sConflictingV2Annotation, sValue;
5802
+ switch (sName) {
5803
+ case "creatable":
5804
+ case "deletable":
5805
+ case "updatable":
5806
+ if (oAnnotatable.peek(sName) === "false") {
5807
+ oAnnotatable.convert(sName, false);
5808
+ }
5809
+ break;
5810
+ case "deletable-path":
5811
+ case "updatable-path":
5812
+ sConflictingV2Annotation = sName.slice(0, 9);
5813
+ sValue = oAnnotatable.consume(sName);
5814
+ if (oAnnotatable.peek(sConflictingV2Annotation)) {
5815
+ oAnnotatable.convert(sName, false);
5816
+ Log.warning("Inconsistent metadata in '" + this.url + "'", "Use either 'sap:" + sConflictingV2Annotation + "' or 'sap:" + sConflictingV2Annotation + "-path'" + " at entity set '" + oAnnotatable.sPath + "'", sClassName);
5817
+ } else {
5818
+ oAnnotatable.convert(sName, {
5819
+ $Path: sValue
5820
+ });
5821
+ }
5822
+ break;
5823
+ case "label":
5824
+ this.convertLabel(oAnnotatable);
5825
+ break;
5826
+ case "pageable":
5827
+ sValue = oAnnotatable.consume(sName);
5828
+ if (sValue === "false") {
5829
+ oAnnotatable.annotate("@Org.OData.Capabilities.V1.SkipSupported", false);
5830
+ oAnnotatable.annotate("@Org.OData.Capabilities.V1.TopSupported", false);
5831
+ }
5832
+ break;
5833
+ case "requires-filter":
5834
+ sValue = oAnnotatable.consume(sName);
5835
+ if (sValue === "true") {
5836
+ oAnnotatable.convert(sName, true);
5837
+ }
5838
+ break;
5839
+ case "topable":
5840
+ sValue = oAnnotatable.consume(sName);
5841
+ if (sValue === "false") {
5842
+ oAnnotatable.convert(sName, false);
5843
+ }
5844
+ break;
5845
+ }
5846
+ };
5847
+ _V2MetadataConverter.prototype.convertLabel = function (oAnnotatable) {
5848
+ oAnnotatable.convert("label", oAnnotatable.consume("label"));
5849
+ };
5850
+ _V2MetadataConverter.prototype.convertPropertyAnnotation = function (oAnnotatable, sName) {
5851
+ var sValue;
5852
+ switch (sName) {
5853
+ case "heading":
5854
+ case "label":
5855
+ case "quickinfo":
5856
+ oAnnotatable.convert(sName, oAnnotatable.consume(sName));
5857
+ break;
5858
+ case "field-control":
5859
+ case "precision":
5860
+ case "text":
5861
+ oAnnotatable.convert(sName, {
5862
+ $Path: oAnnotatable.consume(sName)
5863
+ });
5864
+ break;
5865
+ case "aggregation-role":
5866
+ sValue = oAnnotatable.consume(sName);
5867
+ if (sValue === "dimension") {
5868
+ oAnnotatable.annotate("@com.sap.vocabularies.Analytics.v1.Dimension", true);
5869
+ } else if (sValue === "measure") {
5870
+ oAnnotatable.annotate("@com.sap.vocabularies.Analytics.v1.Measure", true);
5871
+ }
5872
+ break;
5873
+ case "display-format":
5874
+ sValue = oAnnotatable.consume(sName);
5875
+ if (sValue === "NonNegative") {
5876
+ oAnnotatable.annotate("@com.sap.vocabularies.Common.v1.IsDigitSequence", true);
5877
+ } else if (sValue === "UpperCase") {
5878
+ oAnnotatable.annotate("@com.sap.vocabularies.Common.v1.IsUpperCase", true);
5879
+ }
5880
+ break;
5881
+ case "semantics":
5882
+ this.convertPropertySemanticsAnnotation(oAnnotatable);
5883
+ break;
5884
+ case "unit":
5885
+ this.mProperty2Unit[oAnnotatable.sPath] = oAnnotatable.consume("unit");
5886
+ break;
5887
+ case "visible":
5888
+ sValue = oAnnotatable.consume(sName);
5889
+ if (sValue === "false") {
5890
+ oAnnotatable.annotate("@com.sap.vocabularies.UI.v1.Hidden", true);
5891
+ oAnnotatable.annotate("@com.sap.vocabularies.Common.v1.FieldControl", {
5892
+ $EnumMember: "com.sap.vocabularies.Common.v1.FieldControlType/Hidden"
5893
+ });
5894
+ }
5895
+ break;
5896
+ }
5897
+ };
5898
+ _V2MetadataConverter.prototype.convertPropertySemanticsAnnotation = function (oAnnotatable) {
5899
+ var oAnnotations, sEnum, oPath, aResult, oSemantics, aValue = oAnnotatable.peek("semantics").split(";"), sValue = aValue[0], oV2toV4ComplexSemantic = mV2toV4ComplexSemantics[sValue];
5900
+ if (sValue === "unit-of-measure" || sValue === "currency-code") {
5901
+ this.mProperty2Semantics[oAnnotatable.sPath] = oAnnotatable.consume("semantics");
5902
+ } else if (mV2toV4SimpleSemantics[sValue]) {
5903
+ oAnnotatable.annotate(mV2toV4SimpleSemantics[sValue], true);
5904
+ oAnnotatable.consume("semantics");
5905
+ } else if (oV2toV4ComplexSemantic) {
5906
+ oPath = {
5907
+ $Path: this.sPropertyName
5908
+ };
5909
+ oAnnotations = oAnnotatable.oParent.getOrCreateAnnotationRecord("@com.sap.vocabularies.Communication.v1." + oV2toV4ComplexSemantic.TermName);
5910
+ if (oV2toV4ComplexSemantic.Path) {
5911
+ oSemantics = this.getOrCreateObject(oAnnotations, oV2toV4ComplexSemantic.Path);
5912
+ oSemantics[oV2toV4ComplexSemantic.V4Attribute || sValue] = oPath;
5913
+ if (oV2toV4ComplexSemantic.v4PropertyAnnotation) {
5914
+ oAnnotatable.annotate(oV2toV4ComplexSemantic.v4PropertyAnnotation, true);
5915
+ if (aValue[1]) {
5916
+ aResult = [];
5917
+ sEnum = aValue[1].split("=")[1];
5918
+ sEnum.split(",").forEach(function (sType) {
5919
+ var sTargetType = oV2toV4ComplexSemantic.typeMapping[sType];
5920
+ if (sTargetType) {
5921
+ aResult.push(oV2toV4ComplexSemantic.v4EnumType + "/" + sTargetType);
5922
+ } else {
5923
+ Log.warning("Unsupported semantic type: " + sType, undefined, sClassName);
5924
+ }
5925
+ });
5926
+ if (aResult.length) {
5927
+ oSemantics.type = {
5928
+ EnumMember: aResult.join(" ")
5929
+ };
5930
+ }
5931
+ }
5932
+ oAnnotations[oV2toV4ComplexSemantic.Path] = [oSemantics];
5933
+ } else {
5934
+ oAnnotations[oV2toV4ComplexSemantic.Path] = oSemantics;
5935
+ }
5936
+ } else {
5937
+ oAnnotations[oV2toV4ComplexSemantic.V4Attribute || sValue] = oPath;
5938
+ }
5939
+ oAnnotatable.consume("semantics");
5940
+ }
5941
+ };
5942
+ _V2MetadataConverter.prototype.finalize = function () {
5943
+ this.result.$Version = "4.0";
5944
+ this.setDefaultEntityContainer();
5945
+ this.updateNavigationPropertiesAndCreateBindings();
5946
+ this.processBoundOperations();
5947
+ this.processUnitConversion();
5948
+ };
5949
+ _V2MetadataConverter.prototype.mergeAnnotations = function (mConvertedV2Annotations, mV4Annotations) {
5950
+ var sAnnotatablePath;
5951
+ for (sAnnotatablePath in mConvertedV2Annotations) {
5952
+ if ((sAnnotatablePath in mV4Annotations)) {
5953
+ mV4Annotations[sAnnotatablePath] = Object.assign(mConvertedV2Annotations[sAnnotatablePath], mV4Annotations[sAnnotatablePath]);
5954
+ } else {
5955
+ mV4Annotations[sAnnotatablePath] = mConvertedV2Annotations[sAnnotatablePath];
5956
+ }
5957
+ }
5958
+ };
5959
+ _V2MetadataConverter.prototype.postProcessSchema = function (_oElement, _aResult) {
5960
+ var mAnnotations, oEntityContainer, sEntityContainerName, oEntitySet, sEntitySetName, sTarget;
5961
+ for (sEntityContainerName in this.mEntityContainersOfSchema) {
5962
+ oEntityContainer = this.mEntityContainersOfSchema[sEntityContainerName];
5963
+ for (sEntitySetName in oEntityContainer) {
5964
+ oEntitySet = oEntityContainer[sEntitySetName];
5965
+ if (oEntitySet.$kind !== "EntitySet") {
5966
+ continue;
5967
+ }
5968
+ sTarget = sEntityContainerName + "/" + sEntitySetName;
5969
+ mAnnotations = _Helper$1.merge(this.convertedV2Annotations[sTarget] || ({}), this.mEntityType2EntitySetAnnotation[oEntitySet.$Type]);
5970
+ if (!_Helper$1.isEmptyObject(mAnnotations)) {
5971
+ this.convertedV2Annotations[sTarget] = mAnnotations;
5972
+ }
5973
+ }
5974
+ }
5975
+ if (this.bIgnoreAnnotations) {
5976
+ if (!_Helper$1.isEmptyObject(this.convertedV2Annotations)) {
5977
+ this.schema.$Annotations = {};
5978
+ }
5979
+ } else if (this.schema.$Annotations) {
5980
+ this.mergeAnnotations(this.convertedV2Annotations, this.schema.$Annotations);
5981
+ } else if (!_Helper$1.isEmptyObject(this.convertedV2Annotations)) {
5982
+ this.schema.$Annotations = this.convertedV2Annotations;
5983
+ }
5984
+ this.convertedV2Annotations = {};
5985
+ this.mEntityContainersOfSchema = {};
5986
+ };
5987
+ _V2MetadataConverter.prototype.processAssociation = function (oElement) {
5988
+ var sName = this.namespace + oElement.getAttribute("Name");
5989
+ this.associations[sName] = this.association = {
5990
+ referentialConstraint: null,
5991
+ roles: {}
5992
+ };
5993
+ };
5994
+ _V2MetadataConverter.prototype.processAssociationEnd = function (oElement) {
5995
+ var sName = oElement.getAttribute("Role");
5996
+ this.association.roles[sName] = {
5997
+ multiplicity: oElement.getAttribute("Multiplicity"),
5998
+ propertyName: undefined,
5999
+ typeName: this.resolveAlias(oElement.getAttribute("Type"))
6000
+ };
6001
+ };
6002
+ _V2MetadataConverter.prototype.processAssociationSet = function (oElement) {
6003
+ var oAssociationSet = {
6004
+ associationName: this.resolveAlias(oElement.getAttribute("Association")),
6005
+ ends: [],
6006
+ entityContainer: this.entityContainer
6007
+ };
6008
+ this.associationSet = oAssociationSet;
6009
+ this.associationSets.push(oAssociationSet);
6010
+ this.consumeSapAnnotation("creatable");
6011
+ this.consumeSapAnnotation("deletable");
6012
+ this.consumeSapAnnotation("updatable");
6013
+ };
6014
+ _V2MetadataConverter.prototype.processAssociationSetEnd = function (oElement) {
6015
+ this.associationSet.ends.push({
6016
+ entitySetName: oElement.getAttribute("EntitySet"),
6017
+ roleName: oElement.getAttribute("Role")
6018
+ });
6019
+ };
6020
+ _V2MetadataConverter.prototype.processComplexType = function (oElement) {
6021
+ this.processType(oElement, {
6022
+ $kind: "ComplexType"
6023
+ });
6024
+ };
6025
+ _V2MetadataConverter.prototype.processDataServices = function (oElement) {
6026
+ if (oElement.getAttributeNS(sMicrosoftNamespace, "DataServiceVersion") !== "2.0") {
6027
+ throw new Error(this.url + ": expected DataServiceVersion=\"2.0\": " + serializeSingleElement(oElement));
6028
+ }
6029
+ };
6030
+ _V2MetadataConverter.prototype.processDependent = function (oElement) {
6031
+ var oConstraint = this.association.referentialConstraint;
6032
+ this.constraintRole = oConstraint.dependent = {
6033
+ roleName: oElement.getAttribute("Role")
6034
+ };
6035
+ };
6036
+ _V2MetadataConverter.prototype.processElement = function (oElement, fnProcessor) {
6037
+ this.collectSapAnnotations(oElement);
6038
+ if (fnProcessor) {
6039
+ fnProcessor.call(this, oElement);
6040
+ }
6041
+ this.warnUnsupportedSapAnnotations(oElement);
6042
+ };
6043
+ _V2MetadataConverter.prototype.processEntityContainer = function (oElement) {
6044
+ var sQualifiedName = this.namespace + oElement.getAttribute("Name");
6045
+ this.mEntityContainersOfSchema[sQualifiedName] = this.entityContainer = {
6046
+ $kind: "EntityContainer"
6047
+ };
6048
+ this.addToResult(sQualifiedName, this.entityContainer);
6049
+ if (oElement.getAttributeNS(sMicrosoftNamespace, "IsDefaultEntityContainer") === "true") {
6050
+ this.defaultEntityContainer = sQualifiedName;
6051
+ }
6052
+ this.v2annotatable(sQualifiedName);
6053
+ };
6054
+ _V2MetadataConverter.prototype.processEntitySet = function (oElement) {
6055
+ var oAnnotatable, sName = oElement.getAttribute("Name");
6056
+ this.entityContainer[sName] = this.entitySet = {
6057
+ $kind: "EntitySet",
6058
+ $Type: this.resolveAlias(oElement.getAttribute("EntityType"))
6059
+ };
6060
+ oAnnotatable = this.v2annotatable(sName, this.convertEntitySetAnnotation);
6061
+ oAnnotatable.consume("creatable");
6062
+ oAnnotatable.consume("deletable");
6063
+ oAnnotatable.consume("updatable");
6064
+ if (oAnnotatable.consume("searchable") !== "true") {
6065
+ oAnnotatable.convert("searchable", false);
6066
+ }
6067
+ };
6068
+ _V2MetadataConverter.prototype.processEntityType = function (oElement) {
6069
+ var oType = {
6070
+ $kind: "EntityType"
6071
+ }, that = this;
6072
+ this.processType(oElement, oType);
6073
+ this.processAttributes(oElement, oType, {
6074
+ Abstract: this.setIfTrue,
6075
+ BaseType: function (sType) {
6076
+ return sType ? that.resolveAlias(sType) : undefined;
6077
+ }
6078
+ });
6079
+ this.convertLabel(this.oAnnotatable);
6080
+ };
6081
+ _V2MetadataConverter.prototype.processEntityTypeKeyPropertyRef = function (oElement) {
6082
+ var sName = oElement.getAttribute("Name");
6083
+ this.getOrCreateArray(this.type, "$Key").push(sName);
6084
+ };
6085
+ _V2MetadataConverter.prototype.processFacetAttributes = function (oElement, oResult) {
6086
+ var that = this;
6087
+ this.processAttributes(oElement, oResult, {
6088
+ DefaultValue: this.setValue,
6089
+ MaxLength: function (sValue) {
6090
+ return sValue === "Max" ? undefined : that.setNumber(sValue);
6091
+ },
6092
+ Nullable: this.setIfFalse,
6093
+ Precision: this.setNumber,
6094
+ Scale: this.setNumber,
6095
+ Unicode: this.setIfFalse
6096
+ });
6097
+ if (oElement.getAttribute("FixedLength") === "false") {
6098
+ oResult.$Scale = "variable";
6099
+ }
6100
+ };
6101
+ _V2MetadataConverter.prototype.processFunctionImport = function (oElement) {
6102
+ var sAnnotationActionFor, sHttpMethod = oElement.getAttributeNS(sMicrosoftNamespace, "HttpMethod"), sKind = sHttpMethod !== "GET" ? "Action" : "Function", sLabel, sName = oElement.getAttribute("Name"), oOperation = {
6103
+ $kind: sKind
6104
+ }, oOperationImport = {
6105
+ $kind: sKind + "Import"
6106
+ }, sQualifiedName = this.namespace + sName, sReturnType = oElement.getAttribute("ReturnType"), oReturnType;
6107
+ oOperationImport["$" + sKind] = sQualifiedName;
6108
+ this.processAttributes(oElement, oOperationImport, {
6109
+ EntitySet: this.setValue
6110
+ });
6111
+ if (sReturnType) {
6112
+ oOperation.$ReturnType = oReturnType = {};
6113
+ this.processTypedCollection(sReturnType, oReturnType);
6114
+ }
6115
+ if (!rHttpMethods.test(sHttpMethod)) {
6116
+ Log.warning("Unsupported HttpMethod at FunctionImport '" + sName + "', removing this FunctionImport", undefined, sClassName);
6117
+ this.consumeSapAnnotation("action-for");
6118
+ this.consumeSapAnnotation("applicable-path");
6119
+ } else {
6120
+ if (sHttpMethod !== "GET" && sHttpMethod !== "POST") {
6121
+ oOperation.$v2HttpMethod = sHttpMethod;
6122
+ }
6123
+ this.addToResult(sQualifiedName, [oOperation]);
6124
+ sAnnotationActionFor = this.consumeSapAnnotation("action-for");
6125
+ if (sAnnotationActionFor) {
6126
+ oOperation.$IsBound = true;
6127
+ oOperation.$Parameter = [{
6128
+ $Name: null,
6129
+ $Nullable: false,
6130
+ $Type: this.resolveAlias(sAnnotationActionFor)
6131
+ }];
6132
+ this.aBoundOperations.push(oOperation);
6133
+ this.consumeSapAnnotation("applicable-path");
6134
+ sLabel = this.consumeSapAnnotation("label");
6135
+ if (sLabel) {
6136
+ oOperation[mV2toV4["label"].term] = sLabel;
6137
+ }
6138
+ } else {
6139
+ this.entityContainer[sName] = oOperationImport;
6140
+ this.v2annotatable(sName);
6141
+ this.convertLabel(this.oAnnotatable);
6142
+ }
6143
+ }
6144
+ this.oOperation = oOperation;
6145
+ };
6146
+ _V2MetadataConverter.prototype.processParameter = function (oElement) {
6147
+ var sLabel, oOperation = this.oOperation, oParameter = {
6148
+ $Name: oElement.getAttribute("Name")
6149
+ };
6150
+ this.processFacetAttributes(oElement, oParameter);
6151
+ this.processTypedCollection(oElement.getAttribute("Type"), oParameter);
6152
+ this.getOrCreateArray(oOperation, "$Parameter").push(oParameter);
6153
+ sLabel = this.consumeSapAnnotation("label");
6154
+ if (sLabel) {
6155
+ oParameter[mV2toV4["label"].term] = sLabel;
6156
+ }
6157
+ };
6158
+ _V2MetadataConverter.prototype.processPrincipal = function (oElement) {
6159
+ var oConstraint = this.association.referentialConstraint;
6160
+ this.constraintRole = oConstraint.principal = {
6161
+ roleName: oElement.getAttribute("Role")
6162
+ };
6163
+ };
6164
+ _V2MetadataConverter.prototype.processReferentialConstraint = function (_oElement) {
6165
+ this.association.referentialConstraint = {};
6166
+ };
6167
+ _V2MetadataConverter.prototype.processReferentialConstraintPropertyRef = function (oElement) {
6168
+ this.constraintRole.propertyRef = oElement.getAttribute("Name");
6169
+ };
6170
+ _V2MetadataConverter.prototype.processSchema = function (oElement) {
6171
+ var sSchemaVersion = this.consumeSapAnnotation("schema-version");
6172
+ this.namespace = oElement.getAttribute("Namespace") + ".";
6173
+ this.schema = {
6174
+ $kind: "Schema"
6175
+ };
6176
+ this.addToResult(this.namespace, this.schema);
6177
+ if (sSchemaVersion) {
6178
+ this.schema["@Org.Odata.Core.V1.SchemaVersion"] = sSchemaVersion;
6179
+ }
6180
+ };
6181
+ _V2MetadataConverter.prototype.processType = function (oElement, oType) {
6182
+ var sQualifiedName = this.namespace + oElement.getAttribute("Name");
6183
+ this.sTypeName = sQualifiedName;
6184
+ this.type = oType;
6185
+ this.addToResult(sQualifiedName, oType);
6186
+ this.v2annotatable(sQualifiedName);
6187
+ };
6188
+ _V2MetadataConverter.prototype.processTypedCollection = function (sType, oProperty) {
6189
+ var aMatches = this.rCollection.exec(sType);
6190
+ if (aMatches) {
6191
+ oProperty.$isCollection = true;
6192
+ sType = aMatches[1];
6193
+ }
6194
+ if (!sType.includes(".")) {
6195
+ sType = "Edm." + sType;
6196
+ }
6197
+ switch (sType) {
6198
+ case "Edm.DateTime":
6199
+ oProperty.$v2Type = sType;
6200
+ if (this.mSapAnnotations["display-format"] === "Date") {
6201
+ sType = "Edm.Date";
6202
+ delete oProperty.$Precision;
6203
+ } else {
6204
+ sType = "Edm.DateTimeOffset";
6205
+ }
6206
+ break;
6207
+ case "Edm.Float":
6208
+ oProperty.$v2Type = sType;
6209
+ sType = "Edm.Single";
6210
+ break;
6211
+ case "Edm.Time":
6212
+ oProperty.$v2Type = sType;
6213
+ sType = "Edm.TimeOfDay";
6214
+ break;
6215
+ default:
6216
+ sType = this.resolveAlias(sType);
6217
+ }
6218
+ oProperty.$Type = sType;
6219
+ };
6220
+ _V2MetadataConverter.prototype.processTypeNavigationProperty = function (oElement) {
6221
+ var sCreatable = this.consumeSapAnnotation("creatable"), sCreatablePath = this.consumeSapAnnotation("creatable-path"), sFilterable = this.consumeSapAnnotation("filterable"), oFilterablePath, vHere, sName = oElement.getAttribute("Name"), oNavigationPropertyPath, oProperty = {
6222
+ $kind: "NavigationProperty"
6223
+ }, that = this;
6224
+ function pushPropertyPath(sTerm, sProperty, oAnnotation) {
6225
+ vHere = that.getOrCreateObject(that.mEntityType2EntitySetAnnotation, that.sTypeName);
6226
+ vHere = that.getOrCreateObject(vHere, sTerm);
6227
+ vHere = that.getOrCreateArray(vHere, sProperty);
6228
+ vHere.push(oAnnotation);
6229
+ }
6230
+ this.type[sName] = oProperty;
6231
+ this.navigationProperties.push({
6232
+ associationName: this.resolveAlias(oElement.getAttribute("Relationship")),
6233
+ fromRoleName: oElement.getAttribute("FromRole"),
6234
+ property: oProperty,
6235
+ propertyName: sName,
6236
+ toRoleName: oElement.getAttribute("ToRole")
6237
+ });
6238
+ this.v2annotatable(sName);
6239
+ if (sCreatable) {
6240
+ oNavigationPropertyPath = {
6241
+ $NavigationPropertyPath: sName
6242
+ };
6243
+ if (sCreatablePath) {
6244
+ Log.warning("Inconsistent metadata in '" + this.url + "'", "Use either 'sap:creatable' or 'sap:creatable-path' at navigation property '" + this.oAnnotatable.sPath + "'", sClassName);
6245
+ } else if (sCreatable === "true") {
6246
+ oNavigationPropertyPath = null;
6247
+ }
6248
+ } else if (sCreatablePath) {
6249
+ oNavigationPropertyPath = {
6250
+ $If: [{
6251
+ $Not: {
6252
+ $Path: sCreatablePath
6253
+ }
6254
+ }, {
6255
+ $NavigationPropertyPath: sName
6256
+ }]
6257
+ };
6258
+ }
6259
+ if (oNavigationPropertyPath) {
6260
+ pushPropertyPath("@Org.OData.Capabilities.V1.InsertRestrictions", "NonInsertableNavigationProperties", oNavigationPropertyPath);
6261
+ }
6262
+ if (sFilterable === "false") {
6263
+ oFilterablePath = {
6264
+ NavigationProperty: {
6265
+ $NavigationPropertyPath: sName
6266
+ },
6267
+ FilterRestrictions: {
6268
+ Filterable: false
6269
+ }
6270
+ };
6271
+ pushPropertyPath("@Org.OData.Capabilities.V1.NavigationRestrictions", "RestrictedProperties", oFilterablePath);
6272
+ }
6273
+ };
6274
+ _V2MetadataConverter.prototype.processTypeProperty = function (oElement) {
6275
+ var oAnnotatable, sEnumMember, sFilterRestriction, vHere, sName = oElement.getAttribute("Name"), oProperty = {
6276
+ $kind: "Property"
6277
+ }, that = this;
6278
+ function pushPropertyPath(sTerm, sProperty, sAnnotation) {
6279
+ if (that.type.$kind === "EntityType") {
6280
+ vHere = that.getOrCreateObject(that.mEntityType2EntitySetAnnotation, that.sTypeName);
6281
+ vHere = that.getOrCreateObject(vHere, sTerm);
6282
+ vHere = that.getOrCreateArray(vHere, sProperty);
6283
+ vHere.push({
6284
+ $PropertyPath: sName
6285
+ });
6286
+ } else {
6287
+ Log.warning("Unsupported SAP annotation at a complex type in '" + that.url + "'", "sap:" + sAnnotation + " at property '" + oAnnotatable.sPath + "'", sClassName);
6288
+ }
6289
+ }
6290
+ this.sPropertyName = sName;
6291
+ this.type[sName] = oProperty;
6292
+ this.processFacetAttributes(oElement, oProperty);
6293
+ this.processTypedCollection(oElement.getAttribute("Type"), oProperty);
6294
+ oAnnotatable = this.v2annotatable(sName, this.convertPropertyAnnotation);
6295
+ if (oAnnotatable.consume("updatable") === "false") {
6296
+ if (oAnnotatable.consume("creatable") === "false") {
6297
+ oAnnotatable.annotate("@Org.OData.Core.V1.Computed", true);
6298
+ } else {
6299
+ oAnnotatable.annotate("@Org.OData.Core.V1.Immutable", true);
6300
+ }
6301
+ }
6302
+ if (oAnnotatable.consume("filterable") === "false") {
6303
+ pushPropertyPath("@Org.OData.Capabilities.V1.FilterRestrictions", "NonFilterableProperties", "filterable");
6304
+ }
6305
+ sFilterRestriction = oAnnotatable.consume("filter-restriction");
6306
+ if (sFilterRestriction) {
6307
+ switch (sFilterRestriction) {
6308
+ case "interval":
6309
+ sEnumMember = "SingleInterval";
6310
+ break;
6311
+ case "multi-value":
6312
+ sEnumMember = "MultiValue";
6313
+ break;
6314
+ case "single-value":
6315
+ sEnumMember = "SingleValue";
6316
+ break;
6317
+ default:
6318
+ Log.warning("Inconsistent metadata in '" + this.url + "'", "Unsupported sap:filter-restriction=\"" + sFilterRestriction + "\" at property '" + oAnnotatable.sPath + "'", sClassName);
6319
+ }
6320
+ if (sEnumMember) {
6321
+ if (this.type.$kind === "EntityType") {
6322
+ vHere = this.getOrCreateObject(this.mEntityType2EntitySetAnnotation, this.sTypeName);
6323
+ vHere = this.getOrCreateArray(vHere, "@com.sap.vocabularies.Common.v1.FilterExpressionRestrictions");
6324
+ vHere.push({
6325
+ AllowedExpressions: {
6326
+ EnumMember: "com.sap.vocabularies.Common.v1.FilterExpressionType/" + sEnumMember
6327
+ },
6328
+ Property: {
6329
+ $PropertyPath: sName
6330
+ }
6331
+ });
6332
+ } else {
6333
+ Log.warning("Unsupported SAP annotation at a complex type in '" + this.url + "'", "sap:filter-restriction at property '" + oAnnotatable.sPath + "'", sClassName);
6334
+ }
6335
+ }
6336
+ }
6337
+ if (oAnnotatable.consume("required-in-filter") === "true") {
6338
+ pushPropertyPath("@Org.OData.Capabilities.V1.FilterRestrictions", "RequiredProperties", "required-in-filter");
6339
+ }
6340
+ if (oAnnotatable.consume("sortable") === "false") {
6341
+ pushPropertyPath("@Org.OData.Capabilities.V1.SortRestrictions", "NonSortableProperties", "sortable");
6342
+ }
6343
+ };
6344
+ _V2MetadataConverter.prototype.processBoundOperations = function () {
6345
+ var that = this;
6346
+ this.aBoundOperations.forEach(function (oOperation) {
6347
+ var oEntityType = that.result[oOperation.$Parameter[0].$Type];
6348
+ oEntityType.$Key.forEach(function (sKeyName) {
6349
+ oOperation.$Parameter.some(function (oParameter, i) {
6350
+ if (oParameter.$Name === sKeyName) {
6351
+ oOperation.$Parameter.splice(i, 1);
6352
+ return true;
6353
+ }
6354
+ });
6355
+ });
6356
+ });
6357
+ };
6358
+ _V2MetadataConverter.prototype.processUnitConversion = function () {
6359
+ var that = this;
6360
+ Object.keys(this.mProperty2Unit).forEach(function (sPropertyPath) {
6361
+ var vHere, oType, sTypeName = sPropertyPath.split("/")[0], sUnitAnnotation, sUnitPath = that.mProperty2Unit[sPropertyPath], aUnitPathSegments = sUnitPath.split("/"), oUnitProperty, sUnitSemantics, i, n = aUnitPathSegments.length;
6362
+ for (i = 0; i < n; i += 1) {
6363
+ oType = that.result[sTypeName];
6364
+ oUnitProperty = oType[aUnitPathSegments[i]];
6365
+ if (!oUnitProperty) {
6366
+ Log.warning("Path '" + sUnitPath + "' for sap:unit cannot be resolved", sPropertyPath, sClassName);
6367
+ return;
6368
+ }
6369
+ if (i < n - 1) {
6370
+ sTypeName = oUnitProperty.$Type;
6371
+ }
6372
+ }
6373
+ sUnitSemantics = that.mProperty2Semantics[sTypeName + "/" + aUnitPathSegments[n - 1]];
6374
+ if (!sUnitSemantics) {
6375
+ Log.warning("Unsupported sap:semantics at sap:unit='" + sUnitPath + "'; expected 'currency-code' or 'unit-of-measure'", sPropertyPath, sClassName);
6376
+ return;
6377
+ }
6378
+ sUnitAnnotation = sUnitSemantics === "currency-code" ? "ISOCurrency" : "Unit";
6379
+ sUnitAnnotation = "@Org.OData.Measures.V1." + sUnitAnnotation;
6380
+ vHere = that.getOrCreateObject(that.result[_Helper$1.namespace(sPropertyPath) + "."], "$Annotations");
6381
+ if (that.bIgnoreAnnotations) {
6382
+ return;
6383
+ }
6384
+ vHere = that.getOrCreateObject(vHere, sPropertyPath);
6385
+ if (!((sUnitAnnotation in vHere))) {
6386
+ vHere[sUnitAnnotation] = {
6387
+ $Path: sUnitPath
6388
+ };
6389
+ }
6390
+ });
6391
+ };
6392
+ function serializeSingleElement(oElement) {
6393
+ var oAttribute, oAttributesList = oElement.attributes, sText = "<" + oElement.nodeName, i, n;
6394
+ for ((i = 0, n = oAttributesList.length); i < n; i += 1) {
6395
+ oAttribute = oAttributesList.item(i);
6396
+ sText += " " + oAttribute.name + "=\"" + oAttribute.value + "\"";
6397
+ }
6398
+ return sText + (oElement.childNodes.length ? ">" : "/>");
6399
+ }
6400
+ _V2MetadataConverter.prototype.setDefaultEntityContainer = function () {
6401
+ var sDefaultEntityContainer = this.defaultEntityContainer, aEntityContainers, oResult = this.result;
6402
+ if (sDefaultEntityContainer) {
6403
+ oResult.$EntityContainer = sDefaultEntityContainer;
6404
+ } else {
6405
+ aEntityContainers = Object.keys(oResult).filter(function (sQualifiedName) {
6406
+ return oResult[sQualifiedName].$kind === "EntityContainer";
6407
+ });
6408
+ if (aEntityContainers.length === 1) {
6409
+ oResult.$EntityContainer = aEntityContainers[0];
6410
+ }
6411
+ }
6412
+ };
6413
+ _V2MetadataConverter.prototype.updateNavigationPropertiesAndCreateBindings = function () {
6414
+ var that = this;
6415
+ this.navigationProperties.forEach(function (oNavigationPropertyData) {
6416
+ var oAssociation = that.associations[oNavigationPropertyData.associationName], oConstraint = oAssociation.referentialConstraint, oNavigationProperty = oNavigationPropertyData.property, oToRole = oAssociation.roles[oNavigationPropertyData.toRoleName];
6417
+ oNavigationProperty.$Type = oToRole.typeName;
6418
+ oToRole.propertyName = oNavigationPropertyData.propertyName;
6419
+ if (oToRole.multiplicity === "1") {
6420
+ oNavigationProperty.$Nullable = false;
6421
+ }
6422
+ if (oToRole.multiplicity === "*") {
6423
+ oNavigationProperty.$isCollection = true;
6424
+ }
6425
+ if (oConstraint && oConstraint.principal.roleName === oNavigationPropertyData.toRoleName) {
6426
+ oNavigationProperty.$ReferentialConstraint = {};
6427
+ oNavigationProperty.$ReferentialConstraint[oConstraint.dependent.propertyRef] = oConstraint.principal.propertyRef;
6428
+ }
6429
+ });
6430
+ this.associationSets.forEach(function (oAssociationSet) {
6431
+ var oAssociation = that.associations[oAssociationSet.associationName], oEntityContainer = oAssociationSet.entityContainer;
6432
+ function createNavigationPropertyBinding(oAssociationSetFrom, oAssociationSetTo) {
6433
+ var oEntitySet = oEntityContainer[oAssociationSetFrom.entitySetName], oToRole = oAssociation.roles[oAssociationSetTo.roleName];
6434
+ if (oToRole.propertyName) {
6435
+ oEntitySet.$NavigationPropertyBinding = oEntitySet.$NavigationPropertyBinding || ({});
6436
+ oEntitySet.$NavigationPropertyBinding[oToRole.propertyName] = oAssociationSetTo.entitySetName;
6437
+ }
6438
+ }
6439
+ createNavigationPropertyBinding(oAssociationSet.ends[0], oAssociationSet.ends[1]);
6440
+ createNavigationPropertyBinding(oAssociationSet.ends[1], oAssociationSet.ends[0]);
6441
+ });
6442
+ };
6443
+ _V2MetadataConverter.prototype.v2annotatable = function (sName, fnProcessV2Annotatable) {
6444
+ var oAnnotatable = new Annotatable(this, sName);
6445
+ this.oAnnotatable = oAnnotatable;
6446
+ if (fnProcessV2Annotatable) {
6447
+ fnProcessV2Annotatable = fnProcessV2Annotatable.bind(this);
6448
+ Object.keys(this.mSapAnnotations).forEach(function (sName) {
6449
+ fnProcessV2Annotatable(oAnnotatable, sName);
6450
+ });
6451
+ }
6452
+ return oAnnotatable;
6453
+ };
6454
+ _V2MetadataConverter.prototype.warnUnsupportedSapAnnotations = function (oElement) {
6455
+ Object.keys(this.mSapAnnotations).forEach(function (sName) {
6456
+ Log.warning("Unsupported annotation 'sap:" + sName + "'", serializeSingleElement(oElement), sClassName);
6457
+ });
6458
+ };
6459
+ (function ($$) {
6460
+ var oStructuredTypeConfig;
6461
+ $$.sRootNamespace = sEdmxNamespace;
6462
+ $$.oAliasConfig = {
6463
+ Reference: {
6464
+ __xmlns: _MetadataConverter.sEdmxNamespace,
6465
+ Include: {
6466
+ __processor: $$.processAlias
6467
+ }
6468
+ },
6469
+ DataServices: {
6470
+ Schema: {
6471
+ __processor: $$.processAlias
6472
+ }
6473
+ }
6474
+ };
6475
+ oStructuredTypeConfig = {
6476
+ NavigationProperty: {
6477
+ __processor: $$.processTypeNavigationProperty
6478
+ },
6479
+ Property: {
6480
+ __processor: $$.processTypeProperty
6481
+ }
6482
+ };
6483
+ $$.oFullConfig = {
6484
+ __include: [$$.oReferenceInclude],
6485
+ DataServices: {
6486
+ __processor: $$.processDataServices,
6487
+ Schema: {
6488
+ __postProcessor: $$.postProcessSchema,
6489
+ __processor: $$.processSchema,
6490
+ __include: [$$.oAnnotationsConfig],
6491
+ Association: {
6492
+ __processor: $$.processAssociation,
6493
+ End: {
6494
+ __processor: $$.processAssociationEnd
6495
+ },
6496
+ ReferentialConstraint: {
6497
+ __processor: $$.processReferentialConstraint,
6498
+ Dependent: {
6499
+ __processor: $$.processDependent,
6500
+ PropertyRef: {
6501
+ __processor: $$.processReferentialConstraintPropertyRef
6502
+ }
6503
+ },
6504
+ Principal: {
6505
+ __processor: $$.processPrincipal,
6506
+ PropertyRef: {
6507
+ __processor: $$.processReferentialConstraintPropertyRef
6508
+ }
6509
+ }
6510
+ }
6511
+ },
6512
+ ComplexType: {
6513
+ __processor: $$.processComplexType,
6514
+ __include: [oStructuredTypeConfig]
6515
+ },
6516
+ EntityContainer: {
6517
+ __processor: $$.processEntityContainer,
6518
+ AssociationSet: {
6519
+ __processor: $$.processAssociationSet,
6520
+ End: {
6521
+ __processor: $$.processAssociationSetEnd
6522
+ }
6523
+ },
6524
+ EntitySet: {
6525
+ __processor: $$.processEntitySet
6526
+ },
6527
+ FunctionImport: {
6528
+ __processor: $$.processFunctionImport,
6529
+ Parameter: {
6530
+ __processor: $$.processParameter
6531
+ }
6532
+ }
6533
+ },
6534
+ EntityType: {
6535
+ __processor: $$.processEntityType,
6536
+ __include: [oStructuredTypeConfig],
6537
+ Key: {
6538
+ PropertyRef: {
6539
+ __processor: $$.processEntityTypeKeyPropertyRef
6540
+ }
6541
+ }
6542
+ }
6543
+ }
6544
+ }
6545
+ };
6546
+ })(_V2MetadataConverter.prototype);
6547
+
6548
+ function _V4MetadataConverter() {
6549
+ this.enumType = null;
6550
+ this.enumTypeMemberCounter = 0;
6551
+ this.navigationProperty = null;
6552
+ _MetadataConverter.call(this);
6553
+ }
6554
+ _V4MetadataConverter.prototype = Object.create(_MetadataConverter.prototype);
6555
+ _V4MetadataConverter.prototype.finalize = function () {
6556
+ if (this.result.$Version !== "4.0") {
6557
+ throw new Error(this.url + ": Unsupported OData version " + this.result.$Version);
6558
+ }
6559
+ };
6560
+ _V4MetadataConverter.prototype.processActionOrFunction = function (oElement) {
6561
+ var sKind = oElement.localName, oOperation = {
6562
+ $kind: sKind
6563
+ }, aOverloads, oParametersCollection, sQualifiedName = this.namespace + oElement.getAttribute("Name"), sSignature = "", that = this;
6564
+ function getType(oParameter) {
6565
+ var oType = {};
6566
+ that.processTypedCollection(oParameter.getAttribute("Type"), oType);
6567
+ return oType.$isCollection ? "Collection(" + oType.$Type + ")" : oType.$Type;
6568
+ }
6569
+ this.processAttributes(oElement, oOperation, {
6570
+ IsBound: this.setIfTrue,
6571
+ EntitySetPath: this.setValue,
6572
+ IsComposable: this.setIfTrue
6573
+ });
6574
+ aOverloads = this.getOrCreateArray(this.result, sQualifiedName);
6575
+ if (!Array.isArray(aOverloads)) {
6576
+ aOverloads = [];
6577
+ this.addToResult(sQualifiedName, aOverloads);
6578
+ }
6579
+ aOverloads.push(oOperation);
6580
+ this.oOperation = oOperation;
6581
+ if (oOperation.$IsBound) {
6582
+ oParametersCollection = oElement.getElementsByTagName("Parameter");
6583
+ sSignature = oElement.localName === "Action" ? getType(oParametersCollection[0]) : Array.prototype.map.call(oParametersCollection, getType).join(",");
6584
+ }
6585
+ this.annotatable(sQualifiedName + "(" + sSignature + ")");
6586
+ };
6587
+ _V4MetadataConverter.prototype.processComplexType = function (oElement) {
6588
+ this.processType(oElement, {
6589
+ $kind: "ComplexType"
6590
+ });
6591
+ };
6592
+ _V4MetadataConverter.prototype.processEdmx = function (oElement) {
6593
+ this.processAttributes(oElement, this.result, {
6594
+ Version: this.setValue
6595
+ });
6596
+ };
6597
+ _V4MetadataConverter.prototype.processElement = function (oElement, fnProcessor) {
6598
+ if (fnProcessor) {
6599
+ fnProcessor.call(this, oElement);
6600
+ }
6601
+ };
6602
+ _V4MetadataConverter.prototype.processEntityContainer = function (oElement) {
6603
+ var sQualifiedName = this.namespace + oElement.getAttribute("Name");
6604
+ this.entityContainer = {
6605
+ $kind: "EntityContainer"
6606
+ };
6607
+ this.addToResult(sQualifiedName, this.entityContainer);
6608
+ this.addToResult("$EntityContainer", sQualifiedName);
6609
+ this.annotatable(sQualifiedName);
6610
+ };
6611
+ _V4MetadataConverter.prototype.processEntitySet = function (oElement) {
6612
+ var sName = oElement.getAttribute("Name");
6613
+ this.entityContainer[sName] = this.entitySet = {
6614
+ $kind: "EntitySet",
6615
+ $Type: this.resolveAlias(oElement.getAttribute("EntityType"))
6616
+ };
6617
+ this.processAttributes(oElement, this.entitySet, {
6618
+ IncludeInServiceDocument: this.setIfFalse
6619
+ });
6620
+ this.annotatable(sName);
6621
+ };
6622
+ _V4MetadataConverter.prototype.processEntityType = function (oElement) {
6623
+ this.processType(oElement, {
6624
+ $kind: "EntityType"
6625
+ });
6626
+ };
6627
+ _V4MetadataConverter.prototype.processEntityTypeKeyPropertyRef = function (oElement) {
6628
+ var sAlias = oElement.getAttribute("Alias"), vKey, sName = oElement.getAttribute("Name");
6629
+ if (sAlias) {
6630
+ vKey = {};
6631
+ vKey[sAlias] = sName;
6632
+ } else {
6633
+ vKey = sName;
6634
+ }
6635
+ this.getOrCreateArray(this.type, "$Key").push(vKey);
6636
+ };
6637
+ _V4MetadataConverter.prototype.processEnumType = function (oElement) {
6638
+ var sQualifiedName = this.namespace + oElement.getAttribute("Name"), oEnumType = {
6639
+ $kind: "EnumType"
6640
+ };
6641
+ this.processAttributes(oElement, oEnumType, {
6642
+ IsFlags: this.setIfTrue,
6643
+ UnderlyingType: function (sValue) {
6644
+ return sValue !== "Edm.Int32" ? sValue : undefined;
6645
+ }
6646
+ });
6647
+ this.enumType = oEnumType;
6648
+ this.addToResult(sQualifiedName, oEnumType);
6649
+ this.enumTypeMemberCounter = 0;
6650
+ this.annotatable(sQualifiedName);
6651
+ };
6652
+ _V4MetadataConverter.prototype.processEnumTypeMember = function (oElement) {
6653
+ var sName = oElement.getAttribute("Name"), sValue = oElement.getAttribute("Value"), vValue;
6654
+ if (sValue) {
6655
+ vValue = parseInt(sValue);
6656
+ if (!_Helper$1.isSafeInteger(vValue)) {
6657
+ vValue = sValue;
6658
+ }
6659
+ } else {
6660
+ vValue = this.enumTypeMemberCounter;
6661
+ this.enumTypeMemberCounter += 1;
6662
+ }
6663
+ this.enumType[sName] = vValue;
6664
+ this.annotatable(sName);
6665
+ };
6666
+ _V4MetadataConverter.prototype.processFacetAttributes = function (oElement, oResult) {
6667
+ var that = this;
6668
+ this.processAttributes(oElement, oResult, {
6669
+ MaxLength: function (sValue) {
6670
+ return sValue === "max" ? undefined : that.setNumber(sValue);
6671
+ },
6672
+ Precision: this.setNumber,
6673
+ Scale: function (sValue) {
6674
+ return sValue === "variable" ? sValue : that.setNumber(sValue);
6675
+ },
6676
+ SRID: this.setValue,
6677
+ Unicode: this.setIfFalse
6678
+ });
6679
+ };
6680
+ _V4MetadataConverter.prototype.processImport = function (oElement) {
6681
+ var sKind = oElement.localName, oImport = {
6682
+ $kind: sKind
6683
+ }, sName = oElement.getAttribute("Name"), that = this;
6684
+ sKind = sKind.replace("Import", "");
6685
+ oImport["$" + sKind] = this.resolveAlias(oElement.getAttribute(sKind));
6686
+ this.processAttributes(oElement, oImport, {
6687
+ EntitySet: function (sValue) {
6688
+ return that.resolveTargetPath(sValue);
6689
+ },
6690
+ IncludeInServiceDocument: this.setIfTrue
6691
+ });
6692
+ this.entityContainer[sName] = oImport;
6693
+ this.annotatable(sName);
6694
+ };
6695
+ _V4MetadataConverter.prototype.processNavigationPropertyBinding = function (oElement) {
6696
+ var oNavigationPropertyBinding = this.getOrCreateObject(this.entitySet, "$NavigationPropertyBinding");
6697
+ oNavigationPropertyBinding[oElement.getAttribute("Path")] = this.resolveTargetPath(oElement.getAttribute("Target"));
6698
+ };
6699
+ _V4MetadataConverter.prototype.processParameter = function (oElement) {
6700
+ var oActionOrFunction = this.oOperation, oParameter = {};
6701
+ this.processTypedCollection(oElement.getAttribute("Type"), oParameter);
6702
+ this.processAttributes(oElement, oParameter, {
6703
+ Name: this.setValue,
6704
+ Nullable: this.setIfFalse
6705
+ });
6706
+ this.processFacetAttributes(oElement, oParameter);
6707
+ this.getOrCreateArray(oActionOrFunction, "$Parameter").push(oParameter);
6708
+ this.annotatable(oParameter.$Name);
6709
+ };
6710
+ _V4MetadataConverter.prototype.processReturnType = function (oElement) {
6711
+ var oActionOrFunction = this.oOperation, oReturnType = {};
6712
+ this.processTypedCollection(oElement.getAttribute("Type"), oReturnType);
6713
+ this.processAttributes(oElement, oReturnType, {
6714
+ Nullable: this.setIfFalse
6715
+ });
6716
+ this.processFacetAttributes(oElement, oReturnType);
6717
+ oActionOrFunction.$ReturnType = oReturnType;
6718
+ this.annotatable("$ReturnType");
6719
+ };
6720
+ _V4MetadataConverter.prototype.processSchema = function (oElement) {
6721
+ this.namespace = oElement.getAttribute("Namespace") + ".";
6722
+ this.schema = {
6723
+ $kind: "Schema"
6724
+ };
6725
+ this.addToResult(this.namespace, this.schema);
6726
+ this.annotatable(this.schema);
6727
+ };
6728
+ _V4MetadataConverter.prototype.processSingleton = function (oElement) {
6729
+ var sName = oElement.getAttribute("Name");
6730
+ this.entityContainer[sName] = this.entitySet = {
6731
+ $kind: "Singleton",
6732
+ $Type: this.resolveAlias(oElement.getAttribute("Type"))
6733
+ };
6734
+ this.annotatable(sName);
6735
+ };
6736
+ _V4MetadataConverter.prototype.processTerm = function (oElement) {
6737
+ var sQualifiedName = this.namespace + oElement.getAttribute("Name"), oTerm = {
6738
+ $kind: "Term"
6739
+ }, that = this;
6740
+ this.processTypedCollection(oElement.getAttribute("Type"), oTerm);
6741
+ this.processAttributes(oElement, oTerm, {
6742
+ Nullable: this.setIfFalse,
6743
+ BaseTerm: function (sValue) {
6744
+ return sValue ? that.resolveAlias(sValue) : undefined;
6745
+ }
6746
+ });
6747
+ this.processFacetAttributes(oElement, oTerm);
6748
+ this.addToResult(sQualifiedName, oTerm);
6749
+ this.annotatable(sQualifiedName);
6750
+ };
6751
+ _V4MetadataConverter.prototype.processType = function (oElement, oType) {
6752
+ var sQualifiedName = this.namespace + oElement.getAttribute("Name"), that = this;
6753
+ this.processAttributes(oElement, oType, {
6754
+ OpenType: that.setIfTrue,
6755
+ HasStream: that.setIfTrue,
6756
+ Abstract: that.setIfTrue,
6757
+ BaseType: function (sType) {
6758
+ return sType ? that.resolveAlias(sType) : undefined;
6759
+ }
6760
+ });
6761
+ this.type = oType;
6762
+ this.addToResult(sQualifiedName, oType);
6763
+ this.annotatable(sQualifiedName);
6764
+ };
6765
+ _V4MetadataConverter.prototype.processTypedCollection = function (sType, oProperty) {
6766
+ var aMatches = this.rCollection.exec(sType);
6767
+ if (aMatches) {
6768
+ oProperty.$isCollection = true;
6769
+ sType = aMatches[1];
6770
+ }
6771
+ oProperty.$Type = this.resolveAlias(sType);
6772
+ };
6773
+ _V4MetadataConverter.prototype.processTypeDefinition = function (oElement) {
6774
+ var sQualifiedName = this.namespace + oElement.getAttribute("Name"), oTypeDefinition = {
6775
+ $kind: "TypeDefinition",
6776
+ $UnderlyingType: oElement.getAttribute("UnderlyingType")
6777
+ };
6778
+ this.addToResult(sQualifiedName, oTypeDefinition);
6779
+ this.processFacetAttributes(oElement, oTypeDefinition);
6780
+ this.annotatable(sQualifiedName);
6781
+ };
6782
+ _V4MetadataConverter.prototype.processTypeNavigationProperty = function (oElement) {
6783
+ var sName = oElement.getAttribute("Name"), oProperty = {
6784
+ $kind: "NavigationProperty"
6785
+ };
6786
+ this.processTypedCollection(oElement.getAttribute("Type"), oProperty);
6787
+ this.processAttributes(oElement, oProperty, {
6788
+ Nullable: this.setIfFalse,
6789
+ Partner: this.setValue,
6790
+ ContainsTarget: this.setIfTrue
6791
+ });
6792
+ this.type[sName] = this.navigationProperty = oProperty;
6793
+ this.annotatable(sName);
6794
+ };
6795
+ _V4MetadataConverter.prototype.processTypeNavigationPropertyOnDelete = function (oElement) {
6796
+ this.navigationProperty.$OnDelete = oElement.getAttribute("Action");
6797
+ this.annotatable(this.navigationProperty, "$OnDelete");
6798
+ };
6799
+ _V4MetadataConverter.prototype.processTypeNavigationPropertyReferentialConstraint = function (oElement) {
6800
+ var sProperty = oElement.getAttribute("Property"), oReferentialConstraint = this.getOrCreateObject(this.navigationProperty, "$ReferentialConstraint");
6801
+ oReferentialConstraint[sProperty] = oElement.getAttribute("ReferencedProperty");
6802
+ this.annotatable(oReferentialConstraint, sProperty);
6803
+ };
6804
+ _V4MetadataConverter.prototype.processTypeProperty = function (oElement) {
6805
+ var sName = oElement.getAttribute("Name"), oProperty = {
6806
+ $kind: "Property"
6807
+ };
6808
+ this.processTypedCollection(oElement.getAttribute("Type"), oProperty);
6809
+ this.processAttributes(oElement, oProperty, {
6810
+ Nullable: this.setIfFalse,
6811
+ DefaultValue: this.setValue
6812
+ });
6813
+ this.processFacetAttributes(oElement, oProperty);
6814
+ this.type[sName] = oProperty;
6815
+ this.annotatable(sName);
6816
+ };
6817
+ _V4MetadataConverter.prototype.resolveTargetPath = function (sPath) {
6818
+ var iSlash;
6819
+ if (!sPath) {
6820
+ return sPath;
6821
+ }
6822
+ sPath = this.resolveAliasInPath(sPath);
6823
+ iSlash = sPath.indexOf("/");
6824
+ if (iSlash >= 0 && !sPath.includes("/", iSlash + 1)) {
6825
+ if (sPath.slice(0, iSlash) === this.result.$EntityContainer) {
6826
+ return sPath.slice(iSlash + 1);
6827
+ }
6828
+ }
6829
+ return sPath;
6830
+ };
6831
+ (function ($$) {
6832
+ var oActionOrFunctionConfig, oEntitySetConfig, oStructuredTypeConfig;
6833
+ $$.sRootNamespace = $$.sEdmxNamespace;
6834
+ $$.oAliasConfig = {
6835
+ __xmlns: $$.sEdmxNamespace,
6836
+ Reference: {
6837
+ Include: {
6838
+ __processor: $$.processAlias
6839
+ }
6840
+ },
6841
+ DataServices: {
6842
+ Schema: {
6843
+ __xmlns: $$.sEdmNamespace,
6844
+ __processor: $$.processAlias
6845
+ }
6846
+ }
6847
+ };
6848
+ oStructuredTypeConfig = {
6849
+ Property: {
6850
+ __processor: $$.processTypeProperty,
6851
+ __include: [$$.oAnnotationConfig]
6852
+ },
6853
+ NavigationProperty: {
6854
+ __processor: $$.processTypeNavigationProperty,
6855
+ __include: [$$.oAnnotationConfig],
6856
+ OnDelete: {
6857
+ __processor: $$.processTypeNavigationPropertyOnDelete,
6858
+ __include: [$$.oAnnotationConfig]
6859
+ },
6860
+ ReferentialConstraint: {
6861
+ __processor: $$.processTypeNavigationPropertyReferentialConstraint,
6862
+ __include: [$$.oAnnotationConfig]
6863
+ }
6864
+ }
6865
+ };
6866
+ oEntitySetConfig = {
6867
+ NavigationPropertyBinding: {
6868
+ __processor: $$.processNavigationPropertyBinding
6869
+ }
6870
+ };
6871
+ oActionOrFunctionConfig = {
6872
+ Parameter: {
6873
+ __processor: $$.processParameter,
6874
+ __include: [$$.oAnnotationConfig]
6875
+ },
6876
+ ReturnType: {
6877
+ __processor: $$.processReturnType,
6878
+ __include: [$$.oAnnotationConfig]
6879
+ }
6880
+ };
6881
+ $$.oFullConfig = {
6882
+ __xmlns: $$.sEdmxNamespace,
6883
+ __processor: $$.processEdmx,
6884
+ __include: [$$.oReferenceInclude],
6885
+ DataServices: {
6886
+ Schema: {
6887
+ __xmlns: $$.sEdmNamespace,
6888
+ __processor: $$.processSchema,
6889
+ __include: [$$.oAnnotationsConfig, $$.oAnnotationConfig],
6890
+ Action: {
6891
+ __processor: $$.processActionOrFunction,
6892
+ __include: [oActionOrFunctionConfig, $$.oAnnotationConfig]
6893
+ },
6894
+ Function: {
6895
+ __processor: $$.processActionOrFunction,
6896
+ __include: [oActionOrFunctionConfig, $$.oAnnotationConfig]
6897
+ },
6898
+ EntityType: {
6899
+ __processor: $$.processEntityType,
6900
+ __include: [oStructuredTypeConfig, $$.oAnnotationConfig],
6901
+ Key: {
6902
+ PropertyRef: {
6903
+ __processor: $$.processEntityTypeKeyPropertyRef
6904
+ }
6905
+ }
6906
+ },
6907
+ ComplexType: {
6908
+ __processor: $$.processComplexType,
6909
+ __include: [oStructuredTypeConfig, $$.oAnnotationConfig]
6910
+ },
6911
+ EntityContainer: {
6912
+ __processor: $$.processEntityContainer,
6913
+ __include: [$$.oAnnotationConfig],
6914
+ ActionImport: {
6915
+ __processor: $$.processImport,
6916
+ __include: [$$.oAnnotationConfig]
6917
+ },
6918
+ EntitySet: {
6919
+ __processor: $$.processEntitySet,
6920
+ __include: [oEntitySetConfig, $$.oAnnotationConfig]
6921
+ },
6922
+ FunctionImport: {
6923
+ __processor: $$.processImport,
6924
+ __include: [$$.oAnnotationConfig]
6925
+ },
6926
+ Singleton: {
6927
+ __processor: $$.processSingleton,
6928
+ __include: [oEntitySetConfig, $$.oAnnotationConfig]
6929
+ }
6930
+ },
6931
+ EnumType: {
6932
+ __processor: $$.processEnumType,
6933
+ __include: [$$.oAnnotationConfig],
6934
+ Member: {
6935
+ __processor: $$.processEnumTypeMember,
6936
+ __include: [$$.oAnnotationConfig]
6937
+ }
6938
+ },
6939
+ Term: {
6940
+ __processor: $$.processTerm,
6941
+ __include: [$$.oAnnotationConfig]
6942
+ },
6943
+ TypeDefinition: {
6944
+ __processor: $$.processTypeDefinition,
6945
+ __include: [$$.oAnnotationConfig]
6946
+ }
6947
+ }
6948
+ }
6949
+ };
6950
+ })(_V4MetadataConverter.prototype);
6951
+
6952
+ export { Applier, ApplyUtil, Change, RegistrationBuild$1 as RegistrationBuild, URI, _V2MetadataConverter as V2MetadataConverter, _V4MetadataConverter as V4MetadataConverter };